Examples of CRUD Operation on a ThingModel:
CREATE:
Code Block |
---|
language | ruby |
---|
title | Create PhidgetServo Thing Model |
---|
linenumbers | true |
---|
|
#
Create:
PhidgetServoModel:
ServoProtocolURL: "phid://"
PhidgetDeviceType: "PhidgetAdvancedServo"
DeviceInterfaceIndex: 0
ServoAngle: 110 |
CREATE RESULT:
Code Block |
---|
language | ruby |
---|
title | Create PhidgetServoModel Result |
---|
linenumbers | true |
---|
|
#
Create(Status: "Success"):
PhidgetServoModel:
PhidServoId: "KNJN2YRVAAAAUAABA7LIQ4Y6"
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") |
Note: If a ThingModel is combined with a ThingFacet, creation of a ThingModel results in instantiating (Trigger) of a ThingFacet action.
UPDATE:
Code Block |
---|
language | ruby |
---|
title | PhidgetServo Thing Model |
---|
linenumbers | true |
---|
|
#
Query:
Find(format: "version"):
PhidgetServoModel as: "var.PS"):
PhidServoId(ne: "")
SetResponseData:
key: Message.Value.Find.Result.PhidgetServoModel.ServoAngle.Value
value: 120
Update:
from: Result
Include: $Response.Message.Value.Find |
UPDATE Result:
Code Block |
---|
language | ruby |
---|
title | PhidgetServo Thing Model |
---|
linenumbers | true |
---|
|
#
Find(Status: "Success", Format: "version"):
Result:
PhidgetServoModel:
PhidServoId: "KNJPIFR6AAAAUAABA67ZRBQO"
PhidgetDeviceType(Value: "PhidgetAdvancedServo", Version: "1")
ServoAngle(Version: "1", Value: "120")
DeviceInterfaceIndex(Value: "0", Version: "1")
ServoProtocolURL(Value: "phid://", Version: "1") |
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:
Code Block |
---|
language | ruby |
---|
title | Delete PhidgetServoModel Thing Model |
---|
linenumbers | true |
---|
|
#
Query:
DeleteAll:
PhidgetServoModel:
PhidServoId(ne: "") |
DELETE Result
Code Block |
---|
language | ruby |
---|
title | Delete PhidgetServoModel Thing Model Result |
---|
linenumbers | true |
---|
|
#
DeleteAll(Status: "Success"):
Result:
PhidgetServoModel:
PhidServoId: "KNJOOOBZAAAAUAABA72MMI6E"
PhidgetDeviceType: "PhidgetAdvancedServo"
ServoAngle: 110
DeviceInterfaceIndex: 0
ServoProtocolURL: "phid://" |
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
Code Block |
---|
language | xml |
---|
title | PhidgetServo Thing Model |
---|
linenumbers | true |
---|
|
#
Query:
Find(format: "all"):
PhidgetServoModel:
PhidServoId(ne: "") |
Find result: Format="all" - returns all the internal attribute data as well.
Code Block |
---|
language | ruby |
---|
title | PhidgetServoModel ThingModel Find Result |
---|
linenumbers | true |
---|
|
#
Find(Status: "Success", Format: "all"):
Result:
PhidgetServoModel(QName: "Atomiton.PhidgetServos.PhidgetServoModel"):
PhidServoId: "KNJOOOBZAAAAUAABA72MMI6E"
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") |
Note: