def test_Sensor(self): """ creates a sensor object and test that sensor object """ obs = ObservationCollection(comment='mycol3') this_graph = cfg.get_graph() print(this_graph.serialize(format='turtle'))
def test_create_platfrom(self): """ creates platform, procedure object and tests adding a procedure to a sensor attached to the platform """ # procedure object proc1 = Procedure("procedure 1", "proc1") proc2 = Procedure("procedure 2", "proc2") # list of procedures proList = [proc1, proc2] # observable property object obs1 = ObservableProperty("obs-property1", "obs-property") obs2 = ObservableProperty("obs-property2", "obs-property2") obs3 = ObservableProperty("obs-property3", "obs-property3") # list of observable properties obsList = [obs1, obs2] obsList2 =[obs1,obs2] # sensor object s1 = Sensor("Sensor 1", "first sensor", obsList, proList) s2 = Sensor("Sensor 2", "second sensor", obsList2, proList) s3 = Sensor("Sensor 3", "second sensor", obsList2, proList) act1 = Actuator("Actuator 1", "first actuator",[],[]) act2 = Actuator("Actuator 2", "second actuator",[],[]) act3 = Actuator("Actuator 3", "third actuator",[],[]) #list of actuators actList =[act1,act2,act3] #list of sensors senList = [s1,s2] # platform object p1 = Platform("platform 1", "p1", senList, actList,[]) p1.add_sensor(s3) this_graph = cfg.get_graph() #print(this_graph.serialize(format='turtle')) print(this_graph.serialize(format="ttl").decode('utf-8'))
def test_Observation(self): """ creates an observation object and tests this observation on the graph """ obs = ObservationCollection(comment="mycol") this_graph = cfg.get_graph() print(this_graph.serialize(format='turtle'))
def test_remove_sensor(self): """ test remove sensor from the global graph """ obs = ObservationCollection(comment='mycol2') this_graph = cfg.get_graph() print(this_graph.serialize(format='turtle'))
def test_add_sensor(self): """ test add sensor to the graph """ obs = ObservationCollection(comment="mycol") obs = Platform(comment="mycol") this_graph = cfg.get_graph() print(this_graph.serialize(format='turtle'))
def test_add_observation(self): """ test to add observation to sensor """ s6 = Sensor("Sensor 6", "sixth sensor", [], []) obs1 = Observation("Observation 1", "measuring temperature") s6.add_observation(obs1) this_graph = cfg.get_graph() # print(this_graph.serialize(format='turtle')) print(this_graph.serialize(format="ttl").decode('utf-8'))
from rdflib import BNode, Literal, RDF, RDFS from PySOSA import config as cfg from PySOSA.Actuator import Actuator from PySOSA.Sampler import Sampler from PySOSA.Sensor import Sensor # Add Graph obj obsgraph = cfg.get_graph() class Platform(object): """ Creates a Platform object that represents a SOSA Platform A Platform is an entity that hosts other entities, particularly Sensors, Actuators, Samplers, and other Platforms. """ # Maybe remove list if makes object too big/not needed, or might want a func that returns this list sensors = [] actuators = [] samplers = [] def __init__(self, *args): """ constructor for instantiating Platform object Args: *args (str): label, comment, (list of or a) sensor, actuator, sampler platform object can be instantiated with multiple arguments, can have multiple sensors, actuators etc. Returns: object: an instantiated platform object with assigned attributes to it """ self.platform_id = BNode() self.label = Literal(args[0])