Engee documentation
Notebook

Comparison of subsystems to be included

This example shows two identical subsystems, with differences in the settings of the received control signal, in the first case the signal starts the model, in the second case it resets its execution.

The figure below shows the model itself.

image.png

Next, let's connect the auxiliary function to run the model.

In [ ]:
function run_model( name_model)
    
    Path = (@__DIR__) * "/" * name_model * ".engee"
    
    if name_model in [m.name for m in engee.get_all_models()] # Проверка условия загрузки модели в ядро
        model = engee.open( name_model ) # Открыть модель
        model_output = engee.run( model, verbose=true ); # Запустить модель
    else
        model = engee.load( Path, force=true ) # Загрузить модель
        model_output = engee.run( model, verbose=true ); # Запустить модель
        engee.close( name_model, force=true ); # Закрыть модель
    end
    sleep(5)
    return model_output
end
Out[0]:
run_model (generic function with 1 method)

Let's run the model.

In [ ]:
run_model("CompareEnabled") # Запуск модели.
Building...
Progress 100%
Out[0]:
Dict{String, DataFrames.DataFrame} with 3 entries:
  "state_and_output_held.Out1"  => 1001×2 DataFrame…
  "state_and_output_reset.Out1" => 1001×2 DataFrame…
  "Sine Wave.1"                 => 1001×2 DataFrame

Unpack and display the signals recorded from the model.

In [ ]:
held = simout["CompareEnabled/state_and_output_held.Out1"];
reset = simout["CompareEnabled/state_and_output_reset.Out1"];
Sine = simout["CompareEnabled/Sine Wave.1"];

held = collect(held);
reset = collect(reset);
Sine = collect(Sine);

plot(held.time, held.value)
plot!(reset.time, reset.value)
plot!(Sine.time, Sine.value)
Out[0]:

Conclusion

As we can see from the resulting graph, the system with reset goes to the initial state of the integrator at the moment of transition to the positive region of the control signal, while the system without reset continues counting from the last counted value inside the integrator.

Blocks used in example