diff --git a/tests/conftest.py b/tests/conftest.py index e04f8a1..8969381 100755 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -34,11 +34,8 @@ from trano.models.constants import Azimuth, Flow, Tilt from trano.models.elements.base import Port, param_from_config from trano.models.elements.boundary import Boundary -from trano.models.elements.controls.ahu import AhuControl -from trano.models.elements.controls.boiler import BoilerControl -from trano.models.elements.controls.collector import CollectorControl -from trano.models.elements.controls.emission import EmissionControl -from trano.models.elements.controls.three_way_valve import ThreeWayValveControl +from trano.models.elements.control import ThreeWayValveControl, EmissionControl, CollectorControl, \ + BoilerControl, AhuControl from trano.models.elements.envelope import ExternalWall, FloorOnGround, InternalElement, Window from trano.models.elements.space import Space from trano.models.elements.system import System, Weather, ThreeWayValve, TemperatureSensor, SplitValve, Radiator, Pump, \ diff --git a/tests/fixtures/house.py b/tests/fixtures/house.py index 5cf2032..97633ae 100644 --- a/tests/fixtures/house.py +++ b/tests/fixtures/house.py @@ -5,9 +5,7 @@ from trano.material import Material from trano.models.constants import Azimuth, Tilt from trano.models.elements.base import param_from_config -from trano.models.elements.controls.collector import CollectorControl -from trano.models.elements.controls.emission import EmissionControl -from trano.models.elements.controls.three_way_valve import ThreeWayValveControl +from trano.models.elements.control import ThreeWayValveControl, EmissionControl, CollectorControl from trano.models.elements.envelope import ExternalDoor, ExternalWall, FloorOnGround, InternalElement, Window from trano.models.elements.space import Space from trano.models.elements.system import Weather, Valve, ThreeWayValve, TemperatureSensor, SplitValve, Radiator, Pump, \ diff --git a/tests/fixtures/spaces_with_emissions.py b/tests/fixtures/spaces_with_emissions.py index 5277c70..f734d1f 100644 --- a/tests/fixtures/spaces_with_emissions.py +++ b/tests/fixtures/spaces_with_emissions.py @@ -1,7 +1,7 @@ from trano.construction import Constructions from trano.glass import Glasses from trano.models.constants import Azimuth, Tilt -from trano.models.elements.controls.emission import EmissionControl +from trano.models.elements.control import EmissionControl from trano.models.elements.envelope import ExternalWall, FloorOnGround, Window from trano.models.elements.space import Space from trano.models.elements.system import Valve, Radiator, Occupancy diff --git a/tests/fixtures/spaces_with_ventilation.py b/tests/fixtures/spaces_with_ventilation.py index 7336dd3..33c0d85 100644 --- a/tests/fixtures/spaces_with_ventilation.py +++ b/tests/fixtures/spaces_with_ventilation.py @@ -1,7 +1,7 @@ from trano.construction import Constructions from trano.glass import Glasses from trano.models.constants import Azimuth, Tilt -from trano.models.elements.controls.vav import VAVControl +from trano.models.elements.control import VAVControl from trano.models.elements.envelope import ExternalWall, FloorOnGround, Window from trano.models.elements.system import Occupancy, Duct, DamperVariant, VAV from trano.models.elements.space import Space diff --git a/trano/data_models/conversion.py b/trano/data_models/conversion.py index b9c3507..a4eb4a9 100644 --- a/trano/data_models/conversion.py +++ b/trano/data_models/conversion.py @@ -15,12 +15,6 @@ from trano.glass import GasLayer, Glass, GlassLayer from trano.material import Gas, GlassMaterial, Material from trano.models.elements.base import param_from_config -from trano.models.elements.controls.boiler import BoilerControl # noqa: F401 -from trano.models.elements.controls.collector import CollectorControl # noqa: F401 -from trano.models.elements.controls.emission import EmissionControl # noqa: F401 -from trano.models.elements.controls.three_way_valve import ( # noqa: F401 - ThreeWayValveControl, -) from trano.models.elements.envelope import ExternalWall, FloorOnGround, Window from trano.models.elements.space import Space from trano.models.elements.system import Weather, Occupancy diff --git a/trano/models/elements/base.py b/trano/models/elements/base.py index b30c3b8..ce2238f 100644 --- a/trano/models/elements/base.py +++ b/trano/models/elements/base.py @@ -256,7 +256,6 @@ def validate_targets( # noqa: PLR0915, PLR0912, C901 targets.append(DataBus) elif value == "Control": - from trano.models.elements.controls.base import Control targets.append(Control) elif value == "Space": @@ -270,7 +269,7 @@ def validate_targets( # noqa: PLR0915, PLR0912, C901 targets.append(System) elif value == "AhuControl": - from trano.models.elements.controls.ahu import AhuControl + from trano.models.elements.control import AhuControl targets.append(AhuControl) elif value == "BaseWeather": @@ -298,7 +297,7 @@ def validate_targets( # noqa: PLR0915, PLR0912, C901 targets.append(Emission) elif value == "VAVControl": - from trano.models.elements.controls.vav import VAVControl + from trano.models.elements.control import VAVControl targets.append(VAVControl) elif value == "BaseWall": @@ -327,7 +326,6 @@ def is_available(self) -> bool: return self.multi_connection or self.available def is_controllable(self) -> bool: - from trano.models.elements.controls.base import Control return self.targets is not None and any( target == Control for target in self.targets @@ -758,3 +756,9 @@ class LibraryData(BaseModel): class BaseBoundary(BaseElement): ... + + +class Control(BaseElement): + position: Optional[List[float]] = None + controllable_element: Optional[BaseElement] = None + space_name: Optional[str] = None diff --git a/trano/models/elements/controls/ahu.py b/trano/models/elements/control.py similarity index 55% rename from trano/models/elements/controls/ahu.py rename to trano/models/elements/control.py index eb6da55..2b83b2a 100644 --- a/trano/models/elements/controls/ahu.py +++ b/trano/models/elements/control.py @@ -2,9 +2,33 @@ from pydantic import computed_field -from trano.models.elements.controls.base import Control -from trano.models.elements.system import VAV +from trano.models.elements.base import BaseElement, BaseParameter, Control from trano.models.elements.space import Space +from trano.models.elements.system import Valve, VAV + + +class ControlParameters(BaseParameter): + ... + + +class VAVControl(Control): + ahu: Optional[BaseElement] = None + + +class ThreeWayValveControl(Control): + ... + + +class EmissionControl(Control): + ... + + +class CollectorControl(Control): + valves: Optional[List[Valve]] = None + + +class BoilerControl(Control): + ... class AhuControl(Control): diff --git a/trano/models/elements/controls/__init__.py b/trano/models/elements/controls/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/trano/models/elements/controls/base.py b/trano/models/elements/controls/base.py deleted file mode 100644 index 1eda5f6..0000000 --- a/trano/models/elements/controls/base.py +++ /dev/null @@ -1,14 +0,0 @@ -from typing import List, Optional - -from trano.models.elements.base import BaseElement, BaseParameter - - -class Control(BaseElement): - position: Optional[List[float]] = None - controllable_element: Optional[BaseElement] = None - space_name: Optional[str] = None - - -class ControlParameters(BaseParameter): - ... - diff --git a/trano/models/elements/controls/boiler.py b/trano/models/elements/controls/boiler.py deleted file mode 100644 index 8aa02d9..0000000 --- a/trano/models/elements/controls/boiler.py +++ /dev/null @@ -1,5 +0,0 @@ -from trano.models.elements.controls.base import Control - - -class BoilerControl(Control): - ... diff --git a/trano/models/elements/controls/collector.py b/trano/models/elements/controls/collector.py deleted file mode 100644 index 486e429..0000000 --- a/trano/models/elements/controls/collector.py +++ /dev/null @@ -1,8 +0,0 @@ -from typing import List, Optional - -from trano.models.elements.controls.base import Control -from trano.models.elements.system import Valve - - -class CollectorControl(Control): - valves: Optional[List[Valve]] = None diff --git a/trano/models/elements/controls/emission.py b/trano/models/elements/controls/emission.py deleted file mode 100644 index 3f2bd78..0000000 --- a/trano/models/elements/controls/emission.py +++ /dev/null @@ -1,5 +0,0 @@ -from trano.models.elements.controls.base import Control - - -class EmissionControl(Control): - ... diff --git a/trano/models/elements/controls/three_way_valve.py b/trano/models/elements/controls/three_way_valve.py deleted file mode 100644 index 15ad6d9..0000000 --- a/trano/models/elements/controls/three_way_valve.py +++ /dev/null @@ -1,5 +0,0 @@ -from trano.models.elements.controls.base import Control - - -class ThreeWayValveControl(Control): - ... diff --git a/trano/models/elements/controls/vav.py b/trano/models/elements/controls/vav.py deleted file mode 100644 index 0a6cee4..0000000 --- a/trano/models/elements/controls/vav.py +++ /dev/null @@ -1,10 +0,0 @@ -from typing import Optional - -from trano.models.elements.base import ( - BaseElement, -) -from trano.models.elements.controls.base import Control - - -class VAVControl(Control): - ahu: Optional[BaseElement] = None diff --git a/trano/models/elements/system.py b/trano/models/elements/system.py index e83b395..c333d9f 100644 --- a/trano/models/elements/system.py +++ b/trano/models/elements/system.py @@ -1,12 +1,11 @@ -from typing import List, Optional +from typing import List, Optional, TYPE_CHECKING -from trano.models.elements.base import BaseElement, BaseVariant -from trano.models.elements.controls.base import Control +from trano.models.elements.base import BaseElement, BaseVariant, Control class System(BaseElement): position: Optional[List[float]] = None - control: Optional["Control"] = None + control: Optional[Control] = None class Sensor(System): diff --git a/trano/topology.py b/trano/topology.py index 887ea0c..80190f0 100644 --- a/trano/topology.py +++ b/trano/topology.py @@ -21,13 +21,10 @@ BaseElement, Connection, DynamicTemplateCategories, - connect, + connect, Control, ) from trano.models.elements.bus import DataBus -from trano.models.elements.controls.ahu import AhuControl -from trano.models.elements.controls.base import Control -from trano.models.elements.controls.collector import CollectorControl -from trano.models.elements.controls.vav import VAVControl +from trano.models.elements.control import VAVControl, CollectorControl, AhuControl from trano.models.elements.envelope import InternalElement from trano.models.elements.materials.properties import extract_properties from trano.models.elements.space import Space, _get_controllable_element