def getSOSmsg(self): while True: try: msg = self.srv.listen() pkt = msg[0]['data'] try: data = pysos.unpack('<BbB', pkt) temp = float(data[1]) if data[0] == 3 and data[2] == 200: self.Kim.rssi[0] = temp if data[0] == 3 and data[2] == 201: self.Zainul.rssi[0] = temp if data[0] == 8 and data[2] == 200: self.Kim.rssi[1] = temp if data[0] == 8 and data[2] == 201: self.Zainul.rssi[1] = temp except: addr = pysos.unpack('<B', pkt[0]) temp = pkt[1:].split(',') if addr[0] == 3: self.Lamp.energy = float(temp[3]) / 10 self.LampFig.Update(self.Lamp.energy) if addr[0] == 8: self.Coffee.energy = float(temp[3]) / 10 self.CoffeeFig.Update(self.Coffee.energy) except: pass
def getSOSmsg(self): while True: try: msg = self.srv.listen() pkt = msg[0]["data"] try: data = pysos.unpack("<BBB", pkt) temp = float(data[1]) if temp < 40: self.Kim.present = 1 except: addr = pysos.unpack("<B", pkt[0]) temp = pkt[1:].split(",") if addr[0] == 3: self.Iron.energy = float(temp[3]) / 10 self.IronFig.Update(self.Iron.energy) try: if self.Kim.present == 1: self.Kim.energy = self.Iron.energy self.KimFig.Update(self.Kim.energy) self.Kim.present = 0 else: self.Kim.energy = 0 self.Kim.present = 0 self.KimFig.Update(self.Kim.energy) except: pass # if addr[0]==8: # self.Light1.energy = float(temp[3])/10 except: pass
def getSOSmsg(self): while True: try: msg = self.srv.listen() pkt = msg[0]['data'] try: data = pysos.unpack('<BbB',pkt) temp = float(data[1]) if data[0] == 3 and data[2] == 200: self.Kim.rssi[0] = temp if data[0] == 3 and data[2] == 201: self.Zainul.rssi[0] = temp if data[0] == 8 and data[2] == 200: self.Kim.rssi[1] = temp if data[0] == 8 and data[2] == 201: self.Zainul.rssi[1] = temp except: addr = pysos.unpack('<B',pkt[0]) temp = pkt[1:].split(',') if addr[0]==3: self.Lamp.energy = float(temp[3])/10 self.LampFig.Update(self.Lamp.energy) if addr[0]==8: self.Coffee.energy = float(temp[3])/10 self.CoffeeFig.Update(self.Coffee.energy) except: pass
def getSOSmsg(self): while True: try: msg = self.srv.listen() pkt = msg[0]['data'] try: data = pysos.unpack('<BBB',pkt) temp = float(data[1]) if temp < 40: self.Kim.present = 1 except: addr = pysos.unpack('<B',pkt[0]) temp = pkt[1:].split(',') if addr[0]==3: self.Iron.energy = float(temp[3])/10 self.IronFig.Update(self.Iron.energy) try: if self.Kim.present == 1: self.Kim.energy=self.Iron.energy self.KimFig.Update(self.Kim.energy) self.Kim.present = 0 else: self.Kim.energy = 0 self.Kim.present = 0 self.KimFig.Update(self.Kim.energy) except: pass # if addr[0]==8: # self.Light1.energy = float(temp[3])/10 except: pass
def getSOSmsg(self, msg): pkt = msg['data'] try: (ID, Data) = pysos.unpack('<BH', pkt) print "WaterMeter", Data except: pass try: (ID, Data) = pysos.unpack('<Bf', pkt) print "Var", ID, Data except: pass
def getSOSmsg(self,msg): pkt = msg['data'] try: (ID,Data) = pysos.unpack('<BH',pkt) print "WaterMeter",Data except: pass try: (ID,Data) = pysos.unpack('<Bf',pkt) print "Var", ID, Data except: pass
def getSOSmsg(self, msg): try: pkt = msg['data'] try: data = pysos.unpack('<BbB',pkt) temp = float(data[1]) # Moving average alpha = 0.7 if data[0] == 2 and data[2] == 200: self.Chorssi[0] = self.Chorssi[0]*(1-alpha)+alpha*temp elif data[0] == 3 and data[2] == 200: self.Chorssi[1] = self.Chorssi[1]*(1-alpha)+alpha*temp elif data[0] == 7 and data[2] == 200: self.Chorssi[2] = self.Chorssi[2]*(1-alpha)+alpha*temp elif data[0] == 8 and data[2] == 200: self.Chorssi[3] = self.Chorssi[3]*(1-alpha)+alpha*temp if data[0] == 2 and data[2] == 201: self.Kimrssi[0] = self.Kimrssi[0]*(1-alpha)+alpha*temp elif data[0] == 3 and data[2] == 201: self.Kimrssi[1] = self.Kimrssi[1]*(1-alpha)+alpha*temp elif data[0] == 7 and data[2] == 201: self.Kimrssi[2] = self.Kimrssi[2]*(1-alpha)+alpha*temp elif data[0] == 8 and data[2] == 201: self.Kimrssi[3] = self.Kimrssi[3]*(1-alpha)+alpha*temp except: pass except: pass
def getSOSmsg(self): while True: msg = self.srv.listen() pkt = msg[0]['data'] (ID, Data) = pysos.unpack('<Bf', pkt) if ID == 10: print Data
def getSOSmsg(self): while True: msg = self.srv.listen() pkt = msg[0]['data'] (ID,Data) = pysos.unpack('<Bf',pkt) if ID == 10: print Data
def getSOSmsg(self): while True: try: msg = self.srv.listen() pkt = msg[0]['data'] photoMsg = pysos.unpack('>BH',pkt) if photoMsg[0]==1: print photoMsg except: pass
def getSOSmsg(self,msg): pkt = msg['data'] try: (ID,Data) = pysos.unpack('<BH',pkt) print "WaterMeter",Data data[0] = Data except: pass try: (ID,Data) = pysos.unpack('<Bf',pkt) print "Var", ID, Data if ID == 11: data[2] = Data elif ID == 12: data[1] = Data elif ID == 13: data[3] = Data except: pass
def getSOSmsg(self): while True: try: msg = self.srv.listen() pkt = msg[0]['data'] accMsg = pysos.unpack('<BH',pkt) if accMsg[0]==2: self.py = 2*(accMsg[1]-511)+400 if accMsg[0]==1: self.px = 2*(accMsg[1]-511)+400 if accMsg[0]==3: self.pz = (accMsg[1]-397)+80 except: pass
def getSOSmsg(self): while True: try: msg = self.srv.listen() pkt = msg[0]['data'] photoMsg = pysos.unpack('<BH',pkt) if photoMsg[0]==3: deltaV = self.constant*self.samplingtime*(photoMsg[1]-self.middle) self.velocity = self.velocity+deltaV deltaP = self.velocity*self.samplingtime self.position = self.position+deltaP #print photoMsg[1]-self.middle print photoMsg[1] except: pass
def getSOSmsg(self): while True: try: msg = self.srv.listen() pkt = msg[0]['data'] photoMsg = pysos.unpack('<BH', pkt) if photoMsg[0] == 3: deltaV = self.constant * self.samplingtime * (photoMsg[1] - self.middle) self.velocity = self.velocity + deltaV deltaP = self.velocity * self.samplingtime self.position = self.position + deltaP #print photoMsg[1]-self.middle print photoMsg[1] except: pass
def getSOSmsg(self): while True: try: msg = self.srv.listen() pkt = msg[0]['data'] accMsg = pysos.unpack('<BH',pkt) if accMsg[0]==2: self.py = 2*(accMsg[1]-511)+400 self.follower[1] = 0.8*self.follower[1]+0.2*self.py if accMsg[0]==1: self.px = 2*(accMsg[1]-511)+400 self.follower[0] = 0.8*self.follower[0]+0.2*self.px if accMsg[0]==3: self.pz = (accMsg[1]-397)+80 self.follower[2] = 0.95*self.follower[2]+0.05*self.pz except: pass
def getSOSmsg(self): while True: try: msg = self.srv.listen() pkt = msg[0]['data'] accMsg = pysos.unpack('<BH', pkt) if accMsg[0] == 2: self.py = 2 * (accMsg[1] - 511) + 400 self.follower[1] = 0.8 * self.follower[1] + 0.2 * self.py if accMsg[0] == 1: self.px = 2 * (accMsg[1] - 511) + 400 self.follower[0] = 0.8 * self.follower[0] + 0.2 * self.px if accMsg[0] == 3: self.pz = (accMsg[1] - 397) + 80 self.follower[2] = 0.95 * self.follower[2] + 0.05 * self.pz except: pass
def getSOSmsg(self): while True: try: msg = self.srv.listen() pkt = msg[0]['data'] SpltMsg = pysos.unpack('<BHLB',pkt[10:18]) if SpltMsg[0] == 1: # PM if self.PM[SpltMsg[1]] != pkt[18:]: self.PM[SpltMsg[1]]=pkt[18:] temp = pkt[18:].split(',') Data = (('A',temp[5]),('TimeStamp',time.time()),('V',temp[4]),('W',temp[3]),('AID',SpltMsg[1])) PMqueue.put(Data,True,0.5) if SpltMsg[0] == 2: # RFID if self.TID[SpltMsg[1]] != pkt[18:]: print pkt[18:] self.TID[SpltMsg[1]]=pkt[18:] Data = (('TID',self.TID[SpltMsg[1]].strip()),('TimeStamp',time.time()),('UID',SpltMsg[1]),('UserName','YH')) RFIDqueue.put(Data,True,0.5) except: pass
def getSOSmsg(self, msg): try: pkt = msg['data'] try: data = pysos.unpack('<BbB', pkt) temp = float(data[1]) # Moving average alpha = 0.7 if data[0] == 2 and data[2] == 200: self.Cho.rssi[0] = self.Cho.rssi[0] * ( 1 - alpha) + alpha * temp elif data[0] == 3 and data[2] == 200: self.Cho.rssi[1] = self.Cho.rssi[1] * ( 1 - alpha) + alpha * temp elif data[0] == 7 and data[2] == 200: self.Cho.rssi[2] = self.Cho.rssi[2] * ( 1 - alpha) + alpha * temp elif data[0] == 8 and data[2] == 200: self.Cho.rssi[3] = self.Cho.rssi[3] * ( 1 - alpha) + alpha * temp elif data[0] == 2 and data[2] == 201: self.Kim.rssi[0] = self.Kim.rssi[0] * ( 1 - alpha) + alpha * temp elif data[0] == 3 and data[2] == 201: self.Kim.rssi[1] = self.Kim.rssi[1] * ( 1 - alpha) + alpha * temp elif data[0] == 7 and data[2] == 201: self.Kim.rssi[2] = self.Kim.rssi[2] * ( 1 - alpha) + alpha * temp elif data[0] == 8 and data[2] == 201: self.Kim.rssi[3] = self.Kim.rssi[3] * ( 1 - alpha) + alpha * temp # direct value # if data[0] == 2 and data[2] == 200: # self.Cho.rssi[0] = temp # elif data[0] == 3 and data[2] == 200: # self.Cho.rssi[1] = temp # elif data[0] == 7 and data[2] == 200: # self.Cho.rssi[2] = temp # elif data[0] == 8 and data[2] == 200: # self.Cho.rssi[3] = temp # # # elif data[0] == 2 and data[2] == 201: # self.Kim.rssi[0] = temp # elif data[0] == 3 and data[2] == 201: # self.Kim.rssi[1] = temp # elif data[0] == 7 and data[2] == 201: # self.Kim.rssi[2] = temp # elif data[0] == 8 and data[2] == 201: # self.Kim.rssi[3] = temp except: addr = pysos.unpack('<B', pkt[0]) temp = pkt[1:].split(',') if addr[0] == 3: self.Lamp.energy = float(temp[3]) / 10 self.LampFig.Update(self.Lamp.energy) elif addr[0] == 7: self.Coffee.energy = float(temp[3]) / 10 self.CoffeeFig.Update(self.Coffee.energy) elif addr[0] == 2: self.TV.energy = float(temp[3]) / 10 self.TVFig.Update(self.TV.energy) elif addr[0] == 8: self.Lamp2.energy = float(temp[3]) / 10 self.Lamp2Fig.Update(self.Lamp2.energy) except: pass
def getSOSmsg(self,msg): try: pkt = msg['data'] try: data = pysos.unpack('<BbB',pkt) temp = float(data[1]) # Moving average alpha = 0.7 if data[0] == 2 and data[2] == 200: self.Cho.rssi[0] = self.Cho.rssi[0]*(1-alpha)+alpha*temp elif data[0] == 3 and data[2] == 200: self.Cho.rssi[1] = self.Cho.rssi[1]*(1-alpha)+alpha*temp elif data[0] == 7 and data[2] == 200: self.Cho.rssi[2] = self.Cho.rssi[2]*(1-alpha)+alpha*temp elif data[0] == 8 and data[2] == 200: self.Cho.rssi[3] = self.Cho.rssi[3]*(1-alpha)+alpha*temp elif data[0] == 2 and data[2] == 201: self.Kim.rssi[0] = self.Kim.rssi[0]*(1-alpha)+alpha*temp elif data[0] == 3 and data[2] == 201: self.Kim.rssi[1] = self.Kim.rssi[1]*(1-alpha)+alpha*temp elif data[0] == 7 and data[2] == 201: self.Kim.rssi[2] = self.Kim.rssi[2]*(1-alpha)+alpha*temp elif data[0] == 8 and data[2] == 201: self.Kim.rssi[3] = self.Kim.rssi[3]*(1-alpha)+alpha*temp # direct value # if data[0] == 2 and data[2] == 200: # self.Cho.rssi[0] = temp # elif data[0] == 3 and data[2] == 200: # self.Cho.rssi[1] = temp # elif data[0] == 7 and data[2] == 200: # self.Cho.rssi[2] = temp # elif data[0] == 8 and data[2] == 200: # self.Cho.rssi[3] = temp # # # elif data[0] == 2 and data[2] == 201: # self.Kim.rssi[0] = temp # elif data[0] == 3 and data[2] == 201: # self.Kim.rssi[1] = temp # elif data[0] == 7 and data[2] == 201: # self.Kim.rssi[2] = temp # elif data[0] == 8 and data[2] == 201: # self.Kim.rssi[3] = temp except: addr = pysos.unpack('<B',pkt[0]) temp = pkt[1:].split(',') if addr[0]==3: self.Lamp.energy = float(temp[3])/10 self.LampFig.Update(self.Lamp.energy) elif addr[0]==7: self.Coffee.energy = float(temp[3])/10 self.CoffeeFig.Update(self.Coffee.energy) elif addr[0]==2: self.TV.energy = float(temp[3])/10 self.TVFig.Update(self.TV.energy) elif addr[0]==8: self.Lamp2.energy = float(temp[3])/10 self.Lamp2Fig.Update(self.Lamp2.energy) except: pass