Definitions#

Definition Map#

class mhi.xml.pscad.definitions.DefinitionMapping#

The project’s Definition dictionary.

Example:

for defn_name in project.definition:
    print(defn_name)

main_defn = project.definition['Main']

del project.definition['not_needed']
create(name: str) UserCmpDefn#

Create a new UserCmp Definition

create_tline(name: str) RowDefn#

Create a new TLine

create_cable(name: str) RowDefn#

Create a new TLine

Definition#

class mhi.xml.pscad.Definition#

Definition node

property group: str#

A comma separated list of groups this definition belongs to.

Examples:

'(null)'
'Miscellaneous,I/O Devices'
'Meters,Breakers Faults,Machines,Miscellaneous'
property groups: list[str]#

The list of groups this definition belongs to.

Examples:

['(null)']
['Miscellaneous', 'I/O Devices']
['Meters', 'Breakers Faults', 'Machines', 'Miscellaneous']
property description: str#

Description of the definition

delete() None#

Remove this definition from its parent project

class mhi.xml.pscad.UserCmpDefn#

User Component Definition node

property form: Form#

The Parameter Form for the definition

property schematic: Schematic | None#

The Schematic of the definition, if it is a module definition

property script: ScriptSegmentMapping#

The script dictionary for the definition

This contains ‘Computations’, ‘Checks’, ‘Fortran’, ‘Branch’ sections (etc).

property graphics: Graphics#

The Graphics of the definition

Form#

class mhi.xml.pscad.Form#

A collection of categories of parameters, along with their descriptions and validity constraints.

Examples:

form = definition.form

# Create a "Extra" category, add 'Author', 'Version' parameters.
extra = form.category.create("Extra")
extra.add_text('Author', "Creator")
extra.add_integer('Version', "Revision number", min=1, default=1)

# Remove the "Extra" category
del form.category["Extra"]
property w: int#

Width of the dialog form, in pixels.

Does not include additional width added by dynamic help.

property h: int#

Height of the dialog form, in pixels

property splitter: int#

The “Description <–> Value” splitter position, in percent

property commentlines: int#

Number of lines at the bottom of the form for help text.

property category: KeyMapping[Category]#

Form category dictionary

property parameter: KeyMapping[Parameter]#

Form parameter dictionary

Form Category#

class mhi.xml.pscad.Category#

A form category

Contains 1 or more parameters, and a condition for when the category is enabled.

property cond#

Category enabled condition expression (read/write)

property parameter: KeyMapping[Parameter]#

Category parameter dictionary

add_text(name: str, description: str, default: str = '', empty_allowed=True, **kwargs) Parameter#

Create a text parameter.

add_integer(name: str, description: str, default: int = 0, min: int | None = None, max: int | None = None, animate: bool = False, **kwargs) Parameter#

Create an Integer parameter.

add_real(name: str, description: str, default: int = 0, min: int | None = None, max: int | None = None, animate: bool = False, unit: str | None = None, **kwargs) Parameter#

Create a Real parameter.

Form Parameter#

class mhi.xml.pscad.Parameter#

A parameter definition.

Gives the parameter a symbol name, description, type, units, default value, validation attributes (minimum and/or maximum limits, regex), and help attributes.

property description: str#

Parameter description

property group: str#

Parameter group (set of related parameters in one category)

property type: str#

Parameter type (Text, Complex, Real, Integer, Choice, Boolean, Table)

property min: int | float | None#

Minimum allowed value (Integer / Real) or length (Text)

property max: int | float | None#

Maximum allowed value (Integer / Real) or length (Text)

property unit: str#

Parameter unit (kV, kA, ohm, MVA, rad/s, …)

property empty_allowed: bool#

Can this Text field be empty?

property animate: bool#

Is this parameter animated?

property help_mode: str#

Help mode (Append, Overwrite)

property default: str#

Default value for the parameter

property help: str#

Brief help message to Append/Overwrite help panel with

property regex: str#

A reg-ex validation pattern for Text input parameters

property cond: str#

Enable condition for this parameter.

property error_msg: str#

The message to display if a issue exists with the entered parameter value.

property choices: dict[int, str]#

The options for a Choice parameter

Graphics#

class mhi.xml.pscad.Graphics#

A <graphics/> container node

add_text(*coords, text: str, color: str = 'Black', full_font: str = 'Tahoma, 12world', font_size: int = 0, align: str | Align | int = Align.CENTER, angle: int = 0, cond: str = 'true')#

Add a line of text to the definition graphics

add_line(*coords, color: str = 'Black', line_style: str | LineStyle | int = LineStyle.SOLID, thickness: int = 0, port: str = '', cond: str = 'true')#

Add a line to the definition graphics

add_rect(*coords, color: str = 'Black', line_style: str | LineStyle | int = LineStyle.SOLID, thickness: int = 0, port: str = '', fill_style: str | FillStyle | int = FillStyle.HOLLOW, fill_fg: str = 'Black', fill_bg: str = 'White', cond: str = 'true')#

Add a rectangle to the definition graphics

add_ellipse(*coords, color: str = 'Black', line_style: str | LineStyle | int = LineStyle.SOLID, thickness: int = 0, port: str = '', fill_style: str | FillStyle | int = FillStyle.HOLLOW, fill_fg: str = 'Black', fill_bg: str = 'White', cond: str = 'true')#

Add an ellipse to the definition graphics

add_circle(*coords, color: str = 'Black', line_style: str | LineStyle | int = LineStyle.SOLID, thickness: int = 0, port: str = '', fill_style: str | FillStyle | int = FillStyle.HOLLOW, fill_fg: str = 'Black', fill_bg: str = 'White', cond: str = 'true')#

Add a circle to the definition graphics

ports(name: str | None = None) list[Port]#

Retrieve the list of ports defined in the component graphics

add_input(x: int, y: int, name: str, *, dim: int = 1, cond: str = 'true', internal: bool = False, datatype: SignalType | str | int = SignalType.REAL) Port#

Add an input port to the graphic definition

add_output(x: int, y: int, name: str, *, dim: int = 1, cond: str = 'true', internal: bool = False, datatype: SignalType | str | int = SignalType.REAL) Port#

Add an output port to the graphic definition

add_electrical(x: int, y: int, name: str, *, dim: int = 1, cond: str = 'true', internal: bool = False, electype: ElectricalType | str | int = ElectricalType.FIXED) Port#

Add an electical port to the graphic definition

Graphic Elements#

class mhi.xml.pscad.GfxText#

Gfx Text

property color: Colour#

The ‘color’ property of a visible Gfx item

property value: str#

The ‘message’ of a Graphics.Text item

property full_font: str#

The ‘font’ used to draw a Graphics.Text item

property font_size: int#

The ‘size of font’ used to draw a Graphics.Text item

property anchor: Align#

The ‘text anchor’ (Left/Centre/Right) of a Graphics.Text item

property angle: int#

The ‘angle’ (in degrees) to draw the Graphic.Text message at

class mhi.xml.pscad.GfxLine#

Gfx Line

property color: Colour#

The ‘color’ property of a visible Gfx item

property dasharray: LineStyle#

The ‘Line Style’ of a stroked Gfx item

property thickness: int#

The ‘Line Thickness’ of a stroked Gfx item

vertices() list[Vertex]#

The list <vertex> elements of a Graphics.Line

Changed in version 1.2.0.

class mhi.xml.pscad.GfxRectangle#

Gfx Rectangle

property color: Colour#

The ‘color’ property of a visible Gfx item

property dasharray: LineStyle#

The ‘Line Style’ of a stroked Gfx item

property thickness: int#

The ‘Line Thickness’ of a stroked Gfx item

property fill_style: FillStyle#

The ‘Fill Style’ of a painted Gfx item

property fill_fg: Colour#

The ‘Foreground color’ of a painted Gfx item

property fill_bg: Colour#

The ‘Background Color’ of a painted Gfx item

class mhi.xml.pscad.GfxEllipse#

Gfx Ellipse

property color: Colour#

The ‘color’ property of a visible Gfx item

property dasharray: LineStyle#

The ‘Line Style’ of a stroked Gfx item

property thickness: int#

The ‘Line Thickness’ of a stroked Gfx item

property fill_style: FillStyle#

The ‘Fill Style’ of a painted Gfx item

property fill_fg: Colour#

The ‘Foreground color’ of a painted Gfx item

property fill_bg: Colour#

The ‘Background Color’ of a painted Gfx item

class mhi.xml.pscad.Port#

Graphics Port

property name: str#

The ‘name’ of the connection point

property dim: int#

The ‘dimension’ of the connection point

property mode: NodeType#

The ‘mode’ of the connection point (Input, Output, Electrical, …)

property datatype: SignalType#

The ‘data type’ of input/output Port (Logical, Integer, Real, …)

property electype: ElectricalType#

The ‘type’ of an Electrical Port (Fixed, Removable, Ground, …)

property internal: bool#

An electrical port’s ‘internal’ nature (not connected externally)