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

2 ビュー (過去 30 日間)
Weiming
Weiming 2025 年 4 月 18 日
編集済み: Altaïr 2025 年 4 月 22 日
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?

回答 (1 件)

Altaïr
Altaïr 2025 年 4 月 22 日
編集済み: Altaïr 2025 年 4 月 22 日
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.

カテゴリ

Help Center および File ExchangeDiscrete-Event Simulation についてさらに検索

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by