User Tools

Site Tools


events

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
events [2017/11/25 15:24]
admin [Calendar and Timed Events]
events [2020/09/24 19:03] (current)
Line 4: Line 4:
 All events are triggered by a variable change. This could be a device variable, a system variable or a global variable. 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. ​+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 eventthen 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. 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 1 is: if Temperature > 35 then start fan
 +
 Condition 2 is: if Temperature < 30 then stop fan Condition 2 is: if Temperature < 30 then stop fan
  
Line 26: Line 27:
 {{ :​devicevar_change_2.png |}} {{ :​devicevar_change_2.png |}}
  
-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. ​+The first line of the condition script is a comment. It is shown in the //​Eventlist// ​and is used as a hint for the programmer. ​
 Change the condition script as shown below. Change the condition script as shown below.
  
 {{ :​devicevar_change_3.png |}} {{ :​devicevar_change_3.png |}}
  
-Click the //Add Event// button +Click the //Add Event// buttonNow 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 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:+
  
 {{ :​devicevar_change_4.png |}} {{ :​devicevar_change_4.png |}}
Line 82: Line 82:
  
 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. 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.
-===== Calendar ​and Timed Events =====+ 
 +==== Using Global Variables as Parameter ​==== 
 + 
 +You might run in a situation where you need to use the data that is provided by an event as parameter. Assume the following task: 
 + 
 +There is a MIDI message (lets say a controller change) that should control the volume of an OSC device. The volume should be controlled in 100 steps, so we receive Controller Change messages from 0:0:0 to 0:0:100 (Channel 1, Controller 1, Value from 0..100) 
 + 
 +If we cant use the Value parameter, we have to create 100 Events. Event 1 checs if Value = 1, Event 2 checks if Value = 2 etc. Of course nobody will use this. But there is an elegant way to do this with only one Event, one Task and one global variable. 
 + 
 +First we need a global variable that is used to store the volume level. See [[scriptsgeneral#​Global Variables|Global Variables Section]] if you don't know how to create a global variable. Now we can create the Event: 
 + 
 +{{ ::​eventparameter.png |}} 
 + 
 +The Event Script 
 + 
 +<​code>​ 
 +//If onControllerChange = then Condition = true 
 +Dim onControllerChange as Variant 
 +onControllerChange = GetDeviceVar("​MIDI","​onControllerChange"​) 
 +Dim v as string 
 +v = NthField(onControllerChange,":",​3) 
 +SetGlobalVar("​Volume",​v) 
 +Condition = true 
 +</​code>​ 
 + 
 +First notice the last line, '​Condition = true'. Here we define that the condition is allways true, no matter what controller change message is received. If you expect controller change messages from other controllers than controller 1 on channel 1 you have to change this. e.g. 
 +<​code>​ 
 +dim Controller, Channel as string 
 +controller = NthField(onControllerChange,":",​1) 
 +channel = NthField(onControllerChange,":",​2) 
 +if Controller = "​0"​ and Channel = "​0"​ then Condition is true 
 +</​code>​ 
 + 
 +Now lets look how we extract the volume level and use it as parameter:​ 
 +<​code>​ 
 +Dim v as string 
 +v = NthField(onControllerChange,":",​3) 
 +SetGlobalVar("​Volume",​v) 
 +</​code>​ 
 +the variable v receives the volume level. This level is the strored in the global variable Volume. 
 + 
 +Make sure that the 'After Fired Block for ms' value is set to 0 to allow quick volume changes. 
 +{{ ::​blockafterfired.png |}} 
 + 
 +Now we link the Event to a script. 
 +{{ ::​eventparameter2.png |}} 
 + 
 +This script simply reads the global Volume variable and inserts it in an OSC Command 
 + 
 +===== Calendar ​Events =====
  
 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. 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.
Line 88: Line 137:
 {{ :​systemdevice.png |}} {{ :​systemdevice.png |}}
  
-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 [[user_interface#​Options|Options Dialog System page]].+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|Options Dialog System page]].
  
 **//​DayOfWeek //** is the current weekday (1=Sunday..7=Saturday) **//​DayOfWeek //** is the current weekday (1=Sunday..7=Saturday)
Line 110: Line 159:
 end end
 </​code>​ </​code>​
 +
 +Maybe one is wondering about **//Dim DayOfWeek as Variant//​**. If DayOfWeek was declared as string, then an operation such as //if DayOfWeek > 1// would couse a compile error, because a string cannot be compared with an integer. A variant behaves as string if the content is a string, or as integer if the content can be converted to integer. So the string "​1"​ can be converted to the integer 1. This happens automatically.
  
 Now the event is fired 25 Times (from "​09:​00:​00:​00"​ - "​09:​00:​00:​24"​ at 25 fps). Because we want to ensure that the event is only fired ocne, set the //After fired block for ms// to 2000 ms. Now the event is fired 25 Times (from "​09:​00:​00:​00"​ - "​09:​00:​00:​24"​ at 25 fps). Because we want to ensure that the event is only fired ocne, set the //After fired block for ms// to 2000 ms.
Line 119: Line 170:
  
  
-===== 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. 
- 
-{{:​timer.png|}} 
- 
-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. 
- 
-{{:​keboard_event_create.png|}} 
- 
-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. 
  
-{{:​Keyboard_Events_Enable.png|}} 
events.1511619853.txt.gz · Last modified: 2020/09/24 19:00 (external edit)