Data Source Value Calculation Engine

Plugins skapade av Switch Kings användare | Plugins created by Switch King users
tomas
Administrator
Administrator
Posts: 419
Joined: Tue 09 Nov 2010, 20:41

Data Source Value Calculation Engine

Post by tomas » Wed 18 Feb 2015, 23:01

This plugin is used to perform various calculations (see below) on data source values and output the result to one or more other data sources.

The following calculations are currently supported:
  • Dew point temperature ("daggpunktstemperatur") [°C]
  • Difference between air tempeature and dew point temperature [°C]
  • Current water vapor content ("ånghalt") [g/m3]
The data source value(s) holding the result can be used when defining rules for group schedules. Examples of usage:
- Control fans for attic ventilation
- Control dehumidifier ("avfuktare") for a suspended house foundation ("krypgrund")
- Other stuff yet to explore :)

Instructions
- Put the files in the Binaries folder (found in the zip file) in the Plugins folder where the Switch King Server is installed.
- Open the DSVCalcEnginePlugin.dll.config file (using e.g. Notepad) and update the key values (see below).
- (Leave the key values empty for calculations you are not using)
- Restart the Switch King Server

Create new data source(s) to publish the results from the calculation:
- Select File > New > Data Source
- Select option "Values provided from external system"
- Configure the remaining options for the data source at will and finish
- Open the newly created data source and make a note of the Data Source ID found on the General tab
- Use this ID in the .config file to save the results from the calculation
(Use the same approach to find out the Data Source IDs for your data sources on which to perform the calculation.)

Dew point temperature
This function calculates the dew point temperature using air temperature and humidity as input.

Definition:

Code: Select all

Tc: Air temperature (°C)
Rh: Relative humidity (0-100%)
Td: Dew point temperature (°C)

if (Rh > 85.0)
{
   Td = Tc - 0.133 * (100.0 - Rh);
}
else
{
   Td = Tc - 0.2 * (95.0 - Rh);
}
Configuration:

Code: Select all

<add key="Dewpoint" value="i[Tc]:i[Rh]:o[Td]"/>
Replace Tc, Rh and Td with corresponding data source IDs, example:
<add key="Dewpoint" value="i1:i2:o3"/>
Difference between air temperature and dew point temperature
This function calculates the difference between the air temperature and the dew point temperature using air temperature and humidity as input.

Definition:

Code: Select all

Tc: Air temperature (°C)
Rh: Relative humidity (0-100%)
Td: Dew point temperature (°C)
Tdiff: Difference between Tc and Td (°C)

Tdiff = Tc - Td
(Rh is used to calculate Td using code defined for Dew point temperature.)
Configuration:

Code: Select all

<add key="DewpointDiff" value="i[Tc]:i[Rh]:o[Tdiff]"/>
Replace Tc, Rh and Td with corresponding data source IDs, example:
<add key="DewpointDiff" value="i1:i2:o3"/>
Current water vapor content
This function calculates the current amount of water content in vapor ("ånghalt") using air temperature and humidity as input.

Definition:

Code: Select all

Tc: Air temperature (°C)
Tk: Air temperature (Kelvin)
Rh: Relative humidity (0-100%)
v: Water vapor content (g/m3)

Tk = Tc + 273.2
//Maximum water vapor content
vs = (1.32 / Tk) * Math.Pow((1 + 0.02 * (Tk - 273.2)), 4) * 1000
//Current water vapor content
v = Rh * (vs / 100)
Configuration:

Code: Select all

<add key="WaterVapor" value="i[Tc]:i[Rh]:o[v]"/>
Replace Tc, Rh and Td with corresponding data source IDs, example:
<add key="WaterVapor" value="i1:i2:o3"/>
Source code and Binaries are included in the zip file.

Source code is available for further development:
Search for "#mycalc" in the code for Plugin.cs to find out where to add code for your own calculation.
You may add any number of inputs, outputs and constants in the configuration key. The plugin will parse the value string from left so the order of the items are important.
The output data sources are not updated until the plugin has recorded updates of all input data sources (from the Switch King Server was started).
Example:
value="i10:i11:c1.25:i35:o14:o17"

It is possible to perform multiple calculations for the same function by using the pipe character in the value string.
Example:
value="i10:i11:c1.25:i35:o14:o17|i20:i21:c0.45:i45:o24:o27"

It is highly appreciated if you share your contributions with the community. Thanks!

Filename: DSVCalcEnginePlugin_0.1.zip
Version: 0.1
Date: 2015-02-18
Requirements: Switch King Server v 3.2.3 and later
Developer: Switch King
DSVCalcEnginePlugin_0.1.zip
@krambriw, tack för att du delat med dig av beräkningarna!

(Det går bra att posta frågor/kommentarer på svenska också i denna tråden.)
You do not have the required permissions to view the files attached to this post.
Tomas | Switch King

tomas
Administrator
Administrator
Posts: 419
Joined: Tue 09 Nov 2010, 20:41

Re: Data Source Value Calculation Engine

Post by tomas » Sat 21 Feb 2015, 10:52

Finns det fler beräkningar som kan vara av intresse för hemautomation?

Finns det någon generell beräkning för COP till exempel?
Tomas | Switch King

krambriw
4 stars
4 stars
Posts: 336
Joined: Thu 19 Jul 2012, 19:41

Re: Data Source Value Calculation Engine

Post by krambriw » Sun 22 Feb 2015, 08:03

Finns det någon generell beräkning för COP till exempel?
Generellt så är COP ett värde beräknat som avgiven energi/inmatad energi.

Så för tex FLVP värmepumpar (frånluftsvärmepumpar) brukar COP värden på 3 anses vara bra, LLVP (luft-luft) brukar kunna komma upp i 4-5 men då endast om inte utetemperaturen är väldigt låg. När man beräknar COP för en värmepump anser en del (däribland jag) att man skall dra bort 'tomgångseffekten', dvs den som alltid behövs för att driva fläktar, pumpar och annan elektronik, oavsett om kompressorn går eller ej, från den totala energin som behövs för att driva utrustningen. Som exempel har vi en Comfortzone FLVP. Den drar cirka 110 W på "tomgång". När kompressorn startar, dvs då återvinning pågär, så ökar förbrukningen och man kan då jämföra med avgiven effekt/energi. Detta förutsätter naturligtvis att man har separat elmätare för värmepumpen och att man kan lita på informationen från pumpen om avgiven effekt/energi. Vi brukar ha COP på runt 3,3 vid uppvärmning av radiatorkretsen och betydligt lägre för VV produktionen.

mvh

Jarina
2 stars
2 stars
Posts: 32
Joined: Tue 19 Nov 2013, 18:52

Re: Data Source Value Calculation Engine

Post by Jarina » Thu 12 Mar 2015, 22:31

Jag förstår inte var jag ska stoppa in de olika kod exemplen

jag öppnar config filen i notepad:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<!-- Performs calculations based on data source values and saves result in other data source(s). -->
<!-- See http://www.switchking.se/forum/viewtopi ... =23&t=1684 for more information. -->
<!-- Username: Your user name for the REST interface in Switch King. -->
<!-- Password: Your password for the REST interface in Switch King. -->
<!-- Port: Port used for the REST interface in Switch King (default 8800) -->
<add key="Dewpoint" value=""/>
<add key="DewpointDiff" value=""/>
<add key="WaterVapor" value=""/>
<add key="MyCalc" value=""/>
<add key="Username" value="user"/>
<add key="Password" value="pass"/>
<add key="Port" value="8800"/>
</appSettings>
</configuration>
Men var ska detta in:
Dew point temperature
This function calculates the dew point temperature using air temperature and humidity as input.

Definition:
CODE: SELECT ALL
Tc: Air temperature (°C)
Rh: Relative humidity (0-100%)
Td: Dew point temperature (°C)

if (Rh > 85.0)
{
Td = Tc - 0.133 * (100.0 - Rh);
}
else
{
Td = Tc - 0.2 * (95.0 - Rh);
}

Configuration:
CODE: SELECT ALL
<add key="Dewpoint" value="i[Tc]:i[Rh]:o[Td]"/>
Replace Tc, Rh and Td with corresponding data source IDs, example:
<add key="Dewpoint" value="i1:i2:o3"/>


Difference between air temperature and dew point temperature
This function calculates the difference between the air temperature and the dew point temperature using air temperature and humidity as input.

Definition:
CODE: SELECT ALL
Tc: Air temperature (°C)
Rh: Relative humidity (0-100%)
Td: Dew point temperature (°C)
Tdiff: Difference between Tc and Td (°C)

Tdiff = Tc - Td
(Rh is used to calculate Td using code defined for Dew point temperature.)

Configuration:
CODE: SELECT ALL
<add key="DewpointDiff" value="i[Tc]:i[Rh]:o[Tdiff]"/>
Replace Tc, Rh and Td with corresponding data source IDs, example:
<add key="DewpointDiff" value="i1:i2:o3"/>

tomas
Administrator
Administrator
Posts: 419
Joined: Tue 09 Nov 2010, 20:41

Re: Data Source Value Calculation Engine

Post by tomas » Mon 16 Mar 2015, 23:39

Hej Jarina,

Om du t ex vill räkna ut Dewpoint så behöver du bara ange vilka datakällor som ska kopplas till den beräkningen i config-filen. Själva beräkningen tar sedan pluginet hand om.

Modifiera denna raden i config-filen:
<add key="Dewpoint" value=""/>

Till t ex:
<add key="Dewpoint" value="i7:i4:o12"/>

I Switch King behöver du då ha datakällor med motsvarande ID (Tc sparat i datakälla med ID = 7 osv).
Tomas | Switch King

sneip
1 star
1 star
Posts: 4
Joined: Mon 30 Dec 2013, 14:16

Re: Data Source Value Calculation Engine

Post by sneip » Wed 08 Apr 2015, 11:51

hej!

Jag lyckas läga till 1st som räknar ut ånghalten, men nu vill jag lägga till 5st och det får jag inta att fungera??
hur skrivar man in detta? har provat en massa olika sätt men ej fått det att funka...

MVH Mattias
Tack på förhand!

tomas
Administrator
Administrator
Posts: 419
Joined: Tue 09 Nov 2010, 20:41

Re: Data Source Value Calculation Engine

Post by tomas » Wed 08 Apr 2015, 20:18

Hej,

Det ska fungera att lägga till flera beräkningar genom att separera med pipe-tecken.

Här är ett exempel för 1 st beräkning:
<add key="WaterVapor" value="i1:i2:o3"/>

Här är ett exempel för 2 st beräkningar:
<add key="WaterVapor" value="i1:i2:o3|i14:i15:o16"/>

Tänk också på att det måste ha kommit in uppdateringar av ingående datakällor till Switch King innan beräkningen utförs.
Tomas | Switch King

sneip
1 star
1 star
Posts: 4
Joined: Mon 30 Dec 2013, 14:16

Re: Data Source Value Calculation Engine

Post by sneip » Thu 09 Apr 2015, 19:05

Hej!

så här ser min config ut:

<add key="Dewpoint" value="i6:i7:o37|i28:i27:o38"/>
<add key="DewpointDiff" value=""/>
<add key="WaterVapor" value="i11:i10:o32|i28:i27:o36|i8:i9:o33|i26:i25:o35|i6:i7:o34"/>

Men den vill ej funka, och ingående datakällor var uppdaterade....

Mattias

tomas
Administrator
Administrator
Posts: 419
Joined: Tue 09 Nov 2010, 20:41

Re: Data Source Value Calculation Engine

Post by tomas » Sun 12 Apr 2015, 16:36

Config:en ser rätt ut.

Fungerar Dewpoint som den ska med 2 st värden?

i6, i7, i27 & i28 ingår både i Dewpoint och WaterVapor. Det borde funka, men du kan ju prova att lägga till en i taget för WaterVapor och testa. Lägg till de med i6, i7, i27 och i28 sist i så fall.
Tomas | Switch King

sneip
1 star
1 star
Posts: 4
Joined: Mon 30 Dec 2013, 14:16

Re: Data Source Value Calculation Engine

Post by sneip » Mon 13 Apr 2015, 22:43

Hej

Nej det är bara den ena Dewpoint som fungerar, och en WaterVapor, lyckas du att få flera värden?

Mvh Mattias

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests