| 12345678910111213141516171819202122232425262728293031 |
- from dataclasses import dataclass, field
- import time
- from enum import Enum
- class WorkpieceColor(Enum):
- NONE = 'NONE'
- RED = 'RED'
- WHITE = 'WHITE'
- BLUE = 'BLUE'
- @dataclass
- class Workpiece:
- id: str
- color: WorkpieceColor
- state: str = 'RAW'
- created_at: float = field(default_factory=time.time) # time when workpiece was created, default to current time, can be set to sim time
-
- def __str__(self):
- return f"{type(self).__name__}(id={self.id}, color={self.color.value} state={self.state})"
- def __repr__(self):
- return f"{type(self).__name__}(id={self.id}, color={self.color.value} state={self.state})"
- def to_dict(self) -> dict:
- return {
- "id": self.id,
- "color": self.color.value,
- "state": self.state
- }
|