Status ViewModel
controller.presentation.view_models.status_view_model
状态视图模型 - 管理机器人状态显示 订阅 RobotStateDomainService,不再自己维护状态
StatusViewModel
StatusViewModel(robot_state_service: RobotStateDomainService, parent=None)
Bases: BaseViewModel
状态视图模型。
管理机器人状态显示,订阅 RobotStateDomainService 的状态更新,不再自己维护状态。
职责: 1. 订阅 RobotStateDomainService 的状态更新 2. 转换数据格式(转换为 dict 供 UI 组件使用) 3. 发射信号给 UI 组件
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
status_updated |
pyqtSignal
|
状态更新信号,携带状态数据字典。 |
robot_state_service |
RobotStateDomainService
|
机械臂状态服务。 |
初始化状态视图模型。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
robot_state_service
|
RobotStateDomainService
|
机械臂状态服务(依赖注入)。 |
必需 |
parent
|
QObject
|
父对象. Defaults to None. |
None
|
源代码位于: src/controller/controller/presentation/view_models/status_view_model.py
28 29 30 31 32 33 34 35 36 37 38 39 | |
get_position_string
get_position_string() -> str
获取位置信息的字符串表示。
返回:
| 名称 | 类型 | 描述 |
|---|---|---|
str |
str
|
位置字符串,如 "[0.50, -1.20, 0.30, 0.00, 0.00, 0.00]"。如果无数据返回 "--"。 |
源代码位于: src/controller/controller/presentation/view_models/status_view_model.py
66 67 68 69 70 71 72 73 74 75 76 | |
get_status_summary
get_status_summary() -> str
获取状态摘要。
返回:
| 名称 | 类型 | 描述 |
|---|---|---|
str |
str
|
状态摘要字符串,如 "CMD:0x06 | MODE:0x08 | STA:0x01"。如果无数据返回 "无状态数据"。 |
源代码位于: src/controller/controller/presentation/view_models/status_view_model.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |