public void Initialize()
        {
            int _totalBusStops = TotalNumberOfBusStops;
            int _busNumber     = 1;

            for (int _nIndex = 1; _nIndex <= _totalBusStops; _nIndex++)
            {
                int _currentPassangersAtStop = 0;
                if (_dicNumberOfPersonsByStopNumber.Keys.Contains(_nIndex))
                {
                    _dicNumberOfPersonsByStopNumber.TryGetValue(_nIndex, out _currentPassangersAtStop);
                }

                if ((_nIndex % 3).Equals(0))
                {
                    //Bus arrival event
                    BusArrivalEvent _busArrivalEvent = new BusArrivalEvent()
                    {
                        NumberofPersonInQueueAtStop = _currentPassangersAtStop,
                        BusNumber = _busNumber,
                        ClockTime = _nIndex
                    };

                    _busArrivalEvent = _busArrivalEvent.CreateEvent(_nIndex) as BusArrivalEvent;

                    AddToQueue(_busArrivalEvent);

                    BoardingEvent _boardingEvent = new BoardingEvent()
                    {
                        NumberofPersonInQueueAtStop = _currentPassangersAtStop,
                        BusNumber       = _busNumber,
                        TimeofExecution = _busArrivalEvent.TimeofExecution
                    };

                    _boardingEvent = _boardingEvent.CreateEvent(_nIndex) as BoardingEvent;

                    AddToQueue(_boardingEvent);
                    _busNumber += 1;
                }
                //Person Arrival event.
                PersonArrivalEvent _personArrival = new PersonArrivalEvent()
                {
                    NumberofPersonInQueueAtStop = _currentPassangersAtStop,
                    ClockTime = _nIndex
                };
                _personArrival = _personArrival.CreateEvent(_nIndex) as PersonArrivalEvent;
                AddToQueue(_personArrival);
                _dicNumberOfPersonsByStopNumber.Add(_nIndex, _personArrival.NumberofPersonInQueueAtStop);
            }
        }
Beispiel #2
0
        public void Initialize()
        {
            int _totalBusStops = _busTerminalConfiguration.TotalNumberofBusStops;
            int _busNumber     = 1;

            for (int _nIndex = 1; _nIndex <= _totalBusStops; _nIndex++)
            {
                _lblPassengerCount = Controls.Find(string.Format("lblPassengerCount{0}", _nIndex), true).FirstOrDefault() as Label;
                int _currentPassangersAtStop = 0;
                int.TryParse(_lblPassengerCount.Text, out _currentPassangersAtStop);

                if ((_nIndex % 3).Equals(0))
                {
                    //Bus arrival event
                    BusArrivalEvent _busArrivalEvent = new BusArrivalEvent()
                    {
                        NumberofPersonInQueueAtStop = _currentPassangersAtStop,
                        BusNumber = _busNumber,
                        ClockTime = _nIndex
                    };

                    _busArrivalEvent = _busArrivalEvent.CreateEvent(_nIndex) as BusArrivalEvent;

                    AddToQueue(_busArrivalEvent);

                    BoardingEvent _boardingEvent = new BoardingEvent()
                    {
                        NumberofPersonInQueueAtStop = _currentPassangersAtStop,
                        BusNumber       = _busNumber,
                        TimeofExecution = _busArrivalEvent.TimeofExecution
                    };

                    _boardingEvent = _boardingEvent.CreateEvent(_nIndex) as BoardingEvent;

                    AddToQueue(_boardingEvent);
                    _busNumber += 1;
                }
                //Person Arrival event.
                PersonArrivalEvent _personArrival = new PersonArrivalEvent()
                {
                    NumberofPersonInQueueAtStop = _currentPassangersAtStop,
                    ClockTime = _nIndex
                };
                _personArrival = _personArrival.CreateEvent(_nIndex) as PersonArrivalEvent;
                AddToQueue(_personArrival);
                _lblPassengerCount.Text = _personArrival.NumberofPersonInQueueAtStop.ToString();
            }
            _ntotalBuses = _busNumber;
        }