Call Nodes#

Overview#

class mhi.psout.Call#

A Call in the global call tree of the file.

All calls other than the root call node will have a parent. Every call may have child subcalls, which in turn can have grandchildren, great-grandchildern, and so on.

Identification#

Call.file: File#

File the call is from

Call.id#

The call handle’s id

property Call.type: CallType#

Type of this call node.

Identifies the node as either a MODULE, TRACE, or ROOT.

Added in version 2.0.

Call.parent#

Return the parent call handle

Call.variables() → Dict[str, Any]#

Retrieve the key=value attributes stored with this object as a dictionary.

If only a single variable value is required, item["VariableName"] may be used to fetch just that value.

Children#

Call.num_calls#

Returns number of sub call handles

Call.call(path: int | str, *, sep: str = '') → Call#

Return a subcall of the current node, identified by either an id number, or a path.

Parameters:
  • path – the id or xpath of a subcall

  • sep – A delimiter string (optional)

Changed in version 1.3: Accepts a path instead of a name, simplifying access to grandchildren

Call.calls(path: str = '*', *, sep: str = '') → Iterable[Call]#

Return the subcall children of the current call, matching the given path pattern.

Parameters:
  • path – An XPath-esque filter pattern

  • sep – A delimiter string (optional)

Examples:

for child in call.calls():
    print(child)

for descendent in call.calls('**'):
    print(descendent)

Changed in version 1.3: Added optional path argument (defaults to *)

Call.paths(path: str = '*', *, sep: str = '') → Iterable[str]#

Return the subcall child paths of the current call, matching the given path pattern.

Parameters:
  • path – An XPath-esque filter pattern

  • sep – A delimiter string (optional)

Examples:

for path in call.paths():
    print(path)

for path in call.paths('**'):
    print(path)

Added in version 1.3.

Call.call_paths(path: str, *, sep: str = '') → Iterable[Tuple[Call, str]]#

Return the calls and paths from the current call that match the given path pattern.

Parameters:
  • path – An XPath-esque filter pattern

  • sep – A delimiter string (optional)

Example:

for node, path in call.call_paths("**/*[@Source='PGB']"):
    print(path, node)

Added in version 1.3.

Call.add_call(iid: int, **kwargs) → Call#

Add a new “MODULE” call to the call tree under this parent.

Parameters:
  • iid – Identifier for the new child call node

  • kwargs – Additional name/value pairs (eg, Name=”…”) for the call

Added in version 2.0.

Call.add_module(iid: int, name: str, **kwargs) → Call#

Add a PSCAD-flavoured “MODULE” call.

Ensures the added MODULE call node has Source="Module"

Parameters:
  • iid – Identifier for the new child call node

  • name – The name for the node

  • kwargs – Additional name/value pairs

Added in version 2.0.

Call.add_trace_call(iid: int, **kwargs) → Call#

Add a new “TRACE” call to the call tree under this parent.

Parameters:
  • iid – Identifier for the new child call node

  • kwargs – Additional name/value pairs (eg, Name=”…”) for the call

Added in version 2.0.

Call.add_pgb_call(iid: int, name: str, description: str = 'Output Channel') → Call#

Add a single PSCAD-flavoured “TRACE” calls.

Creates MODULE call node with the given Name and Description, with Source="PGB". Inside that call node, creates a MODULE call node with Name="Record", and Source="Data". Inside the Record call node, create the TRACE call node, with Name="PGB:Data", Description="{name}:PGB:Trace:1", and Source="Trace".

Parameters:
  • iid – Identifier for the new child call node

  • name – The name for the PGB

  • description – a description of the PGB

  • kwargs – Additional name/value pairs

Returns:

The created TRACE call node

Added in version 2.0.

Call.add_pgb_calls(iid: int, name: str, dim: int, description: str = 'Output Channel') → List[Call]#

Add PSCAD-flavoured “TRACE” calls.

Creates MODULE call node with the given Name and Description, with Source="PGB". Inside that call node, creates a MODULE call node with Name="Record", and Source="Data". Inside the Record call node, create the requested number of TRACE call nodes, with Name="PGB:Data", Description="{name}:PGB:Trace:#", and Source="Trace".

Parameters:
  • iid – Identifier for the new child call node

  • name – The name for the PGB

  • dim – dimension (number of traces) to created

  • description – a description of the PGB

  • kwargs – Additional name/value pairs

Returns:

The created TRACE call nodes

Added in version 2.0.