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 Current »

Examples of CRUD Operation on a ThingModel:

CREATE:

Create PhidgetServo Thing Model
<Create>
    <PhidgetServoModel>
      <ServoProtocolURL>
        phid://
      </ServoProtocolURL>
      <PhidgetDeviceType>
        PhidgetAdvancedServo
      </PhidgetDeviceType>
      <DeviceInterfaceIndex>
        0
      </DeviceInterfaceIndex>
      <ServoAngle>
        110
      </ServoAngle>
    </PhidgetServoModel>
  </Create>

CREATE RESULT:

Create PhidgetServoModel Result
<Create Status="Success">
  <PhidgetServoModel>
    <PhidServoId>KNJN2YRVAAAAUAABA7LIQ4Y6</PhidServoId>
    <ServoProtocolURL Status="Success+Created:1:1457384153653;" Value="phid://"/>
    <DeviceInterfaceIndex Status="Success+Created:1:1457384153653;" Value="0"/>
    <PhidgetDeviceType Status="Success+Created:1:1457384153653;" Value="PhidgetAdvancedServo"/>
    <ServoAngle Status="Success+Created:1:1457384153654;" Value="110"/>
  </PhidgetServoModel>
</Create>

Note: If a ThingModel is combined with a ThingFacet, creation of a ThingModel results in instantiating (Trigger) of a ThingFacet action.


UPDATE:

PhidgetServo Thing Model
<Query>
  <Find format="version">
    <PhidgetServoModel as="var.PS">
      <PhidServoId ne=""/>
    </PhidgetServoModel>
  </Find>
  <SetResponseData>
    <key>
      Message.Value.Find.Result.PhidgetServoModel.ServoAngle.Value
    </key>
    <value>
      120
    </value>
  </SetResponseData>
  <Update>
    <from>
      Result
    </from>
    <Include>
      $Response.Message.Value.Find
    </Include>
  </Update>
</Query>

 

UPDATE Result:

PhidgetServo Thing Model
<Find Status="Success" Format="version">
  <Result>
    <PhidgetServoModel>
      <PhidServoId>KNJPIFR6AAAAUAABA67ZRBQO</PhidServoId>
      <PhidgetDeviceType Value="PhidgetAdvancedServo" Version="1"/>
      <ServoAngle Version="1" Value="120"/>
      <DeviceInterfaceIndex Value="0" Version="1"/>
      <ServoProtocolURL Value="phid://" Version="1"/>
    </PhidgetServoModel>
  </Result>
</Find>
<Update Status="Success" Format="version">
  <PhidgetServoModel>
    <PhidServoId>KNJPIFR6AAAAUAABA67ZRBQO</PhidServoId>
    <ServoProtocolURL Status="Success_NoAction:1:1457385641534;" Value="phid://" Version="1"/>
    <DeviceInterfaceIndex Status="Success_NoAction:1:1457385641534;" Value="0" Version="1"/>
    <PhidgetDeviceType Status="Success_NoAction:1:1457385641535;" Value="PhidgetAdvancedServo" Version="1"/>
    <ServoAngle Status="Success=Updated:2:1457385767153;" Value="120" Version="2"/>
  </PhidgetServoModel>
</Update>

Note: If a ThingModel is combined with a ThingFacet updating a ThingModel attribute results in Trigger of a Action if that attribute is associated with an action.


DELETE:

Delete PhidgetServoModel Thing Model
<<Query>
  <DeleteAll>
    <PhidgetServoModel>
      <PhidServoId ne=""/>
    </PhidgetServoModel>
  </DeleteAll>
</Query>


DELETE Result

Delete PhidgetServoModel Thing Model Result
<DeleteAll Status="Success">
  <Result>
    <PhidgetServoModel>
      <PhidServoId>KNJOOOBZAAAAUAABA72MMI6E</PhidServoId>
      <PhidgetDeviceType>PhidgetAdvancedServo</PhidgetDeviceType>
      <ServoAngle>110</ServoAngle>
      <DeviceInterfaceIndex>0</DeviceInterfaceIndex>
      <ServoProtocolURL>phid://</ServoProtocolURL>
    </PhidgetServoModel>
  </Result>
</DeleteAll>

Note: If a ThingModel is combined with a ThingFacet, creation of a ThingModel results in deleting an instance results in cleanup of connections with actual things as per the protocol Handler used.

 

 

FIND

PhidgetServo Thing Model
<Query>
  <Find format="all">
    <PhidgetServoModel>
      <PhidServoId ne="" />
    </PhidgetServoModel>
  </Find>
</Query>

 

Find result: Format="all" - returns all the internal attribute data as well.

PhidgetServoModel ThingModel Find Result
<Find Status="Success" Format="all">
  <Result>
    <PhidgetServoModel QName="Atomiton.PhidgetServos.PhidgetServoModel">
      <PhidServoId>KNJOOOBZAAAAUAABA72MMI6E</PhidServoId>
      <PhidgetDeviceType Value="PhidgetAdvancedServo" Known="PhidgetAdvancedServo" Version="1" Timestamp="1457384798266" DateTime="2016-03-07 13:06:38.266" QName="Atomiton.PhidgetServos.PhidgetServoModel.PhidgetDeviceType" FName="PhidgetDeviceType"/>
      <ServoAngle Value="110" Known="110" Version="1" Timestamp="1457384798266" DateTime="2016-03-07 13:06:38.266" QName="Atomiton.PhidgetServos.PhidgetServoModel.ServoAngle" FName="ServoAngle"/>
      <DeviceInterfaceIndex Value="0" Known="0" Version="1" Timestamp="1457384798266" DateTime="2016-03-07 13:06:38.266" QName="Atomiton.PhidgetServos.PhidgetServoModel.DeviceInterfaceIndex" FName="DeviceInterfaceIndex"/>
      <ServoProtocolURL Value="phid://" Known="phid://" Version="1" Timestamp="1457384798265" DateTime="2016-03-07 13:06:38.265" QName="Atomiton.PhidgetServos.PhidgetServoModel.ServoProtocolURL" FName="ServoProtocolURL"/>
    </PhidgetServoModel>
  </Result>
</Find>

 

Note:

  • No labels