Esempio n. 1
0
 public void AddTargetFloorRequst(ITargetFloorRequest request)
 {
     request.AddToDictionary();
     if (request.GetFloorNumber() == ElevatorController.instance.CurrentFloor)
     {
         ElevatorController.instance.RemoveCompleteFloor(ElevatorController.instance.CurrentFloor);
         ElevatorController.instance.ChangeState(new DoorsOpen());
         ElevatorController.instance.OpenTheDoor();
     }
     else if (request.GetFloorNumber() > ElevatorController.instance.CurrentFloor)
     {
         ElevatorController.instance.ChangeState(new ToUp());
         ElevatorController.instance.targetFloorNumber = request.GetFloorNumber();
         ElevatorController.instance.AddTargetFloorNumberRequest(request.GetFloorNumber());
         ElevatorController.instance.currentDirection = ElevatorController.DIRECTION_UP;
         ElevatorController.instance.StartMoving();
     }
     else if (request.GetFloorNumber() < ElevatorController.instance.CurrentFloor)
     {
         ElevatorController.instance.ChangeState(new ToDown());
         ElevatorController.instance.targetFloorNumber = request.GetFloorNumber();
         ElevatorController.instance.AddTargetFloorNumberRequest(request.GetFloorNumber());
         ElevatorController.instance.currentDirection = ElevatorController.DIRECTION_DOWN;
         ElevatorController.instance.StartMoving();
     }
 }
Esempio n. 2
0
    public void AddTargetFloorRequst(ITargetFloorRequest request)
    {
        request.AddToDictionary();
        ElevatorController.instance.AddTargetFloorNumberRequest(request.GetFloorNumber());
        if (request.GetFloorNumber() == ElevatorController.instance.CurrentFloor)
        {
            ElevatorController.instance.targetFloorNumber = request.GetFloorNumber();
            if (ElevatorController.instance.Interfloor < (float)ElevatorController.instance.CurrentFloor)
            {
                ElevatorController.instance.currentDirection = ElevatorController.DIRECTION_UP;
                ElevatorController.instance.ChangeState(new ToUp());
            }
            else
            {
                ElevatorController.instance.currentDirection = ElevatorController.DIRECTION_DOWN;
                ElevatorController.instance.ChangeState(new ToDown());
            }
            ElevatorController.instance.StartMoving();
        }
        else
        {
            int  nextTarget     = ElevatorController.instance.GetNextTarget(ElevatorController.instance.CurrentFloor);
            bool targetNotFound = false;

            if (nextTarget == -1)
            {
                ElevatorController.instance.SwitchDirection();
                nextTarget = ElevatorController.instance.GetNextTarget(ElevatorController.instance.CurrentFloor);
                if (nextTarget == -1)
                {
                    targetNotFound = true;
                    ElevatorController.instance.currentState = new WaitOnFloor();
                }
            }

            if (!targetNotFound)
            {
                if (ElevatorController.instance.currentDirection == ElevatorController.DIRECTION_UP)
                {
                    ElevatorController.instance.ChangeState(new ToUp());
                }
                else
                {
                    ElevatorController.instance.ChangeState(new ToDown());
                }

                ElevatorController.instance.targetFloorNumber = nextTarget;
                ElevatorController.instance.StartMoving();
            }
        }
    }
Esempio n. 3
0
 public void AddTargetFloorRequst(ITargetFloorRequest request)
 {
     request.AddToDictionary();
     if (request.GetFloorNumber() == ElevatorController.instance.CurrentFloor)
     {
         ElevatorController.instance.RemoveCompleteFloor(ElevatorController.instance.CurrentFloor);
     }
     else
     {
         ElevatorController.instance.AddTargetFloorNumberRequest(request.GetFloorNumber());
         if (request.ItClosesTheDoors())
         {
             ElevatorController.instance.CloseTheDoor();
         }
     }
 }
Esempio n. 4
0
 public void AddTargetFloorRequst(ITargetFloorRequest request)
 {
     request.AddToDictionary();
     ElevatorController.instance.AddTargetFloorNumberRequest(request.GetFloorNumber());
     ElevatorController.instance.targetFloorNumber = ElevatorController.instance.GetNextTarget(ElevatorController.instance.CurrentFloor);
 }