Ejemplo n.º 1
0
    def readFun(self):
        try:
            dev = ft.list_devices()
        except:
            dev = []
            
        while len (dev) == 0:
            if not self.q.empty():
                item = self.q.get()
#                self.statusQueue.put(item)
            time.sleep (5)
            print "Rechecking hardware connection..."
            try:
                dev = ft.list_devices()
            except:
                dev = []
            print dev


        self.f = ft.open_ex(dev[0])
        print self.f  
        while True:
            item = self.q.get()
            self.f.write(item)
            while self.f.get_queue_status() < 19:
                pass
            readData = self.f.read(self.f.get_queue_status())
            confirmFlag = True
            if item[1:20:1] != readData :
                confirmFlag = False
                for i in range(2):
                    self.f.write(item)
                    while self.f.get_queue_status() < 19:
                        pass
                    readData = self.f.read(self.f.get_queue_status())
                    if item[1:20:1] == readData:
                        confirmFlag = True
                        break
            if confirmFlag == False:
                self.statusQueue.put(item)
                print 'Connect error,please check device'
                
            elif self.q.empty() and confirmFlag != False:
                self.statusQueue.put('Finished')
                
            print repr(item),'\n',repr(readData)
Ejemplo n.º 2
0
 def downloadToDevice(self): 
     try:
         dev = ft.list_devices()
     except:
         dev = []
     if not len(dev) :
         QtGui.QMessageBox.question(None,'message','No device ,please check',
                                                         QtGui.QMessageBox.Ok)
         return
     with self.session.begin():
         tableFire = self.session.query(ScriptData).all()
     node = {'head':0xAAF0,'length':0x14,'function':0x01,'ID':0xAABBCCDD,'fireBox':None,
             'firePoint':None,'seconds':None,'offsetSec':None,'crc':0,'tail':0xDD}
     
     for row in tableFire:
         if  row.ConnectorID == None:
             reply = QtGui.QMessageBox.question(None,'message','Please choose ignitorBox first',
                                        QtGui.QMessageBox.Ok)
             if reply == QtGui.QMessageBox.Ok:
                 return
             
     for row in tableFire:
         with self.session.begin():
             ignitorBoxRow = self.session.query(IgnitorsData).filter_by(UUID = row.IgnitorID).first()
         node['fireBox'] = int(ignitorBoxRow.BoxID)
         node['firePoint'] = row.ConnectorID
         node['seconds'] = int(row.IgnitionTime.seconds)
         node['offsetSec'] = int(row.IgnitionTime.microseconds/1000)
         package = protocol.dataPack(node)
         package.pack()
         self.q.put (package.package)
         print 'fire head',node['firePoint'],'fire Box ',node['fireBox']
         print repr(package.package)
         self.timer = QtCore.QTimer()
         QtCore.QObject.connect(self.timer,QtCore.SIGNAL("timeout()"), self.checkQueue)
         self.timer.start(2000)