def _mainloop(self): terminal = Terminal() if not terminal.is_open(): self.notify.emit(u'Ошибка', u'Нет связи с концентратором') self.ready.emit(False, {}) return if self.db is None: self.db = DB(notify=lambda title, msg: self.notify.emit(title, msg)) titles = self.db.get_terminals() devices = titles.keys() if not devices: self.notify.emit(u'Ошибка', u'Нет информации о терминалах') self.ready.emit(False, {}) return self.queue = Queue() self.ready.emit(True, titles) greenlets = self.spawn_device_greenlets(terminal, devices) while True: command = self.queue.get() if callable(command): command(terminal) else: [greenlet.kill() for greenlet in greenlets] break terminal.close() self.queue = None self.stopped.emit()
def _mainloop(self): try: terminal = Terminal(explicit_error=True) except ReaderError: self.notify.emit(_('Terminals error'), _('Cannot connect to concentrator')) self.ready.emit(False, {}) sleep(10) self.stopped.emit() return self.db = DB(notify=lambda title, msg: self.notify.emit(title, msg)) self.queue = Queue() self.ready.emit(True, self.devices) greenlets = self.spawn_device_greenlets(terminal, self.devices) if not greenlets: greenlets.append(spawn(self.dummy_greenlet)) while True: command = self.queue.get() if callable(command): command(terminal) else: [greenlet.kill() for greenlet in greenlets] break terminal.close() self.queue = None self.stopped.emit()
from console import Rig, Show from console.heads import Dimmer from interface import Terminal from console import fx from artnet import ArtNetSender from twisted.internet import reactor r = Rig() show = Show(r) for i in range(1, 9): d = Dimmer(1, i) r.heads[i] = d f = fx.IntensityRamp() show.programmer.add_fx(range(1, 9), f) show.run() artnet = ArtNetSender(r.outputs[0]) reactor.listenUDP(6454, artnet) reactor.run() interface = Terminal(show) interface.start()