Describe state
This commit is contained in:
@@ -1,20 +1,23 @@
|
||||
from typing import Dict
|
||||
|
||||
from primaite.simulator.core import Action, ActionManager, AllowAllValidator, SimComponent
|
||||
from primaite.simulator.domain.controller import DomainController
|
||||
from primaite.simulator.network.container import NetworkContainer
|
||||
|
||||
|
||||
class __TempNetwork:
|
||||
class Simulation(SimComponent):
|
||||
"""TODO."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class SimulationContainer(SimComponent):
|
||||
"""TODO."""
|
||||
|
||||
network: __TempNetwork
|
||||
network: NetworkContainer
|
||||
domain: DomainController
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
if not kwargs.get("network"):
|
||||
kwargs["network"] = NetworkContainer()
|
||||
|
||||
if not kwargs.get("domain"):
|
||||
kwargs["domain"] = DomainController()
|
||||
|
||||
super().__init__(**kwargs)
|
||||
|
||||
self.action_manager = ActionManager()
|
||||
@@ -32,3 +35,21 @@ class SimulationContainer(SimComponent):
|
||||
func=lambda request, context: self.domain.apply_action(request, context), validator=AllowAllValidator()
|
||||
),
|
||||
)
|
||||
|
||||
def describe_state(self) -> Dict:
|
||||
"""
|
||||
Produce a dictionary describing the current state of this object.
|
||||
|
||||
Please see :py:meth:`primaite.simulator.core.SimComponent.describe_state` for a more detailed explanation.
|
||||
|
||||
:return: Current state of this object and child objects.
|
||||
:rtype: Dict
|
||||
"""
|
||||
state = super().describe_state()
|
||||
state.update(
|
||||
{
|
||||
"network": self.network.describe_state(),
|
||||
"domain": self.domain.describe_state(),
|
||||
}
|
||||
)
|
||||
return state
|
||||
|
||||
Reference in New Issue
Block a user