Using operations
The
com.apama.cumulocity.Operation event represents a device operation. If the configuration option
subscribeToOperations is enabled (see
Configuring the Cumulocity IoT transport) or if you
Subscribe to the
operations stream, this event is sent to the
com.apama.cumulocity.Operation.SUBSCRIBE_CHANNEL (same as
cumulocity.operations) channel. This event contains the identifier of the source, a status, and optional parameters.
Example of an operation:
Operation("12345","deviceId", "EXECUTING", new dictionary<string,any>})
Example
The following is a simple example of how to receive, create and send operations:
// Subscribe to receive all the operations published from Cumulocity IoT
monitor.subscribe(Operation.SUBSCRIBE_CHANNEL);
on all Operation() as o {
log o.toString() at INFO;
// Update an operation
o.status := "EXECUTING";
send o to Operation.SEND_CHANNEL;
}
// Create an operation
Operation operation := new Operation;
operation.source := "<MANAGED_OBJECT_ID>";
operation.status := "PENDING";
operation.params.add("c8y_Message", {"text": "Device Operation"});
send operation to Operation.SEND_CHANNEL;