Skip to content

Home Information - Your home, your data, organized.

Python

Reviewed and updated docs/comments after more recent refactorings.

Anthony Cassandra4cb58b5a2209
diff --git a/src/hi/simulator/base_models.py b/src/hi/simulator/base_models.py
index 2f9356e5..269fad6d 100644
--- a/src/hi/simulator/base_models.py
+++ b/src/hi/simulator/base_models.py
@@ -78,6 +78,8 @@ class SimState:
more SimState subclasses. SimState classes are provided via the
SimEntityDefinition and will be initialized with the containing
entities fields and values by the SimulatorManager.
+
+ SimState definitions and instances are not persisted in the database.
"""
sim_entity_fields : SimEntityFields # Will be provided by SimulatorManager when creating instances.
entity_state_type : EntityStateType # Subclasses should provide a default value for this.
diff --git a/src/hi/simulator/enums.py b/src/hi/simulator/enums.py
deleted file mode 100644
index 15379ca2..00000000
--- a/src/hi/simulator/enums.py
+++ /dev/null
@@ -1,2 +0,0 @@
-from hi.apps.common.enums import LabeledEnum
-
diff --git a/src/hi/simulator/forms.py b/src/hi/simulator/forms.py
index 7bee7688..dedf65d0 100644
--- a/src/hi/simulator/forms.py
+++ b/src/hi/simulator/forms.py
@@ -19,7 +19,7 @@ class SimProfileForm( forms.ModelForm ):
class SimEntityFieldsForm( forms.Form ):
"""
- Dynamically build a Django form from a subclass of SimEntity.
+ Dynamically build a Django form from a subclass of SimEntityFields.
"""
DATA_TYPE_TO_FORM_FIELD = {
diff --git a/src/hi/simulator/sim_entity.py b/src/hi/simulator/sim_entity.py
index 45d753d2..f5e0c5d8 100644
--- a/src/hi/simulator/sim_entity.py
+++ b/src/hi/simulator/sim_entity.py
@@ -9,9 +9,9 @@ from .base_models import SimEntityDefinition, SimEntityFields, SimState
class SimEntity:
"""
These are the run-time instances created and managed by the
- SimulatorManager. They are the user-defined simulator entities chosen
- from the provided SimEntityDefinition instances to define the run-time
- configuration of the simulator.
+ SimulatorManager and Simulator classes. These are the simulator
+ entities chosen by the user from the provided SimEntityDefinition
+ instances to define the run-time configuration of the simulator.
"""
db_sim_entity : DbSimEntity
sim_entity_definition : SimEntityDefinition
diff --git a/src/hi/simulator/simulator.py b/src/hi/simulator/simulator.py
index 1404f76d..b21e706c 100644
--- a/src/hi/simulator/simulator.py
+++ b/src/hi/simulator/simulator.py
@@ -7,9 +7,17 @@ from .sim_entity import SimEntity
class Simulator( Singleton ):
-
+ """
+ The class that each simulator should subclass and include in a
+ simulator.py file in its app directory. This is how the
+ SimulatorManager discovers the types of simulator entities and states
+ provided by the simulator. This is also used by the simulators to get
+ the current satte of which entities, states and state values currently
+ are defined.
+ """
+
def __init_singleton__( self ):
- self._sim_entity_map : Dict[ id, SimEntity ] = dict()
+ self._initialize()
return
@property
@@ -42,7 +50,7 @@ class Simulator( Singleton ):
occur at start up and if/when the simulation profile changes
(requiring a new list of SimEntity instances).
"""
- self._sim_entity_map = dict()
+ self._sim_entity_map : Dict[ id, SimEntity ] = dict()
return
def validate_sim_entity( self, sim_entity : SimEntity ):
diff --git a/src/hi/simulator/simulator_data.py b/src/hi/simulator/simulator_data.py
index ed696b4b..95afb843 100644
--- a/src/hi/simulator/simulator_data.py
+++ b/src/hi/simulator/simulator_data.py
@@ -3,7 +3,6 @@ from typing import Dict, List
from .base_models import SimEntityDefinition
from .simulator import Simulator
-from .sim_entity import SimEntity
@dataclass
@@ -11,4 +10,3 @@ class SimulatorData:
simulator : Simulator
sim_entity_definition_map : Dict[ str , SimEntityDefinition ] = field( default_factory = dict )
- sim_entity_instance_list : List[ SimEntity ] = field( default_factory = list )