An Action is a named element that describes a unit of executable functionality.
An Action has a name modifier:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<Action Name="RotateCameraAction" Documentation="Simple Action to Rotate IP-based Camera by x degrees"/> |
...
An Action must be associated or attached to a Model or Model Facet Attributemodel attribute. In ThingFacets or AppFacets, an Action is associated with an model attribute of the same ThingFacet or AppFacet using the "KnownBy" modifier as below. The associated attribute becomes an actionable attribute.
...
Action results in changes of the "Known" value(s) of any attributes
From the Action, using the output of the workflow, you can update any attributes of the ThingFacet or AppFacetmodel. 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 Attributesattributes.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<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> |
Note: the output of the workflow can update any attribute of the model. This is not limited to the actionable attribute.
Action is triggered by the modification of associated (KnownBy) 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 ThingModels and AppModels any updates to the associated attribute(s) values will trigger the Action. This can happen through include the initialization of the attributes (i.e. when it first acquires its value). The attribute value updates can only be achieved via TQL queries, in one of the following meansforms:
- Internally TQL Queries changing External applications using TQL queries to update the value of the attributesExternal applications using TQL Queries changing . This includes the following example of a Save query to instantiate the model. Here giving the attribute RFID a value of $Null( ) will trigger the Action "KnownBy" this attribute.
- Internally TQL queries updating 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(e.g. TQL queries can be used by models to update values of other model's attributes).
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<Query> <Save format="version,current"> <RfidReader ReaderId="R1" URL="perif://"> <RFID value="$Null()" version="1"/> </RfidReader> </Save> </Query> |
...