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/12/14 13:45]
admin [Device Variable Change Events]
events [2019/01/17 13:47] (current)
admin [Using Global Variables as Parameter]
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 81: 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.
 +
 +==== 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 ===== ===== Calendar Events =====
  
Line 87: 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)
events.1513259128.txt.gz · Last modified: 2017/12/14 13:45 by admin