def start(self, _): """ 设备启动菜单时间处理器 点击启动菜单时调用该函数 """ if self.urgency: return all_key_in = "batch_id" in server.selected and "express_id" in server.selected if not all_key_in: express_list = server.get_express_list() select = SelectDiolag(self, u"选择窗口", express_list) select.SetPosition((400, 200)) select.ShowModal() all_key_in = "batch_id" in server.selected and "express_id" in server.selected if all_key_in: watcher.info[0], watcher.info[1] = select.get_select_info() watcher.publish(EVENT.SERIAL_CMD, "AA05start") watcher.publish(EVENT.EVT_START, "start") watcher.publish(EVENT.EVT_UPDATE, None) else: server.clear_batch() select.Destroy() else: watcher.publish(EVENT.SERIAL_CMD, "AA05start") watcher.publish(EVENT.EVT_START, "start")
def _connect(self): """ 连接socket """ try: self.server.connect(("localhost", self.port)) except socket.error: watcher.log_error("socket connetc errot") watcher.publish(EVENT.PROGRAM_ERROR, "socket connect error") raise InerException("socket connect error", __file__)
def _connect(self): """ 串口连接 """ try: self.serial = serial.Serial(self.port, self.baudrate) except serial.SerialException: watcher.log_error("serial connect error") watcher.publish(EVENT.PROGRAM_ERROR, "serial connect error") raise InerException("serial content error", __file__)
def decode_cmd(content): """ 解析命令 :param content:命令内容 :return None """ cm_type = content[:2] length = int(content[2:4]) cmd = content[4:length + 4] if cm_type == 'AB': if cmd == 'urgency': watcher.publish(EVENT.EVT_URGENCY, cmd) elif cmd == 'clear': watcher.publish(EVENT.CLEAR, cmd)
def decode_cmd(self, cmd): """ 命令解析 :cmd:命令内容 """ if cmd == 'Ready': pass else: check, pos, name = cmd.split(";") if check == '0': pass else: self.queue.put((pos, name)) watcher.publish(EVENT.EVT_CAMERA, name) watcher.info[3] += 1 watcher.info[2] += 1 watcher.publish(EVENT.EVT_UPDATE, None)
def complete(self, _): """ 完成接驳 """ if self.urgency: return server.clear_batch() watcher.publish(EVENT.EVT_COMPLETE, 'complete') watcher.publish(EVENT.SERIAL_CMD, "AA04stop") watcher.info[0] = u"尚未接驳" watcher.info[1] = u"尚未接驳" watcher.info[2] = 0; watcher.info[3] = 0; watcher.info[4] = 0; watcher.info[5] = 0; watcher.publish(EVENT.EVT_UPDATE, None)
def shoutdown(self, _): """ 关机 """ watcher.publish(EVENT.SERIAL_CMD, "AA08shutdown") exit(0)
def pause(self, _): """ 暂停 """ if self.urgency: return watcher.publish(EVENT.SERIAL_CMD, "AA04stop") watcher.publish(EVENT.EVT_PAUSE, 'pause')