Product: | Elvis |
Version: | 2.5 |
Booth: | 2006-08-30 |
Summary
This article shows how Elvis can be used to create a presence simulation.
The simulation is based on the fact that the timing of certain events (e.g. light on/off) is recorded as a time program during normal operation. In simulation mode, this time program is then activated so that the same events then run automatically.
The time program is designed as a weekly program, i.e. separate times can be recorded for each of the seven days of the week.
The simulation is in one of three modes of operation at any given time:
- Inactive: It is neither recorded nor played.
- Recording: Events are recorded.
- Simulation: Events are played.
Details
Control data point
This data point (in the example it has the name “PresSimCtrl”) determines the operating mode. It can be controlled, for example, via the visualization interface or an EIB telegram.
In the example, it is used as follows:
Data point type: | Numerator |
Interpretation of the values | 0 = Inactive 1 = Recording 2 = Simulation |
ActualValue: | persistent, default value 0 |
Time program
A time program (in the example it has the name “PresSim”) is created. The data points to be included in the simulation are assigned to the time program.
Then, for each day of the week, an instance of the time program is defined. All instances are initially inactive. In order to easily identify the time program instance for a specific day of the week in the global script, these instances are given the texts “Mon”, “Tue”, …, “Sun”.
Activation/deactivation occurs in the global script when the value of the PresSimCtrl data point changes.
Recording
The actual recording is done in the global script. OnDatapointChanged verifies that all of the following conditions are true:
- the ActualValue of PresSimCtrl is 1
- the data point property that has changed is an ActualValue
- the data point that has changed is in the list of data points to simulate
If all conditions are met, the detected event is entered into the time program. If it is the first event to be recorded for today, all events that may already exist in the day’s time program will be deleted beforehand (these are from the previous week).
For the third condition, it would make the most sense for the global script to check whether the data point is included in the list of data points of the PresSim time program. Unfortunately, this is not possible in the current Elvis version. Therefore, this check must be based on another data point property. The following are available:
- Name: as in the example, you could check whether the data point name contains the component “PresSim>”<
- User-defined property: you could define your own data point property and use its value as an identifier
When configuring, you have to make sure that the check filters out exactly those data points that are also assigned to the time program. In practice, this is probably not a very big problem, since the number of data points to be simulated will usually not be very large.
To detect whether an event is the first on that day, the global script remembers the date and time of the last recorded event in a PresSimPrevEvent data point.
Download the sample project kb050131.zip