MATLAB Answers

I am working on queueing using Simulink Sim Events, and I need help on adding an attribute to the events.

9 views (last 30 days)
I want my events to have the time they were generated at the entity generator and the time their servicing was completed at the server as timestamps, so that I can calculate the difference between the two values. I started with SIMULINK as I found examples provided, and am open to other ways on implementing it

  0 Comments

Sign in to comment.

Accepted Answer

Krishna Akella
Krishna Akella on 24 Jun 2019
Hi Biplav,
Have you tried using SimEvents blocks for this? With simEvents you can use an 'Entity Generator' block and a 'Entity Server' block to model your queueing system. You can add two attributes to the entity via the 'Entity Type' tab page in the 'Entity Generator' block and call them 'entryTime' and 'ExitTime' or something like that. You can add timeStamps by getting the current time and setting the appropriate attribute in the entity to the current time. For example, see inside the 'Design Patterns' in SimEvents for 'Time stamp entities upon generation'. You can use this pattern to time stamp entities in the geenrator. Similarly you can timestamp entities in the entity server's 'Service Complete' event action:
entity.ExitTime = stampEntity();
Then you can find the difference from these two values.
Hope that helps!
Regards,
Krishna

  1 Comment

BIPLAV CHOUDHURY
BIPLAV CHOUDHURY on 24 Jun 2019
Thanks Krishna, I was able to generate the entity generation and server arrival times (they are the same values technically). However, I am facing an issue with the generation of the service completion times: I have set the service completion time attribute to be set using the service completion Event Action in the server, but it seems it is never called and the service completion time is always at the initial value.
Another issue is that the time values shown by the diagnostics window and the values saved by the simout command are not matching: is there any time synchrnization that needs to be set initially?

Sign in to comment.

More Answers (2)

Krishna Akella
Krishna Akella on 27 Jun 2019
That sounds strange. The service completion action must be called when the server is finished serving an entity.
There should be no need to set any kind of synchronization with respect to time.
Is it possible for your to share your model? At least a scaled down model where the problem can be reproduced? That might help me in understanding the issue better.
Regards,
Krishna

  0 Comments

Sign in to comment.


BIPLAV CHOUDHURY
BIPLAV CHOUDHURY on 27 Jun 2019
Edited: BIPLAV CHOUDHURY on 27 Jun 2019
I have attached the file. I am describing the problem so that you can locate the problem:
a. After running the file, a total of 15 events are generated and the diagnostics window shows the generation times to be 0, 2.04, 3.0385.......... etc. But with simout,
simout.gen_time.time
gives the generation times as 1.0245, 2.5438, 13.3569..... and so on. Thus there is a mismatch between the times, even when we are looking at the same variable in the same run of the program.
b. I am using the
[entity.serv_comp] = stampEntity();
command in the service complete tab in the Event Actions options with the initial value set to 0, and it seems like this event is never called and it stays at 0 during the whole run.

  0 Comments

Sign in to comment.

Products


Release

R2018b

Translated by