拆分device.Service接口
This commit is contained in:
@@ -42,17 +42,21 @@ func WithoutTracking() SendOption {
|
||||
}
|
||||
}
|
||||
|
||||
// Service 抽象了一组方法用于控制设备行为
|
||||
type Service interface {
|
||||
|
||||
// Switch 用于切换指定设备的状态, 比如启动和停止
|
||||
// DeviceOperator 提供了对单个或多个设备进行具体操作的接口,
|
||||
// 如开关、触发采集等。它通常用于响应用户的直接指令或执行具体的业务任务。
|
||||
type DeviceOperator interface {
|
||||
// Switch 用于切换指定设备的状态, 比如启动和停止。
|
||||
Switch(ctx context.Context, device *models.Device, action DeviceAction) error
|
||||
|
||||
// Collect 用于发起对指定区域主控下的多个设备的批量采集请求。
|
||||
Collect(ctx context.Context, areaControllerID uint32, devicesToCollect []*models.Device) error
|
||||
}
|
||||
|
||||
// Send 是一个通用的发送方法,用于将一个标准的指令载荷发送到指定的区域主控。
|
||||
// 它负责将载荷包装成顶层指令、序列化、调用底层发送器,并默认记录下行命令日志。
|
||||
// DeviceCommunicator 抽象了与设备进行底层通信的能力。
|
||||
// 它负责将一个标准的指令载荷发送到指定的区域主控。
|
||||
type DeviceCommunicator interface {
|
||||
// Send 是一个通用的发送方法,它负责将载荷包装、序列化、
|
||||
// 调用底层发送器,并默认记录下行命令日志。
|
||||
Send(ctx context.Context, areaControllerID uint32, payload proto.InstructionPayload, opts ...SendOption) error
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user