In a previous howto we looked at how to link server interfaces. Sometimes it is not necessary to establish a full link but just send an event to the rest of the system. A typical example on this can be when an event comes in that signals a special state and you what the system to go perform other steps. Here you can send out the events needed to perform those steps.
There are currently three actions defined for this in the VSCP server
Send event
VSCP_DAEMON_ACTION_CODE_SEND_EVENT 0x40/64
This actions sends out a specified event and optionally set a boolean variable to true if the send was successful. The full documentation is here.
If for example you want to send the event CLASS1.INFORMATION, Type=3, ON every second you can use
<row enable="true" groupid="Send event"> <comment> Periodic event Send CLASS1:INFORMATION, Type=3 ON event every second </comment> <mask priority="0" class="0xFFFF" type="0xFFFF" GUID=" 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" /> <filter priority="0" class="65535" type="5" GUID=" 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" /> <action>0x40</action> <param> 0,20,3,0,,,0:1:2:3:4:5:6:7:8:9:10:11:12:13:14:15,0,1,35 </param> </row>
Send event conditional
VSCP_DAEMON_ACTION_CODE_SEND_EVENT_CONDITIONAL 0x41/65
This action works much as the previous action. The difference is that it just send the event if a named VSCP remote variable is true. The full documentation is here.
If you like in the example above want to send the event CLASS1.INFORMATION, Type=3, ON every second you can use
<row enable="true" groupid="Send event conditional" > <comment> Create variable that hold flag for sent event when the server is started ( CLASS2.VSCPD, Type=23 ). </comment> <mask priority="0" class="0xFFFF" type="0xFFFF" GUID=" 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" /> <filter priority="0" class="65535" type="23" GUID=" 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" /> <action>0x50</action> <param> bsent;bool;false;0;0x777;false </param> </row> <row enable="true" groupid="Send event conditional" > <comment> Create variable that hold flag send conditional event when the server is started ( CLASS2.VSCPD, Type=23 ). </comment> <mask priority="0" class="0xFFFF" type="0xFFFF" GUID=" 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" /> <filter priority="0" class="65535" type="23" GUID=" 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" /> <action>0x50</action> <param> bevent;bool;false;0;0x777;false </param> </row> <row enable="true" groupid="Send event conditional"> <comment> Send event conditional Send CLASS1:INFORMATION, Type=3 ON event </comment> <mask priority="0" class="0xFFFF" type="0xFFFF" GUID=" 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" /> <filter priority="0" class="65535" type="5" GUID="00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" /> <action>0x41</action> <param> bevent;0,20,3,0,,,0:1:2:3:4:5:6:7:8:9:10:11:12:13:14:15,0,1,35;bsent </param> </row>
The difference from the previous example is the introduction of the bEvent remote variable. This variable is initialized to false so before it is set to true no events will be sent. We can look at the variable sin the admin web interface
Setting it to true
make the action trigger and the event is sent once a second while the bEvent variable is set to true.
Send event(s) from file
The last send event action send one or more events from a file instead of having them specified in the action parameter. This makes it possible to send several events from one trigger. A typical scenario could be to trigger on button press and set a scene by presetting lamps and other things which will be set by the sent out list of events,
This action is fully specified here. The file for the events to send out is XML based. Apart from that it should be easy to set up from the documentation.
The events defined here in a file called sendevents simulate setting a scenario.
<events> <event> <!-- CLASS1.CONTROL, Type=5 TurnOn Turn on lamps in zone=1, subzon=0 --> <head>0</head> <class>30</class> <type>5</type> <guid>00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00</guid> <data>0,1,0</data> </event> <event> <!-- CLASS1.CONTROL, Type=5 TurnOn Turn on lamps in zone=1, subzon=0 --> <head>0</head> <class>30</class> <type>5</type> <guid>00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00</guid> <data>0,1,2</data> </event> <event> <!-- CLASS1.CONTROL, Type=5 TurnOn Turn on lamps in zone=1, subzon=22 --> <head>0</head> <class>30</class> <type>5</type> <guid>00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00</guid> <data>0,1,22</data> </event> <event> <!-- CLASS1.CONTROL, Type=5 TurnOn Turn on lamps in zone=1, subzon=240 --> <head>0</head> <class>30</class> <type>5</type> <guid>00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00</guid> <data>0,1,240</data> </event> <event> <!-- CLASS1.CONTROL, Type=6 TurnOff Turn off head light lamps in zone=1, subzon=1 --> <head>0</head> <class>30</class> <type>6</type> <guid>00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00</guid> <data>0,1,1</data> </event> <event> <!-- CLASS1.CONTROL, Type=20 Dim lamp(s) Dim lamps in zone=1, subzon=0 at 30% --> <head>0</head> <class>30</class> <type>20</type> <guid>00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00</guid> <data>30,1,0</data> </event> </events>
A DM that sets this scenario every minute looks like this
<?xml version = "1.0" encoding = "UTF-8" ?> <dm> <row enable="true" groupid="Send events from file" > <comment> Send events in list sendevents when the server is started ( CLASS2.VSCPD, Type=23 ). </comment> <mask priority="0" class="0xFFFF" type="0xFFFF" GUID="00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" /> <filter priority="0" class="65535" type="6" GUID="00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" /> <action>0x42</action> <param> /srv/vscp/sendevents </param> </row> </dm>
And running it we see in VSCP works that the events get sent
You can find sample files for tests here.