2024-06-05 09:11:37 +01:00
|
|
|
# © Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
|
2023-08-03 21:30:13 +01:00
|
|
|
from abc import abstractmethod
|
|
|
|
|
from enum import Enum
|
2023-08-07 19:33:52 +01:00
|
|
|
from typing import Dict
|
2023-08-03 21:30:13 +01:00
|
|
|
|
|
|
|
|
from primaite.simulator.system.software import Software
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ProcessOperatingState(Enum):
|
|
|
|
|
"""Enumeration of Process Operating States."""
|
|
|
|
|
|
|
|
|
|
RUNNING = 1
|
|
|
|
|
"The process is running."
|
|
|
|
|
PAUSED = 2
|
|
|
|
|
"The process is temporarily paused."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Process(Software):
|
|
|
|
|
"""
|
|
|
|
|
Represents a Process, a program in execution, in the simulation environment.
|
|
|
|
|
|
|
|
|
|
Processes are executed by a Node and do not have the ability to performing input/output operations.
|
|
|
|
|
"""
|
2023-08-07 19:33:52 +01:00
|
|
|
|
2023-08-03 21:30:13 +01:00
|
|
|
operating_state: ProcessOperatingState
|
|
|
|
|
"The current operating state of the Process."
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def describe_state(self) -> Dict:
|
|
|
|
|
"""
|
2023-08-17 15:32:12 +01:00
|
|
|
Produce a dictionary describing the current state of this object.
|
2023-08-03 21:30:13 +01:00
|
|
|
|
2023-08-17 15:32:12 +01:00
|
|
|
Please see :py:meth:`primaite.simulator.core.SimComponent.describe_state` for a more detailed explanation.
|
2023-08-03 21:30:13 +01:00
|
|
|
|
2023-08-17 15:32:12 +01:00
|
|
|
:return: Current state of this object and child objects.
|
2023-08-03 21:30:13 +01:00
|
|
|
:rtype: Dict
|
|
|
|
|
"""
|
2023-08-20 18:38:02 +01:00
|
|
|
state = super().describe_state()
|
2023-12-14 11:19:32 +00:00
|
|
|
state.update({"operating_state": self.operating_state.value})
|
2023-08-20 18:38:02 +01:00
|
|
|
return state
|