workpiece.py 660 B

1234567891011121314151617181920212223242526272829
  1. from dataclasses import dataclass
  2. from enum import Enum
  3. class WorkpieceColor(Enum):
  4. NONE = 'NONE'
  5. RED = 'RED'
  6. WHITE = 'WHITE'
  7. BLUE = 'BLUE'
  8. @dataclass
  9. class Workpiece:
  10. id: str
  11. color: WorkpieceColor
  12. state: str = 'raw' # 'raw'
  13. def __str__(self):
  14. return f"{type(self).__name__}(id={self.id}, color={self.color.value} state={self.state})"
  15. def __repr__(self):
  16. return f"{type(self).__name__}(id={self.id}, color={self.color.value} state={self.state})"
  17. def to_dict(self) -> dict:
  18. return {
  19. "id": self.id,
  20. "color": self.color.value,
  21. "state": self.state
  22. }