Example #1
0
 def run(self):
     while (1):
         tab_data = ['M', '\x00', '\x7F']
         motorCommand.put(tab_data)
         time.sleep(60)
         tab_data = ['M', '\x01', '\x7F']
         motorCommand.put(tab_data)
         time.sleep(10)
         tab_data = ['M', '\x01', '\x00']
         motorCommand.put(tab_data)
         time.sleep(15)
 def run(self):
     while(1):
         tab_data = ['M', '\x00', '\x7F']
         motorCommand.put(tab_data)
         time.sleep(60)
         tab_data = ['M', '\x01', '\x7F']
         motorCommand.put(tab_data)
         time.sleep(10)
         tab_data = ['M', '\x01', '\x00']
         motorCommand.put(tab_data)            
         time.sleep(15)            
 def run(self):
     while(1):
         tab_data = self.ComPort_Bluetooth.get_data_3964r(None, self.ComPort_Bluetooth.timeout)
         if tab_data != None:
             if((tab_data[0] == 'M') or (tab_data[0] == 'K')):
                 motorCommand.put(tab_data)
             else:
                 if(tab_data[0] == '\x40'):
                     if(temperature1_BT.empty() == False):
                         tab_data = temperature1_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(self.ComPort_Bluetooth.timeout, tab_data[0], tab_data[1], tab_data[2])
                 elif(tab_data[0] == '\x41'):
                     if(temperature2_BT.empty() == False):                        
                         tab_data = temperature2_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(self.ComPort_Bluetooth.timeout, tab_data[0], tab_data[1], tab_data[2])
                 elif(tab_data[0] == '\x42'):
                     if(temperature3_BT.empty() == False):
                         tab_data = temperature3_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(self.ComPort_Bluetooth.timeout, tab_data[0], tab_data[1], tab_data[2])
                 elif(tab_data[0] == '\x43'):
                     if(temperature4_BT.empty() == False):
                         tab_data = temperature4_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(self.ComPort_Bluetooth.timeout, tab_data[0], tab_data[1], tab_data[2])
                 elif(tab_data[0] == '\x44'):
                     if(temperature5_BT.empty() == False):
                         tab_data = temperature5_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(self.ComPort_Bluetooth.timeout, tab_data[0], tab_data[1], tab_data[2])
                 elif(tab_data[0] == '\x45'):
                     if(temperature6_BT.empty() == False):
                         tab_data = temperature6_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(self.ComPort_Bluetooth.timeout, tab_data[0], tab_data[1], tab_data[2])
                 elif(tab_data[0] == '\x46'):
                     if(temperature7_BT.empty() == False):
                         tab_data = temperature7_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(self.ComPort_Bluetooth.timeout, tab_data[0], tab_data[1], tab_data[2])
                 elif(tab_data[0] == '\x47'):
                     if(temperature8_BT.empty() == False):
                         tab_data = temperature8_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(self.ComPort_Bluetooth.timeout, tab_data[0], tab_data[1], tab_data[2])
                 elif(tab_data[0] == '\x50'):
                     if(adc1_BT.empty() == False):
                         tab_data = adc1_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(self.ComPort_Bluetooth.timeout, tab_data[0], tab_data[1], tab_data[2])
                 elif(tab_data[0] == '\x51'):
                     if(adc2_BT.empty() == False):
                         tab_data = adc2_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(self.ComPort_Bluetooth.timeout, tab_data[0], tab_data[1], tab_data[2])
                 elif(tab_data[0] == '\x52'):
                     if(adc3_BT.empty() == False):
                         tab_data = adc3_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(self.ComPort_Bluetooth.timeout, tab_data[0], tab_data[1], tab_data[2])
                 elif(tab_data[0] == '\x53'):
                     if(adc4_BT.empty() == False):
                         tab_data = adc4_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(self.ComPort_Bluetooth.timeout, tab_data[0], tab_data[1], tab_data[2])
                 elif(tab_data[0] == '\x60'):
                     if(accelerometer1_BT.empty() == False):
                         tab_data = accelerometer1_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(self.ComPort_Bluetooth.timeout, tab_data[0], tab_data[1], tab_data[2])
                 elif(tab_data[0] == '\x70'):
                     if(hygrometer1_BT.empty() == False):
                         tab_data = hygrometer1_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(self.ComPort_Bluetooth.timeout, tab_data[0], tab_data[1], tab_data[2])
                 elif(tab_data[0] == '\x71'):
                     if(hygrometer2_BT.empty() == False):
                         tab_data = hygrometer2_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(self.ComPort_Bluetooth.timeout, tab_data[0], tab_data[1], tab_data[2])
                 elif(tab_data[0] == '\x80'):
                     if(impuls1_BT.empty() == False):
                         tab_data = impuls1_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(self.ComPort_Bluetooth.timeout, tab_data[0], tab_data[1], tab_data[2])
                 elif(tab_data[0] == '\x81'):
                     if(impuls2_BT.empty() == False):
                         tab_data = impuls2_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(self.ComPort_Bluetooth.timeout, tab_data[0], tab_data[1], tab_data[2])
 def run(self):
     while (1):
         #            tab_data = ['M', '\x00', '\xFF']
         #            motorCommand.put(tab_data)
         #            time.sleep(150)
         #            tab_data = ['M', '\x01', '\x7F']
         #            motorCommand.put(tab_data)
         #            time.sleep(60)
         #            tab_data = ['M', '\x01', '\x00']
         #            motorCommand.put(tab_data)
         #            time.sleep(30)
         tab_data = self.ComPort_US.get_data_3964r(None,
                                                   self.ComPort_US.timeout)
         if tab_data != None:
             if ((tab_data[0] == 'M') or (tab_data[0] == 'K')):
                 motorCommand.put(tab_data)
             else:
                 if (tab_data[0] == '\x40'):
                     if (temperature1_US.empty() == False):
                         tab_data = temperature1_US.get()
                         self.ComPort_US.send_data_3964r(
                             self.ComPort_US.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                         print "US- Temperature 1  : [ " + str(
                             tab_data[0]) + " | " + str(ord(
                                 tab_data[1])) + " | " + str(
                                     ord(tab_data[2])) + " ]"
                 elif (tab_data[0] == '\x41'):
                     if (temperature2_US.empty() == False):
                         tab_data = temperature2_US.get()
                         self.ComPort_US.send_data_3964r(
                             self.ComPort_US.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                         print "US- Temperature 1  : [ " + str(
                             tab_data[0]) + " | " + str(ord(
                                 tab_data[1])) + " | " + str(
                                     ord(tab_data[2])) + " ]"
                 elif (tab_data[0] == '\x42'):
                     if (temperature3_US.empty() == False):
                         tab_data = temperature3_US.get()
                         self.ComPort_US.send_data_3964r(
                             self.ComPort_US.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                         print "US- Temperature 3  : [ " + str(
                             tab_data[0]) + " | " + str(ord(
                                 tab_data[1])) + " | " + str(
                                     ord(tab_data[2])) + " ]"
                 elif (tab_data[0] == '\x43'):
                     if (temperature4_US.empty() == False):
                         tab_data = temperature4_US.get()
                         self.ComPort_US.send_data_3964r(
                             self.ComPort_US.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                         print "US- Temperature 4  : [ " + str(
                             tab_data[0]) + " | " + str(ord(
                                 tab_data[1])) + " | " + str(
                                     ord(tab_data[2])) + " ]"
                 elif (tab_data[0] == '\x44'):
                     if (temperature5_US.empty() == False):
                         tab_data = temperature5_US.get()
                         self.ComPort_US.send_data_3964r(
                             self.ComPort_US.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                         print "US- Temperature 5  : [ " + str(
                             tab_data[0]) + " | " + str(ord(
                                 tab_data[1])) + " | " + str(
                                     ord(tab_data[2])) + " ]"
                 elif (tab_data[0] == '\x45'):
                     if (temperature6_US.empty() == False):
                         tab_data = temperature6_US.get()
                         self.ComPort_US.send_data_3964r(
                             self.ComPort_US.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                         print "US- Temperature 6  : [ " + str(
                             tab_data[0]) + " | " + str(ord(
                                 tab_data[1])) + " | " + str(
                                     ord(tab_data[2])) + " ]"
                 elif (tab_data[0] == '\x46'):
                     if (temperature7_US.empty() == False):
                         tab_data = temperature7_US.get()
                         self.ComPort_US.send_data_3964r(
                             self.ComPort_US.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                         print "US- Temperature 7  : [ " + str(
                             tab_data[0]) + " | " + str(ord(
                                 tab_data[1])) + " | " + str(
                                     ord(tab_data[2])) + " ]"
                 elif (tab_data[0] == '\x47'):
                     if (temperature8_US.empty() == False):
                         tab_data = temperature8_US.get()
                         self.ComPort_US.send_data_3964r(
                             self.ComPort_US.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                         print "US- Temperature 8  : [ " + str(
                             tab_data[0]) + " | " + str(ord(
                                 tab_data[1])) + " | " + str(
                                     ord(tab_data[2])) + " ]"
                 elif (tab_data[0] == '\x50'):
                     if (adc1_US.empty() == False):
                         tab_data = adc1_US.get()
                         self.ComPort_US.send_data_3964r(
                             self.ComPort_US.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                         print "US- ADC 1  : [ " + str(
                             tab_data[0]) + " | " + str(ord(
                                 tab_data[1])) + " | " + str(
                                     ord(tab_data[2])) + " ]"
                 elif (tab_data[0] == '\x51'):
                     if (adc2_US.empty() == False):
                         tab_data = adc2_US.get()
                         self.ComPort_US.send_data_3964r(
                             self.ComPort_US.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                         print "US- ADC 2  : [ " + str(
                             tab_data[0]) + " | " + str(ord(
                                 tab_data[1])) + " | " + str(
                                     ord(tab_data[2])) + " ]"
                 elif (tab_data[0] == '\x52'):
                     if (adc3_US.empty() == False):
                         tab_data = adc3_US.get()
                         self.ComPort_US.send_data_3964r(
                             self.ComPort_US.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                         print "US- ADC 3  : [ " + str(
                             tab_data[0]) + " | " + str(ord(
                                 tab_data[1])) + " | " + str(
                                     ord(tab_data[2])) + " ]"
                 elif (tab_data[0] == '\x53'):
                     if (adc4_US.empty() == False):
                         tab_data = adc4_US.get()
                         self.ComPort_US.send_data_3964r(
                             self.ComPort_US.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                         print "US- ADC 4  : [ " + str(
                             tab_data[0]) + " | " + str(ord(
                                 tab_data[1])) + " | " + str(
                                     ord(tab_data[2])) + " ]"
                 elif (tab_data[0] == '\x60'):
                     if (accelerometer1_US.empty() == False):
                         tab_data = accelerometer1_US.get()
                         self.ComPort_US.send_data_3964r(
                             self.ComPort_US.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                         print "US- Accelerometre 1  : [ " + str(
                             tab_data[0]) + " | " + str(ord(
                                 tab_data[1])) + " | " + str(
                                     ord(tab_data[2])) + " ]"
                 elif (tab_data[0] == '\x70'):
                     if (hygrometer1_US.empty() == False):
                         tab_data = hygrometer1_US.get()
                         self.ComPort_US.send_data_3964r(
                             self.ComPort_US.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                         print "US- Humidite 1  : [ " + str(
                             tab_data[0]) + " | " + str(ord(
                                 tab_data[1])) + " | " + str(
                                     ord(tab_data[2])) + " ]"
                 elif (tab_data[0] == '\x71'):
                     if (hygrometer2_US.empty() == False):
                         tab_data = hygrometer2_US.get()
                         self.ComPort_US.send_data_3964r(
                             self.ComPort_US.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                         print "US- Humidite 2  : [ " + str(
                             tab_data[0]) + " | " + str(ord(
                                 tab_data[1])) + " | " + str(
                                     ord(tab_data[2])) + " ]"
                 elif (tab_data[0] == '\x80'):
                     if (impuls1_US.empty() == False):
                         tab_data = impuls1_US.get()
                         self.ComPort_US.send_data_3964r(
                             self.ComPort_US.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                         print "US- Impulsion 1  : [ " + str(
                             tab_data[0]) + " | " + str(ord(
                                 tab_data[1])) + " | " + str(
                                     ord(tab_data[2])) + " ]"
                 elif (tab_data[0] == '\x81'):
                     if (impuls2_US.empty() == False):
                         tab_data = impuls2_US.get()
                         self.ComPort_US.send_data_3964r(
                             self.ComPort_US.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                         print "US- Impulsion 2  : [ " + str(
                             tab_data[0]) + " | " + str(ord(
                                 tab_data[1])) + " | " + str(
                                     ord(tab_data[2])) + " ]"
 def run(self):
     while (1):
         tab_data = self.ComPort_Bluetooth.get_data_3964r(
             None, self.ComPort_Bluetooth.timeout)
         if tab_data != None:
             if ((tab_data[0] == 'M') or (tab_data[0] == 'K')):
                 motorCommand.put(tab_data)
             else:
                 if (tab_data[0] == '\x40'):
                     if (temperature1_BT.empty() == False):
                         tab_data = temperature1_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(
                             self.ComPort_Bluetooth.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                 elif (tab_data[0] == '\x41'):
                     if (temperature2_BT.empty() == False):
                         tab_data = temperature2_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(
                             self.ComPort_Bluetooth.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                 elif (tab_data[0] == '\x42'):
                     if (temperature3_BT.empty() == False):
                         tab_data = temperature3_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(
                             self.ComPort_Bluetooth.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                 elif (tab_data[0] == '\x43'):
                     if (temperature4_BT.empty() == False):
                         tab_data = temperature4_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(
                             self.ComPort_Bluetooth.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                 elif (tab_data[0] == '\x44'):
                     if (temperature5_BT.empty() == False):
                         tab_data = temperature5_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(
                             self.ComPort_Bluetooth.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                 elif (tab_data[0] == '\x45'):
                     if (temperature6_BT.empty() == False):
                         tab_data = temperature6_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(
                             self.ComPort_Bluetooth.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                 elif (tab_data[0] == '\x46'):
                     if (temperature7_BT.empty() == False):
                         tab_data = temperature7_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(
                             self.ComPort_Bluetooth.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                 elif (tab_data[0] == '\x47'):
                     if (temperature8_BT.empty() == False):
                         tab_data = temperature8_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(
                             self.ComPort_Bluetooth.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                 elif (tab_data[0] == '\x50'):
                     if (adc1_BT.empty() == False):
                         tab_data = adc1_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(
                             self.ComPort_Bluetooth.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                 elif (tab_data[0] == '\x51'):
                     if (adc2_BT.empty() == False):
                         tab_data = adc2_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(
                             self.ComPort_Bluetooth.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                 elif (tab_data[0] == '\x52'):
                     if (adc3_BT.empty() == False):
                         tab_data = adc3_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(
                             self.ComPort_Bluetooth.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                 elif (tab_data[0] == '\x53'):
                     if (adc4_BT.empty() == False):
                         tab_data = adc4_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(
                             self.ComPort_Bluetooth.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                 elif (tab_data[0] == '\x60'):
                     if (accelerometer1_BT.empty() == False):
                         tab_data = accelerometer1_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(
                             self.ComPort_Bluetooth.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                 elif (tab_data[0] == '\x70'):
                     if (hygrometer1_BT.empty() == False):
                         tab_data = hygrometer1_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(
                             self.ComPort_Bluetooth.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                 elif (tab_data[0] == '\x71'):
                     if (hygrometer2_BT.empty() == False):
                         tab_data = hygrometer2_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(
                             self.ComPort_Bluetooth.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                 elif (tab_data[0] == '\x80'):
                     if (impuls1_BT.empty() == False):
                         tab_data = impuls1_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(
                             self.ComPort_Bluetooth.timeout, tab_data[0],
                             tab_data[1], tab_data[2])
                 elif (tab_data[0] == '\x81'):
                     if (impuls2_BT.empty() == False):
                         tab_data = impuls2_BT.get()
                         self.ComPort_Bluetooth.send_data_3964r(
                             self.ComPort_Bluetooth.timeout, tab_data[0],
                             tab_data[1], tab_data[2])