hand_peripheral.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. """睿手相关参数模型"""
  2. from enum import Enum
  3. from pydantic import BaseModel
  4. from pydantic import Field
  5. class ChannelName(int, Enum):
  6. CHANNEL_A = 0x01
  7. CHANNEL_B = 0x02
  8. class DraftChannel(int, Enum):
  9. SINGLE = 0x01
  10. DOUBLE = 0x02
  11. class IsElectric(int, Enum):
  12. WITH_ELECTRIC = 0x00
  13. WITHOUT_ELECTRIC = 0x01
  14. class SetCurrent(BaseModel):
  15. """set current pydantic model"""
  16. channel: ChannelName = Field(
  17. ...,
  18. description=
  19. "set peripheral hand current channel (channelA: 0x01, channelB: 0x02)")
  20. value: int = Field(...,
  21. le=255,
  22. ge=0,
  23. description="set peripheral hand current value")
  24. class ControlMotion(BaseModel):
  25. """control motion pydantic model"""
  26. hand_select: str = Field()
  27. thumb: int = Field(..., le=100, ge=0)
  28. index_finger: int = Field(..., le=100, ge=0)
  29. middle_finger: int = Field(..., le=100, ge=0)
  30. ring_finger: int = Field(..., le=100, ge=0)
  31. little_finger: int = Field(..., le=100, ge=0)
  32. duration: int = Field(..., le=20, ge=5)
  33. class DraftingAction(BaseModel):
  34. """drafting action pydantic model"""
  35. hand_select: str = Field(
  36. ...,
  37. description="select control hand (double: 0x01, left: 0x02, right:0x03)"
  38. )
  39. is_electric: IsElectric = Field(
  40. ..., description="model (with electric: 0x00, without electric: 0x01)")
  41. draft_channel: DraftChannel = Field(
  42. ..., description="select channel (a channel: 0x01, double: 0x02)")
  43. a_channel_value: int = Field(...,
  44. le=255,
  45. ge=0,
  46. description="set A channel hand current value")
  47. b_channel_value: int = Field(...,
  48. le=255,
  49. ge=0,
  50. description="set b channel hand current value")
  51. duration: int = Field(..., le=20, ge=5)