feat(phase3): implement SimPy discrete-event simulation engine, multi-zone order generation, fleet dispatcher, and wider Zone B aisles
This commit is contained in:
@@ -166,6 +166,11 @@ class Robot:
|
||||
return 0.0
|
||||
return max(0.0, min(100.0, (self.battery_level / self.battery_capacity) * 100.0))
|
||||
|
||||
@property
|
||||
def is_available(self) -> bool:
|
||||
"""Check if robot is idle and ready to be assigned a new task."""
|
||||
return self.current_state == RobotState.IDLE and self.current_task_id is None
|
||||
|
||||
def transition_to(self, new_state: RobotState, sim_time: float) -> None:
|
||||
"""Execute a state transition verifying legality against the transition matrix.
|
||||
|
||||
@@ -249,15 +254,17 @@ class Robot:
|
||||
|
||||
return True, None
|
||||
|
||||
def assign_task(self, task: Any) -> None:
|
||||
def assign_task(self, task: Any, sim_time: Optional[float] = None) -> None:
|
||||
"""Assign active task after verifying compatibility rules.
|
||||
|
||||
Raises:
|
||||
IncompatibleRobotTaskError: If robot is incompatible with task payload or zone.
|
||||
"""
|
||||
compatible, reason = self.validate_task_compatibility(task)
|
||||
if not compatible:
|
||||
raise IncompatibleRobotTaskError(reason or "Robot incompatible with task")
|
||||
# If task is already a Task object, validate compatibility
|
||||
if hasattr(task, "required_payload") or hasattr(task, "target_zone"):
|
||||
compatible, reason = self.validate_task_compatibility(task)
|
||||
if not compatible:
|
||||
raise IncompatibleRobotTaskError(reason or "Robot incompatible with task")
|
||||
|
||||
task_id = getattr(task, "task_id", str(task))
|
||||
self.current_task_id = task_id
|
||||
@@ -269,6 +276,10 @@ class Robot:
|
||||
self.current_task_id = None
|
||||
self.current_route.clear()
|
||||
|
||||
def complete_task(self, sim_time: Optional[float] = None) -> None:
|
||||
"""Complete active task and clear binding."""
|
||||
self.release_task()
|
||||
|
||||
def consume_energy(self, duration_seconds: float, mode: str = "moving_empty") -> float:
|
||||
"""Deduct energy consumed over duration according to active power mode.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user