chore: remove target component method in Command interface
This commit is contained in:
parent
ca2b1e8fd4
commit
b0bfd95ed9
@ -1,80 +1,40 @@
|
|||||||
package device
|
package device
|
||||||
|
|
||||||
// FingerPoseCommand 手指姿态指令
|
// FingerPoseCommand 手指姿态指令
|
||||||
type FingerPoseCommand struct {
|
type FingerPoseCommand struct{ poseData []byte }
|
||||||
fingerID string
|
|
||||||
poseData []byte
|
|
||||||
targetComp string
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewFingerPoseCommand(fingerID string, poseData []byte) *FingerPoseCommand {
|
func NewFingerPoseCommand(fingerID string, poseData []byte) *FingerPoseCommand {
|
||||||
return &FingerPoseCommand{
|
return &FingerPoseCommand{poseData: poseData}
|
||||||
fingerID: fingerID,
|
|
||||||
poseData: poseData,
|
|
||||||
targetComp: "finger_" + fingerID,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FingerPoseCommand) Type() string {
|
func (c *FingerPoseCommand) Type() string { return "SetFingerPose" }
|
||||||
return "SetFingerPose"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *FingerPoseCommand) Payload() []byte {
|
func (c *FingerPoseCommand) Payload() []byte { return c.poseData }
|
||||||
return c.poseData
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *FingerPoseCommand) TargetComponent() string {
|
|
||||||
return c.targetComp
|
|
||||||
}
|
|
||||||
|
|
||||||
// PalmPoseCommand 手掌姿态指令
|
// PalmPoseCommand 手掌姿态指令
|
||||||
type PalmPoseCommand struct {
|
type PalmPoseCommand struct{ poseData []byte }
|
||||||
poseData []byte
|
|
||||||
targetComp string
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewPalmPoseCommand(poseData []byte) *PalmPoseCommand {
|
func NewPalmPoseCommand(poseData []byte) *PalmPoseCommand {
|
||||||
return &PalmPoseCommand{
|
return &PalmPoseCommand{poseData: poseData}
|
||||||
poseData: poseData,
|
|
||||||
targetComp: "palm",
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *PalmPoseCommand) Type() string {
|
func (c *PalmPoseCommand) Type() string { return "SetPalmPose" }
|
||||||
return "SetPalmPose"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *PalmPoseCommand) Payload() []byte {
|
func (c *PalmPoseCommand) Payload() []byte { return c.poseData }
|
||||||
return c.poseData
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *PalmPoseCommand) TargetComponent() string {
|
|
||||||
return c.targetComp
|
|
||||||
}
|
|
||||||
|
|
||||||
// GenericCommand 通用指令
|
// GenericCommand 通用指令
|
||||||
type GenericCommand struct {
|
type GenericCommand struct {
|
||||||
cmdType string
|
cmdType string
|
||||||
payload []byte
|
payload []byte
|
||||||
targetComp string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGenericCommand(cmdType string, payload []byte, targetComp string) *GenericCommand {
|
func NewGenericCommand(cmdType string, payload []byte, targetComp string) *GenericCommand {
|
||||||
return &GenericCommand{
|
return &GenericCommand{
|
||||||
cmdType: cmdType,
|
cmdType: cmdType,
|
||||||
payload: payload,
|
payload: payload,
|
||||||
targetComp: targetComp,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *GenericCommand) Type() string {
|
func (c *GenericCommand) Type() string { return c.cmdType }
|
||||||
return c.cmdType
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *GenericCommand) Payload() []byte {
|
func (c *GenericCommand) Payload() []byte { return c.payload }
|
||||||
return c.payload
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *GenericCommand) TargetComponent() string {
|
|
||||||
return c.targetComp
|
|
||||||
}
|
|
||||||
|
@ -31,9 +31,8 @@ type Device interface {
|
|||||||
|
|
||||||
// Command 代表一个发送给设备的指令
|
// Command 代表一个发送给设备的指令
|
||||||
type Command interface {
|
type Command interface {
|
||||||
Type() string // 指令类型,例如 "SetFingerPose", "SetPalmAngle"
|
Type() string // 指令类型,例如 "SetFingerPose", "SetPalmAngle"
|
||||||
Payload() []byte // 指令的实际数据
|
Payload() []byte // 指令的实际数据
|
||||||
TargetComponent() string // 目标组件 ID
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SensorData 代表从传感器读取的数据
|
// SensorData 代表从传感器读取的数据
|
||||||
|
Loading…
x
Reference in New Issue
Block a user