Versions Compared

Key

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

Here you can see two actions: SyncPreset and SyncImage which deal with camera preset and snapshot image respectively. Both also update camera state.

In order to tell the system how to select actions, a new attribute “KnownBy” is added. It contains a list of all actions which can update given attribute in order of preference (e.g. based on action performance, execution time etc., for example). 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 SyncImage action and when both state and preset need updates, SyncPreset will be used.

·         A number of improvements has been introduced to workflow definition language:

o   delayAfter parameter allows to delay process execution after enclosing invoke was completed. This allows to avoid extra invokes for pure waiting. In the example above, the WF gives camera 5 seconds to process the preset change (i.e. rotate the camera to new preset position). This allows to encapsulate the whole preset change thing into a single invoke.

o   OnlyIf (also recognized as only-if) invoke parameter is a negative to already existing skip-if. That is only-if === not(skip-if) and vice versa. The invoke will be executed when only-if condition is true. This is for convenience.

·         As per request, OldValue and OldKnown have been added to the subscription messages. They contain previous values of value and known respectively.


Code Block
languagexml
firstline0
titleThingFacet Camera Example
<ThingFacet#
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: KnownBy="SyncImage,SyncPreset"/>)
      <String name=String(name: "Image", KnownBy: KnownBy="SyncImage"/>)
      <String name=String(name: "Preset", KnownBy=: "SyncPreset"/>)
      <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>InvokePOK: Invoke/SetPreset/Message/starts-with(Value, 'ok')</POK>
      IOK: <IOK>InvokeInvoke/GetImage/Message/starts-with(Value, 'data')</IOK>

      <!--# Actions --> 
     <Action Action(name=: "SyncPreset", 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 Invoke(name=: "SetPreset", 
       waitFor=           waitFor: "Argument", 
                  skip-if=: "[%:[:AA:].Preset/no-value(Value):%]" delayAfter="PT5S", 
                  delayAfter: "PT5S"
                  get=: "[%:[:AA:].URL.Value:%]/cgi-bin/decoder_control.cgi?[:UP:][%:amp:%]command=15[%:amp:%]sit=[%:[:AA:].Preset.Value:%]"/>)                  
               <Output Output(name=: "Result", as=: "ActionResult">):
                    <Value>Value:
                        <State>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: "SyncImage", 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:
<Value>                        State: <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>