Executable State Machine Simulation mit Java Script

The Executable Model Simulation in EA is a powerful tool. In contrast to interpreted model simulation, executable model simulation generates code, which is then executed. The currently executed behavior is then visualized in the EA.

During simulation, events (triggers) can be “fired” manually or directly from the simulation. The following syntax is currently supported.

%BROADCAST_EVENT("<TRIGGER_NAME>.<SIGNAL_NAME>(<PAEAMETE_WERT_1>, … <PAEAMETE_WERT_n>,  )")%;

Concrete example:

%BROADCAST_EVENT("T_MyTrigger.Sig_MySig(5)")%;

The transferred values can now be accessed in the Guard Condition during the transition. For JavaScript, this is done as follows:

event.signal.attX == 5

If the executable simulation is executed with other programming languages, the query in the Guard Condition must be adapted accordingly. For C#, for example, this can look like this:

((Sig_MyX)_event.signal) != null && ((Sig_MyX)_event.signal).att1 == 5

Basically the same logic: EVENT.SIGNAL.<ATTRIBUT_WERT>

The above code ensures that no exceptions occur.

Here is the representation of the whole example as Executable JavaScript Simulation.

 

Posted in Best Practices, Model Simulation
Tags: ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*

code