Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<ThingFacet name="Esky">
<Sid name="CameraId"/>
<String name="URL"/>
<String name="UserName"/>
<String name="Password"/>
<String name="State" KnownBy="SyncImage,SyncPreset"/>
<String name="Image" KnownBy="SyncImage"/>
<String name="Preset" KnownBy="SyncPreset"/>
<Unique name="Camera" value="URL"/>
<!-- Helpers -->
<AA>[:#o#Event.Argument:]</AA>
<UP>user=[%:[:AA:].UserName.Value:%][%:amp:%]pwd=[%:[:AA:].Password.Value:%]</UP>
<POK>Invoke/SetPreset/Message/starts-with(Value, 'ok')</POK>
<IOK>Invoke/GetImage/Message/starts-with(Value, 'data')</IOK>
<!-- Actions -->
<Action name="SyncPreset" 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="SyncImage" 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>
</ThingFacet> |
Page Comparison
General
Content
Integrations