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 in tgt_block_path.

  • lib_block_path — the full path to the block in the model or library. Way lib_block_path you can see it 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 — 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 in tgt_block_path the last one contains the name of the future block, it tries to add a block under this name.

  • If tgt_path if it does not contain the name of the future block, then the name is formed according to the pattern <block_type>-<index> For example Sin-1, where the index is the number of blocks of a given 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") # добавит блок из библиотеки в систему и присвоит ему имя Test_name
_ Errors_
  • If the name is occupied, it ends with an error. IncorrectBlockNameException.

  • If the path to the library block is incorrect, it ends with an error. InvalidBlockPathException.

  • If the system to which the block is added does not exist or is closed, it fails. SystemIsNotExistException.

Deleting a block

The public method is used delete_block

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

  • block_path — the absolute path to the block in the model by type "newmodel_1/Sine Wave", where newmodel_1 — the name of the model, and Sine Wave — the name of the block.

  • 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 — the full path to the block in the system.

  • tgt_block_path::String — 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:

# Добавляет блок с именем Add-3 из модели newmodel_1 в модель newmodel_2
engee.copy_block("newmodel_1/Add-3", "newmodel_2/")

# Добавляет блок с именем Custom Block Name из модели newmodel_1 в модель newmodel_2 под именем Test_name
engee.copy_block("newmodel_1/Custom Block Name", "newmodel_2/Test_name")
_ Errors_
  • IncorrectBlockNameException — 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

# добавляет линии между портами
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)

# удаляет линии между портами
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/removes a line between ports src_port_path and dst_port_path, where src_port — full path to the block’s exit port, tgt_port — 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 src_port_path path is not an out port

  • TargetEgdeIsNotInputPort — if the port on the path is tgt_port_path, it is not the input port.

  • TargetEdgeAlreadyConnected — if the TGT port is already connected.

  • NotAcausalPort — for a non-directional connection, if one of the ports has a 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)
  • Similarly get_param and set_param! for the model parameters.

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

# Получаем текущие параметры Sine Wave
sine_params = engee.get_param("newmodel_1/Sine Wave")

# Создаем копию всех параметров и изменяем только один
modified_params = copy(sine_params)
modified_params["Amplitude"] = "2.5"  # изменяем только амплитуду

# Применяем все параметры (остальные остаются как были)
engee.set_param!("newmodel_1/Sine Wave", pairs(modified_params)...)

The example shows how to change only one parameter of the block (the amplitude), while keeping all other parameters unchanged. Use this approach when you need to modify the block settings point-by-point without risking resetting other parameters.

All available block parameters can be obtained by selecting it with the mouse and running 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 program management.

Examples

engee.add_block("/Basic/Sources/Sine Wave", "model_name/Sine Wave-x") #вставляет блок Sine Wave из библиотеки Basic/Sources и присваивает ему имя Sine Wave-x

engee.add_block("/Basic/Sinks/Terminator", "model_name/") #вставляет блок Terminator из библиотеки Basic/Receivers и присваивает имя автоматически (например Terminator-1, если блок с именем Terminator уже существует)

engee.delete_block("newmodel_1/Terminator") #удаляет блок и все связанные с блоком линии и порты

engee.add_line("Sine Wave/1", "Terminator/1")  #устанавливает сигнал между выходным портом №1 у блока Sin Wave и входным портом №1 блока Terminator

engee.delete_line("Sine Wave/1", "Terminator/1") # deletes 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 simulation parameters

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