Application Programming Interface
SAInt-API is a powerful tool to automate the manual processes in the GUI. It gives access to multiple network and scenario data processing and execution functions. The API can be used with Python, C++, C#, and VisualBasic. We will focus here in describing the functions implemented for Python, but the interested user can refer to the manual "SAInt-API-Help.chm" (available in .\encoord\SAInt-v3\Documents from the user#s Documents folder), for details on the other languages.
The functions described in this section of the Reference Guide provides functionalities to develop scripts and plugins.
A plugin is a software component that adds new features or functionality to an existing application without altering its core code. It acts as an extension, enabling users to customize and enhance the application to meet specific needs. It is more than a script, because it not only allows to accomplish a set of complex operations, but it also has a graphical user interface and a larger codebase.
For examples of publicly-available plugins, please, refer the "Plugins" category of the community Forum.
For examples of how to use the calls to SAInt-API and to develop plugins check the tutorials in "Scripting in SAInt", and at the beginner level the "Beginner Tutorial on SAInt API" and the "Beginner Tutorial on Plugins Development". To review how install and execute a new plugin check the How-To "Install and Execute a Plugin".
1. Requirements
1.1. Python
Python version: SAInt-API has been tested with multiple releases of Python. From version Python 3.9 to Python 3.14, extensive tests have been carried out without encountering any problems. However, the latest release of Python, 3.15, has not been thoroughly tested. It may generate compatibility problems with other packages or may be affected by unsolved bugs. We encourage our users to avoid the very latest release if possible.
Ctypes package: The ctypes package provides C-compatible data types and allows function calls from a dynamic link library (DLL). It can imported using from ctypes import * command.
Access API Functions: It is necessary to create a DLL object using mydll = cdll.LoadLibrary(path) command, where path is the directory of the SAInt API and DLL file. The SAInt-API functions can then be accessed as attributes of the DLL object.
|
If you are not able to load SAInt-API, try the following:
If the problem persists, please contact encoord support. |
1.2. Python wrapper
Some of the API functions can be used following two different approaches. The first approach only uses the functionality provided by the "CTypes" package and a "low-level" interaction with the API entry points. This approach is available for all functions and it is generally the way to go for the majority of users. A second approach, described in some of the examples, showcases a more elegant use of the API functions based on a "parameter objects wrapper" providing functions which are covering many of the calls of approach one. This second approach is still in its infancy and will lay the foundations for a full-fledged SAInt Python package in the future.
To use the "parameter objects wrapper" approach, the user must include the following code.
Wrapper classes in Python to use certain API entry points based on the second approach (Click to open).
import ctypes
def set_ctypes_function_signatures(dll: ctypes.CDLL):
"""Set up function signatures for parameter object functions"""
if dll.getParameterNetObject.restype == ctypes.c_void_p:
return
dll.getParameterNetObject.restype = ctypes.c_void_p
dll.getParameterValue.restype = ctypes.c_wchar_p
dll.setParameterValue.restype = ctypes.c_bool
dll.releaseParameterObject.restype = None
dll.addEEVT.restype = ctypes.c_void_p
dll.addGEVT.restype = ctypes.c_void_p
dll.addTEVT.restype = ctypes.c_void_p
dll.addEPRF.restype = ctypes.c_void_p
dll.addGPRF.restype = ctypes.c_void_p
dll.addTPRF.restype = ctypes.c_void_p
dll.getLastErrorMessage.restype = ctypes.c_wchar_p
dll.addGNO.restype = ctypes.c_void_p
dll.addGBR.restype = ctypes.c_void_p
dll.addENO.restype = ctypes.c_void_p
dll.addEBR.restype = ctypes.c_void_p
dll.addTNO.restype = ctypes.c_void_p
dll.addFUEL.restype = ctypes.c_void_p
dll.addHYDP.restype = ctypes.c_void_p
dll.addASVC.restype = ctypes.c_void_p
dll.addECNSTR.restype = ctypes.c_void_p
dll.addEVAR.restype = ctypes.c_void_p
dll.addASVCX.restype = ctypes.c_void_p
dll.addTBR.restype = ctypes.c_void_p
dll.addEXT.restype = ctypes.c_void_p
dll.addGXT.restype = ctypes.c_void_p
dll.addTXT.restype = ctypes.c_void_p
dll.addCTG.restype = ctypes.c_void_p
dll.addMBR.restype = ctypes.c_void_p
# Set up query endpoint signatures
dll.getESCE.restype = ctypes.c_void_p
dll.getGSCE.restype = ctypes.c_void_p
dll.getTSCE.restype = ctypes.c_void_p
dll.getEEVT.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_wchar_p]
dll.getEEVT.restype = PointerArray
dll.getGEVT.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_wchar_p]
dll.getGEVT.restype = PointerArray
dll.getTEVT.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_wchar_p]
dll.getTEVT.restype = PointerArray
dll.removeEEVT.argtypes = [ctypes.c_void_p]
dll.removeEEVT.restype = ctypes.c_bool
dll.removeGEVT.argtypes = [ctypes.c_void_p]
dll.removeGEVT.restype = ctypes.c_bool
dll.removeTEVT.argtypes = [ctypes.c_void_p]
dll.removeTEVT.restype = ctypes.c_bool
dll.removeEPRF.argtypes = [ctypes.c_void_p]
dll.removeEPRF.restype = ctypes.c_bool
dll.removeGPRF.argtypes = [ctypes.c_void_p]
dll.removeGPRF.restype = ctypes.c_bool
dll.removeTPRF.argtypes = [ctypes.c_void_p]
dll.removeTPRF.restype = ctypes.c_bool
dll.removeEPRFName.argtypes = [ctypes.c_wchar_p]
dll.removeEPRFName.restype = ctypes.c_bool
dll.removeGPRFName.argtypes = [ctypes.c_wchar_p]
dll.removeGPRFName.restype = ctypes.c_bool
dll.removeTPRFName.argtypes = [ctypes.c_wchar_p]
dll.removeTPRFName.restype = ctypes.c_bool
dll.getEPRF.argtypes = [ctypes.c_wchar_p]
dll.getEPRF.restype = PointerArray
dll.getGPRF.argtypes = [ctypes.c_wchar_p]
dll.getGPRF.restype = PointerArray
dll.getTPRF.argtypes = [ctypes.c_wchar_p]
dll.getTPRF.restype = PointerArray
dll.getEOBJ.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p]
dll.getEOBJ.restype = PointerArray
dll.getGOBJ.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p]
dll.getGOBJ.restype = PointerArray
dll.getTOBJ.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p]
dll.getTOBJ.restype = PointerArray
# Set up parameter types for the functions
dll.getParameterValue.argtypes = [ctypes.c_void_p, ctypes.c_wchar_p]
dll.setParameterValue.argtypes = [ctypes.c_void_p, ctypes.c_wchar_p, ctypes.c_wchar_p]
dll.releaseParameterObject.argtypes = [ctypes.c_void_p]
dll.releaseArrayObject.argtypes = [ctypes.c_void_p]
dll.addEEVT.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_wchar_p]
dll.addGEVT.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_wchar_p]
dll.addTEVT.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_wchar_p]
dll.addEPRF.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_wchar_p]
dll.addGPRF.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_wchar_p]
dll.addTPRF.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_wchar_p]
dll.addGNO.argtypes = [ctypes.c_wchar_p]
dll.addGBR.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_wchar_p]
dll.addENO.argtypes = [ctypes.c_wchar_p]
dll.addEBR.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_wchar_p]
dll.addTNO.argtypes = [ctypes.c_wchar_p]
dll.addFUEL.argtypes = [ctypes.c_wchar_p]
dll.addHYDP.argtypes = [ctypes.c_wchar_p]
dll.addASVC.argtypes = [ctypes.c_wchar_p]
dll.addECNSTR.argtypes = [ctypes.c_wchar_p]
dll.addEVAR.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_wchar_p]
dll.addASVCX.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_wchar_p]
dll.addTBR.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_wchar_p]
dll.addEXT.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_wchar_p]
dll.addGXT.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_wchar_p]
dll.addTXT.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_wchar_p]
dll.addCTG.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p]
dll.addMBR.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_wchar_p]
# Define PointerArray structure
class PointerArray(ctypes.Structure):
_fields_ = [
("array_pointer", ctypes.c_void_p),
("count", ctypes.c_int)
]
def from_array(self, dll: ctypes.CDLL, obj_type: str) -> list['ParameterObject']:
try:
if self.array_pointer and self.count > 0:
ptr_array = (ctypes.c_void_p * self.count).from_address(self.array_pointer)
objects = [ParameterObject(ptr_array[i], dll, f"{obj_type}_{i}", None)
for i in range(self.count)]
return objects
if self.count == -1:
raise ValueError(f"Failed to get {obj_type} objects: {dll.getLastErrorMessage()}")
return []
finally:
if self.array_pointer and self.count > 0:
dll.releaseArrayObject(self.array_pointer)
def create_parameter_object( dll: ctypes.CDLL,ptr_value: ctypes.c_void_p, obj_id: str, allowed_parameters=None,**kwargs : dict) -> 'ParameterObject':
r= ParameterObject(ptr_value, dll, obj_id, allowed_parameters)
for key, value in kwargs.items():
r[key] = value
return r
# This is a wrapper to allow to use the parameter object as python object
# it is a context manager that will release the parameter object when done
class ParameterObject:
_SPECIAL_ATTRS = [
'dll', 'ptr', '_initialized', '_allowed_parameters',
'__iter__', '__next__', '__del__', '__enter__', '__exit__',
'__getitem__', '__setitem__', '__getattr__', '__setattr__',
'__del__'
]
# static method to create a instance of the ParameterObject class for electric scenario object that are fetched from the network
@staticmethod
def get_esce(dll: ctypes.CDLL) -> 'ParameterObject':
set_ctypes_function_signatures(dll)
ptr_value = dll.getESCE()
return create_parameter_object(dll, ptr_value, "ESCE", None)
# static method to create a instance of the ParameterObject class for gas scenario object that are fetched from the network
@staticmethod
def get_gsce(dll: ctypes.CDLL) -> 'ParameterObject':
set_ctypes_function_signatures(dll)
ptr_value = dll.getGSCE()
return create_parameter_object(dll, ptr_value, "GSCE", None)
# static method to create a instance of the ParameterObject class for thermal scenario object that are fetched from the network
@staticmethod
def get_tsce(dll: ctypes.CDLL) -> 'ParameterObject':
set_ctypes_function_signatures(dll)
ptr_value = dll.getTSCE()
return create_parameter_object(dll, ptr_value, "TSCE", None)
# static method to create a instance of the ParameterObject class for net object that are fetch to the network
@staticmethod
def get_net_object(dll: ctypes.CDLL, obj_id: str, allowed_parameters=None) -> 'ParameterObject':
set_ctypes_function_signatures(dll)
ptr_value = dll.getParameterNetObject(obj_id)
return ParameterObject(ptr_value, dll, obj_id, allowed_parameters)
# static method to create a instance of the ParameterObject class for scenario event object that are added to the network
@staticmethod
def add_eevt(dll: ctypes.CDLL, obj_id: str, parameterName: str, value: None,**kwargs : dict) -> 'ParameterObject':
set_ctypes_function_signatures(dll)
ptr_value = dll.addEEVT(obj_id, parameterName, value)
return create_parameter_object(dll, ptr_value, obj_id+ "."+parameterName,None, **kwargs)
# static method to create a instance of the ParameterObject class for scenario event object that are added to the network
@staticmethod
def add_gevt(dll: ctypes.CDLL, obj_id: str, parameterName: str, value: None,**kwargs : dict) -> 'ParameterObject':
set_ctypes_function_signatures(dll)
ptr_value = dll.addGEVT(obj_id, parameterName, value)
return create_parameter_object(dll, ptr_value, obj_id+ "."+parameterName,None, **kwargs)
# static method to create a instance of the ParameterObject class for scenario event object that are added to the network
@staticmethod
def add_tevt(dll: ctypes.CDLL, obj_id: str, parameterName: str, value: None,**kwargs : dict) -> 'ParameterObject':
set_ctypes_function_signatures(dll)
ptr_value = dll.addTEVT(obj_id, parameterName, value)
return create_parameter_object(dll, ptr_value, obj_id+ "."+parameterName,None, **kwargs)
# static method to create a instance of the ParameterObject class for profile object that are added to the electric scenario
@staticmethod
def add_eprf(dll: ctypes.CDLL, profile_name: str, means_values: str, deviation_values: str, **kwargs: dict) -> 'ParameterObject':
set_ctypes_function_signatures(dll)
ptr_value = dll.addEPRF(profile_name, means_values, deviation_values)
return create_parameter_object(dll, ptr_value, profile_name, None, **kwargs)
# static method to create a instance of the ParameterObject class for profile object that are added to the gas scenario
@staticmethod
def add_gprf(dll: ctypes.CDLL, profile_name: str, means_values: str, deviation_values: str, **kwargs: dict) -> 'ParameterObject':
set_ctypes_function_signatures(dll)
ptr_value = dll.addGPRF(profile_name, means_values, deviation_values)
return create_parameter_object(dll, ptr_value, profile_name, None, **kwargs)
# static method to create a instance of the ParameterObject class for profile object that are added to the thermal scenario
@staticmethod
def add_tprf(dll: ctypes.CDLL, profile_name: str, means_values: str, deviation_values: str, **kwargs: dict) -> 'ParameterObject':
set_ctypes_function_signatures(dll)
ptr_value = dll.addTPRF(profile_name, means_values, deviation_values)
return create_parameter_object(dll, ptr_value, profile_name, None, **kwargs)
# static method to create a instance of the ParameterObject class for gas node that are added to the network
@staticmethod
def add_gno(dll: ctypes.CDLL, obj_id: str, allowed_parameters=None,**kwargs : dict) -> 'ParameterObject':
set_ctypes_function_signatures(dll)
ptr_value = dll.addGNO(obj_id)
return create_parameter_object(dll, ptr_value, obj_id, allowed_parameters, **kwargs)
# static method to create a instance of the ParameterObject class for gas branch that are added to the network
@staticmethod
def add_gbr(dll: ctypes.CDLL, obj_id: str, from_node_id: str, to_node_id: str, allowed_parameters=None,**kwargs : dict) -> 'ParameterObject':
set_ctypes_function_signatures(dll)
ptr_value = dll.addGBR(obj_id, from_node_id, to_node_id)
return create_parameter_object(dll, ptr_value, obj_id, allowed_parameters, **kwargs)
# static method to create a instance of the ParameterObject class for electric node that are added to the network
@staticmethod
def add_eno(dll: ctypes.CDLL, obj_id: str, allowed_parameters=None,**kwargs : dict) -> 'ParameterObject':
set_ctypes_function_signatures(dll)
ptr_value = dll.addENO(obj_id)
return create_parameter_object(dll, ptr_value, obj_id, allowed_parameters, **kwargs)
# static method to create a instance of the ParameterObject class for electric branch that are added to the network
@staticmethod
def add_ebr(dll: ctypes.CDLL, obj_id: str, from_node_id: str, to_node_id: str, allowed_parameters=None,**kwargs : dict) -> 'ParameterObject':
set_ctypes_function_signatures(dll)
ptr_value = dll.addEBR(obj_id, from_node_id, to_node_id)
return create_parameter_object(dll, ptr_value, obj_id, allowed_parameters, **kwargs)
# static method to create a instance of the ParameterObject class for thermal node that are added to the network
@staticmethod
def add_tno(dll: ctypes.CDLL, obj_id: str, allowed_parameters=None,**kwargs : dict) -> 'ParameterObject':
set_ctypes_function_signatures(dll)
ptr_value = dll.addTNO(obj_id)
return create_parameter_object(dll, ptr_value, obj_id, allowed_parameters, **kwargs)
# static method to create a instance of the ParameterObject class for fuel that are added to the electric network
@staticmethod
def add_fuel(dll: ctypes.CDLL, obj_id: str, allowed_parameters=None,**kwargs : dict) -> 'ParameterObject':
set_ctypes_function_signatures(dll)
ptr_value = dll.addFUEL(obj_id)
return create_parameter_object(dll, ptr_value, obj_id, allowed_parameters, **kwargs)
# static method to create a instance of the ParameterObject class for hydro plant that are added to the electric network
@staticmethod
def add_hydp(dll: ctypes.CDLL, obj_id: str, allowed_parameters=None,**kwargs : dict) -> 'ParameterObject':
set_ctypes_function_signatures(dll)
ptr_value = dll.addHYDP(obj_id)
return create_parameter_object(dll, ptr_value, obj_id, allowed_parameters, **kwargs)
# static method to create a instance of the ParameterObject class for ancillary service that are added to the electric network
@staticmethod
def add_asvc(dll: ctypes.CDLL, obj_id: str, allowed_parameters=None,**kwargs : dict) -> 'ParameterObject':
set_ctypes_function_signatures(dll)
ptr_value = dll.addASVC(obj_id)
return create_parameter_object(dll, ptr_value, obj_id, allowed_parameters, **kwargs)
# static method to create a instance of the ParameterObject class for electric constraint that are added to the electric network
@staticmethod
def add_ecnstr(dll: ctypes.CDLL, obj_id: str, allowed_parameters=None,**kwargs : dict) -> 'ParameterObject':
set_ctypes_function_signatures(dll)
ptr_value = dll.addECNSTR(obj_id)
return create_parameter_object(dll, ptr_value, obj_id, allowed_parameters, **kwargs)
# static method to create a instance of the ParameterObject class for variable that are added to the electric constraint
@staticmethod
def add_evar(dll: ctypes.CDLL, variable_obj_id: str, net_obj_id: str, electric_constraint_obj_id: str, variable_name: str, allowed_parameters=None,**kwargs : dict) -> 'ParameterObject':
set_ctypes_function_signatures(dll)
ptr_value = dll.addEVAR(variable_obj_id, net_obj_id, electric_constraint_obj_id, variable_name)
return create_parameter_object(dll, ptr_value, variable_obj_id , allowed_parameters, **kwargs)
# static method to create a instance of the ParameterObject class for ancillary service external that are added to the electric network
@staticmethod
def add_asvcx(dll: ctypes.CDLL, asvc_ext_obj_id: str, net_obj_id: str, ancillary_service_obj_id: str, allowed_parameters=None,**kwargs : dict) -> 'ParameterObject':
set_ctypes_function_signatures(dll)
ptr_value = dll.addASVCX(asvc_ext_obj_id, net_obj_id, ancillary_service_obj_id)
return create_parameter_object(dll, ptr_value, asvc_ext_obj_id, allowed_parameters, **kwargs)
# static method to create a instance of the ParameterObject class for thermal branch that are added to the network
@staticmethod
def add_tbr(dll: ctypes.CDLL, obj_id: str, from_node_id: str, to_node_id: str, allowed_parameters=None,**kwargs : dict) -> 'ParameterObject':
set_ctypes_function_signatures(dll)
ptr_value = dll.addTBR(obj_id, from_node_id, to_node_id)
return create_parameter_object(dll, ptr_value, obj_id, allowed_parameters, **kwargs)
# static method to create a instance of the ParameterObject class for external object that are added to the electric network
@staticmethod
def add_ext(dll: ctypes.CDLL, obj_id: str, parent_obj_id: str, additional_param_obj_id: str, allowed_parameters=None,**kwargs : dict) -> 'ParameterObject':
set_ctypes_function_signatures(dll)
ptr_value = dll.addEXT(obj_id, parent_obj_id, additional_param_obj_id)
return create_parameter_object(dll, ptr_value, obj_id, allowed_parameters, **kwargs)
# static method to create a instance of the ParameterObject class for external object that are added to the gas network
@staticmethod
def add_gxt(dll: ctypes.CDLL, obj_id: str, parent_obj_id: str, additional_param_obj_id: str, allowed_parameters=None,**kwargs : dict) -> 'ParameterObject':
set_ctypes_function_signatures(dll)
ptr_value = dll.addGXT(obj_id, parent_obj_id, additional_param_obj_id)
return create_parameter_object(dll, ptr_value, obj_id, allowed_parameters, **kwargs)
# static method to create a instance of the ParameterObject class for external object that are added to the thermal network
@staticmethod
def add_txt(dll: ctypes.CDLL, obj_id: str, parent_obj_id: str, additional_param_obj_id: str, allowed_parameters=None,**kwargs : dict) -> 'ParameterObject':
set_ctypes_function_signatures(dll)
ptr_value = dll.addTXT(obj_id, parent_obj_id, additional_param_obj_id)
return create_parameter_object(dll, ptr_value, obj_id, allowed_parameters, **kwargs)
# static method to create a instance of the ParameterObject class for contingency that are added to the electric network
@staticmethod
def add_ctg(dll: ctypes.CDLL, obj_id: str, allowed_parameters=None,**kwargs : dict) -> 'ParameterObject':
set_ctypes_function_signatures(dll)
ptr_value = dll.addCTG(obj_id)
return create_parameter_object(dll, ptr_value, obj_id, allowed_parameters, **kwargs)
# static method to create a instance of the ParameterObject class for monitored branch that are added to the electric network
@staticmethod
def add_mbr(dll: ctypes.CDLL, obj_id: str, parent_obj_id: str, additional_param_obj_id: str, allowed_parameters=None,**kwargs : dict) -> 'ParameterObject':
set_ctypes_function_signatures(dll)
ptr_value = dll.addMBR(obj_id, parent_obj_id, additional_param_obj_id)
return create_parameter_object(dll, ptr_value, obj_id, allowed_parameters, **kwargs)
# Query methods for scenario events
@staticmethod
def get_eevt(dll: ctypes.CDLL, parameterName="", objId="", time="", value=""):
"""Get array of scenario event parameter objects from electric scenario"""
set_ctypes_function_signatures(dll)
result = dll.getEEVT(parameterName, objId, time, value)
return result.from_array(dll,"EleEvt")
@staticmethod
def get_gevt(dll: ctypes.CDLL, parameterName="", objId="", time="", value=""):
"""Get array of scenario event parameter objects from gas scenario"""
set_ctypes_function_signatures(dll)
result = dll.getGEVT(parameterName, objId, time, value)
return result.from_array(dll,"GasEvt")
@staticmethod
def get_tevt(dll: ctypes.CDLL, parameterName="", objId="", time="", value=""):
"""Get array of scenario event parameter objects from thermal scenario"""
set_ctypes_function_signatures(dll)
result = dll.getTEVT(parameterName, objId, time, value)
return result.from_array(dll,"TherEvt")
@staticmethod
def remove_eevt(dll: ctypes.CDLL, event_ptr: ctypes.c_void_p)->bool:
"""Remove a scenario event from the electric scenario"""
set_ctypes_function_signatures(dll)
result = dll.removeEEVT(event_ptr)
if not result:
msg=dll.getLastErrorMessage()
if not (msg is None) and msg != "":
raise ValueError(f"Failed to remove scenario event: {msg}")
return result
@staticmethod
def remove_gevt(dll: ctypes.CDLL, event_ptr: ctypes.c_void_p)->bool:
"""Remove a scenario event from the gas scenario"""
set_ctypes_function_signatures(dll)
result = dll.removeGEVT(event_ptr)
if not result:
msg=dll.getLastErrorMessage()
if not (msg is None) and msg != "":
raise ValueError(f"Failed to remove scenario event: {msg}")
return result
@staticmethod
def remove_tevt(dll: ctypes.CDLL, event_ptr: ctypes.c_void_p)->bool:
"""Remove a scenario event from the thermal scenario"""
set_ctypes_function_signatures(dll)
result = dll.removeTEVT(event_ptr)
if not result:
msg=dll.getLastErrorMessage()
if not (msg is None) and msg != "":
raise ValueError(f"Failed to remove scenario event: {msg}")
return result
# Query methods for profiles
@staticmethod
def get_eprf(dll: ctypes.CDLL, name=""):
"""Get array of profile parameter objects from electric scenario"""
set_ctypes_function_signatures(dll)
result = dll.getEPRF(name)
return result.from_array(dll,"ElePrf")
@staticmethod
def get_gprf(dll: ctypes.CDLL, name=""):
"""Get array of profile parameter objects from gas scenario"""
set_ctypes_function_signatures(dll)
result = dll.getGPRF(name)
return result.from_array(dll,"GasPrf")
@staticmethod
def get_tprf(dll: ctypes.CDLL, name=""):
"""Get array of profile parameter objects from thermal scenario"""
set_ctypes_function_signatures(dll)
result = dll.getTPRF(name)
return result.from_array(dll,"TherPrf")
@staticmethod
def remove_eprf(dll: ctypes.CDLL, profile_ptr: ctypes.c_void_p)->bool:
"""Remove a profile from the electric scenario"""
set_ctypes_function_signatures(dll)
result = dll.removeEPRF(profile_ptr)
if not result:
msg=dll.getLastErrorMessage()
if not (msg is None) and msg != "":
raise ValueError(f"Failed to remove profile: {msg}")
return result
@staticmethod
def remove_gprf(dll: ctypes.CDLL, profile_ptr: ctypes.c_void_p)->bool:
"""Remove a profile from the gas scenario"""
set_ctypes_function_signatures(dll)
result = dll.removeGPRF(profile_ptr)
if not result:
msg=dll.getLastErrorMessage()
if not (msg is None) and msg != "":
raise ValueError(f"Failed to remove profile: {msg}")
return result
@staticmethod
def remove_tprf(dll: ctypes.CDLL, profile_ptr: ctypes.c_void_p)->bool:
"""Remove a profile from the thermal scenario"""
set_ctypes_function_signatures(dll)
result = dll.removeTPRF(profile_ptr)
if not result:
msg=dll.getLastErrorMessage()
if not (msg is None) and msg != "":
raise ValueError(f"Failed to remove profile: {msg}")
return result
@staticmethod
def remove_eprf_name(dll: ctypes.CDLL, name: str)->bool:
"""Remove a profile from the electric scenario by name"""
set_ctypes_function_signatures(dll)
result = dll.removeEPRFName(name)
if not result:
msg=dll.getLastErrorMessage()
if not (msg is None) and msg != "":
raise ValueError(f"Failed to remove profile by name: {msg}")
return result
@staticmethod
def remove_gprf_name(dll: ctypes.CDLL, name: str)->bool:
"""Remove a profile from the gas scenario by name"""
set_ctypes_function_signatures(dll)
result = dll.removeGPRFName(name)
if not result:
msg=dll.getLastErrorMessage()
if not (msg is None) and msg != "":
raise ValueError(f"Failed to remove profile by name: {msg}")
return result
@staticmethod
def remove_tprf_name(dll: ctypes.CDLL, name: str)->bool:
"""Remove a profile from the thermal scenario by name"""
set_ctypes_function_signatures(dll)
result = dll.removeTPRFName(name)
if not result:
msg=dll.getLastErrorMessage()
if not (msg is None) and msg != "":
raise ValueError(f"Failed to remove profile by name: {msg}")
return result
# Query methods for network objects
@staticmethod
def get_eobj(dll: ctypes.CDLL, objType, name=""):
"""Get array of network object parameter objects from electric network"""
set_ctypes_function_signatures(dll)
result = dll.getEOBJ(objType, name)
return result.from_array(dll,"EleNetObj")
@staticmethod
def get_gobj(dll: ctypes.CDLL, objType, name=""):
"""Get array of network object parameter objects from gas network"""
set_ctypes_function_signatures(dll)
result = dll.getGOBJ(objType, name)
return result.from_array(dll,"GasNetObj")
@staticmethod
def get_tobj(dll: ctypes.CDLL, objType, name=""):
"""Get array of network object parameter objects from thermal network"""
set_ctypes_function_signatures(dll)
result = dll.getTOBJ(objType, name)
return result.from_array(dll,"TherNetObj")
def __init__(self, ptr_value: any, dll: ctypes.CDLL, objName: str, allowed_parameters=None):
if ptr_value is None:
msg=dll.getLastErrorMessage()
raise ValueError(f"Failed to get parameter object for {objName}: {msg}")
object.__setattr__(self, 'dll', dll)
object.__setattr__(self, 'objName', objName)
print(f"getParameterObject returned: {ptr_value} (type: {type(ptr_value)})")
object.__setattr__(self, 'ptr', ptr_value)
object.__setattr__(self, '_allowed_parameters',
allowed_parameters or set())
object.__setattr__(self, '_initialized', True)
def get_value(self, parameter_name):
if self.ptr == 0 or self.ptr is None:
raise ValueError("Parameter object pointer is invalid")
try:
result = self.dll.getParameterValue(self.ptr, parameter_name)
if result is None:
msg=self.dll.getLastErrorMessage()
raise ValueError(f"Failed to get parameter '{parameter_name}': {msg}")
return result
except Exception as e:
raise ValueError(f"Error getting parameter '{parameter_name}': {e}")
def set_value(self, parameter_name, value):
if self.ptr == 0 or self.ptr is None:
raise ValueError("Parameter object pointer is invalid")
try:
result = self.dll.setParameterValue(self.ptr, parameter_name, str(value))
except Exception as e:
raise ValueError(f"Error setting parameter '{parameter_name}': {e}")
if not result:
msg=self.dll.getLastErrorMessage()
raise ValueError(f"Failed to set parameter '{parameter_name}' to '{value}': {msg}")
return result
def cleanup(self):
"""Explicitly release the parameter object"""
if hasattr(self, 'ptr') and self.ptr != 0 and self.ptr is not None:
print(f"Releasing parameter object: {self.ptr}")
self.dll.releaseParameterObject(self.ptr)
object.__setattr__(self, 'ptr', 0)
def __getitem__(self, parameter_name):
"""Support paramObj["Name"] syntax"""
if not hasattr(self, '_initialized') or parameter_name in self._SPECIAL_ATTRS:
return object.__getattr__(self, parameter_name)
else:
return self.get_value(parameter_name)
def __setitem__(self, parameter_name, value):
"""Support paramObj["Name"] = value syntax"""
if not hasattr(self, '_initialized') or parameter_name in self._SPECIAL_ATTRS:
object.__setattr__(self, parameter_name, value)
else:
return self.set_value(parameter_name, value)
def __getattr__(self, name):
if not hasattr(self, '_initialized') or name in self._SPECIAL_ATTRS:
return object.__getattr__(self, name)
else:
if self._allowed_parameters and name not in self._allowed_parameters:
raise AttributeError(f"'{self.objName}' object has no attribute '{name}'")
return self.get_value(name)
def __setattr__(self, name, value):
if not hasattr(self, '_initialized') or name in self._SPECIAL_ATTRS:
object.__setattr__(self, name, value)
else:
if self._allowed_parameters and name not in self._allowed_parameters:
raise AttributeError(f"'{self.objName}' object has no attribute '{name}'")
self.set_value(name, value)
def __enter__(self):
return self
def __exit__(self, exc_type, exc_val, exc_tb):
self.cleanup()
def __del__(self):
self.cleanup()
2. SAInt-API functions
This section describes the functions of SAInt-API with examples of their usage with Python. The functions are divided into different groups based on the action or output, as well based on the type of energy network or scenario.
|
Logging is carried out in the background and saved in a text file in the same folder as the network or the processed input file. The user can check the content of the log file to monitor the workflow or to identify problems when warnings or errors are registered. |
3. Generic functions
These are generic function designed to set, get, or release parameters for objects, scenarios or to retrieve the last error message.
string getLastErrorMessage()
Get last error message from the API.This function is used to retrieve the last error message set by the API functions.It can be called after any API function that may have failed to get more information about the error.
Returns: Last error message
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.openGSOL("C:\\GNET30_DYN.gsol")
ptr=mydll.getParameterNetObject("GNO.notExist")
if ptr is None: # if the parameter object is not found, the last error message will be returned
print(mydll.getLastErrorMessage())
IntPtr getParameterNetObject(string objId)
Get a parameter object for a network object that can be used to get/set parameters from Python.
| Parameter | Type | Description |
|---|---|---|
|
String |
Network object ID |
Returns: Returns a pointer to COMVisibleObject that can be used to get/set parameter values
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
# Approach 1 (direct ctypes):
# Set up function signatures for parameter object functions
mydll.getParameterNetObject.restype = c_void_p
mydll.getParameterValue.restype = c_wchar_p
mydll.setParameterValue.restype = c_bool
# Set up parameter types for the functions
mydll.getParameterValue.argtypes = [c_void_p, c_wchar_p]
mydll.setParameterValue.argtypes = [c_void_p, c_wchar_p, c_wchar_p]
# Get parameter object
param_obj = mydll.getParameterNetObject("GNO.001")
if param_obj is None or param_obj == 0:
print(mydll.getLastErrorMessage())
exit()
# Get parameter value
value = mydll.getParameterValue(param_obj, "Name")
if value is None:
msg = mydll.getLastErrorMessage()
if msg is not None:
print(msg)
exit()
print(value)
# Set parameter value
result = mydll.setParameterValue(param_obj, "Name", "NewName")
if result is false:
print(mydll.getLastErrorMessage())
exit()
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
# Approach 2 (recommended with ParameterObject wrapper):
#this is a wrapper to allow to use the parameter object as python object
param_obj= ParameterObject.get_net_object(mydll, "GNO.001")
# Get parameter value
value = param_obj.Name
print(value)
# Set parameter value
param_obj.Name = "NewName"
print(param_obj.Name)
IntPtr getParameterObjectValue(IntPtr parameterObjectPtr, string parameterName)
Get a parameter object ptr from a parameter object.
| Parameter | Type | Description |
|---|---|---|
|
IntPtr |
Pointer to parameter object returned by getParameterNetObject |
|
String |
Name of the parameter to get |
Returns: Returns a pointer to COMVisibleObject that can be used to get/set parameter values
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET29_18.gnet")
# Approach 1 (direct ctypes):
# Set up function signatures for parameter object functions
mydll.getParameterNetObject.restype = c_void_p
mydll.getParameterValue.restype = c_wchar_p
mydll.getParameterObjectValue.restype = c_void_p
# Set up parameter types for the functions
mydll.getParameterNetObject.argtypes = [c_wchar_p]
mydll.getParameterValue.argtypes = [c_void_p, c_wchar_p]
mydll.getParameterObjectValue.argtypes = [c_void_p, c_wchar_p]
# Get parameter object
branch_obj = mydll.getParameterNetObject("GPI.PI_1")
if branch_obj is None or branch_obj == 0:
print(mydll.getLastErrorMessage())
exit()
# Get from node object
node_obj = mydll.getParameterObjectValue(branch_obj, "FromNetNode")
if node_obj is None or node_obj == 0:
print(mydll.getLastErrorMessage())
exit()
value = mydll.getParameterValue(node_obj, "Name")
if value is None:
msg = mydll.getLastErrorMessage()
if msg is not None:
print(msg)
exit()
else:
print(value)
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET29_18.gnet")
# Approach 2 (recommended with ParameterObject wrapper):
# this is a wrapper to allow to use the parameter object as python object
branch_obj= ParameterObject.get_net_object(mydll, "GPI.PI_1")
print(branch_obj.FromNetNode.Name)
string getParameterValue(IntPtr parameterObjectPtr, string parameterName)
Get a parameter value from a parameter object.
| Parameter | Type | Description |
|---|---|---|
|
IntPtr |
Pointer to parameter object returned by getParameterNetObject |
|
String |
Name of the parameter to get |
Returns: Returns the parameter value as a string
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
# Approach 1 (direct ctypes):
# Set up function signatures for parameter object functions
mydll.getParameterNetObject.restype = c_void_p
mydll.getParameterValue.restype = c_wchar_p
mydll.setParameterValue.restype = c_bool
# Set up parameter types for the functions
mydll.getParameterValue.argtypes = [c_void_p, c_wchar_p]
mydll.setParameterValue.argtypes = [c_void_p, c_wchar_p, c_wchar_p]
# Get parameter object
param_obj = mydll.getParameterNetObject("GNO.NO_1")
if param_obj is None or param_obj == 0:
print(mydll.getLastErrorMessage())
exit()
# Get parameter value
value = mydll.getParameterValue(param_obj, "Name")
if value is None:
msg = mydll.getLastErrorMessage()
if msg is not None:
print(msg)
exit()
else:
print(value)
exit()
# Set parameter value
result = mydll.setParameterValue(param_obj, "Name", "NewName")
if result is false:
print(mydll.getLastErrorMessage())
exit()
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
# Approach 2 (recommended with ParameterObject wrapper):
# this is a wrapper to allow to use the parameter object as python object
gno_obj= ParameterObject.get_net_object(mydll, "GNO.NO_1")
value = gno_obj.Name
print(value)
string getParameterValueType(IntPtr parameterObjectPtr, string parameterName)
Get a parameter value type from a parameter object.
| Parameter | Type | Description |
|---|---|---|
|
IntPtr |
Pointer to parameter object returned by getParameterNetObject |
|
String |
Name of the parameter to get |
Returns: Returns the parameter value as a string
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET29_18.gnet")
# Approach 1 (direct ctypes):
# Set up function signatures for parameter object functions
mydll.getParameterNetObject.restype = c_void_p
mydll.getParameterValue.restype = c_wchar_p
mydll.getParameterValueType.restype = c_wchar_p
# Set up parameter types for the functions
mydll.getParameterValue.argtypes = [c_void_p, c_wchar_p]
mydll.getParameterValueType.argtypes = [c_void_p, c_wchar_p]
# Get parameter object
param_obj = mydll.getParameterNetObject("GPI.PI_1")
if param_obj is None or param_obj == 0:
print(mydll.getLastErrorMessage())
exit()
# Get parameter value type
# if the parameter value is a c_void_p, it will return "pointer" that can be used to get the parameter object using getParameterObjectValue
# if the parameter is a primitive type, it will return the type name and if it is a time series, it will return the type name and " - timeseries"
type_str = mydll.getParameterValueType(param_obj, "Name")
if type_str is None:
msg = mydll.getLastErrorMessage()
if msg is not None:
print(msg)
exit()
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET29_18.gnet")
# Approach 2 (recommended with ParameterObject wrapper):
# this is a wrapper to allow to use the parameter object as python object
# getParameterValueType will be used internally to use current endpoint to get value of the parameter(getParameterValue, getParameterValueByTimeStep, getParameterObjectValue,getParameterTimeSeries)
gpo_obj= ParameterObject.get_net_object(mydll, "GPO.001")
type_str = gpo_obj.Name
print(type_str)
string getParameterValueByTimeStep(IntPtr parameterObjectPtr, string parameterName, string timeStep)
Get a parameter value from a parameter object for a specific time step.
| Parameter | Type | Description |
|---|---|---|
|
IntPtr |
Pointer to parameter object returned by getParameterNetObject |
|
String |
Name of the parameter to get |
|
String |
Time step index (use -1 for default) |
Returns: Returns the parameter value as a string
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\DYN_6.gsce")
# Approach 1 (direct ctypes):
# Set up function signatures for parameter object functions
mydll.getParameterNetObject.restype = c_void_p
mydll.getParameterValue.restype = c_wchar_p
mydll.setParameterValue.restype = c_bool
# Set up parameter types for the functions
mydll.getParameterValue.argtypes = [c_void_p, c_wchar_p]
mydll.setParameterValue.argtypes = [c_void_p, c_wchar_p, c_wchar_p]
# Get parameter object
param_obj = mydll.getParameterNetObject("GNO.001")
if param_obj is None or param_obj == 0:
print(mydll.getLastErrorMessage())
exit()
# Get parameter value
value = mydll.getParameterValueByTimeStep(param_obj, "PMAX", "+2") # +2, start, end, 6:20,5/6, etc.
if value is None:
msg = mydll.getLastErrorMessage()
if msg is not None:
print(msg)
exit()
print(value)
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\DYN_6.gsce")
# Approach 2 (recommended with ParameterObject wrapper):
# this is a wrapper to allow to use the parameter object as python object
gno_obj= ParameterObject.get_net_object(mydll, "GNO.001")
value = gno_obj.PMAX["+2"]
print(value)
APIExport.PointerArray getParameterTimeSeries(IntPtr parameterObjectPtr, string parameterName)
| Parameter | Type | Description |
|---|---|---|
|
IntPtr |
|
|
String |
Returns: None
releaseParameterObject(IntPtr parameterObjectPtr)
Release a parameter object and free its memory.
| Parameter | Type | Description |
|---|---|---|
|
IntPtr |
Pointer to parameter object returned by getParameterNetObject |
bool setParameterValue(IntPtr parameterObjectPtr, string parameterName, string value)
Set a parameter value on a parameter object.
| Parameter | Type | Description |
|---|---|---|
|
IntPtr |
Pointer to parameter object returned by getParameterNetObject |
|
String |
Name of the parameter to set |
|
String |
Value to set |
Returns: Returns true if successful, false otherwise
SetScenarioParameter(string paramName, string value)
Set scenario parameter
| Parameter | Type | Description |
|---|---|---|
|
String |
Parameter Name |
|
String |
Parameter Value |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_DYN.esce")
mydll.SetScenarioParameter("AverageFlowPrf","True")
releaseArrayObject(IntPtr arrayPointer)
Release a array pointer and free its memory.
| Parameter | Type | Description |
|---|---|---|
|
IntPtr |
Pointer to array object returned by getE/G/TNetObj or getE/G/TPrf or getE/G/TEvt |
4. Functions for Projects
openPRJ(string PrjFile)
Open a project and load it into memory.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to project file (*.prj) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openPRJ("C:\\Project1.prj")
openSES(string SesFile)
Open a session of a related project and load it into memory.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to session file (*.ses) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openSES("C:\\Project1_Session1.ses")
5. Functions for Networks
-
Electric Model
-
Gas Model
-
Thermal Model
-
Hub systems
openENET(string ENETFile)
Open an electric network model and load it into memory.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to electric network file (*.enet) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
importENET(string ImportFile)
Import an electric network model from a network import file and load it into memory.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to network import file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.importENET("C:\\Template_ENET.xlsx")
exportENET(string ImportFile)
Export an electric network to network import file.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to network import file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.exportENET("C:\\Export_to_ENET_Import.xlsx")
paraimportENET(string ImportFile)
Import a parameter import file and apply it to a loaded electric network model.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to parameter import file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.paraimportENET("C:\\ENET_ParaImport.xlsx")
paraexportENET(string ExportFile)
Export an input parameter for an electric network model.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to parameter import file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.paraexportENET("C:\\ENET_ParaExport.xlsx")
importWTPC(string ImportFile)
Import a wind turbine power curve to a loaded electric network.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to import wind turbine power curve file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.importWTPC("C:\\ENET_WTPCExport.xlsx")
includeWTPC(string WTPCFile)
Include a wind turbine power curve to a loaded electric network.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to wind turbine power curve file (*.wtpc) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.includeWTPC("C:\\ENET_WTPCInclude.wtpc")
exportWTPC(string ExportFile)
Export a wind turbine power curve from a loaded electric network to an import or include file.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to file to export to (*.wtpc | *.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.exportWTPC("C:\\ENET_WTPCExport.xlsx")
importFCC(string ImportFile)
Import a fuel consumption curve to a loaded electric network.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to import fuel consumption curve file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.importFCC("C:\\ENET_FCCData.xlsx")
includeFCC(string FCCFile)
Include a fuel consumption curve to a loaded electric network.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to fuel consumption curve file (*.fcc) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.includeFCC("C:\\ENET_FCCInclude.fcc")
exportFCC(string ExportFile)
Export a fuel consumption curve from a loaded electric network to an import or include file.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to file to export to (*.fcc | *.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.exportFCC("C:\\ENET_FCCExport.xlsx")
joinENET(string MainENETFile, string ENETFileToAdd, string targetENETFile, bool PreserveContainers, bool LoadAfter)
Join an electric network model from a network file to another electric network model from network file and save the combined network to the target file. Each network must be in a different directory.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to main electric network file (*.enet) |
|
String |
Full path to electric network file to add (*.enet) |
|
String |
Full path to electric network file to save (*.enet) |
|
Boolean |
Set true to preserve the existing subsystems (Zones,Subs,Groups) in the main network |
|
Boolean |
Set true to load the target network after the join process |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.joinENET("C:\\A\\ENET30.enet","C:\\B\\ENET5.enet","C:\\C\\newENET.enet",False,True)
joinToLoadedENET(string ENETFileToAdd, string targetNetFile, bool PreserveContainers, bool LoadAfter)
Join an electric network model from a network file to loaded electric network model and save the combined network to the target file. Each network must be in a different directory.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to electric network file to add (*.enet) |
|
String |
Full path to electric network file to save (*.enet) |
|
Boolean |
Set true to preserve the existed the subsystems ( Zones,Subs,Groups) in the main network |
|
Boolean |
Set true to load the target network after the include process |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.joinToLoadedENET("C:\\A\\ENET5.enet","C:\\B\\newENET.enet",False,True)
convertCRSENET(string targetFileName, string sourceEPSG_ID, string targetEPSG_ID, bool transferWholeNet)
Convert the nodes and vertices coordinates of an electric network from one coordinate reference system to another using the EPSG code.
| Parameter | Type | Description |
|---|---|---|
|
String |
File name of target network file. |
|
String |
String with EPSG code or WKT String of the source CRS (e.g. 32632 | Default | None) |
|
String |
String with EPSG code or WKT String of the target CRS (e.g. 32632 | Default | None) |
|
Boolean |
transfer all file in the network’s folder to the new location |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.convertCRSENET("C:\\NewFolder\\ENET30_Geo.enet","32632","Default",True)
exportENETByEPSGID(string ImportFile, string EPSG_ID)
Export an electric network to network import file with a new CRS indicated by an EPSG code.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to network import file (*.xlsx | *.xls | *.txt | *.csv) |
|
String |
EPSG Coordinate System code (e.g. 32632) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.exportENETByEPSGID("C:\\Export_to_ENET_Import.xlsx","32632")
saveENET()
saveENETCopy(string CopyOfENETFile)
| Parameter | Type | Description |
|---|---|---|
|
String |
openGNET(string GNETFile)
Open a gas network model and load it into memory.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to gas network file (*.gnet) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
importGNET(string ImportFile)
Import a gas network model from a network import file and load it into memory.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to network import file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.importGNET("C:\\Template_GNET.xlsx")
exportGNET(string ImportFile)
Export a gas network to network import file.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to network import file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.exportGNET("C:\\Export_to_GNET_Import.xlsx")
paraimportGNET(string ImportFile)
Import a parameter import file and apply it to a loaded gas network model.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to parameter import file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.paraimportGNET("C:\\GNET_ParaImport.xlsx")
paraexportGNET(string ExportFile)
Export an input parameter for a gas network model.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to parameter import file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.paraexportGNET("C:\\GNET_ParaExport.xlsx")
importQUAL(string ImportFile)
Import a gas quality from an import file to a gas network.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to gas quality import file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.importQUAL("C:\\GNET_QUALImport.xlsx")
exportQUAL(string ExportFile)
Export a gas quality from a gas network to an import or include file.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to file to export to (*.qual | *.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.exportQUAL("C:\\GNET_QUALExport.xlsx")
importSynNET(string SynergiFile)
Import a gas network model from a Synergi database file and load it into memory.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to Synergi database file (*.mdb) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.importSynNET("C:\\GasNet.mdb")
joinGNET(string MainGNETFile, string GNETFileToAdd, string targetGNETFile, bool PreserveContainers, bool LoadAfter)
Join a gas network model from a network file to another gas network model from another network file and save the combined network to the target file. Each network must be in a different directory.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to main gas network file (*.gnet) |
|
String |
Full path to gas network file to add (*.gnet) |
|
String |
Full path to gas network file to save (*.gnet) |
|
Boolean |
Set true to preserve the existing subsystems (Zones,Subs,Groups) in the main network |
|
Boolean |
Set true to load the target network after the join process |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.joinGNET("C:\\A\\GNET30.gnet","C:\\B\\GNET5.gnet","C:\\C\\newGNET.gnet",False,True)
joinToLoadedGNET(string GNETFileToAdd, string targetNetFile, bool PreserveContainers, bool LoadAfter)
Join a gas network model from a network file to loaded gas network model and save the combined network to the target file. Each network must be in a different directory.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to gas network file to add (*.gnet) |
|
String |
Full path to gas network file to save (*.gnet) |
|
Boolean |
Set true to preserve the existed the subsystems ( Zones,Subs,Groups) in the main network |
|
Boolean |
Set true to load the target network after the include process |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.joinToLoadedGNET("C:\\A\\GNET5.gnet","C:\\B\\newGNET.gnet",False,True)
convertCRSGNET(string targetFileName, string sourceEPSG_ID, string targetEPSG_ID, bool transferWholeNet)
Convert nodes and vertices coordinates of a gas network from one coordinate reference system to another using the EPSG code.
| Parameter | Type | Description |
|---|---|---|
|
String |
File name of target network file. |
|
String |
String with EPSG code or WKT String of the source CRS (e.g. 32632 | Default | None) |
|
String |
String with EPSG code or WKT String of the target CRS (e.g. 32632 | Default | None) |
|
Boolean |
transfer all file in the network’s folder to the new location |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.convertCRSGNET("C:\\NewFolder\\GNET30_Geo.gnet","32632","Default", True)
exportGNETByEPSGID(string ImportFile, string EPSG_ID)
Export a gas network to network import file with a new CRS indicated by an EPSG code.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to network import file (*.xlsx | *.xls | *.txt | *.csv) |
|
String |
EPSG Coordinate System code (e.g. 32632) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.exportGNETByEPSGID("C:\\Export_to_GNET_Import.xlsx","32632")
saveGNET()
saveGNETCopy(string CopyOfGNETFile)
| Parameter | Type | Description |
|---|---|---|
|
String |
openTNET(string TNETFile)
Open a thermal network model and load it into memory.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to thermal network file (*.tnet) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
importTNET(string ImportFile)
Import a thermal network model from a network import file and load it into memory.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to network import file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.importTNET("C:\\Template_TNET.xlsx")
exportTNET(string ImportFile)
Export a thermal network to network import file.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to network import file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.exportTNET("C:\\Export_to_TNET_Import.xlsx")
paraimportTNET(string ImportFile)
Import a parameter import file and apply it to a loaded thermal network model.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to parameter import file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.paraimportTNET("C:\\TNET_ParaImport.xlsx")
paraexportTNET(string ExportFile)
Export an input parameter for a thermal network model.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to parameter import file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.paraexportTNET("C:\\TNET_ParaExport.xlsx")
joinTNET(string MainTNETFile, string TNETFileToAdd, string targetTNETFile, bool PreserveContainers, bool LoadAfter)
Join a thermal network model from a network file to another thermal network model from network file and save the combined network to the target file. Each network must be in a different directory.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to main thermal network file (*.tnet) |
|
String |
Full path to thermal network file to add (*.tnet) |
|
String |
Full path to thermal network file to save (*.tnet) |
|
Boolean |
Set true to preserve the existing subsystems (Zones,Subs,Groups) in the main network |
|
Boolean |
Set true to load the target network after the join process |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.joinTNET("C:\\A\\TNET30.tnet","C:\\B\\TNET5.tnet","C:\\C\\newTNET.tnet",False,True)
joinToLoadedTNET(string TNETFileToAdd, string targetNetFile, bool PreserveContainers, bool LoadAfter)
Join a thermal network model from a network file to loaded thermal network model and save the combined network to the target file. Each network must be in a different directory.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to thermal network file to add (*.tnet) |
|
String |
Full path to thermal network file to save (*.tnet) |
|
Boolean |
Set true to preserve the existed the subsystems ( Zones,Subs,Groups) in the main network |
|
Boolean |
Set true to load the target network after the include process |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.joinToLoadedTNET("C:\\A\\TNET5.tnet","C:\\B\\newTNET.tnet",False,True)
convertCRSTNET(string targetFileName, string sourceEPSG_ID, string targetEPSG_ID, bool transferWholeNet)
Convert the nodes and vertices coordinates of a thermal network from one coordinate reference system to another using the EPSG code.
| Parameter | Type | Description |
|---|---|---|
|
String |
File name of target network file. |
|
String |
String with EPSG code or WKT String of the source CRS (e.g. 32632 | Default | None) |
|
String |
String with EPSG code or WKT String of the target CRS (e.g. 32632 | Default | None) |
|
Boolean |
transfer all file in the network’s folder to the new location |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.convertCRSTNET("C:\\NewFolder\\TNET30_Geo.tnet","32632","Default",True)
exportTNETByEPSGID(string ImportFile, string EPSG_ID)
Export a thermal network to network import file with a new CRS indicated by an EPSG code.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to network import file (*.xlsx | *.xls | *.txt | *.csv) |
|
String |
EPSG Coordinate System code (e.g. 32632) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.exportTNETByEPSGID("C:\\Export_to_TNET_Import.xlsx","32632")
saveTNET()
saveTNETCopy(string CopyOfTNETFile)
| Parameter | Type | Description |
|---|---|---|
|
String |
openHUBS(string HUBFile)
Open a hub system model and load it into memory.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to hub system file (*.hubs) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openHUBS("C:\\HUBS6.hubs")
importHUBS(string ImportFile)
Import a hub system from a hub system import file and load it into memory.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to network import file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.importHUBS("C:\\Template_HUBS.xlsx")
exportHUBS(string ImportFile)
Export a hub system to a hub system import file.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to network import file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openHUBS("C:\\HUBS5.hubs")
mydll.exportHUBS("C:\\Export_to_HUBS_Import.xlsx")
6. Functions for adding objects to Networks
-
Electric Model
-
Gas Model
-
Thermal Model
IntPtr addASVC(string ancillaryServiceObjID)
Add an ancillary service to the currently loaded electric network.
| Parameter | Type | Description |
|---|---|---|
|
String |
The ancillary service object ID in the format 'NetObjType.Name' (e.g., 'ASVC.ASVC_1') |
Returns: Pointer to the created ancillary service object, or 0 if failed
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET04_03.enet")
# Approach 1 (direct ctypes):
mydll.addASVC.argtypes = [c_wchar_p]
mydll.addASVC.restype = c_void_p
# Add an ancillary service with name "ASVC_1"
ancillary_ptr = mydll.addASVC("ASVC.ASVC_1")
if ancillary_ptr is None or ancillary_ptr == 0:
print(mydll.getLastErrorMessage())
exit()
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET04_03.enet")
# Approach 2 (recommended with ParameterObject wrapper):
# Add an ancillary service with name "ASVC_1"
asvc_obj= ParameterObject.add_asvc(mydll, "ASVC.ASVC_1") # This is a wrapper to allow to use the parameter object as python object
print(asvc_obj.ID)
IntPtr addASVCX(string asvcxObjID, string netObjID, string ancillaryServiceObjID)
Add an ancillary service external connection between a network object and an ancillary service in the currently loaded electric network.
| Parameter | Type | Description |
|---|---|---|
|
String |
The ancillary service external object ID in the format 'NetObjType.Name' (e.g., 'ASVCX.ASVCX_1') |
|
String |
The network object ID in the format 'NetObjType.Name' (e.g., 'FGEN.GAS_TURB') |
|
String |
The ancillary service object ID in the format 'NetObjType.Name' (e.g., 'ASVC.ASVC_1') |
Returns: Pointer to the created ancillary service external object, or 0 if failed
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET04_03.enet")
# Approach 1 (direct ctypes):
mydll.addASVCX.argtypes = [c_wchar_p, c_wchar_p, c_wchar_p]
mydll.addASVCX.restype = c_void_p
asvcx_ptr = mydll.addASVCX("ASVCX.ASVCX_1", "FGEN.GAS_TURB", "ASVC.ASVC_1")
if asvcx_ptr is None or asvcx_ptr == 0:
print(mydll.getLastErrorMessage())
exit()
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET04_03.enet")
# Approach 2 (recommended with ParameterObject wrapper):
# Link generator GAS_TURB to ancillary service ASVC_1
asvcx_obj= ParameterObject.add_asvcx(mydll, "ASVCX.ASVCX_1", "FGEN.GAS_TURB", "ASVC.ASVC_1") # This is a wrapper to allow to use the parameter object as python object
print(asvcx_obj.ID)
IntPtr addFUEL(string fuelObjID)
Add a fuel to the currently loaded electric network.
| Parameter | Type | Description |
|---|---|---|
|
String |
The fuel object ID in the format 'NetObjType.Name' (e.g., 'FUEL.FUEL_1') |
Returns: Pointer to the created fuel object, or 0 if failed
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
# Approach 1 (direct ctypes):
mydll.addFUEL.argtypes = [c_wchar_p]
mydll.addFUEL.restype = c_void_p
# Add a fuel with name "FUEL_1"
fuel_ptr = mydll.addFUEL("FUEL.FUEL_1")
if fuel_ptr is None or fuel_ptr == 0:
print(mydll.getLastErrorMessage())
exit()
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
# Approach 2 (recommended with ParameterObject wrapper):
# Add a fuel with name "FUEL_1"
fuel_obj= ParameterObject.add_fuel(mydll, "FUEL.FUEL_1") # This is a wrapper to allow to use the parameter object as python object
print(fuel_obj.ID)
IntPtr addEVAR(string variableObjID, string netObjID, string electricConstraintObjID, string variableName)
Add a variable to an electric constraint in the currently loaded electric network.
| Parameter | Type | Description |
|---|---|---|
|
String |
The variable object ID in the format 'NetObjType.Name' (e.g., 'EVAR.EVAR_1') |
|
String |
The network object ID in the format 'NetObjType.Name' (e.g., 'ENO.NO_1') |
|
String |
The electric constraint object ID in the format 'NetObjType.Name' (e.g., 'ECNSTR.ECNSTR_1') |
|
String |
The variable name as a string (e.g., "P", "VA", "VAL") |
Returns: Pointer to the created variable object, or 0 if failed
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET04_03.enet")
# Approach 1 (direct ctypes):
mydll.addEVAR.argtypes = [c_wchar_p, c_wchar_p, c_wchar_p, c_wchar_p]
mydll.addEVAR.restype = c_void_p
# Add a variable to constraint ECNSTR_1 for node NO_1 with variable name P (power)
variable_ptr = mydll.addEVAR("EVAR.EVAR_1", "ENO.NO_1", "ECNSTR.ECNSTR_1", "P")
if variable_ptr is None or variable_ptr == 0:
print(mydll.getLastErrorMessage())
exit()
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET04_03.enet")
# Approach 2 (recommended with ParameterObject wrapper):
# Add a variable to constraint ECNSTR_1 for node NO_1 with variable name P (power)
evar_obj= ParameterObject.add_evar(mydll, "EVAR.EVAR_1", "ENO.NO_1", "ECNSTR.ECNSTR_1", "P") # This is a wrapper to allow to use the parameter object as python object
print(evar_obj.ID)
IntPtr addECNSTR(string electricConstraintObjID)
Add an electric constraint to the currently loaded electric network.
| Parameter | Type | Description |
|---|---|---|
|
String |
The electric constraint object ID in the format 'NetObjType.Name' (e.g., 'ECNSTR.ECNSTR_1') |
Returns: Pointer to the created electric constraint object, or 0 if failed
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET04_03.enet")
# Approach 1 (direct ctypes):
mydll.addECNSTR.argtypes = [c_wchar_p]
mydll.addECNSTR.restype = c_void_p
# Add an electric constraint with name "ECNSTR_1"
constraint_ptr = mydll.addECNSTR("ECNSTR.ECNSTR_1")
if constraint_ptr is None or constraint_ptr == 0:
print(mydll.getLastErrorMessage())
exit()
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET04_03.enet")
# Approach 2 (recommended with ParameterObject wrapper):
# Add an electric constraint with name "ECNSTR_1"
ecnstr_obj= ParameterObject.add_ecnstr(mydll, "ECNSTR.ECNSTR_1") # This is a wrapper to allow to use the parameter object as python object
print(ecnstr_obj.ID)
IntPtr addHYDP(string hydroPlantObjID)
Add a hydro plant to the currently loaded electric network.
| Parameter | Type | Description |
|---|---|---|
|
String |
The hydro plant object ID in the format 'NetObjType.Name' (e.g., 'HYDP.HYDP_1') |
Returns: Pointer to the created hydro plant object, or 0 if failed
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
# Approach 1 (direct ctypes):
mydll.addHYDP.argtypes = [c_wchar_p]
mydll.addHYDP.restype = c_void_p
# Add a hydro plant with name "HYDP_1"
hydroplant_ptr = mydll.addHYDP("HYDP.HYDP_1")
if hydroplant_ptr is None or hydroplant_ptr == 0:
print(mydll.getLastErrorMessage())
exit()
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
# Approach 2 (recommended with ParameterObject wrapper):
# Add a hydro plant with name "HYDP_1"
hydp_obj= ParameterObject.add_hydp(mydll, "HYDP.HYDP_1") # This is a wrapper to allow to use the parameter object as python object
print(hydp_obj.ID)
IntPtr addENO(string nodeObjID)
Add a node to the currently loaded electric network.
| Parameter | Type | Description |
|---|---|---|
|
String |
The node object ID in the format 'NetObjType.Name' (e.g., 'ENO.ENO_1') |
Returns: Pointer to the created node object, or IntPtr.Zero if failed
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
# Approach 1 (direct ctypes):
mydll.addENO.argtypes = [c_wchar_p]
mydll.addENO.restype = c_void_p
# Add a node of type "Bus" with name "B1"
node_ptr = mydll.addENO("ENO.ENO_1")
if node_ptr is None or node_ptr == 0:
print(mydll.getLastErrorMessage())
exit()
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
# Approach 2 (recommended with ParameterObject wrapper):
# Add a node of type "Bus" with name "B1"
eno_obj= ParameterObject.add_eno(mydll, "ENO.ENO_1") # This is a wrapper to allow to use the parameter object as python object
print(eno_obj.ID)
IntPtr addEBR(string branchObjID, string fromNodeObjID, string toNodeObjID)
Add a branch to the currently loaded electric network.
| Parameter | Type | Description |
|---|---|---|
|
String |
The branch object ID in the format 'NetObjType.Name' (e.g., 'LI.Line_1') |
|
String |
The from node object ID in the format 'NetObjType.Name' (e.g., 'ENO.ENO_1') |
|
String |
The to node object ID in the format 'NetObjType.Name' (e.g., 'ENO.ENO_2') |
Returns: Pointer to the created branch object, or IntPtr.Zero if failed
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
# Approach 1 (direct ctypes):
mydll.addEBR.argtypes = [c_wchar_p, c_wchar_p, c_wchar_p]
mydll.addEBR.restype = c_void_p
# Add a branch of type "Line" with name "Line_1" from node "ENO_1" to node "ENO_2"
branch_ptr = mydll.addEBR("LI.Line_1", "ENO.ENO_1", "ENO.ENO_2")
if branch_ptr is None or branch_ptr == 0:
print(mydll.getLastErrorMessage())
exit()
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
# Approach 2 (recommended with ParameterObject wrapper):
# Add a branch of type "Line" with name "Line_1" from node "ENO_1" to node "ENO_2"
ebr_obj= ParameterObject.add_ebr(mydll, "LI.Line_1", "ENO.ENO_1", "ENO.ENO_2") # This is a wrapper to allow to use the parameter object as python object
print(ebr_obj.ID)
IntPtr addEXT(string externalObjID, string parentNodeObjID, string additionalParam)
Add an external object to the currently loaded electric network.
| Parameter | Type | Description |
|---|---|---|
|
String |
The external object ID in the format 'NetObjType.Name' (e.g., 'EDEM.EDEM_1', 'FGEN.FGEN_1') |
|
String |
The parent node object ID in the format 'NetObjType.Name' (e.g., 'ENO.ENO_1') |
|
String |
Optional additional parameter object ID (required for FGEN: 'FUEL.FUEL_1', for HGEN: 'HYDP.HYDP_1') |
Returns: Pointer to the created external object, or IntPtr.Zero if failed
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
# Approach 1 (direct ctypes):
mydll.addEXT.argtypes = [c_wchar_p, c_wchar_p, c_wchar_p]
mydll.addEXT.restype = c_void_p
# Add an electric demand external with name "EDEM_1" to node "ENO_1"
external_ptr = mydll.addEXT("EDEM.EDEM_1", "ENO.ENO_1", None)
if external_ptr is None or external_ptr == 0:
print(mydll.getLastErrorMessage())
exit()
# Add a fuel generator with name "FGEN_1" to node "ENO_1" connected to fuel "FUEL_1"
external_ptr = mydll.addEXT("FGEN.FGEN_1", "ENO.ENO_1", "FUEL.FUEL_1")
if external_ptr is None or external_ptr == 0:
print(mydll.getLastErrorMessage())
exit()
# Add a hydro generator with name "HGEN_1" to node "ENO_2" connected to hydro plant "HYDP_1"
external_ptr = mydll.addEXT("HGEN.HGEN_1", "ENO.ENO_2", "HYDP.HYDP_1")
if external_ptr is None or external_ptr == 0:
print(mydll.getLastErrorMessage())
exit()
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
# Approach 2 (recommended with ParameterObject wrapper):
# Add an electric demand external with name "EDEM_1" to node "ENO_1"
external_obj= ParameterObject.add_ext(mydll, "EDEM.EDEM_1", "ENO.ENO_1", None) # This is a wrapper to allow to use the parameter object as python object
print(external_obj.ID)
# Add a fuel generator with name "FGEN_1" to node "ENO_1" connected to fuel "FUEL_1"
external_obj= ParameterObject.add_ext(mydll, "FGEN.FGEN_1", "ENO.ENO_1", "FUEL.FUEL_1") # This is a wrapper to allow to use the parameter object as python object
print(external_obj.ID)
# Add a hydro generator with name "HGEN_1" to node "ENO_2" connected to hydro plant "HYDP_1"
external_obj= ParameterObject.add_ext(mydll, "HGEN.HGEN_1", "ENO.ENO_2", "HYDP.HYDP_1") # This is a wrapper to allow to use the parameter object as python object
print(external_obj.ID)
IntPtr addCTG(string ctgObjID, string contingencyElementID)
Add a contingency to the currently loaded electric network.
| Parameter | Type | Description |
|---|---|---|
|
String |
The contingency object ID in the format 'NetObjType.Name' (e.g., 'CTG.CTG_1') |
|
String |
The contingency element object ID in the format 'NetObjType.Name' (e.g., 'LI.LINE_1') |
Returns: Pointer to the created contingency object, or 0 if failed
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET04_03.enet")
# Approach 1 (direct ctypes):
mydll.addCTG.argtypes = [c_wchar_p, c_wchar_p]
mydll.addCTG.restype = c_void_p
# Add a contingency with name "CTG_1" for line "LI_1"
ctg_ptr = mydll.addCTG("CTG.CTG_1", "LI.LI_1")
if ctg_ptr is None or ctg_ptr == 0:
print(mydll.getLastErrorMessage())
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET04_03.enet")
# Approach 2 (recommended with ParameterObject wrapper):
# Add a contingency with name "CTG_1" for line "LI_1"
ctg_obj= ParameterObject.add_ctg(mydll, "CTG.CTG_1", "LI.LI_1") # This is a wrapper to allow to use the parameter object as python object
print(ctg_obj.ID)
IntPtr addMBR(string mbrObjID, string ctgObjID, string branchObjID)
Add a monitored branch to a contingency in the currently loaded electric network.
| Parameter | Type | Description |
|---|---|---|
|
String |
The monitored branch object ID in the format 'NetObjType.Name' (e.g., 'MBR.MBR_1') |
|
String |
The contingency object ID in the format 'NetObjType.Name' (e.g., 'CTG.CTG_1') |
|
String |
The electric branch object ID in the format 'NetObjType.Name' (e.g., 'LI.LINE_1' or 'TRF.XFMR_1') |
Returns: Pointer to the created monitored branch object, or IntPtr.Zero if failed
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET04_03.enet")
# Approach 1 (direct ctypes):
mydll.addCTG.argtypes = [c_wchar_p, c_wchar_p]
mydll.addCTG.restype = c_void_p
mydll.addMBR.argtypes = [c_wchar_p, c_wchar_p, c_wchar_p]
mydll.addMBR.restype = c_void_p
# Add a contingency with name "CTG_1" for line "LI_1"
ctg_ptr = mydll.addCTG("CTG.CTG_1", "LI.LI_1")
if ctg_ptr is None or ctg_ptr == 0:
print(mydll.getLastErrorMessage())
exit()
# Add a monitored branch "MBR_1" to contingency "CTG_1" for line "LI_2"
mbr_ptr = mydll.addMBR("MBR.MBR_1", "CTG.CTG_1", "LI.LI_2")
if mbr_ptr is None or mbr_ptr == 0:
print(mydll.getLastErrorMessage())
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET04_03.enet")
# Approach 2 (recommended with ParameterObject wrapper):
# Add a contingency with name "CTG_1" for line "LI_1"
ctg_obj= ParameterObject.add_ctg(mydll, "CTG.CTG_1", "LI.LI_1") # This is a wrapper to allow to use the parameter object as python object
print(ctg_obj.ID)
# Add a monitored branch "MBR_1" to contingency "CTG_1" for line "LI_2"
mbr_obj= ParameterObject.add_mbr(mydll, "MBR.MBR_1", "CTG.CTG_1", "LI.LI_2") # This is a wrapper to allow to use the parameter object as python object
print(mbr_obj.ID)
APIExport.PointerArray getEOBJ(string objType, string name)
| Parameter | Type | Description |
|---|---|---|
|
String |
|
|
String |
Returns: None
beginEBatchUpdate()
Begin batch update mode for the electric network.Call this before making multiple network modifications (adding nodes, branches, externals, etc.) to significantly improve performance.Must be followed by endEBatchUpdate() to finalize the changes.
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
# Begin batch mode
mydll.beginEBatchUpdate()
# Add multiple network objects (nodes, branches, externals, etc.)
for i in range(100):
mydll.addEBR(f"LI.Line_{i}", f"ENO.Node_{i}", f"ENO.Node_{i+1}")
# End batch mode (finalizes all changes)
mydll.endEBatchUpdate()
endEBatchUpdate()
End batch update mode for the electric network.Finalizes all changes made during batch mode by calling SetLinks() once.
# See beginEBatchUpdate() for full example
mydll.endEBatchUpdate()
IntPtr addGNO(string nodeObjID)
Add a node to the currently loaded gas network.
| Parameter | Type | Description |
|---|---|---|
|
String |
The node object ID in the format 'NetObjType.Name' (e.g., 'GNO.GNO_1') |
Returns: Pointer to the created node object, or IntPtr.Zero if failed
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
# Approach 1 (direct ctypes):
mydll.addGNO.argtypes = [c_wchar_p]
mydll.addGNO.restype = c_void_p
# Add a node of type "GasNode" with name "N1"
node_ptr = mydll.addGNO("GNO.GNO_1")
if node_ptr is None or node_ptr == 0:
print(mydll.getLastErrorMessage())
exit()
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
# Approach 2 (recommended with ParameterObject wrapper):
# Add a node of type "GasNode" with name "N1"
gno_obj= ParameterObject.add_gno(mydll, "GNO.GNO_1") # This is a wrapper to allow to use the parameter object as python object
print(gno_obj.ID)
IntPtr addGBR(string branchObjID, string fromNodeObjID, string toNodeObjID)
Add a branch to the currently loaded gas network.
| Parameter | Type | Description |
|---|---|---|
|
String |
The branch object ID in the format 'NetObjType.Name' (e.g., 'GPI.GPI_1') |
|
String |
The from node object ID in the format 'NetObjType.Name' (e.g., 'GNO.GNO_1') |
|
String |
The to node object ID in the format 'NetObjType.Name' (e.g., 'GNO.GNO_2') |
Returns: Pointer to the created branch object, or IntPtr.Zero if failed
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
# Approach 1 (direct ctypes):
mydll.addGBR.argtypes = [c_wchar_p, c_wchar_p, c_wchar_p]
mydll.addGBR.restype = c_void_p
# Add a branch of type "Pipe" with name "GPI_1" from node "GNO_1" to node "GNO_2"
branch_ptr = mydll.addGBR("GPI.GPI_1", "GNO.GNO_1", "GNO.GNO_2")
if branch_ptr is None or branch_ptr == 0:
print(mydll.getLastErrorMessage())
exit()
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
# Approach 2 (recommended with ParameterObject wrapper):
# Add a branch of type "Pipe" with name "GPI_1" from node "GNO_1" to node "GNO_2"
gbr_obj= ParameterObject.add_gbr(mydll, "GPI.GPI_1", "GNO.GNO_1", "GNO.GNO_2") # This is a wrapper to allow to use the parameter object as python object
print(gbr_obj.ID)
IntPtr addGXT(string externalObjID, string parentNodeObjID, string additionalParam)
Add an external object to the currently loaded gas network.
| Parameter | Type | Description |
|---|---|---|
|
String |
The external object ID in the format 'NetObjType.Name' (e.g., 'GDEM.GDEM_1') |
|
String |
The parent node object ID in the format 'NetObjType.Name' (e.g., 'GNO.GNO_1') |
|
String |
Optional additional parameter object ID (e.g., for specialized externals that require connections) |
Returns: Pointer to the created external object, or IntPtr.Zero if failed
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
# Approach 1 (direct ctypes):
mydll.addGXT.argtypes = [c_wchar_p, c_wchar_p, c_wchar_p]
mydll.addGXT.restype = c_void_p
# Add a gas demand external with name "GDEM_1" to node "GNO_1"
external_ptr = mydll.addGXT("GDEM.GDEM_1", "GNO.GNO_1", None)
if external_ptr is None or external_ptr == 0:
print(mydll.getLastErrorMessage())
exit()
# Add a gas supply external with name "GSUP_1" to node "GNO_2"
external_ptr = mydll.addGXT("GSUP.GSUP_1", "GNO.GNO_2", None)
if external_ptr is None or external_ptr == 0:
print(mydll.getLastErrorMessage())
exit()
mydll = cdll.LoadLibrary("SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
# Approach 2 (recommended with ParameterObject wrapper):
# Add a gas demand external with name "GDEM_1" to node "GNO_1"
external_obj= ParameterObject.add_gxt(mydll, "GDEM.GDEM_1", "GNO.GNO_1", None) # This is a wrapper to allow to use the parameter object as python object
print(external_obj.ID)
APIExport.PointerArray getTOBJ(string objType, string name)
| Parameter | Type | Description |
|---|---|---|
|
String |
|
|
String |
Returns: None
beginGBatchUpdate()
Begin batch update mode for the gas network.Call this before making multiple network modifications (adding nodes, branches, externals, etc.) to significantly improve performance.Must be followed by endGBatchUpdate() to finalize the changes.
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
# Begin batch mode
mydll.beginGBatchUpdate()
# Add multiple network objects (nodes, branches, externals, etc.)
for i in range(100):
mydll.addGBR(f"GPI.Pipe_{i}", f"GNO.Node_{i}", f"GNO.Node_{i+1}")
# End batch mode (finalizes all changes)
mydll.endGBatchUpdate()
endGBatchUpdate()
End batch update mode for the gas network.Finalizes all changes made during batch mode by calling SetLinks() once.
# See beginGBatchUpdate() for full example
mydll.endGBatchUpdate()
IntPtr addTNO(string nodeObjID)
Add a node to the currently loaded thermal network.
| Parameter | Type | Description |
|---|---|---|
|
String |
The node object ID in the format 'NetObjType.Name' (e.g., 'TNO.TNO_1') |
Returns: Pointer to the created node object, or IntPtr.Zero if failed
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
# Approach 1 (direct ctypes):
mydll.addTNO.argtypes = [c_wchar_p]
mydll.addTNO.restype = c_void_p
# Add a node of type "ThermalNode" with name "TN1"
node_ptr = mydll.addTNO("TNO.TNO_1")
if node_ptr is None or node_ptr == 0:
print(mydll.getLastErrorMessage())
exit()
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
# Approach 2 (recommended with ParameterObject wrapper):
# Add a node of type "ThermalNode" with name "TN1"
tno_obj= ParameterObject.add_tno(mydll, "TNO.TNO_1") # This is a wrapper to allow to use the parameter object as python object
print(tno_obj.ID)
IntPtr addTBR(string branchObjID, string fromNodeObjID, string toNodeObjID)
Add a branch to the currently loaded thermal network.
| Parameter | Type | Description |
|---|---|---|
|
String |
The branch object ID in the format 'NetObjType.Name' (e.g., 'TPI.TP01') |
|
String |
The from node object ID in the format 'NetObjType.Name' (e.g., 'TNO.HN01') |
|
String |
The to node object ID in the format 'NetObjType.Name' (e.g., 'TNO.HN02') |
Returns: Pointer to the created branch object, or IntPtr.Zero if failed
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET33_25.tnet")
# Approach 1 (direct ctypes):
mydll.addTBR.argtypes = [c_wchar_p, c_wchar_p, c_wchar_p]
mydll.addTBR.restype = c_void_p
# Add a branch of type "ThermalPipe" with name "TP01" from node "HN01" to node "HN02"
branch_ptr = mydll.addTBR("TPI.TP01", "TNO.HN01", "TNO.HN02")
if branch_ptr is None or branch_ptr == 0:
print(mydll.getLastErrorMessage())
exit()
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET33_25.tnet")
# Approach 2 (recommended with ParameterObject wrapper):
# Add a branch of type "ThermalPipe" with name "TP01" from node "HN01" to node "HN02"
branch_obj= ParameterObject.add_tbr(mydll, "TPI.TP01", "TNO.HN01", "TNO.HN02") # This is a wrapper to allow to use the parameter object as python object
print(branch_obj.ID)
IntPtr addTXT(string externalObjID, string parentNodeObjID, string additionalParam)
Add an external object to the currently loaded thermal network.
| Parameter | Type | Description |
|---|---|---|
|
String |
The external object ID in the format 'NetObjType.Name' (e.g., 'HDEM.HDEM_1') |
|
String |
The parent node object ID in the format 'NetObjType.Name' (e.g., 'TNO.TNO_1') |
|
String |
Optional additional parameter object ID (e.g., for specialized externals that require connections) |
Returns: Pointer to the created external object, or IntPtr.Zero if failed
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET33_25.tnet")
# Approach 1 (direct ctypes):
mydll.addTXT.argtypes = [c_wchar_p, c_wchar_p, c_wchar_p]
mydll.addTXT.restype = c_void_p
# Add a thermal demand external with name "HDEM_1" to node "HN01"
external_ptr = mydll.addTXT("HDEM.HDEM_1", "TNO.HN01", None)
if external_ptr is None or external_ptr == 0:
print(mydll.getLastErrorMessage())
exit()
# Add a thermal supply external with name "HSUP_1" to node "HN02"
external_ptr = mydll.addTXT("HSUP.HSUP_1", "TNO.HN02", None)
if external_ptr is None or external_ptr == 0:
print(mydll.getLastErrorMessage())
exit()
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET33_25.tnet")
# Approach 2 (recommended with ParameterObject wrapper):
# Add a thermal demand external with name "HDEM_1" to node "HN01"
external_obj= ParameterObject.add_txt(mydll, "HDEM.HDEM_1", "TNO.HN01", None) # This is a wrapper to allow to use the parameter object as python object
print(external_obj.ID)
APIExport.PointerArray getGOBJ(string objType, string name)
| Parameter | Type | Description |
|---|---|---|
|
String |
|
|
String |
Returns: None
beginTBatchUpdate()
Begin batch update mode for the thermal network.Call this before making multiple network modifications (adding nodes, branches, externals, etc.) to significantly improve performance.Must be followed by endTBatchUpdate() to finalize the changes.
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
# Begin batch mode
mydll.beginTBatchUpdate()
# Add multiple network objects (nodes, branches, externals, etc.)
for i in range(100):
mydll.addTBR(f"TPI.Pipe_{i}", f"TNO.Node_{i}", f"TNO.Node_{i+1}")
# End batch mode (finalizes all changes)
mydll.endTBatchUpdate()
endTBatchUpdate()
End batch update mode for the thermal network.Finalizes all changes made during batch mode by calling SetLinks() once.
# See beginTBatchUpdate() for full example
mydll.endTBatchUpdate()
|
Use the function |
7. Functions for Scenario management
Some special functions to deal with ACPF scenarios and the way the solver handles some objects:
int GetMaxControlIterations()
Get Maximum Control Iterations
Returns: Maximum number of iteration steps for constraint and control handling
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_DYN.esce")
mydll.GetMaxControlIterations.restype = c_int
value = mydll.GetMaxControlIterations()
print(value)
int GetMaxTransformerTapIterations()
Get Maximum Transformer Tap Iterations
Returns: Maximum number of iteration steps for changing the tap position of transformers
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_DYN.esce")
mydll.GetMaxTransformerTapIterations.restype = c_int
value = mydll.GetMaxTransformerTapIterations()
print(value)
SetMaxControlIterations(int value)
Set Maximum Control Iterations
| Parameter | Type | Description |
|---|---|---|
|
Int32 |
Maximum number of iteration steps for constraint and control handling (0-100) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_DYN.esce")
mydll.SetMaxControlIterations(10)
SetMaxTransformerTapIterations(int value)
Set Maximum Transformer Tap Iterations
| Parameter | Type | Description |
|---|---|---|
|
Int32 |
Maximum number of iteration steps for changing the tap position of transformers (1-100) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_DYN.esce")
mydll.SetMaxTransformerTapIterations(10)
SetMaxSwitchedShuntIterations(int value)
Set Maximum Switched Shunt Iterations
| Parameter | Type | Description |
|---|---|---|
|
Int32 |
Maximum number of iteration steps for changing the step position of switched shunts (1-100) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_DYN.esce")
mydll.SetMaxSwitchedShuntIterations(10)
int GetMaxSwitchedShuntIterations()
Get Maximum Switched Shunt Iterations
Returns: Maximum number of iteration steps for changing the step position of switched shunts
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_DYN.esce")
mydll.GetMaxSwitchedShuntIterations.restype = c_int
value = mydll.GetMaxSwitchedShuntIterations()
print(value)
Set of functions for creating, saving, clearing, importing or exporting scenarios.
-
Electric Model
-
Gas Model
-
Thermal Model
newESCE(string ScenarioNameStr, string ScenarioTypeStr, string StartTimeStr, string EndTimeStr, int TimeStep, int TimeHorizon, int TimeLookAhead, int TimeStepLookAhead)
Create a new electric scenario for a loaded electric network model.
| Parameter | Type | Description |
|---|---|---|
|
String |
Scenario name |
|
String |
Scenario type, either "SteadyACPF", "SteadyACOPF", "QuasiDynamicACPF", "QuasiDynamicACOPF", "SteadyDCPF", "SteadyDCOPF", "QuasiDynamicDCPF", "QuasiDynamicDCOPF", or "DCUCOPF" |
|
String |
Start time in the DateTime format set by the user |
|
String |
End time in the DateTime format set by the user |
|
Int32 |
Time step (of time horizon) in minutes |
|
Int32 |
Time horizon (required input) in minutes, only used in "DCUCOPF" |
|
Int32 |
Time look ahead (required input) in minutes, only used in "DCUCOPF" |
|
Int32 |
Time step look ahead (required input) in minutes, only used in "DCUCOPF" |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.newESCE("ENET30_STE", "SteadyACPF", "01/01/2022 00:00", "01/01/2022 01:00", 60, 60, 0, 0)
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.newESCE("ENET30_QDYN", "QuasiDynamicACPF", "01/01/2022 06:00", "02/01/2022 06:00", 15, 15, 0, 0)
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.newESCE("ENET30_PCM", "DCUCOPF", "01/01/2022 00:00", "08/01/2022 00:00", 30, 1440, 1440, 120)
openESCE(string ESCEFile)
Open an electric scenario for a loaded electric network model.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to electric scenario file (*.esce) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_STE.esce")
importESCE(string FileName)
Import a scenario events from an import file to a loaded electric scenario.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to scenario event import file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_QDYN.esce")
mydll.importESCE("C:\\Template_ESCE.xlsx")
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.newGSCE("ENET30_DYN", "QuasiDynamicACPF", "01/01/2022 06:00", "02/01/2022 06:00", 15)
mydll.importESCE("C:\\Template_ESCE.xlsx")
exportESCE(string FileName)
Export an electric scenario events to a scenario event import file.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to scenario event export file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_QDYN.esce")
mydll.exportESCE("C:\\ExportEvents.xlsx")
exportESCEWithDateTimeFormat(string FileName, string DateTimeFormat)
Export electric scenario events to scenario event import file using a user-specified date and time format.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to scenario event export file (*.xlsx | *.xls | *.txt | *.csv) |
|
String |
A supported DateTime format string (e.g., "dd/MM/yyyy HH:mm"). |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_QDYN.esce")
mydll.exportESCEWithDateTimeFormat("C:\\ExportEvents.xlsx", "dd/MM/yyyy HH:mm")
includeESCE(string FileName, string StartTimeStr, string EndTimeStr)
Include an electric scenario to a loaded network model and scenario.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to electric scenario file to include (*.esce) |
|
String |
Start time from which events in the scenario file should be added (similar to time definition for scenario event in GUI and import file) |
|
String |
End time to which events in the scenario file should be added (similar to time definition for scenario event in GUI and import file) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.newESCE("ENET30_QDYN", "QuasiDynamicACPF", "01/01/2022 06:00", "02/01/2022 06:00", 15)
mydll.includeESCE("C:\\ENET30_QDYN2.esce", "+2", "+5")
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.newESCE("ENET30_QDYN", "QuasiDynamicACPF", "01/01/2022 06:00", "02/01/2022 06:00", 15)
mydll.includeESCE("C:\\ENET30_QDYN2.esce", "2:00", "5:00")
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.newESCE("ENET30_QDYN", "QuasiDynamicACPF", "01/01/2022 06:00", "02/01/2022 06:00", 15)
mydll.includeESCE("C:\\ENET30_QDYN2.esce", "1/2:00", "2/5:00")
clearESCE()
Clear loaded scenario events from an electric scenario.
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_QDYN.esce")
mydll.importESCE("C:\\Template_ESCE.xlsx")
mydll.clearESCE()
IntPtr getESCE()
Get pointer to electric scenario object.
Returns: Returns a pointer to the electric scenario object
from ctypes import *
mydll = cdll.LoadLibrary("SAInt-API.dll")
mydll.openENET("ENET04_03.enet")
mydll.openESCE("QDYN_ACPF_1.esce")
# Approach 1 (direct ctypes):
mydll.getGSCE.restype = c_void_p
mydll.setParameterValue.restype = c_bool
mydll.getParameterValue.restype = c_wchar_p
mydll.setParameterValue.argtypes = [c_void_p, c_wchar_p, c_wchar_p]
mydll.getParameterValue.argtypes = [c_void_p, c_wchar_p]
# Get electric scenario object of QDYN_ACPF_1.esce
ptr = mydll.getESCE()
if ptr is None or ptr == 0:
print(mydll.getLastErrorMessage())
exit()
mydll.setParameterValue(ptr, "StartTime", "01/01/2022 06:00")
mydll.setParameterValue(ptr, "EndTime", "02/01/2022 06:00")
mydll.setParameterValue(ptr, "TimeStep", "15")
print(mydll.getParameterValue(ptr, "StartTime"))
print(mydll.getParameterValue(ptr, "EndTime"))
print(mydll.getParameterValue(ptr, "TimeStep"))
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("ENET04_03.enet")
mydll.openESCE("QDYN_ACPF_1.esce")
# Approach 2 (recommended with ParameterObject wrapper):
# Get electric scenario object of QDYN_ACPF_1.esce
scenario= ParameterObject.get_esce(mydll)
scenario.StartTime = "01/01/2022 06:00"
scenario.EndTime = "02/01/2022 06:00"
scenario.TimeStep = "15"
print(scenario.StartTime)
print(scenario.EndTime)
print(scenario.TimeStep)
saveESCE()
Save an active electric scenario to a file
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.newESCE("ENET30_PCM", "DCUCOPF", "01/01/2022 00:00", "08/01/2022 00:00", 1800, 86400, 86400, 7200)
mydll.saveESCE()
saveESCECopy(string CopyOfESCEFile)
Save a copy of an active electric scenario to a file
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to electric scenario file (*.esce) where copy is saved |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_STE.esce")
mydll.saveESCECopy("C:\\ENET30_STECopy.esce")
newGSCE(string ScenarioNameStr, string ScenarioTypeStr, string StartTimeStr, string EndTimeStr, int TimeStep)
Create a new gas scenario for a loaded gas network model.
| Parameter | Type | Description |
|---|---|---|
|
String |
Scenario name |
|
String |
Scenario type, either "SteadyGas" or "DynamicGas" |
|
String |
Start time in the DateTime format set by the user |
|
String |
End time in the DateTime format set by the user |
|
Int32 |
Time step in minutes |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.newGSCE("GNET30_STE", "SteadyGas", "01/01/2022 00:00", "01/01/2022 01:00", 60)
from ctypes import *
mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.newGSCE("GNET30_DYN", "DynamicGas", "01/01/2022 06:00", "02/01/2022 06:00", 15)
openGSCE(string GSCEFile)
Open a gas scenario for a loaded gas network model.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to gas scenario file (*.gsce) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_STE.gsce")
importGSCE(string FileName)
Import scenario events from an import file to a loaded gas scenario.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to scenario event import file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.importGSCE("C:\\Template_GSCE.xlsx")
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.newGSCE("GNET30_DYN", "DynamicGas", "01/01/2022 06:00", "02/01/2022 06:00", 15)
mydll.importGSCE("C:\\Template_GSCE.xlsx")
exportGSCE(string FileName)
Export a gas scenario events to a scenario event import file.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to scenario event export file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.exportGSCE("C:\\ExportEvents.xlsx")
exportGSCEWithDateTimeFormat(string FileName, string DateTimeFormat)
Export gas scenario events to scenario event import file using a user-specified date and time format.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to scenario event export file (*.xlsx | *.xls | *.txt | *.csv) |
|
String |
A supported DateTime format string (e.g., "dd/MM/yyyy HH:mm"). |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.exportGSCEWithDateTimeFormat("C:\\ExportEvents.xlsx", "dd/MM/yyyy HH:mm")
includeGSCE(string FileName, string StartTimeStr, string EndTimeStr)
Include a gas scenario to a loaded network model and scenario.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to gas scenario file to include (*.gsce) |
|
String |
Start time from which events in the scenario file should be added (similar to time definition for scenario event in GUI and import file) |
|
String |
End time to which events in the scenario file should be added (similar to time definition for scenario event in GUI and import file) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.newGSCE("GNET30_DYN", "DynamicGas", "01/01/2022 06:00", "02/01/2022 06:00", 15)
mydll.includeGSCE("C:\\GNET30_DYN2.gsce", "+2", "+5")
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.newGSCE("GNET30_DYN", "DynamicGas", "01/01/2022 06:00", "02/01/2022 06:00", 15)
mydll.includeGSCE("C:\\GNET30_DYN2.gsce", "2:00", "5:00")
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.newGSCE("GNET30_DYN", "DynamicGas", "01/01/2022 06:00", "02/01/2022 06:00", 15)
mydll.includeGSCE("C:\\GNET30_DYN2.gsce", "1/2:00", "2/5:00")
clearGSCE()
Clear Gas Scenario Events
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.importGSCE("C:\\Template_GSCE.xlsx")
mydll.clearGSCE()
IntPtr getGSCE()
Get pointer to gas scenario object.
Returns: Returns a pointer to the gas scenario object
from ctypes import *
mydll = cdll.LoadLibrary("SAInt-API.dll")
mydll.openGNET("GNET29_18.gnet")
mydll.openGSCE("DYN_6.gsce")
# Approach 1 (direct ctypes):
mydll.getGSCE.restype = c_void_p
mydll.setParameterValue.restype = c_bool
mydll.getParameterValue.restype = c_wchar_p
mydll.setParameterValue.argtypes = [c_void_p, c_wchar_p, c_wchar_p]
mydll.getParameterValue.argtypes = [c_void_p, c_wchar_p]
# Get gas scenario object of DYN_6.gsce
ptr = mydll.getGSCE()
if ptr is None or ptr == 0:
print(mydll.getLastErrorMessage())
exit()
mydll.setParameterValue(ptr, "StartTime", "01/01/2022 06:00")
mydll.setParameterValue(ptr, "EndTime", "02/01/2022 06:00")
mydll.setParameterValue(ptr, "TimeStep", "15")
print(mydll.getParameterValue(ptr, "StartTime"))
print(mydll.getParameterValue(ptr, "EndTime"))
print(mydll.getParameterValue(ptr, "TimeStep"))
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("GNET29_18.gnet")
mydll.openGSCE("DYN_6.gsce")
# Approach 2 (recommended with ParameterObject wrapper):
# Get gas scenario object of DYN_6.gsce
scenario= ParameterObject.get_gsce(mydll)
scenario.StartTime = "01/01/2022 06:00"
scenario.EndTime = "02/01/2022 06:00"
scenario.TimeStep = "15"
print(scenario.StartTime)
print(scenario.EndTime)
print(scenario.TimeStep)
saveGSCE()
Save an active gas scenario to a file
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.newGSCE("GNET30_STE", "SteadyGas", "01/01/2022 00:00", "01/01/2022 01:00", 3600)
mydll.saveGSCE()
saveGSCECopy(string CopyOfGSCEFile)
Save a copy of an active gas scenario to a file
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to gas scenario file (*.gsce) where copy is saved |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_STE.gsce")
mydll.saveGSCECopy("C:\\GNET30_STECopy.gsce")
newTSCE(string ScenarioNameStr, string ScenarioTypeStr, string StartTimeStr, string EndTimeStr, int TimeStep)
Create a new thermal scenario for a loaded thermal network model.
| Parameter | Type | Description |
|---|---|---|
|
String |
Scenario name |
|
String |
Scenario type, either "SteadyThermal" or "QuasiDynamicThermal" |
|
String |
Start time in the DateTime format set by the user (e.g. "dd/MM/yyyy HH:mm") |
|
String |
End time in the DateTime format set by the user (e.g. "dd/MM/yyyy HH:mm") |
|
Int32 |
Time step in minutes |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.newTSCE("TNET30_STE", "SteadyThermal, "01/01/2022 00:00", "01/01/2022 01:00", 60)
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.newTSCE("TNET30_DYN", "QuasiDynamicThermal", "01/01/2022 06:00", "02/01/2022 06:00", 15)
openTSCE(string TSCEFile)
Open a thermal scenario for a loaded thermal network model.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to thermal scenario file (*.tsce) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.openTSCE("C:\\TNET30_STE.tsce")
importTSCE(string FileName)
Import a scenario events from an import file to a loaded thermal scenario.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to scenario event import file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.openTSCE("C:\\TNET30_STE.tsce")
mydll.importTSCE("C:\\Template_TSCE.xlsx")
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.newTSCE("TNET30_DYN", "QuasiDynamicThermal", "01/01/2022 06:00", "02/01/2022 06:00", 15)
mydll.importTSCE("C:\\Template_TSCE.xlsx")
exportTSCE(string FileName)
Export a thermal scenario events to a scenario event import file.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to scenario event import file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.openTSCE("C:\\TNET30_DYN.tsce")
mydll.exportTSCE("C:\\ExportEvents.txt")
exportTSCEWithDateTimeFormat(string FileName, string DateTimeFormat)
Export thermal scenario events to scenario event import file using a user-specified date and time format.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to scenario event export file (*.xlsx | *.xls | *.txt | *.csv) |
|
String |
A supported DateTime format string (e.g., "dd/MM/yyyy HH:mm"). |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.openTSCE("C:\\TNET30_DYN.tsce")
mydll.exportTSCEWithDateTimeFormat("C:\\ExportEvents.txt", "dd/MM/yyyy HH:mm")
includeTSCE(string FileName, string StartTimeStr, string EndTimeStr)
Include a thermal scenario to a loaded network model and scenario.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to thermal scenario file to include (*.tsce) |
|
String |
Start time from which events in the scenario file should be added (similar to time definition for scenario event in GUI and import file) |
|
String |
End time to which events in the scenario file should be added (similar to time definition for scenario event in GUI and import file) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.newTSCE("TNET30_DYN", "QuasiDynamicThermal", "01/01/2022 06:00", "02/01/2022 06:00", 15)
mydll.includeTSCE("C:\\TNET30_DYN2.tsce", "+2", "+5")
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.newTSCE("TNET30_DYN", "QuasiDynamicThermal", "01/01/2022 06:00", "02/01/2022 06:00", 15)
mydll.includeTSCE("C:\\TNET30_DYN2.tsce", "2:00", "5:00")
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.newTSCE("TNET30_DYN", "QuasiDynamicThermal", "01/01/2022 06:00", "02/01/2022 06:00", 15)
mydll.includeTSCE("C:\\TNET30_DYN2.tsce", "1/2:00", "2/5:00")
clearTSCE()
Clear loaded scenario events from a thermal scenario.
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.openTSCE("C:\\TNET30_STE.tsce")
mydll.importTSCE("C:\\Template_TSCE.xlsx")
mydll.clearTSCE()
IntPtr getTSCE()
Get pointer to thermal scenario object.
Returns: Returns a pointer to the thermal scenario object
from ctypes import *
mydll = cdll.LoadLibrary("SAInt-API.dll")
mydll.openTNET("TNET33_25.tnet")
mydll.openTSCE("TQDYN.tsce")
# Approach 1 (direct ctypes):
mydll.getTSCE.restype = c_void_p
mydll.setParameterValue.restype = c_bool
mydll.getParameterValue.restype = c_wchar_p
mydll.setParameterValue.argtypes = [c_void_p, c_wchar_p, c_wchar_p]
mydll.getParameterValue.argtypes = [c_void_p, c_wchar_p]
# Get thermal scenario object of TQDYN.tsce
ptr = mydll.getTSCE()
if ptr is None or ptr == 0:
print(mydll.getLastErrorMessage())
exit()
mydll.setParameterValue(ptr, "StartTime", "01/01/2022 06:00")
mydll.setParameterValue(ptr, "EndTime", "02/01/2022 06:00")
mydll.setParameterValue(ptr, "TimeStep", "15")
print(mydll.getParameterValue(ptr, "StartTime"))
print(mydll.getParameterValue(ptr, "EndTime"))
print(mydll.getParameterValue(ptr, "TimeStep"))
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("TNET33_25.tnet")
mydll.openTSCE("TQDYN.tsce")
# Approach 2 (recommended with ParameterObject wrapper):
# Get thermal scenario object of TQDYN.tsce
scenario= ParameterObject.get_tsce(mydll)
scenario.StartTime = "01/01/2022 06:00"
scenario.EndTime = "02/01/2022 06:00"
scenario.TimeStep = "15"
print(scenario.StartTime)
print(scenario.EndTime)
print(scenario.TimeStep)
saveTSCE()
Save an active thremal scenario to a file
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\TNET30.tnet")
mydll.newTSCE("TNET30_STE", "SteadyThermal, "01/01/2022 00:00", "01/01/2022 01:00", 3600)
mydll.saveTSCE()
saveTSCECopy(string CopyOfTSCEFile)
Save a copy of an active thermal scenario to a file
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to thermal scenario file (*.tsce) where copy is saved |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.openTSCE("C:\\TNET30_STE.tsce")
mydll.saveTSCECopy("C:\\TNET30_STECopy.tsce")
|
When importing scenario’s events using Microsoft Excel™ templates, it is important to pay attention at the way Excel deals with date/time data. The format used in the cells must match the one specified in the column header for the properties If an invalid format is provided for SAInt can handle date and time values stored as "text strings" or as numbers (in Excel) as long as valid format is specified. Check the import log for errors, and details. For the property |
7.1. Change DCUCOPF scenario settings
The user can specify some aspects of the optimization problem, like defining the MIP gap or the maximum time the solver has for searching for a solution, or explicitly choose the optimization problem type between MIP or LP.
RelMipGap
The relative MIP gap in the current loaded scenario.
mydll = cdll.LoadLibrary('C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll')
mydll.evalCmdStr('ENET.SCE.RelMipGap=0.05')
TimeLimit
The solver time limit in the current loaded scenario.
mydll = cdll.LoadLibrary('C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll')
mydll.evalCmdStr('ENET.SCE.TimeLimit=600')
SetOptimizationProblemType(string value)
Set Optimization Problem Type
| Parameter | Type | Description |
|---|---|---|
|
String |
Value (MIP | LP) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_DYN.esce")
mydll.SetOptimizationProblemType("LP")
7.2. Change Gurobi settings
SAInt uses Gurobi (https://www.gurobi.com/) as solver for optimization problems related to ACOPF, DCUCOPF, and CEM scenarios. Details on the set of parameters that the user can specify are provided in sections "Scenario settings" for steady state, quasi-dynamic, and DCUCOPF scenarios.
When using the API, Gurobi parameters are set by using the command SetGurobiParameter and specifying the name of the parameter and its value as a string type. For simplicity, SAInt tries to match the corresponding settings as described in the documentation of Gurobi.
SetGurobiParameter(string paramName, string value)
Set Gurobi Optimizer parameter
| Parameter | Type | Description |
|---|---|---|
|
String |
Parameter Name |
|
String |
Parameter Value (SoftMemLimit | PreSolve | AggFill | IntegralityFocus | NumericFocus | MIPFocus | Seed | Threads | ImproveStartGap | Heuristics | OutputFlag | Method | ScaleFlag). |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_DYN.esce")
mydll.SetGurobiParameter("SoftMemLimit", "24")
Examples of how to set the values for the Gurobi parameters.
mydll = cdll.LoadLibrary('C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll')
mydll.SetGurobiParameter("SoftMemLimit", "24")
mydll.SetGurobiParameter("PreSolve", "0")
mydll.SetGurobiParameter("AggFill", "0")
mydll.SetGurobiParameter("IntegralityFocus", "2")
mydll.SetGurobiParameter("NumericFocus", "2")
mydll.SetGurobiParameter("MIPFocus", "1")
mydll.SetGurobiParameter("Seed", "1973")
mydll.SetGurobiParameter("Threads", "4")
mydll.SetGurobiParameter("ImproveStartGap", "0.1")
mydll.SetGurobiParameter("Heuristics", "0.15")
mydll.SetGurobiParameter("OutputFlag", "0")
8. Functions for Scenario execution
These functions apply to all scenario types.
showSIMLOG(bool input)
Show the simulation log in a console window.
| Parameter | Type | Description |
|---|---|---|
|
Boolean |
True if simulation log should be displayed in the console |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.runGSIM.restype = c_int
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.openGCON("C:\\GNET30_STE.gcon")
mydll.showSIMLOG(True)
b = mydll.runGSIM()
print(b)
setSIMLOGFile(string input)
Specify a file to write the simulation log to.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to log file (*.log) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.runGSIM.restype = c_int
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.openGCON("C:\\GNET30_STE.gcon")
mydll.writeSIMLOG(True)
mydll.setSIMLOGFile("C:\\SimOut.log")
b = mydll.runGSIM()
print(b)
writeSIMLOG(bool input)
Write the simulation log to a file.
| Parameter | Type | Description |
|---|---|---|
|
Boolean |
True if simulation log should be written to a file specified by the "setSIMLOGFile" function |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.runGSIM.restype = c_int
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.openGCON("C:\\GNET30_STE.gcon")
mydll.writeSIMLOG(True)
mydll.setSIMLOGFile("C:\\SimOut.log")
b = mydll.runGSIM()
print(b)
-
Electric Model
-
Gas Model
-
Thermal Model
-
Hub Systems
int runESIM()
Run an electric scenario for the loaded electric network, scenario and condition file.
Returns:
-
none = 0
-
Infeasible = 1
-
Feasible = 2
-
Solving = 4
-
Aborted = 8
-
Paused = 16
-
Solved = 32
-
Failed = 64
-
ConstraintViolation = 128
-
AmbientPressureViolation = 256
-
ConstraintHandling = 512
-
MissingPressure = 1028
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.runESIM.restype = c_int
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_QDYN.esce")
mydll.openECON("C:\\ENET30_STE.econ")
b = mydll.runESIM()
print(b)
int runESIMCustomDLL(string AssemblyPath, string NamespaceName, string ClassName)
Run an electric scenario for the loaded electric network, scenario and condition file using a custom dll file.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to custom dll file (*.dll) |
|
String |
Namespace where the class is defined |
|
String |
Name of class where the "ISolverHandler" interface is implemented |
Returns:
-
none = 0
-
Infeasible = 1
-
Feasible = 2
-
Solving = 4
-
Aborted = 8
-
Paused = 16
-
Solved = 32
-
Failed = 64
-
ConstraintViolation = 128
-
AmbientPressureViolation = 256
-
ConstraintHandling = 512
-
MissingPressure = 1028
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.runESIMCustomDLL.restype = c_int
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_DYN.esce")
mydll.openECON("C:\\ENET30_STE.econ")
b = mydll.rungESIMCustomDLL("C:\\MyAssembly.dll", "MyAssembly", "TestClass")
print(b)
int runESIMNoSol()
Run an electric scenario for the loaded electric network, scenario and condition file without creating CON or SOL file.
Returns:
-
none = 0
-
Infeasible = 1
-
Feasible = 2
-
Solving = 4
-
Aborted = 8
-
Paused = 16
-
Solved = 32
-
Failed = 64
-
ConstraintViolation = 128
-
AmbientPressureViolation = 256
-
ConstraintHandling = 512
-
MissingPressure = 1028
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.runESIM.restype = c_int
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_QDYN.esce")
mydll.openECON("C:\\ENET30_STE.econ")
b = mydll.runTSIMNoSol()
print(b)
int runGSIM()
Run a gas scenario for the loaded gas network, scenario and condition file.
Returns:
-
none = 0
-
Infeasible = 1
-
Feasible = 2
-
Solving = 4
-
Aborted = 8
-
Paused = 16
-
Solved = 32
-
Failed = 64
-
ConstraintViolation = 128
-
AmbientPressureViolation = 256
-
ConstraintHandling = 512
-
MissingPressure = 1028
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.runGSIM.restype = c_int
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.openGCON("C:\\GNET30_STE.gcon")
b = mydll.runGSIM()
print(b)
int runGSIMCustomDLL(string AssemblyPath, string NamespaceName, string ClassName)
Run a gas scenario for the loaded gas network, scenario and condition file using a custom dll file.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to custom dll file (*.dll) |
|
String |
Namespace where the class is defined |
|
String |
Name of class where the "ISolverHandler" interface is implemented |
Returns:
-
none = 0
-
Infeasible = 1
-
Feasible = 2
-
Solving = 4
-
Aborted = 8
-
Paused = 16
-
Solved = 32
-
Failed = 64
-
ConstraintViolation = 128
-
AmbientPressureViolation = 256
-
ConstraintHandling = 512
-
MissingPressure = 1028
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.runGSIMCustomDLL.restype = c_int
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.openGCON("C:\\GNET30_STE.gcon")
b = mydll.rungGSIMCustomDLL("C:\\MyAssembly.dll", "MyAssembly", "TestClass")
print(b)
int runGSIMNoSol()
Run a gas scenario for the loaded gas network, scenario and condition file without creating CON or SOL file.
Returns:
-
none = 0
-
Infeasible = 1
-
Feasible = 2
-
Solving = 4
-
Aborted = 8
-
Paused = 16
-
Solved = 32
-
Failed = 64
-
ConstraintViolation = 128
-
AmbientPressureViolation = 256
-
ConstraintHandling = 512
-
MissingPressure = 1028
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.runGSIM.restype = c_int
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.openGCON("C:\\GNET30_STE.gcon")
b = mydll.runGSIMNoSol()
print(b)
setMaxCnstrSteps(int k)
Set the maximum number of steps the solver should perform in the constraint handling loop of a gas simulation.
| Parameter | Type | Description |
|---|---|---|
|
Int32 |
Maximum number of constraint steps in the constraint handling loop |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.openGCON("C:\\GNET30_STE.gcon")
mydll.setMaxCnstrSteps(200)
mydll.runGSIM()
int runTSIM()
Run a thermal scenario for the loaded thermal network, scenario and condition file.
Returns:
-
none = 0
-
Infeasible = 1
-
Feasible = 2
-
Solving = 4
-
Aborted = 8
-
Paused = 16
-
Solved = 32
-
Failed = 64
-
ConstraintViolation = 128
-
AmbientPressureViolation = 256
-
ConstraintHandling = 512
-
MissingPressure = 1028
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.runTSIM.restype = c_int
mydll.openTNET("C:\\TNET30.tnet")
mydll.openTSCE("C:\\TNET30_DYN.tsce")
mydll.openTCON("C:\\TNET30_STE.tcon")
b = mydll.runTSIM()
print(b)
int runTSIMCustomDLL(string AssemblyPath, string NamespaceName, string ClassName)
Run a thermal scenario for the loaded thermal network, scenario and condition file using a custom dll file.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to custom dll file (*.dll) |
|
String |
Namespace where the class is defined |
|
String |
Name of class where the "ISolverHandler" interface is implemented |
Returns:
-
none = 0
-
Infeasible = 1
-
Feasible = 2
-
Solving = 4
-
Aborted = 8
-
Paused = 16
-
Solved = 32
-
Failed = 64
-
ConstraintViolation = 128
-
AmbientPressureViolation = 256
-
ConstraintHandling = 512
-
MissingPressure = 1028
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.runTSIMCustomDLL.restype = c_int
mydll.openTNET("C:\\TNET30.tnet")
mydll.openTSCE("C:\\TNET30_QDYN.tsce")
mydll.openTCON("C:\\TNET30_STE.tcon")
b = mydll.runTSIMCustomDLL("C:\\MyAssembly.dll", "MyAssembly", "TestClass")
print(b)
int runTSIMNoSol()
Run a thermal scenario for the loaded thermal network, scenario and condition file without creating CON or SOL file.
Returns:
-
none = 0
-
Infeasible = 1
-
Feasible = 2
-
Solving = 4
-
Aborted = 8
-
Paused = 16
-
Solved = 32
-
Failed = 64
-
ConstraintViolation = 128
-
AmbientPressureViolation = 256
-
ConstraintHandling = 512
-
MissingPressure = 1028
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.runTSIM.restype = c_int
mydll.openTNET("C:\\TNET30.tnet")
mydll.openTSCE("C:\\TNET30_DYN.tsce")
mydll.openTCON("C:\\TNET30_STE.tcon")
b = mydll.runTSIMNoSol()
print(b)
int runCMBSIM()
Run a combined simulation for the loaded gas and electric network, scenario and condition file.
Returns:
-
none = 0
-
Infeasible = 1
-
Feasible = 2
-
Solving = 4
-
Aborted = 8
-
Paused = 16
-
Solved = 32
-
Failed = 64
-
ConstraintViolation = 128
-
AmbientPressureViolation = 256
-
ConstraintHandling = 512
-
MissingPressure = 1028
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.runCMBSIM.restype = c_int
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.openGCON("C:\\GNET30_STE.gcon")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_QDYN.esce")
mydll.openECON("C:\\ENET30_STE.econ")
b = mydll.runCMBSIM()
print(b)
int runCMBSIMCustomDLL(string AssemblyPath, string NamespaceName, string ClassName)
Run a combined simulation for the loaded gas and electric network, scenario and condition file using a custom dll file.
| Parameter | Type | Description |
|---|---|---|
|
String |
|
|
String |
|
|
String |
Returns:
-
none = 0
-
Infeasible = 1
-
Feasible = 2
-
Solving = 4
-
Aborted = 8
-
Paused = 16
-
Solved = 32
-
Failed = 64
-
ConstraintViolation = 128
-
AmbientPressureViolation = 256
-
ConstraintHandling = 512
-
MissingPressure = 1028
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.runCMBSIM.restype = c_int
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.openGCON("C:\\GNET30_STE.gcon")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_QDYN.esce")
mydll.openECON("C:\\ENET30_STE.econ")
b = mydll.runCMBSIMCustomDLL("C:\\MyAssembly.dll", "MyAssembly", "TestClass")
print(b)
|
The default logging output of the functions |
9. Functions related to Scenario solutions
-
Electric Model
-
Gas Model
-
Thermal Model
openESOL(string SOLFile)
Open an electric solution file to the loaded electric network model.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to electric solution file (*.esol) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_QDYN.esce")
mydll.openESOL("C:\\ENET30_QDYN.esol")
writeESOL(string SOLInputFile, string SOLOutputFile)
Write an electric scenario results to a file using a result description file.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to result description file (*.xlsx | *.xls | *.txt | *.csv) |
|
String |
Path to result output file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_DYN.esce")
mydll.openECON("C:\\ENET30_STE.econ")
mydll.runESIM()
mydll.writeESOL("C:\\SolIn.xlsx", "C:\\SolOutput.xlsx")
writeESOLWithDateTimeFormat(string SOLInputFile, string SOLOutputFile, string DateTimeFormat)
Write an electric scenario results to a file using a result description file and a user-specified date and time format.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to result description file (*.xlsx | *.xls | *.txt | *.csv) |
|
String |
Path to result output file (*.xlsx | *.xls | *.txt | *.csv) |
|
String |
A supported DateTime format string (e.g., "dd/MM/yyyy HH:mm"). |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_DYN.esce")
mydll.openECON("C:\\ENET30_STE.econ")
mydll.runESIM()
mydll.writeESOLWithDateTimeFormat("C:\\SolIn.xlsx", "C:\\SolOutput.xlsx", "dd/MM/yyyy HH:mm")
openECON(string CONFile)
Open a state/condition file for the loaded electric network model.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to electric state file (*.econ) |
from ctypes import *
mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_QDYN.esce")
mydll.openECON("C:\\ENET30_STE.econ")
setECONWriteStatus(bool writefile)
Switch between writing and not writing the electric network state file after simulation.
| Parameter | Type | Description |
|---|---|---|
|
Boolean |
If True state file will be generated after simulation (True | False). |
from ctypes import *
mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_QDYN.esce")
mydll.openECON("C:\\ENET30_QDYN.econ")
mydll.setECONWriteStatus(False)
mydll.runESIM()
exportECON(string Filename, string TimeStr)
Export an electric network state at the specified simulation time to a state file.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to electric state file (*.econ) |
|
String |
Time in the DateTime format set by the user for which state file should be generated (similar to time definition for scenario event in GUI and import file) |
from ctypes import *
mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_QDYN.esce")
mydll.openESOL("C:\\ENET30_QDYN.esol")
mydll.exportECON("C:\\ExportState.econ", "1/2:00")
from ctypes import *
mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_QDYN.esce")
mydll.openESOL("C:\\ENET30_QDYN.esol")
mydll.exportECON("C:\\ExportState.econ", "+2")
openGSOL(string SOLFile)
Open a gas solution file for the loaded gas network model.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to gas solution file (*.gsol) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.openGSOL("C:\\GNET30_DYN.gsol")
writeGSOL(string SOLInputFile, string SOLOutputFile)
Write a gas scenario results to a file using a result description file.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to result description file (*.xlsx | *.xls | *.txt | *.csv) |
|
String |
Path to result output file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.openGCON("C:\\GNET30_STE.gcon")
mydll.runGSIM()
mydll.writeGSOL("C:\\SolIn.xlsx", "C:\\SolOutput.xlsx")
writeGSOLWithDateTimeFormat(string SOLInputFile, string SOLOutputFile, string DateTimeFormat)
Write gas scenario results to file using result description file and a user-specified date and time format.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to result description file (*.xlsx | *.xls | *.txt | *.csv) |
|
String |
Path to result output file (*.xlsx | *.xls | *.txt | *.csv) |
|
String |
A supported DateTime format string (e.g., "dd/MM/yyyy HH:mm"). |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.openGCON("C:\\GNET30_STE.gcon")
mydll.runGSIM()
mydll.writeGSOLWithDateTimeFormat("C:\\SolIn.xlsx", "C:\\SolOutput.xlsx", "dd/MM/yyyy HH:mm")
openGCON(string CONFile)
Open a state/condition file for the loaded gas network model.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to gas state file (*.gcon) |
from ctypes import *
mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.openGCON("C:\\GNET30_STE.gcon")
setGCONWriteStatus(bool writefile)
Switch between writing and not writing the gas network state file after simulation.
| Parameter | Type | Description |
|---|---|---|
|
Boolean |
If True state file will be generated after simulation (True | False). |
from ctypes import *
mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_QDYN.gsce")
mydll.openGCON("C:\\GNET30_QDYN.gcon")
mydll.setGCONWriteStatus(False)
mydll.runGSIM()
exportGCON(string Filename, string TimeStr)
Export a gas network state at the specified simulation time to a state file.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to gas state file (*.gcon) |
|
String |
Time in the DateTime format set by the user for which state file should be generated (similar to time definition for scenario event in GUI and import file) |
from ctypes import *
mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.openGSOL("C:\\GNET30_DYN.gsol")
mydll.exportGCON("C:\\ExportState.gcon", "1/2:00")
from ctypes import *
mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.openGSOL("C:\\GNET30_DYN.gsol")
mydll.exportGCON("C:\\ExportState.gcon", "+2")
openTSOL(string SOLFile)
Open a thermal solution file for the loaded thermal network model.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to gas solution file (*.tsol) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.openTSCE("C:\\TNET30_DYN.tsce")
mydll.openTSOL("C:\\TNET30_DYN.tsol")
writeTSOL(string SOLInputFile, string SOLOutputFile)
Write a thermal scenario results to a file using a result description file.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to result description file (*.xlsx | *.xls | *.txt | *.csv) |
|
String |
Full path to result output file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.openTSCE("C:\\TNET30_DYN.tsce")
mydll.openTCON("C:\\TNET30_STE.tcon")
mydll.runTSIM()
mydll.writeTSOL("C:\\SolIn.xlsx", "C:\\SolOutput.xlsx")
writeTSOLWithDateTimeFormat(string SOLInputFile, string SOLOutputFile, string DateTimeFormat)
Write a thermal scenario results to a file using a result description file and a user-specified date and time format.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to result description file (*.xlsx | *.xls | *.txt | *.csv) |
|
String |
Path to result output file (*.xlsx | *.xls | *.txt | *.csv) |
|
String |
A supported DateTime format string (e.g., "dd/MM/yyyy HH:mm"). |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.openTSCE("C:\\TNET30_DYN.tsce")
mydll.openTCON("C:\\TNET30_STE.tcon")
mydll.runTSIM()
mydll.writeTSOL("C:\\SolIn.xlsx", "C:\\SolOutput.xlsx", "dd/MM/yyyy HH:mm")
openTCON(string CONFile)
Open a state/condition file for the loaded thermal network model.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to thermal state file (*.tcon) |
from ctypes import *
mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.openTSCE("C:\\TNET30_DYN.tsce")
mydll.openTCON("C:\\TNET30_STE.tcon")
setTCONWriteStatus(bool writefile)
Switch between writing and not writing the thermal network state file after simulation.
| Parameter | Type | Description |
|---|---|---|
|
Boolean |
If True state file will be generated after simulation (True | False). |
from ctypes import *
mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.openTSCE("C:\\TNET30_DYN.tsce")
mydll.openTCON("C:\\TNET30_DYN.tcon")
mydll.setTCONWriteStatus(False)
mydll.runTSIM()
exportTCON(string Filename, string TimeStr)
Export a thermal network state at the specified simulation time to a state file.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to gas state file (*.tcon) |
|
String |
Time in the DateTime format set by the user for which state file should be generated (similar to time definition for scenario event in GUI and import file) |
from ctypes import *
mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.openTSCE("C:\\TNET30_DYN.tsce")
mydll.openTSOL("C:\\TNET30_DYN.tsol")
mydll.exportTCON("C:\\ExportState.tcon", "1/2:00")
from ctypes import *
mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.openTSCE("C:\\TNET30_DYN.tsce")
mydll.openTSOL("C:\\TNET30_DYN.tsol")
mydll.exportTCON("C:\\ExportState.tcon", "+2")
10. Functions for Profiles
-
Electric Model
-
Gas Model
-
Thermal Model
importEPRF(string FileName)
Import a profile import file to a loaded electric scenario.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to profile import file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_QDYN.esce")
mydll.importEPRF("C:\\Template_Profile_Import.xlsx")
mydll.importESCE("C:\\Template_ESCE.xlsx")
exportEPRF(string FileName)
Export profiles from the current electric scenario to an export file.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to profile export file (*.prfl) |
from ctypes import *
mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_QDYN.esce")
mydll.exportEPRF("C:\\ExportProfile.prfl")
includeEPRF(string FileName)
Include profiles from a profile file to the current electric scenario.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to profile file (*.prfl) |
from ctypes import *
mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_QDYN.esce")
mydll.includeEPRF("C:\\Profile.prfl")
mydll.importESCE("C:\\Template_ESCE.xlsx")
IntPtr addEPRF(string profileName, string meansValues, string deviationValues)
Adds a profile object to the currently loaded electric scenario and returns a parameter object for further manipulation.If fewer than two items are provided in the profile data, the missing item(s) will be added using default data.
| Parameter | Type | Description |
|---|---|---|
|
String |
Name of the profile to add |
|
String |
Comma-separated list of mean values |
|
String |
Comma-separated list of deviation values |
Returns: Returns a pointer to the profile object
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.newESCE("ENET30_QDYN", "QuasiDynamicACPF", "01/01/2022 06:00", "02/01/2022 06:00", 15)
# Approach 1 (direct ctypes):
# Set up function signatures for parameter object functions
mydll.getParameterValue.restype = c_wchar_p
mydll.setParameterValue.restype = c_bool
mydll.releaseParameterObject.restype = None
mydll.addEPRF.restype = c_void_p
# Set up parameter types for the functions
mydll.getParameterValue.argtypes = [c_void_p, c_wchar_p]
mydll.setParameterValue.argtypes = [c_void_p, c_wchar_p, c_wchar_p]
mydll.addEPRF.argtypes = [c_wchar_p, c_wchar_p, c_wchar_p]
ptr = mydll.addEPRF("profile1", "1.0,2.0,3.0", "0.1,0.2,0.3")
if ptr is None or ptr == 0:
print(mydll.getLastErrorMessage())
exit()
# Access profile properties if needed
print(mydll.getParameterValue(ptr,"name"))
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.newESCE("ENET30_QDYN", "QuasiDynamicACPF", "01/01/2022 06:00", "02/01/2022 06:00", 15)
# Approach 2 (recommended with ParameterObject wrapper):
# this is a wrapper to allow to use the parameter object as python object
profile1= ParameterObject.add_eprf(mydll, "profile1", "1.0,2.0,3.0", "0.1,0.2,0.3")
# Access profile properties if needed
print(profile1.Name)
APIExport.PointerArray getEPRF(string name)
| Parameter | Type | Description |
|---|---|---|
|
String |
Returns: None
bool removeEPRF(IntPtr profilePtr)
Remove a profile from the electric scenario by pointer.
| Parameter | Type | Description |
|---|---|---|
|
IntPtr |
Pointer to the electric profile to remove |
Returns: True if the electric profile was removed, False otherwise
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("ENET30.enet")
mydll.openESCE("ENET30_QDYN.esce")
# Approach 1 (direct ctypes):
mydll.addEPRF.argtypes = [c_wchar_p, c_wchar_p, c_wchar_p]
mydll.addEPRF.restype = c_void_p
mydll.removeEPRF.argtypes = [c_void_p]
mydll.removeEPRF.restype = c_bool
ptr = mydll.addEPRF("profile1", "1.0,2.0,3.0", "0.1,0.2,0.3")
if ptr is None or ptr == 0:
print(mydll.getLastErrorMessage())
exit()
result = mydll.removeEPRF(ptr)
if not result:
print(mydll.getLastErrorMessage())
exit()
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("ENET30.enet")
mydll.openESCE("ENET30_QDYN.esce")
# Approach 2 (recommended with ParameterObject wrapper):
profile1= ParameterObject.add_eprf(mydll, "profile1", "1.0,2.0,3.0", "0.1,0.2,0.3")
ParameterObject.remove_eprf(profile1)
bool removeEPRFName(string name)
Remove a profile from the electric scenario by name.
| Parameter | Type | Description |
|---|---|---|
|
String |
Name of the profile to remove |
Returns: True if the electric profile was removed, False otherwise
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("ENET30.enet")
mydll.openESCE("ENET30_QDYN.esce")
# Approach 1 (direct ctypes):
mydll.addEPRF.argtypes = [c_wchar_p, c_wchar_p, c_wchar_p]
mydll.addEPRF.restype = c_void_p
mydll.removeEPRFName.argtypes = [c_wchar_p]
mydll.removeEPRFName.restype = c_bool
ptr = mydll.addEPRF("profile1", "1.0,2.0,3.0", "0.1,0.2,0.3")
if ptr is None or ptr == 0:
print(mydll.getLastErrorMessage())
exit()
result = mydll.removeEPRFName("profile1")
if not result:
print(mydll.getLastErrorMessage())
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("ENET30.enet")
mydll.openESCE("ENET30_QDYN.esce")
# Approach 2 (recommended with ParameterObject wrapper):
ParameterObject.add_eprf(mydll, "profile1", "1.0,2.0,3.0", "0.1,0.2,0.3")
result = ParameterObject.remove_eprf_name(mydll, "profile1")
importGPRF(string FileName)
Import a profile import file to a loaded gas scenario.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to profile import file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.importGPRF("C:\\Template_Profile_Import.xlsx")
mydll.importGSCE("C:\\Template_GSCE.xlsx")
exportGPRF(string FileName)
Export profiles from the current gas scenario to an export file.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to profile export file (*.prfl) |
from ctypes import *
mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.exportGPRF("C:\\ExportProfile.prfl")
includeGPRF(string FileName)
Include a profiles from a profile file to the current gas scenario.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to profile file (*.prfl) |
from ctypes import *
mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.includeGPRF("C:\\Profile.prfl")
mydll.importGSCE("C:\\Template_GSCE.xlsx")
IntPtr addGPRF(string profileName, string meansValues, string deviationValues)
Adds a profile object to the currently loaded gas scenario and returns a parameter object for further manipulation.If fewer than two items are provided in the profile data, the missing item(s) will be added using default data.
| Parameter | Type | Description |
|---|---|---|
|
String |
Name of the profile to add |
|
String |
Comma-separated list of mean values |
|
String |
Comma-separated list of deviation values |
Returns: Returns a pointer to the profile object
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.newGSCE("GNET30_DYN", "DynamicGas", "01/01/2022 06:00", "02/01/2022 06:00", 15)
# Approach 1 (direct ctypes):
# Set up function signatures for parameter object functions
mydll.getParameterValue.restype = c_wchar_p
mydll.setParameterValue.restype = c_bool
mydll.releaseParameterObject.restype = None
mydll.addGPRF.restype = c_void_p
# Set up parameter types for the functions
mydll.getParameterValue.argtypes = [c_void_p, c_wchar_p]
mydll.setParameterValue.argtypes = [c_void_p, c_wchar_p, c_wchar_p]
mydll.addGPRF.argtypes = [c_wchar_p, c_wchar_p, c_wchar_p]
ptr = mydll.addGPRF("profile1", "1.0,2.0,3.0", "0.1,0.2,0.3")
if ptr is None or ptr == 0:
print(mydll.getLastErrorMessage())
exit()
# Access profile properties if needed
print(mydll.getParameterValue(ptr,"name"))
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.newGSCE("GNET30_DYN", "DynamicGas", "01/01/2022 06:00", "02/01/2022 06:00", 15)
# Approach 2 (recommended with ParameterObject wrapper):
# this is a wrapper to allow to use the parameter object as python object
profile= ParameterObject.add_gprf(mydll, "profile1", "1.0,2.0,3.0", "0.1,0.2,0.3")
# Access profile properties if needed
print(profile.Name)
APIExport.PointerArray getTPRF(string name)
| Parameter | Type | Description |
|---|---|---|
|
String |
Returns: None
bool removeGPRF(IntPtr profilePtr)
Remove a profile from the gas scenario by pointer.
| Parameter | Type | Description |
|---|---|---|
|
IntPtr |
Pointer to the profile to remove |
Returns: True if the profile was removed, False otherwise
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("GNET30.gnet")
mydll.openGSCE("GNET30_DYN.gsce")
# Approach 1 (direct ctypes):
mydll.addGPRF.argtypes = [c_wchar_p, c_wchar_p, c_wchar_p]
mydll.addGPRF.restype = c_void_p
mydll.removeGPRF.argtypes = [c_void_p]
mydll.removeGPRF.restype = c_bool
ptr = mydll.addGPRF("profile1", "1.0,2.0,3.0", "0.1,0.2,0.3")
if ptr is None or ptr == 0:
print(mydll.getLastErrorMessage())
exit()
result = mydll.removeGPRF(ptr)
if not result:
print(mydll.getLastErrorMessage())
exit()
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("GNET30.gnet")
mydll.openGSCE("GNET30_DYN.gsce")
# Approach 2 (recommended with ParameterObject wrapper):
profile= ParameterObject.add_gprf(mydll, "profile1", "1.0,2.0,3.0", "0.1,0.2,0.3")
ParameterObject.remove_gprf(profile)
bool removeGPRFName(string name)
Remove a profile from the gas scenario by name.
| Parameter | Type | Description |
|---|---|---|
|
String |
Name of the profile to remove |
Returns: True if the gas profile was removed, False otherwise
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("GNET30.gnet")
mydll.openGSCE("GNET30_DYN.gsce")
# Approach 1 (direct ctypes):
mydll.addGPRF.argtypes = [c_wchar_p, c_wchar_p, c_wchar_p]
mydll.addGPRF.restype = c_void_p
mydll.removeGPRFName.argtypes = [c_wchar_p]
mydll.removeGPRFName.restype = c_bool
ptr = mydll.addGPRF("profile1", "1.0,2.0,3.0", "0.1,0.2,0.3")
if ptr is None or ptr == 0:
print(mydll.getLastErrorMessage())
exit()
result = mydll.removeGPRFName("profile1")
if not result:
print(mydll.getLastErrorMessage())
exit()
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("GNET30.gnet")
mydll.openGSCE("GNET30_DYN.gsce")
# Approach 2 (recommended with ParameterObject wrapper):
ParameterObject.add_gprf(mydll, "profile1", "1.0,2.0,3.0", "0.1,0.2,0.3")
result = ParameterObject.remove_gprf_name(mydll, "profile1")
importTPRF(string FileName)
Import a profile import file to a loaded thermal scenario.
| Parameter | Type | Description |
|---|---|---|
|
String |
Path to profile import file (*.xlsx | *.xls | *.txt | *.csv) |
from ctypes import *
mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.openTSCE("C:\\TNET30_DYN.tnet")
mydll.importTPRF("C:\\Template_Profile_Import.xlsx")
mydll.importTSCE("C:\\Template_TSCE.xlsx")
exportTPRF(string FileName)
Export profiles from the current thermal scenario to an export file.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to profile export file (*.prfl) |
from ctypes import *
mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.openTSCE("C:\\TNET30_DYN.tsce")
mydll.exportTPRF("C:\\ExportProfile.prfl")
includeTPRF(string FileName)
Include profiles from profile file to the current thermal scenario.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to profile file (*.prfl) |
from ctypes import *
mydll= cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.openTSCE("C:\\TNET30_DYN.tsce")
mydll.includeTPRF("C:\\Profile.prfl")
mydll.importTSCE("C:\\Template_TSCE.xlsx")
IntPtr addTPRF(string profileName, string meansValues, string deviationValues)
Adds a profile object to the currently loaded thermal scenario and returns a parameter object for further manipulation.If fewer than two items are provided in the profile data, the missing item(s) will be added using default data.
| Parameter | Type | Description |
|---|---|---|
|
String |
Name of the profile to add |
|
String |
Comma-separated list of mean values |
|
String |
Comma-separated list of deviation values |
Returns: Returns a pointer to the profile object
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.newTSCE("TNET30_DYN", "QuasiDynamicThermal", "01/01/2022 06:00", "02/01/2022 06:00", 15)
# Approach 1 (direct ctypes):
# Set up function signatures for parameter object functions
mydll.getParameterValue.restype = c_wchar_p
mydll.setParameterValue.restype = c_bool
mydll.releaseParameterObject.restype = None
mydll.addTPRF.restype = c_void_p
# Set up parameter types for the functions
mydll.getParameterValue.argtypes = [c_void_p, c_wchar_p]
mydll.setParameterValue.argtypes = [c_void_p, c_wchar_p, c_wchar_p]
mydll.addTPRF.argtypes = [c_wchar_p, c_wchar_p, c_wchar_p]
ptr = mydll.addTPRF("profile1", "1.0,2.0,3.0", "0.1,0.2,0.3")
if ptr is None or ptr == 0:
print(mydll.getLastErrorMessage())
exit()
# Access profile properties if needed
print(mydll.getParameterValue(ptr,"name"))
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.newTSCE("TNET30_DYN", "QuasiDynamicThermal", "01/01/2022 06:00", "02/01/2022 06:00", 15)
# Approach 2 (recommended with ParameterObject wrapper):
# this is a wrapper to allow to use the parameter object as python object
profile1= ParameterObject.add_tprf(mydll, "profile1", "1.0,2.0,3.0", "0.1,0.2,0.3")
# Access profile properties if needed
print(profile1.Name)
APIExport.PointerArray getGPRF(string name)
| Parameter | Type | Description |
|---|---|---|
|
String |
Returns: None
bool removeTPRF(IntPtr profilePtr)
Remove a profile from the thermal scenario by pointer.
| Parameter | Type | Description |
|---|---|---|
|
IntPtr |
Pointer to the profile to remove |
Returns: True if the profile was removed, False otherwise
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("TNET30.tnet")
mydll.openTSCE("TNET30_DYN.tsce")
# Approach 1 (direct ctypes):
mydll.addTPRF.argtypes = [c_wchar_p, c_wchar_p, c_wchar_p]
mydll.addTPRF.restype = c_void_p
mydll.removeTPRF.argtypes = [c_void_p]
mydll.removeTPRF.restype = c_bool
ptr = mydll.addTPRF("profile1", "1.0,2.0,3.0", "0.1,0.2,0.3")
if ptr is None or ptr == 0:
print(mydll.getLastErrorMessage())
exit()
result = mydll.removeTPRF(ptr)
if not result:
print(mydll.getLastErrorMessage())
exit()
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("TNET30.tnet")
mydll.openTSCE("TNET30_DYN.tsce")
# Approach 2 (recommended with ParameterObject wrapper):
profile1= ParameterObject.add_tprf(mydll, "profile1", "1.0,2.0,3.0", "0.1,0.2,0.3")
ParameterObject.remove_tprf(profile1)
bool removeTPRFName(string name)
Remove a profile from the thermal scenario by name.
| Parameter | Type | Description |
|---|---|---|
|
String |
Name of the profile to remove |
Returns: True if the thermal profile was removed, False otherwise
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("TNET30.tnet")
mydll.openTSCE("TNET30_DYN.tsce")
# Approach 1 (direct ctypes):
mydll.addTPRF.argtypes = [c_wchar_p, c_wchar_p, c_wchar_p]
mydll.addTPRF.restype = c_void_p
mydll.removeTPRFName.argtypes = [c_wchar_p]
mydll.removeTPRFName.restype = c_bool
ptr = mydll.addTPRF("profile1", "1.0,2.0,3.0", "0.1,0.2,0.3")
if ptr is None or ptr == 0:
print(mydll.getLastErrorMessage())
exit()
result = mydll.removeTPRFName("profile1")
if not result:
print(mydll.getLastErrorMessage())
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("TNET30.tnet")
mydll.openTSCE("TNET30_DYN.tsce")
# Approach 2 (recommended with ParameterObject wrapper):
ParameterObject.add_tprf(mydll, "profile1", "1.0,2.0,3.0", "0.1,0.2,0.3")
result = ParameterObject.remove_tprf_name(mydll, "profile1")
11. Functions for Events
Functions for managing events.
-
Electric Events
-
Gas Events
-
Thermal Events
IntPtr addEEVT(string netObjectID, string parameterName, string value)
Add a scenario event to an electric scenario.
| Parameter | Type | Description |
|---|---|---|
|
String |
ID of the network object to add the event to |
|
String |
Name of the parameter to add the event to |
|
String |
Value of the event to add |
Returns: Returns a pointer to the scenario event
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.newESCE("ENET30_QDYN", "QuasiDynamicACPF", "01/01/2022 06:00", "02/01/2022 06:00", 15)
# Approach 1 (direct ctypes):
# Set up function signatures for parameter object functions
mydll.getParameterNetObject.restype = c_void_p
mydll.getParameterValue.restype = c_wchar_p
mydll.setParameterValue.restype = c_bool
mydll.addEEVT.restype = c_void_p
# Set up parameter types for the functions
mydll.getParameterValue.argtypes = [c_void_p, c_wchar_p]
mydll.setParameterValue.argtypes = [c_void_p, c_wchar_p, c_wchar_p]
mydll.addEEVT.argtypes = [c_wchar_p, c_wchar_p, c_wchar_p]
ptr =mydll.addEEVT("ENO.ENO1", "PMAX", "100")
if ptr is None or ptr == 0:
print(mydll.getLastErrorMessage())
exit()
mydll.setParameterValue(ptr, "profileName", "profile1")
mydll.setParameterValue(ptr, "startTime", "01/01/2022 06:00")
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.newESCE("ENET30_QDYN", "QuasiDynamicACPF", "01/01/2022 06:00", "02/01/2022 06:00", 15)
# Approach 2 (recommended with ParameterObject wrapper):
# this is a wrapper to allow to use the parameter object as python object
profile1= ParameterObject.add_eevt(mydll, "ENO.ENO1", "PMAX", "100")
profile1.profileName = "profile1"
profile1.startTime = "01/01/2022 06:00"
APIExport.PointerArray getEEVT(string parameterName, string objId, string time, string value)
| Parameter | Type | Description |
|---|---|---|
|
String |
|
|
String |
|
|
String |
|
|
String |
Returns: None
bool removeEEVT(IntPtr eventPtr)
Remove a scenario event from the electric scenario by pointer.
| Parameter | Type | Description |
|---|---|---|
|
IntPtr |
Pointer to the scenario event to remove |
Returns: True if the scenario event was removed, False otherwise
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("ENET30.enet")
mydll.openESCE("ENET30_QDYN.esce")
# Approach 1 (direct ctypes):
mydll.addEEVT.argtypes = [c_wchar_p, c_wchar_p, c_wchar_p]
mydll.addEEVT.restype = c_void_p
mydll.removeEEVT.argtypes = [c_void_p]
ptr = mydll.addEEVT("ENO.ENO1", "PMAX", "100")
if ptr is None or ptr == 0:
print(mydll.getLastErrorMessage())
exit()
result = mydll.removeEEVT(ptr)
if not result:
print(mydll.getLastErrorMessage())
exit()
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("ENET30.enet")
mydll.openESCE("ENET30_QDYN.esce")
# Approach 2 (recommended with ParameterObject wrapper):
event1=ParameterObject.add_eevt(mydll, "ENO.ENO1", "PMAX", "100")
ParameterObject.remove_eevt(event1)
IntPtr addGEVT(string netObjectID, string parameterName, string value)
Add a scenario event to a gas scenario.
| Parameter | Type | Description |
|---|---|---|
|
String |
ID of the network object to add the event to |
|
String |
Name of the parameter to add the event to |
|
String |
Value of the event to add |
Returns: Returns a pointer to the scenario event
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.newGSCE("GNET30_DYN", "DynamicGas", "01/01/2022 06:00", "02/01/2022 06:00", 15)
# Approach 1 (direct ctypes):
# Set up function signatures for parameter object functions
mydll.getParameterNetObject.restype = c_void_p
mydll.getParameterValue.restype = c_wchar_p
mydll.setParameterValue.restype = c_bool
mydll.addGEVT.restype = c_void_p
# Set up parameter types for the functions
mydll.getParameterValue.argtypes = [c_void_p, c_wchar_p]
mydll.setParameterValue.argtypes = [c_void_p, c_wchar_p, c_wchar_p]
mydll.addGEVT.argtypes = [c_wchar_p, c_wchar_p, c_wchar_p]
ptr =mydll.addGEVT("GNO.GNO1", "P", "100")
if ptr is None or ptr == 0:
print(mydll.getLastErrorMessage())
exit()
mydll.setParameterValue(ptr, "profileName", "profile1")
mydll.setParameterValue(ptr, "startTime", "01/01/2022 06:00")
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.newGSCE("GNET30_DYN", "DynamicGas", "01/01/2022 06:00", "02/01/2022 06:00", 15)
# Approach 2 (recommended with ParameterObject wrapper):
# this is a wrapper to allow to use the parameter object as python object
profile1= ParameterObject.add_gevt(mydll, "GNO.GNO1", "P", "100")
profile1.profileName = "profile1"
profile1.startTime = "01/01/2022 06:00"
APIExport.PointerArray getTEVT(string parameterName, string objId, string time, string value)
| Parameter | Type | Description |
|---|---|---|
|
String |
|
|
String |
|
|
String |
|
|
String |
Returns: None
bool removeGEVT(IntPtr eventPtr)
Remove a scenario event from the gas scenario by pointer.
| Parameter | Type | Description |
|---|---|---|
|
IntPtr |
Pointer to the scenario event to remove |
Returns: True if the scenario event was removed, False otherwise
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("GNET30.gnet")
mydll.openGSCE("GNET30_DYN.gsce")
# Approach 1 (direct ctypes):
mydll.addGEVT.argtypes = [c_wchar_p, c_wchar_p, c_wchar_p]
mydll.addGEVT.restype = c_void_p
mydll.removeGEVT.argtypes = [c_void_p]
ptr = mydll.addGEVT("GNO.GNO1", "P", "100")
if ptr is None or ptr == 0:
print(mydll.getLastErrorMessage())
exit()
result = mydll.removeGEVT(ptr)
if not result:
print(mydll.getLastErrorMessage())
exit()
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("GNET30.gnet")
mydll.openGSCE("GNET30_DYN.gsce")
# Approach 2 (recommended with ParameterObject wrapper):
event1=ParameterObject.add_gevt(mydll, "GNO.GNO1", "P", "100")
ParameterObject.remove_gevt(event1)
IntPtr addTEVT(string netObjectID, string parameterName, string value)
Add a scenario event to a thermal scenario.
| Parameter | Type | Description |
|---|---|---|
|
String |
ID of the network object to add the event to |
|
String |
Name of the parameter to add the event to |
|
String |
Value of the event to add |
Returns: Returns a pointer to the scenario event
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.newTSCE("TNET30_DYN", "QuasiDynamicThermal", "01/01/2022 06:00", "02/01/2022 06:00", 15)
mydll.importTPRF("C:\\TNET30_TPRF.xlsx")
# Approach 1 (direct ctypes):
# Set up function signatures for parameter object functions
mydll.getParameterNetObject.restype = c_void_p
mydll.getParameterValue.restype = c_wchar_p
mydll.setParameterValue.restype = c_bool
mydll.addTEVT.restype = c_void_p
# Set up parameter types for the functions
mydll.getParameterValue.argtypes = [c_void_p, c_wchar_p]
mydll.setParameterValue.argtypes = [c_void_p, c_wchar_p, c_wchar_p]
mydll.addTEVT.argtypes = [c_wchar_p, c_wchar_p, c_wchar_p]
ptr =mydll.addTEVT("TNO.TNO1", "Q", "100")
if ptr is None or ptr == 0:
print(mydll.getLastErrorMessage())
exit()
mydll.setParameterValue(ptr, "profileName", "profile1")
mydll.setParameterValue(ptr, "startTime", "01/01/2022 06:00")
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("C:\\TNET30.tnet")
mydll.newTSCE("TNET30_DYN", "QuasiDynamicThermal", "01/01/2022 06:00", "02/01/2022 06:00", 15)
mydll.importTPRF("C:\\TNET30_TPRF.xlsx")
# Approach 2 (recommended with ParameterObject wrapper):
# this is a wrapper to allow to use the parameter object as python object
profile1= ParameterObject.add_tevt(mydll, "TNO.TNO1", "Q", "100")
profile1.profileName = "profile1"
profile1.startTime = "01/01/2022 06:00"
APIExport.PointerArray getGEVT(string parameterName, string objId, string time, string value)
| Parameter | Type | Description |
|---|---|---|
|
String |
|
|
String |
|
|
String |
|
|
String |
Returns: None
bool removeTEVT(IntPtr eventPtr)
Remove a scenario event from the thermal scenario by pointer.
| Parameter | Type | Description |
|---|---|---|
|
IntPtr |
Pointer to the scenario event to remove |
Returns: True if the scenario event was removed, False otherwise
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("TNET30.tnet")
mydll.openTSCE("TNET30_DYN.tsce")
# Approach 1 (direct ctypes):
mydll.addTEVT.argtypes = [c_wchar_p, c_wchar_p, c_wchar_p]
mydll.addTEVT.restype = c_void_p
mydll.removeTEVT.argtypes = [c_void_p]
ptr = mydll.addTEVT("TNO.TNO1", "Q", "100")
if ptr is None or ptr == 0:
print(mydll.getLastErrorMessage())
exit()
result = mydll.removeTEVT(ptr)
if not result:
print(mydll.getLastErrorMessage())
exit()
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openTNET("TNET30.tnet")
mydll.openTSCE("TNET30_DYN.tsce")
# Approach 2 (recommended with ParameterObject wrapper):
event1=ParameterObject.add_tevt(mydll, "TNO.TNO1", "Q", "100")
ParameterObject.remove_tevt(event1)
12. Evaluation
How to write expression is discussed in the section "Expression" of the reference guide. These functions apply to all scenario types.
eval(string Expression)
Evaluate an expression for the current loaded model and display the result in a console/log.
| Parameter | Type | Description |
|---|---|---|
|
String |
Expression similar to GUI command window expression |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.openGSOL("C:\\GNET30_STE.gsol")
mydll.eval("GNET.LP.(%)")
bool evalBool(string Expression)
Evaluate logical expression for current loaded model and return an integer. Expression is first evaluated by the internal SAInt Interpretor before it is sent to the IronPython Interpretor. Thus expressions such as <ObjectTypeCode>.<Name>.<Extension> are first evaluated by the internal SAInt Interpretor before being evaluated by the IronPython Interpretor.
| Parameter | Type | Description |
|---|---|---|
|
String |
Returns: None
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.evalBool.restype = c_bool
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.openGSOL("C:\\GNET30_DYN.gsol")
b = mydll.evalBool("GNET.NUMNO>2")
print(b)
float evalFloat(string Expression)
Evaluate an expression for the current loaded model and return a float.
| Parameter | Type | Description |
|---|---|---|
|
String |
Returns: None
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.evalFloat.restype = c_float
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.openGSOL("C:\\GNET30_DYN.gsol")
b = mydll.evalFloat("GNET.LP.[Msm3].(2)")
print(b)
int evalInt(string Expression)
Evaluate the expression for the current loaded model and return an integer.
| Parameter | Type | Description |
|---|---|---|
|
String |
Returns: None
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.evalInt.restype = c_int
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.openGSOL("C:\\GNET30_DYN.gsol")
b = mydll.evalInt("GNET.NUMNO")
print(b)
string evalStr(string Expression)
Evaluate the expression for the current loaded model and return a string.
| Parameter | Type | Description |
|---|---|---|
|
String |
Expression similar to GUI command window expression |
Returns: None
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.evalStr.restype = c_wchar_p
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.openGSOL("C:\\GNET30_STE.gsol")
b = mydll.evalStr("GNO.Name.(%)")
print(b)
evalCmd(string Expression)
Evaluate an expression w/o preprocessing the expression in the SAInt interpreter for the current loaded model and display the result in console/log.
| Parameter | Type | Description |
|---|---|---|
|
String |
Expression similar to GUI command window expression |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.openGSOL("C:\\GNET30_STE.gsol")
mydll.evalCmd("eminat('GNO.%.P')")
bool evalCmdBool(string Expression)
Evaluate a logical expression w/o preprocessing the expression in the SAInt interpreter for the current loaded model and return a boolean.
| Parameter | Type | Description |
|---|---|---|
|
String |
Returns: None
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.evalCmdBool.restype=c_bool
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.openGSOL("C:\\GNET30_DYN.gsol")
b = mydll.evalCmdBool("emin('GNO.%.P.[bar-g]')>10")
print(b)
float evalCmdFloat(string Expression)
Evaluate an expression w/o preprocessing the expression in the SAInt interpreter for the current loaded model and return a float.
| Parameter | Type | Description |
|---|---|---|
|
String |
Returns: None
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.evalCmdFloat.restype=c_float
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.openGSOL("C:\\GNET30_DYN.gsol")
b = mydll.evalCmdFloat("emax('GNO.%.P.[bar-g]')")
print(b)
int evalCmdInt(string Expression)
Evaluate an expression w/o preprocessing the expression in the SAInt interpreter for the current loaded model and return an integer.
| Parameter | Type | Description |
|---|---|---|
|
String |
Returns: None
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.evalCmdInt.restype=c_int
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.openGSOL("C:\\GNET30_DYN.gsol")
b = mydll.evalCmdInt("ecount('GNO.%')")
print(b)
string evalCmdStr(string Expression)
Evaluate an expression w/o preprocessing the expression in the SAInt interpreter for the current loaded model and return a string.
| Parameter | Type | Description |
|---|---|---|
|
String |
Expression similar to GUI command window expression |
Returns: None
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.evalCmdStr.restype = c_wchar_p
mydll.openGNET("C:\\GNET30.gnet")
mydll.openGSCE("C:\\GNET30_DYN.gsce")
mydll.openGSOL("C:\\GNET30_STE.gsol")
b = mydll.evalCmdStr("eminat('GNO.%.P')")
print(b)
13. Miscellaneous Functions
LoadUnits(string filePath)
Change the default units by loading a units file.
| Parameter | Type | Description |
|---|---|---|
|
String |
Full path to units file (*.units) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.LoadUnits("C:\\SampleUnits.units)
string getVersion()
Get the current SAInt version.
Returns: None
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.getVersion.restype = c_wchar_p
b = mydll.getVersion()
print(b)
For managing the date and time format, the following functions are available:
string getDateTimeFormat()
Get the current user setting’s date format.
Returns: None
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.getDateTimeFormat.restype = c_wchar_p
b = mydll.getDateTimeFormat()
print(b)
setDateTimeFormat(string dateTimeFormat)
Set the user setting’s date format
| Parameter | Type | Description |
|---|---|---|
|
String |
The customized date time format. Accepted values: {"system", "yyyy-MM-dd HH:mm", "yyyy/MM/dd HH:mm", "dd-MM-yyyy HH:mm", "dd/MM/yyyy HH:mm", "MM-dd-yyyy HH:mm", "MM/dd/yyyy HH:mm"} |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.setDateTimeFormat("dd/MM/yyyy HH:mm")
|
The date and time format can be personalized in SAInt-GUI from the general settings as described in section "Miscellaneous". When using SAInt-API, the format specified in the GUI is ignored, and scripts need to combine the use of the functions "setDateTimeFormat" and "getDateTimeFormat" to properly manage the date/time format during execution. |
For implementing the phase connectivity check via the API, the following function is available:
int checkPhaseConnectivity(int logLevel, string logFileName)
Check connectivity of three-phase electric network and report critical connections.
| Parameter | Type | Description |
|---|---|---|
|
Int32 |
Log level indicating what type of messages to log. Considered log levels are 1=Debug, 2=Information, 3=Warning |
|
String |
Path to logfile for saving logs. If empty string is passed nothing will be written to a file. |
Returns: Returns an integer indicating how many warnings were detected
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
# Print all log messages to console and specified log file
b=mydll.checkPhaseConnectivity(1,"C:\\logmessage.txt")
print(b)
# Print log messages that have a log level information or warning to console but not to a log file
b=mydll.checkPhaseConnectivity(2,"")
print(b)
To select which linear solver to use in the simulation, the following function is available:
SetLinearSolverEngine(string value)
Set Optimization Problem Type
| Parameter | Type | Description |
|---|---|---|
|
String |
Value (SparseLU | Pardiso | KLU) |
from ctypes import *
mydll = cdll.LoadLibrary("C:\\Program Files\\encoord\\SAInt-v3\\SAInt-API.dll")
mydll.openENET("C:\\ENET30.enet")
mydll.openESCE("C:\\ENET30_DYN.esce")
mydll.SetLinearSolverEngine("SparseLU")
14. Exception logging mechanism
SAInt API provides the user with a logging option for debugging possible errors and addressing exceptions caused by the execution of Python code. The exception logging mechanism saves the exception log either in the default directory .\encoord\SAInt-v3\Logs or in a user-specified directory if a new system environment variable named SAIntExceptionLogPath is defined.
15. Data Translation Plugin
The following methods are provided to interact with plugins through scripts developed using SAInt-API capabilities.
LoadPlugin(string rootPluginPath)
| Parameter | Type | Description |
|---|---|---|
|
String |
RunPlugin()
PrintPluginConfiguration()
SetPluginConfiguration(string fieldName, string value)
| Parameter | Type | Description |
|---|---|---|
|
String |
|
|
String |