Skip to content

Commit

Permalink
fix: remove legacy code: moved control.py.
Browse files Browse the repository at this point in the history
  • Loading branch information
andoludo committed Aug 29, 2024
1 parent 2b8ab8a commit c6e07d4
Show file tree
Hide file tree
Showing 16 changed files with 44 additions and 78 deletions.
7 changes: 2 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand Down
4 changes: 1 addition & 3 deletions tests/fixtures/house.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/spaces_with_emissions.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/spaces_with_ventilation.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 0 additions & 6 deletions trano/data_models/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions trano/models/elements/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -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":
Expand Down Expand Up @@ -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":
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Empty file.
14 changes: 0 additions & 14 deletions trano/models/elements/controls/base.py

This file was deleted.

5 changes: 0 additions & 5 deletions trano/models/elements/controls/boiler.py

This file was deleted.

8 changes: 0 additions & 8 deletions trano/models/elements/controls/collector.py

This file was deleted.

5 changes: 0 additions & 5 deletions trano/models/elements/controls/emission.py

This file was deleted.

5 changes: 0 additions & 5 deletions trano/models/elements/controls/three_way_valve.py

This file was deleted.

10 changes: 0 additions & 10 deletions trano/models/elements/controls/vav.py

This file was deleted.

7 changes: 3 additions & 4 deletions trano/models/elements/system.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
7 changes: 2 additions & 5 deletions trano/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c6e07d4

Please sign in to comment.