How can I create an entity with a signal coming from the departures of a server? in simulink

5 ビュー (過去 30 日間)
john
john 2025 年 2 月 5 日
コメント済み: Laurent Royer 2025 年 2 月 19 日
I have an entity server from which I have activated the number of entities departed in statistics. I want from that signal (departed entities) to create a new entity. Any ideas?

回答 (1 件)

MULI
MULI 2025 年 2 月 12 日
Hi @john,
If you need to create a new entity every time an entity leaves the server, you can follow this approach:
Detect When an Entity Departs
  • The number of entities departed signal from the "Entity Server" increases over time (e.g., 0 → 1 → 2 → 3).
  • You can use an "Edge Detection Block" to detect these changes.This will generate a trigger signal whenever an entity departs.
Use That Trigger to Generate a New Entity
  • Add an "Entity Generator" and set it to event-based mode (instead of time-based).
  • Connect the trigger signal (from the "Edge Detection Block") to the "Entity Generator's" event input. Now, a new entity will be created automatically every time an entity departs.
Manage the Flow of New Entities
  • You can also use a "Queue" or another "Entity Server" to control entity timing.
  • To apply custom logic (e.g., setting entity attributes), you can use a "MATLAB Function Block".
Simulink Implementation
  • The "Entity Server" outputs the Number of Entities Departed as a signal, which is processed by the "Edge Detection Block" to detect changes and generate an event trigger. This trigger is converted into a discrete event by the "Triggered Subsystem", which then activates the "Entity Generator" in event-based mode to create a new entity.
  • The newly generated entity can be managed using a "Queue" for timing control, modified using a "MATLAB Function Block" for custom attributes, and finally routed into the system via the "Entity Sink".
You can also refer to these documenation links on how to set up event-based entity generation in Simulink SimEvents:
  1 件のコメント
Laurent Royer
Laurent Royer 2025 年 2 月 19 日
Not sure it's mandatory here, but I'd insert a "Message Send" block between the change detection and the 2nd generator:

サインインしてコメントする。

カテゴリ

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