Programming for experts
P.
116 of 349
Write a value and the timestamp in
the memory of time series
Writing a new value automatically
updates the linked webelement
Values from the past show ...
... or compare with the past
The readability of the code is increased, if we specify in the above example as the last argument the to be stored
variable or group address. This is not absolutely necessary e.g.
timebufferconfig
(ChartBuffer1, MemTyp, Len, 2.2f16)
or
timebufferconfig
(ChartBuffer2, MemTyp, Len,2) would also configure the timebuffer correctly.
With the configuration of the timebuffer to the webelement mtimechart the memory of the time series
(timebuffer) is submitted for presentation by configuring their ID (=handle, acces of number). In this
case the webelement accesses always out the last valid data in the memory.
Now the time series must be “filled” with data. The function
timebufferadd
(
ChartBufferID, Daten
)
completes this task. The function writes the current value of the variable or group address (
data
) as
well as the timestamp, which is derived from system time of the Enertex® EibPC, in the memory of
the selected time series. So there a time series exists exactly out of a combination value-timestamp.
Values can be up to 4 bytes long. Timestamps internally nedd 8 bytes.
Picture 7:Building of time series (timebuffer)
As Picture 7 should suggest, it is not necessarily so that the values in the timebuffer in the same
interval have to be included, although this can often be the case when logging of energy data. The
webelement mtimechart evaluates correctly the timestamp.
If the argument
MemTyp
from
timebufferconfig
was defined as a ring[store] so after reaching the last
value the memory will be filled again from the beginning. i.e. the oldest value is replaces with the
latest. Is
MemTyp
defined as linear[memory] then the recording stops if the memory is full
With a timeseries of linked diagram are automatically updated in the visualization i.e. it can be
represented basically the same time series in different diagrams. For example writing every 15
minutes a value in the buffer and indicating the most recent 192 values in our diagram, you only
need the following code:
// Werte in den Buffer schreiben
if mtime(0,0) or mtime(15,0) or mtime(30,0) or mtime(45,0) then {
timebufferadd(ChartBuffer0,"Temperature-1/2/3");
timebufferadd(ChartBuffer1,"Controll-1/2/4");
} endif
With
timebuffersize
(
ChartBufferID
)
the level of buffer can be accessed at any time.
The mtimechart webelement now displays 192 values, which is equivalent to a period of 2 days. Our
buffer has space for 35040 values, which corresponds to ¼ hours values one year recording time.
Picture 8 shows the option for the user to represent the past values: It an be given a start- and end
date. If more than the configured number of values in the web element are stored in the same period
in the time series as the diagram adjusts the display so that it hides intermediate values.
Picture 8: Timechart moving
Example: The user sets a period of four days (e.g. 2013-07-11 bis 2013-09-13). In the here given
configuration in the time buffer (ID 0 und 1) 384 values are stored. The diagram can only display 192
values and shows therefore in presentation each second value, effectively ½ hour values over 4 days
will be displayed. Values fluctuations that are present in ¼ hour intervals, are no longer displayed. Th
time axis is scaled or adjusted to the time specified. If the user configures the date fields in different
time intervals the axis is scaled so that the stored values are displayed from oldest to the newest
date.
With the field for Δd an offset in days for the presentation interval of the time buffer is set. The time
axis is not scaled, but stops at the set date range. The values of the time series of this day back
shifted are read from the memory. In this way curves of different time series are overlaid and
compared.
HandbuchEibPC_USA-30.odt, 2017-05-11
Enertex
®
Bayern GmbH - Erlachstraße 13 - 91301 Forchheim - [email protected]