def __init__(self, args): L(args.log) self.config = JOb(file(os.path.join(os.path.dirname(__file__), "..", "config.json"), "rb")) self.status = JSONObject() self.status.running = False self.wrappers = [] ResourceManagement.args = args ResourceManagement.config = self.config self.clock = None self.annotator = GenericAnnotation() self.stoppedClock = False # init triplestore if args.triplestore: ThreadedTriplestoreAdapter.triplestore = TripleStoreFactory.getTripleStore( self.config.triplestore.driver, self.config.triplestore ) # dump the graph with the static annotations StaticAnnotator.dumpGraph() if args.aggregate: # self.aggregator = AggregatorFactory.make(self.config.aggregationmethod, self.config.aggregation_configuration) # self.aggregator = AggregatorFactory.make() # TODO self.aggregator = GenericAggregator() self.aggregationQueue = QueueThread(handler=self.aggregateHandler) self.receiverQueue = QueueThread(handler=self.receiveHandler) # establish connection to the message bus if args.messagebus: threading.Thread(name="messageBusConnector", target=self.start_messagebus, args=(args,)).start() else: self.messageBusQueue = None if args.eventannotation: self.eventWrapper = GenericEventWrapper(self.messageBusQueue) else: self.eventWrapper = None if args.gdi: from CityPulseGdi.eu.citypulse.uaso.gdi.CityPulseGDInterface import CityPulseGDInterface self.gdiInterface = CityPulseGDInterface(self.config.gdi_db) # self.gdiInterface.removeAllSensorStreams() else: self.gdiInterface = None self.averageStreamQuality = None if args.sql: self.sql = SQL(self.config.gdi_db, self) else: self.sql = None self.startInterface() self.autodeploy()
prefix prov: <http://www.w3.org/ns/prov#> SELECT MAX(str(?timeValue)) as ?maxDateTime MIN(str(?timeValue)) as ?minDateTime WHERE { ?observation ssn:observationResultTime ?time . ?observation ssn:observedBy <""" + sensorName + """> . ?time tl:at ?timeValue . }""" sparql = self.getSparqlObject(graphName, queryString) try: ret = sparql.query().convert() return ret except Exception as e: L.e("Error in getStreamMinMaxDate:", e.message) if __name__ == '__main__': from virtualisation.triplestore.triplestorefactory import TripleStoreFactory config = JSONObject(file(os.path.join(os.path.dirname(__file__), "..", "config.json"), "rb")) tripleStore = TripleStoreFactory.getTripleStore(config.triplestore.driver, config.triplestore) # x = JSONObject() # print tripleStore.getObservationGraph2("aarhus_road_parking#", "http://ict-citypulse.eu/SensorID-9ae902fb-232b-5ea8-b7be-34d60d563112", "2015-10-09T17:27:38", "2015-10-10T17:29:28", asGraph=False) # print x.dumps() # sensorNames = ["http://ict-citypulse.eu/SensorID-4a838c4b-30d0-5fb4-b3b5-16d6c5c4ff9f", "http://ict-citypulse.eu/SensorID-d281e004-dfac-56c4-b237-d3b854c63558", \ # "http://ict-citypulse.eu/SensorID-4a838c4b-30d0-5fb4-b3b5-16d6c5c4ff9f", "http://ict-citypulse.eu/SensorID-4ebf0933-b115-5e44-98e7-2432325395a1", \ # "http://ict-citypulse.eu/SensorID-2586bf63-d256-59a0-bc29-9d04eb92dacb", "http://ict-citypulse.eu/SensorID-fb6c280f-1daa-56ea-a984-bfc2ae79d835", \ # "http://ict-citypulse.eu/SensorID-51f0f28c-0909-5a83-a310-b6bd686bf57b", "http://ict-citypulse.eu/SensorID-d281e004-dfac-56c4-b237-d3b854c63558"] # sensorNames = ["http://ict-citypulse.eu/SensorID-4a838c4b-30d0-5fb4-b3b5-16d6c5c4ff9f"] # # # import datetime