Trying to make priority queue with two parallel FIFO queues.

조회 수: 4 (최근 30일)
Muhammad Ashar
Muhammad Ashar 2023년 8월 8일
편집: Ninad 2023년 8월 23일
I'm trying to modify a Simulink example. I'm using example openExample('simevents/QueuingStrategiesExample'). Instead of 4 queues, I'm going with 2 eliminating the other 2. The model I have in mind is that the data/signal will go from the shortest path (queue) but after alterting the example the signal is only going through one queue. I have to build up it further but somehow I can't find a way for the signal to read the other queue or in other words if one queue is completely empty (which is the case right now) the discrete signal should diverted to the empty queue therefore minimizing the time to reach to point B. Any insights to sort out this issue will be really appreciated. Thanksks

답변 (1개)

Ninad
Ninad 2023년 8월 23일
편집: Ninad 2023년 8월 23일
I tried to reproduce the issue on my end, by opening the model and making the necessary changes to the model. Please try the following steps, because it seems to work for ne:
Step 1: To open the model run the following command in MATLAB command line: openExample('simevents/QueuingStrategiesExample')
Step 2: open the function block: seQueuingStrategies > Four Line Queue > Queue Selector > MATLAB Function
Step 3: Replace the code in the MATLAB function block (fcn) with the following code:
function y = fcn(u1, u2)
%#codegen
% Identify which input index is the smallest
[~,y] = min([u1 u2]);
Step 4: Change the Queue Selector Sub-system by removing the excess input signals.
Step 5: Open the Four Line Queue Sub-system make the following changes:
Open > Line Router and set the Number of output ports = 2
Open > Exit Path 1 and set the Number of input ports = 2
Delete > Customer Line 3 and Customer Line 4 and all the excess connections
To verify:
Add two scope blocks connecting to the Number of entities in block, n for Customer Line 1 and 2 respectively.
On running the model, you can visualize the two scope blocks and see that both the queues are receiving inputs.

카테고리

Help CenterFile Exchange에서 Signal Attributes and Indexing에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by