8.1 Discovery Queries
By using the oneM2M Base Ontology in the <semanticDescriptor> resources we can send queries to the oneM2M CSE to find the services offered by a device and further query those services to discover the oneM2M primitives to access those services.
Here is a list of queries that we will support for all three of the models:
Query 1: Find all washing machines of manufacturer XYZ.
PREFIX sn: <http://www.XYZ.com/WashingMachines#XYZ_Cool>
PREFIX m2m: <https://git.onem2m.org/MAS/BaseOntology/raw/master/base_ontology.owl#>
PREFIX saref: <https://saref.etsi.org/core/>
SELECT ?res ?wm
WHERE {
?wm a sn:XYZ_Cool .
?wm m2m:oneM2MTargetURI ?res .
}
res | wm |
---|---|
"myWashingMachine" | http://www.XYZ.com/WashingMachines#XYZ_CoolWASH_XYZ_myWashingMachine |
"My-WashingMachine" | http://www.XYZ.com/WashingMachines#XYZ_CoolWASH_XYZ_My-WashingMachine |
"deviceClothesWasher" | http://www.XYZ.com/WashingMachines#XYZ_CoolWASH_XYZ_deviceClothesWasher |
Query 2: List all the commands offered by a specific washing machine
PREFIX sn:<http://www.XYZ.com/WashingMachines#>
PREFIX m2m: <https://git.onem2m.org/MAS/BaseOntology/raw/master/base_ontology.owl#>
PREFIX saref: <https://saref.etsi.org/core/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?wm ?operation ?command
WHERE {
?wm m2m:hasOperation ?operation .
?operation a ?command .
VALUES ?wm {<http://www.XYZ.com/WashingMachines#XYZ_CoolWASH_XYZ_myWashingMachine>} .
?command rdfs:subClassOf saref:Command
}
This lists the operations and commands and functions associated with the commands
wm | operation | command |
---|---|---|
http://www.XYZ.com/WashingMachines#XYZ_CoolWASH_XYZ_myWashingMachine | http://www.XYZ.com/WashingMachines#XYZ_CoolWASH_XYZ-StartStopFunction-ON_Command_myWashingMachine | saref:OnCommand |
http://www.XYZ.com/WashingMachines#XYZ_CoolWASH_XYZ_myWashingMachine | http://www.XYZ.com/WashingMachines#XYZ_CoolWASH_XYZ-StartStopFunction-OFF_Command_myWashingMachine | saref:OffCommand |
http://www.XYZ.com/WashingMachines#XYZ_CoolWASH_XYZ_myWashingMachine | http://www.XYZ.com/WashingMachines#XYZ_CoolWASH_XYZ-StartStopFunction-TOGGLE_Command_myWashingMachine | saref:ToggleCommand |
http://www.XYZ.com/WashingMachines#XYZ_CoolWASH_XYZ_myWashingMachine | http://www.XYZ.com/WashingMachines#XYZ_CoolWASH_XYZ-MonitoringFunction-WashingMachineStatus_myWashingMachine | saref:GetCommand |