Coverage for backend/common/config_generator.py: 100%
16 statements
« prev ^ index » next coverage.py v7.10.7, created at 2025-11-06 23:27 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2025-11-06 23:27 +0000
1from common.config_types import *
2from common.config_utils import *
5def generate_config(config_name, ports, properties, property_set_groups, property_package_ports, key_properties):
7 # Define the ports for a turbine:
8 inlet = PortType(displayName="Inlet", type = ConType.Inlet, streamType="stream", streamName="S")
9 outlet = PortType(displayName="Outlet", type = ConType.Outlet, streamType="stream", streamName="S")
10 power_outlet = PortType(displayName="Power Stream", type = ConType.Outlet, streamType="energy_stream", makeStream=False)
11 port_list = [("inlet",inlet),("outlet",outlet),("power_outlet",power_outlet)]
12 turbine_ports = dict(port_list)
14 if property_package_ports is None:
15 _propertypackageports = default_property_package_ports()
16 else:
17 _propertypackageports = property_package_ports
19 # Set the properties for turbine:
20 if "Turbine" in config_name:
21 # Create the config object:
22 config = ObjectType(displayType=config_name, displayName=config_name, ports=turbine_ports,
23 propertyPackagePorts=default_property_package_ports(),
24 graphicObject= unitop_graphic(), properties=PropertiesType(properties),
25 propertySetGroups=dict(property_set_groups), keyProperties=key_properties)
26 return config
28 else:
29 # If the config is being generated for a non-turbine, use the argument parameters:
30 config = ObjectType(displayType=config_name, displayName=config_name, ports=ports,
31 propertyPackagePorts=_propertypackageports,
32 graphicObject= unitop_graphic(), properties=PropertiesType(properties),
33 propertySetGroups=dict(property_set_groups), keyProperties=key_properties)
34 return config