Component Wizard¶
-
class
mhi.pscad.automation.wizard.
UserDefnWizard
(name: str)¶ User Definition construction wizard
Usage:
wizard = UserDefnWizard("definition_name") wizard.description = "A multiplicative gain factor component" wizard.port.input(-2, 0, "In", Signal.REAL) wizard.port.output(2, 0, "Out", Signal.REAL) config = wizard.category.add("Configuration") config.real('Gain', description="Gain factor") wizard.graphics.text("Gain", 0, 4) wizard.script['Fortran'] = " $Out = $In * $Gain" defn = wizard.create_definition(project) canvas.create_component(defn, x, y)
New in version 2.2.
-
name
¶ Definition name (hint)
When the definition is created, PSCAD may change the definition name to ensure it is unique.
-
description
¶ Component definition description
-
property
port
¶ Port container.
Use
to add new inputs, outputs, and electrical connection ports.
Use
wizard.port["name"]
to access aPort
by name.Since the same port name may exist multiple times with different
enable
condtions, usefor port in wizard.port:
to iterate over all defined ports.
-
property
graphics
¶ Graphics container.
The current defined graphic shapes (excluding port lines & arrows) may be iterated over using
for shape in wizard.graphics:
Use
to add new text, lines, arrows, and rectangles.
Note
Lines & arrows will be created for ports automatically.
Parameter Form’s Caption
-
form_width
¶ Parameter Form’s width
-
form_height
¶ Parameter Form height
-
form_splitter
¶ Parameter Form default splitter position
-
form_category_width
¶ Parameter Form’s category tree width
-
form_help_width
¶ Parameter Form’s dynamic help panel width
-
property
category
¶ Component parameter form category container
Use
wizard.category.add("category_name", ...)
, to add categories to the form. Parameters may then be added to that category object.Use
wizard.category["name"]
to access acategory
by name.
-
property
parameter
¶ Component parameter container
Using
wizard.parameter["name"]
to access an existing parameter.Note
Parameters can only be added to a category object. Use
wizard.category.add(...)
to create the category, then add parameters to that category object.
-
property
script
¶ Component scripts container
Use
wizard.script['Fortran'] = '''...'''
to set a script section.Valid sections are: Branch, Checks, Computations, Dsdyn, Dsout, Fortran, MANA, Matrix-Fill, Model-Data, T-Lines, Transformers Help, FlyBy, and Comments.
-
create_definition
(prj: Project) → Definition¶ Create the definition in the given project.
Once the desired ports, graphics, and form parameters & categories have been added to the wizard, this method will create the required component definition in the given project, which may then be used to create instances of the component.
Note
The definition name configured in the wizard is only a hint. When PSCAD creates the definition, it may change the definition name, so refer the returned definition for the actualy definition name.
-
Ports¶
-
class
mhi.pscad.automation.wizard.UserDefnWizard.
Ports
¶ Port Container, accessed using the
wizard.port
property.Use
wizard.port["name"]
to access aPort
by name.Since the same port name may exist multiple times with different
enable
condtions, usefor port in wizard.port:
to iterate over all defined ports.-
electrical
(x: int, y: int, name: str, electrical_type: Union[str, mhi.pscad.automation.types.Electrical] = 'FIXED', dim: int = 1, enable: str = 'true', internal: bool = False)¶ Create a new electrical connection port
-
input
(x: int, y: int, name: str, data_type: Union[str, mhi.pscad.automation.types.Signal], dim: int = 1, enable: str = 'true', arrow: Union[bool, Tuple[int, int]] = True)¶ Create a new control signal input port
-
output
(x: int, y: int, name: str, data_type: Union[str, mhi.pscad.automation.types.Signal], dim: int = 1, enable: str = 'true', arrow: Union[bool, Tuple[int, int]] = False)¶ Create a new control signal output port
-
Port¶
-
class
mhi.pscad.automation.wizard.UserDefnWizard.
Port
¶ Component Input/Output/Electrical connections
-
data_type
¶ I/O port data type (BOOLEAN, INTEGER, REAL, COMPLEX)
-
dim
¶ Port dimension.
A dimension of 1 indicates a scalar wire connection. A dimension greater than 1 indicates an array wire connection. A dimension of 0 inherits the dimesion of the connected wire.
-
electrical_type
¶ Electrical port type (FIXED, SWITCHED, REMOVABLE)
-
enable
¶ Port enable condition
-
internal
¶ Used to create electrical nodes with no outside connection
-
mode
¶ Port node type (ELECTRICAL, INPUT, OUTPUT)
-
name
¶ Port name
-
property
side
¶ Port label location (NONE, LEFT, ABOVE, BELOW, RIGHT, AUTO)
-
x
¶ Port X coordinate
-
y
¶ Port Y coordinate
-
Graphics¶
-
class
mhi.pscad.automation.wizard.UserDefnWizard.
Graphics
¶ Container for graphical elements, accessed using the
wizard.graphics
property.The current defined graphic shapes (excluding port lines & arrows) may be iterated over using
for shape in wizard.graphics:
-
arrow
(x1: int, y1: int, x2: int, y2: int, length: int = 5, width: int = 5, *, enable: str = 'true', color: str = 'black', line_style: Union[str, mhi.pscad.automation.types.LineStyle] = <LineStyle.SOLID: 0>, thickness: int = 0, port: str = '')¶ Create an arrow from [x1,y1] to [x2,y2].
-
line
(x1: int, y1: int, x2: int, y2: int, *, enable: str = 'true', color: str = 'black', line_style: Union[str, mhi.pscad.automation.types.LineStyle] = <LineStyle.SOLID: 0>, thickness: int = 0, port: str = '')¶ Create a line between [x1,y1] and [x2,y2].
-
rectangle
(x1: int, y1: int, x2: int, y2: int, enable: str = 'true', color: str = 'black', line_style: Union[str, mhi.pscad.automation.types.LineStyle] = <LineStyle.SOLID: 0>, thickness: int = 0, port: str = '', foreground: str = 'Black', background: str = 'White', fill_style: int = 0)¶ Create a rectangle between corners [x1,y1] and [x2,y2].
-
text
(text: str, x: int = 0, y: int = 5, *, color: str = 'Black', enable: str = 'true', angle: int = 0, anchor: Union[str, mhi.pscad.automation.types.Align] = <Align.CENTER: 1>, full_font: str = 'Tahoma, 12world')¶ Create a text label.
-
Text¶
Line¶
-
class
mhi.pscad.automation.wizard.UserDefnWizard.
Line
¶ A straight line
-
color
¶ Color
-
enable
¶ Visibility condition
-
line_style
¶ Line style (SOLID, DOT, DASH, DOTDASH)
-
port
¶ Associated port name (for line thickness)
-
thickness
¶ Line thickness
0
0.2pt
1
0.4pt
2
0.6pt
3
0.8pt
4
1.0pt
5
1.2pt
6
1.4pt
7
Associated Port
-
x
¶ X coordinate
-
y
¶ Y coordinate
-
Rectangle¶
-
class
mhi.pscad.automation.wizard.UserDefnWizard.
Rectangle
¶ An axis-aligned rectangle.
-
background
¶ Background fill color
-
color
¶ Color
-
enable
¶ Visibility condition
-
fill_style
¶ Fill style (SOLID, HOLLOW, CROSS, HORIZONTAL, VERTICAL, …)
-
foreground
¶ Foreground fill color
-
height
¶ Height
-
line_style
¶ Line style (SOLID, DOT, DASH, DOTDASH)
-
port
¶ Associated port name (for line thickness)
-
thickness
¶ Line thickness
0
0.2pt
1
0.4pt
2
0.6pt
3
0.8pt
4
1.0pt
5
1.2pt
6
1.4pt
7
Associated Port
-
width
¶ Width
-
x
¶ X coordinate
-
y
¶ Y coordinate
-
Parameter Form¶
-
class
mhi.pscad.automation.wizard.UserDefnWizard.
Parameters
¶ Parameters container, accessed using the
wizard.parameter
property.Note
Parameters can only be added to a category object. Use
wizard.category.add(...)
to create the category, then add parameters to that category object.-
keys
() → List[str]¶ List of parameter names
-
Categories¶
Category¶
-
class
mhi.pscad.automation.wizard.UserDefnWizard.
Category
¶ Component parameter form category, accessed using the
wizard.category
property.After creating a category using
category = wizard.category.add("category_name", ...)
, useto add parameters to that category.
Properties¶
-
Category.
name
¶ Category Name
-
Category.
level
¶ Category Level, for indenting category tree nodes
-
Category.
enable
¶ Category enable condition
Methods¶
-
Category.
text
(name: str, *, description: str = None, group: str = '', enable: str = None, visible: str = None, value: str = '', help: str = None, help_mode: str = None, regex: str = None, allow_empty_strings: bool = True, minimum_length: int = None, maximum_length: int = None, error_msg: str = None)¶ Add a text parameter to the category
-
Category.
logical
(name: str, *, description: str = None, group: str = '', enable: str = None, visible: str = None, value: str = '.TRUE.', help: str = None, help_mode: str = None)¶ Add a logical parameter to the category
-
Category.
boolean
(name: str, *, description: str = None, group: str = '', enable: str = None, visible: str = None, true_text: str = 'Show', false_text: str = 'Hide', value: str = '.TRUE.', help: str = None, help_mode: str = None)¶ Add a boolean parameter to the category.
By default, boolean parameters display
Show
orHide
when true or false, but these may be changed using thetrue_text="...", false_text="..."
parameters.
-
Category.
choice
(name: str, *, choices: Dict[int, str], description: str = None, group: str = '', enable: str = None, visible: str = None, value: str = '', help: str = None, help_mode: str = None)¶ Add a choice parameter to the category.
The choices must be specified by passing a dictionary to the
choices={...}
parameter. Dictionary keys should be integers, and the values the text to display for each key.
-
Category.
integer
(name: str, *, description: str = None, group: str = '', enable: str = None, visible: str = None, value: int = 0, help: str = None, help_mode: str = None, minimum: int = - 2147483647, maximum: int = 2147483647)¶ Add an integer parameter to the category.
-
Category.
real
(name: str, *, description: str = None, group: str = '', enable: str = None, visible: str = None, value: float = 0.0, help: str = None, help_mode: str = None, minimum: float = - 1e+308, maximum: float = 1e+308, units: str = None)¶ Add an real parameter to the category.
Parameters¶
-
class
mhi.pscad.automation.wizard.UserDefnWizard.
Categories
¶ Component parameter form category container, accessed using the
wizard.category
property.-
add
(name, *, enable: str = 'true', level: int = None)¶ Add a new category
-
keys
() → List[str]¶ List of Form Category names
-
Parameter¶
-
class
mhi.pscad.automation.wizard.UserDefnWizard.
Parameter
¶ Component parameter
-
allow_empty_strings
¶ Is Text Parameter allowed to be empty?
-
property
choices
¶ Choice parameter choices
-
description
¶ Parameter description
-
enable
¶ Parameter enable condition
-
error_message
¶ Text Parameter invalid input error message
-
group
¶ Parameter group
-
help_mode
¶ Parameter help mode (
Overwrite
orAppend
)
-
help_text
¶ Parameter Help text
-
maximum
¶ Parameter maximum limit
-
minimum
¶ Parameter minimum limit
-
name
¶ Parameter name
-
regex
¶ Text Parameter regular-expression filter
-
type
¶ Type of the Parameter
-
units
¶ Parameter units
-
value
¶ Parameter description
-
visible
¶ Parameter visibility condition
-