This is an old revision of the document!
An event in V-Control works as a trigger. If the event occurs, a defined task is executed as event handler. All events are triggered by a variable change. This could be a device variable, a system variable or a global variable.
The device drivers collect information about the connected device and represent the status of the device in device variables. Each time a variable changes an event is fired. If there is an event handler for this event then the task that handles the event is fired. Device Events allow V-Control to respond on external events triggered by a connected device. If, for example, a temperature sensor send a message that a limit is reached, or a motion sensor detects a person and notify this, or a players position has changed, V-Control can launch a task and react on this event.
To trigger an event, a condition script determines if the event handling task is fired or not. Lets say we have a temperature sensor and we want to start a fan if the temperature is over 35°C. The fan should stop if the temperature is less then 30°C. So we have two conditions to check and determine which task to start.
Condition 1 is: if Temperature > 35 then start fan Condition 2 is: if Temperature < 30 then stop fan
These events initiated by the external attached devices, e.g. a liquid level sensor reports a new level or a light barrier detects a break. The sensor send a message via the channel (or the device driver requests the status periodically), and V-Control looks if there is an event handler. If an event handler is found, it checks the condition and fire the task if the condition is true.
The ioLogic E1214 is a TCP controlled box from Moxa. It uses the Modbus TCP protocol. It has 6 Relays and 6 digital inputs.Now we want to run a task if digital input 1 gets High. Select the device and the device variable D0Status. Then click the Create Condition Template button. V-Control creates a condition script that has to be edited so that the condition is true if D0Status = 1.
The first line of the condition script is a comment. It is shown in the Eventlist is is used as a hint for the programmer. Change the condition script as shown below.
Click the Add Event button Now there is a new entry in the Eventlist. The next step is to assign a task to this event. In the context menu (click right) of the event list select Assign Task. The list now looks like this:
Now, if the variable D0Status of the device changes from 0 to 1, the task assigned to the event is fired.
The first row of the condition script is a comment and shown in the Eventlist. Write whatever is helpful to have a good hint what the script is doing.
The second row
Dim D0Status as String
creates the local variable D0Status. This is necessary because we don't have direct access to a device variable.
D0Status = GetDeviceVar("ioLogic_E1214_v4","D0Status")
the content of the device variable D0Status is assigned to the local variable D0Status. The GetDeviceVar function accept only strings as parameters, so the device name and the variable name have to be surrounded by “.
The last row checks if the condition is true. The condition is always false by default and changes only to true if explicit set.
If D0Status = "1" then Condition = true
The Condition Editor tries to support the programmer in creating the script. As explained above, the Create Condition Template button creates a script that is used as first step.
Variable change events can occur from device variables and global variables. If then Use Device Variable option is set, a device variable is used. For global variables use the Use Global Variable option.
Device variables can change very frequently. A variable containing a timecode changes every 33 ms (30 fps). If you have a condition such as
Dim Positionas string Dim iPosition,iTarget as Integer Position = GetDeviceVar("DVS_Pronto","Position" iTarget = TimecodeToFramecode("10-12-21-10") iPosition = TimecodeToFramecode(Position) if (iPosition >= iTarget) and (iPosition < Target +10) then Condition = true
This script returns true if the Position is between 10-12-21-10 and 10-12-21-20. It might be that V-Control does not detect all of the 10 valid variable changes, but for sure more then one. In this case the Task that is linked to the event is fired frequently during this period. It could happen that V-Control tries to fire the task again while it is still running. For that reason we have the After fired block for ms. Here you can enter the time in ms the event should not fire again. After the time it will fire again. This value is 1000ms (1 Second) by default.
If your script causes compile errors the line with the error is marked in the script and an error message is shown (Compiler Message).
A double click in the eventlist loads the event again. To change the event click the Update Event button, to create a new click the Add Event button.
To create events that depend on a Date, Time or Time interval the System device is used. To add a System device open the Device Setup dialog by clicking the Device button in the toolbar. Search for System_v4.
The System Device is the only device that does not need a channel. It has no commands, only status variables representing Date and Time. The Time is in the format HH:MM:SS:FF (FF = Frames). The framerate is determined in the Options Dialog System page.
DayOfWeek is the current weekday (1=Sunday..7=Saturday)
To create an event that fires weekdays at 9:00 AM we have to check the current Time and the DayOfWeek. Because the DayOfWeekVariable changes only every 24 hours, we use the CurrentTime variable as trigger.
Select the CurrentTime variable, select the Events tab and pres the Create Condition Template button.
Change the Template to <code> If CurrentTime = “09:00:00 ” and DayOfWeek >1 and < 7 then Condition = true Dim CurrentTime as String Check Time first CurrentTime = GetDeviceVar(“System_v4”,”CurrentTime“) ignore frames, analyse the part “HH:MM:SS” only If Mid(CurrentTime,1,8) = “09:00:00” then Dim DayOfWeek as string DayOfWeek = GetDeviceVar(“System_v4”,”DayOfWeek“) if DayOfWeek >1 and DayOfWeek < 7 then condition = true end </code ===== Timer Events ===== Timer events are useful to launch tasks periodically. This makes it possible to request e.g. the temperature from a temperature sensor e.g. every 100 seconds and check the returned value. If necessary, the task can take countermeasures. So, timer events can be used to check threshold values from sensors that are not capable to fire an event if the threshold is exceeded or to request status parameters periodically. To create a timer event select Events → Timer from main menu or use the context menu of the event list. After the event is created (see picture above), it is necessary to assign a task to that event (same procedure as in Calendar or Device Events). To change a Timer Event, double click in the list. The caption of the Add button changes to Update. Change Interval and / or Event Name and click Update. ===== Keyboard Events ===== Connected keyboards can also fire an event. The keyboard can, but doesn't have to be, a standard PC keyboard. Infrared or RF remote controls, using an USB token and register as HID device keyboard, can also be used as input device. From the operating systems point of view, those remote controls are standard keyboards as well. This works with all supported operating systems (Windows, Mac OS X and Linux). Keyboard events in conjunction with one of the described remote controls are very useful to control devices, connected via RS232, Ethernet, DMX etc. with an Infrared or RF remote control. To add a keyboard event chose Events → Keyboard in the main menu. A new keyboard event is added in three steps: - Click in the field Keys: to have the input focus set to the field. Now press the key you want to fire an event. If the key is a printable ASCII key (abc… 123… +-*/…) then the key appears in the input field. If the key is a non printable key (F1 F2 F3… SPACE ESC ENTER…) then the name of the key appears. It is possible to fire an event on a sequence of keys, for example 235. In this case, the event is fired if the three keys are pressed in a sequence. If a sequence of keys is entered, the keys are separated by a space. ATTENTION: If V-Control receives a key or key sequence that has no event assigned to, then the keys are stored in a queue. This is because maybe later a key will be received, that has, together with the keys in the queue, an event assigned. If an invalid key is received, then the queue will never be empty, and all following keys are stored in the queue. To flush the queue you can send an ENTER key. - Enter the event name. - Add the event to the list. After that, a task has to be assigned to the event (see Calendar Events / Device Events). To enable the keyboard events mark the checkbox Enable Keyboard Events.