Engee documentation
Notebook

Managing models from the Engee application

This example shows how to send commands to the Engee computing core from an interactive application.

Program execution

Our program will perform a very simple task. If there is a file in the current Engee folder model_1.engee then this model will be opened and executed. A variable should appear in the Variables window simout.

If there is no such model in the current folder, an error report will be displayed in the application window.

The following command allows you to launch the application:

In [ ]:
genie_app = engee.genie.start("$(@__DIR__)/app.jl", log_file="log.txt");
Warning: Rejecting shutdown request
@ EngeeLanguageServer /usr/local/ijulia-core/packages/EngeeLanguageServer/8aXAQ/src/EngeeLanguageServer.jl:125

Open the application in a new window, separate from Engee:

In [ ]:
display("text/html", """<a href="$(string(genie_app.url))" target="_blank" rel="noopener noreferrer">Открыть в отдельном окне</a>""")

If you need to stop the application, for example, to restart or for debugging purposes, uncomment and execute the following code:

In [ ]:
# engee.genie.stop("$(@__DIR__)/app.jl");

The user has at his disposal the following type of control panel:

Description of the application operation

For sending the command to the Engee core, in the file app.jl the following lines answer:

engee.eval("""engee.open("model_1.engee");
engee.run("model_1")""")

Team open opens the model (careful, it may overwrite an already open model), and the command run launches it for execution.

engee_big_green_button.png

Simplified application code

There is a lot of formatting in this application, but if you remove all the markup and positioning of the elements, then we will have a fairly clear template example.:

using Engee, GenieFramework

@app begin
    @out message = ""
    @in press_btn = false
    
    @onbutton press_btn begin
        try
            engee.eval("""engee.open("model_1.engee"); engee.run("model_1")""")
message = "Command executed successfully! The model is running."
        catch e
            message = "Error: $e"
end
    end
end

function ui()
[
h5("Special button for launching the model"),
        h6("model_1.engee"),
        btn("🚀 LAUNCH!", @click(:press_btn)),
        p("{{message}}")
    ]
end

@page("/", ui)

A section of the reactive data model can be distinguished (@app) and interface markup with user interface elements (ui(()).

Conclusion

With proper code design and compliance with the standard syntax for Engee applications, very complex tools can be created on the Engee platform that allow you to create, run models and analyze results.