Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 14 Next »

The new IntegralPy library can be used to control INTEGRAL from Python-Script: loading grid data, editing grid data, start calculations.

Quick-start Video: (for better quality go to article media “Anhänge” → “Dateien” and download the video)

IMPORTANT NOTE TO VIDEO: in the current INTEGRAL versions the control paramaters for ProtobufGridIO & VisuService are visible by default. There is no need to activate them through macro command which is depicted in the video.

IntegralPy_Einführung.mp4

For comments, questions and access to IntegralPy Python-library contact eimantas.survila@fgh-ma.de

VisuService Integral Start

Video: (for better quality go to article media “Anhänge” → “Dateien” and download the video)

VisuService_Integral_Integration.mp4

Activate both “Nutze ProtobufGridIO API lokal” and “Nutze Web-Visualisierung …”.

grafik-20240705-132705.png

Open VisuService through the button in INTEGRAL:

grafik-20241108-110508.png

Documentation IntegralPy

Activate the ProtobufGridIO in INTEGRAL

Go to control parameters and activate “Nutze ProtobufGridIO API lokal”

grafik-20240705-132705.png

Importing the library

import integralpy

Methods

integralpy.connect(host)
Returns session object

session.load_grid_file(local_path)

Loads a grid from xml-file and returns a grid object.

session.load_grid_file_cim(local_paths)

Loads a grid from a list of zip-files and returns a grid object.

local_paths an array of strings with local path information

session.get_current_grid()
Returns the grid object of currently loaded grid

grid.calculate_base_load_flow()

Starts the Grundlastfluss calculation for the currently loaded grid.

grid.get_base_load_flow_results()

Prototype version (up to change in near future): returns a string which entails the result tables as CSV.

grid.import_from_db(db_name, db_server_ip, db_username, db_password, db_server_port)

Imports a grid from database.

db_name - Database name for the grid which should be imported
db_server_ip - The IP address of the database server
db_username - The username of the database
db_password - The password of the database user
db_server_port - The port of the database server (Note: db_server_port must be a string)

grid.export_to_db(db_name, db_server_ip, db_username, db_password, db_server_port)

Exports the current grid to database.

db_name - Database name for the grid which should be imported
db_server_ip - The IP address of the database server
db_username - The username of the database
db_password - The password of the database user
db_server_port - The port of the database server (Note: db_server_port must be a string)

grid.get(type, attr, ids)
type is either list or single type from integralpy.Type
attr is a list of attributes from integralpy.Attribute
ids is either single id or list of ids

returns either a single object or a list of objects

grid.write(objects)
objects is either a single object or list of objects

grid.create(type)
type is a single type
returns a newly created object

grid.remove_attribute(type, attr, ids)
type is either list or single type from integralpy.Type
attr is a list of attributes from integralpy.Attribute
ids is either single id or list of ids

grid.remove(objects)
objects is either a single object or list of objects

Examples of using IntegralPy:

from integralpy import connect

if __name__ == "__main__":
    session = connect("localhost:7321")
    path = "ks-a1.xml"
    session.load_grid_file(path)
from integralpy import connect, Type, Attribute

if __name__ == "__main__":
    session = connect()
    file_path_rel = "ks-a1.xml"
    netz = session.load_grid_file(file_path_rel)
    # if the grid is already loaded:
    netz = session.get_current_grid()
    objects = netz.get(
        type=Type.LEITUNG,
        attr=[Attribute.LEITUNG.KURZNAME, Attribute.LEITUNG.BEZEICHNER],
    )
    print(objects)

    netzeinspeisung = netz.get(ids=772)
    print(netzeinspeisung)
import integralpy

if __name__ == "__main__":
    session = integralpy.connect("localhost:7321")
    file_path = "ks-a1.xml"
    netz = session.load_grid_file(file_path)
    new_leitung = netz.create(type=integralpy.Type.LEITUNG)

    leitung = netz.get(ids=1175)
    leitung.kurzname = "Something different"
    netz.write(leitung)
    print("new_leitung", leitung)
  • No labels