Source code for symupy.runtime.logic.states

""" 
    This module defines the basic states required to execute and launch a simulation. 

    The states are defined as: 

    * **Compliance**: This state is defined to check availability of files and candidates.
    * **Connect**: This state is defined to process 
    * **Initialize**: This state perform initialization tasks. In example, loading the file scenarios into the simulator. Declaring initial conditions for the platoon, etc. 
    * **Preroutine**: Tasks to be done before the querying information from the simulator
    * **Query**: Tasks of parsing data and querying information from the simulator
    * **Control**: Perform decision tasks for the platoon 
    * **Push**: Push updated information to the simulator for platoon vehicles 
    * **Postroutine**: Performs tasks after the information has been pushed. 
"""

from .base import State


# Start of our states
[docs]class Compliance(State): """ The state which declares an status to check file compliance . """
[docs] def on_event(self, event: str) -> None: if event == "Connect": return Connect() return self
[docs]class Connect(State): """ The state which declares the creation of a connection with the simulator """
[docs] def on_event(self, event: str): if event == "Initialize": return Initialize() return self
[docs]class Initialize(State): """ The state which initializes values for the scenario simulation """
[docs] def on_event(self, event: str): if event == "PreRoutine": return PreRoutine() return self
[docs]class PreRoutine(State): """ The state which performs task previous to the interaction with the simulator """
[docs] def on_event(self, event: str): if event == "Query": return Query() return self
[docs]class Query(State): """ The state which retrieves information from the simulator """
[docs] def on_event(self, event: str): if event == "Control": return Control() return self
[docs]class Control(State): """ The state which computes the control decision """
[docs] def on_event(self, event: str): if event == "Push": return Push() return self
[docs]class Push(State): """ The state which pushes data back to the simulator """
[docs] def on_event(self, event: str): if event == "PostRoutine": return PostRoutine() return self
[docs]class PostRoutine(State): """ The state which logs information or compute step indicators """
[docs] def on_event(self, event: str): if event == "PreRoutine": return PreRoutine() elif event == "Terminate": return Terminate() return self
[docs]class Terminate(State): """ The state which declares the end of a simulation """
[docs] def on_event(self, event: str): return self
# End of our states.