Software editing of models
Working with models
Adding a block
Before editing a model, open it using the open method. After editing, don’t forget to save the results with save.
To add a block use the public method add_block
engee.add_block(lib_block_path, tgt_block_path)
-
Adds a copy of the block from
lib_block_path
totgt_block_path
. -
The
lib_block_path
is the full path to the block in the model or library. You can see thelib_block_path
path by double-clicking on the free area of the workspace and typing the name of the required block: -
tgt_block_path
- the path to the system and the expected name. If no name is 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 a future block last, tries to add a block under that name. -
If
tgt_path
does not contain the name of the future block, the name is formed using the pattern<block_type>-<index>
, e.g.Sin-1
, where index is the number of blocks of the given type after the addition and Sin is the block_type of the block. -
Adds an additional port to the subsystem when a block port is added, e.g.
Inport
.
Added blocks will not be shown immediately. To display blocks, you must reopen the model (having previously saved 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 busy, terminates with an
IncorrectBlockNameException
error. -
If the path to the library block is incorrect, it terminates with an
InvalidBlockPathException
error. -
If the system to which the block is added does not exist or is closed, it is terminated with a
SystemIsNotExistException
error.
Deleting a block
The public method delete_block is used
engee.delete_block(block_path)
-
Deletes the block at the specified path.
-
block_path
- absolute path to the block in the model by typenewmodel_1/Sine Wave
, wherenewmodel_1
is the model name andSine Wave
is the block name. -
Also deletes all lines and ports associated with the block.
Copying a block
Usage of the public method copy_block
engee.copy_block("newmodel_1/Add-3", "newmodel_2/") # добавить блок из модели `newmodel_1` с именем "Test_name" в модель `nemodel_2`
engee.copy_block("newmodel_1/Custom Block Name", "newmodel_2/Test_name")
-
Adds a block from model
newmodel_1
and assigns it a name in modelnewmodel_2
. -
src_block_path::String
- 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).
Errors
-
IncorrectBlockNameException
- incorrect name for a new block. -
InvalidBlockPathException
- the copied block 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 add_line and delete_line are used
# добавляет линии между портами
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/deletes a line between ports
src_port_path
anddst_port_path
, wheresrc_port
is the full path to the block output port,tgt_port
is the full path to the block input port. -
If the path points to the block port of the subsystem, it connects/disconnects the subsystem itself by the corresponding port.
-
In other cases, the blocks of the corresponding ports must be in the same system.
-
The serial number of the port is used as the port name.
Errors
-
SourceEdgeIsNotOutputPort
- if the port on the src_port_path is not an out port -
TargetEgdeIsNotInputPort
- if the port on the tgt_port_path is not an input port. -
TargetEdgeAlreadyConnected
- if the tgt port is already connected. -
NotAcausalPort
- on a non-directional connection, if one of the ports is of type not acausal. -
LineCannotBeAdded
- if incorrect port type or line direction.
Write/read block and signal parameters
Public methods set_param! and get_param are used
engee.set_param!(blockPath, paramName => paramValue)
engee.get_param(blockPath, paramName)
engee.get_param(blockPath)
engee.set_param!(blockPath, blockParams)
-
Similar to
get_param
andset_param!
for model parameters.
You can get parameters not only for the model, but also for a particular block, and change them using a variable structure (let’s call params), for example:
params = engee.get_param("newmodel_1/Terminator") #возвращает все параметры блока Terminator в структуру params
engee.set_param!("newmodel_1/Terminator", params) #блоку Terminator присваиваются параметры из структуры params
All available parameters for a block can be obtained by selecting it with the mouse and executing
|
All public programme 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") #вставляет блок 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") # удаляет сигнал между выходным портом №1 у блока Sin Wave и входным портом №1 блока Terminator
engee.get_param("newmodel_1") # получение параметров моделирования
engee.set_param!("newmodel_1", "StopTime" => 15, "FixedStep" => 0.05) #меняем время окончания симуляции и фиксированный размер шага