Global Module¶
Global ERACS Python module contains all constants and core functions. Also contains classes for basic operation of running ERACS studies.
-
exception
TEracsError
¶ Parent class of all ERACS related exceptions.
- Inherits
Exception.
-
exception
TEracsArgumentError
¶ This exception class is raised when an error is detected relating to one of the arguments passed into a method within the ERACS Python Interface.
- Inherits
-
exception
TEracsDllError
¶ This exception class is raised when an error is detected relating to a DLL in use, such as one of the calculation modules.
- Inherits
-
exception
TEracsReturnCodeError
(AProgramNumber, AMethodName, code)¶ This exception class is raised when a non-zero return code is returned from a DLL call. Each return code can have a different meaning, so this exception class uses lookup tables to include a more useful description inside the exception message to explain the reason for the return code.
- Inherits
-
property
ReturnCode
¶ The return code which was returned from an ERACS DLL.
- Type
int.
- Writable
False.
- Example
1501 (Loadflow - Bad busbar sequence number)
-
CompareReturnCode
(AValue)¶ This method can be used to compare the argument against two possible values. Arguments of 1001 and 1 both refer to an EGeneralError; the 1000 signifies that it’s a Loadflow error number, so really the error code is just 1. This method takes the module prefix into account.
- Returns
True if the argument matches the return code.
-
exception
TEracsDataError
¶ This exception class is raised when an error is detected relating to the data within a network. For example, when a mandatory key is missing from a data dictionary.
- Inherits
-
ToBytes
(AStringObject)¶ This function was created to fix the difference in bytes() between Python versions 2 and 3.
- Parameters
AStringObject (str) – A string object to be converted to a bytes object.
- Returns
The bytes object.
-
ToString
(ABytesObject)¶ This function was created to fix the difference in bytes() between Python versions 2 and 3.
- Parameters
ABytesObject (bytes) – A bytes object, to be converted to a string object.
- Returns
The string object.
-
PIVersion
(AbsPath=False)¶ This function returns the ERACS Python Interface version.
- Returns
A string of the semantic version number x.y.z.b where x is major, y is minor, z is release/patch, and b is build.
-
CompareSemanticVersionString
(AActualVersion, AExpectedVersion)¶ Compares semantic version strings and returns an integer. If the first semantic version string is higher than the second, 1 is returned. If both semantic version strings are equal, 0 is returned. If the first semantic version string is lower than the second, -1 is returned.
- Parameters
AActualVersion (int) – The first parameter is considered the actual version number.
AExpectedVersion (int) – The second parameter is considered the expected version number.
- Example
CompareSemanticVersionString(“3.11.0”, “3.10.0”) = 1.
- Returns
An integer in [-1, 0, 1] to determine which semantic version is newer.
-
DocsVersion
(AbsPath=False)¶ This function returns the ERACS Python Interface version number but only as 3 segments (it gets rid of the build number) because the documentation doesn’t need to know or display build number.
- Returns
A string of the semantic version number x.y.z where x is major, y is minor, and z is release/patch.
-
class
TEracsInformation
¶ This class can be used to get important information about ERACS. For example it has properties for all important directories relating to ERACS.
-
property
DongleSolution
¶ Specifies whether the user is using a dongle solution.
- Type
int.
- Writable
False.
-
property
ConfigurationFolder
¶ Points to the Configuration folder within the ERACS installation.
- Type
str.
- Writable
False.
-
property
InstallationFolder
¶ Points to the main installation folder for ERACS.
- Type
str.
- Writable
False.
-
property
PythonFolder
¶ Points to the Python folder within the ERACS installation.
- Type
str.
- Writable
False.
-
property
InterfaceFolder
¶ Points to the Interface folder residing in the Python folder of the ERACS installation.
- Type
str.
- Writable
False.
-
property
ExamplesFolder
¶ Points to the Examples folder residing in the Python folder of the ERACS installation.
- Type
str.
- Writable
False.
-
property
TemplateFolder
¶ Points to the Template folder within the ERACS installation.
- Type
str.
- Writable
False.
-
property
NetworksFolder
¶ Points to the Networks folder within the ERACS installation.
- Type
str.
- Writable
False.
-
property
IsInstalled
¶ Checks whether ERACS is installed, returns 0 = true, any other value false.
- Type
int.
- Writable
False.
-
property
SilentSecurity
¶ Whether silent security is enabled.
- Type
bool.
- Writable
False.
-
property
ERACSVersionNumber
¶ The version number for the ERACS installation.
- Type
str.
- Writable
False.
-
property
LoadflowVersionNumber
¶ The version number for the Loadflow calculation module.
- Type
str.
- Writable
False.
-
property
FaultVersionNumber
¶ The version number for the Loadflow calculation module.
- Type
str.
- Writable
False.
-
property
ImpedanceVersionNumber
¶ The version number for the Loadflow calculation module.
- Type
str.
- Writable
False.
-
property
InjectionVersionNumber
¶ The version number for the Loadflow calculation module.
- Type
str.
- Writable
False.
-
property
-
class
TEracsDllLoader
¶ Class used to load a DLL. This class is used extensively throughout the ERACS Python Interface for loading up each calculation module and all other dependent DLLs.
-
property
Dll
¶ The loaded DLL reference.
- Type
WinDLL
- Writable
False.
-
property
Loaded
¶ Is the DLL loaded?
- Type
bool.
- Writable
False.
-
property
RunRecommendedCheck
¶ The recommended check will check to see whether any recommended (optional) dependencies are available. This property determines whether that check is performed. It’s advised to keep this enabled, unless you know it can be disabled.
- Type
bool.
- Writable
True.
-
property
DependencyList
¶ List of all dependent DLLs.
- Type
list.
- Writable
False.
-
property
RecommendedList
¶ List of all recommended DLLs.
- Type
list.
- Writable
False.
-
UnloadDLL
()¶ Unload any loaded DLL, freeing up any resources associated with it. Unload DLLs once their use is finished.
- Raises
TEracsDllError – If the DLL could not be freed (perhaps it wasn’t loaded in the first place?).
-
LoadDLL
(ADllFile)¶ This function can be used to load a DLL from the main ERACS installation folder,
- Parameters
ADllFile (str) – The full path of the DLL, or just the DLL file name (with or without the .dll extension). If a path is provided, that path will be used, otherwise it will look through the Python system paths.
- Use
example: LoadDLL(self._DllName())
- Raises
TEracsError – If using a 64-bit version of Python which isn’t supported.
TEracsDllError – If the DLL didn’t load successfully, possibly due to the path being wrong, DLL not existing, etc.
-
property
-
class
TEracsEnviron
¶ This class sets up the environment such as loading the security DLL and setting global variables. This class can be used to toggle silent security and other core features.
-
property
XlsxWriterAvailable
¶ Is the XlsxWriter library present and available?
- Type
bool.
- Writable
False.
-
property
LxmlAvailable
¶ Is the lxml library present and available?
- Type
bool.
- Writable
False.
-
property
EracsInformation
¶ An object of the TEracsInformation class.
- Type
- Writable
False.
-
property
LoadflowEnabled
¶ Is the Loadflow calculation available to the user?
- Type
bool.
- Writable
False.
-
property
ImpedanceEnabled
¶ Is the Harmonic Impedance calculation available to the user?
- Type
bool.
- Writable
False.
-
property
FaultEnabled
¶ Is the Fault calculation available to the user?
- Type
bool.
- Writable
False.
-
property
InjectionEnabled
¶ Is the Injection calculation available to the user?
- Type
bool.
- Writable
False.
-
property
SilentSecurity
¶ Silent security will authenticate the user behind-the-scenes if possible.
- Type
bool.
- Writable
True.
-
EndSession
()¶
-
property
-
class
TEracsEngineInterface
(*args)¶ The engine interface classes are designed to assist with interacting with calculation engines, and are the main driving points when running a calculation. These classes hold an object reference to a complex (lower-level) class underneath, so for example, when loading a busbar into a Loadflow study, you should use this class to modify any attributes, which will in turn be reflected in the underlying low-level object which is passed straight to Loadflow.
-
property
Object
¶ The complex/low-level object which is passed to the calculation engine as a record structure.
- Type
Varies, depending on the type of the descendant class. For example,
LoadflowRecords.TLFBusData
has an object of type _TLFBusDataComplex.- Writable
False.
-
property
-
class
TEracsEngineInterfaceResult
(*args)¶ This class is used to represent result information. The underlying object is passed to Loadflow and populated, the results are then available within the ERACS Python Interface.
- Inherits
-
StoreIntoDictionary
(AOutputDictionary: dict)¶ Store all information from the underlying object into a dictionary.
- Parameters
AOutputDictionary (dict) – The dictionary to populate with field data.
- Raises
TEracsArgumentError – If first argument is not a dict.
-
class
TEracsEngineInterfaceResultElement
(*args)¶ The results for a specific element type are represented with this class. For example,
FaultRecords.TFBusbarResult
inherits from this class, with the busbar being the element the results are for. This class stores common information for all element results, such as sequence numbers.- Inherits
-
property
SequenceNumber
¶ The sequence number of the element result.
- Type
int.
- Writable
False.
-
class
TEracsEngineInterfaceData
(*args)¶ This class should be inherited and used for all data being passed into the calculation engines. It provides common methods for all descendants which will represent data passed to the calculation engines, such as SetDefaults, WriteBytes, and ClearBytes (for writing and clearing identifier strings).
- Inherits
-
SetDefaults
()¶ This method should be called to set the default values before loading up the next set of data. This class’s object is re-used for all elements, so restoring default values beforehand is important to avoid bugs.
- Raises
TEracsDataError – If any of the keys are missing.
-
WriteBytes
(ABuffer, AString)¶ Writes a string to the bytes object buffer. This is used to populate fields which are strings, such as the element identifier.
- Parameters
ABuffer (int) – The size of the bytes array.
AString (str) – The string to populate into the bytes array.
- Raises
TEracsDataError – If it fails to write bytes. Was a string passed in?
-
ClearBytes
(ABuffer)¶ Clears the bytes object buffer so that it contains empty characters. This helps prevent bugs, otherwise characters won’t be cleared from the buffer and may appear in other element data.
- Parameters
ABuffer (int) – The size of the bytes buffer to clear.
-
ReadBytes
(ABuffer)¶ Read the string contained within the bytes object buffer. This is a method provided for simplifying access, this way the element identifiers can be easily read.
- Parameters
ABuffer (int) – The size of the bytes buffer to read from.
- Returns
The string read from the bytes buffer.
-
class
TEracsEngineInterfaceSetupData
(*args)¶ This class is specifically for containing setup data for the calculation engine. It contains setup specific data such as network name and data state name.
- Inherits
-
property
NetworkName
¶ Name of the network being used in the study.
- Type
str.
- Writable
True.
-
property
StateName
¶ Name of the data state being used in the study.
- Type
str.
- Writable
True.
-
property
UserID
¶ Name of the original user who created the network.
- Type
str.
- Writable
True.
-
property
ChangeID
¶ Name of the user who last modified the network (and is likely running this study).
- Type
str.
- Writable
True.
-
property
SysDate
¶ System date of the study being performed.
- Type
str.
- Writable
False.
-
SetDefaults
()¶ This method should be called to set the default values before loading up the next set of data. This class’s object is re-used for all elements, so restoring default values beforehand is important to avoid bugs.
- Raises
TEracsDataError – If any of the keys are missing.
-
LoadHeaders
(AHeaderDictionary)¶ Loads headers into the setup data, which includes network and data state names.
- Parameters
AHeaderDictionary (dict) – This dictionary contains header specific information.
- Raises
TEracsDataError – If expected keys are missing from the given dictionary.
-
class
TEracsEngineInterfaceDataElement
(*args)¶ This class holds data for an element. This class should be inherited from for more specific data shared between all elements of a particular type. This class contains properties, such as sequence number, which are common to all ERACS elements.
- Inherits
-
property
SequenceNumber
¶ The sequence number of the element being passed to the calculation engine.
- Type
int.
- Writable
True.
-
property
SeqNum
¶ Alternative to SequenceNumber property.
- Type
int.
- Writable
True.
-
property
ID
¶ The Identifier of the element.
- Type
str.
- Writable
True.
-
property
TypeCode
¶ The Typecode which identifies the element type.
- Type
int.
- Writable
True.
-
SetDefaults
()¶ This method should be called to set the default values before loading up the next set of data. This class’s object is re-used for all elements, so restoring default values beforehand is important to avoid bugs.
- Raises
TEracsDataError – If any of the keys are missing.
-
class
TEracsEngineInterfaceDataElementWithLibrary
(*args)¶ This class should be inherited from classes which represent element data containing library information. For example, this class is inherited from TLFLineCableData and TLFSeriesElementData. This class provides the library key property, so it doesn’t have to be redefined in descendants.
- Inherits
-
property
LibraryKey
¶ The library key for the element (in the ERACS database).
- Type
str.
- Writable
True.
-
SetDefaults
()¶ This method should be called to set the default values before loading up the next set of data. This class’s object is re-used for all elements, so restoring default values beforehand is important to avoid bugs.
- Raises
TEracsDataError – If any of the keys are missing.