Beispiel #1
0
 public IRequest GenerateReq(int nowTicks, List <IElevator> elevs)
 {
     if (!_isInside)
     {
         if (nowTicks == _directionReqTime)
         {
             Console.WriteLine("[Passenger] {0} is pressing, from {1} to {2}, ",
                               _name, _sourceFloor, _targetFloor);
             IRequest req = new PassengerReq(
                 RequestType.DirectionReq, nowTicks, _sourceFloor, this.UpDown);
             RegElevatorStopNotify(elevs);
             return(req);
         }
     }
     return(null);
 }
Beispiel #2
0
        private void EnterElevator(IScheduler scheduler, int tick, IElevator elev)
        {
            SenElevator senElev = elev as SenElevator;

            if (senElev.FreeCapability >= _weight)
            {
                Console.WriteLine("[Passenger] {0} enter elevator {1}, at floor {2}",
                                  _name, elev.ID, _sourceFloor);
                _isInside      = true;
                _targetReqTime = tick;
                _myElev        = elev;
                senElev.SubCapability(_weight);
                PassengerReq req = new PassengerReq(RequestType.DestinationReq, tick, _targetFloor, Direction.No);
                req.SetReqInElevator(senElev);
                scheduler.QueueReq(req);
            }
            else if (senElev.CurrentStatus.DoorCloseOpenTicks < 4) //wait for one tick to try enter again.
            {
                Console.WriteLine("[Passenger] {0} can't get in due to over-weighted, press up/down again", this.Name);
                scheduler.QueueReq(
                    new PassengerReq(RequestType.DirectionReq, tick, this._sourceFloor, this.UpDown));
            }
        }