Exemplo n.º 1
0
 def show_box_show_tip(self, data_dict):
     msg_id, msg_data = Util.get_msg_id_data_dict(data_dict)
     if msg_id is not None:
         index, tip = Util.get_index_tip_msg_data(msg_data)
         if index is not None:
             pass
     pass
Exemplo n.º 2
0
 def compare_qr_code(self):
     ret, md5sum_download = Util.get_md5sum(self.download_file_name)
     if ret == 'ok':
         ret, md5sum_current = Util.get_md5sum(self.qr_code_path)
         if md5sum_current == md5sum_download:
             self.logger.info('two png is same!!')
             return True
     self.logger.info('two png not same!!' + str(md5sum_download) + ' : ' +
                      str(md5sum_current))
     return False
Exemplo n.º 3
0
    def on_click_button_yes(self):
        """取消按钮"""
        if list_show_box_string[self.index][show_box_yes] is not None:
            self.mode_dispatcher(
                list_show_box_string[self.index][show_box_yes])
        elif self.index == show_box_start_error:
            self.logger.fatal('start error restart!')
            Util.do_restart()

        self.hide()
Exemplo n.º 4
0
 def start(self):
     Util.add_thread(target=self.__run__)
     Util.add_thread(target=self.write_file_queue_callback)
     if self.rtmp_enable == 'yes':
         Util.add_thread(target=self.rtmp_queue_callback)
     if self.http_local_enable == 'yes':
         Util.add_thread(target=self.local_queue_callback)
Exemplo n.º 5
0
 def __show_box_callback(self, data_dict):
     """
     data_dict =
     {
         'msg_id' : 'ui_manager_show_box',
         'msg_data' : {
             'index' : 1 ,
             'tip' : 'this a tip for show box'
         }
     }
     """
     msg_id, msg_data = Util.get_msg_id_data_dict(data_dict)
     if msg_id is not None:
         index, tip = Util.get_index_tip_msg_data(msg_data)
         if index is not None:
             self.__show_box(index, tip)
Exemplo n.º 6
0
 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)
Exemplo n.º 7
0
 def control_callback(self, data_dict):
     self.__logger.info(str(data_dict))
     _, msg_data = Util.get_msg_id_data_dict(data_dict)
     if 'ros_start' in msg_data:
         if msg_data['ros_start']:
             if self.is_start:
                 self.__logger.warning(' is starting please wait')
             else:
                 self.__logger.info('start launch begin')
                 Util.add_thread(target=self.start_launch_thread)
         else:
             if self.is_stop:
                 self.__logger.warning(' is stopping please wait')
             else:
                 self.__logger.info('stop launch begin')
                 Util.add_thread(target=self.stop_launch_thread)
Exemplo n.º 8
0
    def get_map_num(self):

        list_map = Util.get_map_num()

        self.m_button_left.hide()
        self.m_button_right.hide()
        list_map_len = len(list_map)

        if list_map_len == 0:
            self.timer_update_map.stop()
            self.show_box(show_box_need_build_map, '')
        else:
            if list_map == self.list_map:
                self.timer_update_map.stop()
                return
            else:
                self.list_map = list_map

                self.clear_all()

                self.position_cnt = 0

                self.timer_update_map.start(50)

        # if list_map_len > 8:
        #     self.m_button_right.show()
        pass
Exemplo n.º 9
0
    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()
Exemplo n.º 10
0
    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()
Exemplo n.º 11
0
    def __subscribe_msg(self, data_dict):
        """
        subscribe msg_id with mode_name.

        :param data_dict: is a dict . include msg_id, mode_name

        Note: ##
        data_dict = {
            'msg_id' : 'register_msg_id',
            'msg_data' :
            {
                'msg_id' : 'xxxxx_id',
                'module_name' : 'xxxxxx'
            }
        }
        """
        msg_id, msg_data = Util.get_msg_id_data_dict(data_dict)
        if msg_id is not None:
            msg_id = msg_data.get('msg_id')
            module_name = msg_data.get('module_name')
            if isinstance(msg_id, str) and isinstance(module_name, str):
                if msg_id == self.msg_id.inner_register_id:
                    self.__logger.info('register_msg_id ready for service !')
                else:
                    if msg_id in self.msg_id_module_dict:
                        self.__logger.warning('msg_id : ' + str(msg_id) + ' register again! old module_ is ' +
                                              str(self.msg_id_module_dict[msg_id]) + ' new module is ' +
                                              str(module_name))
                    else:
                        self.__logger.info('msg_id : ' + str(msg_id) + ' register to module :' + str(module_name))
                    self.msg_id_module_dict[msg_id] = module_name
                    self.send_msg_id_manager_dispatcher(msg_id)
Exemplo n.º 12
0
    def __multi_msg_dispatcher(self, data_dict):
        msg_id, msg_data = Util.get_msg_id_data_dict(data_dict)

        if msg_id is not None:
            module_name = self.msg_id_module_dict.get(msg_id)
            if isinstance(module_name, str):
                self.send_msg(msg_id, module_name, msg_data, msg_src=data_dict['msg_src'])
Exemplo n.º 13
0
    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())
Exemplo n.º 14
0
 def send_msg_ros(self, msg_data):
     ret, send_msg = Util.dict_to_ros_msg(msg_data)
     if ret == 'ok':
         self.pub.publish(send_msg)
     else:
         self.logger.warning('msg : ' + str(msg_data) + 'to json fail by:' +
                             str(ret))
     return
Exemplo n.º 15
0
 def mode_status_update(self, data_dict):
     self.logger.info(str(data_dict))
     _, msg_data = Util.get_msg_id_data_dict(data_dict)
     if 'status' in msg_data and 'index' in msg_data:
         status = msg_data['status']
         index = msg_data['index']
         if isinstance(status, bool) and index in range(start_status_cnt):
             self.list_start_status[index][start_status] = status
Exemplo n.º 16
0
    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()
Exemplo n.º 17
0
 def inner_msg_handler(self, data_dict):
     msg_id, msg_data = Util.get_msg_id_data_dict(data_dict)
     if msg_id is not None:
         callback = self.__subscriber_dict.get(msg_id)
         if callback is not None:
             callback(data_dict)
         else:
             if self.__default_callback is not None:
                 self.__default_callback(data_dict)
Exemplo n.º 18
0
 def progress_notify_callback(self, data_dict):
     _, msg_data = Util.get_msg_id_data_dict(data_dict)
     self.logger.info('receive msg ' + str(data_dict))
     if 'progress_percent' in msg_data:
         progress_percent = msg_data['progress_percent']
         if isinstance(progress_percent, int):
             if progress_percent >= 100:
                 self.progress_percent = 100
             else:
                 self.progress_percent = progress_percent
Exemplo n.º 19
0
    def position_notify_callback(self, data_dict):
        msg_id, msg_data = Util.get_msg_id_data_dict(data_dict)
        if 'x' in msg_data and 'y' in msg_data and 'z' in msg_data:
            self.position_x = int(msg_data['x'])
            self.position_y = int(msg_data['y'])
            self.position_z = int(msg_data['z'])
        else:
            self.logger.warning(str(data_dict) + ' data error !!!')

        pass
Exemplo n.º 20
0
    def on_click_map_button(self, index):
        """选择地图按钮处理事件"""
        self.logger.info('click ' + str(index) + 'map')
        button_index = index - Map_button_id_delta

        if 0 <= button_index < len(self.list_map):
            if Util.change_wp_file(self.list_map[button_index].get('wp')) and \
                    Util.change_pcd_file(self.list_map[button_index].get('pcd')):
                map_select_path = self.list_map[button_index].get('png')
                map_select_name = self.list_map[button_index].get('name')
                self.show_box(show_box_map_select,
                              '【' + map_select_name + '】?')
                data_dict = {
                    'map_path': map_select_path,
                    'map_name': map_select_name
                }
                self.send_msg_dispatcher(self.msg_id.mode_working_show_map,
                                         data_dict)
            else:
                self.show_box(show_box_launch_fail, '')
Exemplo n.º 21
0
    def do_update_map(self):
        self.timer_update_map.stop()
        list_map_len = len(self.list_map)
        pos = self.get_map_qrect(list_map_len)

        if self.position_cnt >= len(self.list_map):
            return
        map_detail = self.list_map[self.position_cnt]

        rect_back, rect_title = self.get_qrect(pos, list_map_len,
                                               self.position_cnt)

        frame = AppQt.get_sub_frame(self.map_frame, rect_back,
                                    'background-color: #FFFFFF;')
        frame.show()

        self.list_map_frame.append(frame)
        png_path = map_detail.get('png')
        Util.resize_png_for_map_display(png_path)
        style_sheet = 'QPushButton{border-image: url(' + png_path + ')}'

        rect = AppQt.QRect(3, 3, pos['map_weight'] - 2 * 3,
                           pos['map_weight'] - 2 * 3)
        map_button = AppQt.get_pushbutton(frame, rect,
                                          style_sheet)  # type: QPushButton
        map_button.setObjectName(str(self.position_cnt + Map_button_id_delta))
        map_button.show()

        map_button.clicked.connect(
            lambda: self.on_click_map_button(int(self.sender().objectName())))

        self.list_map_button.append(map_button)

        name = map_detail.get('name')
        map_label = AppQt.get_label_text(self.map_frame, rect_title, False,
                                         name, 26)
        map_label.show()

        self.list_map_label.append(map_label)
        self.timer_update_map.start(50)
        pass
Exemplo n.º 22
0
 def interface_ros_send_msg_out(self, data_dict):
     _, msg_data = Util.get_msg_id_data_dict(data_dict)
     if msg_data is not None and isinstance(msg_data, dict):
         if self.ros_is_running:
             if self.ui_ros_topic_is_sub:
                 # self.send_msg_ros(msg_data)
                 self.msg_out_queue.put_nowait(msg_data)
             else:
                 self.logger.info('/ui_ros_topic is not Subscriber')
         else:
             self.logger.info('ros_master is not run')
     return
Exemplo n.º 23
0
    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))
Exemplo n.º 24
0
 def set_button_enable_callback(self, data_dict):
     """
     {
         'msg_id': 'base_frame_set_button_enable',
         'msg_data':{
             'button_enable': False
         }
     }
     :param data_dict:
     :return:
     """
     msg_id, msg_data = Util.get_msg_id_data_dict(data_dict)
     if msg_id is not None and isinstance(msg_data, dict):
         self.set_button_enable_msg_data_proc(msg_data)
Exemplo n.º 25
0
 def update_link_status_callback(self, data_dict):
     """
     {
         'msg_id' : 'mode_mt_update_link_status',
         'msg_data': {
             'link_ros': False,
             'link_mcu': False
         }
     }
     :param data_dict:
     :return:
     """
     msg_id, msg_data = Util.get_msg_id_data_dict(data_dict)
     if msg_id is not None and isinstance(msg_data, dict):
         self.update_link_status_proc(msg_data)
Exemplo n.º 26
0
    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()
Exemplo n.º 27
0
 def set_odom_callback(self, data_dict):
     """
     {
         'msg_id' : 'cfg_server_set_odom',
         'msg_data': {
             'odom': 1.23
         }
     }
     :param data_dict:
     :return:
     """
     msg_id, msg_data = Util.get_msg_id_data_dict(data_dict)
     if msg_id is not None and isinstance(msg_data, dict):
         self.logger.info('set_odom :' + str(data_dict))
         odom = msg_data['odom']
         self.database.update_key_value('odom', str(odom))
Exemplo n.º 28
0
    def show_map_callback(self, data_dict):
        msg_id, msg_data = Util.get_msg_id_data_dict(data_dict)
        if 'map_path' in msg_data and 'map_name' in msg_data:
            map_path = msg_data['map_path']
            if os.path.isfile(
                    map_path
            ) or map_path == ':/mode_map_select/mode_map_select/default.png':
                self.map_select_path = map_path
                if 'map_name' in msg_data:
                    self.map_select_name = msg_data['map_name']
                    return
            else:
                self.logger.fatal(str(map_path) + ' select path is no existed')
                return

        self.logger.warning(str(data_dict) + ' data error !!!')
Exemplo n.º 29
0
 def update_button_status_callback(self, data_dict):
     """
     {
         'msg_id' : 'mode_mt_update_button_status',
         'msg_data': {
             'brush_status': 'open', # close
             'water_status': 'open',
             'direction_status': 'forward' #back
         }
     }
     :param data_dict:
     :return:
     """
     msg_id, msg_data = Util.get_msg_id_data_dict(data_dict)
     if msg_id is not None and isinstance(msg_data, dict):
         self.update_button_status_proc(msg_data)
Exemplo n.º 30
0
    def update_button_status_callback(self, data_dict):
        """
        {
            'msg_id' : 'base_frame_update_button_status',
            'msg_data': {
                'page_mode': 1
            }
        }
        :param data_dict:
        :return:
        """

        msg_id, msg_data = Util.get_msg_id_data_dict(data_dict)
        if msg_id is not None and isinstance(msg_data, dict):
            self.logger.info('get_status :' + str(data_dict))
            self.update_button_status_proc(msg_data)