diff --git a/device/commands.go b/device/commands.go index fb14a71..bba515a 100644 --- a/device/commands.go +++ b/device/commands.go @@ -1,80 +1,40 @@ package device // FingerPoseCommand 手指姿态指令 -type FingerPoseCommand struct { - fingerID string - poseData []byte - targetComp string -} +type FingerPoseCommand struct{ poseData []byte } func NewFingerPoseCommand(fingerID string, poseData []byte) *FingerPoseCommand { - return &FingerPoseCommand{ - fingerID: fingerID, - poseData: poseData, - targetComp: "finger_" + fingerID, - } + return &FingerPoseCommand{poseData: poseData} } -func (c *FingerPoseCommand) Type() string { - return "SetFingerPose" -} +func (c *FingerPoseCommand) Type() string { return "SetFingerPose" } -func (c *FingerPoseCommand) Payload() []byte { - return c.poseData -} - -func (c *FingerPoseCommand) TargetComponent() string { - return c.targetComp -} +func (c *FingerPoseCommand) Payload() []byte { return c.poseData } // PalmPoseCommand 手掌姿态指令 -type PalmPoseCommand struct { - poseData []byte - targetComp string -} +type PalmPoseCommand struct{ poseData []byte } func NewPalmPoseCommand(poseData []byte) *PalmPoseCommand { - return &PalmPoseCommand{ - poseData: poseData, - targetComp: "palm", - } + return &PalmPoseCommand{poseData: poseData} } -func (c *PalmPoseCommand) Type() string { - return "SetPalmPose" -} +func (c *PalmPoseCommand) Type() string { return "SetPalmPose" } -func (c *PalmPoseCommand) Payload() []byte { - return c.poseData -} - -func (c *PalmPoseCommand) TargetComponent() string { - return c.targetComp -} +func (c *PalmPoseCommand) Payload() []byte { return c.poseData } // GenericCommand 通用指令 type GenericCommand struct { - cmdType string - payload []byte - targetComp string + cmdType string + payload []byte } func NewGenericCommand(cmdType string, payload []byte, targetComp string) *GenericCommand { return &GenericCommand{ - cmdType: cmdType, - payload: payload, - targetComp: targetComp, + cmdType: cmdType, + payload: payload, } } -func (c *GenericCommand) Type() string { - return c.cmdType -} +func (c *GenericCommand) Type() string { return c.cmdType } -func (c *GenericCommand) Payload() []byte { - return c.payload -} - -func (c *GenericCommand) TargetComponent() string { - return c.targetComp -} +func (c *GenericCommand) Payload() []byte { return c.payload } diff --git a/device/device.go b/device/device.go index a8e2f05..64296d6 100644 --- a/device/device.go +++ b/device/device.go @@ -31,9 +31,8 @@ type Device interface { // Command 代表一个发送给设备的指令 type Command interface { - Type() string // 指令类型,例如 "SetFingerPose", "SetPalmAngle" - Payload() []byte // 指令的实际数据 - TargetComponent() string // 目标组件 ID + Type() string // 指令类型,例如 "SetFingerPose", "SetPalmAngle" + Payload() []byte // 指令的实际数据 } // SensorData 代表从传感器读取的数据