Engee documentation

Programmatic model editing

Working with models

Adding a block

Before editing the model, open it using the method open. After editing, don’t forget to save the results using save.

A public method is used to add a block. add_block

engee.add_block(lib_block_path, tgt_block_path)
  • Adds a copy of the block from lib_block_path to `tgt_block_path'.

  • lib_block_path' is the full path to the block in the model or library. The path `lib_block_path can be seen by double-clicking on the free area of the workspace and typing the name of the desired block.:

    block path add method

  • `tgt_block_path' is the path to the system and the expected name. If the name is not specified, it is set automatically.

  • If the path to an existing model block matches the path to a block from the library because the names of the model and its systems match the names of the library sections, the block from the model is selected.

  • If tgt_block_path contains the name of the future block last, it tries to add a block with this name.

  • If tgt_path does not contain the name of the future block, then the name is modeled after <block_type>-<index>, for example Sin-1, where the index is the number of blocks of this type after addition, and Sin is the block_type of the block.

  • Adds an additional port to the subsystem when adding a block port, for example, `Inport'.

The added blocks will not be shown immediately. To display the blocks, you need to reopen the model (after saving it), switch between models, or reload the page.
example
engee.add_block("/Basic/Math Operations/Add", "newmodel_1/")

engee.add_block("/Basic/Math Operations/Complex to Real-Imag", "newmodel_1/Test_name") # adds a block from the library to the system and assigns it the name Test_name.
_ Errors_
  • If the name is occupied, it ends with the error `IncorrectBlockNameException'.

  • If the path to the library block is incorrect, the error `InvalidBlockPathException' ends.

  • If the system to which the block is added does not exist or is closed, the error `SystemIsNotExistException' ends.

Deleting a block

The public method is used delete_block

engee.delete_block(block_path)
  • Deletes a block along the specified path.

  • 'block_path' is the absolute path to the block in the model by type newmodel_1/Sine Wave, where newmodel_1 is the model name and `Sine Wave' is the block name.

  • It also deletes all lines and ports associated with the block.

Copying a block

Using a public method copy_block:

engee.copy_block(src_block_path::String, tgt_block_path::String)
  • `src_block_path::String' is the full path to the block in the system.

  • tgt_block_path::String is the path to the system and the expected name. Format: `path/to/system/newblockname' (if the name is not specified, it is set automatically).

Example:

# Adds a block named Add-3 from the newmodel_1 model to the newmodel_2 model
engee.copy_block("newmodel_1/Add-3", "newmodel_2/")

# Adds a block named Custom Block Name from the newmodel_1 model to the newmodel_2 model named Test_name
engee.copy_block("newmodel_1/Custom Block Name", "newmodel_2/Test_name")
_ Errors_
  • `IncorrectBlockNameException' is an incorrect name for the new block.

  • `InvalidBlockPathException' — the block being copied does not exist on the specified path.

  • `SystemIsNotExistException' — the system to which the block is added does not exist.

Adding/removing a signal

Public methods are used add_line and delete_line

# adds lines between ports
engee.add_line(src_port, dst_port) = engee.add_line(engee.gcs(), src_port_path, dst_port_path)
engee.add_line(system::String|System, src_port :: String, dst_port :: String)

# deletes lines between ports
engee.delete_line(src_port, dst_port) = delete_line(gcs(), src_port, dst_port)
engee.delete_line(system, src_port :: String, dst_port :: String)
  • Adds/deletes a line between ports src_port_path and dst_port_path, where src_port is the full path to the block’s exit port, and tgt_port is the full path to the block’s input port.

  • If the path points to the subsystem’s block port, it connects/disconnects the subsystem itself via the corresponding port.

  • In all other cases, the blocks of the corresponding ports must be located on the same system.

  • The port name is its serial number.

_ Errors_
  • `SourceEdgeIsNotOutputPort' — if the port on the path src_port_path is not an out port

  • `TargetEgdeIsNotInputPort' — if the port on the path is not the input port.

  • `TargetEdgeAlreadyConnected' — if the tgt port is already connected.

  • `NotAcausalPort' — for an undirected connection, if one of the ports is of the non-acausal type.

  • LineCannotBeAdded — if the port type or line direction is incorrect.

Writing/reading block and signal parameters

Public methods are used set_param! and get_param

engee.set_param!(blockPath, paramName => paramValue)
engee.get_param(blockPath, paramName)
engee.get_param(blockPath)
engee.set_param!(blockPath, blockParams)
  • Similar to get_param and set_param! for the parameters of the model.

You can get the parameters not only of the model, but also of a specific block, and also change them using the structure of variables (let’s call them params), for example:

params = engee.get_param("newmodel_1/Terminator") # returns all parameters of the Terminator block to the params structure

engee.set_param!("newmodel_1/Terminator", params) # the Terminator block is assigned parameters from the params structure

All available block parameters can be obtained by selecting it with the mouse and executing the command engee.get_param(engee.gcb()). For example, for the block Constant:

engee> engee.get_param(engee.gcb())
BlockParameters(
  BlockName => Constant,
  Value => 1.0,
  OutDataTypeStr => Inherit: auto,
  SampleTime => Inf,
  BlockType => Constant,
)
All public software management methods available in Engee are presented in the article. Public methods of programme management.

Examples

engee.add_block("/Basic/Sources/Sine Wave", "model_name/Sine Wave-x") # inserts the Sine Wave block from the Basic/Sources library and assigns it the name Sine Wave-x

engee.add_block("/Basic/Sinks/Terminator", "model_name/") # inserts the Terminator block from the Basic/Receivers library and assigns a name automatically (for example, Terminator-1 if a block named Terminator already exists)

engee.delete_block("newmodel_1/Terminator") # deletes the block and all associated lines and ports

engee.add_line("Sine Wave/1", "Terminator/1")  # sets the signal between output port No. 1 of the Sin Wave unit and input port No. 1 of the Terminator unit

engee.delete_line("Sine Wave/1", "Terminator/1") # removes the signal between output port No. 1 of the Sin Wave block and input port No. 1 of the Terminator block

engee.get_param("newmodel_1") # getting the simulation parameters

engee.set_param!("newmodel_1", "StopTime" => 15, "FixedStep" => 0.05) # change the end time of the simulation and the fixed step size