コード例 #1
0
ファイル: hmi.py プロジェクト: EQ4/mod-ui
    def checker(self, data=None):
        if data is not None:
            logging.info('[hmi] received <- %s' % repr(data))
            try:
                msg = Protocol(data.decode())
            except ProtocolError as e:
                logging.error('[hmi] error parsing msg %s' % repr(data))
                self.reply_protocol_error(e.error_code())
            else:
                if msg.is_resp():
                    try:
                        original_msg, callback, datatype = self.queue.pop(0)
                    except IndexError:
                        # something is wrong / not synced!!
                        logging.error("[hmi] NOT SYNCED")
                    else:
                        if callback is not None:
                            logging.info("[hmi] calling callback for %s" % original_msg)
                            callback(msg.process_resp(datatype))
                        self.process_queue()
                else:
                    def _callback(resp, resp_args=None):
                        if resp_args is None:
                            self.send("resp %d" % (0 if resp else -1))
                        else:
                            self.send("resp %d %s" % (0 if resp else -1, resp_args))

                    msg.run_cmd(_callback)
        try:
            self.sp.read_until(b'\0', self.checker)
        except serial.SerialException as e:
            logging.error("[hmi] error while reading %s" % e)
コード例 #2
0
ファイル: hmi.py プロジェクト: unbracketed/mod-ui
    def checker(self, data=None):
        if data is not None:
            logging.info('[hmi] received <- %s' % repr(data))
            try:
                msg = Protocol(data.decode("utf-8", errors="ignore"))
            except ProtocolError as e:
                logging.error('[hmi] error parsing msg %s' % repr(data))
                self.reply_protocol_error(e.error_code())
            else:
                if msg.is_resp():
                    try:
                        original_msg, callback, datatype = self.queue.pop(0)
                    except IndexError:
                        # something is wrong / not synced!!
                        logging.error("[hmi] NOT SYNCED")
                    else:
                        if callback is not None:
                            logging.info("[hmi] calling callback for %s" % original_msg)
                            callback(msg.process_resp(datatype))
                        self.process_queue()
                else:
                    def _callback(resp, resp_args=None):
                        if resp_args is None:
                            self.send("resp %d" % (0 if resp else -1))
                        else:
                            self.send("resp %d %s" % (0 if resp else -1, resp_args))

                    msg.run_cmd(_callback)
        try:
            self.sp.read_until(b'\0', self.checker)
        except serial.SerialException as e:
            logging.error("[hmi] error while reading %s" % e)
コード例 #3
0
    def checker(self, data=None):
        ioloop = IOLoop.instance()

        if data is not None and data != b'\0':
            self.last_write_time = 0
            logging.debug('[hmi] received <- %s', data)
            try:
                msg = Protocol(data.decode("utf-8", errors="ignore"))
            except ProtocolError as e:
                logging.error('[hmi] error parsing msg %s', data)
                logging.error('[hmi]   error code %s', e.error_code())
                self.reply_protocol_error(e.error_code())
            else:
                # reset timeout checks when a message is received
                self.need_flush = 0
                if self.flush_io is not None:
                    ioloop.remove_timeout(self.flush_io)
                    self.flush_io = None

                if msg.is_resp():
                    try:
                        original_msg, callback, datatype = self.queue.pop(0)
                        logging.debug("[hmi] popped from queue: %s", original_msg)
                    except IndexError:
                        # something is wrong / not synced!!
                        logging.error("[hmi] NOT SYNCED")
                    else:
                        if callback is not None:
                            logging.debug("[hmi] calling callback for %s", original_msg)
                            callback(msg.process_resp(datatype))
                        self.process_queue()
                else:
                    def _callback(resp, resp_args=None):
                        resp = 0 if resp else -1
                        if resp_args is None:
                            self.send_reply("%s %d" % (CMD_RESPONSE, resp))
                            logging.debug('[hmi]     sent "resp %s"', resp)

                        else:
                            self.send_reply("%s %d %s" % (CMD_RESPONSE, resp, resp_args))
                            logging.debug('[hmi]     sent "resp %s %s"', resp, resp_args)

                        self.handling_response = False
                        if self.queue_idle:
                            self.process_queue()

                    self.handling_response = True
                    msg.run_cmd(_callback)

        if self.need_flush != 0:
            if self.flush_io is not None:
                ioloop.remove_timeout(self.flush_io)
            self.flush_io = ioloop.call_later(self.timeout/2, self.flush)

        try:
            self.sp.read_until(b'\0', self.checker)
        except serial.SerialException as e:
            logging.error("[hmi] error while reading %s", e)
コード例 #4
0
    def checker(self, data=None):
        if data is not None:
            self.last_write_time = 0
            logging.debug('[hmi] received <- %s', data)
            try:
                msg = Protocol(data.decode("utf-8", errors="ignore"))
            except ProtocolError as e:
                logging.error('[hmi] error parsing msg %s', data)
                logging.error('[hmi]   error code %s', e.error_code())
                self.reply_protocol_error(e.error_code())
            else:
                if msg.is_resp():
                    try:
                        original_msg, callback, datatype = self.queue.pop(0)
                        logging.debug("[hmi] popped from queue: %s",
                                      original_msg)
                    except IndexError:
                        # something is wrong / not synced!!
                        logging.error("[hmi] NOT SYNCED")
                    else:
                        if callback is not None:
                            logging.debug("[hmi] calling callback for %s",
                                          original_msg)
                            callback(msg.process_resp(datatype))
                        self.process_queue()
                else:

                    def _callback(resp, resp_args=None):
                        resp = 0 if resp else -1
                        if resp_args is None:
                            self.send("resp %d" % resp, None)
                            logging.debug('[hmi]     sent "resp %s"', resp)

                        else:
                            self.send("resp %d %s" % (resp, resp_args), None)
                            logging.debug('[hmi]     sent "resp %s %s"', resp,
                                          resp_args)

                    msg.run_cmd(_callback)

        if self.need_flush != 0:
            if self.flush_io is not None:
                self.ioloop.remove_timeout(self.flush_io)
            self.flush_io = self.ioloop.call_later(2, self.flush)

        try:
            self.sp.read_until(b'\0', self.checker)
        except serial.SerialException as e:
            logging.error("[hmi] error while reading %s", e)
コード例 #5
0
ファイル: session.py プロジェクト: beraldoleal/mod-ui
    def __init__(self):
        self.hmi_initialized = False
        self.host_initialized = False
        self.pedalboard_initialized = False

        self._playback_1_connected_ports = []
        self._playback_2_connected_ports = []
        self._tuner = False
        self._tuner_port = 1
        self._peakmeter = False

        self.monitor_server = None

        self.current_bank = None

        self.jack_bufsize = DEFAULT_JACK_BUFSIZE
        self.effect_index = EffectIndex()

        self._pedalboard = Pedalboard()

        #Protocol.register_cmd_callback("banks", self.hmi_list_banks)
        #Protocol.register_cmd_callback("pedalboards", self.hmi_list_pedalboards)
        Protocol.register_cmd_callback("hw_con", self.hardware_connected)
        Protocol.register_cmd_callback("hw_dis", self.hardware_disconnected)
        Protocol.register_cmd_callback("control_set", self.hmi_parameter_set)
        Protocol.register_cmd_callback("control_get", self.parameter_get)
        Protocol.register_cmd_callback("control_next", self.parameter_addressing_next)
        Protocol.register_cmd_callback("peakmeter", self.peakmeter_set)
        Protocol.register_cmd_callback("tuner", self.tuner_set)
        Protocol.register_cmd_callback("tuner_input", self.tuner_set_input)
        #Protocol.register_cmd_callback("pedalboard_save", self.save_current_pedalboard)
        #Protocol.register_cmd_callback("pedalboard_reset", self.reset_current_pedalboard)
        Protocol.register_cmd_callback("jack_cpu_load", self.jack_cpu_load)

#        self.host = factory(Host, FakeHost, DEV_HOST,
#                            "unix:///tmp/ingen.sock", self.host_callback)
        self.host = Host(os.environ.get("MOD_INGEN_SOCKET_URI", "unix:///tmp/ingen.sock"), self.host_callback)
        self.hmi = factory(HMI, FakeHMI, DEV_HMI,
                           HMI_SERIAL_PORT, HMI_BAUD_RATE, self.hmi_callback)

        self.recorder = Recorder()
        self.player = Player()
        self.bundlepath = None
        self.mute_state = True
        self.recording = None
        self.instances = []
        self.instance_mapper = InstanceIdMapper()
        self.engine_samplerate = 48000 # default value

        self._clipmeter = Clipmeter(self.hmi)
        self.websockets = []

        self._load_pb_hack = None
        self._save_waiter = None
コード例 #6
0
ファイル: addressing.py プロジェクト: EQ4/mod-ui
    def __init__(self, hmi):
        self.host = None
        self.hmi  = hmi
        self.mapper = InstanceIdMapper()
        self.banks = []
        self.instances = {}
        self._init_addressings()

        # Register HMI protocol callbacks
        Protocol.register_cmd_callback("hw_con", self.hmi_hardware_connected)
        Protocol.register_cmd_callback("hw_dis", self.hmi_hardware_disconnected)
        Protocol.register_cmd_callback("banks", self.hmi_list_banks)
        Protocol.register_cmd_callback("pedalboards", self.hmi_list_bank_pedalboards)
        Protocol.register_cmd_callback("pedalboard", self.hmi_load_bank_pedalboard)
        Protocol.register_cmd_callback("control_get", self.hmi_parameter_get)
        Protocol.register_cmd_callback("control_set", self.hmi_parameter_set)
        Protocol.register_cmd_callback("control_next", self.hmi_parameter_addressing_next)
コード例 #7
0
ファイル: hmi_debug.py プロジェクト: ViktorNova/mod-ui
    if len(queue) == 0:
        print "Queue empty"
        tornado.ioloop.IOLoop.instance().stop()
    action, msg = queue.pop(0)
    if action == SEND:
        print 'sending %s' % msg
        hmi.send(msg, consume)
    elif action == ASK:
        print msg

def reply(*args):
    if len(queue) == 0:
        print "Queue empty"
        tornado.ioloop.IOLoop.instance().stop()
    hmi.send(queue.pop(0)[1])
    consume()

Protocol.register_cmd_callback("banks", reply)
Protocol.register_cmd_callback("pedalboards", reply)
Protocol.register_cmd_callback("pedalboard", reply)

def start():
    print "pinging"
    hmi.ping(consume)

#hmi = HMI(HMI_SERIAL_PORT, HMI_BAUD_RATE, ping)
hmi = HMI(HMI_SERIAL_PORT, HMI_BAUD_RATE, consume)
application = web.Application()
options.parse_command_line()
tornado.ioloop.IOLoop.instance().start()
コード例 #8
0
ファイル: hmi_debug.py プロジェクト: zen3d/mod-ui
    if action == SEND:
        print 'sending %s' % msg
        hmi.send(msg, consume)
    elif action == ASK:
        print msg


def reply(*args):
    if len(queue) == 0:
        print "Queue empty"
        tornado.ioloop.IOLoop.instance().stop()
    hmi.send(queue.pop(0)[1])
    consume()


Protocol.register_cmd_callback("banks", reply)
Protocol.register_cmd_callback("pedalboards", reply)
Protocol.register_cmd_callback("pedalboard", reply)


def start():
    print "pinging"
    hmi.ping(consume)


#hmi = HMI(HMI_SERIAL_PORT, HMI_BAUD_RATE, ping)
hmi = HMI(HMI_SERIAL_PORT, HMI_BAUD_RATE, consume)
application = web.Application()
options.parse_command_line()
tornado.ioloop.IOLoop.instance().start()
コード例 #9
0
ファイル: addressing.py プロジェクト: EQ4/mod-ui
    def __init__(self, hmi):
        self.host = None
        self.hmi = hmi
        self.mapper = InstanceIdMapper()
        self.banks = []
        self.instances = {}
        self._init_addressings()

        # Register HMI protocol callbacks
        Protocol.register_cmd_callback("hw_con", self.hmi_hardware_connected)
        Protocol.register_cmd_callback("hw_dis",
                                       self.hmi_hardware_disconnected)
        Protocol.register_cmd_callback("banks", self.hmi_list_banks)
        Protocol.register_cmd_callback("pedalboards",
                                       self.hmi_list_bank_pedalboards)
        Protocol.register_cmd_callback("pedalboard",
                                       self.hmi_load_bank_pedalboard)
        Protocol.register_cmd_callback("control_get", self.hmi_parameter_get)
        Protocol.register_cmd_callback("control_set", self.hmi_parameter_set)
        Protocol.register_cmd_callback("control_next",
                                       self.hmi_parameter_addressing_next)