8.2 Interoperability Queries

The following queries demonstrate how interoperability is achieved using semantics in oneM2M. Using the results of the queries above we can issue the following types of queries to determine exactly how to use the services of the washing machines, without regard the way it was modeled. This query shows how to use the saref:GetCommand for the SDT model of the washing machine

Query 3: How do I use saref:GetCommand of the SDT washing machine

PREFIX m2m: <https://git.onem2m.org/MAS/BaseOntology/raw/master/base_ontology.owl#>
PREFIX saref: <https://saref.etsi.org/core/>

SELECT ?sarefCommand ?method ?targetURI ?attr ?res
WHERE {
    ?wm m2m:hasOperation ?operation .
    ?operation a m2m:Operation .
    ?operation m2m:oneM2MMethod ?method .
    optional {?operation m2m:hasDataRestriction ?res} .
    optional {?operation m2m:oneM2Mattribute ?attr} .
    ?operation a ?sarefCommand .
    ?operation m2m:oneM2MTargetURI ?targetURI .
    VALUES ?wm {<http://www.XYZ.com/WashingMachines#XYZ_CoolWASH_XYZ_deviceClothesWasher>} .
    VALUES ?sarefCommand {saref:GetCommand}
}
The result of executing query 3 is:

sarefCommand Method targetURI Attr res
"RETRIEVE" "/deviceClothesWasher/runState" "currentMachineState"

Query 3 can be modified for demonstration purposes to show the response for all three washing machines by removing the line beginning with "VALUES ?wm". The result of this query can be compared with the expected responses described in clause 7.2.1.

sarefCommand method targetURI attr res
"RETRIEVE" "/deviceClothesWasher/runState" "currentMachineState"
"RETRIEVE" "/My-WashingMachine/sarefWashingMachine/ MonitorService" "WashingMachineStatus"
"RETRIEVE" "/myWashingMachine/status/la"

Query 4: How do I use all commands of the washing machine modeled with SDT

SELECT ?sarefCommand ?method ?targetURI ?attr ?res
WHERE {
    ?wm m2m:hasOperation ?operation .
    ?operation a m2m:Operation .
    ?operation m2m:oneM2MMethod ?method .
    optional {?operation m2m:hasDataRestriction ?res} .
    optional {?operation m2m:oneM2Mattribute ?attr} .
    ?operation a ?sarefCommand .
    ?operation m2m:oneM2MTargetURI ?targetURI .
    VALUES ?wm {&lt;http://www.XYZ.com/WashingMachines#XYZ_CoolWASH_XYZ_deviceClothesWasher>} .
    VALUES ?sarefCommand {saref:GetCommand saref:OnCommand saref:OffCommand saref:ToggleCommand}
    }
ORDER BY ?sarefCommand

This query can be issued after discovering the appropriate device to dynamically build the commands needed to perform operations on the device.

sarefCommand method targetURI attr res
saref:GetCommand "RETRIEVE" "/deviceClothesWasher/runState" "currentMachineState"
saref:OffCommand "UPDATE" "/deviceClothesWasher/binarySwitch" "powerState" "False"
saref:OnCommand "UPDATE" "/deviceClothesWasher/binarySwitch" "powerState" "True"
saref:ToggleCommand "UPDATE" "/deviceClothesWasher/binarySwitch/toggle"

The SPARQL query that is used is a critical component of the ability to dynamically determine the API of the model. The tokens following the SELECT statement are variables that will be included in the response. For this use case we need to know what oneM2M primitive to send to a CSE to perform the desired command. The method implies the type of resource that is at the targetURI. An UPDATE method implies that the targetURI is a <flexContainer> whereas if the method is CREATE then the resource type being created will be a <contentInstance>. In the case of a <flexContainer> "attr" specifies the custom attribute that needs to be updated and the "res" specifies the value to use in that attribute.

If we were designing a smartphone application to control the washing machine it might look like the wireframe shown below.

Figure 11: Sample application wireframe

Figure 11: Sample application wireframe