basically done
This commit is contained in:
@ -1,67 +0,0 @@
|
||||
from sys import argv
|
||||
from commons import clibs
|
||||
|
||||
tab_name = clibs.tab_names['at']
|
||||
logger = clibs.log_prod
|
||||
|
||||
|
||||
def trigger_estop(md, w2t):
|
||||
md.trigger_estop()
|
||||
w2t("触发急停成功,可点击机器状态验证。", 0, 0, 'green', tab_name)
|
||||
|
||||
|
||||
def reset_estop(md, w2t):
|
||||
md.reset_estop()
|
||||
w2t("恢复急停成功,可点击机器状态验证。", 0, 0, 'green', tab_name)
|
||||
|
||||
|
||||
def get_state(hr, w2t):
|
||||
# 获取机器状态
|
||||
_response = clibs.execution('state.get_state', hr, w2t, tab_name)
|
||||
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=tab_name)
|
||||
|
||||
# 获取设备伺服信息
|
||||
_response = clibs.execution('device.get_params', hr, w2t, tab_name)
|
||||
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=tab_name)
|
||||
|
||||
# 设置示教器模式
|
||||
_response = clibs.execution('state.set_tp_mode', hr, w2t, tab_name, tp_mode='without')
|
||||
|
||||
|
||||
def warning_info(hr, w2t):
|
||||
for postfix in ['', '.2', '.3', '.4', '.5', '.6', '.7', '.8', '.9', '.10']:
|
||||
log_name = clibs.log_data_hmi + postfix
|
||||
try:
|
||||
with open(log_name, 'r', encoding='utf-8') as f_log:
|
||||
for line in f_log:
|
||||
if 'alarm' in line:
|
||||
w2t(line.strip(), tab_name=tab_name)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
|
||||
def main(hr, md, func, w2t):
|
||||
if hr is None:
|
||||
w2t("无法连接机器人,检查是否已经使用Robot Assist软件连接机器,重试中...", 0, 49, 'red', tab_name)
|
||||
# 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:])
|
||||
|
@ -75,8 +75,11 @@ def initialization(path, sub, data_dirs, data_files, hr, w2t):
|
||||
clibs.insert_logdb("INFO", "do_brake", f"get_configs: 各关节角速度 {avs}")
|
||||
return avs
|
||||
|
||||
clibs.c_hr.set_socket_params(True, str(clibs.external_port), "\r", 1)
|
||||
clibs.c_ec = openapi.ExternalCommunication(clibs.ip_addr, clibs.external_port)
|
||||
try:
|
||||
clibs.c_hr.set_socket_params(True, str(clibs.external_port), "\r", 1)
|
||||
clibs.c_ec = openapi.ExternalCommunication(clibs.ip_addr, clibs.external_port)
|
||||
except Exception:
|
||||
w2t(f"{clibs.ip_addr}:{clibs.socket_port} 或者 {clibs.ip_addr}:{clibs.external_port} 不可达,需检查网络连接!\n", color="red", desc="NetworkError")
|
||||
|
||||
_config_file, _prj_file, _result_dirs = check_files()
|
||||
_avs = get_configs()
|
||||
|
Reference in New Issue
Block a user