Selection Server - Outside/global variables.

I'm using the Selection Server of SimEvents but cannot get it to be applicable for my uses.
The Selection Server uses key arrivals(entity) to match them to passengers inside the queue. After a key has arrived, he looks for a corresponding passenger and destroys the key. My problem is that whenever a key hasn't been matched to a passenger (because there simply is no passenger with that key yet) it still gets destroyed. So when that next passenger arrives there is no key left and he will never leave the queue.
I've thought on 2 solutions,
  • Postpone destroying the key, ill-advised because multiple loops arise.
  • Keep Boolean Array which will be checked when a passenger arrives. If the corresponding key-Boolean is true. The passenger can leave the queue.
This Boolean array I'm referring to would be a global variable, but I have no idea how to incorporate this within an "classdef" environment.

댓글 수: 1

Mo Zhao
Mo Zhao 2016년 6월 21일
In our Selection Server example, the output responses immediately to the key arrivals, while the passengers are stored in the storage. That's why we do not design a life time for the key entity. If you want the keys to live, I think your two solutions are both valid.
1. You can schedule a timer event in the "callEntryImpl" method to replace the destroy event, and in the "callTimerImpl" method you schdule the destroy event. In method "passengerEntryImpl", you also need to schedule an iterate event to loop though storage 2 to compare the input passenger with previous keys. Don't forget to change the size of storage 2.
2. You can also choose to cache the keys in an array as a private property of the system object, instead of directly using the "call" entities in storage 2 for comparison. You can refer to http://www.mathworks.com/help/matlab/matlab_oop/defining-properties.html for the peroperty definition. In the "passengerEntryImpl" method, you can use "obj.<property_name>" to access it.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Discrete-Event Simulation에 대해 자세히 알아보기

제품

질문:

2016년 5월 19일

댓글:

2016년 6월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by