How to get Number of entities in block in Event action?

2 views (last 30 days)
I am trying to change the service time based on the length of the queue in real time, How can I do that?
In the attached figure, I tried to get the length by using statistics.n but it didn't work. Is there any way I can send the real-time queue length to entity server?

Answers (1)

Altaïr
Altaïr on 22 Apr 2025
Edited: Altaïr on 22 Apr 2025
It appears that accessing statistic variables directly from within the Events Actions tab is not explicitly documented. The most relevant information available pertains to the parameters accessible inside event actions, as described in the following documentation page:
It seems like accessing statistic variables directly from within the Events Actions tab is not possible. One possible workaround is to write the statistic data to a variable in either the base or model workspace, which can then be accessed within the event action. However, this method may introduce a slight delay between writing and reading the statistical value. A more effective method, which avoids any noticeable delay, involves using a Simulink Function that simply passes the statistical variable from its input to its output. For example:
Model:
Simulink Function:
This Simulink function can be invoked within the event action to access the statistical value. By comparing the values shown in the Diagnostic Viewer from the Event Action section with the actual values of the statistical variable in the Data Inspector, it can be confirmed that there is no delay. I've attached the model for your reference.

Categories

Find more on Discrete-Event Simulation in Help Center and File Exchange

Products


Release

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!