Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

One can associate multiple thing actions to a Thingfacet Attribute. You can do this by providing comma separated list of Action names. For example,

Assoicating Multiple Thing Actions
<String name="State" KnownBy="SyncImageAction,SyncPresetAction"/>
Multiple Thing Actions
<!-- Actions -->
<Action Name="SyncPresetAction" Documentation="Synchronize camera state and preset">
  <Workflow Limit="1" Live="1" Timeout="PT20S">
    <Task Name="Main" While="true">
      <Event Name="Argument" As="ActionArgument"/>
      <Invoke Name="SetPreset" waitFor="Argument" skip-if="[%:[:AA:].Preset/no-value(Value):%]" delayAfter="PT5S"
        get="[%:[:AA:].URL.Value:%]/cgi-bin/decoder_control.cgi?[:UP:][%:amp:%]command=15[%:amp:%]sit=[%:[:AA:].Preset.Value:%]"/>
      <Output name="Result" as="ActionResult">
        <Value>
          <State> [%:[%:@Output:%]/if([:POK:]) then 'ON' else 'OFF':%]</State>
          <Preset>[%:[%:@Output:%]/if([:POK:]) then '[%:[:AA:].Preset.Value:%]' else null():%]</Preset>
        </Value>
      </Output>
    </Task>
  </Workflow>
</Action>
<Action name="SyncImageAction" documentation="Synchronize camera state and snapshot image">
  <Workflow Limit="1" Live="1" Timeout="PT10S">
    <Task name="Main" while="true">
      <Event name="Argument" as="ActionArgument"/>
      <Invoke name="GetImage" waitFor="Argument" delay="PT1S" get="[%:[:AA:].URL.Value:%]/cgi-bin/video_snapshot.cgi?[:UP:]"/>
      <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>
    </Task>
  </Workflow>
</Action>

Here you can see two actions: SyncPresetAction and SyncImageActon which deal with camera preset and snapshot image respectively. Both as a result update the camera state.

In case when multiple attributes are updated, the system will select minimum number of actions with highest preference to perform the update[s]. That is, if only state needs to be updated, the engine will use SyncImageAction action and when both state and preset need updates, SyncPresetAction will be used.

  • No labels