def start(self): self.__logger.info('start service_manger!') cfg_server = CfgServer() cfg_server.start() self.__logger.info('start cfg_service ok!') interface_ros = InterfaceRos() interface_ros.start() self.__logger.info('start interface_ros ok') video_record_enable = get_value_by_key('video_record_enable', 'CONFIG') self.__logger.info('get video_record_enable :' + str(video_record_enable)) if video_record_enable == 'yes': video_record = VideoRecord() video_record.start() self.__logger.info('start video_record ok !') update_task = UpdateTask() update_task.start() self.__logger.info('start update_task Ok!') interface_ros.init_ros_node() self.__logger.info('start init_ros_node Ok!') check_memory = get_value_by_key('check_memory', 'CONFIG') self.__logger.info('get check_memory :' + str(check_memory)) if check_memory == 'yes': task_mem = Thread(target=get_mem_snap) task_mem.start() while True: time.sleep(1)
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): 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 change_wp_file(wp_path): launch_file = get_value_by_key('linerunning', 'LAUNCH') if launch_file is None: launch_file = '/home/utry/catkin_ws/src/linerunning_v2/launch/xiaoyuan_clear.launch' launch_file_bk = get_launch_backup(launch_file) if os.path.isfile(launch_file): cmd = 'cp ' + launch_file + ' ' + launch_file_bk os.system(cmd) if os.path.isfile(wp_path) and os.path.isfile(launch_file): with open(launch_file, 'r') as f_launch: file_lines = f_launch.readlines() with open(launch_file, 'w') as f_launch: for line in file_lines: if 'waypoints_filepath' in line: line = ' <param name="waypoints_filepath" type="string" value="' + wp_path + '"/>\n' f_launch.write(line) with open(launch_file, 'r') as f_launch: file_lines = f_launch.readlines() for line in file_lines: if wp_path in line: return True if os.path.isfile(launch_file_bk): cmd = 'cp ' + launch_file_bk + ' ' + launch_file os.system(cmd) return False
def change_pcd_file(pcd_path): launch_file = get_value_by_key('other', 'LAUNCH') if launch_file is None: launch_file = '/home/utry/catkin_ws/src/xiaoyuan_robot_v2/launch/xiaoyuan_robot_start_other.launch' # 拼接backup文件 launch_file_bk = get_launch_backup(launch_file) if os.path.isfile(launch_file): cmd = 'cp ' + launch_file + ' ' + launch_file_bk os.system(cmd) if os.path.isfile(pcd_path) and os.path.isfile(launch_file): with open(launch_file, 'r') as f_launch: file_lines = f_launch.readlines() with open(launch_file, 'w') as f_launch: for line in file_lines: if 'map_pcd' in line: line = ' <arg name="map_pcd" value="' + pcd_path + '"/>\n' f_launch.write(line) with open(launch_file, 'r') as f_launch: file_lines = f_launch.readlines() for line in file_lines: if pcd_path in line: return True if os.path.isfile(launch_file_bk): cmd = 'cp ' + launch_file_bk + ' ' + launch_file os.system(cmd) return False
def __init__(self, database_name='u_database.db'): database_path = get_value_by_key('database', 'DATA_PATH') print('Database get path: ' + str(database_path)) if database_path is None: database_path = os.path.curdir self.connect = sqlite3.connect(os.path.join(database_path, str(database_name)), check_same_thread=False) self.cursor = self.connect.cursor() self.cursor.execute("PRAGMA synchronous = 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 start(self): self.__logger.info('begin to init ros core') try: process = Process(target=self.ros_core_process) process.daemon = True time.sleep(1) process.start() self.__logger.info('complete to init ros core') check_memory = get_value_by_key('check_memory', 'CONFIG') self.__logger.info('get check_memory :' + str(check_memory)) if check_memory == 'yes': task_mem = Thread(target=get_mem_snap) task_mem.start() self.launch_thread = LaunchThread() self.launch_thread.start() except Exception as e: self.__logger.fatal('process start fail!! ' + str(e)) time.sleep(1)
def start(self): self.__logger.info('begin to init pyqt5 app for this project!') # init widgets self.__app = QtWidgets.QApplication([]) self.widgets = QtWidgets.QWidget() self.widgets.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint) self.widgets.move(0, 0) self.widgets.resize(800, 480) print('ui_manager come in 76') if not os.path.isfile('./debug'): self.widgets.setCursor(QtCore.Qt.BlankCursor) self.dispatcher = UDispatcher(UMsg.ui_dispatcher, self.__manager_pipe) print('ui_manager come in 82') # init base_frame self.__frame = BaseFrame(self.widgets) print('ui_manager come in 86') # self.__change_page(0) # show main frame self.widgets.show() # test mem check_memory = get_value_by_key('check_memory', 'CONFIG') self.__logger.info('get check_memory :' + str(check_memory)) if check_memory == 'yes': task_mem = Thread(target=get_mem_snap) task_mem.start() self.__app.exec_() self.__logger.info('end!!!!!!') print('ui_manager come in 58')
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)