how to control entities in the queue

2 vues (au cours des 30 derniers jours)
Muhammad Asad Hanif
Muhammad Asad Hanif le 31 Juil 2016
Réponse apportée : Shreshth le 28 Août 2024
I want to control the entities in the queue block. For example I have two entities in queue block and connected server has the capacity of 1 followed by another server with the capacity 1. Now I want that second entity only leaves the queue when 1st entity leaves the second server.
I think, this is control by writing code in "exit", of "event actions" in queue block.
  1 commentaire
Natasa
Natasa le 15 Déc 2017
Modifié(e) : Natasa le 15 Déc 2017
Hallo! Did you solve this problem?

Connectez-vous pour commenter.

Réponses (1)

Shreshth
Shreshth le 28 Août 2024
Hey Asad,
To control entity departure in a Simulink Queue block:
  1. Open the Queue Block: Double-click the Queue block in your model.
  2. Access Event Actions: Go to the "Event Actions" tab.
  3. Modify "Exit" Event:
  • Write MATLAB code to control entity departure.
  • Use a persistent flag to track if the first entity has left the second server.
Example code:
persistent firstEntityProcessed;
if isempty(firstEntityProcessed)
firstEntityProcessed = false;
end
if firstEntityProcessed
% Allow second entity to leave
else
% Hold second entity in queue
end
% Update `firstEntityProcessed` when the first entity leaves the second server
4. Set Up State Update: Ensure firstEntityProcessed is updated when the first entity exits the second server.
5.Test: Run the simulation to verify behavior.
Hope it helps.

Catégories

En savoir plus sur Messages dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by