diff --git a/src/omotes_simulator_core/adapter/transforms/esdl_asset_mapper.py b/src/omotes_simulator_core/adapter/transforms/esdl_asset_mapper.py
index 251c470a..19cabc48 100644
--- a/src/omotes_simulator_core/adapter/transforms/esdl_asset_mapper.py
+++ b/src/omotes_simulator_core/adapter/transforms/esdl_asset_mapper.py
@@ -14,13 +14,12 @@
# along with this program. If not, see .
"""Module containing the Esdl to asset mapper class."""
-from typing import Any, Type
+from typing import Type
import esdl
import numpy as np
from omotes_simulator_core.entities.assets.asset_abstract import AssetAbstract
-from omotes_simulator_core.entities.assets.demand_cluster import DemandCluster
from omotes_simulator_core.entities.assets.esdl_asset_object import EsdlAssetObject
from omotes_simulator_core.entities.assets.production_cluster import ProductionCluster
from omotes_simulator_core.entities.assets.ates_cluster import AtesCluster
@@ -29,26 +28,28 @@
from omotes_simulator_core.entities.assets.controller.controller_consumer import ControllerConsumer
from omotes_simulator_core.entities.assets.controller.controller_storage import ControllerStorage
from omotes_simulator_core.simulation.mappers.mappers import EsdlMapperAbstract, Entity
+from omotes_simulator_core.adapter.transforms.esdl_asset_mappers.consumer_mapper import (
+ EsdlAssetConsumerMapper,
+)
from omotes_simulator_core.adapter.transforms.esdl_asset_mappers.heat_pump_mapper import (
EsdlAssetHeatPumpMapper,
)
-
-
from omotes_simulator_core.adapter.transforms.esdl_asset_mappers.pipe_mapper import (
EsdlAssetPipeMapper,
)
+
CONVERSION_DICT: dict[type, Type[AssetAbstract]] = {
esdl.Producer: ProductionCluster,
esdl.GenericProducer: ProductionCluster,
- esdl.Consumer: DemandCluster,
- esdl.GenericConsumer: DemandCluster,
- esdl.HeatingDemand: DemandCluster,
esdl.ATES: AtesCluster,
}
# Define the conversion dictionary
conversion_dict_mappers: dict[type, Type[EsdlMapperAbstract]] = {
+ esdl.Consumer: EsdlAssetConsumerMapper,
+ esdl.GenericConsumer: EsdlAssetConsumerMapper,
+ esdl.HeatingDemand: EsdlAssetConsumerMapper,
esdl.Pipe: EsdlAssetPipeMapper,
esdl.HeatPump: EsdlAssetHeatPumpMapper,
}
@@ -58,7 +59,7 @@ class EsdlAssetMapper:
"""Creates entity Asset objects based on a PyESDL EnergySystem assets."""
@staticmethod
- def to_esdl(entity: AssetAbstract) -> Any:
+ def to_esdl(entity: AssetAbstract) -> EsdlAssetObject:
"""Maps entity object to PyEsdl objects."""
raise NotImplementedError("EsdlAssetMapper.to_esdl()")
diff --git a/src/omotes_simulator_core/adapter/transforms/esdl_asset_mappers/consumer_mapper.py b/src/omotes_simulator_core/adapter/transforms/esdl_asset_mappers/consumer_mapper.py
new file mode 100644
index 00000000..be90fe96
--- /dev/null
+++ b/src/omotes_simulator_core/adapter/transforms/esdl_asset_mappers/consumer_mapper.py
@@ -0,0 +1,42 @@
+# Copyright (c) 2023. Deltares & TNO
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+"""Module containing the Esdl to Consumer asset mapper class."""
+
+from omotes_simulator_core.entities.assets.demand_cluster import DemandCluster
+from omotes_simulator_core.entities.assets.asset_abstract import AssetAbstract
+from omotes_simulator_core.entities.assets.esdl_asset_object import EsdlAssetObject
+from omotes_simulator_core.simulation.mappers.mappers import EsdlMapperAbstract
+
+
+class EsdlAssetConsumerMapper(EsdlMapperAbstract):
+ """Class to map an ESDL asset to a consumer entity class."""
+
+ def to_esdl(self, entity: DemandCluster) -> EsdlAssetObject:
+ """Map a Consumer entity to an EsdlAsset."""
+ raise NotImplementedError("EsdlAssetConsumerMapper.to_esdl()")
+
+ def to_entity(self, esdl_asset: EsdlAssetObject) -> AssetAbstract:
+ """Method to map an ESDL asset to a consumer entity class.
+
+ :param EsdlAssetObject esdl_asset: Object to be converted to a consumer entity.
+ :return: Consumer object.
+ """
+ consumer_entity = DemandCluster(
+ asset_name=esdl_asset.esdl_asset.name,
+ asset_id=esdl_asset.esdl_asset.id,
+ port_ids=esdl_asset.get_port_ids(),
+ )
+
+ return consumer_entity
diff --git a/unit_test/adapters/transforms/esdl_asset_mappers/test_esdl_asset_consumer_mapper.py b/unit_test/adapters/transforms/esdl_asset_mappers/test_esdl_asset_consumer_mapper.py
new file mode 100644
index 00000000..b56d87a3
--- /dev/null
+++ b/unit_test/adapters/transforms/esdl_asset_mappers/test_esdl_asset_consumer_mapper.py
@@ -0,0 +1,51 @@
+# Copyright (c) 2023. Deltares & TNO
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+"""Test consumer mapper."""
+
+import unittest
+from pathlib import Path
+
+from omotes_simulator_core.adapter.transforms.esdl_asset_mappers.consumer_mapper import (
+ EsdlAssetConsumerMapper,
+)
+from omotes_simulator_core.entities.esdl_object import EsdlObject
+from omotes_simulator_core.infrastructure.utils import pyesdl_from_file
+
+
+class TestEsdlAssetConsumerMapper(unittest.TestCase):
+ """Test class for consumer mapper."""
+
+ def setUp(self) -> None:
+ """Set up test case."""
+ esdl_file_path = (
+ Path(__file__).parent / ".." / ".." / ".." / ".." / "testdata" / "test1.esdl"
+ )
+ self.esdl_object = EsdlObject(pyesdl_from_file(esdl_file_path))
+ self.mapper = EsdlAssetConsumerMapper()
+
+ def test_to_entity_method(self):
+ """Test for to_entity method."""
+ # Arrange
+ consumers = self.esdl_object.get_all_assets_of_type("consumer")
+ esdl_asset = consumers[0]
+
+ # Act
+ consumer_entity = self.mapper.to_entity(esdl_asset)
+
+ # Assert
+ self.assertEqual(consumer_entity.name, esdl_asset.esdl_asset.name)
+ self.assertEqual(consumer_entity.asset_id, esdl_asset.esdl_asset.id)
+ self.assertEqual(consumer_entity.connected_ports, esdl_asset.get_port_ids())