Pārlūkot izejas kodu

Fix issue where status wasn't properly updated when DSO got cleared

anfeny 8 mēneši atpakaļ
vecāks
revīzija
87b263d9dc
1 mainītis faili ar 5 papildinājumiem un 3 dzēšanām
  1. 5 3
      simulator/devs_models/dso.py

+ 5 - 3
simulator/devs_models/dso.py

@@ -61,8 +61,10 @@ class DSO(AtomicDEVS):
     def get_status_message(self, use_next_phase=True) -> MqttMessage:
         """ Get the status message for the input bay """
         phase = self.state.phase.next() if use_next_phase else self.state.phase
-        active = 1 if (self.state.workpiece is not None) else 0
-        code = 1 if (phase == DsoPhase.IDLE) else 0 # TODO: figure out this logic
+        # active = 1 if (self.state.workpiece is not None) else 0
+        # code = 1 if (phase == DsoPhase.IDLE) else 0 # TODO: figure out this logic
+        active = 1 if (phase == DsoPhase.WP_RECEIVED) else 0
+        code = 0 if (phase == DsoPhase.AWAIT_PICKUP) else 1 # 1 for idle, 0 for not blocked (wp here)
 
         message = MqttMessage()
         message.topic = "f/i/state/dso"
@@ -111,7 +113,7 @@ class DSO(AtomicDEVS):
             return {self.mqtt_out: [self.get_status_message(use_next_phase=False)]}
         
         if self.state.phase == DsoPhase.PICKUP:
-            return {self.out: [self.state.workpiece]} # output the workpiece to the collector
+            return {self.out: [self.state.workpiece], self.mqtt_out: [self.get_status_message()]} # output the workpiece to the collector
 
         return {}