baseObject = HttpObjectService( ).baseObject # make an instance of the service, default object root and default port 8000 print 'httpd started at', baseObject.Properties.get('httpService') # create the weather station resource template # first the description baseObject.Description.set( (URIRef('sensors/rhvWeather-01'), RDFS.Class, Literal('SmartObject'))) baseObject.Description.set((URIRef('sensors/rhvWeather-01'), RDFS.Resource, Literal('SensorSystem'))) baseObject.Description.set( (URIRef('sensors/rhvWeather-01'), RDF.type, Literal('WeatherSensor'))) # sensors resource under the baseObject for all sensors sensors = baseObject.create({'resourceName': 'sensors',\ 'resourceClass': 'SmartObject'}) # top level object container for sensors, default class is SmartObject #weather resource under sensors for the weather sensor weather = sensors.create({'resourceName': 'rhvWeather-01', \ 'resourceClass': 'SmartObject'}) # create a default class SmartObject for the weather sensor cluster # make a reference to the weather sensor object Description and build an example graph (could use the built-in reference as well) weather.description = weather.Resources.get('Description') weather.description.set( (URIRef('sensors/rhvWeather-01/outdoor_temperature'), RDFS.Resource, Literal('sensor'))) weather.description.set( (URIRef('sensors/rhvWeather-01/outdoor_temperature'), RDF.type, Literal('temperature'))) weather.description.set( (URIRef('sensors/rhvWeather-01/outdoor_humidity'), RDFS.Resource, Literal('sensor')))
import sys if __name__ == '__main__' : baseObject = HttpObjectService().baseObject # make an instance of the service, default object root and default port 8000 print 'httpd started at', baseObject.Properties.get('httpService') # create the weather station resource template # first the description baseObject.Description.set((URIRef('sensors/rhvWeather-01'), RDFS.Class, Literal('SmartObject'))) baseObject.Description.set((URIRef('sensors/rhvWeather-01'), RDFS.Resource, Literal('SensorSystem'))) baseObject.Description.set((URIRef('sensors/rhvWeather-01'), RDF.type, Literal('WeatherSensor'))) # sensors resource under the baseObject for all sensors sensors = baseObject.create({'resourceName': 'sensors',\ 'resourceClass': 'SmartObject'}) # top level object container for sensors, default class is SmartObject #weather resource under sensors for the weather sensor weather = sensors.create({'resourceName': 'rhvWeather-01', \ 'resourceClass': 'SmartObject'}) # create a default class SmartObject for the weather sensor cluster # make a reference to the weather sensor object Description and build an example graph (could use the built-in reference as well) weather.description = weather.Resources.get('Description') weather.description.set((URIRef('sensors/rhvWeather-01/outdoor_temperature'), RDFS.Resource, Literal('sensor'))) weather.description.set((URIRef('sensors/rhvWeather-01/outdoor_temperature'), RDF.type, Literal('temperature'))) weather.description.set((URIRef('sensors/rhvWeather-01/outdoor_humidity'), RDFS.Resource, Literal('sensor'))) weather.description.set((URIRef('sensors/rhvWeather-01/outdoor_humidity'), RDF.type, Literal('humidity'))) weather.description.set((URIRef('sensors/rhvWeather-01/sealevel_pressure'), RDFS.Resource, Literal('sensor'))) weather.description.set((URIRef('sensors/rhvWeather-01/sealevel_pressure'), RDF.type, Literal('pressure'))) weather.description.set((URIRef('sensors/rhvWeather-01/indoor_temperature'), RDFS.Resource, Literal('sensor'))) weather.description.set((URIRef('sensors/rhvWeather-01/indoor_temperature'), RDF.type, Literal('temperature'))) weather.description.set((URIRef('sensors/rhvWeather-01/indoor_humidity'), RDFS.Resource, Literal('sensor')))
from ObjectService.HttpObjectService import HttpObjectService from ObjectService.CoapObjectService import CoapObjectService from time import sleep import sys if __name__ == '__main__' : baseObject = HttpObjectService(port=8001).baseObject # make a service instance at port 8001 print 'httpd started at', baseObject.Properties.get('httpService') #coapService = CoapObjectService(baseObject) # create the weather station resource template # emulate the .well-known/core interface baseObject.create({'resourceName': '.well-known','resourceClass': 'SmartObject'},\ ).create({'resourceName': 'core','resourceClass': 'LinkFormatProxy'}) # sensors resource under the baseObject for all sensors # top level object container for sensors, default class is SmartObject sensors = baseObject.create({'resourceName': 'sensors', 'resourceClass': 'SmartObject'}) #weather resource under sensors for the weather sensor # create a default class SmartObject for the weather sensor cluster weather = sensors.create({'resourceName': 'rhvWeather-01', 'resourceClass': 'SmartObject'}) # example description in simple link-format like concepts baseObject.Description.set((URIRef('sensors/rhvWeather-01'), RDFS.Class, Literal('SmartObject'))) baseObject.Description.set((URIRef('sensors/rhvWeather-01'), RDF.type, Literal('SensorSystem'))) baseObject.Description.set((URIRef('sensors/rhvWeather-01'), RDFS.Resource, Literal('Weather'))) # baseObject.Description.set((URIRef('sensors/rhvWeather-01/outdoor_temperature'), RDF.type, Literal('sensor')))
from ObjectService.HttpObjectService import HttpObjectService from ObjectService.CoapObjectService import CoapObjectService from time import sleep import sys if __name__ == '__main__': baseObject = HttpObjectService( ).baseObject # make an instance of the service, default object root and default port 8000 print 'httpd started at', baseObject.Properties.get('httpService') coapService = CoapObjectService(baseObject) # create the weather station resource template # emulate the .well-known/core interface baseObject.create({'resourceName': '.well-known','resourceClass': 'SmartObject'},\ ).create({'resourceName': 'core','resourceClass': 'LinkFormatProxy'}) # sensors resource under the baseObject for all sensors # top level object container for sensors, default class is SmartObject sensors = baseObject.create({ 'resourceName': 'sensors', 'resourceClass': 'SmartObject' }) #weather resource under sensors for the weather sensor # create a default class SmartObject for the weather sensor cluster weather = sensors.create({ 'resourceName': 'rhvWeather-01', 'resourceClass': 'SmartObject' })