Math: Some examples
From bab-tec.de wiki
This examples are showing how the functions, variables and operations are insert into the mathematical expression:
- „eo(1) + 100“ => Returns the value of the KNX-object with the number 1 (mentioned as EO_1 in the following) plus 100. Of course it is important to consider the possible range of KNX-output objects!
- „eo(3)*eo(4)“ => Multiplies EO_3 and EO_4. If there is no group address assigned to a KNX-object an error is been dropped.
- „100 / eo(1)“ => Divides 100 by EO_1. Attention: If a zero is been sent on input 1, the calculation of this expression delivers a run-time-error! ("Division by zero").
- „sqrt(eo(0)^2+eo(1)^2)“ => Is calculating the length of the hypotenuse in a right angled triangle, if on EO_0 and EO_1 the length of the cathetus is been sent. ("Pythagorean theorem")
- „eoi()“ => Returns 2, if on the KNX-Object with the number 2 is received something.
- „eo(eoi())“ => Returns the received value.
- „eo(eoi())^2“ => Is calculating the square of the received telegram value.
- „rand()“ => Returns a random value.
- „rand() & 0xff“ => Limits this value from 0 to maximum 255. So the result can be displayed with EIS 14.
- „srand(time())“ => Returns nothing (resp. zero), but initiate the random generator with a pseudo-random start value.
- „eo(0)+eo(2)+eo(3)+eo(1)+eo(5)+eo(6)+eo(4)“ => Is calculating the sum of multiple KNX-Objects.
- „eo_sum(0,1,2,3,4,5,6)“ => Like above, but much more "runtime friendlier" and insightful.
- „"foo" + "bar"“ => Returns "foobar" as result. This can only be sent as EIS 15 on the output.
- „eo(0)>23?1:0“ => Returns 1 if the value of the input object is above 23 (degrees EIS 5) and 0 if the value is smaller or equal than 23.
- „eo_ga(0,1)“ => Returns the second group address in the first input object (eo(0)) as unformatted number.
- „ga_str(0,2)“ => Returns the group address of the input 1 as string (EIS 15 text) in two digit notation on the output. "...(0,3)" returns the address in three digit notation.
- „str_ga("17/1/2")“ => Returns the number "35074" on the output.
- „override_addr=(eo(0)>10?61482:61480); eo(0)>10?1:0“ => Sends 1 on the address 30/0/42 if the input value is larger than 10, and 0 on the address 30/0/42 if the input value is smaller than 10.
- „override_addr=(eo(0)>10?61482:61480); override_eis=(eo(0)>10?1:9); eo(0)>10?1:2400“ => Sends 1 as EIS 1 (1bit) on the address 30/0/42 if the input value eo(0) is larger than 10, and sends 2400 as EIS 9 (4byte) on the address 30/0/40 if the input value is smaller than 10.
- „override_addr=(5<<11) | (1<<8) | eo(0); 1“ => sends value '1' to the group address 5/1/x, where x is the value of eo(0)
- „override_skip_send=(eo(0)>10?1:0)“ => Is the input value of eo(0) smaller than 10, a 0 is been sent on the output, if the value is larger than 10 the jobs sends nothing.
- „x=(eo(0)>10?1:0); override_keep_data=x“ => Returns a output value from 0 to 10 or the value of the triggering input telegram.
- „version()“ => Returns the current version number of the math job with a arbitrary input telegram.