Engee documentation

Software management of model files

Working with models

Creating a new model

The public method create is used.

Use the following code to create a model in Engee:

model = "model_name"
engee.create(model)

The code initialises a model variable with the value "model_name", after accessing it via engee.create the Model object is returned and the model is created. You can also create a model in another way:

engee.create("model_name")

Here, the name for the model is immediately passed as a string (data type String) and does not require the variable to be initialised beforehand.

Thus, based on the above code:

  • A model is created with model_name and parameters by default.

  • The model becomes the current model. Its root system becomes the current system.

    The model name (model_name) must not contain the character /.
Errors.

If a model with this name already exists, throws a ModelAlreadyExistsException exception.

Output
engee.create("model_name")
"Model(model_name)"

Loading a model from a file

The public method load is used

engee.load(file_path; force = false)
  • Loads a model from a file with extension .engee located in the file_path path.

  • Returns an object of type Model.

  • The model becomes the current model. Its root system becomes the current system.

Errors.
  • If a model with this name already exists and the parameters force = true, then reloads it and any changes not previously saved will be lost, if force = false then throws a ModelAlreadyExistsException exception. By default, force = false.

  • If the file has an invalid extension, it throws the InvalidFileExtension exception.

  • If such a file does not exist, throws the FileNotFound exception.

Output
engee.load("NewModel.engee"; force = true)
Model(NewModel)

Opening a previously used model

The public method open is used

engee.open(model_name)
engee.open(path)
engee.open(model)
engee.open(system)
  • If model_name of a previously opened model is specified in the parameters, it becomes the current model. Its root system becomes the current system. Returns a Model object.

  • Returns the open System.

  • If a path to an existing system system_path is specified in the parameters, the model containing it becomes the current model, and the system itself becomes the current system that is displayed in the visual editor. Returns a System object.

  • It is also possible to pass directly an instance of Model or System instead of the path.

Errors.
  • If the model does not exist, throws a ModelDoesntExistException exception.

  • If the system does not exist, throws a SystemIsNotExistException exception.

Output
# open model:
m1 = engee.open("NewModel")
Model(NewModel)
engee.gcm(), engee.gcs()
(Model(NewModel), System(root))
# open system:
engee.open("AnotherModel/Subsystem-1")
System(Subsystem-1)
engee.gcm(), engee.gcs()
(Model(AnotherModel), System(Subsystem-1))

Referring to the open current model

The public method gcm is used.

engee.get_current_model()
engee.gcm()
  • Returns the current active model.

Opening the current system (model and subsystem)

Uses the public method gcs.

engee.get_current_system()
engee.gcs()
  • Returns the current active system.

Errors
  • If the current system does not exist, throws a NoModelOpenedException exception.

Viewing the list of open models

Uses the public method get_all_models.

engee.get_all_models(; sorted=true)
  • Returns a list of models open in the current session as Vector{Model}.

  • If the parameters sorted=true then sorts the models by name, if sorted=false the models are output in order of opening. By default sorted=true.

Check for unsaved changes

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

To check for unsaved changes use the public method is_dirty.

engee.is_dirty(model)
  • 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.

Saving the model to a file

The public method save is used.

engee.save(model_name, file_path; force = false)
engee.save(model, file_path; force = false)
  • Saves the model named model_name to the path file_path in a file with extension .engee.

  • Intermediate directories are created if necessary.

  • Returns nothing.

Errors.
  • If the file already exists and the parameters force = true, overwrites it, if force = false, it terminates with a FileAlreadyExists error.

By default, force = false.

Closing the model

The public method close is used.

engee.close(model_name; force = false)
engee.close(model; force = false)
engee.close(; force = false)
  • Closes the model with the name model_name in the visual editor (deletes it from the session).

  • The model opened in the visual editor tab to the left becomes the current model.

  • Returns Model.

  • If no model is specified, closes the current model. If no current model is specified, does nothing.

  • If model is closed, does nothing.

Errors.
  • If there are unsaved changes and the parameters force=false, it terminates with an UnsavedModelException error, if force=true, the unsaved changes will be lost.

All public methods of programme management available in Engee are provided in the article Public methods of programme management.

Examples

engee.create("newmodel_1") # создает модель с именем newmodel_1
engee.load("/user/newmodel_1.engee"; force = true) # принудительно загружает модель с именем newmodel_1 по указанному пути
engee.gcm() # возвращает текущую активную модель
engee.gcs() # возвращает текущую активную систему
engee.get_all_models(; sorted=true) # возвращает список открытых в текущей сессии моделей и сортирует их по имени
engee.is_dirty("newmodel_1") # проверяет есть ли несохраненные изменения, если после исполнения команды выводит true, значит есть несохраненные изменения
engee.open("newmodel_1") # возвращает открытую систему system и делает модель с именем newmodel_1 текущей моделью, может быть задана через путь к модели
engee.save("newmodel_1", "/user/newmodel_2.engee") # сохраняет модель newmodel_1 как модель newmodel_2 по указанному пути
engee.close("newmodel_1") # закрывает модель с именем newmodel_1 (удаляет из сессии)