Beispiel #1
0
class DaqThread(QObject,threading.Thread):
    daqCompleted = QtCore.pyqtSignal(int)
    def __init__(self,devName = "Dev1/ai0:3",sampleNum = 400,sampleRate = 400.0,channelNum = 4,parent = None):
        super(QObject,self).__init__(parent)
        threading.Thread.__init__(self)
        self.devName = devName
        self.sampleNum = sampleNum
        self.sampleRate = sampleRate
        self.channelNum = channelNum;
        self.daq = Daq()
        self.data = []
        self.num = 0
        self.runFlag = 1
        
    def startDev(self):
        self.daq.initDev(self.devName,self.sampleNum,self.sampleRate,num = self.channelNum)
        self.daq.devStart()
    
    def startDaq(self):
        self.runFlag = 1
    
    def stopDaq(self):
        self.runFlag = 0
    
    def stopDev(self):
        self.daq.devStop()
        self.stopDaq()
    
    def getNum(self):
        return self.num
    
    def getData(self):
        return self.data
        
    def run(self):
        while(True):
            if(self.runFlag):
                (self.data,self.num) = self.daq.acquireData()
                self.daqCompleted.emit(self.num)
            else:
                sleep(0.5)
     
    @QtCore.pyqtSlot(int)        
    def printData(self,num):
        print self.getData()