KNOWLEDGE BASE

face-white

Process Server Programming

30.08.2006 11:12

KB050131 | PRESENCE SIMULATION

INF

Product: Elvis
Version: 2.5
Stand: 2006-08-30

Summary

This article demonstrates how a presence simulation can be implemented in Elvis.

The simulation is based on recording the sequence of specific events (e.g. light on/off) in normal operation as a schedule. In simulation mode this schedule is activated so that the same events are executed automatically.

The schedule is created as week schedule, i.e. for each of the seven week days separate times can be recorded.

The simulation is at each point in time in one of three modi:

  • Inactive: Neither recording nor simulation
  • Recording: Events are recorded
  • Simulation: Events are played

Details

Control datapoint

This datapoint (in the example it has the name “PresSimCtrl”) determines the operation mode.
It can be switched e.g. from the visualization interface or an EIB telegram.

In the example it is declared as follows:

Datapoint type: Counter
Interpretation of values 0 = Inactive
1 = Recording
2 = Simulation
ActualValue: persistent, default value 0
Schedule

A schedule (in the example it has the name “PresSim”) is created. The datapoints to be included in the simulation are assigned to the schedule.

RTEmagicC 81d05e9043 1.jpg 1

For each week day one instance of this schedule is defined. All instances are disabled. For easy indentification of the schedule instance for a specific week day in the global script, the instances are labelled with a unique text (“Mo”, “Di”, …, “So”).

RTEmagicC a536df281f 1.jpg 1

The enabling/disabling of the schedule instances is done in the global script, if the value of the PresSimCtrl datapoint changes.

Recording

The recording is done in the global script. In OnDatapointChanged it is checked whether all of the following conditions apply:

  1. the ActualValue of PresSimCtrl is 1
  2. the datapoint property that has changed is ActualValue
  3. the datapoint that has changed is in the list of datapoints to be simulated

If all conditions are true the event is added to the schedule. If this is the first event recorded for today, all existing events for this day are deleted first(these are from the previous week).

For the third condition it would be best to check in the global script ifthe datapoint is in the list of datapoints assigned to the schedule “PresSim”.Unfortunately, this is not possible in the current Elvis version.So the check has to be based on another datapoint property. Candidates are:

  • Name: e.g. check if the name contains the substring “<PresSim>” (as is done in the example)
  • User-defined property: define a new datapoint property and check its value

When developing the project be sure that the check filters exaclty the same datapoints that are assigned to the schedule. In practice this will not be a big problem since the numberof datapoints to be simulated will not be too large.

To recognize that the event is the first today, the globa script remembersdate and time of the previously recorded event in a datapoint “PresSimPrevEvent”.

Download of the example project kb050131.zip