diff --git a/yagat/frames/impl/static_var_compensator_list_view.py b/yagat/frames/impl/static_var_compensator_list_view.py new file mode 100644 index 0000000..e668228 --- /dev/null +++ b/yagat/frames/impl/static_var_compensator_list_view.py @@ -0,0 +1,48 @@ +# +# Copyright (c) 2024, Damien Jeandemange (https://github.com/jeandemanged) +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# SPDX-License-Identifier: MPL-2.0 +# +import os +import tkinter as tk + +import pandas as pd +import pypowsybl.network as pn + +from yagat.app_context import AppContext +from yagat.frames.impl.base_list_view import BaseListView + + +class StaticVarCompensatorListView(BaseListView): + + def __init__(self, parent, context: AppContext, *args, **kwargs): + BaseListView.__init__(self, parent, context, *args, **kwargs) + + @property + def tab_name(self) -> str: + return 'Static VAR Compensators' + + def get_data_frame(self) -> pd.DataFrame: + return self.context.network_structure.static_var_compensators + + def filter_data_frame(self, df: pd.DataFrame, voltage_levels: list[str]) -> pd.DataFrame: + return df.loc[df['voltage_level_id'].isin(voltage_levels)] + + +if __name__ == "__main__": + + if os.name == 'nt': + # Fixing the blur UI on Windows + from ctypes import windll + + windll.shcore.SetProcessDpiAwareness(2) + root = tk.Tk() + ctx = AppContext(root) + bw = StaticVarCompensatorListView(root, ctx) + bw.pack(fill="both", expand=True) + ctx.network = pn.create_four_substations_node_breaker_network() + ctx.selection = ('network', '', None) + ctx.selected_tab = bw.tab_name + root.mainloop() diff --git a/yagat/frames/impl/tabs_view.py b/yagat/frames/impl/tabs_view.py index e8fcf60..bd3b4b1 100644 --- a/yagat/frames/impl/tabs_view.py +++ b/yagat/frames/impl/tabs_view.py @@ -21,6 +21,7 @@ from yagat.frames.impl.three_windings_transformer_list_view import ThreeWindingsTransformerListView from yagat.frames.impl.dangling_line_list_view import DanglingLineListView from yagat.frames.impl.shunt_compensator_list_view import ShuntCompensatorListView +from yagat.frames.impl.static_var_compensator_list_view import StaticVarCompensatorListView from yagat.networkstructure import BusView @@ -42,6 +43,7 @@ def __init__(self, parent, context: AppContext, *args, **kwargs): self._add_tab(ThreeWindingsTransformerListView(self.tab_control, self.context)) self._add_tab(DanglingLineListView(self.tab_control, self.context)) self._add_tab(ShuntCompensatorListView(self.tab_control, self.context)) + self._add_tab(StaticVarCompensatorListView(self.tab_control, self.context)) self.tab_control.pack(expand=True, fill=tk.BOTH) diff --git a/yagat/networkstructure/impl/network_structure.py b/yagat/networkstructure/impl/network_structure.py index a30e4c2..de961a3 100644 --- a/yagat/networkstructure/impl/network_structure.py +++ b/yagat/networkstructure/impl/network_structure.py @@ -134,6 +134,10 @@ def dangling_lines(self) -> pd.DataFrame: def shunt_compensators(self) -> pd.DataFrame: return self._injections_df[ns.EquipmentType.SHUNT_COMPENSATOR] + @property + def static_var_compensators(self) -> pd.DataFrame: + return self._injections_df[ns.EquipmentType.STATIC_VAR_COMPENSATOR] + @property def three_windings_transformers(self) -> pd.DataFrame: return self._three_windings_transformers_df