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
-
ReturnCode
¶ The return code which was returned from an ERACS DLL.
- Type
Integer.
- 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.
-
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.
-
DongleSolution
¶ Specifies whether the user is using a dongle solution.
- Type
Integer.
- Writable
False.
-
ConfigurationFolder
¶ Points to the Configuration folder within the ERACS installation.
- Type
String.
- Writable
False.
-
InstallationFolder
¶ Points to the main installation folder for ERACS.
- Type
String.
- Writable
False.
-
PythonFolder
¶ Points to the Python folder within the ERACS installation.
- Type
String.
- Writable
False.
-
InterfaceFolder
¶ Points to the Interface folder residing in the Python folder of the ERACS installation.
- Type
String.
- Writable
False.
-
ExamplesFolder
¶ Points to the Examples folder residing in the Python folder of the ERACS installation.
- Type
String.
- Writable
False.
-
TemplateFolder
¶ Points to the Template folder within the ERACS installation.
- Type
String.
- Writable
False.
-
NetworksFolder
¶ Points to the Networks folder within the ERACS installation.
- Type
String.
- Writable
False.
-
IsInstalled
¶ Checks whether ERACS is installed, returns 0 = true, any other value false.
- Type
Integer.
- Writable
False.
-
SilentSecurity
¶ Whether silent security is enabled.
- Type
Boolean.
- Writable
False.
-
VersionNumber
¶ The version number for the ERACS installation.
- Type
String.
- Writable
False.
-
-
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.
-
Dll
¶ The loaded DLL reference.
- Type
WinDLL
- Writable
False.
-
Loaded
¶ Is the DLL loaded?
- Type
Boolean.
- Writable
False.
-
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
Boolean.
- Writable
True.
-
DependencyList
¶ List of all dependent DLLs.
- Type
List.
- Writable
False.
-
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.
-
-
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.
-
XlsxWriterAvailable
¶ Is the XlsxWriter library present and available?
- Type
Boolean.
- Writable
False.
-
LxmlAvailable
¶ Is the lxml library present and available?
- Type
Boolean.
- Writable
False.
-
EracsInformation
¶ An object of the TEracsInformation class.
- Type
- Writable
False.
-
LoadflowEnabled
¶ Is the Loadflow calculation available to the user?
- Type
Boolean.
- Writable
False.
-
ImpedanceEnabled
¶ Is the Harmonic Impedance calculation available to the user?
- Type
Boolean.
- Writable
False.
-
FaultEnabled
¶ Is the Fault calculation available to the user?
- Type
Boolean.
- Writable
False.
-
SilentSecurity
¶ Silent security will authenticate the user behind-the-scenes if possible.
- Type
Boolean.
- Writable
True.
-
EndSession
()¶
-
-
class
TEracsEngineInterface
¶ 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.
-
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.
-
-
class
TEracsEngineInterfaceResult
¶ 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
¶ 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
-
SequenceNumber
¶ The sequence number of the element result.
- Type
Integer.
- Writable
False.
-
class
TEracsEngineInterfaceData
¶ 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
¶ 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
-
NetworkName
¶ Name of the network being used in the study.
- Type
String.
- Writable
True.
-
StateName
¶ Name of the data state being used in the study.
- Type
String.
- Writable
True.
-
UserID
¶ Name of the original user who created the network.
- Type
String.
- Writable
True.
-
ChangeID
¶ Name of the user who last modified the network (and is likely running this study).
- Type
String.
- Writable
True.
-
SysDate
¶ System date of the study being performed.
- Type
String.
- 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
¶ 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
-
SequenceNumber
¶ The sequence number of the element being passed to the calculation engine.
- Type
Integer.
- Writable
True.
-
SeqNum
¶ Alternative to SequenceNumber property.
- Type
Integer.
- Writable
True.
-
ID
¶ The Identifier of the element.
- Type
String.
- Writable
True.
-
TypeCode
¶ The Typecode which identifies the element type.
- Type
Integer.
- 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
¶ 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
-
LibraryKey
¶ The library key for the element (in the ERACS database).
- Type
String.
- 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.