| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- from .cell import Cell
- from enum import Enum
- class DeviceStatus(Enum):
- EMPTY = 0
- INSERTED = 1
- MEASURING = 2
- DONE = 3
- ERROR = 4
- class Device():
- def __init__(self, id: int, config: dict):
- """
- Initializes a Device instance.
- :param device_id: Unique identifier for the device.
- :param slots: Number of slots available in the device.
- """
- self.id: int = id
- self.i2c_address: str = config['i2c_address']
- self.slots = [Slot(idx) for idx in range(config['num_slots'])]
- self.status_list = [DeviceStatus.EMPTY for _ in range(len(self.slots))]
-
- def get_slot_by_id(self, slot_id: int):
- return next((slot for slot in self.slots if slot.id == slot_id), None)
-
- class Slot():
- def __init__(self, id: int):
- self.id = id
- self.curr_cell: Cell = None
- def insert_cell(self, cell: Cell):
- self.curr_cell = cell
- def remove_cell(self):
- self.curr_cell = None
- def is_empty(self) -> bool:
- return self.curr_cell is None
- def get_cell(self) -> Cell:
- return self.curr_cell
|