Beispiel #1
0
 def read_command(self, msg):
     self.rx_msg = msg
     log("Trying to Acquire JSON file", DEBUG,(datetime.datetime.now()-self.start_time))
     #self.json_lock.acquire()
     sp_msg = re.split('/', self.rx_msg.topic)
     try:
         log("Write " + str(sp_msg[2]) +
             str(sp_msg[3]) + "to JSON File", DEBUG,(datetime.datetime.now()-self.start_time))
         datalog(self.rx_msg.payload,str(sp_msg[2])+ '/' + str(sp_msg[3]),self.device_name,RX,(datetime.datetime.now()-self.start_time))
         self.device.write(self.rx_msg.payload, sp_msg[2], int(sp_msg[3]))
     except ValueError as e:
         print(e)
Beispiel #2
0
 def send_commands(self):
     while True:
         obj_topic = self.device.Delete_Change()
         log("Object to be sent " + str(obj_topic), DEBUG)
         if(obj_topic == 'Error'):
             return
         sp_topic = re.split('/', obj_topic)
         try:
             msg = self.device.read(sp_topic[0], int(sp_topic[1]))
         except ValueError as e:
             print(e)
         print(msg)
         datalog(msg,obj_topic,self.device_name,TX,(datetime.datetime.now()-self.start_time))
         self.mqttc.publish(str(self.dev_topic) + '/' + obj_topic, msg)