Public methods of programme management
See also: Application of Programme Model Control. |
All public methods of the engee
programme control are presented here. For engee.script
methods, please refer to the article Software script management.
engee
methods
#
engee.add_block
— Function
engee.add_block(block_identity::String, tgt_block_path::String)
Adds a block from the library.
Arguments
-
lib_block_path::String
: full path to the block in the library. The path starts with/
. -
tgt_block_path::String
: the path to the target system and the expected name of the new block. If only the system name is specified (e.g.,"newmodel_1/"
), the block name will be automatically generated. If the full path with the block name is specified (e.g.,"newmodel_1/Sum1"
), the block will receive the specified name.
Examples
# Добавление блока из библиотеки без присвоения имени
engee.add_block("/Basic/Math Operations/Add", "newmodel_1/")
# Добавление блока с присвоением имени
engee.add_block("/Basic/Math Operations/Add", "newmodel_1/Add_block_new")
#
engee.add_line
— Function
engee.add_line(src_port::String, dst_port::String) = engee.add_line(engee.gcs(), src_port::String, dst_port::String)
engee.add_line(system::String|System, src_port::String, dst_port::String)
engee.add_line(system_id::UUID, src_port::String, dst_port::String)
Adds a link (data flow) between blocks.
Arguments
-
system::System
: the path to the system or an object of typeSystem
. -
src_port::String
: full path toout
(output) port of the block. The serial number of the port is used as the port name. The format of the entry is"system_name/block_name/idx"
. For physical blocks, the programme name of the port is used, e.g.Resistor/ac_1
. -
tgt_port::String
: full path toin
(input) port of the block. The name and record format are similar to the input port.
Examples
# Соединяет первый входной порт блока Sine Wave и первый выходной порт блока Terminator в текущей модели
engee.add_line("Sine Wave/1", "Terminator/1")
# Первый параметр может быть объектом System
system = engee.gcs()
# Вызов эквивалентен предыдущему
engee.add_line(system, "Sine Wave-1/1", "Terminator-1/1")
# Для физических блоков
engee.add_line("Resistor/ac_1", "Current Sensor/ac_1")
#
engee.addpath
— Function
engee.addpath(path::Vararg{String})
Adds one or more paths to the system variable LOAD_PATH
. LOAD_PATH
- is a system variable that Engee uses to find the desired executable objects (e.g. .engee
, .ngscript
), as well as any other paths used in commands.
Arguments
path::Vararg{String}
: one or more paths on the file system.
Examples
engee.addpath("/user/models")
engee.load("model.engee") #загрузка модели
#
engee.clear
— Function
engee.clear()
Clears all variables in the current workspace. clear()
removes all data stored in variables to free up memory for new calculations and data streams. Returns nothing
.
#
engee.clear_all
— Function
engee.clear_all()
Clears all variables, functions, and defined modules from the current workspace. clear_all()
returns the current workspace to its original state. Returns nothing
.
#
engee.close
— Function
engee.close(model_name::String; force::Bool = false)
engee.close(model::Model; force::Bool = false)
engee.close(; force::Bool = false)
Closes the model named model_name
. The model opened to the left in the model navigation pane becomes the current model. If no model is specified, closes the current model. If the current model is not specified, it does nothing. If the model does not already exist, it does nothing.
Arguments
-
model_name::String
: the name of the model to be closed. -
model::Model
: a model object that can be loaded into memory using the functionengee.gcm
. This model can be active in the workspace, but not necessarily open in the GUI. -
force::Bool
: defaults tofalse
. If there are unsaved changes and the parameter is equal tofalse
, it terminates with an error. If equal totrue
, unsaved changes will be lost.
Examples
# Выгружает из памяти модель newmodel_1
engee.close("newmodel_1")
# Выгружает из памяти модель newmodel_1 без сохранения последних изменений
engee.close("newmodel_1", force=true)
# Закрывает модель newmodel_1 (выгружает и убирает с холста)
engee.close("newmodel_1", force=true)
#
engee.close_all
— Function
engee.close_all()
Closes all models.
Examples
# Выгружает из памяти все открытые модели
engee.close_all()
#
engee.compare_models
— Function
engee.compare_models(model_path_1::String, model_path_2::String; subsystem_id_a=UUID_YOU_SUBSYSTEM_IN_MODEL_m)
Compares a pair of models, and returns a list of differences.
Arguments
-
model_path_1::String
: path to the first model to compare. -
model_path_2::String
: the path to the second model to compare with the first. -
subsystem_id_a
: a subsystem identifier, which is used to compare only a specific part of the model (in the subsystem). The specific UUID is used for the call. This parameter can be useful if a comparison of a specific subsystem within a model is required.
Examples
# Абсолютный путь (указание полного пути до файла модели)
m1 = "/user/modelname_1.engee"
# Относительный путь (указание относительного пути до файла модели)
m2 = "modelname_2.engee"
# Вернет результат сравнения m1 и m2
engee.compare_models(m1, m2)
#
engee.convert_model
— Function
engee.convert_model(model_path::String,[out_path::String])
Generates a software control script in Julia language for the specified model. If the path out_path
, is specified, the script is saved to a file with the specified name (the extension can be set arbitrarily, but it is recommended to use .jl to run it in Julia). If the path is not specified, the result is returned as a string.
Arguments
-
model_path::String
: path to the source model in the format.engee
or.slx
to be converted. -
out_path::String
: path to save the generated script. If this argument is not specified, the script can be saved in the default folder (/user
).
Examples
# Получение абсолюнтого пути и вывод Engee-скрипта
model_path = "/user/newmodel_1.engee"
engee.convert_model(model_path)
# Получение относительного пути и вывод Engee-скрипта
m_abs_path = "newmodel_2.engee"
engee.convert_model(m_abs_path)
#
engee.copy_block
— Function
engee.copy_block(src_block_path::String, tgt_block_path::String)
Copies a block from the system.
Arguments
-
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. The format of the entry ispath/to/system/new_block_name
. If no name is specified, it is set automatically.
Examples
# Добавляет блок из модели newmodel_1 и автоматически присваивает ему имя в модели newmodel_2
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")
#
engee.copy_contents
— Function
engee.copy_contents(src_system_path::String, tgt_system_path::String)
engee.copy_contents(src_system_id::UUID, tgt_system_id::UUID)
Copies the contents of one system to another. The target system must be empty. Recursive copying is not allowed.
Arguments
-
src_system_path::String
: path to the system from which to copy. -
tgt_system_path::String
: path to the system being copied to. -
src_system_id::UUID
: ID of the system being copied from. -
src_system_id::UUID
: ID of the system being copied from.
Examples
# Копирование содержимого из корневой системы newmodel_1 в корневую систему newmodel_2
engee.copy_contents("newmodel_1", "newmodel_2")
# Копирование содержимого из подсистемы "newmodel_1/Subsystem" в подсистему `newmodel_1/Subsystem-1`
engee.copy_contents("newmodel_1/Subsystem", "newmodel_1/Subsystem-1")
ERROR: "newmodel_1/Subsystem-1 must be empty. Use `engee.delete_contents`"
engee.delete_contents("newmodel_1/Subsystem-1")
engee.copy_contents("newmodel_1/Subsystem", "newmodel_1/Subsystem-1")
#
engee.create
— Function
engee.create(model_name::String)::Model
Creates a new model named model_name
with default parameters. Returns Model
. The model becomes the current model. Its root system becomes the current system. If a model with this name already exists, it terminates with the error EngeeException
.
Arguments
model_name::String
: the desired name of the model on the system. The model name must not contain the character /
.
Examples
engee.create("NewModel")
Model(
name: NewModel
id: 6b59d80d-8b48-419d-83e7-a90660aa1a6a
)
#
engee.delete_block
— Function
engee.delete_block(block_path::String)
Removes the block, all associated lines, and writable ports from the system.
Arguments
block_path::String
: path to the block.
Examples
# Удаляет блок Sine Wave и все связанные с ним линии и блоки из системы
engee.delete_block("newmodel_1/Sine Wave")
#
engee.delete_contents
— Function
engee.delete_contents(system_path::String)
engee.delete_contents(system_id::UUID)
Deletes the contents of the system.
Arguments
-
system_path::String
: path to the system whose content will be deleted. -
system_id::UUID
: ID of the system whose content will be deleted.
Examples
# Удаление всех блоков из подсистемы Subsystem-1 в модели newmodel_1
engee.delete_contents("newmodel_1/Subsystem-1")
#
engee.delete_line
— Function
engee.delete_line(src_port::String, dst_port::String) = delete_line(gcs(), src_port::String, dst_port::String)
engee.delete_line(system::System, src_port::String, dst_port::String)
Removes the link (data flow) between blocks.
Arguments
-
system::String||System
: the path to the system or an object of typeSystem
. -
src_port::String
: full path toout
(output) port of the block. The serial number of the port is used as the port name. The format of the entry is"system_name/block_name/idx"
. -
tgt_port::String
: full path toin
(input) of the block port. The name and format of the record are similar to theout
port.
Examples
# Удаляет соединение между первым входным портом блока Sine Wave и первым выходным портом блока Terminator в модели newmodel_1
engee.delete_line("newmodel_1", "Sine Wave/1", "Terminator/1")
system = engee.gcs()
engee.delete_line(system, "Sine Wave-1/1", "Terminator-1/1")
# Удаление без указания системы. По умолчанию вызывается применительно к текущей системе
engee.delete_line("Sine Wave-2/1", "Terminator-2/1")
#
engee.find_system
— Function
engee.find_system(; blocktype::Maybe{String}=nothing, depth::Maybe{Int}=nothing, blockparams::Vector{<:Pair{<:AbstractString,<:Any}}=Vector{Pair{String, Any}}())
Searches for entities (models/systems/blocks) in all available models. Returns paths to the found entities.
Arguments
-
blocktype::Maybe{String}=nothing
: type of block to search for. Only blocks with the given type will be returned. -
depth::Maybe{Int}=nothing
: maximum search depth (inclusive). To search without limits, passnothing
. The enumeration starts with 0. The default isnothing
. -
blockparams::Vector
: only blocks with the specified parameters will be returned.
Examples
# Список всех сущностей
engee.find_system(;)
# Список сущностей моделей, не заходя в подсистемы
engee.find_system(; depth=0)
# Список всех блоков типа Sin
engee.find_system(; blocktype="Sin")
# Список всех блоков с полем Value равным 1.0
engee.find_system(; blockparams=["Value"=>1.0])
engee.find_system(path::String; blocktype::Maybe{String}=nothing, depth::Maybe{Int}=nothing, blockparams::Vector{<:Pair{<:AbstractString,<:Any}}=Vector{Pair{String, Any}}())
Searches for entities (models/systems/blocks) along the specified path. Returns the paths to the found entities.
Arguments:
-
path::String
: path to the entity to be searched for -
blocktype::Maybe{String}=nothing
: the type of block to search for. Only blocks with the given type will be returned. -
depth::Maybe{Int}=nothing
: maximum search depth (inclusive). For an unconstrained search, nothing must be passed. The enumeration starts with0
. The default is nothing. -
blockparams::Vector
: only blocks with the specified parameters will be returned.
Examples
# Список сущностей, из которых состоит модель с именем newmodel_1 (подсистем, блоков)
engee.find_system("newmodel_1")
# Список сущностей модели newmodel_1 не заходя в подсистемы
engee.find_system("newmodel_1"; depth=0)
# Список всех блоков типа Sin в модели newmodel_1
engee.find_system("newmodel_1"; blocktype="Sin")
# Список всех блоков с полем Value равным 1.0 в модели `newmodel_1`
engee.find_system("newmodel_1"; blockparams=["Value"=>1.0])
engee.find_system(system::System; blocktype::Maybe{String}=nothing, depth::Maybe{Int}=nothing, blockparams::Vector{<:Pair{<:AbstractString,<:Any}}=Vector{Pair{String, Any}}())
Searches for entities (models/systems/blocks) in the specified system passed as an object of type System
. Returns paths to the found entities.
Arguments:
-
system::System
: the system to be searched. -
blocktype::Maybe{String}=nothing
: the type of block to search. Only blocks with the given type will be returned. -
depth::Maybe{Int}=nothing
: maximum search depth (inclusive). For an unrestricted search, passnothing
. The enumeration starts with0
. The default isnothing
. -
blockparams::Vector
: only blocks with the specified parameters will be returned.
Examples
# Список сущностей, из которых состоит cистема system (подсистем, блоков)
engee.find_system(system)
# Список сущностей системы system не заходя в подсистемы
engee.find_system(system; depth=0)
# Список всех блоков типа Sin в системе system
engee.find_system(system; blocktype="Sin")
# Список всех блоков с полем Value равным 1.0 в системе system
engee.find_system(system; blockparams=["Value"=>1.0])
engee.find_system(model::Model; blocktype::Maybe{String}=nothing, depth::Maybe{Int}=nothing, blockparams::Vector{<:Pair{<:AbstractString,<:Any}}=Vector{Pair{String, Any}}())
Searches for entities (models/systems/blocks) in the specified model passed as an object of type Model
. Returns paths to the found entities.
Arguments:
-
model::Model
: A model object that can be loaded into memory using the functionengee.gcm
. This model can be active in the workspace, but not necessarily open in the GUI. The search will be performed in this model. -
blocktype::Maybe{String}=nothing
: the type of block to search for. Only blocks with the specified type will be returned. -
depth::Maybe{Int}=nothing
: maximum search depth (inclusive). For an unconstrained search. you must passnothing
. The enumeration starts with0
. The default isnothing
. -
blockparams::Vector
: only blocks with the specified parameters will be returned.
Examples
# Список сущностей, из которых состоит модель model (подсистем, блоков)
engee.find_system(model)
# Список сущностей модель model не заходя в подсистемы
engee.find_system(model; depth=0)
# Список всех блоков типа Sin в модели model
engee.find_system(model; blocktype="Sin")
# Список всех блоков с полем Value равным 1.0 в модели model
engee.find_system(model; blockparams=["Value"=>1.0])
#
engee.gcb
— Function
engee.get_current_block()::String
engee.gcb()::String
Returns the path to the current (selected) block. If no block is selected, returns nothing
.
#
engee.gcm
— Function
engee.get_current_model()::Model
engee.gcm()::Model
Returns the current (active) model (returns an object with type Model
). If there is no current model, throws an exception EngeeException
.
Examples
engee.get_current_model()
Model(
name: ssc_bridge_rectifier_modified
id: c390ed60-d2c4-4e17-85df-07129aca8ba4
)
#
engee.gcs
— Function
engee.get_current_system()::System
engee.gcs()::System
Returns the current system as an object of type System
. If the current model does not exist, it raises an error EngeeException
.
Examples
engee.get_current_system()
System(
name: root
id: 4db18dce-1bca-46ca-8441-6f4802a78c6f
)
#
engee.generate_code
— Function
engee.generate_code(path/to/modelname.engee::String, path/to/output_dir::String; subsystem_name=subsystem_path::String, subsystem_id=subsystem_id::String, target::String, jl_path::String)
Generates code in the specified language for models and/or subsystems. Supports the use of templates to customise the output code (including the main
function).
For models
-
Generation is performed for the entire model specified by the absolute or relative path to the model file
.engee
. -
A code generation target can be specified via the parameter
target
, and a custom template path can be specified viatemplate_path
.
Arguments
-
model_path::String
: absolute or relative path to the model from which the code is generated. The argument can be a model object (an object of typemodel
, obtained by the functionengee.gcm
). -
output_dir::String
: absolute or relative path to the directory where the generated code will be saved. If the directoryoutput_dir
does not exist, it will be created automatically. -
target::String
: specifying the language for code generation. Supported languages areСи
(default) orVerilog
. -
template_path::String
: path to the.jl
template file (for example, the function templatemain
).
Examples
# Генерация Си кода для модели
engee.generate_code("newmodel_1.engee", "newmodel_1/codegen_output")
# Генерация Verilog-кода, будет создан файл newmodel_1.v с Verilog-кодом
engee.generate_code("newmodel_1.engee", "newmodel_1/verilog_output", target="verilog")
# Генерация кода с шаблоном, содержащим функцию main
engee.generate_code("codegen_model.engee", "codegen_dir", template_path="/user/main_template.jl")
# Получение текущей открытой модели и генерация кода из нее
m = engee.gcm()
engee.generate_code(m, "/user/newmodel_1/codegen_output")
For subsystems
-
Generation is performed only for the atomic subsystem specified by name (
subsystem_name
) or by identifier (subsystem_id
). -
Other parameters are similar to generation for the full model.
Arguments
-
subsystem_name::String
: full path to the atomic subsystem from which the code is generated. -
subsystem_id::String
: unique identifier of the atomic subsystem from which the code is generated (alternativesubsystem_name
). -
target::String
: specification of the language for code generation. Supported languages areСи
(default) orVerilog
.
Examples
# Генерация Си кода для подсистемы по имени
engee.generate_code("newmodel_1.engee", "newmodel_1/Subsystem", subsystem_name="Subsystem")
# Генерация кода для атомарной подсистемы по ее id
engee.generate_code("/user/newmodel_1.engee", "/user/newmodel_1/Subsystem"; subsystem_id = "88275e0b-a049-4bb5-b8c7-057badd1b536")
# Генерация Verilog кода для подсистемы, будет создан файл newmodel_1.v с Verilog-кодом подсистемы
engee.generate_code("newmodel_1.engee", "newmodel_1/verilog_pid", subsystem_name="SubSystem", target="verilog")
#
engee.get_all_models
— Function
engee.get_all_models(; sorted=true)::Vector{Model}
Returns a list of all models open in the current session, in the format Vector{Model}
. If the parameter is sorted=true
, it returns a list of models sorted by name.
Arguments
sorted::Bool
: default true
. Determines whether the list of models is sorted by name.
Examples
# Список с перечнем всех открытых моделей
models_list = engee.get_all_models()
# Список с названиями всех открытых моделей
model_names = [m.name for m in engee.get_all_models()]
#
engee.get_current_block
— Function
engee.get_current_block()::String
engee.gcb()::String
Returns the path to the current (selected) block. If no block is selected, returns nothing
.
#
engee.get_current_model
— Function
engee.get_current_model()::Model
engee.gcm()::Model
Returns the current (active) model (returns an object with type Model
). If there is no current model, throws an exception EngeeException
.
Examples
engee.get_current_model()
Model(
name: ssc_bridge_rectifier_modified
id: c390ed60-d2c4-4e17-85df-07129aca8ba4
)
#
engee.get_current_system
— Function
engee.get_current_system()::System
engee.gcs()::System
Returns the current system as an object of type System
. If the current model does not exist, it raises an error EngeeException
.
Examples
engee.get_current_system()
System(
name: root
id: 4db18dce-1bca-46ca-8441-6f4802a78c6f
)
#
engee.get_logs
— Function
engee.get_logs([m::Model])
Gets the log messages associated with the model. Returns an array with the messages.
Arguments
m::Model
: the model with respect to which the operation is performed, defaults to the current model. If the model is not open, outputs an error NoModelOpenedException
.
#
engee.get_param
— Function
engee.get_param(model::Model)
engee.get_param(path::String, param::Union{Symbol, String})::Any
engee.get_param(path::String, param::Union{Symbol, String})::Any
engee.get_param(block::Block)
engee.get_param(block::Block, param::Union{Symbol, String})::Any
For models
-
If a model name is specified but no parameter name is specified, returns the simulation settings for the selected model as a dictionary.
-
If a parameter name is specified, it returns the parameter value.
Arguments
-
model::Model
: a model object that can be loaded into memory using the functionengee.gcm
. This model can be active in the workspace, but not necessarily open in the GUI. Parameters will be extracted from this model. -
path::String
: string path to the model, if a path is used instead of a model object. -
param::Union{Symbol, String}
: the name of the parameter to be extracted. Can be a string or a character.
For blocks.
-
On the path to the block, returns either the value of the parameter (if specified) or a dictionary of parameters.
-
If a parameter name is specified, it returns the parameter value.
Arguments
-
block::Block
: the block object for which to retrieve parameters. -
path::String
: the string path to the block, if the path is used instead of the block object. -
param::Union{Symbol, String}
: the name of the block parameter to be extracted. Can be a string or a character.
Examples
# Получение словаря всех параметров модели
m = engee.gcm()
params = engee.get_param(m)
#
engee.get_results
— Function
engee.get_results(model_name::String)
engee.get_results(model::Model)
engee.get_results()
Returns the results of the last simulation of the model as a dictionary Dict{String, DataFrame}
, where key is the name of the port being monitored. If the model is not open, it displays the error NoModelOpenedException
. If the simulation is not running, it displays the error ModelIsNotRunningException
.
Arguments
model::Model
: a model object that can be loaded into memory using the function engee.gcm
. This model can be active in the workspace, but not necessarily open in the GUI. The operation to return the results of the last simulation will be performed relative to this model.
Examples
m = engee.load("start/examples/powersystems/models/power_line_apv.engee")
results1 = engee.run(m);
results2 = engee.get_results(m)
Dict{String, DataFrame} with 6 entries:
"Va" => 40001×2 DataFrame…
"Ia" => 40001×2 DataFrame…
"Ib" => 40001×2 DataFrame…
"Ic" => 40001×2 DataFrame…
"Vc" => 40001×2 DataFrame…
"Vb" => 40001×2 DataFrame…
results1 == results2
true
#
engee.get_status
— Function
engee.get_status()::SimulationStatus
Returns the simulation status as an object of type SimulationStatus
. Returns one of five simulation statuses of the model:
-
BUILDING
: model under construction. -
READY
: model is ready. -
NOT_READY
: model not ready. -
RUNNING
: model in progress. -
PAUSED
: the model is on hold.
Examples
engee.get_status()
READY
#
engee.is_dirty
— Function
engee.is_dirty(model::Model)::Bool
engee.is_dirty(model_path::String)
Checks if there are any unsaved changes to the model. Returns true
if there are unsaved changes, otherwise returns false
. If the model is already closed, returns false
.
Arguments
-
model::Model
: A model object that can be loaded into memory usingengee.gcm
. This model can be active in the workspace, but not necessarily open in the GUI. -
model_path::String
: the path to the model.
#
engee.load
— Function
engee.load(file_path::String; name::Maybe{String}=nothing, force::Bool = false)::Model
Loads a model from a file with extension .engee
, located at file_path
. Returns Model
. The model becomes the current model. Its root system becomes the current system. Features:
-
If a model with this name already exists and the parameter is equal to
true
, then reloads it and any changes not previously saved will be lost, if equal tofalse
, then throws an exception. The default isfalse
. -
The model can be loaded with a different name if it is specified in the parameter
name
. If the parameter is not specified, it leaves the model name saved in the file. -
If the file has a different extension or does not exist, it throws an exception.
Arguments
-
file_path::String
: path to the file from which the model or data will be loaded. -
name::Maybe{String}
: used to specify the name of the model or data to be loaded. -
force::Bool
: defaults tofalse
. If it istrue
, the download will be performed if the file has already been previously downloaded.
Examples
engee.load("NewModel.engee"; force = true)
Model(
name: NewModel
id: 6b59d80d-8b48-419d-83e7-a90660aa1a6a
)
#
engee.open
— Function
engee.open(path::String)::System
engee.open(model::Model)::System
engee.open(system::System)::System
Returns an open system System
. If the model or system does not exist, it terminates with an error EngeeException
. The behaviour of the method changes if:
-
The parameter specifies the name
model_name
of a previously opened model, then it becomes the current model. Its root system becomes the current system; -
The parameter specifies the path to an existing system
system_path
, then the model containing it becomes the current model, and the system itself becomes the current system that is displayed in the visual editor. ReturnsSystem
. You can also pass directly an instance ofModel
orSystem
instead of the path.
Arguments
-
path::String
: the path to the model. -
model::Model
: a model object that can be loaded into memory using the functionengee.gcm
. This model can be active in the workspace, but not necessarily open in the GUI. The default is the current model. -
system::System
: system path or an object of type System.
Examples
# open model:
s1 = engee.open("NewModel")
System(root)
engee.gcm(), engee.gcs()
(Model(
name: NewModel
id: 6b59d80d-8b48-419d-83e7-a90660aa1a6a
)
, System(
name: root
id: 69f5da6f-250d-4fa7-a25f-645bac751aea
)
)
# open system:
engee.open("AnotherModel/Subsystem-1")
System(
name: root
id: 69f5da6f-250d-4fa7-a25f-645bac751aea
)
engee.gcm(), engee.gcs()
(Model(
name: AnotherModel
id: 6b59d80d-8b48-419d-83e7-a90660aa1a6a
)
, System(
name: Subsystem-1
id: 69f5da6f-250d-4fa7-a25f-645bac751aea
)
)
#
engee.resume
— Function
engee.resume(; verbose::Bool = false)
Resumes a suspended simulation.
Arguments
verbose::Bool = false
: enables the output of simulation progress messages.
#
engee.rmpath
— Function
engee.rmpath(path::String)
Removes the path from the system variable LOAD_PATH
. LOAD_PATH
- is a system variable that Engee uses to find the desired executable objects (e.g. .engee
, .ngscript
), as well as any other paths used in commands.
Arguments
path::String
: file system path to be removed from LOAD_PATH
.
Examples
engee.addpath("/user/models")
# Загрузка модели
engee.load("model.engee")
engee.rmpath("/user/models")
# Загрузка модели выдаст ошибку
engee.load("model.engee")
#
engee.run
— Function
engee.run([m::Model]; verbose=false)
Starts the execution of the model. If no model is specified, runs a simulation of the current model. If no model is open, throws an exception NoModelOpenedException
.
Arguments
-
verbose
: specifies whether the progress of the model execution should be printed (default isfalse
- not printed). -
m::Model
: the model relative to which the operation is executed. The default is the current model.
Examples
m = engee.load("/user/start/examples/power_systems/power_line_apv/power_line_apv.engee")
engee.run(m)
Dict{String, DataFrame} with 6 entries:
"Va" => 40001×2 DataFrame…
"Ia" => 40001×2 DataFrame…
"Ib" => 40001×2 DataFrame…
"Ic" => 40001×2 DataFrame…
"Vc" => 40001×2 DataFrame…
"Vb" => 40001×2 DataFrame…
# Пример асинхронного, бесконечного моделирования
m = engee.load("/user/start/examples/controls/PID_controller/pid_controls_tf_stable.engee")
engee.set_param!(m, "end_time" => Inf)
ch = Channel(c -> put!(c, engee.run(m)))
sleep(10)
engee.stop()
take!(ch)
#
engee.save
— Function
engee.save(model_name::String, file_path::String; force::Bool = false)
engee.save(model::Model, file_path::String; force::Bool = false)
Saves the model named model_name
at path file_path
to a file with extension .engee
. If necessary, intermediate directories are created. Returns nothing
.
Arguments
-
model::Model
: A model object that can be loaded into memory using the functionengee.gcm
. This model can be active in the workspace, but not necessarily open in the GUI. -
model_name::String
: the desired name of the model in the system. -
file_path::String
: the directory of the model to be saved. -
force::Bool
: defaults tofalse
. If the file already exists and the parameter is equal totrue
, overwrites the file. If equal tofalse
, it will fail with the errorFileAlreadyExists
.
Examples
# Сохраняет модель newmodel_1 в новый файл newmodel_1.engee
engee.save("newmodel_1", "newmodel_1.engee")
# Сохраняет модель newmodel_1 в файл newmodel_1.engee (перезапывает файл)
engee.save("newmodel_1", "newmodel_1.engee", force = true)
#
engee.screenshot
— Function
engee.screenshot(to_print::Union{Model, String, System}, save_path::String; position_mode::String="auto")
Saves screenshot of model/system to file at path save_path
. Supported formats: PNG, SVG. In other cases an error is displayed ErrorException("unsuported picture format: <FORMAT>")
. Positioning: "auto", "tiled", in other cases "auto" applies.
Arguments
-
to_print::Union{Model, String, System}
: name of the model from which the screenshot will be taken. -
save_path::String
: path to save the screenshot. -
position_mode::String
: positioning of the screenshot. The following modes are used:"auto"
- automatically determine the optimal positioning of blocks (standard mode);"tiled"
- arrange the blocks in a grid to avoid overlaps and make the structure more readable. Any other value is taken as"auto"
.
Examples
engee.screenshot(loaded_model, "/user/saved.png"[; position_mode="tiled"])
#
engee.set_log
— Function
engee.set_log(system_path::String, port_path::String)
engee.set_log(system::System, port_path::String)
engee.set_log(port_path::String)
Sets the port to write.
Arguments
-
system_path::String
: system where the port is located. -
system::System
: system where the port is located. -
port_path::String
: relative path to the port. If no system is provided as the first parameter, the default open system is used.
Examples
engee.set_log("Sine Wave/1")
# Порт блока Sine Wave в текущей системе установлен на запись
engee.set_log("newmodel_1/Subsystem","Sine Wave/1")
# Порт блока Sine Wave в системе newmodel_1/Subsystem установлен на запись
system = engee.gcs()
engee.set_log(system, "Sine Wave/1")
# Порт блока Sine Wave в системе system установлен на запись
engee.run()
Dict{String, DataFrames.DataFrame} with 1 entry:
"Sine Wave.1" => 1001×2 DataFrame…
#
engee.set_param!
— Function
engee.set_param!(model::Model | model_name::String, param::Pair...)
Updates the parameters of the models. Returns nothing
. If the parameters are incorrect, an error occurs.
Arguments
-
model::Model
: A model object that can be loaded into memory using the functionengee.gcm
. This model can be active in the workspace, but not necessarily open in the GUI. Parameters will be updated for this model. -
model_name::String
: string path or model name. -
param::Pair...
: one or more parameters in the format"name" => value
.
Examples
engee.set_param!("model_1", "SolverName" => "ode45", "StopTime" => "10")
# Получаем параметры модели model_1
param_1 = engee.get_param("model_1")
# Копируем параметры из model_1 в model_2
engee.set_param!("model_2", param_1)
The example shows how you can use get_param
and set_param!
together to copy parameters between models.
The structure of the simulation settings is linked to a specific model - you can change the model settings directly by specifying the structure fields, then:
params = engee.get_param("newmodel_1")
# Структура params привязана к конкретной model, аналогично engee.set_param!("newmodel_1", "FixedStep" => "0.05")
params["FixedStep"] = "0.05"
0.05
Changing values in the dictionary params
does not update the model settings automatically - it is a local copy. To make the changes take effect, you must pass the dictionary back using engee.set_param!
.
params = engee.get_param("newmodel_1")
params["FixedStep"] = "0.05"
params["SolverName"] = "Euler"
engee.set_param!("newmodel_1", "FixedStep" => params["FixedStep"], "SolverName" => params["SolverName"])
Each parameter must be represented as a Pair consisting of the parameter name and its value (e.g. "StartTime" => 0.0
). For the parameter param
:
Simulation Parameters
-
StartTime::String
: simulation start time (Float64). -
StopTime::String
: simulation end time (Float64). To specify an infinite simulation time, pass the string"Inf"
or"inf"
(engee.set_param!("model_name", "StopTime" => "Inf")
) -
SolverType::String
: solver type (fixed-step
orvariable-step
). -
SolverName::String
: solver name (depends on the type selected).
Parameters for fixed-step
FixedStep::String
: simulation step (Float64).
Parameters for variable-step
-
AbsTol::String
: absolute precision (Float64 or 'auto'). -
RelTol::String
: relative precision (Float64 or 'auto'). -
InitialStep::String
: initial step (Float64 or 'auto'). -
MaxStep::String
: maximum pitch (Float64 or 'auto'). -
MinStep::String
: minimum step (Float64 or 'auto'). -
OutputTimes::String
: output interval (Float64 or 'auto'). -
DenseOutput::Bool
: dense output of results.
engee.set_param!(block::Block | block_path::String, params::Pair{String}...)
Updates the parameters of the blocks.
Arguments
-
block::Block
: block object. -
block_path::String
: string path to the block. -
params::Pair{String}...
: block parameters in the format"name" => value
.
Examples
engee.set_param!("model_name", "StartTime" => 0.0, "StopTime" => 10.0, "SolverType" => "fixed-step", "SolverName" => "ode45")
#
engee.unset_log
— Function
engee.unset_log(system_path::String, port_path::String)
engee.unset_log(system::System, port_path::String)
engee.unset_log(port_path::String)
Removes the port from recording.
Arguments
-
system_path::String
: the system the port is on. -
system::System
: system where the port is located. -
port_path::String
: the relative path to the port. If no system is provided as the first parameter, the default open system is used.
Examples
engee.set_log("Sine Wave/1")
# Порт блока Sine Wave в текущей системе установлен на запись
engee.run()
Dict{String, DataFrames.DataFrame} with 1 entry:
"Sine Wave.1" => 1001×2 DataFrame…
# Запустили симуляцию и получили результаты
engee.unset_log("Sine Wave/1")
# Порт блока Sine Wave в текущей системе снят с записи
engee.run()
Dict{String, DataFrames.DataFrame}()
#
engee.update_params
— Function
engee.update_params()
engee.update_params(model::Model)
engee.update_params(model_name::String)
Recalculates on the fly the parameters of the blocks of the running simulation by reading their actual values from the workspace. If there is no running simulation, the function does nothing.
Can take as an optional argument the name of the model or model object for which the parameter update should be applied.
Arguments
-
model::Model
: a model object that can be loaded into memory using the functionengee.gcm
. This model can be active in the workspace, but not necessarily open in the GUI. -
model_name::String
: name of the model whose parameters are to be recalculated.
Examples
# Обновляет параметры всех блоков в текущей симуляции
engee.update_params()
# Обновляет параметры указанной модели
model = engee.gcm()
engee.update_params(model)
# Обновляет параметры модели по имени
engee.update_params("newmodel_1")
#
engee.version
— Function
engee.version()
Returns the short version of Engee.
Examples
engee.version()
"24.10.0"