コード例 #1
0
class WMInterface(threading.Thread):
    def __init__(self, channels, update_queue):
        threading.Thread.__init__(self)
        self.queue = update_queue

        self.switch = SwitchController()
        self.dac = DACController()
        self.wm = WavemeterController()

        self.channel = None
        self.channels = channels

        self.channel(1)
        self.running = True

    def run(self):
        while self.running:
            freq = self.wm.frequency()
            pattern = self.wm.interference_pattern()
            self.queue.put(WavemeterUpdate(freq, pattern))

            if self.channel.locking:
                self.channel.lock(freq)

            dt = time.clock() - self.switch_time
            if self.rotating and dt > self.channel.lock_time:
                pass
        print "Done."

    def _switch(self, ch):
        if self.channel is not None:
            self.queue.put(ChannelState(self.channel.index, ChannelState.INACTIVE))

        self.switch.switch(ch)
        self.channel = self.channels[ch]

        self.switch_time = time.clock()
        self.queue.put(ChannelState(self.channel.index, ChannelState.ACTIVE))

        self.wm.exposure_time(self.channel.exp_time / 1000.0)
        contrast = self.wm.contrast()
        freq = self.wm.frequency()

        while abs(self.wm.contrast() - contrast) > 10 or abs(self.wm.frequency() - freq) > 5:
            contrast = self.wm.contrast()
            freq = self.wm.frequency()

    def rotating(self, state):
        self.rotating = state

    def channel(self, ch):
        self.rotating(False)
        self._switch(ch)

    def stop(self):
        self.running = False
        self.join()
コード例 #2
0
    def __init__(self, channels, update_queue):
        threading.Thread.__init__(self)
        self.queue = update_queue

        self.switch = SwitchController()
        self.dac = DACController()
        self.wm = WavemeterController()

        self.channel = None
        self.channels = channels

        self.channel(1)
        self.running = True