def __init__(self): self.srv = pysos.sossrv() self.sensor ={} #parse the sensor list xml_doc = minidom.parse(os.environ['SOSROOT']+'/modules/db_app/server_interpreter/sos_db/sensors.xml') boards= xml_doc.getElementsByTagName('board') for b in boards: board = b.getElementsByTagName('board-name') sensors = b.getElementsByTagName('sensor') b_name = board[0].childNodes[0].data s_list = {} for s in sensors: pair = s.getElementsByTagName('pair') loc = s.getElementsByTagName('location') file = s.getElementsByTagName('file-name') l = loc[0].childNodes[0].data f = file[0].childNodes[0].data for n in pair: name = n.getElementsByTagName('name') s_name = name[0].childNodes[0].data s_value = int( n.getElementsByTagName('value')[0].childNodes[0].data ) s_list[s_name] = Sensor_Driver(s_name, s_value,l, f) self.sensor[b_name] = s_list default_board = 'mts310' self.query_files = {} self.curr_board = "" self.curr_queries = {} self.curr_id = 1 self.install_drivers(default_board) self.srv.register_trigger(self.response_handler, sid=128, type=34) self.out = self.standard_out
def ConnectSos(self, host='localhost', port=7915): """Connect to a running SOS server using PySOS and register a listener function for sensor data.""" # Connect to SOS server try: self.srv = pysos.sossrv(host, port) except IOError: print('Could not connect to SOS server..') self.Close() # Register the listener function self.srv.register_trigger(self._GetData, type=0x81)
def __init__(self): self.srv = pysos.sossrv(host="lcavpool63.epfl.ch") self.srv.register_trigger(self.soundDataMsgTrigger, did=128, sid=128, type=MSG_SOUND) self.srv.register_trigger(self.ozoneDataMsgTrigger, did=128, sid=128, type=MSG_OZONE) while 1: time.sleep(1)
def __init__(self): try: self.srv = pysos.sossrv() except: print "Please run sos_server first" try: thread.start_new_thread(self.parseSOSmsg,()) except thread.error: pass try: self.srv.register_trigger(self.getSOSmsg) except: pass try: thread.start_new_thread(self.TimeOut,()) except thread.error: pass self.queue = Queue.Queue(200) self.Kimrssi=[-200,-200,-200,-200] self.Chorssi=[-200,-200,-200,-200] self.Kimcount = [0,0,0,0]
def __init__(self): try: self.srv = pysos.sossrv() except: print "Please run sos_server first" try: thread.start_new_thread(self.parseSOSmsg, ()) except thread.error: pass try: self.srv.register_trigger(self.getSOSmsg) except: pass try: thread.start_new_thread(self.TimeOut, ()) except thread.error: pass self.queue = Queue.Queue(200) self.Kimrssi = [-200, -200, -200, -200] self.Chorssi = [-200, -200, -200, -200] self.Kimcount = [0, 0, 0, 0]
print "initialization began correctly" if (node_state == 0): state[node_id] = data if (node_state == 1 and state[node_id] != data): print >> sys.stderr, " a message was lost somewhere on node %d before count %d" % ( node_id, data) if (node_state == FINAL_DATA): print "finalization worked correctly" if __name__ == "__main__": # here we set up a connection to sossrv using the pysos module # and begin listening for messages # we also register our function above with the server so that it is called # when the appropriate message type is recieved srv = pysos.sossrv() srv.register_trigger(generic_test, sid=TEST_MODULE, type=MSG_TEST_DATA) # register the signal handler and begin an alarm that will wait for 60 seconds before going off # other times for the alarm might be good, use your own judgement based on your test signal.signal(signal.SIGALRM, panic_handler) signal.alarm(ALARM_LEN) # we do this so since the test_suite application has information regarding the amount of time # each test should be run. after the amount of time specified in test.lst, test_suite will # end this script and move to another test while (1): continue
if node_state == ORDER_GOOD: print "messages sent in order for node %d on count %d" % (node_id, data) if node_state == 0: state[node_id] = data if node_state == 1 and state[node_id] != data: print >> sys.stderr, " a message was lost somewhere" if node_state == FINAL_DATA: print "finalization worked correctly" if __name__ == "__main__": # here we set up a connection to sossrv using the pysos module # and begin listening for messages # we also register our function above with the server so that it is called # when the appropriate message type is recieved srv = pysos.sossrv() srv.register_trigger(generic_test, type=MSG_TEST_DATA, sid=TEST_MODULE) # register the signal handler and begin an alarm that will wait for 60 seconds before going off # other times for the alarm might be good, use your own judgement based on your test signal.signal(signal.SIGALRM, panic_handler) signal.alarm(ALARM_LEN) # we do this so since the test_suite application has information regarding the amount of time # each test should be run. after the amount of time specified in test.lst, test_suite will # end this script and move to another test while 1: continue