Esempio n. 1
0
class TriggerDevice(NeuroDevice):
    def __init__(self, freq = 256, channels = 1):
        self.freq = freq
        self.channels = channels
        self.header = Header(TRIGGER_HEADER)
        self.header.channelCount = channels
        for i in range(channels):
            self.header.channels[i].samplingFrequency = freq
            self.header.channels[i].label = 'TRIGGER%d' % i
        self.values = [0,]*self.channels
        self.valLock = RLock()
        self.queue = Queue(15)
        self.thread = TriggerDeviceThread(self)
        self.thread.start()
    
    def getValues(self):
        self.valLock.acquire()
        try:
            return tuple(self.values)
        finally:
            self.valLock.release()
    
    def setValues(self, val):
        self.valLock.acquire()
        try:
            self.values[:] = val
        finally:
            self.valLock.release()

    def getHeader(self):
        return self.header.text()
    
    def getData(self):
        return self.queue.get(10.0)
Esempio n. 2
0
 def __init__(self, freq = 256, channels = 1):
     self.freq = freq
     self.channels = channels
     self.header = Header(TRIGGER_HEADER)
     self.header.channelCount = channels
     for i in range(channels):
         self.header.channels[i].samplingFrequency = freq
         self.header.channels[i].label = 'TRIGGER%d' % i
     self.values = [0,]*self.channels
     self.valLock = RLock()
     self.queue = Queue(15)
     self.thread = TriggerDeviceThread(self)
     self.thread.start()