:py:mod:`ethos_penalps.process_state_handler`
=============================================

.. py:module:: ethos_penalps.process_state_handler


Module Contents
---------------

Classes
~~~~~~~

.. autoapisummary::

   ethos_penalps.process_state_handler.ProcessStateHandler




Attributes
~~~~~~~~~~

.. autoapisummary::

   ethos_penalps.process_state_handler.logger


.. py:data:: logger

   

.. py:class:: ProcessStateHandler(process_step_data: ethos_penalps.process_step_data.ProcessStepData)


   The ProcessStateHandler contains all objects necessary to switch the process states of a process step.
   Its core functionality is to switch between Idle, InputRequestingProcessStates, OutputProvidingProcessStates.
   In order to switch from the current process state the process_state_switch_selector_handler is required.
   It determines which process_state_switch is conducted. This allows multi path routes in a network of process states.
   The process state switch determines the next process state and the switch time of the process state.
   The process_state_dictionary must contain an idle, input requesting and output providing process state.

   .. py:method:: switch_to_output_stream_providing_state(activation_date: datetime.datetime) -> ethos_penalps.process_state.OutputStreamProvidingState


   .. py:method:: switch_to_input_stream_requesting_state(force_first_switch: bool = False) -> ethos_penalps.process_state.InputStreamProvidingState


   .. py:method:: switch_to_idle_state() -> ethos_penalps.process_state.ProcessStateIdle


   .. py:method:: check_if_multiple_target_states_are_possible()


   .. py:method:: get_earliest_output_stream_production_time() -> datetime.datetime


   .. py:method:: switch_to_previous_state() -> ethos_penalps.process_state.ProcessState

      1.Determines which process state switch should be applied from the current state.
      2. Determines the next switch time.
      3. Sets end time off current state and stores state to process_entry_dict
      4. Sets start time for next process state

      :raises Exception: _description_
      :return: _description_
      :rtype: ProcessState


   .. py:method:: activate_state(state_name_to_activate: str, time_to_activate: datetime.datetime) -> ethos_penalps.process_state.ProcessState


   .. py:method:: deactivate_state(state_name_to_deactivate: str, time_to_deactivate: datetime.datetime)

      Deactivates the current state at time_to_deactivate provided. It is assumed that
      the state to be deactivated has already an end_time. Time to deactivate is then set
      and the state is stored to process state list.

      :param state_name_to_deactivate: _description_
      :type state_name_to_deactivate: str
      :param time_to_deactivate: _description_
      :type time_to_deactivate: datetime.datetime
      :raises Exception: _description_


   .. py:method:: restore_process_step_data(time_data_at_start: ethos_penalps.time_data.TimeData, simulation_state_data_at_start: ethos_penalps.simulation_data.container_simulation_data.CurrentProductionStateData, branch_data_at_start: ethos_penalps.simulation_data.container_branch_data.OutputBranchData)

      Restores the state of the process step data from another process step data.

      :param time_data_at_start: _description_
      :type time_data_at_start: TimeData
      :param simulation_state_data_at_start: _description_
      :type simulation_state_data_at_start: CurrentProductionStateData


   .. py:method:: prepare_for_new_production_branch(new_output_stream_state: ethos_penalps.stream.ContinuousStreamState | ethos_penalps.stream.BatchStreamState, incomplete_output_branch_data: ethos_penalps.simulation_data.container_branch_data.IncompleteOutputBranchData)

      Resets some values for a new Production Branch

      :param new_output_stream_state: _description_
      :type new_output_stream_state: ContinuousStreamState | BatchStreamState
      :raises Exception: _description_


   .. py:method:: check_if_input_and_output_stream_occur_in_same_state() -> bool


   .. py:method:: get_output_stream_providing_state_name() -> str


   .. py:method:: get_process_state(process_state_name: str) -> ethos_penalps.process_state.ProcessState


   .. py:method:: add_process_state(process_state: ethos_penalps.process_state.ProcessState, add_as_current_state: bool = False)


   .. py:method:: store_current_state_to_process_state_list() -> ethos_penalps.data_classes.ProcessStepProductionPlanEntry


   .. py:method:: create_state_for_parallel_input_and_output_stream_with_storage(process_state_name: str, add_as_current_state: bool = False) -> ethos_penalps.process_state.ProcessStateParallelContinuousInputWithStorage


   .. py:method:: create_continuous_output_stream_providing_state(process_state_name: str) -> ethos_penalps.process_state.ContinuousOutputStreamProvidingState


   .. py:method:: create_batch_output_stream_providing_state(process_state_name: str) -> ethos_penalps.process_state.BatchOutputStreamProvidingState


   .. py:method:: create_continuous_input_stream_requesting_state(process_state_name: str) -> ethos_penalps.process_state.ContinuousInputStreamRequestingStateWithStorage


   .. py:method:: create_output_stream_providing_state_from_storage(process_state_name: str, maximum_stream_mass: float | None = None) -> ethos_penalps.process_state.OutputStreamFromStorageState


   .. py:method:: create_batch_input_stream_requesting_state(process_state_name: str) -> ethos_penalps.process_state.BatchInputStreamRequestingStateWithStorage


   .. py:method:: create_full_batch_input_stream_requesting_state(process_state_name: str) -> ethos_penalps.process_state.FullBatchInputStreamProvidingState


   .. py:method:: create_batch_input_stream_requesting_state_energy_based_on_stream_mass(process_state_name: str) -> ethos_penalps.process_state.BatchInputStreamRequestingStateWithStorageEnergyBasedOnStream


   .. py:method:: create_idle_process_state(process_state_name: str, add_as_current_state: bool = True) -> ethos_penalps.process_state.ProcessStateIdle


   .. py:method:: create_intermediate_process_state(process_state_name: str) -> ethos_penalps.process_state.IntermediateState


   .. py:method:: create_intermediate_process_state_energy_based_on_stream_mass(process_state_name: str)


   .. py:method:: get_output_stream_providing_state() -> ethos_penalps.process_state.OutputStreamProvidingState


   .. py:method:: get_input_stream_providing_state() -> ethos_penalps.process_state.InputStreamProvidingState


   .. py:method:: get_idle_state() -> ethos_penalps.process_state.ProcessStateIdle



