Dog Ont In Dog

853 views
761 views

Published on

How to exploit DogOnt concepts and instances to empower the DOG residential gateway

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
853
On SlideShare
0
From Embeds
0
Number of Embeds
10
Actions
Shares
0
Downloads
15
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Dog Ont In Dog

  1. 1. DogOnt in Dog<br />Ontology related tasks in Dog2.0<br />Dario Bonino<br />Politecnicodi Torino, e-Lite research group<br />http://elite.polito.it <br />
  2. 2. Outline<br />Dog2.0<br />Device categories<br />Device models<br />Automatic Generation<br />Queries<br />4/30/2010<br />DogOnt in Dog: Ontology related tasks in Dog2.0<br />2<br />
  3. 3. Dog2.0<br />Device instances and classes in DogOnt can be associated to 2 different components of the Dog2.0 architecture<br />DeviceCategory<br />Defines how a Driver service and a Device service can cooperate (by defining a Java Interface)<br />DeviceModel<br />A representation of a physical device that can be attached to a Driver service<br />4/30/2010<br />DogOnt in Dog: Ontology related tasks in Dog2.0<br />3<br />
  4. 4. Device Category (structure)<br />4/30/2010<br />DogOnt in Dog: Ontology related tasks in Dog2.0<br />4<br />Lighting<br />public interface Lamp extends Lighting<br />{<br />public static intMATCH_TYPE=100;<br />public static intMATCH_SUB_TYPE=50;<br />public static intMATCH_MANUFACTURER=0;<br />public static StringON_OFF_STATE = "OnOffState";<br />public void off();<br />public void on();<br />}<br />isA<br />Lamp<br />OnOffState<br />hasState<br />instance<br />Lamp<br />hasFunctionality<br />OnOffFunctionality<br />hasCommand<br />hasCommand<br />OnCommand<br />OffCommand<br />
  5. 5. Device Category (Hi-Fi)<br />4/30/2010<br />DogOnt in Dog: Ontology related tasks in Dog2.0<br />5<br />package it.polito.elite.domotics.model.devicecategory;<br /> /**<br />* HiFiCategory - automatically generated by DogOnt2Dog<br />*/<br />public interface HiFi extends Entertainment<br />{<br /> public static intMATCH_TYPE=100;<br /> public static intMATCH_SUB_TYPE=50;<br /> public static intMATCH_MANUFACTURER=0;<br /> public static String STAND_BY_ON_OFF_STATE = "StandByOnOffState";<br /> public static String SOURCE_SELECTION_STATE = "SourceSelectionState";<br /> public static String PLAY_STATE = "PlayState";<br /> public static String TUNER_STATE = "TunerState";<br /> public static String VOLUME_LEVEL_STATE = "VolumeLevelState";<br /> public void stop();<br /> public void stepUp();<br /> public void rew();<br /> public void set(Object value);<br /> public void setVolume(Integer volume);<br /> public void next();<br /> …<br /> public void goToTrack(Integer trackNumber);<br />}<br />
  6. 6. Device Model (Structure)<br />4/30/2010<br />DogOnt in Dog: Ontology related tasks in Dog2.0<br />6<br />public class DogLamp extends DogDevice implements Lamp<br />{<br /> public DogLamp(BundleContext context, Properties properties){<br /> super(context);<br /> if(properties==null)<br /> properties=new Properties();<br />properties.put(Constants.DEVICE_CATEGORY, Lamp.class.getCanonicalName());<br />this.setDeviceProperties(properties);<br />this.states.put(Lamp.ON_OFF_STATE,<br /> new DogStatusVariable(<br />properties.getProperty(DogDeviceCostants.DEVICEURI), <br /> new StatusVariable(Lamp.ON_OFF_STATE, StatusVariable.CM_DER, "-"),<br /> "current state of Lamp",true));<br />this.registerDevice(Lamp.class.getName());<br />this.registerStatusVariable();<br /> }<br /> @Override<br /> public void off(){<br /> ((Lamp) this.driver).off();<br /> }<br /> @Override<br /> public void on(){<br /> ((Lamp) this.driver).on();<br /> }<br />}<br />Lighting<br />OnOffState<br />hasState<br />isA<br />Lamp<br />Lamp<br />hasFunctionality<br />OffCommand<br />instance<br />hasCommand<br />OnOffFunctionality<br />OnCommand<br />
  7. 7. Automatic Generation<br />Template based<br />Common structure of device categories and device models<br />Fill “placeholders” (possibly empty) with information extracted from DogOnt<br />SPARQL<br />Works on the schema only<br />4/30/2010<br />DogOnt in Dog: Ontology related tasks in Dog2.0<br />7<br />
  8. 8. Automatic Generation (recipe)<br />Device Categories<br />Device Models<br />GetAllDevicesWithAncestors<br />Foreach device<br />getDeviceCommands<br />getDeviceStates<br />Write the device category code<br />Compile all<br />Jar all with manifest (bundleize)<br />Use in Dog2.0<br />GetAllDevicesWithAncestors<br />Foreach device<br />getDeviceCommands<br />getDeviceStates<br />Write the device model code<br />Compile all<br />Jar all with manifest (bundleize)<br />Use in Dog2.0<br />4/30/2010<br />DogOnt in Dog: Ontology related tasks in Dog2.0<br />8<br />
  9. 9. Queries (1) - Devices<br />Get all devices with ancestors<br />SELECT DISTINCT ?x WHERE { ?x rdfs:subClassOfdogont:Controllable FILTER (?x!=owl:Nothing)} ORDER BY ?x<br />Recurse over ?x and call<br />OntClassdeviceClass = this.modelLoader.getPlainOntModel().getOntClass(deviceURI);<br />ExtendedIteratoriter = deviceClass.listSuperClasses();<br />4/30/2010<br />DogOnt in Dog: Ontology related tasks in Dog2.0<br />9<br />
  10. 10. Queries (2) - Commands<br />Non-Parametric Commands<br />Parametric Commands<br />SELECT DISTINCT ?commandValue WHERE { dogont:"+deviceClass+" rdfs:subClassOf [rdf:typeowl:Restriction; owl:onPropertydogont:hasFunctionality; owl:someValuesFrom ?functionality] . ?functionality rdfs:subClassOfdogont:ControlFunctionality. ?functionality rdfs:subClassOf [rdf:typeowl:Restriction; owl:onPropertydogont:hasCommand; owl:someValuesFrom ?command] . ?command rdfs:subClassOfdogont:NonParametricCommand . ?command rdfs:subClassOf [rdf:typeowl:Restriction; owl:onPropertydogont:realCommandName; owl:hasValue ?commandValue]} ORDER BY ?commandValue<br />SELECT DISTINCT ?commandValue ?commandParamValue WHERE { dogont:"+deviceClass+" rdfs:subClassOf [rdf:typeowl:Restriction; owl:onPropertydogont:hasFunctionality; owl:someValuesFrom ?functionality] . ?functionality rdfs:subClassOfdogont:ControlFunctionality . ?functionality rdfs:subClassOf [rdf:typeowl:Restriction; owl:onPropertydogont:hasCommand; owl:someValuesFrom ?command] . ?command rdfs:subClassOfdogont:ParametricCommand . ?command rdfs:subClassOf [rdf:typeowl:Restriction; owl:onPropertydogont:realCommandName; owl:hasValue ?commandValue] . ?command rdfs:subClassOf [rdf:typeowl:Restriction; owl:onPropertydogont:commandParamName; owl:hasValue ?commandParamValue]} ORDER BY ?commandValue<br />4/30/2010<br />DogOnt in Dog: Ontology related tasks in Dog2.0<br />10<br />
  11. 11. Queries(3) - States<br />SELECT ?state WHERE{ dogont:"+deviceClass+" rdfs:subClassOf [rdf:typeowl:Restriction; owl:onPropertydogont:hasState; owl:someValuesFrom ?state] } ORDER BY ?state<br />4/30/2010<br />DogOnt in Dog: Ontology related tasks in Dog2.0<br />11<br />
  12. 12. Some Figures<br />Total execution time <10s<br />~7 seconds to load and reason the ontology<br />Amount of compiled classes<br />228 classes<br />114 device categories<br />114 device models<br />4/30/2010<br />DogOnt in Dog: Ontology related tasks in Dog2.0<br />12<br />
  13. 13. Rules Generation (DOG1.0)<br />Query<br />Rule<br />SELECT DISTINCT ?x ?y ?v ?c ?d ?class ?cvWHERE { ?x a dogont:Controllable . ?y a dogont:Controllable . ?x dogont:controlledObject?y . ?x dogont:hasFunctionality ?f . ?f dogont:hasNotification ?n . ?n dogont:notificationValue?v . ?n dogont:generateCommand ?c . ?d dogont:hasFunctionality ?f2 . ?f2 dogont:hasCommand ?c . ?c rdf:type ?class . ?class rdfs:subClassOfdogont:DiscreteCommand . ?class rdfs:subClassOf [rdf:typeowl:Restriction; owl:onPropertydogont:realCommandName; owl:hasValue?cv]}<br />when<br />dev:Device( id == "http://elite.polito.it/ontologies/simplehome.owl#"?x")<br />cmd:StateCommand(state =="?v")<br />status:DeviceStatus( status == cmd, device == dev)<br />rulesCore:RulesCore()<br />message: DogMessage(dataType == DogBundle.DataTypeEnum.DEVICE_STATUS, data == status)<br />then<br />Device newDev = new Device("http://elite.polito.it/ontologies/DOGHouseModel.owl#"+?y+");<br />DeviceStatusnewStatus = new DeviceStatus(newDev, new StateCommand("+?cv+”,StatusTypeEnum.DISCRETE));<br />DogMessagemyCmd = new DogMessage(MessageTypeEnum.CMD,newGregorianCalendar(), message.getDataType(), newStatus); <br />rulesCore.takeActions(myCmd); <br />4/30/2010<br />DogOnt in Dog: Ontology related tasks in Dog2.0<br />13<br />
  14. 14. Questions?<br />Dario Bonino<br />dario.bonino@polito.it<br />

×