Actions

An Action is a named element that describes a unit of executable functionality.

An Action has a name:  

Action Named Element
#
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:

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.

Action Named Element
#
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.

Action Result
#
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).

Instantiate a Device using TQL Query
#
Query:
  Save(format: "version,current"):
    RfidReader(ReaderId: "R1", URL: "perif://"):
        RFID(value: "$Null()", version: "1")

See also Automatic Action trigger.