11# -*- coding: utf-8 -*-
22from altdss import altdss
33
4+ from pygridsim .configs import NAME_TO_CONFIG
45from pygridsim .lines import _make_line
56from pygridsim .parameters import _make_generator , _make_load_node , _make_pv , _make_source_node
67from pygridsim .results import _export_results , _query_solution
@@ -16,17 +17,16 @@ def __init__(self):
1617 Stores numbers of circuit components to ensure unique naming of repeat circuit components.
1718
1819 Attributes:
19- num_loads (int): Number of loads in circuit so far.
20- num_lines (int): Number of lines in circuit so far.
21- num_transformers (int): Number of transformers in circuit so far.
22- num_pv (int): Number of PV systems in circuit so far.
23- num_generators (int): Number generators in circuit so far.
20+ num_generators (int): Number of generators created so far.
21+ num_lines (int): Number of lines created so far.
22+ num_loads (int): Number of load nodes created so far.
23+ num_pv (int): Number of PVSystems create so far.
2424 """
25- self .num_loads = 0
25+ self .num_generators = 0
2626 self .num_lines = 0
27- self .num_transformers = 0
27+ self .num_loads = 0
2828 self .num_pv = 0
29- self . num_generators = 0
29+
3030 altdss .ClearAll ()
3131 altdss ('new circuit.MyCircuit' )
3232
@@ -52,6 +52,7 @@ def add_load_nodes(self,
5252 list[OpenDSS object]:
5353 A list of OpenDSS objects representing the load nodes created.
5454 """
55+
5556 params = params or dict ()
5657 load_nodes = []
5758 for _ in range (num ):
@@ -206,6 +207,37 @@ def clear(self):
206207 None
207208 """
208209 altdss .ClearAll ()
209- self .num_loads = 0
210- self .num_lines = 0
211- self .num_transformers = 0
210+
211+ def get_types (self , component : str , show_ranges : bool = False ):
212+ """Provides list of all supported Load Types
213+
214+ Args:
215+ component (str):
216+ Which component to get, one of (one of "load", "source", "pv", "line")
217+ show_ranges (bool, optional):
218+ Whether to show all configuration ranges in output.
219+
220+ Returns:
221+ list:
222+ A list containing all load types, if show_ranges False.
223+ A list of tuples showing all load types and configurations, if show_ranges True.
224+ """
225+ component_simplified = component .lower ().replace (" " , "" )
226+ if (component_simplified [- 1 ] == "s" ):
227+ component_simplified = component_simplified [:- 1 ]
228+ configuration = {}
229+ if component_simplified in NAME_TO_CONFIG :
230+ configuration = NAME_TO_CONFIG [component_simplified ]
231+ else :
232+ raise KeyError (
233+ f"Invalid component input: expect one of { [name for name in NAME_TO_CONFIG ]} " )
234+
235+ if not show_ranges :
236+ return [component_type .value for component_type in configuration ]
237+
238+ component_types = []
239+ for component_type in configuration :
240+ config_dict = configuration [component_type ]
241+ component_types .append ((component_type .value , config_dict ))
242+
243+ return component_types
0 commit comments