def __init__(self): self.module_name = 'cfg_server' App.__init__(self, self.module_name) self.logger = get_logger(self.module_name) self.database = DataBase() self.database.create_table() self.__init_callback()
def __init__(self): self.__module_name = 'LaunchThread' App.__init__(self, self.__module_name) self.__logger = get_logger(self.__module_name) self.launch_under_pan = None self.launch_under_pan_path = get_value_by_key('underpan', 'LAUNCH') self.__logger.info('get underpan path: ' + str(self.launch_under_pan_path)) if self.launch_under_pan_path is None: self.launch_under_pan_path = \ '/home/utry/catkin_ws/src/xiaoyuan_robot_v2/launch/xiaoyuan_robot_start_underpan.launch' self.launch_other = None self.launch_other_path = get_value_by_key('other', 'LAUNCH') self.__logger.info('get other path: ' + str(self.launch_other_path)) if self.launch_other_path is None: self.launch_other_path = \ '/home/utry/catkin_ws/src/xiaoyuan_robot_v2/launch/xiaoyuan_robot_start_other.launch' self.launch_sensor = None self.launch_amcl = None self.launch_running = None self.launch_running_path = get_value_by_key('linerunning', 'LAUNCH') self.__logger.info('get linerunning path: ' + str(self.launch_running_path)) if self.launch_running_path is None: self.launch_running_path = '/home/utry/catkin_ws/src/linerunning_v2/launch/xiaoyuan_clear.launch' self.is_start = False self.is_stop = False self.is_shutdown = False self.uuid = None self.__init_callback()
def __init__(self, base_frame): self.module_name = 'mode_start' # style_sheet = 'QFrame{border-image: url(:/mode_start/mode_start/start.png)}' \ # 'QFrame{background: transparent}' AppQt.Q_App.__init__(self, self.module_name, base_frame, QRect(0, 0, 800, 480)) self.logger = get_logger(self.module_name) self.res_path = Util.get_res_path(self.module_name) self.show_str = '正在启动请稍后' self.status_cnt = 0 self.start_index = 0 self.timeout_cnt = 0 self.list_start_status = list_start_info self.picture_label = AppQt.get_label_picture( self, QRect(0, 0, 800, 480), ':/mode_start/mode_start/start.png') rect = AppQt.QRect(0, 340, 800, 24) self.m_static_start_result = AppQt.get_label_text( self, rect, False, '正在启动,请稍后···', 24, 'MicrosoftYaHei', '#333333') self.m_static_start_result.setStyleSheet('background: transparent;') self.timer_show = QtCore.QTimer(parent=self) # 创建定时器 self.timer_show.timeout.connect(lambda: self.on_timer_show()) self.__init_callback()
def __init__(self): self.module_name = 'update_task' App.__init__(self, self.module_name) self.json_request = '' self.logger = get_logger(self.module_name) self.res_path = Util.get_res_path('Update') self.download_url = get_value_by_key('update_download_url', 'HOST_URL') self.logger.info('get download_url:' + str(self.download_url)) if self.download_url is None: self.download_url = 'http://47.100.182.145:9200' self.update_url = get_value_by_key('update_url', 'HOST_URL') self.logger.info('get update_url:' + str(self.update_url)) if self.update_url is None: self.update_url = 'http://47.100.182.145:9200/update_info?' self.update_function_list = [] self.update_function_list_init() self.is_shutdown = False self.update_index = 0 self.show_update_flag = False self.update_status = False self.process_percent = 0 self.download_file_name = 'update.zip' self.__init_callback()
def __init__(self, base_frame): self.module_name = 'mode_check' self.logger = get_logger(self.module_name) AppQt.Q_App.__init__(self, self.module_name, base_frame) self.res_path = Util.get_res_path(self.module_name) self.check_index = 0 self.check_last_status = Check_status_idle self.check_list_all = check_list_all self.check_process_target = 0 self.current_process = 0 self.degree = 0 self.link_4G = True self.link_ros = True self.link_mcu = True self.battery_count = 88 self.water_count = 88 self.release_stop = True self.fault_status = True self.origin_status = True AppQt.get_label_picture(self, AppQt.QRect(344, 30, 130, 140), ':/mode_check/mode_check/扑拉飞呀导入版本.gif') AppQt.get_label_picture(self, AppQt.QRect(210, 174, 380, 41), ':/mode_check/mode_check/自检进度条-灰.png') self.cover_panel = AppQt.get_sub_frame(self, AppQt.QRect(213, 178, 0, 34)) AppQt.get_label_picture(self.cover_panel, AppQt.QRect(0, 0, 380, 34), ':/mode_check/mode_check/自检进度条-蓝.png') rect = AppQt.QRect(215, 237, 150, 24) self.m_static_check_title = AppQt.get_label_text( self, rect, False, '', 24, 'MicrosoftYaHei', '#333333') self.m_static_check_title.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) rect = AppQt.QRect(430, 237, 150, 24) self.m_static_check_subtitle = AppQt.get_label_text( self, rect, False, '', 24, 'MicrosoftYaHei', '#333333') self.m_static_check_subtitle.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) rect = AppQt.QRect(430, 270, 150, 24) self.m_static_check_result = AppQt.get_label_text( self, rect, False, '', 24, 'MicrosoftYaHei', '#333333') self.m_static_check_result.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.__check_list_init__() self.timer_show = QtCore.QTimer() # 创建定时器 self.timer_show.timeout.connect(lambda: self.on_timer_show()) self.timer_process = QtCore.QTimer() # 创建定时器 self.timer_process.timeout.connect(lambda: self.on_timer_process())
def __init__(self, module_name, module_pipe=None): self.__module_name = module_name App.__init__(self, self.__module_name, is_msg_center=True) self.__logger = get_logger(self.__module_name) self.__init() # self.__msg_id_module_dict = {} if module_pipe is not None: self.add_manager_dispatcher_pipe(module_pipe)
def __init__(self, base_frame): self.module_name = 'mode_mt' self.logger = get_logger(self.module_name) AppQt.Q_App.__init__(self, self.module_name, base_frame) # frame init self.res_path = Util.get_res_path('mode_mt') self.list_msg_info = [['close', 'open', 'brush_req'], ['close', 'open', 'water_req'], ['forward', 'back', 'direction_req']] self.list_mt_button_status = [ Mt_button_off, Mt_button_off, Mt_button_forward ] self.list_remote_mt_button_status = [ Mt_button_off, Mt_button_off, Mt_button_forward ] self.link_ros = False self.link_mcu = False tmp_list = list_label_mt_string for index in range(Mt_button_num): rect = tmp_list[index][list_label_point] name = tmp_list[index][list_label_info] AppQt.get_label_text(self, rect, True, name, 28, 'MicrosoftYaHei-Bold', '#000000') self.list_mt_button_bitmap = [] self.list_mt_button = [] tmp_list = list_button_mt_string for index in range(Mt_button_num): list_tmp = [] bitmap = "QPushButton{border-image: url(:/mode_mt/mode_mt/" + str( tmp_list[index][Mt_button_off]) + ")}" list_tmp.append(bitmap) bitmap = "QPushButton{border-image: url(:/mode_mt/mode_mt/" + str( tmp_list[index][Mt_button_on]) + ")}" list_tmp.append(bitmap) self.list_mt_button_bitmap.append(list_tmp) rect = tmp_list[index][Mt_button_point] style_sheet = list_tmp[self.list_mt_button_status[index]] mt_button = AppQt.get_pushbutton(self, rect, style_sheet) mt_button.setObjectName(str(tmp_list[index][Mt_button_id])) mt_button.clicked.connect( lambda: self.on_click_mt_button(self.sender().objectName())) self.list_mt_button.append(mt_button) self.timer_show = QtCore.QTimer(parent=self) # 创建定时器 self.timer_show.timeout.connect(self.on_timer_show) self.timer_delay = QtCore.QTimer(parent=self) # 创建定时器 self.timer_delay.timeout.connect(self.on_timer_delay) self.__init_callback()
def __init__(self, manager_pipe): self.__module_name = 'ui_manager' print('ui_manager come in 57') self.__logger = get_logger(self.__module_name) print('ui_manager come in 59') self.dispatcher = None self.__frame = None self.__manager_pipe = manager_pipe self.__app = None self.widgets = None
def __init__(self): if self.__first: # 单例模式 self.__first = False # 模块和接口对应关系,现在用的Queue,我可能会变 self.__module_queue_dict = {} # 消息储存的地方 self.msg_id_module_dict = {} #初始化logger模块 self.__logger = get_logger('pyins') pass
def __init__(self, module_name, module_pipe=None): self.__module_name = module_name Q_App.__init__(self, self.__module_name, is_msg_center=True, geometry=QRect(0, 0, 0, 0)) # self.hide() self.__logger = get_logger(self.__module_name) self.__init() # self.__msg_id_module_dict = {} if module_pipe is not None: self.add_manager_dispatcher_pipe(module_pipe)
def __init__(self, module_name, is_msg_center=False, need_start=True, inner_connection=None): self.__app_name = module_name self.__logger = get_logger('app_' + self.__app_name) self.__need_start = need_start self.__is_msg_center = is_msg_center self.__ins = Ins() self.msg_id_module_dict = self.__ins.msg_id_module_dict self.msg_id = UMsg() # print(self.__app_name, ' :', need_start, '##', inner_connection, '###', inner_callback) if not need_start and inner_connection is not None: self.__queue = inner_connection else: self.__queue = Queue(0) self.__pipe_dispatcher_rec = None self.__pipe_dispatcher_send = None self.__sleep_time = 0.001 self.__lock = None # type: Lock if self.__is_msg_center: self.__pipe_dispatcher_rec, self.__pipe_dispatcher_send = Pipe( False) self.__ins.add_module_queue(self.__app_name, self.__pipe_dispatcher_send) self.__ins.add_module_queue('dispatcher', self.__queue) if self.__app_name != self.msg_id.out_dispatcher: self.send_queue_module_manager() else: self.__lock = RLock() else: self.__sleep_time = 0.01 self.__ins.add_module_queue(self.__app_name, self.__queue) self.__subscriber_dict = {} self.__logger.info('init model ' + self.__app_name) self.__is_shutdown = False self.__default_callback = None self.__multi_default_callback = None # run self self.__start__()
def run_ui_process(self, module_pipe): print('begin to start run_ui_process') logger = get_logger('ui_manager') logger.info('begin to start run_ui_process') try: manager = UiManager(module_pipe) manager.start() while True: time.sleep(1) except Exception as e: print('ui find exception !!!!!!! : ' + str(e)) logger.fatal('ui find exception !!!!!!! : ' + str(e)) time.sleep(2)
def __init__(self): self.module_name = 'video_record' App.__init__(self, self.module_name) self.logger = get_logger(self.module_name) # Message.__init__(self,mode_name='VideoRecord') self.cap = None self.fourcc = None self.out_file = None self.start_time = 0 self.frequency = 8.0 self.abspath = None # video record self.record_time = get_value_by_key('video_record_time', 'CONFIG') # type:str self.logger.info('get video_record_time: ' + str(self.record_time)) if self.record_time is None: self.record_time = 180 else: if self.record_time.isdigit(): self.record_time = int(self.record_time) else: self.logger.info('get video_record_time is not digit') self.record_time = 180 self.file_size = get_value_by_key('video_record_size', 'CONFIG') # type:str self.logger.info('get video_record_size: ' + str(self.file_size)) if self.file_size is None: self.file_size = 1024 else: if self.file_size.isdigit(): self.file_size = int(self.file_size) else: self.logger.info('get video_record_size is not digit') self.file_size = 1024 self.save_path = Util.get_res_path('video_save') self.snap_flag = False self.write_file_queue = Queue() self.rtmp_queue = Queue() self.local_queue = Queue() self.video_record_flip = get_value_by_key('video_record_flip', 'CONFIG') self.logger.info('get video_record_flip :' + str(self.video_record_flip)) self.rtmp_enable = get_value_by_key('rtmp_enable', 'CONFIG') self.logger.info('get rtmp_enable :' + str(self.rtmp_enable)) self.rtmp_url = get_value_by_key('rtmp_url', 'CONFIG') self.logger.info('get rtmp_url :' + str(self.rtmp_url)) if self.rtmp_url is None: self.rtmp_url = 'rtmp://120.26.209.2:1935/live/test' self.http_local_enable = get_value_by_key('http_local_enable', 'CONFIG') self.logger.info('get http_local_enable :' + str(self.http_local_enable))
def __init__(self, base_frame): self.module_name = 'Update' AppQt.Q_App.__init__(self, self.module_name, base_frame) self.logger = get_logger(self.module_name) self.res_path = Util.get_res_path(self.module_name) self.check_index = 0 self.check_last_status = Check_status_idle self.Update_list_all = Update_list_all self.check_process_target = 0 self.current_process = 0 self.degree = 0 self.update_index = 0 self.show_update_flag = False self.update_status = False self.process_percent = 0 # gif 动图 AppQt.get_label_picture(self, QRect(335, 20, 130, 140), ':/update/Update/扑拉飞呀导入版本.gif') AppQt.get_label_picture(self, QRect(210, 174, 380, 41), ':/update/Update/自检进度条-灰.png') self.cover_panel = AppQt.get_sub_frame(self, QRect(213, 178, 0, 34)) AppQt.get_label_picture(self.cover_panel, QRect(0, 0, 380, 34), ':/update/Update/自检进度条-蓝.png') self.m_static_check_title = AppQt.get_label_text(self, QRect(215, 237, 150, 24), False, 'test', 24, 'MicrosoftYaHei', '#333333') self.m_static_check_title.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.m_static_check_subtitle = AppQt.get_label_text(self, QRect(430, 237, 150, 24), False, 'test', 24, 'MicrosoftYaHei', '#333333') self.m_static_check_subtitle.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.m_static_check_result = AppQt.get_label_text(self, QRect(430, 270, 150, 24), False, 'test', 24, 'MicrosoftYaHei', '#333333') self.m_static_check_result.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.__check_list_init__() self.timer_show = QtCore.QTimer(parent=self) # 创建定时器 self.timer_show.timeout.connect(lambda: self.on_timer_show()) self.timer_process = QtCore.QTimer(parent=self) # 创建定时器 self.timer_process.timeout.connect(lambda: self.on_timer_process()) self.__init_callback()
def __init__(self, manager_pipe): self.module_name = 'service_manager' self.__logger = get_logger(self.module_name) self.__logger.info('init ' + str(self.module_name) + ' begin') print('come in 61') try: print('come in 63') self.dispatcher = UDispatcher(UMsg.service_dispatcher, manager_pipe) print('come in 65') except Exception as e: print('come in 65') self.__logger.fatal('find exception : ' + str(e)) self.__logger.info('init ' + str(self.module_name) + ' success') return
def __init__(self): self.module_name = 'interface_ros' App.__init__(self, self.module_name) self.link_ros = False self.link_mcu = False self.received_time = 0 self.logger = get_logger(self.module_name) self.pub = None self.ros_is_running = False self.send_link_status = False self.master = None self.ui_ros_topic_is_sub = False self.callback_dict = {} self.__init_callback() self.msg_out_queue = Queue(0) Util.add_thread(target=self.msg_out_queue_callback)
def __init__(self): self.logger = get_logger('Manager') self.logger.info('#######################################') self.logger.info('begin to start process') self.logger.info('#######################################') self.manager_lock = multiprocessing.Lock() self.manager_dispatcher = UDispatcher(UMsg.manager_dispatcher) self.manager_dispatcher.start() self.manager_pipe = { 'pipe': self.manager_dispatcher.get_self_pipe(), 'lock': self.manager_dispatcher.get_self_lock() } self.process_ui = None self.process_service = None self.process_ros = None self.process_pool = {}
def __init__(self, module_pipe): self.__module_name = 'ros_manager' print('come in ' + str(self.__module_name)) try: self.__logger = get_logger(self.__module_name) print('come in 78' + str(self.__module_name)) self.__logger.info('come in ' + self.__module_name) print('come in 80' + str(self.__module_name)) self.dispatcher = UDispatcher(UMsg.ros_dispatcher, module_pipe) print('come in 82' + str(self.__module_name)) except Exception as e: import os os.system('echo \"' + str(e) + '\" > coredump.log') self.__logger.fatal('find exception: ' + str(e)) self.__logger.info('UDispatcher init ok ') self.launch_thread = None self.__logger_inner = None
def __init__(self, base_frame): self.__frame = base_frame self.__module_name = 'manager_frame' AppQt.Q_App.__init__(self, self.__module_name, parent=base_frame, geometry=QtCore.QRect(0, 40, 800, 340)) self.__logger = get_logger(self.__module_name) self.__default_page = setting.Page_mt_mode self.robot_status = 'mt' self.show_box_panel = None # type: AppQt.Q_App self.start_panel = None # type: AppQt.Q_App self.page_stack = None # type: QtWidgets.QStackedWidget self.__init_callback() self.__run()
def __init__(self, base_frame): self.module_name = 'show_box' self.logger = get_logger(self.module_name) AppQt.Q_App.__init__( self, self.module_name, base_frame, QRect(0, 0, 800, 480), 'QFrame{border-image: url(:/show_box/show_box/半透明.png)}' 'QFrame{background: transparent}') self.res_path = Util.get_res_path(self.module_name) self.index = 0 self.m_bitmap_white = AppQt.get_sub_frame( self, QRect(100, 53, 600, 374), 'QFrame{border-image: url(:/show_box/show_box/弹窗.png)}') style_sheet = 'QPushButton{border-image: url(:/show_box/show_box/否.png)}' + \ 'QPushButton:pressed{border-image: url(:/show_box/show_box/否-点击.png)}' self.button_no = AppQt.get_pushbutton(self.m_bitmap_white, QRect(41, 223, 240, 70), style_sheet) self.button_no.clicked.connect(lambda: self.on_click_button_no()) style_sheet = 'QPushButton{border-image: url(:/show_box/show_box/是.png)}' + \ 'QPushButton:pressed{border-image: url(:/show_box/show_box/是-点击.png)}' self.button_yes = AppQt.get_pushbutton(self.m_bitmap_white, QRect(320, 223, 240, 70), style_sheet) self.button_yes.clicked.connect(lambda: self.on_click_button_yes()) self.m_static_show = AppQt.get_label_text(self.m_bitmap_white, QRect(0, 70, 600, 94), True, '', 34, 'MicrosoftYaHei-Bold', '#333333') self.timer_show = QtCore.QTimer(parent=self) # 创建定时器 self.timer_show.timeout.connect(lambda: self.on_timer_show()) self.__init_callback()
def __init__(self, base_frame): self.module_name = 'mode_map_select' self.logger = get_logger(self.module_name) AppQt.Q_App.__init__(self, self.module_name, base_frame) self.show_callback = self.start self.hide_callback = self.stop self.res_path = Util.get_res_path(self.module_name) # self.get_map_num() style_sheet = 'QPushButton{border-image: url(:/mode_map_select/mode_map_select/左-亮.png)}' + \ 'QPushButton:pressed{border-image: url(:/mode_map_select/mode_map_select/左-灰.png)}' self.m_button_left = AppQt.get_pushbutton(self, QRect(20, 140, 58, 58), style_sheet) # self.get_map_num() style_sheet = 'QPushButton{border-image: url(:/mode_map_select/mode_map_select/右-亮.png)}' + \ 'QPushButton:pressed{border-image: url(:/mode_map_select/mode_map_select/右-灰.png)}' self.m_button_right = AppQt.get_pushbutton(self, QRect(720, 140, 58, 58), style_sheet) self.map_frame = AppQt.get_sub_frame(self, QRect(100, 0, 600, 340)) self.map_frame.show() self.list_map_button = [] self.list_map_frame = [] self.list_map_label = [] self.list_map = [] self.timer_show = QtCore.QTimer() # 创建定时器 self.timer_show.timeout.connect( lambda: self.on_timer_show()) # 绑定一个定时器事件 self.timer_update_map = QtCore.QTimer() # 创建定时器 self.timer_update_map.timeout.connect( lambda: self.on_timer_update_map()) # 绑定一个定时器事件 self.position_cnt = 0 self.__init_callback()
def ros_core_process(self): logger_inner = get_logger('ros_manager_inner') logger_inner.info('begin ros core') try: while True: while True: time.sleep(3) status, result = getipaddr() logger_inner.info('get ip :' + str(result)) if status: logger_inner.info('host ip is init!') break else: print('wait for ip init!!') logger_inner.warning('wait for ip init!!') if not get_ros_core(): logger_inner.info('start ros core') try: roslaunch.main(['roscore', '--core']) while True: time.sleep(1) except Exception as e: print('I am except ' + str(e)) logger_inner.fatal(str(e)) continue finally: logger_inner.fatal('I am finally') time.sleep(1) else: logger_inner.warning('ros core is exist , skip!') print('ros core is exist , skip!') break except Exception as e: print('something error ' + str(e)) logger_inner.fatal('something error ' + str(e))
def __init__(self, base_frame): self.module_name = 'mode_working' self.logger = get_logger(self.module_name) AppQt.Q_App.__init__(self, self.module_name, base_frame) self.res_path = Util.get_res_path(self.module_name) self.current_process = [0, 0, 0] self.check_process_target = [0, 0, 0] self.degree = [0, 0, 0] self.count = 0 self.map_select_path = None self.map_select_name = None self.working_status = working_status_on self.move_speed = 0 self.position_x = 0 self.position_y = 0 self.position_z = 0 self.progress_percent = 0 self.label_back = AppQt.get_sub_frame(self, AppQt.QRect(28, 26, 228, 228), 'background-color: #FFFFFF;') self.m_bitmap_map_working = AppQt.get_label_picture( self.label_back, AppQt.QRect(5, 5, 218, 218)) self.map_label_name = AppQt.get_label_text( self, AppQt.QRect(8, 276, 270, 26), False, '', 26) tmp_list = list_working_label_info for index in range(4): rect = tmp_list[index][list_working_point] name = tmp_list[index][list_working_name] AppQt.get_label_text(self, rect, True, name, 26, 'MicrosoftYaHei-Bold', '#333333') self.list_working_label_point_show = [] for index in range(Working_point_num): rect = AppQt.QRect(380 + 130 * index, 192, 90, 24) working_label = AppQt.get_label_text(self, rect, False, '', 24, 'MicrosoftYaHei', '#333333') self.list_working_label_point_show.append(working_label) self.working_set_point() tmp_list = list_working_process_info self.list_working_cover_panel = [] self.list_working_cover_text = [] for index in range(Working_gauge_num): rect = tmp_list[index][list_working_gray_point] path = ':/mode_working/mode_working/工作中-灰.png' AppQt.get_label_picture(self, rect, path) cover_panel = AppQt.get_sub_frame(self, rect) path = ':/mode_working/mode_working/工作中-蓝.png' AppQt.get_label_picture(cover_panel, AppQt.QRect(0, 0, 380, 38), path) rect = tmp_list[index][list_working_text_point] text_panel = AppQt.get_sub_frame( self, rect, 'QFrame{background: transparent}') cover_text = AppQt.get_label_text( text_panel, AppQt.QRect(0, 0, rect.width(), rect.height()), True, '', 26, 'MicrosoftYaHei-Bold', '#0E0E32') cover_text.setStyleSheet('QLabel{background: transparent}') self.list_working_cover_panel.append(cover_panel) self.list_working_cover_text.append(cover_text) self.list_working_button_bitmap = [] bitmap = 'QPushButton{border-image: url(:/mode_working/mode_working/暂停.png)}' + \ 'QPushButton:pressed{border-image: url(:/mode_working/mode_working/暂停-按下.png)}' self.list_working_button_bitmap.append(bitmap) bitmap = 'QPushButton{border-image: url(:/mode_working/mode_working/继续.png)}' + \ 'QPushButton:pressed{border-image: url(:/mode_working/mode_working/继续-按下.png)}' self.list_working_button_bitmap.append(bitmap) rect = AppQt.QRect(286, 236, 214, 74) style_sheet = self.list_working_button_bitmap[self.working_status] self.m_button_pause_continue = AppQt.get_pushbutton( self, rect, style_sheet) self.m_button_pause_continue.clicked.connect( lambda: self.on_click_pause_continue()) rect = AppQt.QRect(524, 236, 214, 74) self.cancel_style_sheet_enable = 'QPushButton{border-image: url(:/mode_working/mode_working/取消.png)}' + \ 'QPushButton:pressed{border-image: url(:/mode_working/mode_working/取消-按下.png)}' self.cancel_style_sheet_disable = 'QPushButton{border-image: url(:/mode_working/mode_working/取消灰.png)}' self.m_button_cancel = AppQt.get_pushbutton( self, rect, self.cancel_style_sheet_enable) self.m_button_cancel.clicked.connect(lambda: self.on_click_cancel()) self.timer_show = QtCore.QTimer(parent=self) # 创建定时器 self.timer_show.timeout.connect(lambda: self.on_timer_show()) self.timer_process = QtCore.QTimer(parent=self) # 创建定时器 self.timer_process.timeout.connect(lambda: self.on_timer_process()) self.timer_delay = QtCore.QTimer(parent=self) # 创建定时器 self.timer_delay.timeout.connect(lambda: self.on_timer_process()) self.timer_start_delay = QtCore.QTimer(parent=self) self.timer_start_delay.timeout.connect( lambda: self.on_timer_start_delay()) self.__init_callback()
def __init__(self, base_frame): self.module_name = 'mode_author' self.logger = get_logger(self.module_name) AppQt.Q_App.__init__(self, self.module_name, base_frame) self.show_callback = self.start self.hide_callback = self.stop self.res_path = Util.get_res_path(self.module_name) self.input_cnt = 0 self.one_second_cnt = 0 password = get_value_by_key('password', 'CONFIG') # type: str self.logger.info('get password: '******'889972' if password is not None: if len(password) == 6: if password.isdigit(): self.password = str(password) self.logger.info('set password: '******'' self.error_show_cnt = 0 self.mac_id = Util.get_mac_address() self.download_url = get_value_by_key('qrcode_download_url', 'HOST_URL') self.logger.info('get qr_code url is : ' + str(self.download_url)) if self.download_url is None: self.download_url = 'http://47.100.182.145:8080/qrcode/clearQrcode?macId=' self.download_url += self.mac_id self.unlock_url = get_value_by_key('unlock_url', 'HOST_URL') self.logger.info('unlock url is : ' + str(self.unlock_url)) if self.unlock_url is None: self.unlock_url = 'http://47.100.182.145:8080/lock/queryUnlockById?macId=' self.unlock_url += self.mac_id self.lock_url = get_value_by_key('lock_url', 'HOST_URL') self.logger.info('lock url is : ' + str(self.lock_url)) if self.lock_url is None: self.lock_url = 'http://47.100.182.145:8080/lock/lock?macId=' self.lock_url += self.mac_id self.logger.info('get qr_code url is : ' + str(self.download_url)) self.logger.info('unlock url is : ' + str(self.unlock_url)) self.logger.info('lock url is : ' + str(self.lock_url)) self.download_file_name = self.res_path + 'Qr_d.png' self.qr_code_path = self.res_path + 'Qr.png' self.process_percent = 0 self.m_bitmap_qr = AppQt.get_label_picture( self, AppQt.QRect(18, 120, 161, 161), self.qr_code_path) tmp_list = list_button_author_info self.list_key_button = [] for index in range(12): rect = tmp_list[index][Author_button_point] style_sheet = 'QPushButton{border-image: url(:/mode_author/mode_author/' + \ str(tmp_list[index][Author_button_unselect]) + ')}' + \ 'QPushButton:pressed{border-image: url(:/mode_author/mode_author/' + \ str(tmp_list[index][Author_button_select]) + ')}' button = AppQt.get_pushbutton(self, rect, style_sheet) button.setObjectName(str(tmp_list[index][Author_button_id])) button.clicked.connect( lambda: self.on_click_key(self.sender().objectName())) self.list_key_button.append(button) tmp_list = list_radio_author_string self.radio_list = [] self.radio_bitmap_list = [] bitmap = QtGui.QPixmap(':/mode_author/mode_author/' + tmp_list[Author_radio_off]) self.radio_bitmap_list.append(bitmap) bitmap = QtGui.QPixmap(':/mode_author/mode_author/' + tmp_list[Author_radio_on]) self.radio_bitmap_list.append(bitmap) # 设置属性,位置 for index in range(6): rect = AppQt.QRect(307 + (26 + 37) * index, 57, 26, 26) path = ':/mode_author/mode_author/' + tmp_list[Author_radio_off] radio_button = AppQt.get_label_picture(self, rect, path) self.radio_list.append(radio_button) self.m_static_password_tip = AppQt.get_label_text( self, AppQt.QRect(191, 14, 418, 28), True, '请扫描二维码或 输入管理员密码', 28, 'MicrosoftYaHei-Bold', '#333333') self.timer_show = QtCore.QTimer(parent=self) # 创建定时器 self.timer_show.timeout.connect(self.on_timer_show) self.timer_error_show = QtCore.QTimer(parent=self) # 创建定时器 self.timer_error_show.timeout.connect(self.on_timer_error_show) self.timer_delay = QtCore.QTimer(parent=self) # 创建定时器 self.timer_delay.timeout.connect(self.on_timer_delay) self.update_qr_code = False Util.add_thread(target=self.update_qr_code_function) self.lock_status = False self.unlock_status = False Util.add_thread(target=self.qr_code_lock_function) self.locking = False Util.add_thread(target=self.set_lock_status)
def __init__(self, parent): self.module_name = 'base_frame' # init frame AppQt.Q_App.__init__(self, self.module_name, parent=parent, geometry=AppQt.QRect(0, 0, 800, 480), style_sheet='QFrame{background-color: #D6D5D6}') # init variable self.res_path = Util.get_res_path('frame') self.logger = get_logger(self.module_name) self.one_second_cnt = 0 self.get_odom_cnt = 0 # home self.battery_count = 88 self.water_count = 88 self.odom_count = 0 self.line_speed = 0 self.received_time = 0 self.link_4G = True self.link_ros = False self.link_mcu = False self.is_get_odom = False self.list_mt_button_status = [ Mt_button_off, Mt_button_off, Mt_button_forward ] # title panel init self.title_panel = AppQt.get_sub_frame( self, AppQt.QRect(0, 0, 800, 40), 'QFrame{background-color: #E1E1E1}') # tail panel init self.tail_panel = AppQt.get_sub_frame( self, AppQt.QRect(0, 380, 800, 100), 'QFrame{background-color: #F0F0F0}') # init title 4G self.m_bitmap_4G = AppQt.get_label_picture(self.title_panel, AppQt.QRect(13, 12, 28, 17), ':/frame/frame/信号4.png') # init title battery self.m_battery_url = ':/frame/frame/电池1.png' self.m_bitmap_battery = AppQt.get_label_picture( self.title_panel, AppQt.QRect(745, 11, 43, 18), self.m_battery_url) # init tail water percent self.m_bitmap_water = AppQt.get_label_picture( self.tail_panel, AppQt.QRect(47, 26, 40, 54), ':/frame/frame/水量.png') # init tail odom self.m_bitmap_odom = AppQt.get_label_picture( self.tail_panel, AppQt.QRect(597, 26, 44, 54), ':/frame/frame/lichen.png') # 剩下的label 批量处理,省地方 self.m_title_label_list = [] tmp_list = list_title_string for index in range(len(tmp_list)): # Label初始化 rect = tmp_list[index][Title_index_point] name = tmp_list[index][Title_index_name] font_px = tmp_list[index][Title_index_font_size] title_label = AppQt.get_label_text(self.title_panel, rect, False, name, font_px, 'MicrosoftYaHei', '#000000') # title_label.setAutoFillBackground(True) self.m_title_label_list.append(title_label) # 剩下的label 批量处理,省地方 self.m_tail_label_list = [] tmp_list = list_tail_string for index in range(len(tmp_list)): rect = tmp_list[index][Title_index_point] name = tmp_list[index][Title_index_name] font_px = tmp_list[index][Title_index_font_size] tail_label = AppQt.get_label_text(self.tail_panel, rect, False, name, font_px, 'MicrosoftYaHei', '#000000') self.m_tail_label_list.append(tail_label) # init at or mt button 垃圾逻辑,改掉 self.At_style_sheet_enable = 'QPushButton{border-image: url(:/frame/frame/切换到 自动驾驶.png)}' self.Mt_style_sheet_enable = 'QPushButton{border-image: url(:/frame/frame/切换到 手动驾驶.png)}' self.Mt_style_sheet_disable = 'QPushButton{border-image: url(:/frame/frame/切换到 手动驾驶灰.png)}' self.m_bpButtonAt_mini = AppQt.get_pushbutton( self.tail_panel, AppQt.QRect(235, 0, 331, 100), self.At_style_sheet_enable) self.m_bpButtonAt_mini.clicked.connect(lambda: self.on_click_mini_at()) self.m_bpButtonAt_mini.hide() self.m_bpButtonMt_mini = AppQt.get_pushbutton( self.tail_panel, AppQt.QRect(235, 0, 331, 100), self.Mt_style_sheet_enable) self.m_bpButtonMt_mini.clicked.connect(lambda: self.on_click_mini_mt()) self.m_bpButtonMt_mini.hide() # create timer for title and tail update self.timer_show = QtCore.QTimer(parent=self) # 创建定时器 self.timer_show.timeout.connect(self.on_timer_show) QtCore.QMetaObject.connectSlotsByName(parent) # self.show_mt_signal.connect(self.show_mt_at) # self.set_button_enable_signal.connect(self.set_button_enable) self.__init_callback() self.show() self.Manage = ManagerFrame(self) self.Manage.show()
self.send_msg(self.msg_id.interface_ros_send_msg_out, self.msg_id.inner_dispatcher, msg_data) def show_box(self, index, tip): msg_data = {'index': index, 'tip': tip} # print(msg_data) self.send_msg_dispatcher(self.msg_id.ui_manager_show_box, msg_data) def mode_dispatcher(self, page_mode): msg_data = {'page_mode': page_mode} self.send_msg_dispatcher(self.msg_id.ui_manager_change_page, msg_data) # """test code """ if __name__ == '__main__': logger = get_logger(__name__) message = App('test') print(message.make_session('abc')) # for index in range(20): # time.sleep(0.1) # logger.info('send : test') # message.send_msg('test','test') # # # print(message.check_dispatcher_ready.__annotations__) # message.subscriber('test', message.callback_test) # logger.info('message.start()') # print(pub.topicsMap) # if 'test' in pub.topicsMap: # print('test ok')