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)
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)
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 …”.
Open VisuService through the button in INTEGRAL:
Documentation IntegralPy
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)
session.load_grid_database(dbname, host, user, port, password)
Loads and returns grid object
session.get_current_grid()
Returns the grid object of currently loaded grid
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 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)