跳转至

Control ViewModel

controller.presentation.view_models.control_view_model

ControlViewModel

ControlViewModel(command_hub_service: CommandHubService, parent=None)

Bases: BaseViewModel

控制视图模型。

负责处理用户输入的控制命令,并分发到命令中心服务。

属性:

名称 类型 描述
command_hub_service CommandHubService

命令中心服务。

初始化控制视图模型。

参数:

名称 类型 描述 默认
command_hub_service CommandHubService

命令中心服务。

必需
parent QObject

父对象. Defaults to None.

None
源代码位于: src/controller/controller/presentation/view_models/control_view_model.py
15
16
17
18
19
20
21
22
23
def __init__(self, command_hub_service: CommandHubService, parent=None):
    """初始化控制视图模型。

    Args:
        command_hub_service (CommandHubService): 命令中心服务。
        parent (QObject, optional): 父对象. Defaults to None.
    """
    super().__init__(parent)
    self.command_hub_service = command_hub_service

send_command

send_command(config_dict: dict)

发送控制命令。

参数:

名称 类型 描述 默认
config_dict dict

命令配置字典,包含控制参数。

必需
源代码位于: src/controller/controller/presentation/view_models/control_view_model.py
25
26
27
28
29
30
31
def send_command(self, config_dict: dict):
    """发送控制命令。

    Args:
        config_dict (dict): 命令配置字典,包含控制参数。
    """
    self.command_hub_service.command_distribution(config_dict)