![ReadValFromGenerator.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/226057/ReadValFromGenerator.png)
SimEvents: Is it possible to generate an event-based entity with specific attribute values defined in the caller block's event action?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Abdolkarim Mohammadi
il 22 Mag 2019
Commentato: Abdolkarim Mohammadi
il 24 Giu 2019
![](https://uk.mathworks.com/help/simevents/ug/simple_eventbased.png)
The Entity Terminator block calls the simulink function genNext to generate an entity. I want to know that is possible to add input argument blocks to genNext so that we can call it like genNext(1,2,3) and have the entity generator set the attributes of the generated entity according to the passed inputs?
0 Commenti
Risposta accettata
Krishna Akella
il 24 Giu 2019
Hi Kar,
Unfortunately, the entity generator's 'Generate' event action cannot use the values from the generation triggering entity. I have however been able to use Simulink Functions to create getter and setter functions to write and read values from the event actions:
![ReadValFromGenerator.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/226057/ReadValFromGenerator.png)
I have called setVal(1, 2, 3) from the terminator's entry action and then called [v1, v2, v3] = getVal() from the entity generators 'generate' event action to read the values. However, this has some pit falls. If another entity arrives at the terminator with a higher priority than the generate event, then the values in the simulink function get overwritten. I haven't been able to figure out a better way. Hope this helps!
Regards,
Krishna
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Discrete-Event Simulation in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!