What is an Action?
Where can Action be used in TQL (only in ThingFacets and AppFacets?)
What is the general structure of an Action in TQL? (1 or more workflows?)
Jira Legacy | ||||||||
---|---|---|---|---|---|---|---|---|
|
Actionable Attributes:
Jira Legacy | ||||||||
---|---|---|---|---|---|---|---|---|
|
Relationship between Actionable attributes and actionsAn Action is a named element that describes a unit of executable functionality.
An Action has a name:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
#
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 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.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
#
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 any attributes
From the Action, using the output of the workflow, you can update any attributes of the model. 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.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
#
Output(name: "Result", as: "ActionResult"):
Value:
State: "[%:[%:@Output:%]/if([:IOK:]) then 'ON' else 'OFF':%]"
Image: "[%:[%:@Output:%]/if([:IOK:]) then Invoke/GetImage/Message/Value/text() else '/img/no-image.jpg':%]" |
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 ThingModels and AppModels any updates to the associated attribute(s) values will trigger the Action. This 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 forms:
- External applications using TQL queries to update the value of the attributes. 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 (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") |
See also Automatic Action trigger.