chore: remove target component method in Command interface
This commit is contained in:
parent
ca2b1e8fd4
commit
b0bfd95ed9
@ -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
|
||||
}
|
||||
|
||||
func NewGenericCommand(cmdType string, payload []byte, targetComp string) *GenericCommand {
|
||||
return &GenericCommand{
|
||||
cmdType: cmdType,
|
||||
payload: payload,
|
||||
targetComp: targetComp,
|
||||
}
|
||||
}
|
||||
|
||||
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 }
|
||||
|
@ -33,7 +33,6 @@ type Device interface {
|
||||
type Command interface {
|
||||
Type() string // 指令类型,例如 "SetFingerPose", "SetPalmAngle"
|
||||
Payload() []byte // 指令的实际数据
|
||||
TargetComponent() string // 目标组件 ID
|
||||
}
|
||||
|
||||
// SensorData 代表从传感器读取的数据
|
||||
|
Loading…
x
Reference in New Issue
Block a user