Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagexml
titleAssoicating Multiple Actions
linenumberstrue
<String#
String(name=: "State", KnownBy=: "SyncImageAction,SyncPresetAction"/>

...

)


Here you can see two actions: SyncPresetAction and SyncImageActon which deal with camera preset and snapshot image respectively. Both the actions update the "State" attribute of a Camera Facet. 


Code Block
languagexml
titleMultiple Thing Actions
linenumberstrue
<!--# Actions
-->
<Action Name=Action(Name: "SyncPresetAction", Documentation=: "Synchronize camera state and preset">): 
 <Workflow Workflow(Limit=: "1", Live=: "1", Timeout=: "PT20S">): 
   <Task Task(Name=: "Main", While=: "true">): 
     <Event Event(Name=: "Argument", As=: "ActionArgument"/>)
      <Invoke Name=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=Output(Name: "Result", as=: "ActionResult">): 
        Value>
          State:
<Value>           <State> [%:[%:@Output:%]/if([:POK:]) then 'ON' else 'OFF':%]</State>
           <Preset>Preset:
            [%:[%:@Output:%]/if([:POK:]) then '[%:[:AA:].Preset.Value:%]' else null():%]</Preset>
        </Value>
      </Output>
    </Task>
  </Workflow>
</Action>
<Action name=
Action(Name: "SyncImageAction", documentation=: "Synchronize camera state and snapshot image">): 
  <WorkflowWorkflow Limit=: "1", Live=: "1", Timeout=: "PT10S">): 
    <Task name=Task(Name: "Main", while=: "true">): 
      <Event name=Event(Name: "Argument", as=: "ActionArgument"/>)
      <Invoke name=Invoke(Name: "GetImage", waitFor=: "Argument", delay=: "PT1S", get=: "[%:[:AA:].URL.Value:%]/cgi-bin/video_snapshot.cgi?[:UP:]"/>)
      <Output name=Output(Name: "Result", as=: "ActionResult">): 
        Value>
          State:
 <Value>           <State>[%:[%:@Output:%]/if([:IOK:]) then 'ON' else 'OFF':%]</State>
          Image:
            <Image>[%:[%:@Output:%]/if([:IOK:]) then Invoke/GetImage/Message/Value/text() else '/img/no-image.jpg':%]</Image>
        </Value>
      </Output>
    </Task>
  </Workflow>
</Action>

...


Rules for Selecting an Action:

...

  • Order of Action Names specified in KnownBy - The first Action Name gets first preference, second gets second preference and so on.
  • Minimum number of Action (s) that satisfy the update criteria. This rule is used in conjunction with previous order of preference rule.

 


Code Block
languagexml
titleESKY Camera Thing Facet
linenumberstrue
<ThingFacet name=#
ThingFacet(Name: "Esky">): 
  <Sid name=Sid(Name: "CameraId"/>)
  <String name=String(Name: "URL"/>)
  <String name=String(Name: "UserName"/>)
  <String name=String(Name: "Password"/>)
  <String name=String(Name: "State", KnownBy=: "SyncImageAction,SyncPresetAction"/>)
  <String name=String(Name: "Image", KnownBy=: "SyncImageAction"/>)
  <String name=String(Name: "Preset", KnownBy=: "SyncPresetAction"/>)
  <Unique name=Unique(Name: "Camera", value=: "URL"/>)
  
  <!--# Helpers
-->  AA:
    <AA>[:#o#Event.Argument:]</AA>
  UP:
    <UP>useruser=[%:[:AA:].UserName.Value:%][%:amp:%]pwd=[%:[:AA:].Password.Value:%]</UP>
  POK:
    <POK>InvokeInvoke/SetPreset/Message/starts-with(Value, 'ok')</POK>
  IOK:
    <IOK>InvokeInvoke/GetImage/Message/starts-with(Value, 'data')</IOK>
  
<!-- Actions -->#Actions
  <Action name=Action(Name: "SyncPresetAction", documentation=: "Synchronize camera state and preset">): 
    <WorkflowWorkflow Limit=: "1", Live=: "1", Timeout=: "PT20S">): 
      <Task name=Task(Name: "Main", while=: "true">): 
        <Event name=Event(Name: "Argument", as=: "ActionArgument"/>)
        <Invoke name=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=Output(Name: "Result", as=: "ActionResult">): 
          Value:
            State:
<Value>             <State> [%:[%:@Output:%]/if([:POK:]) then 'ON' else 'OFF':%]</State>
            Preset:
              <Preset>[%:[%:@Output:%]/if([:POK:]) then '[%:[:AA:].Preset.Value:%]' else null():%]</Preset>

         </Value>     
   </Output>
      </Task>
    </Workflow>
  </Action>
  <Action name=Action(Name: "SyncImageAction", documentation=: "Synchronize camera state and snapshot image">): 
    <WorkflowWorkflow Limit=: "1", Live=: "1", Timeout=: "PT10S">): 
      <Task name=Task(Name: "Main", while=: "true">): 
        <Event name=Event(Name: "Argument", as=: "ActionArgument"/>)
        <Invoke name=Invoke(Name: "GetImage", waitFor=: "Argument", delay=: "PT1S", get=: "[%:[:AA:].URL.Value:%]/cgi-bin/video_snapshot.cgi?[:UP:]"/>)
        <Output name=Output(Name: "Result", as=: "ActionResult">): 
          Value:
            State:
 <Value>             <State>[%:[%:@Output:%]/if([:IOK:]) then 'ON' else 'OFF':%]</State>
            Image:
              <Image>[%:[%:@Output:%]/if([:IOK:]) then Invoke/GetImage/Message/Value/text() else '/img/no-image.jpg':%]</Image>
          </Value>
        </Output>
      </Task>
    </Workflow>
  </Action>
</ThingFacet>

 


For example in case of ESKY Camera Facet - here is the list the table of Attribute, Action Association and Attributes that get affected by Actions.

AttributeAction(s) AssociationAttribute(s) Being Updated By Action
StateSyncImageAction, SyncPresetActionState, Image, Preset
Image
SyncImageActionState, Image
PresetSyncPresetActionState, Preset

...


Based on the above Action Association and Rules applied by the TQLEngine, table below gives possibilities:

...