Data Module

Inheritance diagram of Data

Import Data for access to all data-loading classes exposed by the ERACS Python Interface. An instance of the TEracsData class can be used to load and save data using multiple file formats (XML, CSV, etc.).

class TEracsData

This class should be used to load up an ERACS network ready to be passed to a calculation module

Inherits

Collection.TEracsDataCollection.

FaultCapability

Fault Capability, determined by synchronous machines, transformer windings, transmission lines and cables in the network.

Type

Integer.

Writable

False.

GetDataItem(ATypecode, ASeqnum)

Looks for the specified item from the appropriate data list using the typecode and sequence number provided, returns it as a Dictionary. A full list of available typecodes can be viewed here.

Parameters
  • ATypecode (int) – Must be an integer, typecode of element

  • ASeqnum (int) – Must be an integer, sequence number of specific element

Returns

Dictionary for desired data item

Raises

TEracsArgumentError – If no item exists with given typecode and sequence number, or if the typecode is unknown.

CloseSwitch(ASwitchID)

Close the specified switch.

Parameters

ASwitchID (int) – Index of the switch to close.

OpenSwitch(ASwitchID)

Open the specified switch.

Parameters

ASwitchID (int) – Index of the switch to open.

SetSwitchState(ASwitchId, AState)

When a switch needs updating/changing use this method. Each element dictionary has an internal connection indicator key, and therefore changing the state of the switch directly in the Switches list will have no effect.

Parameters
  • ASwitchId (int) – ID of the switch to change the state of.

  • AState (int) – The state to change the switch to. (0 = open, 1 = closed)

Doctest
>>> data = TEracsData()
>>> data.Switches.append(
...     {'id': 'sw1', 'swstate': 1, 'pid': 'cab1', 'ptypecode': 3, 'busbar1': 'bus1'}
... )
>>> data.Switches[0]['swstate']
1
>>> data.OpenSwitch('sw1')
>>> data.Switches[0]['swstate']
0
>>> data.CloseSwitch('sw1')
>>> data.Switches[0]['swstate']
1
Load(AFilePathAndName)

Load the data from a supported format (XML or CSV).

Parameters

AFilePathAndName (str) – The full path and name of file to load.

Returns

True if the file was successfully loaded.

Raises

TEracsArgumentError – If the file has an unknown extension.

Save(AFilePathAndName)

Save the data into a supported format (XML, CSV, JSON, SVG, HTML)

Parameters

AFilePathAndName (str) – The full path and name of file to save.

Returns

True if the file was successfully saved.

Raises

TEracsArgumentError – If the file has an unknown extension.

OpenInBrowserAsSvg()

Open the data in a web browser as SVG.

OpenInBrowserAsHtml()

Open the data in a web browser as HTML.

class TEracsDataConverter

This class simplifies access to certain DLLs for data conversion.

XmlToJson(AFile, ASource)

Converts XML data to JSON

Parameters
  • AFile (str) – The full path and name of Destination file.

  • ASource (str) – The full path and name of Source XML file.

Raises
  • TEracsArgumentError – If either arguments are of the incorrect type or source points to a non-existent file.

  • TEracsDllError – If the DLL is not found or loaded properly.

NameplateXmlToClassicXml(ATx, AKeyname)

Converts a transformer which uses the classic transformer format into a nameplate format (newer).

Parameters

ATx (element) – Transformer XML element in the classic format.

Returns

An XML element for the new nameplate transformer.

Raises

TEracsDllError – If the DLL is not found or loaded properly, or if it fails to return back a converted transformer.