An Action is a named element that describes a unit of executable functionality.
An Action has a name modifier:
<Action Name="RotateCameraAction" Documentation="Simple Action to Rotate IP-based Camera by x degrees"/>
An Action must define executable code in any Atomic Domain Languages (Workflow, FacetScript, TQL, Subscribe, Sequence) or any of their combinations, within one of the following elements:
- ThingFacet (see ThingFacet actions)
- AppFacet (see AppFacet actions)
- Subscribe
- Sequence
NOTE: In the case of ThingFacet or AppFacet an Action must start with a Workflow.
Action is associated with attribute(s)
An Action must be associated or attached to a Model or Model Facet Attribute. In ThingFacets or AppFacets, an Action is associated with an attribute of the same ThingFacet or AppFacet using the "KnownBy" modifier as below. The associated attribute becomes an actionable attribute.
<Double Name="RotateValue" KnownBy="RotateCameraAction"/>
Please refer to <subscribe> and <sequence> for their respective action associations.
See also Associate multiple thing actions.
Action results in changes of the "Known" value(s) of attributes
From the Action, using the output of the workflow, you can update any attributes of the ThingFacet or AppFacet. Note that It is always the "Known" value of the attribute that will be updated by Actions. In this example, Action is changing the State and Image Attributes.
<Output name="Result" as="ActionResult"> <Value> <State>[%:[%:@Output:%]/if([:IOK:]) then 'ON' else 'OFF':%]</State> <Image>[%:[%:@Output:%]/if([:IOK:]) then Invoke/GetImage/Message/Value/text() else '/img/no-image.jpg':%]</Image> </Value> </Output>
Action is triggered by modification of associated attribute values
Trigger is an execution phase of an Action. Execution of an Action is asynchronous and can be triggered in any number of ways. Please refer to <subscribe> and <sequence> for their respective action triggers.
In ThingFacet / AppFacet updating the associated attribute(s) values will trigger the Action. This can happen through one of the following means:
- External devices (sensors / actuators) changing their state
- Internally TQL Queries changing the value of the attributes
- External applications using TQL Queries changing the value of the attributes. For example, to Instantiate a device, we use a TQL Query to update the attribute value, which subsequently initiate its associated Action.
<Query> <Save format="version,current"> <RfidReader ReaderId="R1" URL="perif://"> <RFID value="$Null()" version="1"/> </RfidReader> </Save> </Query>
See also Automatic Action trigger.