VirtualDevice
public protocol VirtualDevice : AbstractVirtualDevice
VirtualDevice for a device-client adds methods to handle write-only and executable actions.
-
Set callback for handling an action
Throws
ClientError.argumentifactionNameis not an action on the model.deprecated: This API does not support actions with multiple arguments Use
setOnAction.
Declaration
Swift
func setOnCall(actionName: String, callback: ((VirtualDevice, Any?)->())?) throwsParameters
actionNameThe action name
callbackThe function to invoke
-
Set a callback that is invoked when an action for the given
actionNameis received.Note that it is possible to set a callback for a specific action and to set a callback for all actions via
setOnAction. If there is a callback for the specific action and for all actions, both callbacks will be invoked, with the specific action invoked first.See
setOnActionDeclaration
Swift
func setOnAction(actionName: String, callback: ((ActionEvent) -> ())?) throwsParameters
actionNameThe action name from the device model
callbacka callback to invoke when an action is received, if
nil, the existing callback will be removed -
Set a callback that is invoked when any action in the device model is received.
Note that it is possible to set a callback for a specific action via
setOnAction. If there is a callback for the specific action and for all actions, both callbacks will be invoked, wiht the specific action invoked first.Ssee
setOnActionDeclaration
Swift
func setOnAction(callback: ((ActionEvent) -> ())?) throwsParameters
callbacka callback to invoke when an action is received, if
nil, the existing callback will be removed -
Create a custom data object for this VirtualDevice. The custom data object will be created with the given format URN.
Throws
ClientError.argumentif a device model format cannot be obtained fromformator if the format type is notDeviceModelFormatType.DATADeclaration
Swift
func createData(format: String) throws -> DataParameters
formatthe custom data message format URN.
Return Value
a
Dataobject -
Create an
Alertfor this VirtualDevice. The alert will be created with the given format URN.Throws
ClientError.argumentif a device model format cannot be obtained fromalertUrnor if the format is notDeviceModelFormatType.ALERTDeclaration
Swift
func createAlert(format: String) throws -> AlertParameters
formatthe alert format URN.
Return Value
an
Alertobject -
Offer to set the value of an attribute. The attribute value is set depending upon any policy that may have been configured for the attribute. If there is no policy for the given attribute, offer behaves as if the
AbstractVirtualDevice.set(attributeName:attributeValue)method were called. The value is validated according to the constraints in the device model. If the value is not valid, aClientError.argumentexception is raised.Throws
ClientError.argumentif the value is not valid, the attribute is not in the model,attributeNameisnil, or if the attribute is read-onlyDeclaration
Swift
func offer(attributeName: String, attributeValue: AnyObject) throws -> VirtualDeviceParameters
attributeNamethe name of an attribute from the device type model
attributeValuethe value to set
Return Value
this VirtualDevice instance
VirtualDevice Protocol Reference