hand_peripheral.py 2.1 KB

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