Diagram Pragmas#

The graphical information is saved as diagram pragmas in the Swan source. This section describes the diagram pragma classes.

../../../_images/diagram_pragma.svg

DiagramPragma class diagram#

Diagram Pragma#

class ansys.scadeone.core.swan.DiagramPragma#

Bases: object

The diagram information of a graphical object.

property arrow_info: PathInfo#

Return the diagram arrow info.

property coordinates: Coordinates#

Return the diagram coordinates.

property direction: Direction#

Return the diagram direction.

property orientation: Orientation#

Return the diagram orientation.

property size: Size#

Return the diagram size.

property wire_info: PathInfo#

Return the diagram wire info.

Coordinates#

class ansys.scadeone.core.swan.Coordinates(x: Coordinate | None = None, y: Coordinate | None = None)#

Bases: object

Coordinates define a horizontal (x) and a vertical (y) position of a graphical object.

Coordinates are specified as:

xy = COORD ";" COORD

where:

Coordinates are used to define the position of the diagram object, states or Active if/when blocks.

property x: Coordinate | None#

Return the x coordinate.

property y: Coordinate | None#

Return the y coordinate.

Coordinate#

class ansys.scadeone.core.swan.Coordinate(position: Position, value: int)#

Bases: object

Coordinate defines a horizontal (x) or vertical (y) position of a graphical object.

Coordinate is defined as:

xy = ("H" | "h")x ";" ("V" | "v")y
  • ("H" | "h") or ("V" | "v"): Absolute or relative position (see Position)

  • x or y: Coordinate value

The relative coordinate values are computed from:

  • the center of the parent block

  • wire and transition: the center of the source/target, or the previous coordinate

property position: Position#

Return the coordinate position (absolute or relative).

property value: int#

Return the coordinate value.

Position#

class ansys.scadeone.core.swan.Position(value)#

Bases: Enum

Position of a coordinate.

xy = ("H" | "h")x ";" ("V" | "v")y
  • H, V: Absolute position

  • h, v: Relative position

ABSOLUTE = 1#

Absolute position.

RELATIVE = 2#

Relative position.

Size#

class ansys.scadeone.core.swan.Size(width: int, height: int)#

Bases: object

Size of a graphical object.

Size is defined as

wh = width ";" height

where:

  • width: Width value

  • height: Height value

Size is used to define the size of the diagram object, states, active if/when blocks or automaton.

property height: int#

Return the object height.

property width: int#

Return the object width.

Direction#

class ansys.scadeone.core.swan.Direction(value: DirectionType)#

Bases: object

The direction of the diagram object.

Direction is defined as

dir = dir_val

where dir_val is defined in DirectionType.

Direction is used to define the direction of predefined operator and block with text (Expr, Def, Instance, Equation).

property value: DirectionType#

Return the direction value.

Direction type#

class ansys.scadeone.core.swan.DirectionType(value)#

Bases: Enum

The direction value of a diagram object.

The direction value is defined as

dir_val = ne|nw|es|en|se|sw|ws|wn

where:

  • ne: North-East

  • nw: North-West

  • es: East-South

  • en: East-North

  • se: South-East

  • sw: South-West

  • ws: West-South

  • wn: West-North

The direction value is read as: the first direction is at the top of the graphical object, and the second direction is the right side of the graphical object.

The default direction is North-East:
  • West corresponding to inputs,

  • East corresponding to outputs.

EAST_NORTH = 'en'#

East-North direction. From the default direction, a 90° left rotation and a horizontal flip are applied (inputs are at the bottom and outputs are at the top).

EAST_SOUTH = 'es'#

East-South direction. From the default direction, a 90° left rotation is applied (inputs are at the bottom and outputs are at the top).

NORTH_EAST = 'ne'#

North-East direction. Default direction (inputs are on the left, outputs are on the right).

NORTH_WEST = 'nw'#

North-West direction. From the default direction, a horizontal flip is applied, or a 180° rotation and a vertical flip are applied (inputs are on the right and outputs are on the left).

SOUTH_EAST = 'se'#

South east direction. From the default direction, a vertical flip is applied (inputs are on the left and outputs are on the right).

SOUTH_WEST = 'sw'#

South-West direction. From the default direction, a 180° rotation is applied (inputs are on the right and outputs are on the left).

WEST_NORTH = 'wn'#

West-North direction. From the default direction a 90° right rotation is applied (inputs are at the top and outputs are at the bottom).

WEST_SOUTH = 'ws'#

West-South direction. From the default direction, a 90° right rotation and a horizontal flip are applied (inputs are at the top and outputs are at the bottom).

Orientation#

class ansys.scadeone.core.swan.Orientation(value: OrientationType)#

Bases: object

Text content orientation.

Orientation is defined as

orient = orient_val

where orient_val is defined in OrientationType.

Orientation is used to define the text content orientation of the diagram object.

property value: OrientationType#

Return the orientation value.

Orientation type#

class ansys.scadeone.core.swan.OrientationType(value)#

Bases: Enum

Text content orientation value.

The orientation value is defined as:

orient_val = "H"|"V"

where:

  • H: Horizontal orientation

  • V: Vertical orientation

HORIZONTAL = 'H'#

Horizontal orientation.

VERTICAL = 'V'#

Vertical orientation.

Path information#

class ansys.scadeone.core.swan.PathInfo(w_anchor: WireAnchor, path: WirePath)#

Bases: object

The wire or transition path between two objects. The path is defined by a list of moves.

The wire and transition paths are defined as:

  • Wire

wp = path_info
  • Transition

tp = path_info

where:

path_info = w_anchor path

w_anchor is defined in WireAnchor.

path is defined in WirePath.

property path: WirePath#

Return the path.

property w_anchor: WireAnchor#

Return the wire anchor.

Wire anchor#

class ansys.scadeone.core.swan.WireAnchor(lunum: Lunum | None = None, coordinates: Coordinates | None = None)#

Bases: object

Wire anchor is the starting or ending point of a path.

Wire anchor is defined as:

w_anchor = LUNUM
    | COORD '|' LUNUM (* connection to a group-related block *)
    | coordinates '|' LUNUM (* coordinates of a starting/ending point of a transition for a state *)
    | coordinates (* unconnected point as a pair of COORD. *)

where:

  • LUNUM: The graphical object identifier (see Lunum)

  • COORD: Coordinate x or y (see Coordinate)

  • coordinates: Coordinates (x;*y*) (see Coordinates)

property coordinates: Coordinates | None#

Return the coordinates.

property lunum: Lunum#

Return the LUNUM.

Wire path#

class ansys.scadeone.core.swan.WirePath(moves: List[Move] | None = None, w_anchor: WireAnchor | None = None, branch: Branch | None = None)#

Bases: object

The wire path structure.

Wire path is defined as:

path = {move} w_anchor
        | {move} branch

{move} means zero or more moves. where:

property branch: Branch | None#

Return the branch.

property moves: List[Move] | None#

Return the moves.

property w_anchor: WireAnchor | None#

Return the wire anchor.

Move#

class ansys.scadeone.core.swan.Move(coordinates: MoveCoordinates | None = None)#

Bases: object

Movement of a wire or transition.

Move is defined as:

Move = move_coordinates

Where:

property coordinates: MoveCoordinates | None#

Return the coordinates.

Move coordinates#

class ansys.scadeone.core.swan.MoveCoordinates(coordinates: Coordinates, fork_coordinates: Coordinates | None = None)#

Bases: object

Move coordinates manages the movement among coordinates of wires and transitions.

Wire coordinates are defined as:

wire_coordinates = COORD | coordinates

and transition coordinates are defined as:

transition_coordinates = (COORD | coordinates) '|' coordinates

Thus, joining both definitions, move coordinates is defined as:

move_coordinates = (COORD | coordinates) '|' coordinates
property coordinates: Coordinates#

Return the coordinates.

property fork_coordinates: Coordinates | None#

Return the fork coordinates. Only applies to transitions.

Branch#

class ansys.scadeone.core.swan.Branch(path_list: List[WirePath])#

Bases: object

Branch is the graphic path followed by the wire or transition.

Branch is defined as:

branch = '[' path_list ']';
path_list = path
    | path_list ',' path

where:

property path_list: List[WirePath]#

Return the path list.