Skip to content

Commit

Permalink
Created the AnyLineTemplateDevice type to properly handle multiple te…
Browse files Browse the repository at this point in the history
…mplate types
  • Loading branch information
SanPen committed Oct 7, 2024
1 parent e6312cd commit 23974c3
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 31 deletions.
37 changes: 9 additions & 28 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/GridCal/Gui/Main/SubClasses/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,12 @@ def open_file_now(self, filenames: Union[str, List[str]],
:return: Nothing
"""
if len(filenames) > 0:

for fname in filenames:
if not os.path.exists(fname):
error_msg(text=f"The file does not exists :(\n{fname}", title="File opening")
return

self.file_name = filenames[0]

# store the working directory
Expand Down
2 changes: 1 addition & 1 deletion src/GridCalEngine/Devices/Branches/dc_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def __init__(self,
self.register(key='fault_pos', units='p.u.', tpe=float,
definition='Per-unit positioning of the fault:0 would be at the "from" side,1 would '
'be at the "to" side,therefore 0.5 is at the middle.')
self.register(key='template', units='', tpe=DeviceType.SequenceLineDevice, definition='', editable=False)
self.register(key='template', units='', tpe=DeviceType.AnyLineTemplateDevice, definition='', editable=False)

self.register(key='locations', units='', tpe=SubObjectType.LineLocations, definition='', editable=False)

Expand Down
2 changes: 1 addition & 1 deletion src/GridCalEngine/Devices/Branches/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def __init__(self, bus_from: Bus = None, bus_to: Bus = None, cn_from: Connectivi
'0 would be at the "from" side,'
'1 would be at the "to" side,'
'therefore 0.5 is at the middle.')
self.register(key='template', units='', tpe=DeviceType.SequenceLineDevice, definition='', editable=False)
self.register(key='template', units='', tpe=DeviceType.AnyLineTemplateDevice, definition='', editable=False)
self.register(key='locations', units='', tpe=SubObjectType.LineLocations, definition='', editable=False)

self.register(key='possible_tower_types', units='', tpe=SubObjectType.Associations,
Expand Down
2 changes: 1 addition & 1 deletion src/GridCalEngine/IO/gridcal/pack_unpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ def parse_object_type_from_json(template_elm: ALL_DEV_TYPES,

if isinstance(gc_prop.tpe, DeviceType):

if isinstance(elm, dev.Line) and gc_prop.name == "template":
if gc_prop.tpe == DeviceType.AnyLineTemplateDevice:
# this is an exception, when dealing with line templates we need to look for
# several types, not only one
seq_templates = elements_dict_by_type.get(DeviceType.OverheadLineTypeDevice, dict())
Expand Down
1 change: 1 addition & 0 deletions src/GridCalEngine/enumerations.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,7 @@ class DeviceType(Enum):
SequenceLineDevice = 'Sequence line'
UnderGroundLineDevice = 'Underground line'
OverheadLineTypeDevice = 'Tower'
AnyLineTemplateDevice = "Any line template"
TransformerTypeDevice = 'Transformer type'
SwitchDevice = 'Switch'

Expand Down

0 comments on commit 23974c3

Please sign in to comment.