get_program_state
Retrieve the program execution status of a Universal Robot by specifying its IP address. Use this tool to monitor and manage robot operations in real-time.
Instructions
获取指定IP机器人的程序执行状态 IP:机器人地址
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ip | Yes |
Implementation Reference
- Handler function for the 'get_program_state' tool. Decorated with @mcp.tool() to register it. Takes robot IP, checks connection, queries loaded program name, program state, saved status, and running status using UR DashboardClient methods, formats and returns the information.@mcp.tool() def get_program_state(ip: str): """获取指定IP机器人的程序执行状态 IP:机器人地址""" try: if '连接失败' in link_check(ip): return return_msg(f"与机器人的连接已断开。") robot_list[ip].robotConnector.DashboardClient.ur_get_loaded_program() prog_name = robot_list[ip].robotConnector.DashboardClient.last_respond robot_list[ip].robotConnector.DashboardClient.ur_programState() prog_state = robot_list[ip].robotConnector.DashboardClient.last_respond robot_list[ip].robotConnector.DashboardClient.ur_isProgramSaved() flg = robot_list[ip].robotConnector.DashboardClient.last_respond robot_list[ip].robotConnector.DashboardClient.ur_running() running = robot_list[ip].robotConnector.DashboardClient.last_respond prog_saved = '' prog_running = '' if flg.startswith("false"): prog_saved = '程序未保存,请及时保存或备份正在编辑的程序。' if running == 'Program running: true': prog_running = '机械臂正在动作。' return return_msg( f"IP为{ip}的优傲机器人当前加载的程序是:{prog_name},程序的执行状态是:{prog_state}。{prog_saved}。{prog_running}") except Exception as e: logger.error(f"程序的执行状态获取失败: {str(e)}") return return_msg(f"程序的执行状态获取失败: {str(e)}")