1. [profile: aio.py]:完善durable text相关逻辑 2. [profile: do_brake/do_current/btn_functions.py]:删除validate_resp函数,修改execution函数 3. [profile: factory_test.py] - 新增耐久/老化测试程序 - 实现六轴折线图显示 4. [profile: openapi.py]:多次合并遗留问题处理 5. templates文件夹组织架构调整
74 lines
2.6 KiB
Python
74 lines
2.6 KiB
Python
from json import loads
|
||
from sys import argv
|
||
|
||
|
||
def execution(cmd, hr, w2t, **kwargs):
|
||
_id = hr.execution(cmd, **kwargs)
|
||
_msg = hr.get_from_id(_id)
|
||
if not _msg:
|
||
w2t(f"无法获取{_id}请求的响应信息", 0, 6, 'red', tab_name='Automatic Test')
|
||
else:
|
||
_response = loads(_msg)
|
||
if not _response:
|
||
w2t(f"无法获取{id}请求的响应信息", 0, 1, 'red', tab_name='Automatic Test')
|
||
return _response
|
||
|
||
|
||
def trigger_estop(md, w2t):
|
||
md.trigger_estop()
|
||
w2t("触发急停成功,可点击机器状态验证。", 0, 0, 'green', 'Automatic Test')
|
||
|
||
|
||
def reset_estop(md, w2t):
|
||
md.reset_estop()
|
||
w2t("恢复急停成功,可点击机器状态验证。", 0, 0, 'green', 'Automatic Test')
|
||
|
||
|
||
def get_state(hr, w2t):
|
||
# 获取机器状态
|
||
_response = execution('state.get_state', hr, w2t)
|
||
stat_desc = {'engine': '上电状态', 'operate': '操作模式', 'rc_state': '控制器状态', 'robot_action': '机器人动作', 'safety_mode': '安全模式', 'servo_mode': '伺服工作模式', 'task_space': '工作任务空间'}
|
||
for component, state in _response['data'].items():
|
||
w2t(f"{stat_desc[component]}: {state}", tab_name='Automatic Test')
|
||
|
||
# 获取设备伺服信息
|
||
_response = execution('device.get_params', hr, w2t)
|
||
dev_desc = {0: '伺服版本', 1: '伺服参数', 2: '安全板固件', 3: '控制器', 4: '通讯总线', 5: '解释器', 6: '运动控制', 8: '力控版本', 9: '末端固件', 10: '机型文件', 11: '环境包'}
|
||
dev_vers = {}
|
||
for device in _response['data']['devices']:
|
||
dev_vers[device['type']] = device['version']
|
||
for i in sorted(dev_desc.keys()):
|
||
w2t(f"{dev_desc[i]}: {dev_vers[i]}", tab_name='Automatic Test')
|
||
|
||
# 设置示教器模式
|
||
_response = execution('state.set_tp_mode', hr, w2t, tp_mode='without')
|
||
|
||
|
||
def warning_info(hr, w2t):
|
||
for msg in hr.c_msg:
|
||
if 'alarm' in msg.lower():
|
||
w2t(str(loads(msg)), tab_name='Automatic Test')
|
||
for msg in hr.c_msg_xs:
|
||
if 'alarm' in msg.lower():
|
||
w2t(str(loads(msg)), tab_name='Automatic Test')
|
||
|
||
|
||
def main(hr, md, func, w2t):
|
||
if hr is None:
|
||
w2t("无法连接机器人,检查是否已经使用Robot Assist软件连接机器,重试中...", 0, 49, 'red', tab_name='Automatic Test')
|
||
# func: get_state/
|
||
match func:
|
||
case 'trigger_estop':
|
||
trigger_estop(md, w2t)
|
||
case 'reset_estop':
|
||
reset_estop(md, w2t)
|
||
case 'get_state':
|
||
get_state(hr, w2t)
|
||
case 'warning_info':
|
||
warning_info(hr, w2t)
|
||
|
||
|
||
if __name__ == '__main__':
|
||
main(*argv[1:])
|
||
|