Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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.

...

For comments, questions and access to IntegralPy Python-library (the wheel files from video) contact eimantas.survila@fgh-ma.de

VisuService Integral Start

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

...

Execute the following script as macro:

function activate_for_integralpy() {
Netz.setze_steuerdatum("/webvisualisierung/zeige_webvis_steuerparameter","1");
}

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

...

Activate the ProtobufGridIO in INTEGRAL

Execute the following script as macro:

function activate_for_integralpy() {
Netz.setze_steuerdatum("/webvisualisierung/zeige_webvis_steuerparameter","1");
}

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

...

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_database(dbname, host, user, port, passwordfile_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. The individual tables are separated by the following string: "== TABLE SEPERATION =="

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)

Returns either a single object or a list of objects

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 idsreturns either a single object or a list of objects

The fields of the returned objects can be changed. For example

leitung.kurzname = “new short name”. See exmpla at the bottom of the page.

grid.write(objects)

Sends back the objects which could be altered in Python script back to INTEGRAL which updates its data model with new information from these objects.
objects is either a single object or list of objects

grid.create(type)
type is a single type
returns Creates a newly created objectnew object in INTEGRAL and returns it.

grid.remove_attribute(type, attr, ids)

Removes the given attributes from the given objects.
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)

Removes the objects from INTEGRAL data model.

objects is either a single object or list of objects

Examples of using IntegralPy:

...