Actions

Introduction

An action is a set of instructions that can be executed by the operator or even by an automated rule. An action can generate events, can use physical and virtual actuators and publish calibrated results.

On this page:


Writing a single coil

Here we have an example of writing a single coil to illuminate an LED, using the X20BC0087 ModBusTCP device from B&R.


<actions>
	<action action_id="Switch_LED_red" device_id="dev_X20BC0087">			# Here we define the name of the action and also which device is used to execute the command.
    	<commands>
      		<command command_id="ON">write_single_coil(12,[1])</command>	# Define the command ON and set the coil on the register 12 to 1.
        	<command command_id="OFF">write_single_coil(12,[0])</command>	# Same, although now we switch to OFF and set the coil to 0.
    	</commands>
    </action>
	.
	.
	.
</actions>


Fallback action

An action command is configurable with a fallback, which allows to trigger an action after the first one has been executed. Here is an example of a flapping state:


 	<action action_id="Blink" device_id="VirtualSensorProvider">
    	<commands>
        	<command command_id="ON" fallback_command_id="OFF" fallback_time_ms="1000">publish_calibrated_result('Blinker', True)</command>
    		<command command_id="OFF" fallback_command_id="ON" fallback_time_ms="1000">publish_calibrated_result('Blinker', False)</command>
  		</commands>
	</action>

Please note that such a behavior can be easily configured with the Automation Controller (AC). Such a blinker would be stoppable.

Execute an action on startup

There are many scenarios where you might want to execute an specific action at startup. It can be easily configured adding exec_on_startup="true" to the command parameters.

<command command_id="Activate_theft_check" exec_on_startup="true">publish_calibrated_result('CheckBatteryTheft', True)</command>


Actions, executed by the VirtualSensorProvider

The VirtualSensorProvider allows the operator to create sensors, which do not have a physical device attached to them. This is especially usefull for setting "States of Alarm" to an system.

Here we will see a small example to set the value of the sensor to true or false.

<action action_id="Alarms" device_id="VirtualSensorProvider">							# Definition of the action and the obliogatory device id. It is important that the device id is the "VirtualSensorProvider".
	<commands>
    	<command command_id="Reset">publish_calibrated_result('Alarm',False)</command>
		command command_id="Set">publish_calibrated_result('Alarm', True)</command>
    </commands>
</action>


Actions, executed by an Automation Rule

An action can also be automatically be executed by an Automation Rule. These rules can be executed per example, if a special event is happening or specific values are reached.

More information about the Automation Rules can be found Automation Rule.


Next Steps