From 1100401b3fc98e8dfd9c224ae88476320ed33bcf Mon Sep 17 00:00:00 2001 From: jeandemanged Date: Sun, 17 Nov 2024 22:27:59 +0100 Subject: [PATCH] Add File | Save network (#14) Signed-off-by: Damien Jeandemange --- README.md | 25 ++++++++++++------------- yagat/menus/impl/file.py | 17 ++++++++++++++--- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index ff0fb38..7b0e250 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,11 @@ YAGAT provides a graphical user interface built on top of the [PowSyBl](https://www.powsybl.org) open source grid analysis libraries. -With YAGAT no computer science skill is required: just download the application and run it. +With YAGAT, no programming skills are required: just download, unzip, and run – you're all set! Today with YAGAT you can: - Load grid models from the various formats supported by [PowSyBl](https://www.powsybl.org): + - PowSyBl native iIDM format - CIM/CGMES - UCTE-DEF - IEEE-CDF @@ -25,13 +26,20 @@ Today with YAGAT you can: ## Installation -### Binary releases - Binary releases are provided for Windows, Linux and macOS on the [releases page](https://github.com/jeandemanged/yagat/releases). No additional software is required for installation. Download and extract the zip archive for your platform, then run YAGAT. -### Building from source +## Quick Start + +- **Open a sample network**: Go to `File` | `Open Sample network` | `IEEE 9 Bus` to load a sample grid model. +- **Navigate the grid**: Use the tree view on the left to browse through the network model and its elements. +- **Run the Load Flow**: Select `Run` | `Load Flow` to execute the analysis. + - Once completed, review the solved bus voltages and branch flows. + +![yagat quickstart](https://github.com/user-attachments/assets/a5ef2a20-13a8-44f5-b927-8d090d173d73) + +## Building from source With Python 3.12 and e.g. using a Virtual Environment and `pip`. @@ -55,15 +63,6 @@ pyinstaller -y yagat.spec YAGAT is then available for your platform in the `dist` directory. -## Quick Start - -- **Open a sample network**: Go to `File` | `Open Sample network` | `IEEE 9 Bus` to load a sample grid model. -- **Navigate the grid**: Use the tree view on the left to browse through the network model and its elements. -- **Run the Load Flow**: Select `Run` | `Load Flow` to execute the analysis. - - Once completed, view the solved bus voltages and branch flows for insights into the grid's state. - -![yagat quickstart](https://github.com/user-attachments/assets/57aad269-4e02-4a34-aba7-2c7906ab0e26) - ## Roadmap YAGAT today lacks many features, but you may already find it useful. What is planned for the future is: diff --git a/yagat/menus/impl/file.py b/yagat/menus/impl/file.py index f22e32b..b86a01b 100644 --- a/yagat/menus/impl/file.py +++ b/yagat/menus/impl/file.py @@ -14,7 +14,6 @@ from yagat.app_context import AppContext - class FileMenu(tk.Menu): def __init__(self, parent, context: AppContext, *args, **kwargs): tk.Menu.__init__(self, parent, *args, **kwargs) @@ -43,7 +42,6 @@ def load_be_nl(): context.network = be context.status_text = 'Network CGMES MicroGrid BE+NL loaded' - self.sample_networks_menu.add_command(label='IEEE 9 Bus', command=lambda: load_sample_network(pn.create_ieee9())) self.sample_networks_menu.add_command(label='IEEE 14 Bus', @@ -76,6 +74,8 @@ def load_be_nl(): command=lambda: load_sample_network( pn.create_four_substations_node_breaker_network_with_extensions())) + self.add_separator() + self.add_command(label='Save...', command=self.save_network) self.add_separator() self.add_command( label='Exit', @@ -90,4 +90,15 @@ def open_network(self): else: self.context.status_text = 'Opening ' + filename self.context.network = pp.network.load(filename) - self.context.status_text = 'Network ' + self.context.network.name + ' loaded' + self.context.status_text = f'Network {self.context.network.name} loaded' + + def save_network(self): + if not self.context.network: + return + filename = fd.asksaveasfilename() + if not filename: + self.context.status_text = 'File save cancelled by user' + else: + self.context.status_text = 'Saving ' + filename + self.context.network.save(filename) + self.context.status_text = f'Network {self.context.network.name} saved to {filename}'