FRAMES NO FRAMES | |||||||
| |||||||
SUMMARY: IMPORT | CONSTANT | FIELD | ACTION | DETAIL: IMPORT | CONSTANT | FIELD | ACTION |
com.apama.cumulocity.ManagedObject("49","","temp_sensor",["c8y_Restart"],["c8y_Temperature","c8y_Light"], ["childDevRefIds"],["childAstRefIds"],["devParentIds"],["assetParentIds"],{"lat":1.0},{"c8y_IsDevice":{}})
// Create a ManagedObject:<br>
ManagedObject createManagedObject := new ManagedObject;
createManagedObject.name := "myDevice";
createManagedObject.params.add("c8y_IsDevice", new dictionary<any, any>);
send createManagedObject to ManagedObject.SEND_CHANNEL;
// Update the name:<br>When listening for events of this type from Cumulocity, use the isCreate() and/or isUpdate() actions within the listener to distinguish between create and update events. If the event was created outside of Cumulocity, then both isCreate() and isUpdate() will return false.
ManagedObject updateManagedObject := new ManagedObject;
updateManagedObject.id := "deviceId";
updateManagedObject.name := "myDevice_UpdatedName";
send updateManagedObject to ManagedObject.SEND_CHANNEL;
Constant summary | |
---|---|
string | CHANNEL := "cumulocity.devices" The channel to which ManagedObject events are sent from the transport.
|
string | NOTIFICATION_CREATED := "CREATED" Value of PARAM_NOTIFICATION that indicates this is a new object. |
string | NOTIFICATION_UPDATED := "UPDATED" Value of PARAM_NOTIFICATION that indicates this is an update to an existing object. |
string | PARAM_NOTIFICATION := ".apama_notificationType" Entry in params that identifies if this is a new object or an update to an existing object. Entry will have a value matching either NOTIFICATION_CREATED or NOTIFICATION_UPDATED. |
string | SEND_CHANNEL := "CumulocityIoTGenericChain" The channel to send a ManagedObject event to update an existing managed object in Cumulocity. |
string | SUBSCRIBE_CHANNEL := "cumulocity.devices" The channel to which ManagedObject events are sent from the transport. |
string | UPDATE_CHANNEL := "CumulocityIoTGenericChain" The channel to send a ManagedObject event to update an existing managed object in Cumulocity.
|
Field summary | |
---|---|
string | id The unique identifier for this specific managed object (device). |
string | type The type of the device. |
string | name The name of this ManagedObject. Note: This does not have to be a unique value. |
sequence<string> | supportedOperations List of supported operations for this device. |
sequence<string> | supportedMeasurements List of supported measurements for this device. |
sequence<string> | childDeviceIds Ids of child devices. Note: This field cannot be set by sending ManagedObject events. |
sequence<string> | childAssetIds Ids of child assets. Note: This field cannot be set by sending ManagedObject events. |
sequence<string> | deviceParentIds Ids of parent devices. Note: This field cannot be set by sending ManagedObject events. |
sequence<string> | assetParentIds Ids of parent assets. Note: This field cannot be set by sending ManagedObject events. |
dictionary<string, float> | position Contains all numeric values within the 'c8y_Position' fragment. Typically these are latitude, longitude, altitude and accuracy. Note: This field cannot be used to delete the entire c8y_Position fragment. |
dictionary<string, any> | params Other fragments for this ManagedObject. Note: This dictionary cannot be manipulated to delete fragments in the ManagedObject. |
Action summary | |
---|---|
dictionary<string, any> |
getC8yPosition() Generates a c8y_Position object based on the relevant position and params within the ManagedObject. |
boolean |
isCreate() Check if this ManagedObject instance was as a result of a managed object being created in Cumulocity. |
boolean |
isUpdate() Check if this ManagedObject instance was as a result of a managed object being updated in Cumulocity. |
void |
setC8yPosition(any c8y_Position) Sets the c8y_Position members of the ManagedObject directly from a dictionary. |
com.apama.cumulocity.ResponseWrapper |
withChannelResponse(integer reqId, dictionary<string, string> headers) Create or update a ManagedObject in Cumulocity and receive a response event confirming the change on ManagedObject.SUBSCRIBE_CHANNEL channel. |
com.apama.cumulocity.ResponseWrapper |
withResponse(integer reqId, dictionary<string, string> headers) Create or update a ManagedObject in Cumulocity IoT and receive a response event on the default channel, confirming the change.
|
Constant detail |
---|
string CHANNEL := "cumulocity.devices"
string NOTIFICATION_CREATED := "CREATED"Value of PARAM_NOTIFICATION that indicates this is a new object.
string NOTIFICATION_UPDATED := "UPDATED"Value of PARAM_NOTIFICATION that indicates this is an update to an existing object.
string PARAM_NOTIFICATION := ".apama_notificationType"Entry in params that identifies if this is a new object or an update to an existing object. Entry will have a value matching either NOTIFICATION_CREATED or NOTIFICATION_UPDATED.
string SEND_CHANNEL := "CumulocityIoTGenericChain"The channel to send a ManagedObject event to update an existing managed object in Cumulocity.
string SUBSCRIBE_CHANNEL := "cumulocity.devices"The channel to which ManagedObject events are sent from the transport.
string UPDATE_CHANNEL := "CumulocityIoTGenericChain"
Field detail |
---|
sequence<string> assetParentIdsIds of parent assets. Note: This field cannot be set by sending ManagedObject events.
sequence<string> childAssetIdsIds of child assets. Note: This field cannot be set by sending ManagedObject events.
sequence<string> childDeviceIdsIds of child devices. Note: This field cannot be set by sending ManagedObject events.
sequence<string> deviceParentIdsIds of parent devices. Note: This field cannot be set by sending ManagedObject events.
string idThe unique identifier for this specific managed object (device).
string nameThe name of this ManagedObject. Note: This does not have to be a unique value.
dictionary<string, any> paramsOther fragments for this ManagedObject. Note: This dictionary cannot be manipulated to delete fragments in the ManagedObject.
dictionary<string, float> positionContains all numeric values within the 'c8y_Position' fragment. Typically these are latitude, longitude, altitude and accuracy. Note: This field cannot be used to delete the entire c8y_Position fragment.
sequence<string> supportedMeasurementsList of supported measurements for this device.
sequence<string> supportedOperationsList of supported operations for this device.
string typeThe type of the device.
Action detail |
---|
dictionary<string, any> getC8yPosition()Generates a c8y_Position object based on the relevant position and params within the ManagedObject.
boolean isCreate()Check if this ManagedObject instance was as a result of a managed object being created in Cumulocity.
boolean isUpdate()Check if this ManagedObject instance was as a result of a managed object being updated in Cumulocity.
void setC8yPosition(any c8y_Position)Sets the c8y_Position members of the ManagedObject directly from a dictionary.
on all Event(type="locationUpdate") as evt {
ManagedObject mo := new ManagedObject;
mo.id := evt.source;
mo.setC8yPosition(evt.params.getOrDefault("c8y_Position"));
send mo to ManagedObject.SEND_CHANNEL;
}
com.apama.cumulocity.ResponseWrapper withChannelResponse(integer reqId, dictionary<string, string> headers)Create or update a ManagedObject in Cumulocity and receive a response event confirming the change on ManagedObject.SUBSCRIBE_CHANNEL channel.
monitor.subscribe(ManagedObject.SUBSCRIBE_CHANNEL);
ManagedObject m := new ManagedObject;
// set fields in m
integer reqId := com.apama.cumulocity.Util.generateReqId();
// myapp is the user application key
on ObjectCommitted(reqId=reqId) as commit and not ObjectCommitFailed(reqId=reqId) {
// do something
}
on ObjectCommitFailed(reqId=reqId) as failure and not ObjectCommitted(reqId=reqId) {
// do something
}
send m.withChannelResponse(reqId, {"X-Cumulocity-Application-Key": "myapp"}) to ManagedObject.SEND_CHANNEL;
com.apama.cumulocity.ResponseWrapper withResponse(integer reqId, dictionary<string, string> headers)
ManagedObject m := new ManagedObject;
// set fields in m
integer reqId := com.apama.cumulocity.Util.generateReqId();
// myapp is the user application key
on ObjectCommitted(reqId=reqId) as commit and not ObjectCommitFailed(reqId=reqId) {
// do something
}
on ObjectCommitFailed(reqId=reqId) as failure and not ObjectCommitted(reqId=reqId) {
// do something
}
send m.withResponse(reqId, {"X-Cumulocity-Application-Key": "myapp"}) to ManagedObject.SEND_CHANNEL;
FRAMES NO FRAMES | |||||||
| |||||||
SUMMARY: IMPORT | CONSTANT | FIELD | ACTION | DETAIL: IMPORT | CONSTANT | FIELD | ACTION |