Skip to content

Commit

Permalink
Merge pull request e2nIEE#1575 from n1kla/feature/pf2pp_fix
Browse files Browse the repository at this point in the history
fixed missing switch names
  • Loading branch information
jkisse authored Apr 26, 2022
2 parents 6cd826b + 7c7356e commit fe8ed21
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions pandapower/converter/powerfactory/pp_import_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,31 +534,32 @@ def import_switch(item, idx_cubicle):
switch_types = {"cbk": "CB", "sdc": "LBS", "swt": "LS", "dct": "DS"}
cub = item.GetCubicle(idx_cubicle)
if cub is None:
return None, None
return None, None, None
switches = cub.GetContents('*.StaSwitch')
if len(switches) > 1:
logger.error('more then 1 switch found for %s: %s' % (item, switches))
if len(switches) != 0:
switch = switches[0]
switch_in_service = not bool(switch.outserv) if switch.HasAttribute('outserv') else True
switch_name = switch.cDisplayName
if not switch.HasAttribute('isclosed'):
logger.warning('switch %s does not have the attribute isclosed!!!' % switch)
switch_is_closed = bool(switch.on_off) and bool(switch.isclosed) and switch_in_service
switch_usage = switch_types.get(switch.aUsage, 'unknown')
return switch_is_closed, switch_usage
return switch_is_closed, switch_usage, switch_name
else:
return None, None
return None, None, None


def create_connection_switches(net, item, number_switches, et, buses, elements):
# False if open, True if closed, None if no switch
logger.debug('creating connection switches')
for i in range(number_switches):
switch_is_closed, switch_usage = import_switch(item, i)
switch_is_closed, switch_usage, switch_name = import_switch(item, i)
logger.debug('switch closed: %s, switch_usage: %s' % (switch_is_closed, switch_usage))
if switch_is_closed is not None:
cd = pp.create_switch(net, bus=buses[i], element=elements[i], et=et,
closed=switch_is_closed, type=switch_usage)
closed=switch_is_closed, type=switch_usage, name=switch_name)
net.res_switch.loc[cd, ['pf_closed', 'pf_in_service']] = switch_is_closed, True


Expand Down Expand Up @@ -998,7 +999,7 @@ def monopolar_in_service(item):
in_service = not bool(item.outserv)

# False if open, True if closed, None if no switch
switch_is_closed, switch_usage = import_switch(item, 0)
switch_is_closed, _ , _ = import_switch(item, 0)
if switch_is_closed is not None:
logger.debug('element in service: <%s>, switch is closed: <%s>' %
(in_service, switch_is_closed))
Expand Down

0 comments on commit fe8ed21

Please sign in to comment.