From 4251c9026291bd7fe2c20c75138bfc6c10c93275 Mon Sep 17 00:00:00 2001 From: Changgang Li Date: Sun, 25 Aug 2019 14:41:05 +0800 Subject: [PATCH] v0.4.1. Update pysteps to stepspy. --- README.md | 103 +- python/stepspy0.6/LICENSE | 21 + python/stepspy0.6/README.md | 13 + .../demo/demo_pysteps2_powerflow.py | 188 ++ python/stepspy0.6/setup.py | 23 + python/stepspy0.6/stepspy/__init__.py | 3 + .../stepspy0.6/stepspy/libsteps/__init__.py | 1 + .../dll_or_so_file_should_be_put_here | 1 + .../stepspy0.6/stepspy/libsteps/pylibsteps.py | 657 ++++++ python/stepspy0.6/stepspy/stepspy.py | 1969 +++++++++++++++++ 10 files changed, 2933 insertions(+), 46 deletions(-) create mode 100644 python/stepspy0.6/LICENSE create mode 100644 python/stepspy0.6/README.md create mode 100644 python/stepspy0.6/demo/demo_pysteps2_powerflow.py create mode 100644 python/stepspy0.6/setup.py create mode 100644 python/stepspy0.6/stepspy/__init__.py create mode 100644 python/stepspy0.6/stepspy/libsteps/__init__.py create mode 100644 python/stepspy0.6/stepspy/libsteps/dll_or_so_file_should_be_put_here create mode 100644 python/stepspy0.6/stepspy/libsteps/pylibsteps.py create mode 100644 python/stepspy0.6/stepspy/stepspy.py diff --git a/README.md b/README.md index 5c6554e5..ba856a03 100644 --- a/README.md +++ b/README.md @@ -1,46 +1,57 @@ -Simulation Toolkit for Electrical Power Systems - -Maintainer: Changgang Li - -Please go to http://steps.drli.group:310 for documentation. - -How to build: -1) Select which Linear Algebra solver is to be used - -Open STEPS.cbp and go to header/basic/sparse_matrix_define.h. Comment the solver you don't want to use. - -For example, if you want to keep only c_sparse, comment out umfpack and klu. - -Then go to source/basic/sparse_matrix_klu.cpp and umfpack.cpp, disable 'compile' and 'link' options of the two files. - -2) Go compile the Linear Algebra solver. - -For example, open csparse.cbp, and compile CSparse. The target should be 'static library' - -3) Go compile the CppTest. - -Open cpptest.cbp, and compile CppTest. The target should be 'static library' - -4) Build STEPS - -In the linker settings, you should include the above two static libraries libCSparse.a and libCpptest.a. - -Then compile the STEPS. - -5) If you want to build a 64bit version, use 64 bit MinGW and select the X64 version compiler. - -If you want to compile a complete version, follow the steps: - -1) Compile BLAS as static library - -2) Compile UMFPACK as static library - -3) Compile CSparse as static library - -4) Compile CppTest as static library - -5) Compile STEPS as dynamic library or exectuable file. Include libUMFPACK.a, libBLAS.a, libCSparse.a, and libCpptest.a. Put libBLAS.a after libUMFPACK.a. - -When compiling in Windows, remove -no-pie and -lgfortran options and remove libKLU.a, libBLAS.a, libUMFPACK.a - - +# Simulation Toolkit for Electrical Power Systems +- Maintainer: Changgang Li from School of Electrical Engineering, Shandong University. +- Documentation: http://steps.drli.group:310 +- Date of Readme: August 25, 2019 + +## Major functions +Simulation Toolkit for Electrical Power Systems (STEPS) is an open source power system simulator designed for balanced large-scale AC-DC hybrid power system analysis. +Currently, it supports powerflow solution and dynamic simulation. In the future, short circuit analysis and eigenvalue analysis will be supported with no timetable. +The data format of STEPS is improved based on PSS/E raw and dyr data format. BPA dat format is also supported. +You are encourage to join us for further development. +## Prerequisite +1. Install Code::Blocks. +2. Install C and C++ compiler supprting C++17. GCC is recommended. + - For Unix-like systems, follow guides to install gcc and g++ with the latest version. + - For Windows system, MinGW-64 is suggested. + - Go to http://mingw-w64.org/ and go to its sourceforge download site for the latest version. + - Install 32-bit version or 64-bit version as you like. 64-bit version is recommended. +3. Start Code::Blocks, and configure its toolchain exectuable. +4. Install Python if you want to try the stepspy module. 64-bit version is recommended. However, if you want to use 32-bit dynamic library of STEPS, you should install Python of the 32-bit version. + +## How to build +1. Select Linear Algebra solver to use + 1. Open STEPS.cbp in the code/ folder with Code::Blocks. + 2. Go to header/basic/sparse\_matrix\_define.h. Comment the solver you don't want to use. For example, if you want to keep only c\_sparse, comment umfpack and klu. + 3. Go to source/basic/sparse\_matrix\_klu.cpp and umfpack.cpp, disable 'compile' and 'link' options of the two files. + 4. Save STEPS.cbp. +2. Compile Linear Algebra solver. + 1. Open the Linear Algebra solver project. For example, if you choose to use CSparse as default Linear Algebra solver, open csparse.cbp in the code/ folder with Code::Blocks. + 2. Go 'Project'-'Properties'-'Build targets'and set type as 'static library'. + 3. Compile CSparse. You should get a libCSparse.a in folder build/bin/Release/. +3. Compile CppTest. + 1. Open cpptest.cbp in the code/ folder with Code::Blocks, set build target as 'static library'. + 2. Compile CppTest. You should get a libCppTest.a in folder build/bin/Release/. +4. Build STEPS + 1. Open STEPS.cbp in the code/ folder with Code::Blocks. + 2. Go 'Project'-'Build options'-'Linker settings', and add the libCsparse.a and libCppTest.a library to 'Link libraries'. + 3. Go 'Project'-'Properties'-'Build Target', and select build target + - If you want to compile STEPS as dynamic library, select 'Dynamic library', and set the output file name as 'libsteps.so' for Unix-like systems or 'libsteps.dll' for Windows systems. + - If you want to compile STEPS as console application, select 'Console application'. + 4. If the target is dynamic library, disable 'Link' option for Source files with leading name of 'main'. If the target is console application, enable 'Link' option for only one of Source files with leading name of 'main'. + 5. Compile the STEPS. You should get the output file in folder build/bin/Release/. + 6. When compiling in Windows, remove -no-pie and -lgfortran options and remove libKLU.a, libBLAS.a, libUMFPACK.a + +Here is a complete procedure of how to build STEPS. +1. Compile BLAS as static library. You can find BLAS.cbp in the code/ folder. +2. Compile UMFPACK as static library. You can find UMFPACK.cbp in the code/ folder. +3. Compile CSparse as static library. You can find CSparse.cbp in the code/ folder. +4. Compile CppTest as static library. You can find CppTest.cbp in the code/ folder. +5. Compile STEPS as dynamic library or exectuable file. Include libUMFPACK.a, libBLAS.a, libCSparse.a, and libCpptest.a. Put libBLAS.a after libUMFPACK.a. + + +## How to use stepspy +stepspy is a Python module of advanced APIs of STEPS. It enables most of STEPS applications. It is recommended to use stepspy in Python 3 of 64-bit version, though Python 2 is also supported. + +stepspy will be uploaded to pypi.org soon, and will be installed via: +- pip3 install stepspy +- python -m pip install stepspy diff --git a/python/stepspy0.6/LICENSE b/python/stepspy0.6/LICENSE new file mode 100644 index 00000000..2c746540 --- /dev/null +++ b/python/stepspy0.6/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Changgang Li + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/python/stepspy0.6/README.md b/python/stepspy0.6/README.md new file mode 100644 index 00000000..cd04e2c8 --- /dev/null +++ b/python/stepspy0.6/README.md @@ -0,0 +1,13 @@ +stepspy: a Python module of Simulation Toolkit for Electrical Power Systems + +Author: Changgang Li from the School of Electrical Engineering, Shandong University, China + +stepspy provides almost all functions of STEPS (https://github.com/changgang/steps). It calls dynamic library of STEPS, and wraps it to advanced functions. + +If you want to manually install stepspy, follow the instructions: +1. Go to https://github.com/changgang/steps to download or fork the latest version of STEPS. +2. Compile STEPS into dynamic library following instructions of STEPS. +3. Go to python/ folder of STEPS, and copy the latest version of stepspy/ to PYTHONPATH/Lib/site-packages/. +4, Move the dynamic library of STEPS to stepspy/libsteps/ in the PYTHONPATH/Lib/site-packages/. +5, If the VC runtime is missing, download and install Microsoft Visual C++ 2017 Redistributable of 32 or 64 bit version. +5, If VC runtime or Mingw Runtime is missing, install vcredit or copy libwinpthread-1.dll from mingw compiler/bin/ to c:/windows/system32 and c:/windows/SysWOW64 diff --git a/python/stepspy0.6/demo/demo_pysteps2_powerflow.py b/python/stepspy0.6/demo/demo_pysteps2_powerflow.py new file mode 100644 index 00000000..af190851 --- /dev/null +++ b/python/stepspy0.6/demo/demo_pysteps2_powerflow.py @@ -0,0 +1,188 @@ +#coding = utf-8 +''' +Here is a demo of showing how to slove powerflow with pysteps2. + +Changgang Li, 2018/09/07 +''' + +from pysteps2 import STEPS # import the class 'STEPS' + +simulator = STEPS() # create a STEPS simulator instance + + +powerflow_data_file = 'IEEE9.raw' # file name of powerflow data. Use absolute path if necessary +powerflow_data_type = 'PSS/E' # powerflow data type. Currently, use 'PSS/E' only + +simulator.load_powerflow_data(powerflow_data_file, powerflow_data_type) # load powerflow data into the simulator + +data_type = 'D' # if you want to set or get doubule data, set data_type as 'F' or 'D'. +data_name = 'MAX ACTIVE POWER IMBALANCE IN MW' # the data name in the powerflow solver of the simulator +# the data_type and data_name should be consistent. make sure the data_type is correct. +# If the data is double, use 'F' or 'D'. If the data is integer, use 'I'. If the data is boolean, use 'B'. If the data is string, use 'S' +''' +(1) when data_type is 'D' or 'F' you can set/get the following data + 'MAX ACTIVE POWER IMBALANCE IN MW': maximum allowed active power mismatch at each bus, in MW. This is the powerflow convergence threshold of P equations. + 'MAX REACTIVE POWER IMBALANCE IN MVAR': maximum allowed reactive power mismatch at each bus, in MVar. This is the powerflow convergence threshold of Q equations. + 'ITERATION ACCELERATOR': acceleration factor for iteration. by default it is 1.0. if >1.0, then the powerflow solver is accelerated. if <1.0, the powerflow solver is decellerated. + + (2) when data_type is 'I', you can set/get the following data + 'MAX ITERATION': maximum iteration count allowed for solving powerflow. If set as 1, you can get the solution step by step. + + (3)when data_type is 'B', you can set/get the following data + 'FLAT START LOGIC': if true, powerflow will be solved with unity voltage profile (1.0pu, 0.0deg), if false, poewrflow will be solved from the current voltage profile. +''' + +# here goes get and set maximum active power imbalance in MW +data_type = 'D' +data_name = 'MAX ACTIVE POWER IMBALANCE IN MW' +P_error_MW = simulator.get_powerflow_solver_parameter(data_type, data_name) + +value = 0.001 +simulator.set_powerflow_solver_parameter(data_type, data_name, value) + +# here goes get and set maximum reactive power imbalance in MVAR +data_type = 'D' +data_name = 'MAX REACTIVE POWER IMBALANCE IN MVAR' +Q_error_MVar = simulator.get_powerflow_solver_parameter(data_type, data_name) + +value = 0.001 +simulator.set_powerflow_solver_parameter(data_type, data_name, value) + +# here goes get and set maximum iteration +data_type = 'I' +data_name = 'MAX ITERATION' +Iter_max = simulator.get_powerflow_solver_parameter(data_type, data_name) + +value = 50 +simulator.set_powerflow_solver_parameter(data_type, data_name, value) + +# here goes get and set flat start logic +data_type = 'B' +data_name = 'FLAT START LOGIC' +flat_flag = simulator.get_powerflow_solver_parameter(data_type, data_name) + +value = False +simulator.set_powerflow_solver_parameter(data_type, data_name, value) + +# now assuming that maximum active and reactive power imbalance are already set. +# show how to solve powerflow + +# solve powerflow with flat start logic disabled +data_type = 'B' +data_name = 'FLAT START LOGIC' +value = False +simulator.set_powerflow_solver_parameter(data_type, data_name, value) + +simulator.solve_powerflow('NR') # use 'NR' for Newton-Raphson solution, use 'PQ' for PQ decoupled solution + +# solve powerflow with flat start logic enabled +data_type = 'B' +data_name = 'FLAT START LOGIC' +value = True +simulator.set_powerflow_solver_parameter(data_type, data_name, value) + +simulator.solve_powerflow('PQ') + +# if you want to solve powerflow step by step to get the solution process, +# you can set MAX ITERATION as 1, and Flat start logic as false +data_type = 'I' +data_name = 'MAX ITERATION' +value = 1 +simulator.set_powerflow_solver_parameter(data_type, data_name, value) + +data_type = 'B' +data_name = 'FLAT START LOGIC' +value = True +simulator.set_powerflow_solver_parameter(data_type, data_name, value) + +simulator.solve_powerflow('NR') # first slove it with flat start enable + +data_type = 'B' +data_name = 'FLAT START LOGIC' +value = False +simulator.set_powerflow_solver_parameter(data_type, data_name, value) # from now on, disable flat start + +while not simulator.is_powerflow_converged(): # use is_powerflow_converged() to check if powerflow is converged + simulator.solve_powerflow('NR') + simulator.save_jacobian_matrix('jacobian.txt') # if you are solving with NR method, you can get jacobian matrix of each iteration in the file + +# once powerflow is converged, you can export powerflow result to file +powerflow_result_file = 'pf_result.txt' +simulator.save_powerflow_result(powerflow_result_file) # you can check the file's contents + +# you can get power loss of a solved powerflow case +ploss_MW = simulator.get_powerflow_loss() # in MW +print('Loss is:', ploss_MW) + +# if you want to get the voltage of each bus, you can try the following codes +buses = simulator.get_all_buses() +for bus in buses: + bus_name = simulator.get_bus_data(bus, 'S', 'Name') + voltage = simulator.get_bus_data(bus, 'D', 'Voltage in PU') + angle = simulator.get_bus_data(bus, 'D', 'Angle in deg') + print(bus, bus_name, voltage, angle) + +# if you want to get the generation of each generator, you can try the following codes +generators = simulator.get_generators_at_bus(0) # 0 indicate all generators will be returned +for generator in generators: + P = simulator.get_generator_data(generator, 'D', 'PGEN_MW') + Q = simulator.get_generator_data(generator, 'D', 'QGEN_MVAR') + print(generator, P, Q) + +# if you want to get the load of each load, you can try the following codes +loads = simulator.get_loads_at_bus(0) # 0 indicate all loads will be returned +for load in loads: + P = simulator.get_load_data(load, 'D', 'P_MW') + Q = simulator.get_load_data(load, 'D', 'Q_MVAR') + print(load, P, Q) + +# if you want to get the power of each line, you can try the following codes +lines = simulator.get_lines_at_bus(0) # 0 indicate all lines will be returned +for line in lines: + bus_send = simulator.get_line_data(line, 'I', 'BUS_SEND') # get the bus number of sending side + bus_recv = simulator.get_line_data(line, 'I', 'BUS_RECV') # get the bus number of receiving side + Psend = simulator.get_line_data(line, 'D', 'PSEND_MW') # active power at sending side + Qsend = simulator.get_line_data(line, 'D', 'QSEND_MVAR') # reactive power at sending side + Precv = simulator.get_line_data(line, 'D', 'PRECV_MW') # active power at receiving side + Qrecv = simulator.get_line_data(line, 'D', 'QRECV_MVAR') # reactive power at receiving side + print(line, bus_send, (Psend, Qsend), bus_recv, (Precv, Qrecv)) + +# if you want to get the power of each transformer, you can try the following codes +transformers = simulator.get_transformers_at_bus(0) # 0 indicate all transformers will be returned +for transformer in transformers: + bus_pri = simulator.get_transformer_data(transformer, 'I', 'Primary', 'BUS') # get the bus number of primary side + bus_sec = simulator.get_transformer_data(transformer, 'I', 'Secondary', 'BUS') # get the bus number of secondary side + + P_pri = simulator.get_transformer_data(transformer, 'D', 'Primary', 'P_MW') # active power at primary side + Q_pri = simulator.get_transformer_data(transformer, 'D', 'Primary', 'Q_MVAR') # reactive power at primary side + P_sec = simulator.get_transformer_data(transformer, 'D', 'Secondary', 'P_MW') # active power at secondary side + Q_sec = simulator.get_transformer_data(transformer, 'D', 'Secondary', 'Q_MVAR') # reactive power at secondary side + print(transformer, bus_pri, (P_pri, Q_pri), bus_sec, (P_sec, Q_sec)) + + + +# if you want to change generation of each generaor, trye the following codes +generator = (2,'1') # generator bus, and generator ID, check generator line of raw file +simulator.set_generator_data(generator, 'D', 'PGEN_MW', 50.0) # remember, only P of generator at bus of type 2 can be changed + +data_type = 'I' +data_name = 'MAX ITERATION' +value = 10 +simulator.set_powerflow_solver_parameter(data_type, data_name, value) + +data_type = 'B' +data_name = 'FLAT START LOGIC' +value = True +simulator.set_powerflow_solver_parameter(data_type, data_name, value) + +simulator.solve_powerflow('NR') + + + + + + + + + + diff --git a/python/stepspy0.6/setup.py b/python/stepspy0.6/setup.py new file mode 100644 index 00000000..b549155d --- /dev/null +++ b/python/stepspy0.6/setup.py @@ -0,0 +1,23 @@ +import setuptools + +with open("README.md", "r") as fh: + long_description = fh.read() + +setuptools.setup( + name="stepspy", + version="0.6.0", + author="Changgang Li", + author_email="lichgang@sdu.edu.cn", + description="Python module of Simulation Toolkit for Electrical Power Systems", + long_description=long_description, + long_description_content_type="text/markdown", + url="https://github.com/changgang/steps", + packages=setuptools.find_packages(), + classifiers=[ + "Programming Language :: Python :: 2", + "Programming Language :: Python :: 3", + "Programming Language :: C++", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + ], +) \ No newline at end of file diff --git a/python/stepspy0.6/stepspy/__init__.py b/python/stepspy0.6/stepspy/__init__.py new file mode 100644 index 00000000..75fa6a0c --- /dev/null +++ b/python/stepspy0.6/stepspy/__init__.py @@ -0,0 +1,3 @@ +from .stepspy import STEPS +name = 'stepspy' +__all__ = ['STEPS'] diff --git a/python/stepspy0.6/stepspy/libsteps/__init__.py b/python/stepspy0.6/stepspy/libsteps/__init__.py new file mode 100644 index 00000000..574b1589 --- /dev/null +++ b/python/stepspy0.6/stepspy/libsteps/__init__.py @@ -0,0 +1 @@ +__all__ = ['pylibsteps'] diff --git a/python/stepspy0.6/stepspy/libsteps/dll_or_so_file_should_be_put_here b/python/stepspy0.6/stepspy/libsteps/dll_or_so_file_should_be_put_here new file mode 100644 index 00000000..8d1c8b69 --- /dev/null +++ b/python/stepspy0.6/stepspy/libsteps/dll_or_so_file_should_be_put_here @@ -0,0 +1 @@ + diff --git a/python/stepspy0.6/stepspy/libsteps/pylibsteps.py b/python/stepspy0.6/stepspy/libsteps/pylibsteps.py new file mode 100644 index 00000000..b7ad4bfb --- /dev/null +++ b/python/stepspy0.6/stepspy/libsteps/pylibsteps.py @@ -0,0 +1,657 @@ +from ctypes import * +import platform +import os + +libsteps_version = "0.6.0" +libsteps_date = "2019/08/25" + +def get_base_library(): + dirname, filename = os.path.split(os.path.abspath(__file__)) + dirname = dirname.replace('\\','/') + if not dirname.endswith('/'): + dirname = dirname + '/' + + libsteps_name = 'libSTEPS' + libsteps_extension = '.so' + if platform.system()=="Linux" or platform.system()=="Unix": + libsteps_extension = '.so' + elif platform.system()=="Windows": + libsteps_extension = '.dll' + + library = dirname+libsteps_name+libsteps_extension + if not os.path.exists(library): + info = "Warning. "+library+" does not exist. No applications with stepspy will be enabled.\n" + info += "Please go to https://github.com/changgang/steps to download the proper version or build it from scratch.\n" + info += "After that, you should put the dynamic library to the exact location of "+library+".\n" + info += "Remember, keep the file name exactly as libSTEPS.so or libSTEPS.dll" + print(info) + library = None + + return library + +def load_library(): + library = get_base_library() + if library is not None: + libsteps = cdll.LoadLibrary(library) + else: + return None + + libsteps.api_set_default_toolkit_log_file.restype = None + libsteps.api_set_default_toolkit_log_file.argtype = (c_char_p, ) + + libsteps.api_generate_new_toolkit.restype = c_uint + libsteps.api_generate_new_toolkit.argtypes = None + + libsteps.api_delete_toolkit.restype = None + libsteps.api_delete_toolkit.argtypes = (c_uint, ) + + libsteps.api_initialize_toolkit.restype = None + libsteps.api_initialize_toolkit.argtypes = (c_uint, ) + + libsteps.api_clear_toolkit.restype = None + libsteps.api_clear_toolkit.argtypes = (c_uint, ) + + libsteps.api_get_toolkit_float_data.restype = c_double + libsteps.api_get_toolkit_float_data.argtypes = (c_char_p, c_uint) + + libsteps.api_set_toolkit_float_data.restype = None + libsteps.api_set_toolkit_float_data.argtypes = (c_char_p, c_double, c_uint) + + libsteps.api_get_toolkit_string_data.restype = c_char_p + libsteps.api_get_toolkit_string_data.argtypes = (c_char_p, c_uint) + + libsteps.api_set_toolkit_string_data.restype = None + libsteps.api_set_toolkit_string_data.argtypes = (c_char_p, c_char_p, c_uint) + + libsteps.api_get_toolkit_bool_data.restype = c_bool + libsteps.api_get_toolkit_bool_data.argtypes = (c_char_p, c_uint) + + libsteps.api_set_toolkit_bool_data.restype = None + libsteps.api_set_toolkit_bool_data.argtypes = (c_char_p, c_bool, c_uint) + + libsteps.api_load_powerflow_data_from_file.restype = None + libsteps.api_load_powerflow_data_from_file.argtypes = (c_char_p, c_char_p, c_uint) + libsteps.api_load_dynamic_data_from_file.restype = None + libsteps.api_load_dynamic_data_from_file.argtypes = (c_char_p, c_char_p, c_uint) + + libsteps.api_save_powerflow_data_to_file.restype = None + libsteps.api_save_powerflow_data_to_file.argtypes = (c_char_p, c_char_p, c_bool, c_bool, c_uint) + libsteps.api_save_dynamic_data_to_file.restype = None + libsteps.api_save_dynamic_data_to_file.argtypes = (c_char_p, c_char_p, c_uint) + + libsteps.api_check_database.restype = None + libsteps.api_check_database.argtypes = (c_uint, ) + + libsteps.api_check_dynamic_data.restype = None + libsteps.api_check_dynamic_data.argtypes = (c_uint, ) + + libsteps.api_check_network_connectivity.restype = None + libsteps.api_check_network_connectivity.argtypes = (c_bool, c_uint) + + libsteps.api_get_allowed_maximum_bus_number.restype = c_uint + libsteps.api_get_allowed_maximum_bus_number.argtypes = (c_uint, ) + + libsteps.api_set_allowed_maximum_bus_number.restype = None + libsteps.api_set_allowed_maximum_bus_number.argtypes = (c_uint, c_uint) + + libsteps.api_get_device_capacity.restype = c_uint + libsteps.api_get_device_capacity.argtypes = (c_char_p, c_uint) + libsteps.api_get_area_capacity.restype = c_uint + libsteps.api_get_area_capacity.argtypes = (c_uint, ) + libsteps.api_get_zone_capacity.restype = c_uint + libsteps.api_get_zone_capacity.argtypes = (c_uint, ) + libsteps.api_get_owner_capacity.restype = c_uint + libsteps.api_get_owner_capacity.argtypes = (c_uint, ) + + libsteps.api_set_device_capacity.restype = None + libsteps.api_set_device_capacity.argtypes = (c_char_p, c_uint, c_uint) + libsteps.api_set_area_capacity.restype = None + libsteps.api_set_area_capacity.argtypes = (c_uint, c_uint) + libsteps.api_set_zone_capacity.restype = None + libsteps.api_set_zone_capacity.argtypes = (c_uint, c_uint) + libsteps.api_set_owner_capacity.restype = None + libsteps.api_set_owner_capacity.argtypes = (c_uint, c_uint) + + libsteps.api_get_device_count.restype = c_uint + libsteps.api_get_device_count.argtypes = (c_char_p, c_uint) + libsteps.api_get_area_count.restype = c_uint + libsteps.api_get_area_count.argtypes = (c_uint, ) + libsteps.api_get_zone_count.restype = c_uint + libsteps.api_get_zone_count.argtypes = (c_uint, ) + libsteps.api_get_owner_count.restype = c_uint + libsteps.api_get_owner_count.argtypes = (c_uint, ) + libsteps.api_get_in_service_bus_count.restype = c_uint + libsteps.api_get_in_service_bus_count.argtypes = (c_uint, ) + libsteps.api_update_overshadowed_buses.restype = None + libsteps.api_update_overshadowed_buses.argtypes = (c_uint, ) + libsteps.api_set_all_buses_un_overshadowed.restype = None + libsteps.api_set_all_buses_un_overshadowed.argtypes = (c_uint, ) + libsteps.api_get_overshadowed_bus_count.restype = c_uint + libsteps.api_get_overshadowed_bus_count.argtypes = (c_uint, ) + + libsteps.api_is_bus_exist.restype = c_bool + libsteps.api_is_bus_exist.argtypes = (c_uint, c_uint) + libsteps.api_is_generator_exist.restype = c_bool + libsteps.api_is_generator_exist.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_is_wt_generator_exist.restype = c_bool + libsteps.api_is_wt_generator_exist.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_is_pv_unit_exist.restype = c_bool + libsteps.api_is_pv_unit_exist.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_is_energy_storage_exist.restype = c_bool + libsteps.api_is_energy_storage_exist.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_is_load_exist.restype = c_bool + libsteps.api_is_load_exist.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_is_fixed_shunt_exist.restype = c_bool + libsteps.api_is_fixed_shunt_exist.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_is_line_exist.restype = c_bool + libsteps.api_is_line_exist.argtypes = (c_uint, c_uint, c_char_p, c_uint) + libsteps.api_is_transformer_exist.restype = c_bool + libsteps.api_is_transformer_exist.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_uint) + libsteps.api_is_hvdc_exist.restype = c_bool + libsteps.api_is_hvdc_exist.argtypes = (c_uint, c_uint, c_char_p, c_uint) + libsteps.api_is_equivalent_device_exist.restype = c_bool + libsteps.api_is_equivalent_device_exist.argtypes = (c_uint, c_char_p, c_uint) + + libsteps.api_show_device_data.restype = None + libsteps.api_show_device_data.argtypes = (c_char_p, c_uint) + + libsteps.api_bus_number2bus_name.restype = c_char_p + libsteps.api_bus_number2bus_name.argtypes = (c_uint, c_uint) + libsteps.api_bus_name2bus_number.restype = c_uint + libsteps.api_bus_name2bus_number.argtypes = (c_char_p, c_uint) + + libsteps.api_initialize_bus_search.restype = None + libsteps.api_initialize_bus_search.argtypes = (c_double, c_double, c_double, c_double, c_uint, c_uint, c_uint, c_uint) + libsteps.api_initialize_all_bus_search.restype = None + libsteps.api_initialize_all_bus_search.argtypes = (c_uint, ) + + libsteps.api_get_current_bus_number.restype = c_uint + libsteps.api_get_current_bus_number.argtypes = (c_uint, ) + + libsteps.api_goto_next_bus.restype = None + libsteps.api_goto_next_bus.argtypes = (c_uint, ) + + libsteps.api_initialize_device_search.restype = None + libsteps.api_initialize_device_search.argtypes = (c_char_p, c_uint, c_uint) + + libsteps.api_get_current_device_bus_number.restype = c_uint + libsteps.api_get_current_device_bus_number.argtypes = (c_char_p, c_char_p, c_uint) + + libsteps.api_get_current_device_identifier.restype = c_char_p + libsteps.api_get_current_device_identifier.argtypes = (c_char_p, c_uint) + + libsteps.api_goto_next_device.restype = None + libsteps.api_goto_next_device.argtypes = (c_char_p, c_uint) + + libsteps.api_initialize_area_search.restype = None + libsteps.api_initialize_area_search.argtypes = (c_uint, ) + + libsteps.api_get_current_area_number.restype = c_uint + libsteps.api_get_current_area_number.argtypes = (c_uint, ) + + libsteps.api_goto_next_area.restype = None + libsteps.api_goto_next_area.argtypes = (c_uint, ) + + libsteps.api_initialize_zone_search.restype = None + libsteps.api_initialize_zone_search.argtypes = (c_uint, ) + + libsteps.api_get_current_zone_number.restype = c_uint + libsteps.api_get_current_zone_number.argtypes = (c_uint, ) + + libsteps.api_goto_next_zone.restype = None + libsteps.api_goto_next_zone.argtypes = (c_uint, ) + + libsteps.api_initialize_owner_search.restype = None + libsteps.api_initialize_owner_search.argtypes = (c_uint, ) + + libsteps.api_get_current_owner_number.restype = c_uint + libsteps.api_get_current_owner_number.argtypes = (c_uint, ) + + libsteps.api_goto_next_owner.restype = None + libsteps.api_goto_next_owner.argtypes = (c_uint, ) + + libsteps.api_add_bus.restype = None + libsteps.api_add_bus.argtypes = (c_uint, c_char_p, c_double, c_uint) + libsteps.api_add_generator.restype = None + libsteps.api_add_generator.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_add_wt_generator.restype = None + libsteps.api_add_wt_generator.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_add_pv_unit.restype = None + libsteps.api_add_pv_unit.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_add_energy_storage.restype = None + libsteps.api_add_energy_storage.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_add_load.restype = None + libsteps.api_add_load.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_add_fixed_shunt.restype = None + libsteps.api_add_fixed_shunt.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_add_line.restype = None + libsteps.api_add_line.argtypes = (c_uint, c_uint, c_char_p, c_uint) + libsteps.api_add_hvdc.restype = None + libsteps.api_add_hvdc.argtypes = (c_uint, c_uint, c_char_p, c_uint) + libsteps.api_add_transformer.restype = None + libsteps.api_add_transformer.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_uint) + libsteps.api_add_equivalent_device.restype = None + libsteps.api_add_equivalent_device.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_add_area.restype = None + libsteps.api_add_area.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_add_zone.restype = None + libsteps.api_add_zone.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_add_owner.restype = None + libsteps.api_add_owner.argtypes = (c_uint, c_char_p, c_uint) + + libsteps.api_remove_bus.restype = None + libsteps.api_remove_bus.argtypes = (c_uint, c_uint) + libsteps.api_remove_generator.restype = None + libsteps.api_remove_generator.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_remove_wt_generator.restype = None + libsteps.api_remove_wt_generator.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_remove_pv_unit.restype = None + libsteps.api_remove_pv_unit.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_remove_energy_storage.restype = None + libsteps.api_remove_energy_storage.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_remove_load.restype = None + libsteps.api_remove_load.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_remove_fixed_shunt.restype = None + libsteps.api_remove_fixed_shunt.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_remove_line.restype = None + libsteps.api_remove_line.argtypes = (c_uint, c_uint, c_char_p, c_uint) + libsteps.api_remove_hvdc.restype = None + libsteps.api_remove_hvdc.argtypes = (c_uint, c_uint, c_char_p, c_uint) + libsteps.api_remove_transformer.restype = None + libsteps.api_remove_transformer.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_uint) + libsteps.api_remove_equivalent_device.restype = None + libsteps.api_remove_equivalent_device.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_remove_area.restype = None + libsteps.api_remove_area.argtypes = (c_uint, c_uint) + libsteps.api_remove_zone.restype = None + libsteps.api_remove_zone.argtypes = (c_uint, c_uint) + libsteps.api_remove_owner.restype = None + libsteps.api_remove_owner.argtypes = (c_uint, c_uint) + + + + + libsteps.api_get_bus_integer_data.restype = (c_int) + libsteps.api_get_bus_integer_data.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_get_bus_float_data.restype = (c_double) + libsteps.api_get_bus_float_data.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_get_bus_string_data.restype = (c_char_p) + libsteps.api_get_bus_string_data.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_set_bus_integer_data.restype = None + libsteps.api_set_bus_integer_data.argtypes = (c_uint, c_char_p, c_int, c_uint) + libsteps.api_set_bus_float_data.restype = None + libsteps.api_set_bus_float_data.argtypes = (c_uint, c_char_p, c_double, c_uint) + libsteps.api_set_bus_string_data.restype = None + libsteps.api_set_bus_string_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + + libsteps.api_get_load_integer_data.restype = (c_int) + libsteps.api_get_load_integer_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_load_float_data.restype = (c_double) + libsteps.api_get_load_float_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_load_string_data.restype = (c_char_p) + libsteps.api_get_load_string_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_load_boolean_data.restype = (c_bool) + libsteps.api_get_load_boolean_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_set_load_integer_data.restype = None + libsteps.api_set_load_integer_data.argtypes = (c_uint, c_char_p, c_char_p, c_int, c_uint) + libsteps.api_set_load_float_data.restype = None + libsteps.api_set_load_float_data.argtypes = (c_uint, c_char_p, c_char_p, c_double, c_uint) + libsteps.api_set_load_string_data.restype = None + libsteps.api_set_load_string_data.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_load_boolean_data.restype = None + libsteps.api_set_load_boolean_data.argtypes = (c_uint, c_char_p, c_char_p, c_bool, c_uint) + + libsteps.api_get_source_integer_data.restype = (c_int) + libsteps.api_get_source_integer_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_source_float_data.restype = (c_double) + libsteps.api_get_source_float_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_source_string_data.restype = (c_char_p) + libsteps.api_get_source_string_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_source_boolean_data.restype = (c_bool) + libsteps.api_get_source_boolean_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_set_source_integer_data.restype = None + libsteps.api_set_source_integer_data.argtypes = (c_uint, c_char_p, c_char_p, c_int, c_uint) + libsteps.api_set_source_float_data.restype = None + libsteps.api_set_source_float_data.argtypes = (c_uint, c_char_p, c_char_p, c_double, c_uint) + libsteps.api_set_source_string_data.restype = None + libsteps.api_set_source_string_data.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_source_boolean_data.restype = None + libsteps.api_set_source_boolean_data.argtypes = (c_uint, c_char_p, c_char_p, c_bool, c_uint) + + libsteps.api_get_fixed_shunt_integer_data.restype = (c_int) + libsteps.api_get_fixed_shunt_integer_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_fixed_shunt_float_data.restype = (c_double) + libsteps.api_get_fixed_shunt_float_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_fixed_shunt_string_data.restype = (c_char_p) + libsteps.api_get_fixed_shunt_string_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_fixed_shunt_boolean_data.restype = (c_bool) + libsteps.api_get_fixed_shunt_boolean_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_set_fixed_shunt_integer_data.restype = None + libsteps.api_set_fixed_shunt_integer_data.argtypes = (c_uint, c_char_p, c_char_p, c_int, c_uint) + libsteps.api_set_fixed_shunt_float_data.restype = None + libsteps.api_set_fixed_shunt_float_data.argtypes = (c_uint, c_char_p, c_char_p, c_double, c_uint) + libsteps.api_set_fixed_shunt_string_data.restype = None + libsteps.api_set_fixed_shunt_string_data.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_fixed_shunt_boolean_data.restype = None + libsteps.api_set_fixed_shunt_boolean_data.argtypes = (c_uint, c_char_p, c_char_p, c_bool, c_uint) + + libsteps.api_get_line_integer_data.restype = (c_int) + libsteps.api_get_line_integer_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_line_float_data.restype = (c_double) + libsteps.api_get_line_float_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_line_string_data.restype = (c_char_p) + libsteps.api_get_line_string_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_line_boolean_data.restype = (c_bool) + libsteps.api_get_line_boolean_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_set_line_integer_data.restype = None + libsteps.api_set_line_integer_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_int, c_uint) + libsteps.api_set_line_float_data.restype = None + libsteps.api_set_line_float_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_double, c_uint) + libsteps.api_set_line_string_data.restype = None + libsteps.api_set_line_string_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_line_boolean_data.restype = None + libsteps.api_set_line_boolean_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_bool, c_uint) + + libsteps.api_get_transformer_integer_data.restype = (c_int) + libsteps.api_get_transformer_integer_data.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_get_transformer_float_data.restype = (c_double) + libsteps.api_get_transformer_float_data.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_get_transformer_string_data.restype = (c_char_p) + libsteps.api_get_transformer_string_data.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_get_transformer_boolean_data.restype = (c_bool) + libsteps.api_get_transformer_boolean_data.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_transformer_integer_data.restype = None + libsteps.api_set_transformer_integer_data.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_int, c_uint) + libsteps.api_set_transformer_float_data.restype = None + libsteps.api_set_transformer_float_data.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_double, c_uint) + libsteps.api_set_transformer_string_data.restype = None + libsteps.api_set_transformer_string_data.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_transformer_boolean_data.restype = None + libsteps.api_set_transformer_boolean_data.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_bool, c_uint) + + libsteps.api_get_hvdc_integer_data.restype = (c_int) + libsteps.api_get_hvdc_integer_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_get_hvdc_float_data.restype = (c_double) + libsteps.api_get_hvdc_float_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_get_hvdc_string_data.restype = (c_char_p) + libsteps.api_get_hvdc_string_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_get_hvdc_boolean_data.restype = (c_bool) + libsteps.api_get_hvdc_boolean_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_hvdc_integer_data.restype = None + libsteps.api_set_hvdc_integer_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_int, c_uint) + libsteps.api_set_hvdc_float_data.restype = None + libsteps.api_set_hvdc_float_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_double, c_uint) + libsteps.api_set_hvdc_string_data.restype = None + libsteps.api_set_hvdc_string_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_hvdc_boolean_data.restype = None + libsteps.api_set_hvdc_boolean_data.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_bool, c_uint) + + libsteps.api_get_area_integer_data.restype = (c_int) + libsteps.api_get_area_integer_data.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_get_area_float_data.restype = (c_double) + libsteps.api_get_area_float_data.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_get_area_string_data.restype = (c_char_p) + libsteps.api_get_area_string_data.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_set_area_integer_data.restype = None + libsteps.api_set_area_integer_data.argtypes = (c_uint, c_char_p, c_int, c_uint) + libsteps.api_set_area_float_data.restype = None + libsteps.api_set_area_float_data.argtypes = (c_uint, c_char_p, c_double, c_uint) + libsteps.api_set_area_string_data.restype = None + libsteps.api_set_area_string_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + + libsteps.api_get_zone_integer_data.restype = (c_int) + libsteps.api_get_zone_integer_data.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_get_zone_string_data.restype = (c_char_p) + libsteps.api_get_zone_string_data.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_set_zone_integer_data.restype = None + libsteps.api_set_zone_integer_data.argtypes = (c_uint, c_char_p, c_int, c_uint) + libsteps.api_set_zone_string_data.restype = None + libsteps.api_set_zone_string_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + + libsteps.api_get_owner_integer_data.restype = (c_int) + libsteps.api_get_owner_integer_data.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_get_owner_string_data.restype = (c_char_p) + libsteps.api_get_owner_string_data.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_set_owner_integer_data.restype = None + libsteps.api_set_owner_integer_data.argtypes = (c_uint, c_char_p, c_int, c_uint) + libsteps.api_set_owner_string_data.restype = None + libsteps.api_set_owner_string_data.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + + libsteps.api_set_dynamic_model.restype = None + libsteps.api_set_dynamic_model.argtypes = (c_char_p, c_char_p, c_uint) + + libsteps.api_get_generator_related_model_name.restype = c_char_p + libsteps.api_get_generator_related_model_name.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_generator_related_model_float_parameter.restype = c_double + libsteps.api_get_generator_related_model_float_parameter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_generator_related_model_float_parameter.restype = None + libsteps.api_set_generator_related_model_float_parameter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_double, c_uint) + + libsteps.api_get_wt_generator_related_model_name.restype = c_char_p + libsteps.api_get_wt_generator_related_model_name.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_wt_generator_related_model_float_parameter.restype = c_double + libsteps.api_get_wt_generator_related_model_float_parameter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_wt_generator_related_model_float_parameter.restype = None + libsteps.api_set_wt_generator_related_model_float_parameter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_double, c_uint) + + libsteps.api_get_pv_unit_related_model_name.restype = c_char_p + libsteps.api_get_pv_unit_related_model_name.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_pv_unit_related_model_float_parameter.restype = c_double + libsteps.api_get_pv_unit_related_model_float_parameter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_pv_unit_related_model_float_parameter.restype = None + libsteps.api_set_pv_unit_related_model_float_parameter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_double, c_uint) + + libsteps.api_get_load_related_model_name.restype = c_char_p + libsteps.api_get_load_related_model_name.argtypes = (c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_load_related_model_float_parameter.restype = c_double + libsteps.api_get_load_related_model_float_parameter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_load_related_model_float_parameter.restype = None + libsteps.api_set_load_related_model_float_parameter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_double, c_uint) + + libsteps.api_get_line_related_model_name.restype = c_char_p + libsteps.api_get_line_related_model_name.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_line_related_model_float_parameter.restype = c_double + libsteps.api_get_line_related_model_float_parameter.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_line_related_model_float_parameter.restype = None + libsteps.api_set_line_related_model_float_parameter.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_double, c_uint) + + libsteps.api_get_hvdc_related_model_name.restype = c_char_p + libsteps.api_get_hvdc_related_model_name.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_uint) + libsteps.api_get_hvdc_related_model_float_parameter.restype = c_double + libsteps.api_get_hvdc_related_model_float_parameter.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_set_hvdc_related_model_float_parameter.restype = None + libsteps.api_set_hvdc_related_model_float_parameter.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_double, c_uint) + + + libsteps.api_get_powerflow_solver_integer_parameter.restype = (c_uint) + libsteps.api_get_powerflow_solver_integer_parameter.argtypes = (c_char_p, c_uint) + libsteps.api_get_powerflow_solver_float_parameter.restype = (c_double) + libsteps.api_get_powerflow_solver_float_parameter.argtypes = (c_char_p, c_uint) + libsteps.api_get_powerflow_solver_boolean_parameter.restype = (c_bool) + libsteps.api_get_powerflow_solver_boolean_parameter.argtypes = (c_char_p, c_uint) + libsteps.api_set_powerflow_solver_integer_parameter.restype = None + libsteps.api_set_powerflow_solver_integer_parameter.argtypes = (c_char_p, c_int, c_uint) + libsteps.api_set_powerflow_solver_float_parameter.restype = None + libsteps.api_set_powerflow_solver_float_parameter.argtypes = (c_char_p, c_double, c_uint) + libsteps.api_set_powerflow_solver_boolean_parameter.restype = None + libsteps.api_set_powerflow_solver_boolean_parameter.argtypes = (c_char_p, c_bool, c_uint) + + libsteps.api_solve_powerflow.restype = None + libsteps.api_solve_powerflow.argtypes = (c_char_p, c_uint) + libsteps.api_is_powerflow_converged.restype = (c_bool) + libsteps.api_is_powerflow_converged.argtypes = (c_uint, ) + libsteps.api_show_powerflow_result.restype = None + libsteps.api_show_powerflow_result.argtypes = (c_uint, ) + libsteps.api_save_powerflow_result.restype = None + libsteps.api_save_powerflow_result.argtypes = (c_char_p, c_uint) + libsteps.api_save_extended_powerflow_result.restype = None + libsteps.api_save_extended_powerflow_result.argtypes = (c_char_p, c_uint) + libsteps.api_save_jacobian_matrix.restype = None + libsteps.api_save_jacobian_matrix.argtypes = (c_char_p, c_uint) + + libsteps.api_build_network_matrix.restype = None + libsteps.api_build_network_matrix.argtypes = (c_uint, ) + libsteps.api_build_decoupled_network_matrix.restype = None + libsteps.api_build_decoupled_network_matrix.argtypes = (c_uint, ) + libsteps.api_build_dc_network_matrix.restype = None + libsteps.api_build_dc_network_matrix.argtypes = (c_uint, ) + libsteps.api_build_dynamic_network_matrix.restype = None + libsteps.api_build_dynamic_network_matrix.argtypes = (c_uint, ) + libsteps.api_save_network_matrix.restype = None + libsteps.api_save_network_matrix.argtypes = (c_char_p, c_uint) + libsteps.api_save_decoupled_network_matrix.restype = None + libsteps.api_save_decoupled_network_matrix.argtypes = (c_char_p, c_uint) + libsteps.api_save_dc_network_matrix.restype = None + libsteps.api_save_dc_network_matrix.argtypes = (c_char_p, c_uint) + libsteps.api_save_dynamic_network_matrix.restype = None + libsteps.api_save_dynamic_network_matrix.argtypes = (c_char_p, c_uint) + + libsteps.api_get_dynamic_simulator_integer_parameter.restype = (c_uint) + libsteps.api_get_dynamic_simulator_integer_parameter.argtypes = (c_char_p, c_uint) + libsteps.api_get_dynamic_simulator_float_parameter.restype = (c_double) + libsteps.api_get_dynamic_simulator_float_parameter.argtypes = (c_char_p, c_uint) + libsteps.api_get_dynamic_simulator_string_parameter.restype = (c_char_p) + libsteps.api_get_dynamic_simulator_string_parameter.argtypes = (c_char_p, c_uint) + libsteps.api_get_dynamic_simulator_boolean_parameter.restype = (c_bool) + libsteps.api_get_dynamic_simulator_boolean_parameter.argtypes = (c_char_p, c_uint) + libsteps.api_set_dynamic_simulator_integer_parameter.restype = None + libsteps.api_set_dynamic_simulator_integer_parameter.argtypes = (c_char_p, c_int, c_uint) + libsteps.api_set_dynamic_simulator_float_parameter.restype = None + libsteps.api_set_dynamic_simulator_float_parameter.argtypes = (c_char_p, c_double, c_uint) + libsteps.api_set_dynamic_simulator_string_parameter.restype = None + libsteps.api_set_dynamic_simulator_string_parameter.argtypes = (c_char_p, c_char_p, c_uint) + libsteps.api_set_dynamic_simulator_boolean_parameter.restype = None + libsteps.api_set_dynamic_simulator_boolean_parameter.argtypes = (c_char_p, c_bool, c_uint) + libsteps.api_get_dynamic_simulator_output_file.restype = (c_char_p) + libsteps.api_get_dynamic_simulator_output_file.argtypes = (c_uint, ) + libsteps.api_set_dynamic_simulator_output_file.restype = None + libsteps.api_set_dynamic_simulator_output_file.argtypes = (c_char_p, c_uint) + + libsteps.api_get_dynamic_simulation_time_step.restype = (c_double) + libsteps.api_get_dynamic_simulation_time_step.argtypes = (c_uint, ) + libsteps.api_set_dynamic_simulation_time_step.restype = None + libsteps.api_set_dynamic_simulation_time_step.argtypes = (c_double, c_uint) + libsteps.api_get_dynamic_simulation_time.restype = (c_double) + libsteps.api_get_dynamic_simulation_time.argtypes = (c_uint, ) + + libsteps.api_prepare_meters.restype = None + libsteps.api_prepare_meters.argtypes = (c_uint, ) + libsteps.api_prepare_bus_related_meters.restype = None + libsteps.api_prepare_bus_related_meters.argtypes = (c_uint, ) + libsteps.api_prepare_generator_related_meters.restype = None + libsteps.api_prepare_generator_related_meters.argtypes = (c_uint, ) + libsteps.api_prepare_wt_generator_related_meters.restype = None + libsteps.api_prepare_wt_generator_related_meters.argtypes = (c_uint, ) + libsteps.api_prepare_pv_unit_related_meters.restype = None + libsteps.api_prepare_pv_unit_related_meters.argtypes = (c_uint, ) + libsteps.api_prepare_energy_storage_related_meters.restype = None + libsteps.api_prepare_energy_storage_related_meters.argtypes = (c_uint, ) + libsteps.api_prepare_load_related_meters.restype = None + libsteps.api_prepare_load_related_meters.argtypes = (c_uint, ) + libsteps.api_prepare_line_related_meters.restype = None + libsteps.api_prepare_line_related_meters.argtypes = (c_uint, ) + libsteps.api_prepare_hvdc_related_meters.restype = None + libsteps.api_prepare_hvdc_related_meters.argtypes = (c_uint, ) + libsteps.api_prepare_equivalent_device_related_meters.restype = None + libsteps.api_prepare_equivalent_device_related_meters.argtypes = (c_uint, ) + + + libsteps.api_prepare_bus_related_meter.restype = None + libsteps.api_prepare_bus_related_meter.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_prepare_generator_related_meter.restype = None + libsteps.api_prepare_generator_related_meter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_prepare_wt_generator_related_meter.restype = None + libsteps.api_prepare_wt_generator_related_meter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_prepare_pv_unit_related_meter.restype = None + libsteps.api_prepare_pv_unit_related_meter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_prepare_energy_storage_related_meter.restype = None + libsteps.api_prepare_energy_storage_related_meter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_prepare_load_related_meter.restype = None + libsteps.api_prepare_load_related_meter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_prepare_line_related_meter.restype = None + libsteps.api_prepare_line_related_meter.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_prepare_hvdc_related_meter.restype = None + libsteps.api_prepare_hvdc_related_meter.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_char_p, c_char_p, c_uint) + libsteps.api_prepare_equivalent_device_related_meter.restype = None + libsteps.api_prepare_equivalent_device_related_meter.argtypes = (c_uint, c_char_p, c_char_p, c_char_p, c_uint) + + libsteps.api_start_dynamic_simulation.restype = None + libsteps.api_start_dynamic_simulation.argtypes = (c_uint, ) + libsteps.api_stop_dynamic_simulation.restype = None + libsteps.api_stop_dynamic_simulation.argtypes = (c_uint, ) + libsteps.api_run_simulation_to_time.restype = None + libsteps.api_run_simulation_to_time.argtypes = (c_double, c_uint) + libsteps.api_run_a_step.restype = None + libsteps.api_run_a_step.argtypes = (c_uint, ) + + libsteps.api_set_bus_fault.restype = None + libsteps.api_set_bus_fault.argtypes = (c_uint, c_char_p, c_double, c_double, c_uint) + libsteps.api_clear_bus_fault.restype = None + libsteps.api_clear_bus_fault.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_trip_bus.restype = None + libsteps.api_trip_bus.argtypes = (c_uint, c_uint) + + libsteps.api_set_line_fault.restype = None + libsteps.api_set_line_fault.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_double, c_double, c_double, c_uint) + libsteps.api_clear_line_fault.restype = None + libsteps.api_clear_line_fault.argtypes = (c_uint, c_uint, c_char_p, c_char_p, c_double, c_uint) + libsteps.api_trip_line.restype = None + libsteps.api_trip_line.argtypes = (c_uint, c_uint, c_char_p, c_uint) + libsteps.api_trip_line_breaker.restype = None + libsteps.api_trip_line_breaker.argtypes = (c_uint, c_uint, c_char_p, c_uint) + libsteps.api_close_line.restype = None + libsteps.api_close_line.argtypes = (c_uint, c_uint, c_char_p, c_uint) + libsteps.api_close_line_breaker.restype = None + libsteps.api_close_line_breaker.argtypes = (c_uint, c_uint, c_char_p, c_uint) + + libsteps.api_trip_transformer.restype = None + libsteps.api_trip_transformer.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_uint) + libsteps.api_trip_transformer_breaker.restype = None + libsteps.api_trip_transformer_breaker.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_uint) + libsteps.api_close_transformer.restype = None + libsteps.api_close_transformer.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_uint) + libsteps.api_close_transformer_breaker.restype = None + libsteps.api_close_transformer_breaker.argtypes = (c_uint, c_uint, c_uint, c_char_p, c_uint) + + libsteps.api_trip_generator.restype = None + libsteps.api_trip_generator.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_shed_generator.restype = None + libsteps.api_shed_generator.argtypes = (c_uint, c_char_p, c_double, c_uint) + + libsteps.api_trip_load.restype = None + libsteps.api_trip_load.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_close_load.restype = None + libsteps.api_close_load.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_scale_load.restype = None + libsteps.api_scale_load.argtypes = (c_uint, c_char_p, c_double, c_uint) + libsteps.api_scale_all_loads.restype = None + libsteps.api_scale_all_loads.argtypes = (c_double, c_uint) + + libsteps.api_trip_fixed_shunt.restype = None + libsteps.api_trip_fixed_shunt.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_close_fixed_shunt.restype = None + libsteps.api_close_fixed_shunt.argtypes = (c_uint, c_char_p, c_uint) + + libsteps.api_manually_bypass_hvdc.restype = None + libsteps.api_manually_bypass_hvdc.argtypes = (c_uint, c_uint, c_char_p, c_uint) + libsteps.api_manually_unbypass_hvdc.restype = None + libsteps.api_manually_unbypass_hvdc.argtypes = (c_uint, c_uint, c_char_p, c_uint) + libsteps.api_manually_block_hvdc.restype = None + libsteps.api_manually_block_hvdc.argtypes = (c_uint, c_uint, c_char_p, c_uint) + libsteps.api_manually_unblock_hvdc.restype = None + libsteps.api_manually_unblock_hvdc.argtypes = (c_uint, c_uint, c_char_p, c_uint) + + libsteps.api_get_generator_voltage_reference_in_pu.restype = (c_double) + libsteps.api_get_generator_voltage_reference_in_pu.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_set_generator_voltage_reference_in_pu.restype = None + libsteps.api_set_generator_voltage_reference_in_pu.argtypes = (c_uint, c_char_p, c_double, c_uint) + + libsteps.api_get_generator_power_reference_in_MW.restype = (c_double) + libsteps.api_get_generator_power_reference_in_MW.argtypes = (c_uint, c_char_p, c_uint) + libsteps.api_set_generator_power_reference_in_MW.restype = None + libsteps.api_set_generator_power_reference_in_MW.argtypes = (c_uint, c_char_p, c_double, c_uint) + + libsteps.api_search_cct.restype = (c_double) + libsteps.api_search_cct.argtypes = (c_char_p, c_char_p, c_uint, c_uint, c_char_p, c_uint, c_uint, c_uint) + + return libsteps diff --git a/python/stepspy0.6/stepspy/stepspy.py b/python/stepspy0.6/stepspy/stepspy.py new file mode 100644 index 00000000..495b8e21 --- /dev/null +++ b/python/stepspy0.6/stepspy/stepspy.py @@ -0,0 +1,1969 @@ +pysteps_version = "0.6.0" +pysteps_date = "2019/05/15" +pysteps_author = (("Changgang Li", "lichangang@sdu.edu.cn"),("Yue Wu","sduyuewu2018@163.com")) + +from .libsteps import pylibsteps +from ctypes import c_char_p +import platform +global STEPS_LIB + +class STEPS(): + def __init__(self, is_default=False, log_file=""): + global STEPS_LIB + + if 'STEPS_LIB' not in globals(): + STEPS_LIB = pylibsteps.load_library() + + if is_default==True: + #STEPS_LIB.api_set_default_toolkit_log_file(log_file) + self.toolkit_index = 1000000000 + else: + log_file = self.__get_c_char_p_of_string(log_file) + self.toolkit_index = STEPS_LIB.api_generate_new_toolkit(log_file) + + def __del__(self): + global STEPS_LIB + if 'STEPS_LIB' in globals(): + STEPS_LIB.api_delete_toolkit(self.toolkit_index) + + def __extract_single_bus_device_id(self, did): + bus = did[0] + ickt = did[1] + return bus, ickt + + def __extract_double_bus_device_id(self, did): + ibus = did[0] + jbus = did[1] + ickt = did[2] + return ibus, jbus, ickt + + def __extract_triple_bus_device_id(self, did): + ibus = did[0] + jbus = did[1] + kbus = 0 + ickt = did[-1] + if len(did)>3: + kbus = did[2] + return ibus, jbus, kbus, ickt + + def __get_c_char_p_of_string(self, data): + python_version = platform.python_version_tuple() + python_version = python_version[0] + if python_version is '3': + return c_char_p(bytes(data, 'utf-8')) + elif python_version is '2': + return c_char_p(bytes(data)) + else: + return None + + def __get_string_from_c_char_p(self, data): + python_version = platform.python_version_tuple() + python_version = python_version[0] + if python_version is '3': + return str(data, encoding='utf-8') + elif python_version is '2': + return str(data) + else: + return None + + def clear_toolkit(self): + global STEPS_LIB + STEPS_LIB.api_clear_toolkit(self.toolkit_index) + return + + def terminate_toolkit(self): + global STEPS_LIB + STEPS_LIB = None + #STEPS_LIB.api_terminate_toolkit(self.toolkit_index) + return + + def get_toolkit_float_data(self, dataname): + global STEPS_LIB + dataname = self.__get_c_char_p_of_string(dataname) + return STEPS_LIB.api_get_toolkit_float_data(dataname, self.toolkit_index) + + def set_toolkit_float_data(self, dataname, value): + global STEPS_LIB + dataname = self.__get_c_char_p_of_string(dataname) + return STEPS_LIB.api_set_toolkit_float_data(dataname, value, self.toolkit_index) + + def get_system_base_power_in_MVA(self): + global STEPS_LIB + return self.get_toolkit_float_data("SBASE") + + def set_system_base_power_in_MVA(self, sbase): + global STEPS_LIB + return self.set_toolkit_float_data("SBASE", sbase) + + def get_toolkit_string_data(self, dataname): + global STEPS_LIB + dataname = self.__get_c_char_p_of_string(dataname) + return self.__get_source_data(STEPS_LIB.api_get_toolkit_string_data(dataname, self.toolkit_index)) + + def set_toolkit_string_data(self, dataname, value): + global STEPS_LIB + dataname = self.__get_c_char_p_of_string(dataname) + value = self.__get_c_char_p_of_string(value) + return self.__get_source_data(STEPS_LIB.api_set_toolkit_string_data(dataname, value, self.toolkit_index)) + + def get_case_information(self): + global STEPS_LIB + return self.__get_source_data(self.get_toolkit_string_data("CASE INFORMATION")) + + def get_case_additional_information(self): + global STEPS_LIB + return self.__get_source_data(self.get_toolkit_string_data("CASE ADDITIONAL INFORMATION")) + + def set_case_information(self, value): + global STEPS_LIB + return self.set_toolkit_string_data("CASE INFORMATION", value) + + def set_case_additional_information(self, value): + global STEPS_LIB + return self.set_toolkit_string_data("CASE ADDITIONAL INFORMATION", value) + + def get_toolkit_bool_data(self, dataname): + global STEPS_LIB + dataname = self.__get_c_char_p_of_string(dataname) + return STEPS_LIB.api_get_toolkit_bool_data(dataname, self.toolkit_index) + + def set_toolkit_bool_data(self, dataname, value): + global STEPS_LIB + dataname = self.__get_c_char_p_of_string(dataname) + return STEPS_LIB.api_set_toolkit_bool_data(dataname, value, self.toolkit_index) + + def get_toolkit_detailed_log_logic(self): + global STEPS_LIB + return self.get_toolkit_bool_data("DETAILED LOG LOGIC") + + def set_toolkit_detailed_log_logic(self, logic): + global STEPS_LIB + return self.set_toolkit_bool_data("DETAILED LOG LOGIC", logic) + + + def get_allowed_maximum_bus_number(self): + global STEPS_LIB + return int(STEPS_LIB.api_get_allowed_maximum_bus_number(self.toolkit_index)) + + def set_allowed_maximum_bus_number(self, max_bus_number): + global STEPS_LIB + STEPS_LIB.api_set_allowed_maximum_bus_number(max_bus_number, self.toolkit_index) + + def load_powerflow_data(self, file, ftype): + global STEPS_LIB + file = self.__get_c_char_p_of_string(file) + ftype = self.__get_c_char_p_of_string(ftype) + STEPS_LIB.api_load_powerflow_data_from_file(file, ftype, self.toolkit_index) + + def save_powerflow_data(self, file, ftype, export_zero_line=True, export_out_of_service_bus=True): + global STEPS_LIB + file = self.__get_c_char_p_of_string(file) + ftype = self.__get_c_char_p_of_string(ftype) + STEPS_LIB.api_save_powerflow_data_to_file(file, ftype, export_zero_line, export_out_of_service_bus, self.toolkit_index) + + def load_dynamic_data(self, file, ftype): + global STEPS_LIB + file = self.__get_c_char_p_of_string(file) + ftype = self.__get_c_char_p_of_string(ftype) + STEPS_LIB.api_load_dynamic_data_from_file(file, ftype, self.toolkit_index) + + def save_dynamic_data(self, file, ftype): + global STEPS_LIB + file = self.__get_c_char_p_of_string(file) + ftype = self.__get_c_char_p_of_string(ftype) + STEPS_LIB.api_save_dynamic_data_to_file(file, ftype, self.toolkit_index) + + def check_database(self): + global STEPS_LIB + STEPS_LIB.api_check_database(self.toolkit_index) + + def check_dynamic_data(self): + global STEPS_LIB + STEPS_LIB.api_check_dynamic_data(self.toolkit_index) + + def check_network_connectivity(self, remove_void_islands=False): + global STEPS_LIB + STEPS_LIB.api_check_network_connectivity(remove_void_islands, self.toolkit_index) + + def get_bus_capacity(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("BUS") + return int(STEPS_LIB.api_get_device_capacity(device, self.toolkit_index)) + def get_generator_capacity(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Generator") + return int(STEPS_LIB.api_get_device_capacity(device, self.toolkit_index)) + def get_wt_generator_capacity(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("WT Generator") + return int(STEPS_LIB.api_get_device_capacity(device, self.toolkit_index)) + def get_pv_unit_capacity(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("PV Unit") + return int(STEPS_LIB.api_get_device_capacity(device, self.toolkit_index)) + def get_load_capacity(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Load") + return int(STEPS_LIB.api_get_device_capacity(device, self.toolkit_index)) + def get_fixed_shunt_capacity(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Fixed Shunt") + return int(STEPS_LIB.api_get_device_capacity(device, self.toolkit_index)) + def get_line_capacity(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Line") + return int(STEPS_LIB.api_get_device_capacity(device, self.toolkit_index)) + def get_transformer_capacity(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Transformer") + return int(STEPS_LIB.api_get_device_capacity(device, self.toolkit_index)) + def get_hvdc_capacity(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("HVDC") + return int(STEPS_LIB.api_get_device_capacity(device, self.toolkit_index)) + def get_equivalent_device_capacity(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Equivalent Device") + return int(STEPS_LIB.api_get_device_capacity(device, self.toolkit_index)) + def get_energy_storage_capacity(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Energy Storage") + return int(STEPS_LIB.api_get_device_capacity(device, self.toolkit_index)) + def get_area_capacity(self): + global STEPS_LIB + return int(STEPS_LIB.api_get_area_capacity(self.toolkit_index)) + def get_zone_capacity(self): + global STEPS_LIB + return int(STEPS_LIB.api_get_zone_capacity(self.toolkit_index)) + def get_owner_capacity(self): + global STEPS_LIB + return int(STEPS_LIB.api_get_owner_capacity(self.toolkit_index)) + + def set_bus_capacity(self, capacity): + global STEPS_LIB + device = self.__get_c_char_p_of_string("BUS") + return STEPS_LIB.api_set_device_capacity("BUS", capacity, self.toolkit_index) + def set_generator_capacity(self, capacity): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Generator") + return STEPS_LIB.api_set_device_capacity(device, capacity, self.toolkit_index) + def set_wt_generator_capacity(self, capacity): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Wt Generator") + return STEPS_LIB.api_set_device_capacity(device, capacity, self.toolkit_index) + def set_pv_unit_capacity(self, capacity): + global STEPS_LIB + device = self.__get_c_char_p_of_string("PV Unit") + return STEPS_LIB.api_set_device_capacity(device, capacity, self.toolkit_index) + def set_load_capacity(self, capacity): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Load") + return STEPS_LIB.api_set_device_capacity(device, capacity, self.toolkit_index) + def set_fixed_shunt_capacity(self, capacity): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Fixed Shunt") + return STEPS_LIB.api_set_device_capacity(device, capacity, self.toolkit_index) + def set_line_capacity(self, capacity): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Line") + return STEPS_LIB.api_set_device_capacity(device, capacity, self.toolkit_index) + def set_transformer_capacity(self, capacity): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Transformer") + return STEPS_LIB.api_set_device_capacity(device, capacity, self.toolkit_index) + def set_hvdc_capacity(self, capacity): + global STEPS_LIB + device = self.__get_c_char_p_of_string("HVDC") + return STEPS_LIB.api_set_device_capacity(device, capacity, self.toolkit_index) + def set_equivalent_device_capacity(self, capacity): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Equivalent Device") + return STEPS_LIB.api_set_device_capacity(device, capacity, self.toolkit_index) + def set_energy_storage_capacity(self, capacity): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Energy Storage") + return STEPS_LIB.api_set_device_capacity(device, capacity, self.toolkit_index) + def set_area_capacity(self, capacity): + global STEPS_LIB + return STEPS_LIB.api_set_area_capacity(capacity, self.toolkit_index) + def set_zone_capacity(self, capacity): + global STEPS_LIB + return STEPS_LIB.api_set_zone_capacity(capacity, self.toolkit_index) + def set_owner_capacity(self, capacity): + global STEPS_LIB + return STEPS_LIB.api_set_owner_capacity(capacity, self.toolkit_index) + + + def add_bus(self, busnumber, busname, basevoltage): + global STEPS_LIB + busname = self.__get_c_char_p_of_string(busname) + STEPS_LIB.api_add_bus(busnumber, busname, basevoltage, self.toolkit_index) + return + + def add_generator(self, generator): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_add_generator(bus, ickt, self.toolkit_index) + return + + def add_wt_generator(self, generator): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_add_wt_generator(bus, ickt, self.toolkit_index) + + def add_pv_unit(self, unit): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(unit) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_add_pv_unit(bus, ickt, self.toolkit_index) + return + + def add_load(self, load): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(load) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_add_load(bus, ickt, self.toolkit_index) + return + + def add_fixed_shunt(self, shunt): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(shunt) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_add_fixed_shunt(bus, ickt, self.toolkit_index) + return + + def add_line(self, line): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_add_line(ibus, jbus, ickt, self.toolkit_index) + return + + def add_hvdc(self, hvdc): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(hvdc) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_add_hvdc(ibus, jbus, ickt, self.toolkit_index) + return + + def add_transformer(self, transformer): + global STEPS_LIB + ibus, jbus, kbus, ickt = self.__extract_triple_bus_device_id(transformer) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_add_transformer(ibus, jbus, kbus, ickt, self.toolkit_index) + return + + def add_equivalent_device(self, device): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(device) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_add_equivalent_device(bus, ickt, self.toolkit_index) + return + + def add_energy_storage(self, storage): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(storage) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_add_energy_storage(bus, ickt, self.toolkit_index) + return + + def add_area(self, areanumber, areaname): + global STEPS_LIB + areaname = self.__get_c_char_p_of_string(areaname) + STEPS_LIB.api_add_area(areanumber, areaname, self.toolkit_index) + return + + def add_zone(self, zonenumber, zonename): + global STEPS_LIB + zonename = self.__get_c_char_p_of_string(zonename) + STEPS_LIB.api_add_zone(zonenumber, zonename, self.toolkit_index) + return + + def add_owner(self, ownernumber, ownername): + global STEPS_LIB + ownername = self.__get_c_char_p_of_string(ownername) + STEPS_LIB.api_add_owner(ownernumber, ownername, self.toolkit_index) + return + + def remove_bus(self, busnumber): + global STEPS_LIB + STEPS_LIB.api_remove_bus(busnumber, self.toolkit_index) + return + + def remove_generator(self, generator): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_remove_generator(bus, ickt, self.toolkit_index) + return + + def remove_wt_generator(self, generator): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_remove_wt_generator(bus, ickt, self.toolkit_index) + return + + def remove_pv_unit(self, unit): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(unit) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_remove_pv_unit(bus, ickt, self.toolkit_index) + return + + def remove_load(self, load): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(load) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_remove_load(bus, ickt, self.toolkit_index) + return + + def remove_fixed_shunt(self, shunt): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(shunt) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_remove_fixed_shunt(bus, ickt, self.toolkit_index) + return + + def remove_line(self, line): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_remove_line(ibus, jbus, ickt, self.toolkit_index) + return + + def remove_hvdc(self, hvdc): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(hvdc) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_remove_hvdc(ibus, jbus, ickt, self.toolkit_index) + return + + def remove_transformer(self, transformer): + global STEPS_LIB + ibus, jbus, kbus, ickt = self.__extract_triple_bus_device_id(transformer) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_remove_transformer(ibus, jbus, kbus, ickt, self.toolkit_index) + return + + def remove_equivalent_device(self, device): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(device) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_remove_equivalent_device(bus, ickt, self.toolkit_index) + return + + def remove_energy_storage(self, storage): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(storage) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_remove_energy_storage(bus, ickt, self.toolkit_index) + return + + def remove_area(self, areanumber): + global STEPS_LIB + STEPS_LIB.api_remove_area(areanumber, self.toolkit_index) + return + + def remove_zone(self, zonenumber): + global STEPS_LIB + STEPS_LIB.api_remove_zone(zonenumber, self.toolkit_index) + return + + def remove_owner(self, ownernumber): + global STEPS_LIB + STEPS_LIB.api_remove_owner(ownernumber, self.toolkit_index) + return + + def get_bus_count(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("BUS") + return STEPS_LIB.api_get_device_count(device, self.toolkit_index) + def get_generator_count(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Generator") + return STEPS_LIB.api_get_device_count(device, self.toolkit_index) + def get_wt_generator_count(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("WT Generator") + return STEPS_LIB.api_get_device_count(device, self.toolkit_index) + def get_pv_unit_count(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("PV Unit") + return STEPS_LIB.api_get_device_count(device, self.toolkit_index) + def get_load_count(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Load") + return STEPS_LIB.api_get_device_count(device, self.toolkit_index) + def get_fixed_shunt_count(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Fixed Shunt") + return STEPS_LIB.api_get_device_count(device, self.toolkit_index) + def get_line_count(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Line") + return STEPS_LIB.api_get_device_count(device, self.toolkit_index) + def get_transformer_count(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Transformer") + return STEPS_LIB.api_get_device_count(device, self.toolkit_index) + def get_hvdc_count(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("HVDC") + return STEPS_LIB.api_get_device_count(device, self.toolkit_index) + def get_equivalent_device_count(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Equivalent Device") + return STEPS_LIB.api_get_device_count(device, self.toolkit_index) + def get_energy_storage_count(self): + global STEPS_LIB + device = self.__get_c_char_p_of_string("Energy Storage") + return STEPS_LIB.api_get_device_count(device, self.toolkit_index) + def get_area_count(self): + global STEPS_LIB + return STEPS_LIB.api_get_area_count(self.toolkit_index) + def get_zone_count(self): + global STEPS_LIB + return STEPS_LIB.api_get_zone_count(self.toolkit_index) + def get_owner_count(self): + global STEPS_LIB + return STEPS_LIB.api_get_owner_count(self.toolkit_index) + def get_in_service_bus_count(self): + global STEPS_LIB + STEPS_LIB.api_get_in_service_bus_count(self.toolkit_index) + return + def update_overshadowed_buses(self): + global STEPS_LIB + return STEPS_LIB.api_update_overshadowed_buses(self.toolkit_index) + def set_all_buses_un_overshadowed(self): + global STEPS_LIB + STEPS_LIB.api_set_all_buses_un_overshadowed(self.toolkit_index) + return + def get_overshadowed_bus_count(self): + global STEPS_LIB + return STEPS_LIB.api_get_overshadowed_bus_count(self.toolkit_index) + + def is_bus_exist(self, bus): + global STEPS_LIB + return STEPS_LIB.api_is_bus_exist(bus, self.toolkit_index) + + def is_generator_exist(self, generator): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_is_generator_exist(bus, ickt, self.toolkit_index) + + def is_wt_generator_exist(self, generator): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_is_wt_generator_exist(bus, ickt, self.toolkit_index) + + def is_pv_unit_exist(self, pv_unit): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(pv_unit) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_is_pv_unit_exist(bus, ickt, self.toolkit_index) + + def is_load_exist(self, load): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(load) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_is_load_exist(bus, ickt, self.toolkit_index) + + def is_fixed_shunt_exist(self, shunt): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(shunt) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_is_fixed_shunt_exist(bus, ickt, self.toolkit_index) + + def is_line_exist(self, line): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_is_line_exist(ibus, jbus, ickt, self.toolkit_index) + + def is_transformer_exist(self, transformer): + global STEPS_LIB + ibus, jbus, kbus, ickt = self.__extract_triple_bus_device_id(transformer) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_is_transformer_exist(ibus, jbus, kbus, ickt, self.toolkit_index) + + def is_hvdc_exist(self, hvdc): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(hvdc) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_is_hvdc_exist(ibus, jbus, ickt, self.toolkit_index) + + def is_equivalent_device_exist(self, equivalent_device): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(equivalent_device) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_is_equivalent_device_exist(bus, ickt, self.toolkit_index) + + def is_energy_storage_exist(self, energy_storage): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(energy_storage) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_is_energy_storage_exist(bus, ickt, self.toolkit_index) + + def bus_name2number(self, name): + global STEPS_LIB + name = self.__get_c_char_p_of_string(name) + return int(STEPS_LIB.api_bus_name2bus_number(name, self.toolkit_index)) + + def bus_number2name(self, bus): + global STEPS_LIB + return self.__get_string_from_c_char_p(STEPS_LIB.api_bus_number2bus_name(bus, self.toolkit_index)) + + def get_all_buses(self): + global STEPS_LIB + STEPS_LIB.api_initialize_all_bus_search(self.toolkit_index) + buses = [] + while True: + bus = STEPS_LIB.api_get_current_bus_number(self.toolkit_index) + if bus==0: + break + buses.append(int(bus)) + STEPS_LIB.api_goto_next_bus(self.toolkit_index) + return tuple(buses) + + def get_buses_with_constraints(self, constraints): + global STEPS_LIB + buses = [] + if len(constraints)<7: + return buses + vbase_min = constraints[0] + vbase_max = constraints[1] + v_min = constraints[2] + v_max = constraints[3] + area = constraints[4] + zone = constraints[5] + owner = constraints[6] + + STEPS_LIB.api_initialize_bus_search(vbase_min, vbase_max, v_min, v_max, area, zone, owner, self.toolkit_index) + while True: + bus = STEPS_LIB.api_get_current_bus_number(self.toolkit_index) + if bus==0: + break + buses.append(int(bus)) + STEPS_LIB.api_goto_next_bus(self.toolkit_index) + return tuple(buses) + + def get_generators_at_bus(self, bus): + global STEPS_LIB + device = "GENERATOR" + device = self.__get_c_char_p_of_string(device) + blank = self.__get_c_char_p_of_string("") + STEPS_LIB.api_initialize_device_search(device, bus, self.toolkit_index) + generators = [] + while True: + bus = STEPS_LIB.api_get_current_device_bus_number(device, blank, self.toolkit_index) + if bus==0: + break + id = STEPS_LIB.api_get_current_device_identifier(device, self.toolkit_index) + id = self.__get_string_from_c_char_p(id) + generators.append((int(bus), id)) + STEPS_LIB.api_goto_next_device(device, self.toolkit_index) + return tuple(generators) + + def get_wt_generators_at_bus(self, bus): + global STEPS_LIB + device = "WT GENERATOR" + device = self.__get_c_char_p_of_string(device) + blank = self.__get_c_char_p_of_string("") + STEPS_LIB.api_initialize_device_search(device, bus, self.toolkit_index) + wt_generators = [] + while True: + bus = STEPS_LIB.api_get_current_device_bus_number(device, blank, self.toolkit_index) + if bus==0: + break + id = STEPS_LIB.api_get_current_device_identifier(device, self.toolkit_index) + id = self.__get_string_from_c_char_p(id) + wt_generators.append((int(bus), id)) + STEPS_LIB.api_goto_next_device(device, self.toolkit_index) + return tuple(wt_generators) + + def get_pv_units_at_bus(self, bus): + global STEPS_LIB + device = "PV UNIT" + device = self.__get_c_char_p_of_string(device) + blank = self.__get_c_char_p_of_string("") + STEPS_LIB.api_initialize_device_search(device, bus, self.toolkit_index) + pv_units = [] + while True: + bus = STEPS_LIB.api_get_current_device_bus_number(device, blank, self.toolkit_index) + if bus==0: + break + id = STEPS_LIB.api_get_current_device_identifier(device, self.toolkit_index) + id = self.__get_string_from_c_char_p(id) + pv_units.append((int(bus), id)) + STEPS_LIB.api_goto_next_device(device, self.toolkit_index) + return tuple(pv_units) + + def get_loads_at_bus(self, bus): + global STEPS_LIB + device = "LOAD" + device = self.__get_c_char_p_of_string(device) + blank = self.__get_c_char_p_of_string("") + STEPS_LIB.api_initialize_device_search(device, bus, self.toolkit_index) + loads = [] + while True: + bus = STEPS_LIB.api_get_current_device_bus_number(device, blank, self.toolkit_index) + if bus==0: + break + id = STEPS_LIB.api_get_current_device_identifier(device, self.toolkit_index) + id = self.__get_string_from_c_char_p(id) + loads.append((int(bus), id)) + STEPS_LIB.api_goto_next_device(device, self.toolkit_index) + return tuple(loads) + + def get_fixed_shunts_at_bus(self, bus): + global STEPS_LIB + device = "FIXED SHUNT" + device = self.__get_c_char_p_of_string(device) + blank = self.__get_c_char_p_of_string("") + STEPS_LIB.api_initialize_device_search(device, bus, self.toolkit_index) + fixed_shunts = [] + while True: + bus = STEPS_LIB.api_get_current_device_bus_number(device, blank, self.toolkit_index) + if bus==0: + break + id = STEPS_LIB.api_get_current_device_identifier(device, self.toolkit_index) + id = self.__get_string_from_c_char_p(id) + fixed_shunts.append((int(bus), id)) + STEPS_LIB.api_goto_next_device(device, self.toolkit_index) + return tuple(fixed_shunts) + + def get_equivalent_devices_at_bus(self, bus): + global STEPS_LIB + device = "EQUIVALENT DEVICE" + device = self.__get_c_char_p_of_string(device) + blank = self.__get_c_char_p_of_string("") + STEPS_LIB.api_initialize_device_search(device, bus, self.toolkit_index) + equivalent_devices = [] + while True: + bus = STEPS_LIB.api_get_current_device_bus_number(device, blank, self.toolkit_index) + if bus==0: + break + id = STEPS_LIB.api_get_current_device_identifier(device, self.toolkit_index) + id = self.__get_string_from_c_char_p(id) + equivalent_devices.append((int(bus), id)) + STEPS_LIB.api_goto_next_device(device, self.toolkit_index) + return tuple(equivalent_devices) + + def get_energy_storages_at_bus(self, bus): + global STEPS_LIB + device = "ENERGY STORAGE" + device = self.__get_c_char_p_of_string(device) + blank = self.__get_c_char_p_of_string("") + STEPS_LIB.api_initialize_device_search(device, bus, self.toolkit_index) + energy_storages = [] + while True: + bus = STEPS_LIB.api_get_current_device_bus_number(device, blank, self.toolkit_index) + if bus==0: + break + id = STEPS_LIB.api_get_current_device_identifier(device, self.toolkit_index) + id = self.__get_string_from_c_char_p(id) + energy_storages.append((int(bus), id)) + STEPS_LIB.api_goto_next_device(device, self.toolkit_index) + return tuple(energy_storages) + + def get_lines_at_bus(self, bus): + global STEPS_LIB + device = "LINE" + device = self.__get_c_char_p_of_string(device) + send_side = self.__get_c_char_p_of_string("SEND") + recv_side = self.__get_c_char_p_of_string("RECEIVE") + STEPS_LIB.api_initialize_device_search(device, bus, self.toolkit_index) + lines = [] + while True: + ibus = STEPS_LIB.api_get_current_device_bus_number(device, send_side, self.toolkit_index) + if ibus==0: + break + jbus = STEPS_LIB.api_get_current_device_bus_number(device, recv_side, self.toolkit_index) + id = STEPS_LIB.api_get_current_device_identifier(device, self.toolkit_index) + id = self.__get_string_from_c_char_p(id) + lines.append((int(ibus), int(jbus), id)) + STEPS_LIB.api_goto_next_device(device, self.toolkit_index) + return tuple(lines) + + def get_transformers_at_bus(self, bus): + global STEPS_LIB + device = "TRANSFORMER" + device = self.__get_c_char_p_of_string(device) + pri_side = self.__get_c_char_p_of_string("PRIMARY") + sec_side = self.__get_c_char_p_of_string("SECONDARY") + ter_side = self.__get_c_char_p_of_string("TERTIARY") + STEPS_LIB.api_initialize_device_search(device, bus, self.toolkit_index) + transformers = [] + while True: + ibus = STEPS_LIB.api_get_current_device_bus_number(device, pri_side, self.toolkit_index) + if ibus==0: + break + jbus = STEPS_LIB.api_get_current_device_bus_number(device, sec_side, self.toolkit_index) + kbus = STEPS_LIB.api_get_current_device_bus_number(device, ter_side, self.toolkit_index) + id = STEPS_LIB.api_get_current_device_identifier(device, self.toolkit_index) + id = self.__get_string_from_c_char_p(id) + transformers.append((int(ibus), int(jbus), int(kbus), id)) + STEPS_LIB.api_goto_next_device(device, self.toolkit_index) + return tuple(transformers) + + def get_hvdcs_at_bus(self, bus): + global STEPS_LIB + device = "HVDC" + device = self.__get_c_char_p_of_string(device) + rec_side = self.__get_c_char_p_of_string("RECTIFIER") + inv_side = self.__get_c_char_p_of_string("INVERTER") + STEPS_LIB.api_initialize_device_search(device, bus, self.toolkit_index) + hvdcs = [] + while True: + ibus = STEPS_LIB.api_get_current_device_bus_number(device, rec_side, self.toolkit_index) + if ibus==0: + break + jbus = STEPS_LIB.api_get_current_device_bus_number(device, inv_side, self.toolkit_index) + id = STEPS_LIB.api_get_current_device_identifier(device, self.toolkit_index) + id = self.__get_string_from_c_char_p(id) + hvdcs.append((int(ibus), int(jbus), id)) + STEPS_LIB.api_goto_next_device(device, self.toolkit_index) + return tuple(hvdcs) + + def get_areas(self): + global STEPS_LIB + STEPS_LIB.api_initialize_area_search(self.toolkit_index) + areas = [] + while True: + area = STEPS_LIB.api_get_current_area_number(self.toolkit_index) + if area==0: + break + areas.append(int(area)) + STEPS_LIB.api_goto_next_area(self.toolkit_index) + return tuple(areas) + + def get_zones(self): + global STEPS_LIB + STEPS_LIB.api_initialize_zone_search(self.toolkit_index) + zones = [] + while True: + zone = STEPS_LIB.api_get_current_zone_number(self.toolkit_index) + if zone==0: + break + zones.append(int(zone)) + STEPS_LIB.api_goto_next_zone(self.toolkit_index) + return tuple(zones) + + def get_owners(self): + global STEPS_LIB + STEPS_LIB.api_initialize_owner_search(self.toolkit_index) + owners = [] + while True: + owner = STEPS_LIB.api_get_current_owner_number(self.toolkit_index) + if owner==0: + break + owners.append(int(owner)) + STEPS_LIB.api_goto_next_owner(self.toolkit_index) + return tuple(owners) + + def get_bus_data(self, bus, par_type, par_name): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return None + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return int(STEPS_LIB.api_get_bus_integer_data(bus, par_name, self.toolkit_index)) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_get_bus_float_data(bus, par_name, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_get_bus_boolean_data(bus, par_name, self.toolkit_index) + if par_type in ['S', 'STRING']: + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_bus_string_data(bus, par_name, self.toolkit_index)) + return None + + def __get_source_data(self, source, par_type, par_name): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return None + bus, ickt = self.__extract_single_bus_device_id(source) + ickt = self.__get_c_char_p_of_string(ickt) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return int(STEPS_LIB.api_get_source_integer_data(bus, ickt, par_name, self.toolkit_index)) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_get_source_float_data(bus, ickt, par_name, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_get_source_boolean_data(bus, ickt, par_name, self.toolkit_index) + if par_type in ['S', 'STRING']: + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_source_string_data(bus, ickt, par_name, self.toolkit_index)) + return None + + def get_generator_data(self, generator, par_type, par_name): + global STEPS_LIB + return self.__get_source_data(generator, par_type, par_name) + + def get_wt_generator_data(self, wt_generator, par_type, par_name): + global STEPS_LIB + return self.__get_source_data(wt_generator, par_type, par_name) + + def get_pv_unit_data(self, pv_unit, par_type, par_name): + global STEPS_LIB + return self.__get_source_data(pv_unit, par_type, par_name) + + def get_energy_storage_data(self, energy_storage, par_type, par_name): + global STEPS_LIB + return self.__get_source_data(energy_storage, par_type, par_name) + + def get_load_data(self, load, par_type, par_name): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return None + bus, ickt = self.__extract_single_bus_device_id(load) + ickt = self.__get_c_char_p_of_string(ickt) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return int(STEPS_LIB.api_get_load_integer_data(bus, ickt, par_name, self.toolkit_index)) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_get_load_float_data(bus, ickt, par_name, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_get_load_boolean_data(bus, ickt, par_name, self.toolkit_index) + if par_type in ['S', 'STRING']: + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_load_string_data(bus, ickt, par_name, self.toolkit_index)) + return None + + def get_fixed_shunt_data(self, fixed_shunt, par_type, par_name): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return None + bus, ickt = self.__extract_single_bus_device_id(fixed_shunt) + ickt = self.__get_c_char_p_of_string(ickt) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return int(STEPS_LIB.api_get_fixed_shunt_integer_data(bus, ickt, par_name, self.toolkit_index)) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_get_fixed_shunt_float_data(bus, ickt, par_name, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_get_fixed_shunt_boolean_data(bus, ickt, par_name, self.toolkit_index) + if par_type in ['S', 'STRING']: + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_fixed_shunt_string_data(bus, ickt, par_name, self.toolkit_index)) + return None + + def get_equivalent_device_data(self, equivalent_device, par_type, par_name): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return None + bus, ickt = self.__extract_single_bus_device_id(equivalent_device) + ickt = self.__get_c_char_p_of_string(ickt) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return int(STEPS_LIB.api_get_equivalent_device_integer_data(bus, ickt, par_name, self.toolkit_index)) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_get_equivalent_device_float_data(bus, ickt, par_name, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_get_equivalent_device_boolean_data(bus, ickt, par_name, self.toolkit_index) + if par_type in ['S', 'STRING']: + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_equivalent_device_string_data(bus, ickt, par_name, self.toolkit_index)) + return None + + def get_line_data(self, line, par_type, par_name): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return None + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return int(STEPS_LIB.api_get_line_integer_data(ibus, jbus, ickt, par_name, self.toolkit_index)) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_get_line_float_data(ibus, jbus, ickt, par_name, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_get_line_boolean_data(ibus, jbus, ickt, par_name, self.toolkit_index) + if par_type in ['S', 'STRING']: + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_line_string_data(ibus, jbus, ickt, par_name, self.toolkit_index)) + return None + + def get_transformer_data(self, transformer, par_type, side, par_name): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return None + side = side.upper() + if side not in ['PRIMARY', 'SECONDARY', 'TERTIARY', 'TRANSFORMER']: + return None + ibus, jbus, kbus, ickt = self.__extract_triple_bus_device_id(transformer) + ickt = self.__get_c_char_p_of_string(ickt) + side = self.__get_c_char_p_of_string(side) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return int(STEPS_LIB.api_get_transformer_integer_data(ibus, jbus, kbus, ickt, side, par_name, self.toolkit_index)) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_get_transformer_float_data(ibus, jbus, kbus, ickt, side, par_name, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_get_transformer_boolean_data(ibus, jbus, kbus, ickt, side, par_name, self.toolkit_index) + if par_type in ['S', 'STRING']: + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_transformer_string_data(ibus, jbus, kbus, ickt, side, par_name, self.toolkit_index)) + return None + + def get_hvdc_data(self, hvdc, par_type, side, par_name): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return None + side = side.upper() + if side not in ['RECTIFIER', 'INVERTER', 'HVDC']: + return None + ibus, jbus, ickt = self.__extract_double_bus_device_id(hvdc) + ickt = self.__get_c_char_p_of_string(ickt) + side = self.__get_c_char_p_of_string(side) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return int(STEPS_LIB.api_get_hvdc_integer_data(ibus, jbus, ickt, side, par_name, self.toolkit_index)) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_get_hvdc_float_data(ibus, jbus, ickt, side, par_name, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_get_hvdc_boolean_data(ibus, jbus, ickt, side, par_name, self.toolkit_index) + if par_type in ['S', 'STRING']: + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_hvdc_string_data(ibus, jbus, ickt, side, par_name, self.toolkit_index)) + return None + + def get_area_data(self, area, par_type, par_name): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return None + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return int(STEPS_LIB.api_get_area_integer_data(area, par_name, self.toolkit_index)) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_get_area_float_data(area, par_name, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_get_area_boolean_data(area, par_name, self.toolkit_index) + if par_type in ['S', 'STRING']: + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_area_string_data(area, par_name, self.toolkit_index)) + return None + + def get_zone_data(self, zone, par_type, par_name): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return None + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return int(STEPS_LIB.api_get_zone_integer_data(zone, par_name, self.toolkit_index)) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_get_zone_float_data(zone, par_name, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_get_zone_boolean_data(zone, par_name, self.toolkit_index) + if par_type in ['S', 'STRING']: + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_zone_string_data(zone, par_name, self.toolkit_index)) + return None + + def get_owner_data(self, owner, par_type, par_name): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return None + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return int(STEPS_LIB.api_get_owner_integer_data(owner, par_name, self.toolkit_index)) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_get_owner_float_data(owner, par_name, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_get_owner_boolean_data(owner, par_name, self.toolkit_index) + if par_type in ['S', 'STRING']: + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_owner_string_data(owner, par_name, self.toolkit_index)) + return None + + + def set_bus_data(self, bus, par_type, par_name, value): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + STEPS_LIB.api_set_bus_integer_data(bus, par_name, value, self.toolkit_index) + return + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_set_bus_float_data(bus, par_name, value, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_set_bus_boolean_data(bus, par_name, value, self.toolkit_index) + if par_type in ['S', 'STRING']: + value = self.__get_c_char_p_of_string(value) + return STEPS_LIB.api_set_bus_string_data(bus, par_name, value, self.toolkit_index) + return + + def __set_source_data(self, source, par_type, par_name, value): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return + bus, ickt = self.__extract_single_bus_device_id(source) + ickt = self.__get_c_char_p_of_string(ickt) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return STEPS_LIB.api_set_source_integer_data(bus, ickt, par_name, value, self.toolkit_index) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_set_source_float_data(bus, ickt, par_name, value, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_set_source_boolean_data(bus, ickt, par_name, value, self.toolkit_index) + if par_type in ['S', 'STRING']: + value = self.__get_c_char_p_of_string(value) + return STEPS_LIB.api_set_source_string_data(bus, ickt, par_name, value, self.toolkit_index) + return + + def set_generator_data(self, generator, par_type, par_name, value): + global STEPS_LIB + return self.__set_source_data(generator, par_type, par_name, value) + + def set_wt_generator_data(self, wt_generator, par_type, par_name, value): + global STEPS_LIB + return self.__set_source_data(wt_generator, par_type, par_name, value) + + def set_pv_unit_data(self, pv_unit, par_type, par_name, value): + global STEPS_LIB + return self.__set_source_data(pv_unit, par_type, par_name, value) + + def set_energy_storage_data(self, energy_storage, par_type, par_name, value): + global STEPS_LIB + return self.__set_source_data(energy_storage, par_type, par_name, value) + + def set_load_data(self, load, par_type, par_name, value): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return + bus, ickt = self.__extract_single_bus_device_id(load) + ickt = self.__get_c_char_p_of_string(ickt) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return STEPS_LIB.api_set_load_integer_data(bus, ickt, par_name, value, self.toolkit_index) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_set_load_float_data(bus, ickt, par_name, value, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_set_load_boolean_data(bus, ickt, par_name, value, self.toolkit_index) + if par_type in ['S', 'STRING']: + value = self.__get_c_char_p_of_string(value) + return STEPS_LIB.api_set_load_string_data(bus, ickt, par_name, value, self.toolkit_index) + return + + def set_fixed_shunt_data(self, fixed_shunt, par_type, par_name, value): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return + bus, ickt = self.__extract_single_bus_device_id(fixed_shunt) + ickt = self.__get_c_char_p_of_string(ickt) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return STEPS_LIB.api_set_fixed_shunt_integer_data(bus, ickt, par_name, value, self.toolkit_index) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_set_fixed_shunt_float_data(bus, ickt, par_name, value, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_set_fixed_shunt_boolean_data(bus, ickt, par_name, value, self.toolkit_index) + if par_type in ['S', 'STRING']: + value = self.__get_c_char_p_of_string(value) + return STEPS_LIB.api_set_fixed_shunt_string_data(bus, ickt, par_name, value, self.toolkit_index) + return + + def set_equivalent_device_data(self, equivalent_device, par_type, par_name, value): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return + bus, ickt = self.__extract_single_bus_device_id(equivalent_device) + ickt = self.__get_c_char_p_of_string(ickt) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return STEPS_LIB.api_set_equivalent_device_integer_data(bus, ickt, par_name, value, self.toolkit_index) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_set_equivalent_device_float_data(bus, ickt, par_name, value, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_set_equivalent_device_boolean_data(bus, ickt, par_name, value, self.toolkit_index) + if par_type in ['S', 'STRING']: + value = self.__get_c_char_p_of_string(value) + return STEPS_LIB.api_set_equivalent_device_string_data(bus, ickt, par_name, value, self.toolkit_index) + return + + def set_line_data(self, line, par_type, par_name, value): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return STEPS_LIB.api_set_line_integer_data(ibus, jbus, ickt, par_name, value, self.toolkit_index) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_set_line_float_data(ibus, jbus, ickt, par_name, value, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_set_line_boolean_data(ibus, jbus, ickt, par_name, value, self.toolkit_index) + if par_type in ['S', 'STRING']: + value = self.__get_c_char_p_of_string(value) + return STEPS_LIB.api_set_line_string_data(ibus, jbus, ickt, par_name, value, self.toolkit_index) + return + + def set_transformer_data(self, transformer, par_type, side, par_name, value): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return + ibus, jbus, kbus, ickt = self.__extract_triple_bus_device_id(transformer) + ickt = self.__get_c_char_p_of_string(ickt) + side = self.__get_c_char_p_of_string(side) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return STEPS_LIB.api_set_transformer_integer_data(ibus, jbus, kbus, ickt, side, par_name, value, self.toolkit_index) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_set_transformer_float_data(ibus, jbus, kbus, ickt, side, par_name, value, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_set_transformer_boolean_data(ibus, jbus, kbus, ickt, side, par_name, value, self.toolkit_index) + if par_type in ['S', 'STRING']: + value = self.__get_c_char_p_of_string(value) + return STEPS_LIB.api_set_transformer_string_data(ibus, jbus, kbus, ickt, side, par_name, value, self.toolkit_index) + return + + def set_hvdc_data(self, hvdc, par_type, side, par_name, value): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return + ibus, jbus, ickt = self.__extract_double_bus_device_id(hvdc) + ickt = self.__get_c_char_p_of_string(ickt) + side = self.__get_c_char_p_of_string(side) + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return STEPS_LIB.api_set_hvdc_integer_data(ibus, jbus, ickt, side, par_name, value, self.toolkit_index) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_set_hvdc_float_data(ibus, jbus, ickt, side, par_name, value, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_set_hvdc_boolean_data(ibus, jbus, ickt, side, par_name, value, self.toolkit_index) + if par_type in ['S', 'STRING']: + value = self.__get_c_char_p_of_string(value) + return STEPS_LIB.api_set_hvdc_string_data(ibus, jbus, ickt, side, par_name, value, self.toolkit_index) + return + + def set_area_data(self, area, par_type, par_name, value): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return STEPS_LIB.api_set_area_integer_data(area, par_name, value, self.toolkit_index) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_set_area_float_data(area, par_name, value, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_set_area_boolean_data(area, par_name, value, self.toolkit_index) + if par_type in ['S', 'STRING']: + value = self.__get_c_char_p_of_string(value) + return STEPS_LIB.api_set_area_string_data(area, par_name, value, self.toolkit_index) + return + + def set_zone_data(self, zone, par_type, par_name, value): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return STEPS_LIB.api_set_zone_integer_data(zone, par_name, value, self.toolkit_index) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_set_zone_float_data(zone, par_name, value, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_set_zone_boolean_data(zone, par_name, value, self.toolkit_index) + if par_type in ['S', 'STRING']: + value = self.__get_c_char_p_of_string(value) + return STEPS_LIB.api_set_zone_string_data(zone, par_name, value, self.toolkit_index) + return + + def set_owner_data(self, owner, par_type, par_name, value): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return STEPS_LIB.api_set_owner_integer_data(owner, par_name, value, self.toolkit_index) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_set_owner_float_data(owner, par_name, value, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_set_owner_boolean_data(owner, par_name, value, self.toolkit_index) + if par_type in ['S', 'STRING']: + value = self.__get_c_char_p_of_string(value) + return STEPS_LIB.api_set_owner_string_data(owner, par_name, value, self.toolkit_index) + return + + def set_dynamic_model(self, data, file_type): + global STEPS_LIB + data = self.__get_c_char_p_of_string(data) + file_type = self.__get_c_char_p_of_string(file_type) + STEPS_LIB.api_set_dynamic_model(data, file_type, self.toolkit_index) + return + + def get_generator_related_model_name(self, generator, model_type): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_generator_related_model_name(ibus, ickt, model_type, self.toolkit_index)) + + def get_generator_related_model_data(self, generator, model_type, par_name): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + par_name = self.__get_c_char_p_of_string(par_name) + return STEPS_LIB.api_get_generator_related_model_float_parameter(ibus, ickt, model_type, par_name, self.toolkit_index) + + def set_generator_related_model_data(self, generator, model_type, par_name, value): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + par_name = self.__get_c_char_p_of_string(par_name) + return STEPS_LIB.api_set_generator_related_model_float_parameter(ibus, ickt, model_type, par_name, value, self.toolkit_index) + + def get_wt_generator_related_model_name(self, generator, model_type): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_wt_generator_related_model_name(ibus, ickt, model_type, self.toolkit_index)) + + def get_wt_generator_related_model_data(self, generator, model_type, par_name): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + par_name = self.__get_c_char_p_of_string(par_name) + return STEPS_LIB.api_get_wt_generator_related_model_float_parameter(ibus, ickt, model_type, par_name, self.toolkit_index) + + def set_wt_generator_related_model_data(self, generator, model_type, par_name, value): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + par_name = self.__get_c_char_p_of_string(par_name) + return STEPS_LIB.api_set_wt_generator_related_model_float_parameter(ibus, ickt, model_type, par_name, value, self.toolkit_index) + + def get_pv_unit_related_model_name(self, pv_unit, model_type): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(pv_unit) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_pv_unit_related_model_name(ibus, ickt, model_type, self.toolkit_index)) + + def get_pv_unit_related_model_data(self, pv_unit, model_type, par_name): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(pv_unit) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + par_name = self.__get_c_char_p_of_string(par_name) + return STEPS_LIB.api_get_pv_unit_related_model_float_parameter(ibus, ickt, model_type, par_name, self.toolkit_index) + + def set_pv_unit_related_model_data(self, pv_unit, model_type, par_name, value): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(pv_unit) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + par_name = self.__get_c_char_p_of_string(par_name) + return STEPS_LIB.api_set_pv_unit_related_model_float_parameter(ibus, ickt, model_type, par_name, value, self.toolkit_index) + + def get_load_related_model_name(self, load, model_type): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(load) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_load_related_model_name(ibus, ickt, model_type, self.toolkit_index)) + + def get_load_related_model_data(self, load, model_type, par_name): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(load) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + par_name = self.__get_c_char_p_of_string(par_name) + return STEPS_LIB.api_get_load_related_model_float_parameter(ibus, ickt, model_type, par_name, self.toolkit_index) + + def set_load_related_model_data(self, load, model_type, par_name, value): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(load) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + par_name = self.__get_c_char_p_of_string(par_name) + return STEPS_LIB.api_set_load_related_model_float_parameter(ibus, ickt, model_type, par_name, value, self.toolkit_index) + + def get_line_related_model_name(self, line, model_type): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_line_related_model_name(ibus, jbus, ickt, model_type, self.toolkit_index)) + + def get_line_related_model_data(self, line, model_type, par_name): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + par_name = self.__get_c_char_p_of_string(par_name) + return STEPS_LIB.api_get_line_related_model_float_parameter(ibus, jbus, ickt, model_type, par_name, self.toolkit_index) + + def set_line_related_model_data(self, line, model_type, par_name, value): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + par_name = self.__get_c_char_p_of_string(par_name) + return STEPS_LIB.api_set_line_related_model_float_parameter(ibus, jbus, ickt, model_type, par_name, value, self.toolkit_index) + + def get_hvdc_related_model_name(self, hvdc, model_type): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(hvdc) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_hvdc_related_model_name(ibus, jbus, ickt, model_type, self.toolkit_index)) + + def get_hvdc_related_model_data(self, hvdc, model_type, par_name): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(hvdc) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + par_name = self.__get_c_char_p_of_string(par_name) + return STEPS_LIB.api_get_hvdc_related_model_float_parameter(ibus, jbus, ickt, model_type, par_name, self.toolkit_index) + + def set_hvdc_related_model_data(self, hvdc, model_type, par_name, value): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(hvdc) + ickt = self.__get_c_char_p_of_string(ickt) + model_type = self.__get_c_char_p_of_string(model_type) + par_name = self.__get_c_char_p_of_string(par_name) + return STEPS_LIB.api_set_hvdc_related_model_float_parameter(ibus, jbus, ickt, model_type, par_name, value, self.toolkit_index) + + def get_powerflow_solver_parameter(self, par_type, par_name): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN']: + return None + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return int(STEPS_LIB.api_get_powerflow_solver_integer_parameter(par_name, self.toolkit_index)) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_get_powerflow_solver_float_parameter(par_name, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_get_powerflow_solver_boolean_parameter(par_name, self.toolkit_index) + return None + + def set_powerflow_solver_parameter(self, par_type, par_name, value): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN']: + return + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return STEPS_LIB.api_set_powerflow_solver_integer_parameter(par_name, value, self.toolkit_index) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_set_powerflow_solver_float_parameter(par_name, value, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_set_powerflow_solver_boolean_parameter(par_name, value, self.toolkit_index) + return + + def solve_powerflow(self, method): + global STEPS_LIB + method = self.__get_c_char_p_of_string(method) + STEPS_LIB.api_solve_powerflow(method, self.toolkit_index) + return + + def is_powerflow_converged(self): + global STEPS_LIB + return STEPS_LIB.api_is_powerflow_converged(self.toolkit_index) + + def get_powerflow_loss(self): + global STEPS_LIB + p_gen = 0.0 + gens = self.get_generators_at_bus(0) + for gen in gens: + p_gen += self.get_generator_data(gen, 'd', 'Pgen_MW') + + gens = self.get_wt_generators_at_bus(0) + for gen in gens: + p_gen += self.get_wt_generator_data(gen, 'd', 'Pgen_MW') + + pvs = self.get_pv_units_at_bus(0) + for pv in pvs: + p_gen += self.get_pv_unit_data(pv, 'd', 'Pgen_MW') + + eses = self.get_energy_storages_at_bus(0) + for es in eses: + p_gen += self.get_energy_storage_data(es, 'd', 'Pgen_MW') + + p_load = 0.0 + loads = self.get_loads_at_bus(0) + for load in loads: + p_load += self.get_load_data(load, 'd', 'P_MW') + + return p_gen-p_load + + + def show_powerflow_result(self): + global STEPS_LIB + STEPS_LIB.api_show_powerflow_result(self.toolkit_index) + return + + def save_powerflow_result(self, file): + global STEPS_LIB + file = self.__get_c_char_p_of_string(file) + STEPS_LIB.api_save_powerflow_result(file, self.toolkit_index) + return + + def save_extended_powerflow_result(self, file): + global STEPS_LIB + file = self.__get_c_char_p_of_string(file) + STEPS_LIB.api_save_extended_powerflow_result(file, self.toolkit_index) + return + + def save_jacobian_matrix(self, file): + global STEPS_LIB + file = self.__get_c_char_p_of_string(file) + STEPS_LIB.api_save_jacobian_matrix(file, self.toolkit_index) + return + + def build_network_matrix(self): + global STEPS_LIB + STEPS_LIB.api_build_network_matrix(self.toolkit_index) + return + + def build_decoupled_network_matrix(self): + global STEPS_LIB + STEPS_LIB.api_build_decoupled_network_matrix(self.toolkit_index) + return + + def build_dc_network_matrix(self): + global STEPS_LIB + STEPS_LIB.api_build_dc_network_matrix(self.toolkit_index) + return + + def build_dynamic_network_matrix(self): + global STEPS_LIB + STEPS_LIB.api_build_dynamic_network_matrix(self.toolkit_index) + return + + def save_network_matrix(self, file): + global STEPS_LIB + file = self.__get_c_char_p_of_string(file) + STEPS_LIB.api_save_network_matrix(file, self.toolkit_index) + return + + def save_decoupled_network_matrix(self, file): + global STEPS_LIB + file = self.__get_c_char_p_of_string(file) + STEPS_LIB.api_save_decoupled_network_matrix(file, self.toolkit_index) + return + + def save_dc_network_matrix(self, file): + global STEPS_LIB + file = self.__get_c_char_p_of_string(file) + STEPS_LIB.api_save_dc_network_matrix(file, self.toolkit_index) + return + + def save_dynamic_network_matrix(self, file): + global STEPS_LIB + file = self.__get_c_char_p_of_string(file) + STEPS_LIB.api_save_dynamic_network_matrix(file, self.toolkit_index) + return + + + def get_dynamic_simulator_parameter(self, par_type, par_name): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return None + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return int(STEPS_LIB.api_get_dynamic_simulator_integer_parameter(par_name, self.toolkit_index)) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_get_dynamic_simulator_float_parameter(par_name, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_get_dynamic_simulator_boolean_parameter(par_name, self.toolkit_index) + if par_type in ['S', 'STRING']: + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_dynamic_simulator_string_parameter(par_name, self.toolkit_index)) + return None + + def set_dynamic_simulator_parameter(self, par_type, par_name, value): + global STEPS_LIB + par_type = par_type.upper() + if par_type not in ['I', 'INT', 'INTEGER', 'F', 'D', 'FLOAT', 'DOUBLE', 'B', 'BOOL', 'BOOLEAN', 'S', 'STRING']: + return None + par_name = self.__get_c_char_p_of_string(par_name) + if par_type in ['I', 'INT', 'INTEGER']: + return STEPS_LIB.api_set_dynamic_simulator_integer_parameter(par_name, value, self.toolkit_index) + if par_type in ['F', 'D', 'FLOAT', 'DOUBLE']: + return STEPS_LIB.api_set_dynamic_simulator_float_parameter(par_name, value, self.toolkit_index) + if par_type in ['B', 'BOOL', 'BOOLEAN']: + return STEPS_LIB.api_set_dynamic_simulator_boolean_parameter(par_name, value, self.toolkit_index) + if par_type in ['S', 'STRING']: + value = self.__get_c_char_p_of_string(value) + return STEPS_LIB.api_set_dynamic_simulator_string_parameter(par_name, value, self.toolkit_index) + return None + + def get_dynamic_simulator_output_file(self): + global STEPS_LIB + return self.__get_string_from_c_char_p(STEPS_LIB.api_get_dynamic_simulator_output_file(self.toolkit_index)) + + def set_dynamic_simulator_output_file(self, file): + global STEPS_LIB + file = self.__get_c_char_p_of_string(file) + return STEPS_LIB.api_set_dynamic_simulator_output_file(file, self.toolkit_index) + + def get_dynamic_simulation_time_step(self): + global STEPS_LIB + return STEPS_LIB.api_get_dynamic_simulation_time_step(self.toolkit_index) + + def set_dynamic_simulation_time_step(self, step): + global STEPS_LIB + return STEPS_LIB.api_set_dynamic_simulation_time_step(step, self.toolkit_index) + + def get_dynamic_simulation_time(self): + global STEPS_LIB + return STEPS_LIB.api_get_dynamic_simulation_time(self.toolkit_index) + + def prepare_meters(self, device_type): + global STEPS_LIB + device_type = device_type.upper() + if device_type not in ['ALL', 'BUS', 'GENERATOR', 'WT GENERATOR', 'LOAD', 'LINE', 'HVDC', 'EQUIVALENT DEVICE']: + return + if device_type in ['ALL']: + STEPS_LIB.api_prepare_meters(self.toolkit_index) + return + if device_type in ['BUS']: + STEPS_LIB.api_prepare_bus_related_meters(self.toolkit_index) + return + if device_type in ['GENERATOR']: + STEPS_LIB.api_prepare_generator_related_meters(self.toolkit_index) + return + if device_type in ['WT GENERATOR']: + STEPS_LIB.api_prepare_wt_generator_related_meters(self.toolkit_index) + return + if device_type in ['PV UNIT']: + STEPS_LIB.api_prepare_pv_unit_related_meters(self.toolkit_index) + return + if device_type in ['ENERGY STORAGE']: + STEPS_LIB.api_prepare_energy_storage_related_meters(self.toolkit_index) + return + if device_type in ['LOAD']: + STEPS_LIB.api_prepare_load_related_meters(self.toolkit_index) + return + if device_type in ['LINE']: + STEPS_LIB.api_prepare_line_related_meters(self.toolkit_index) + return + if device_type in ['HVDC']: + STEPS_LIB.api_prepare_hvdc_related_meters(self.toolkit_index) + return + if device_type in ['EQUIVALENT DEVICE']: + STEPS_LIB.api_prepare_equivalent_device_related_meters(self.toolkit_index) + return + return + + def prepare_bus_meter(self, bus, meter_type): + global STEPS_LIB + meter_type = self.__get_c_char_p_of_string(meter_type) + STEPS_LIB.api_prepare_bus_related_meter(bus, meter_type, self.toolkit_index) + return + + def prepare_generator_meter(self, generator, meter_type, var_name=""): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + meter_type = self.__get_c_char_p_of_string(meter_type) + var_name = self.__get_c_char_p_of_string(var_name) + STEPS_LIB.api_prepare_generator_related_meter(bus, ickt, meter_type, var_name, self.toolkit_index) + return + + def prepare_wt_generator_meter(self, generator, meter_type, var_name=""): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + meter_type = self.__get_c_char_p_of_string(meter_type) + var_name = self.__get_c_char_p_of_string(var_name) + STEPS_LIB.api_prepare_wt_generator_related_meter(bus, ickt, meter_type, var_name, self.toolkit_index) + return + + def prepare_pv_unit_meter(self, pvunit, meter_type, var_name=""): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(pvunit) + ickt = self.__get_c_char_p_of_string(ickt) + meter_type = self.__get_c_char_p_of_string(meter_type) + var_name = self.__get_c_char_p_of_string(var_name) + STEPS_LIB.api_prepare_pv_unit_related_meter(bus, ickt, meter_type, var_name, self.toolkit_index) + return + + def prepare_energy_storage_meter(self, estorage, meter_type, var_name=""): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(estorage) + ickt = self.__get_c_char_p_of_string(ickt) + meter_type = self.__get_c_char_p_of_string(meter_type) + var_name = self.__get_c_char_p_of_string(var_name) + STEPS_LIB.api_prepare_energy_storage_related_meter(bus, ickt, meter_type, var_name, self.toolkit_index) + return + + def prepare_load_meter(self, load, meter_type, var_name=""): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(load) + ickt = self.__get_c_char_p_of_string(ickt) + meter_type = self.__get_c_char_p_of_string(meter_type) + var_name = self.__get_c_char_p_of_string(var_name) + STEPS_LIB.api_prepare_load_related_meter(bus, ickt, meter_type, var_name, self.toolkit_index) + return + + def prepare_line_meter(self, line, meter_type, side, var_name=""): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + meter_type = self.__get_c_char_p_of_string(meter_type) + side = self.__get_c_char_p_of_string(side) + var_name = self.__get_c_char_p_of_string(var_name) + STEPS_LIB.api_prepare_line_related_meter(ibus, jbus, ickt, meter_type, side, var_name, self.toolkit_index) + return + + def prepare_hvdc_meter(self, hvdc, meter_type, side, var_name=""): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(hvdc) + ickt = self.__get_c_char_p_of_string(ickt) + meter_type = self.__get_c_char_p_of_string(meter_type) + side = self.__get_c_char_p_of_string(side) + var_name = self.__get_c_char_p_of_string(var_name) + STEPS_LIB.api_prepare_hvdc_related_meter(ibus, jbus, ickt, meter_type, side, var_name, self.toolkit_index) + return + + def prepare_equivalent_device_meter(self, edevice, meter_type, var_name=""): + global STEPS_LIB + bus, ickt = self.__extract_single_bus_device_id(equivalent_device) + ickt = self.__get_c_char_p_of_string(ickt) + meter_type = self.__get_c_char_p_of_string(meter_type) + var_name = self.__get_c_char_p_of_string(var_name) + STEPS_LIB.api_prepare_equivalent_device_related_meter(bus, ickt, meter_type, var_name, self.toolkit_index) + return + + def start_dynamic_simulation(self): + global STEPS_LIB + STEPS_LIB.api_start_dynamic_simulation(self.toolkit_index) + return + + def stop_dynamic_simulation(self): + global STEPS_LIB + STEPS_LIB.api_stop_dynamic_simulation(self.toolkit_index) + return + + def run_dynamic_simulation_to_time(self, time): + global STEPS_LIB + STEPS_LIB.api_run_simulation_to_time(time, self.toolkit_index) + return + + def run_a_step(self): + global STEPS_LIB + STEPS_LIB.api_run_a_step(self.toolkit_index) + return + + def set_bus_fault(self, bus, fault_type, fault_shunt): + global STEPS_LIB + fault_type = self.__get_c_char_p_of_string(fault_type) + STEPS_LIB.api_set_bus_fault(bus, fault_type, fault_shunt[0], fault_shunt[1], self.toolkit_index) + return + + def clear_bus_fault(self, bus, fault_type): + global STEPS_LIB + fault_type = self.__get_c_char_p_of_string(fault_type) + STEPS_LIB.api_clear_bus_fault(bus, fault_type, self.toolkit_index) + return + + def trip_bus(self, bus): + global STEPS_LIB + STEPS_LIB.api_trip_bus(bus, self.toolkit_index) + return + + def set_line_fault(self, line, fault_type, fault_location, fault_shunt): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + fault_type = self.__get_c_char_p_of_string(fault_type) + STEPS_LIB.api_set_line_fault(ibus, jbus, ickt, fault_type, fault_location, fault_shunt[0], fault_shunt[1], self.toolkit_index) + return + + def clear_line_fault(self, line, fault_type, fault_location): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + fault_type = self.__get_c_char_p_of_string(fault_type) + STEPS_LIB.api_clear_line_fault(ibus, jbus, ickt, fault_type, fault_location, self.toolkit_index) + return + + def trip_line(self, line): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_trip_line(ibus, jbus, ickt, self.toolkit_index) + return + + def trip_line_breaker(self, line): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_trip_line_breaker(ibus, jbus, ickt, self.toolkit_index) + return + + + def close_line(self, line): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_close_line(ibus, jbus, ickt, self.toolkit_index) + return + + def close_line_breaker(self, line): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_single_bus_device_id(line) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_close_line_breaker(ibus, jbus, ickt, self.toolkit_index) + return + + + def trip_transformer(self, transformer): + global STEPS_LIB + ibus, jbus, kbus, ickt = self.__extract_triple_bus_device_id(transformer) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_trip_transformer(ibus, jbus, kbus, ickt, self.toolkit_index) + return + + def trip_transformer_breaker(self, transformer): + global STEPS_LIB + ibus, jbus, kbus, ickt = self.__extract_triple_bus_device_id(transformer) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_trip_transformer_breaker(ibus, jbus, kbus, ickt, self.toolkit_index) + return + + + def close_transformer(self, transformer): + global STEPS_LIB + ibus, jbus, kbus, ickt = self.__extract_triple_bus_device_id(transformer) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_close_transformer(ibus, jbus, kbus, ickt, self.toolkit_index) + return + + def close_transformer_breaker(self, transformer): + global STEPS_LIB + ibus, jbus, kbus, ickt = self.__extract_triple_bus_device_id(transformer) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_close_transformer_breaker(ibus, jbus, kbus, ickt, self.toolkit_index) + return + + def trip_generator(self, generator): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_trip_generator(ibus, ickt, self.toolkit_index) + return + + def shed_generator(self, generator, percent): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_shed_generator(ibus, ickt, percent, self.toolkit_index) + return + + def trip_load(self, load): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(load) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_trip_load(ibus, ickt, self.toolkit_index) + return + + def close_load(self, load): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(load) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_close_load(ibus, ickt, self.toolkit_index) + return + + def scale_load(self, load, percent): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(load) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_scale_load(ibus, ickt, percent, self.toolkit_index) + return + + def scale_all_loads(self, percent): + global STEPS_LIB + STEPS_LIB.api_scale_all_loads(percent, self.toolkit_index) + return + + def trip_fixed_shunt(self, shunt): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(shunt) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_trip_fixed_shunt(ibus, ickt, self.toolkit_index) + return + + def close_fixed_shunt(self, shunt): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(shunt) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_close_fixed_shunt(ibus, ickt, self.toolkit_index) + return + + def manually_bypass_hvdc(self, hvdc): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(hvdc) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_manually_bypass_hvdc(ibus, jbus, ickt, self.toolkit_index) + return + + def manually_block_hvdc(self, hvdc): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(hvdc) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_manually_block_hvdc(ibus, jbus, ickt, self.toolkit_index) + return + + def manually_unbypass_hvdc(self, hvdc): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(hvdc) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_manually_unbypass_hvdc(ibus, jbus, ickt, self.toolkit_index) + return + + def manually_unblock_hvdc(self, hvdc): + global STEPS_LIB + ibus, jbus, ickt = self.__extract_double_bus_device_id(hvdc) + ickt = self.__get_c_char_p_of_string(ickt) + STEPS_LIB.api_manually_unblock_hvdc(ibus, jbus, ickt, self.toolkit_index) + return + + def get_generator_voltage_reference_in_pu(self, generator): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_get_generator_voltage_reference_in_pu(ibus, ickt, self.toolkit_index) + + def get_generator_power_reference_in_MW(self, generator): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_get_generator_power_reference_in_MW(ibus, ickt, self.toolkit_index) + + def set_generator_voltage_reference_in_pu(self, generator, value): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_set_generator_voltage_reference_in_pu(ibus, ickt, value, self.toolkit_index) + + def set_generator_power_reference_in_MW(self, generator, value): + global STEPS_LIB + ibus, ickt = self.__extract_single_bus_device_id(generator) + ickt = self.__get_c_char_p_of_string(ickt) + return STEPS_LIB.api_set_generator_power_reference_in_MW(ibus, ickt, value, self.toolkit_index) \ No newline at end of file