Agent.py
def run(self) -> None:
        """monitor own state and switch modes according to it's change"""

        # note latest known state
        latest_state: int = -1

        # monitor own state change
        while True:
            # detect change of the state
            if latest_state != self.state:

                # do state related actions when state switch detected
                if self.state == 0:
                    self.state_0()

                elif self.state == 1:
                    self.state_1()

                elif self.state == 2:
                    self.state_2()

                elif self.state == 3:
                    self._update_backend_state(priority=1)
                    self.state_3()

                # report own state transition
                logging.info(f"Agent state is now {self.state}")

                # sync backend state with the own one
                self._update_backend_state(priority=1)

                # update latest known state
                latest_state = self.state

            # sleep before next update
            sleep(0.2)
monitor own state and switch modes according to it's change
monitor own state and switch modes according to it's change
monitor own state and switch modes according to it ' s change
def run(self) -> None:
        latest_state: int = -1
        while True:
            if latest_state != self.state:
                if self.state == 0:
                    self.state_0()
                elif self.state == 1:
                    self.state_1()
                elif self.state == 2:
                    self.state_2()
                elif self.state == 3:
                    self._update_backend_state(priority=1)
                    self.state_3()
                logging.info(f"Agent state is now {self.state}")
                self._update_backend_state(priority=1)
                latest_state = self.state
            sleep(0.2)
def run ( self ) -> None : latest_state : int = - 1 while True : if latest_state != self . state : if self . state == 0 : self . state_0 ( ) elif self . state == 1 : self . state_1 ( ) elif self . state == 2 : self . state_2 ( ) elif self . state == 3 : self . _update_backend_state ( priority = 1 ) self . state_3 ( ) logging . info ( f"Agent state is now {self.state}" ) self . _update_backend_state ( priority = 1 ) latest_state = self . state sleep ( 0.2 )
monitor own state and switch modes according to it's change
monitor own state and switch modes according to it ' s change
"""monitor own state and switch modes according to it's change""" # note latest known state # monitor own state change # detect change of the state # do state related actions when state switch detected # report own state transition # sync backend state with the own one # update latest known state # sleep before next update
self