Compare commits
	
		
			2 Commits
		
	
	
		
			d2794b2de7
			...
			af68f19d53
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| af68f19d53 | |||
| b01f8dc19c | 
@@ -551,3 +551,11 @@ v0.2.0.2(2024/07/26)
 | 
				
			|||||||
6. [main: openapi.py]
 | 
					6. [main: openapi.py]
 | 
				
			||||||
   - 将modbus motor_on/off的实现方法改为高电平脉冲触发
 | 
					   - 将modbus motor_on/off的实现方法改为高电平脉冲触发
 | 
				
			||||||
7. configs.xlsx配置表新增write_diagnosis/get_init_speed两个参数
 | 
					7. configs.xlsx配置表新增write_diagnosis/get_init_speed两个参数
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					v0.2.0.3(2024/07/27)
 | 
				
			||||||
 | 
					1. [APIs: do_brake.py]: 精简程序,解决 OOM 问题
 | 
				
			||||||
 | 
					2. [APIs: do_current.py]: 精简程序,解决 OOM 问题
 | 
				
			||||||
 | 
					3. [APIs: factory_test.py]: 精简程序,解决 OOM 问题
 | 
				
			||||||
 | 
					4. [APIsL openapi.py]
 | 
				
			||||||
 | 
					   - 心跳修改为 1 s,因为 OOM 问题的解决依赖于长久的打开曲线开关,此时对于 hr.c_msg 的定时清理是个挑战,将心跳缩短,有利于清理日志后,避免丢失心跳
 | 
				
			||||||
 | 
					   - 新增 diagnosis.save 命令,但是执行时,有问题,待解决
 | 
				
			||||||
										
											Binary file not shown.
										
									
								
							@@ -6,8 +6,8 @@ VSVersionInfo(
 | 
				
			|||||||
  ffi=FixedFileInfo(
 | 
					  ffi=FixedFileInfo(
 | 
				
			||||||
    # filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
 | 
					    # filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
 | 
				
			||||||
    # Set not needed items to zero 0.
 | 
					    # Set not needed items to zero 0.
 | 
				
			||||||
    filevers=(0, 2, 0, 2),
 | 
					    filevers=(0, 2, 0, 3),
 | 
				
			||||||
    prodvers=(0, 2, 0, 2),
 | 
					    prodvers=(0, 2, 0, 3),
 | 
				
			||||||
    # Contains a bitmask that specifies the valid bits 'flags'r
 | 
					    # Contains a bitmask that specifies the valid bits 'flags'r
 | 
				
			||||||
    mask=0x3f,
 | 
					    mask=0x3f,
 | 
				
			||||||
    # Contains a bitmask that specifies the Boolean attributes of the file.
 | 
					    # Contains a bitmask that specifies the Boolean attributes of the file.
 | 
				
			||||||
@@ -31,12 +31,12 @@ VSVersionInfo(
 | 
				
			|||||||
        '040904b0',
 | 
					        '040904b0',
 | 
				
			||||||
        [StringStruct('CompanyName', 'Rokae - https://www.rokae.com/'),
 | 
					        [StringStruct('CompanyName', 'Rokae - https://www.rokae.com/'),
 | 
				
			||||||
        StringStruct('FileDescription', 'All in one automatic toolbox'),
 | 
					        StringStruct('FileDescription', 'All in one automatic toolbox'),
 | 
				
			||||||
        StringStruct('FileVersion', '0.2.0.2 (2024-07-26)'),
 | 
					        StringStruct('FileVersion', '0.2.0.3 (2024-07-27)'),
 | 
				
			||||||
        StringStruct('InternalName', 'AIO.exe'),
 | 
					        StringStruct('InternalName', 'AIO.exe'),
 | 
				
			||||||
        StringStruct('LegalCopyright', '© 2024-2024 Manford Fan'),
 | 
					        StringStruct('LegalCopyright', '© 2024-2024 Manford Fan'),
 | 
				
			||||||
        StringStruct('OriginalFilename', 'AIO.exe'),
 | 
					        StringStruct('OriginalFilename', 'AIO.exe'),
 | 
				
			||||||
        StringStruct('ProductName', 'AIO'),
 | 
					        StringStruct('ProductName', 'AIO'),
 | 
				
			||||||
        StringStruct('ProductVersion', '0.2.0.2 (2024-07-26)')])
 | 
					        StringStruct('ProductVersion', '0.2.0.3 (2024-07-27)')])
 | 
				
			||||||
      ]),
 | 
					      ]),
 | 
				
			||||||
    VarFileInfo([VarStruct('Translation', [1033, 1200])])
 | 
					    VarFileInfo([VarStruct('Translation', [1033, 1200])])
 | 
				
			||||||
  ]
 | 
					  ]
 | 
				
			||||||
 
 | 
				
			|||||||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							@@ -1 +1 @@
 | 
				
			|||||||
0
 | 
					1
 | 
				
			||||||
@@ -5,8 +5,8 @@
 | 
				
			|||||||
  "data": {
 | 
					  "data": {
 | 
				
			||||||
	  "open": false,
 | 
						  "open": false,
 | 
				
			||||||
	  "display_open": false,
 | 
						  "display_open": false,
 | 
				
			||||||
	  "overrun": true,
 | 
						  "overrun": false,
 | 
				
			||||||
	  "turn_area": true,
 | 
						  "turn_area": false,
 | 
				
			||||||
	  "delay_motion": false
 | 
						  "delay_motion": false
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -1 +1 @@
 | 
				
			|||||||
0.2.0.2 @ 07/26/2024
 | 
					0.2.0.3 @ 07/27/2024
 | 
				
			||||||
@@ -105,7 +105,7 @@ class App(customtkinter.CTk):
 | 
				
			|||||||
        btns_func['log']['btn'].configure(command=lambda: self.thread_it(self.func_log_callback))
 | 
					        btns_func['log']['btn'].configure(command=lambda: self.thread_it(self.func_log_callback))
 | 
				
			||||||
        btns_func['end']['btn'].configure(command=lambda: self.thread_it(self.func_end_callback))
 | 
					        btns_func['end']['btn'].configure(command=lambda: self.thread_it(self.func_end_callback))
 | 
				
			||||||
        # create version info
 | 
					        # create version info
 | 
				
			||||||
        self.label_version = customtkinter.CTkLabel(self.frame_func, justify='left', text="Vers: 0.2.0.2\nDate: 07/26/2024", font=self.my_font, text_color="#4F4F4F")
 | 
					        self.label_version = customtkinter.CTkLabel(self.frame_func, justify='left', text="Vers: 0.2.0.3\nDate: 07/27/2024", font=self.my_font, text_color="#4F4F4F")
 | 
				
			||||||
        self.frame_func.rowconfigure(6, weight=1)
 | 
					        self.frame_func.rowconfigure(6, weight=1)
 | 
				
			||||||
        self.label_version.grid(row=6, column=0, padx=20, pady=20, sticky='s')
 | 
					        self.label_version.grid(row=6, column=0, padx=20, pady=20, sticky='s')
 | 
				
			||||||
        # =====================================================================
 | 
					        # =====================================================================
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -90,9 +90,8 @@ def prj_to_xcore(prj_file):
 | 
				
			|||||||
    print(stdout.read().decode())  # 必须得输出一下stdout,才能正确执行sudo
 | 
					    print(stdout.read().decode())  # 必须得输出一下stdout,才能正确执行sudo
 | 
				
			||||||
    print(stderr.read().decode())  # 顺便也执行以下stderr
 | 
					    print(stderr.read().decode())  # 顺便也执行以下stderr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # _prj_name = prj_file.split('\\')[-1].removesuffix('.zip')
 | 
					 | 
				
			||||||
    cmd = 'cd /home/luoshi/bin/controller/; '
 | 
					    cmd = 'cd /home/luoshi/bin/controller/; '
 | 
				
			||||||
    cmd += f'sudo mv projects/target/_build/*.prj projects/target/_build/target.prj'
 | 
					    cmd += 'sudo mv projects/target/_build/*.prj projects/target/_build/target.prj'
 | 
				
			||||||
    stdin, stdout, stderr = ssh.exec_command(cmd, get_pty=True)
 | 
					    stdin, stdout, stderr = ssh.exec_command(cmd, get_pty=True)
 | 
				
			||||||
    stdin.write('luoshi2019' + '\n')
 | 
					    stdin.write('luoshi2019' + '\n')
 | 
				
			||||||
    stdin.flush()
 | 
					    stdin.flush()
 | 
				
			||||||
@@ -120,13 +119,18 @@ def gen_result_file(path, curve_data, axis, _reach, _load, _speed, count):
 | 
				
			|||||||
    for data in curve_data:
 | 
					    for data in curve_data:
 | 
				
			||||||
        dict_results = data['data']
 | 
					        dict_results = data['data']
 | 
				
			||||||
        for item in dict_results:
 | 
					        for item in dict_results:
 | 
				
			||||||
 | 
					            try:
 | 
				
			||||||
                item['value'].reverse()
 | 
					                item['value'].reverse()
 | 
				
			||||||
 | 
					            except KeyError:
 | 
				
			||||||
 | 
					                continue
 | 
				
			||||||
            if item.get('channel', None) == axis-1 and item.get('name', None) == 'hw_joint_vel_feedback':
 | 
					            if item.get('channel', None) == axis-1 and item.get('name', None) == 'hw_joint_vel_feedback':
 | 
				
			||||||
                _d2d_vel['hw_joint_vel_feedback'].extend(item['value'])
 | 
					                _d2d_vel['hw_joint_vel_feedback'].extend(item['value'])
 | 
				
			||||||
            elif item.get('channel', None) == axis-1 and item.get('name', None) == 'device_servo_trq_feedback':
 | 
					            elif item.get('channel', None) == axis-1 and item.get('name', None) == 'device_servo_trq_feedback':
 | 
				
			||||||
                _d2d_trq['device_servo_trq_feedback'].extend(item['value'])
 | 
					                _d2d_trq['device_servo_trq_feedback'].extend(item['value'])
 | 
				
			||||||
            elif item.get('channel', None) == 0 and item.get('name', None) == 'device_safety_estop':
 | 
					            elif item.get('channel', None) == 0 and item.get('name', None) == 'device_safety_estop':
 | 
				
			||||||
                _d2d_stop['device_safety_estop'].extend(item['value'])
 | 
					                _d2d_stop['device_safety_estop'].extend(item['value'])
 | 
				
			||||||
 | 
					        if len(_d2d_trq['device_servo_trq_feedback']) / 1000 > 10:
 | 
				
			||||||
 | 
					            break
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    df1 = pandas.DataFrame.from_dict(_d2d_vel)
 | 
					    df1 = pandas.DataFrame.from_dict(_d2d_vel)
 | 
				
			||||||
    df2 = pandas.DataFrame.from_dict(_d2d_trq)
 | 
					    df2 = pandas.DataFrame.from_dict(_d2d_trq)
 | 
				
			||||||
@@ -164,6 +168,8 @@ def run_rl(path, loadsel, hr, md, config_file, result_dirs, w2t):
 | 
				
			|||||||
    else:
 | 
					    else:
 | 
				
			||||||
        w2t("configs.xlsx中Target页面A1单元格填写不正确,检查后重新运行...", 0, 111, 'red', tab_name)
 | 
					        w2t("configs.xlsx中Target页面A1单元格填写不正确,检查后重新运行...", 0, 111, 'red', tab_name)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    _response = execution('diagnosis.open', hr, w2t, open=True, display_open=True)
 | 
				
			||||||
 | 
					    _response = execution('diagnosis.set_params', hr, w2t, display_pdo_params=display_pdo_params)
 | 
				
			||||||
    for condition in result_dirs:
 | 
					    for condition in result_dirs:
 | 
				
			||||||
        _reach = condition.split('_')[0].removeprefix('reach')
 | 
					        _reach = condition.split('_')[0].removeprefix('reach')
 | 
				
			||||||
        _load = condition.split('_')[1].removeprefix('load')
 | 
					        _load = condition.split('_')[1].removeprefix('load')
 | 
				
			||||||
@@ -189,9 +195,7 @@ def run_rl(path, loadsel, hr, md, config_file, result_dirs, w2t):
 | 
				
			|||||||
                md.reset_estop()
 | 
					                md.reset_estop()
 | 
				
			||||||
                md.clear_alarm()
 | 
					                md.clear_alarm()
 | 
				
			||||||
                md.write_act(0)
 | 
					                md.write_act(0)
 | 
				
			||||||
                _response = execution('diagnosis.open', hr, w2t, open=True, display_open=True)
 | 
					 | 
				
			||||||
                sleep(write_diagnosis)  # 软急停超差后,等待写诊断时间,可通过configs.xlsx配置
 | 
					                sleep(write_diagnosis)  # 软急停超差后,等待写诊断时间,可通过configs.xlsx配置
 | 
				
			||||||
                _response = execution('diagnosis.open', hr, w2t, open=False, display_open=False)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                while count == 1:
 | 
					                while count == 1:
 | 
				
			||||||
                    # 2. 修改未要执行的场景
 | 
					                    # 2. 修改未要执行的场景
 | 
				
			||||||
@@ -236,16 +240,12 @@ def run_rl(path, loadsel, hr, md, config_file, result_dirs, w2t):
 | 
				
			|||||||
                            else:
 | 
					                            else:
 | 
				
			||||||
                                sleep(1)
 | 
					                                sleep(1)
 | 
				
			||||||
                # 4. 打开诊断曲线,并执行采集,之后触发软急停,关闭曲线采集,找出最大速度,传递给RL程序,最后清除相关记录
 | 
					                # 4. 打开诊断曲线,并执行采集,之后触发软急停,关闭曲线采集,找出最大速度,传递给RL程序,最后清除相关记录
 | 
				
			||||||
                    _response = execution('diagnosis.open', hr, w2t, open=True, display_open=True)
 | 
					 | 
				
			||||||
                    _response = execution('diagnosis.set_params', hr, w2t, display_pdo_params=display_pdo_params)
 | 
					 | 
				
			||||||
                    sleep(get_init_speed)  # 获取实际最大速度,可通过configs.xlsx配置
 | 
					                    sleep(get_init_speed)  # 获取实际最大速度,可通过configs.xlsx配置
 | 
				
			||||||
                    _response = execution('rl_task.stop', hr, w2t, tasks=['brake'])
 | 
					                    _response = execution('rl_task.stop', hr, w2t, tasks=['brake'])
 | 
				
			||||||
                    sleep(1)
 | 
					                    # sleep(1)
 | 
				
			||||||
                    _response = execution('state.switch_motor_off', hr, w2t)
 | 
					 | 
				
			||||||
                    _response = execution('state.switch_manual', hr, w2t)
 | 
					 | 
				
			||||||
                    _response = execution('diagnosis.open', hr, w2t, open=False, display_open=False)
 | 
					 | 
				
			||||||
                    # 找出最大速度
 | 
					                    # 找出最大速度
 | 
				
			||||||
                    for _msg in hr.c_msg:
 | 
					                    _c_msg = hr.c_msg.copy()
 | 
				
			||||||
 | 
					                    for _msg in _c_msg:
 | 
				
			||||||
                        if 'diagnosis.result' in _msg:
 | 
					                        if 'diagnosis.result' in _msg:
 | 
				
			||||||
                            dict_results = loads(_msg)['data']
 | 
					                            dict_results = loads(_msg)['data']
 | 
				
			||||||
                            for item in dict_results:
 | 
					                            for item in dict_results:
 | 
				
			||||||
@@ -262,14 +262,10 @@ def run_rl(path, loadsel, hr, md, config_file, result_dirs, w2t):
 | 
				
			|||||||
                        w2t(f"Axis: {axis}-{count} | Speed: {speed_max} | Shouldbe: {speed_target}", 0, 0, 'indigo', tab_name)
 | 
					                        w2t(f"Axis: {axis}-{count} | Speed: {speed_max} | Shouldbe: {speed_target}", 0, 0, 'indigo', tab_name)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    md.write_speed_max(speed_max)
 | 
					                    md.write_speed_max(speed_max)
 | 
				
			||||||
                    sleep(1)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    for _msg in hr.c_msg:
 | 
					 | 
				
			||||||
                        if 'diagnosis.result' in _msg:
 | 
					 | 
				
			||||||
                            _index = hr.c_msg.index(_msg)
 | 
					 | 
				
			||||||
                            del hr.c_msg[_index:]
 | 
					 | 
				
			||||||
                    hr.c_msg_xs.clear()
 | 
					                    hr.c_msg_xs.clear()
 | 
				
			||||||
                            break
 | 
					                    if len(hr.c_msg) > 240:
 | 
				
			||||||
 | 
					                        del hr.c_msg[240:]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if speed_max < 10:
 | 
					                    if speed_max < 10:
 | 
				
			||||||
                        md.clear_alarm()
 | 
					                        md.clear_alarm()
 | 
				
			||||||
@@ -296,8 +292,6 @@ def run_rl(path, loadsel, hr, md, config_file, result_dirs, w2t):
 | 
				
			|||||||
                else:
 | 
					                else:
 | 
				
			||||||
                    w2t("未收到机器人的运行信号,需要确认RL程序编写正确并正常执行...", 0, 111, 'red', tab_name)
 | 
					                    w2t("未收到机器人的运行信号,需要确认RL程序编写正确并正常执行...", 0, 111, 'red', tab_name)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                _response = execution('diagnosis.open', hr, w2t, open=True, display_open=True)
 | 
					 | 
				
			||||||
                _response = execution('diagnosis.set_params', hr, w2t, display_pdo_params=display_pdo_params)
 | 
					 | 
				
			||||||
                sleep(10)  # 排除从其他位姿到零点位姿,再到轴极限位姿的时间
 | 
					                sleep(10)  # 排除从其他位姿到零点位姿,再到轴极限位姿的时间
 | 
				
			||||||
                md.write_probe(1)
 | 
					                md.write_probe(1)
 | 
				
			||||||
                _t_start = time()
 | 
					                _t_start = time()
 | 
				
			||||||
@@ -305,29 +299,25 @@ def run_rl(path, loadsel, hr, md, config_file, result_dirs, w2t):
 | 
				
			|||||||
                    if md.read_brake_done() == 1:
 | 
					                    if md.read_brake_done() == 1:
 | 
				
			||||||
                        sleep(1)  # 保证速度归零
 | 
					                        sleep(1)  # 保证速度归零
 | 
				
			||||||
                        md.write_probe(0)
 | 
					                        md.write_probe(0)
 | 
				
			||||||
                        _response = execution('diagnosis.open', hr, w2t, open=False, display_open=False)
 | 
					 | 
				
			||||||
                        break
 | 
					                        break
 | 
				
			||||||
                    else:
 | 
					                    else:
 | 
				
			||||||
                        if (time() - _t_start) > 30:
 | 
					                        if (time() - _t_start) > 30:
 | 
				
			||||||
                            w2t(f"30s内未触发急停,该条数据无效,需要确认RL/Python程序编写正确并正常执行,或者判别是否是机器本体问题,比如正负方向速度是否一致...", 0, 0, 'red', tab_name)
 | 
					                            w2t(f"30s内未触发急停,该条数据无效,需要确认RL/Python程序编写正确并正常执行,或者判别是否是机器本体问题,比如正负方向速度是否一致...", 0, 0, 'red', tab_name)
 | 
				
			||||||
                            md.write_probe(0)
 | 
					                            md.write_probe(0)
 | 
				
			||||||
                            _response = execution('diagnosis.open', hr, w2t, open=False, display_open=False)
 | 
					 | 
				
			||||||
                            break
 | 
					                            break
 | 
				
			||||||
                        else:
 | 
					                        else:
 | 
				
			||||||
                            sleep(1)
 | 
					                            sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                # 6. 保留数据并处理输出
 | 
					                # 6. 保留数据并处理输出
 | 
				
			||||||
                curve_data = []
 | 
					                curve_data = []
 | 
				
			||||||
                for _msg in hr.c_msg:
 | 
					                _c_msg = hr.c_msg.copy()
 | 
				
			||||||
 | 
					                for _msg in _c_msg:
 | 
				
			||||||
                    if 'diagnosis.result' in _msg:
 | 
					                    if 'diagnosis.result' in _msg:
 | 
				
			||||||
                        curve_data.insert(0, loads(_msg))
 | 
					                        curve_data.insert(0, loads(_msg))
 | 
				
			||||||
                else:
 | 
					                else:
 | 
				
			||||||
                    for _msg in hr.c_msg:
 | 
					 | 
				
			||||||
                        if 'diagnosis.result' in _msg:
 | 
					 | 
				
			||||||
                            _index = hr.c_msg.index(_msg)
 | 
					 | 
				
			||||||
                            del hr.c_msg[_index:]
 | 
					 | 
				
			||||||
                    hr.c_msg_xs.clear()
 | 
					                    hr.c_msg_xs.clear()
 | 
				
			||||||
                            break
 | 
					                    if len(hr.c_msg) > 240:
 | 
				
			||||||
 | 
					                        del hr.c_msg[240:]
 | 
				
			||||||
                    gen_result_file(path, curve_data, axis, _reach, _load, _speed, count)
 | 
					                    gen_result_file(path, curve_data, axis, _reach, _load, _speed, count)
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        w2t(f"\n{loadsel.removeprefix('tool')}%负载的制动性能测试执行完毕,如需采集其他负载,须切换负载类型,并更换其他负载,重新执行。", 0, 0, 'green', tab_name)
 | 
					        w2t(f"\n{loadsel.removeprefix('tool')}%负载的制动性能测试执行完毕,如需采集其他负载,须切换负载类型,并更换其他负载,重新执行。", 0, 0, 'green', tab_name)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,6 +7,20 @@ from paramiko import SSHClient, AutoAddPolicy
 | 
				
			|||||||
from json import loads
 | 
					from json import loads
 | 
				
			||||||
import pandas
 | 
					import pandas
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					display_pdo_params = [
 | 
				
			||||||
 | 
					    {"name": "hw_joint_vel_feedback", "channel": 0},
 | 
				
			||||||
 | 
					    {"name": "hw_joint_vel_feedback", "channel": 1},
 | 
				
			||||||
 | 
					    {"name": "hw_joint_vel_feedback", "channel": 2},
 | 
				
			||||||
 | 
					    {"name": "hw_joint_vel_feedback", "channel": 3},
 | 
				
			||||||
 | 
					    {"name": "hw_joint_vel_feedback", "channel": 4},
 | 
				
			||||||
 | 
					    {"name": "hw_joint_vel_feedback", "channel": 5},
 | 
				
			||||||
 | 
					    {"name": "device_servo_trq_feedback", "channel": 0},
 | 
				
			||||||
 | 
					    {"name": "device_servo_trq_feedback", "channel": 1},
 | 
				
			||||||
 | 
					    {"name": "device_servo_trq_feedback", "channel": 2},
 | 
				
			||||||
 | 
					    {"name": "device_servo_trq_feedback", "channel": 3},
 | 
				
			||||||
 | 
					    {"name": "device_servo_trq_feedback", "channel": 4},
 | 
				
			||||||
 | 
					    {"name": "device_servo_trq_feedback", "channel": 5},
 | 
				
			||||||
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def traversal_files(path, w2t):
 | 
					def traversal_files(path, w2t):
 | 
				
			||||||
    if not exists(path):
 | 
					    if not exists(path):
 | 
				
			||||||
@@ -75,9 +89,8 @@ def prj_to_xcore(prj_file):
 | 
				
			|||||||
    print(stdout.read().decode())  # 必须得输出一下stdout,才能正确执行sudo
 | 
					    print(stdout.read().decode())  # 必须得输出一下stdout,才能正确执行sudo
 | 
				
			||||||
    print(stderr.read().decode())  # 顺便也执行以下stderr
 | 
					    print(stderr.read().decode())  # 顺便也执行以下stderr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # _prj_name = prj_file.split('\\')[-1].removesuffix('.zip')
 | 
					 | 
				
			||||||
    cmd = 'cd /home/luoshi/bin/controller/; '
 | 
					    cmd = 'cd /home/luoshi/bin/controller/; '
 | 
				
			||||||
    cmd += f'sudo mv projects/target/_build/*.prj projects/target/_build/target.prj'
 | 
					    cmd += 'sudo mv projects/target/_build/*.prj projects/target/_build/target.prj'
 | 
				
			||||||
    stdin, stdout, stderr = ssh.exec_command(cmd, get_pty=True)
 | 
					    stdin, stdout, stderr = ssh.exec_command(cmd, get_pty=True)
 | 
				
			||||||
    stdin.write('luoshi2019' + '\n')
 | 
					    stdin.write('luoshi2019' + '\n')
 | 
				
			||||||
    stdin.flush()
 | 
					    stdin.flush()
 | 
				
			||||||
@@ -107,7 +120,10 @@ def data_proc_regular(path, filename, channel, scenario_time):
 | 
				
			|||||||
            for line in lines:
 | 
					            for line in lines:
 | 
				
			||||||
                data = eval(line.strip())['data']
 | 
					                data = eval(line.strip())['data']
 | 
				
			||||||
                for item in data:
 | 
					                for item in data:
 | 
				
			||||||
 | 
					                    try:
 | 
				
			||||||
                        item['value'].reverse()
 | 
					                        item['value'].reverse()
 | 
				
			||||||
 | 
					                    except KeyError:
 | 
				
			||||||
 | 
					                        continue
 | 
				
			||||||
                    if item.get('channel', None) == channel and item.get('name', None) == 'hw_joint_vel_feedback':
 | 
					                    if item.get('channel', None) == channel and item.get('name', None) == 'hw_joint_vel_feedback':
 | 
				
			||||||
                        _d2d_vel['hw_joint_vel_feedback'].extend(item['value'])
 | 
					                        _d2d_vel['hw_joint_vel_feedback'].extend(item['value'])
 | 
				
			||||||
                    elif item.get('channel', None) == channel and item.get('name', None) == 'device_servo_trq_feedback':
 | 
					                    elif item.get('channel', None) == channel and item.get('name', None) == 'device_servo_trq_feedback':
 | 
				
			||||||
@@ -136,7 +152,10 @@ def data_proc_regular(path, filename, channel, scenario_time):
 | 
				
			|||||||
            for line in lines:
 | 
					            for line in lines:
 | 
				
			||||||
                data = eval(line.strip())['data']
 | 
					                data = eval(line.strip())['data']
 | 
				
			||||||
                for item in data:
 | 
					                for item in data:
 | 
				
			||||||
 | 
					                    try:
 | 
				
			||||||
                        item['value'].reverse()
 | 
					                        item['value'].reverse()
 | 
				
			||||||
 | 
					                    except KeyError:
 | 
				
			||||||
 | 
					                        continue
 | 
				
			||||||
                    if item.get('channel', None) == 0 and item.get('name', None) == 'hw_joint_vel_feedback':
 | 
					                    if item.get('channel', None) == 0 and item.get('name', None) == 'hw_joint_vel_feedback':
 | 
				
			||||||
                        _d2d_vel_0['hw_joint_vel_feedback'].extend(item['value'])
 | 
					                        _d2d_vel_0['hw_joint_vel_feedback'].extend(item['value'])
 | 
				
			||||||
                    elif item.get('channel', None) == 0 and item.get('name', None) == 'device_servo_trq_feedback':
 | 
					                    elif item.get('channel', None) == 0 and item.get('name', None) == 'device_servo_trq_feedback':
 | 
				
			||||||
@@ -205,7 +224,10 @@ def data_proc_regular(path, filename, channel, scenario_time):
 | 
				
			|||||||
            for line in lines:
 | 
					            for line in lines:
 | 
				
			||||||
                data = eval(line.strip())['data']
 | 
					                data = eval(line.strip())['data']
 | 
				
			||||||
                for item in data:
 | 
					                for item in data:
 | 
				
			||||||
 | 
					                    try:
 | 
				
			||||||
                        item['value'].reverse()
 | 
					                        item['value'].reverse()
 | 
				
			||||||
 | 
					                    except KeyError:
 | 
				
			||||||
 | 
					                        continue
 | 
				
			||||||
                    if item.get('channel', None) == channel-9 and item.get('name', None) == 'hw_joint_vel_feedback':
 | 
					                    if item.get('channel', None) == channel-9 and item.get('name', None) == 'hw_joint_vel_feedback':
 | 
				
			||||||
                        _d2d_vel['hw_joint_vel_feedback'].extend(item['value'])
 | 
					                        _d2d_vel['hw_joint_vel_feedback'].extend(item['value'])
 | 
				
			||||||
                    elif item.get('channel', None) == channel-9 and item.get('name', None) == 'device_servo_trq_feedback':
 | 
					                    elif item.get('channel', None) == channel-9 and item.get('name', None) == 'device_servo_trq_feedback':
 | 
				
			||||||
@@ -226,7 +248,10 @@ def data_proc_inertia(path, filename, channel):
 | 
				
			|||||||
        for line in lines:
 | 
					        for line in lines:
 | 
				
			||||||
            data = eval(line.strip())['data']
 | 
					            data = eval(line.strip())['data']
 | 
				
			||||||
            for item in data:
 | 
					            for item in data:
 | 
				
			||||||
 | 
					                try:
 | 
				
			||||||
                    item['value'].reverse()
 | 
					                    item['value'].reverse()
 | 
				
			||||||
 | 
					                except KeyError:
 | 
				
			||||||
 | 
					                    continue
 | 
				
			||||||
                if item.get('channel', None) == channel+3 and item.get('name', None) == 'hw_joint_vel_feedback':
 | 
					                if item.get('channel', None) == channel+3 and item.get('name', None) == 'hw_joint_vel_feedback':
 | 
				
			||||||
                    _d2d_vel['hw_joint_vel_feedback'].extend(item['value'])
 | 
					                    _d2d_vel['hw_joint_vel_feedback'].extend(item['value'])
 | 
				
			||||||
                elif item.get('channel', None) == channel+3 and item.get('name', None) == 'device_servo_trq_feedback':
 | 
					                elif item.get('channel', None) == channel+3 and item.get('name', None) == 'device_servo_trq_feedback':
 | 
				
			||||||
@@ -287,20 +312,19 @@ def run_rl(path, hr, md, loadsel, w2t):
 | 
				
			|||||||
        conditions = c_inertia
 | 
					        conditions = c_inertia
 | 
				
			||||||
        disc = disc_inertia
 | 
					        disc = disc_inertia
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # preparation 触发软急停,并解除,目的是让可能正在运行着的机器停下来
 | 
				
			||||||
 | 
					    _response = execution('diagnosis.open', hr, w2t, open=True, display_open=True)
 | 
				
			||||||
 | 
					    _response = execution('diagnosis.set_params', hr, w2t, display_pdo_params=display_pdo_params)
 | 
				
			||||||
 | 
					    # _response = execution('diagnosis.save', hr, w2t, save=True)  # 这条命令有问题
 | 
				
			||||||
 | 
					    md.trigger_estop()
 | 
				
			||||||
 | 
					    md.reset_estop()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for condition in conditions:
 | 
					    for condition in conditions:
 | 
				
			||||||
        number = conditions.index(condition)
 | 
					        number = conditions.index(condition)
 | 
				
			||||||
        w2t(f"正在执行{disc[number][0]}测试......", 0, 0, 'purple', 'Automatic Test')
 | 
					        w2t(f"正在执行{disc[number][0]}测试......", 0, 0, 'purple', 'Automatic Test')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # 1. 关闭诊断曲线,触发软急停,并解除,目的是让可能正在运行着的机器停下来,切手动模式并下电
 | 
					        # 1. 将act重置为False,并修改未要执行的场景
 | 
				
			||||||
        _response = execution('diagnosis.open', hr, w2t, open=False, display_open=False)
 | 
					 | 
				
			||||||
        md.trigger_estop()
 | 
					 | 
				
			||||||
        md.reset_estop()
 | 
					 | 
				
			||||||
        md.write_act(False)
 | 
					        md.write_act(False)
 | 
				
			||||||
        sleep(1)  # 让曲线彻底关闭
 | 
					 | 
				
			||||||
        _response = execution('state.switch_manual', hr, w2t)
 | 
					 | 
				
			||||||
        _response = execution('state.switch_motor_off', hr, w2t)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        # 2. 修改未要执行的场景
 | 
					 | 
				
			||||||
        ssh = SSHClient()
 | 
					        ssh = SSHClient()
 | 
				
			||||||
        ssh.set_missing_host_key_policy(AutoAddPolicy())
 | 
					        ssh.set_missing_host_key_policy(AutoAddPolicy())
 | 
				
			||||||
        ssh.connect('192.168.0.160', 22, username='luoshi', password='luoshi2019')
 | 
					        ssh.connect('192.168.0.160', 22, username='luoshi', password='luoshi2019')
 | 
				
			||||||
@@ -313,15 +337,14 @@ def run_rl(path, hr, md, loadsel, w2t):
 | 
				
			|||||||
        print(stdout.read().decode())  # 必须得输出一下stdout,才能正确执行sudo
 | 
					        print(stdout.read().decode())  # 必须得输出一下stdout,才能正确执行sudo
 | 
				
			||||||
        print(stderr.read().decode())  # 顺便也执行以下stderr
 | 
					        print(stderr.read().decode())  # 顺便也执行以下stderr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # 3. reload工程后,pp2main,并且自动模式和上电
 | 
					        # 2. reload工程后,pp2main,并且自动模式和上电
 | 
				
			||||||
        prj_path = 'target/_build/target.prj'
 | 
					        prj_path = 'target/_build/target.prj'
 | 
				
			||||||
        _response = execution('overview.reload', hr, w2t, prj_path=prj_path, tasks=['current'])
 | 
					        _response = execution('overview.reload', hr, w2t, prj_path=prj_path, tasks=['current'])
 | 
				
			||||||
        _response = execution('overview.get_cur_prj', hr, w2t)
 | 
					 | 
				
			||||||
        _response = execution('rl_task.pp_to_main', hr, w2t, tasks=['current'])
 | 
					        _response = execution('rl_task.pp_to_main', hr, w2t, tasks=['current'])
 | 
				
			||||||
        _response = execution('state.switch_auto', hr, w2t)
 | 
					        _response = execution('state.switch_auto', hr, w2t)
 | 
				
			||||||
        _response = execution('state.switch_motor_on', hr, w2t)
 | 
					        _response = execution('state.switch_motor_on', hr, w2t)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # 4. 开始运行程序,单轴运行15s
 | 
					        # 3. 开始运行程序,单轴运行35s
 | 
				
			||||||
        _response = execution('rl_task.run', hr, w2t, tasks=['current'])
 | 
					        _response = execution('rl_task.run', hr, w2t, tasks=['current'])
 | 
				
			||||||
        _t_start = time()
 | 
					        _t_start = time()
 | 
				
			||||||
        while True:
 | 
					        while True:
 | 
				
			||||||
@@ -334,25 +357,8 @@ def run_rl(path, hr, md, loadsel, w2t):
 | 
				
			|||||||
                else:
 | 
					                else:
 | 
				
			||||||
                    sleep(1)
 | 
					                    sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # 5. 打开诊断曲线,并执行采集
 | 
					        # 4. 打开诊断曲线,并执行采集
 | 
				
			||||||
        sleep(10)  # 保证程序已经运行起来,其实主要是为了保持电流的采集而设定
 | 
					        sleep(10)  # 保证程序已经运行起来,其实主要是为了保持电流的采集而设定
 | 
				
			||||||
        _response = execution('diagnosis.open', hr, w2t, open=True, display_open=True)
 | 
					 | 
				
			||||||
        display_pdo_params = [
 | 
					 | 
				
			||||||
            {"name": "hw_joint_vel_feedback", "channel": 0},
 | 
					 | 
				
			||||||
            {"name": "hw_joint_vel_feedback", "channel": 1},
 | 
					 | 
				
			||||||
            {"name": "hw_joint_vel_feedback", "channel": 2},
 | 
					 | 
				
			||||||
            {"name": "hw_joint_vel_feedback", "channel": 3},
 | 
					 | 
				
			||||||
            {"name": "hw_joint_vel_feedback", "channel": 4},
 | 
					 | 
				
			||||||
            {"name": "hw_joint_vel_feedback", "channel": 5},
 | 
					 | 
				
			||||||
            {"name": "device_servo_trq_feedback", "channel": 0},
 | 
					 | 
				
			||||||
            {"name": "device_servo_trq_feedback", "channel": 1},
 | 
					 | 
				
			||||||
            {"name": "device_servo_trq_feedback", "channel": 2},
 | 
					 | 
				
			||||||
            {"name": "device_servo_trq_feedback", "channel": 3},
 | 
					 | 
				
			||||||
            {"name": "device_servo_trq_feedback", "channel": 4},
 | 
					 | 
				
			||||||
            {"name": "device_servo_trq_feedback", "channel": 5},
 | 
					 | 
				
			||||||
            {"name": "device_safety_estop", "channel": 0},
 | 
					 | 
				
			||||||
        ]
 | 
					 | 
				
			||||||
        _response = execution('diagnosis.set_params', hr, w2t, display_pdo_params=display_pdo_params)
 | 
					 | 
				
			||||||
        scenario_time = 0
 | 
					        scenario_time = 0
 | 
				
			||||||
        if number < 6:
 | 
					        if number < 6:
 | 
				
			||||||
            sleep(35)
 | 
					            sleep(35)
 | 
				
			||||||
@@ -374,24 +380,16 @@ def run_rl(path, hr, md, loadsel, w2t):
 | 
				
			|||||||
            scenario_time = md.read_scenario_time()
 | 
					            scenario_time = md.read_scenario_time()
 | 
				
			||||||
            sleep(float(scenario_time)*0.2)  # 再运行周期的20%即可
 | 
					            sleep(float(scenario_time)*0.2)  # 再运行周期的20%即可
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # 6. 关闭诊断曲线,停止程序运行,下电并且换成手动模式
 | 
					        # 5.停止程序运行,保留数据并处理输出
 | 
				
			||||||
        _response = execution('diagnosis.open', hr, w2t, open=False, display_open=False)
 | 
					 | 
				
			||||||
        _response = execution('rl_task.stop', hr, w2t, tasks=['current'])
 | 
					        _response = execution('rl_task.stop', hr, w2t, tasks=['current'])
 | 
				
			||||||
        _response = execution('state.switch_motor_off', hr, w2t)
 | 
					        _c_msg = hr.c_msg.copy()
 | 
				
			||||||
        _response = execution('state.switch_manual', hr, w2t)
 | 
					        for _msg in _c_msg:
 | 
				
			||||||
        sleep(1)  # 保证所有数据均已返回
 | 
					 | 
				
			||||||
        # 7. 保留数据并处理输出
 | 
					 | 
				
			||||||
        for _msg in hr.c_msg:
 | 
					 | 
				
			||||||
            if 'diagnosis.result' in _msg:
 | 
					            if 'diagnosis.result' in _msg:
 | 
				
			||||||
                disc[number][1].insert(0, loads(_msg))
 | 
					                disc[number][1].insert(0, loads(_msg))
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            _index = 210
 | 
					 | 
				
			||||||
            for _msg in hr.c_msg:
 | 
					 | 
				
			||||||
                if 'diagnosis.result' in _msg:
 | 
					 | 
				
			||||||
                    _index = hr.c_msg.index(_msg)
 | 
					 | 
				
			||||||
                    break
 | 
					 | 
				
			||||||
            del hr.c_msg[_index:]
 | 
					 | 
				
			||||||
            hr.c_msg_xs.clear()
 | 
					            hr.c_msg_xs.clear()
 | 
				
			||||||
 | 
					            if len(hr.c_msg) > 240:
 | 
				
			||||||
 | 
					                del hr.c_msg[240:]
 | 
				
			||||||
            gen_result_file(path, loadsel, disc, number, scenario_time)
 | 
					            gen_result_file(path, loadsel, disc, number, scenario_time)
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        if loadsel == 'tool100':
 | 
					        if loadsel == 'tool100':
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -81,9 +81,8 @@ def prj_to_xcore(prj_file):
 | 
				
			|||||||
    print(stdout.read().decode())  # 必须得输出一下stdout,才能正确执行sudo
 | 
					    print(stdout.read().decode())  # 必须得输出一下stdout,才能正确执行sudo
 | 
				
			||||||
    print(stderr.read().decode())  # 顺便也执行以下stderr
 | 
					    print(stderr.read().decode())  # 顺便也执行以下stderr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _prj_name = prj_file.split('\\')[-1].removesuffix('.zip')
 | 
					 | 
				
			||||||
    cmd = 'cd /home/luoshi/bin/controller/; '
 | 
					    cmd = 'cd /home/luoshi/bin/controller/; '
 | 
				
			||||||
    cmd += f'sudo mv projects/target/_build/{_prj_name}.prj projects/target/_build/target.prj'
 | 
					    cmd += 'sudo mv projects/target/_build/*.prj projects/target/_build/target.prj'
 | 
				
			||||||
    stdin, stdout, stderr = ssh.exec_command(cmd, get_pty=True)
 | 
					    stdin, stdout, stderr = ssh.exec_command(cmd, get_pty=True)
 | 
				
			||||||
    stdin.write('luoshi2019' + '\n')
 | 
					    stdin.write('luoshi2019' + '\n')
 | 
				
			||||||
    stdin.flush()
 | 
					    stdin.flush()
 | 
				
			||||||
@@ -106,7 +105,8 @@ def execution(cmd, hr, w2t, **kwargs):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
def run_rl(path, config_file, data_all, hr, md, w2t):
 | 
					def run_rl(path, config_file, data_all, hr, md, w2t):
 | 
				
			||||||
    # 1. 关闭诊断曲线,触发软急停,并解除,目的是让可能正在运行着的机器停下来,切手动模式并下电
 | 
					    # 1. 关闭诊断曲线,触发软急停,并解除,目的是让可能正在运行着的机器停下来,切手动模式并下电
 | 
				
			||||||
    _response = execution('diagnosis.open', hr, w2t, open=False, display_open=False)
 | 
					    _response = execution('diagnosis.open', hr, w2t, open=True, display_open=True)
 | 
				
			||||||
 | 
					    _response = execution('diagnosis.set_params', hr, w2t, display_pdo_params=display_pdo_params)
 | 
				
			||||||
    md.trigger_estop()
 | 
					    md.trigger_estop()
 | 
				
			||||||
    md.reset_estop()
 | 
					    md.reset_estop()
 | 
				
			||||||
    md.write_act(False)
 | 
					    md.write_act(False)
 | 
				
			||||||
@@ -115,7 +115,6 @@ def run_rl(path, config_file, data_all, hr, md, w2t):
 | 
				
			|||||||
    # 2. reload工程后,pp2main,并且自动模式和上电
 | 
					    # 2. reload工程后,pp2main,并且自动模式和上电
 | 
				
			||||||
    prj_path = 'target/_build/target.prj'
 | 
					    prj_path = 'target/_build/target.prj'
 | 
				
			||||||
    _response = execution('overview.reload', hr, w2t, prj_path=prj_path, tasks=['current'])
 | 
					    _response = execution('overview.reload', hr, w2t, prj_path=prj_path, tasks=['current'])
 | 
				
			||||||
    _response = execution('overview.get_cur_prj', hr, w2t)
 | 
					 | 
				
			||||||
    _response = execution('rl_task.pp_to_main', hr, w2t, tasks=['current'])
 | 
					    _response = execution('rl_task.pp_to_main', hr, w2t, tasks=['current'])
 | 
				
			||||||
    _response = execution('state.switch_auto', hr, w2t)
 | 
					    _response = execution('state.switch_auto', hr, w2t)
 | 
				
			||||||
    _response = execution('state.switch_motor_on', hr, w2t)
 | 
					    _response = execution('state.switch_motor_on', hr, w2t)
 | 
				
			||||||
@@ -134,8 +133,7 @@ def run_rl(path, config_file, data_all, hr, md, w2t):
 | 
				
			|||||||
                sleep(1)
 | 
					                sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # 4. 获取初始数据,周期时间,首次的各轴平均电流值,打开诊断曲线,并执行采集
 | 
					    # 4. 获取初始数据,周期时间,首次的各轴平均电流值,打开诊断曲线,并执行采集
 | 
				
			||||||
    _response = execution('diagnosis.open', hr, w2t, open=True, display_open=True)
 | 
					    sleep(20)  # 初始化 scenario time 为 0
 | 
				
			||||||
    _response = execution('diagnosis.set_params', hr, w2t, display_pdo_params=display_pdo_params)
 | 
					 | 
				
			||||||
    _t_start = time()
 | 
					    _t_start = time()
 | 
				
			||||||
    while True:
 | 
					    while True:
 | 
				
			||||||
        scenario_time = md.read_scenario_time()
 | 
					        scenario_time = md.read_scenario_time()
 | 
				
			||||||
@@ -162,36 +160,26 @@ def run_rl(path, config_file, data_all, hr, md, w2t):
 | 
				
			|||||||
    for i in range(6):
 | 
					    for i in range(6):
 | 
				
			||||||
        rcs.append(float(_ws.cell(row=6, column=i + 2).value))
 | 
					        rcs.append(float(_ws.cell(row=6, column=i + 2).value))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _response = execution('diagnosis.open', hr, w2t, open=False, display_open=False)
 | 
					 | 
				
			||||||
    sleep(1)  # 保证所有数据均已返回
 | 
					 | 
				
			||||||
    get_durable_data(path, data_all, scenario_time, wait_time, rcs, hr, md, w2t)
 | 
					    get_durable_data(path, data_all, scenario_time, wait_time, rcs, hr, md, w2t)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # 7. 继续运行
 | 
					    # 7. 继续运行
 | 
				
			||||||
    while True:
 | 
					    while True:
 | 
				
			||||||
        # 固定间隔,更新一次数据,打开曲线,获取周期内电流,关闭曲线
 | 
					        # 固定间隔,更新一次数据,打开曲线,获取周期内电流,关闭曲线
 | 
				
			||||||
        sleep(wait_time)
 | 
					        sleep(wait_time+scenario_time+7)
 | 
				
			||||||
        _response = execution('diagnosis.open', hr, w2t, open=True, display_open=True)
 | 
					 | 
				
			||||||
        _response = execution('diagnosis.set_params', hr, w2t, display_pdo_params=display_pdo_params)
 | 
					 | 
				
			||||||
        sleep(scenario_time+5)
 | 
					 | 
				
			||||||
        _response = execution('diagnosis.open', hr, w2t, open=False, display_open=False)
 | 
					 | 
				
			||||||
        sleep(2)
 | 
					 | 
				
			||||||
        # 保留数据并处理输出
 | 
					        # 保留数据并处理输出
 | 
				
			||||||
        get_durable_data(path, data_all, scenario_time, wait_time, rcs, hr, md, w2t)
 | 
					        get_durable_data(path, data_all, scenario_time, wait_time, rcs, hr, md, w2t)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_durable_data(path, data, scenario_time, wait_time, rcs, hr, md, w2t):
 | 
					def get_durable_data(path, data, scenario_time, wait_time, rcs, hr, md, w2t):
 | 
				
			||||||
    _data_list = []
 | 
					    _data_list = []
 | 
				
			||||||
    for _msg in hr.c_msg:
 | 
					    _c_msg = hr.c_msg.copy()
 | 
				
			||||||
 | 
					    for _msg in _c_msg:
 | 
				
			||||||
        if 'diagnosis.result' in _msg:
 | 
					        if 'diagnosis.result' in _msg:
 | 
				
			||||||
            _data_list.insert(0, loads(_msg))
 | 
					            _data_list.insert(0, loads(_msg))
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        _index = 210
 | 
					 | 
				
			||||||
        for _msg in hr.c_msg:
 | 
					 | 
				
			||||||
            if 'diagnosis.result' in _msg:
 | 
					 | 
				
			||||||
                _index = hr.c_msg.index(_msg)
 | 
					 | 
				
			||||||
                break
 | 
					 | 
				
			||||||
        del hr.c_msg[_index:]
 | 
					 | 
				
			||||||
        hr.c_msg_xs.clear()
 | 
					        hr.c_msg_xs.clear()
 | 
				
			||||||
 | 
					        if len(hr.c_msg) > 240:
 | 
				
			||||||
 | 
					            del hr.c_msg[240:]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # with open(f'{path}\\log.txt', 'w', encoding='utf-8') as f_obj:
 | 
					    # with open(f'{path}\\log.txt', 'w', encoding='utf-8') as f_obj:
 | 
				
			||||||
    #     for _ in _data_list:
 | 
					    #     for _ in _data_list:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -261,10 +261,12 @@ class HmiRequest(object):
 | 
				
			|||||||
                f_hb.write(_flag)
 | 
					                f_hb.write(_flag)
 | 
				
			||||||
                if _flag == '0':
 | 
					                if _flag == '0':
 | 
				
			||||||
                    self.w2t(f"{_id} 心跳丢失,连接失败,重新连接中...", 0, 7, 'red', tab_name=self.tab_name)
 | 
					                    self.w2t(f"{_id} 心跳丢失,连接失败,重新连接中...", 0, 7, 'red', tab_name=self.tab_name)
 | 
				
			||||||
            sleep(2)
 | 
					                    t = time()
 | 
				
			||||||
            # with open(f"{current_path}/../assets/templates/c_msg.log", "w", encoding='utf-8') as f:
 | 
					                    with open(f"{current_path}/../assets/templates/c_msg.log", "w", encoding='utf-8') as f:
 | 
				
			||||||
            #     for msg in self.c_msg:
 | 
					                        for msg in self.c_msg:
 | 
				
			||||||
            #         f.write(str(loads(msg)) + '\n')
 | 
					                            f.write(str(t) + '-' + str(loads(msg)) + '\n')
 | 
				
			||||||
 | 
					            sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def msg_storage(self, response, flag=0):
 | 
					    def msg_storage(self, response, flag=0):
 | 
				
			||||||
        # response是解码后的字符串
 | 
					        # response是解码后的字符串
 | 
				
			||||||
@@ -604,6 +606,8 @@ class HmiRequest(object):
 | 
				
			|||||||
                    req['data']['type'] = kwargs['type']
 | 
					                    req['data']['type'] = kwargs['type']
 | 
				
			||||||
                    req['data']['bias'] = kwargs['bias']
 | 
					                    req['data']['bias'] = kwargs['bias']
 | 
				
			||||||
                    req['data']['value'] = kwargs['value']
 | 
					                    req['data']['value'] = kwargs['value']
 | 
				
			||||||
 | 
					                case 'diagnosis.save':
 | 
				
			||||||
 | 
					                    req['data']['save'] = kwargs['save']
 | 
				
			||||||
                case _:
 | 
					                case _:
 | 
				
			||||||
                    pass
 | 
					                    pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user