Programming for experts
P.
113 of 349
Convert the consumption in kWh
and on the webserver as a string –
link (note: the “+” sign)
if systemstart() then {
weboutput(Out2,$ <table border="1"><tr> <td class="oben"> <img src="/upload/effb.jpg"
alt="Bild fehl"></td> <td class="mittig"><b>Das ist ziemlich wenig! </b><br> Super Sache,
wenn wenig Energie im <br> Haus verbraucht wird. <br>Freut sich der Geldbeutel und der
<br> <b> Hausbesitzer</b>!</td></tr></table>$)
} endif
The output can be made depended of current values e.g. meter readings of an KNX device, which is
shown in the following.
An engery meter sends via the GA "Energy-2/3/5“,"Energy-2/3/6“ "Energy-2/3/7“ of type u32 the
consumption in Wh. We first define the variables in kWh as a string (c.1400).
ConsumptionOG_kWh=convert(convert("Energy-2/3/5",1f32)/1000f32,$$)
ConsumptionEG_kWh=convert(convert("Energy-2/3/6"1f32)/1000f32,$$)
ConsumptionUG_kWh=convert(convert("Energy-2/3/7",1f32)/1000f32,$$)
Sum_kWh= convert(convert("Energy-2/3/7“+"Energy-2/3/6"+"Energy-2/3/5“,1f32)/1000f32,$$)
At twelve o'clock the values should be displayed daily:
if htime(12,0,0) then {
weboutput(Out1,$<h4>Berechnung der <i>Energieeffizienz</i></h4> <ul style="list-
style-type:disc"> <li>Obergeschoß: $+ Verbrauch$ kWh</li> <li>
Untergeschoß: $+Verbrauc$ kWh </li> <li> Erdschoß: $
+Verbrauc$ kWh </li> </ul> _______________________ <br> Summe:$
+Su$ kWh $c10000)
} endif
Depending on the actual transmitted values, the display will be on the web server (compare with
Abbildung 3):
Abbildung 3: Dynamische Ausgabe
In the code section the HTML string is made of substrings by the use of concatenation (“+”-Signs). It
is important to ensure, that the concatention produces the matching string length. The function
weboutput can transfer up to 65564 bytes to weboutput-element. The concatenation consists only of
$$ (=c1400) and one c10000 string. The string concatenation reserves for the result the number of
bytes, such as the “longest” string-argument is predented.In this case it makes 10.000 bytes, which
are given through the one c10000 string in the code (shown above).
At this point it should be said, that special signs could be composed of multiple bytes, as already
described on P. 108. The concatenation could bring theoretically more than 10000 bytes as a result,
if the strings exhaust the full length of their definition. In this case the “overlaying” signs cannot
respect the concatenation function and accordingly the concatenation function is going to cut the
signs of the string before copying into the result. It is up to the User if he respects it. (compare with p.
109).
For reasons of clarity the HTML code can although be outsourced in a own data. To this you work
with the #include-directive (compare with p. 128).
Back to the example:
The most users don't like the output representation of the exponential floating-point representation.
Therefore the representation of values should be more readable with the function
stringformat
. This
function changes a number into a string - whereupon leading zeros and the indicated accuracy and
floating-point representation can be parameterized.
HandbuchEibPC_USA-30.odt, 2017-05-11
Enertex
®
Bayern GmbH - Erlachstraße 13 - 91301 Forchheim - [email protected]