Ejemplo n.º 1
0
 /// <summary>
 ///     Opens elevator door
 /// </summary>
 public void Open()
 {
     if (CurrentFloor == TargetFloor)
     {
         SetState(ElevatorStateFactory.CreateOpened(_elevatorStateObservable, LoadUnloadTime));
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 ///     Creates elevator instance
 /// </summary>
 /// <param name="logger">Logger for output debug info</param>
 public Elevator(ILogger <Elevator> logger)
 {
     _logger = logger;
     _elevatorStateObservable  = new Subject <IElevatorState>();
     _elevatorActionObservable = new Subject <ElevatorAction>();
     _elevatorState            = ElevatorStateFactory.CreateNone(_elevatorStateObservable);
     CurrentFloor = TargetFloor = 0;
 }
Ejemplo n.º 3
0
        /// <summary>
        ///     Starts move elevator between floors
        /// </summary>
        /// <param name="targetFloor">Target elevator floor</param>
        public void Move(int targetFloor)
        {
            TargetFloor = targetFloor;
            if (CurrentFloor == TargetFloor)
            {
                return;
            }
            var heightBetweenFloors = Math.Abs(TargetFloor - CurrentFloor) * FloorHeight;
            var moveTime            = heightBetweenFloors / Speed;

            SetState(ElevatorStateFactory.CreateMoved(_elevatorStateObservable, moveTime));
        }
Ejemplo n.º 4
0
 /// <summary>
 ///     Normally we cannot enter the same state two or more times. In this case we break this rule. We force opened state
 ///     again even before already was opened state
 /// </summary>
 public void RefreshOpen()
 {
     SetState(ElevatorStateFactory.CreateOpened(_elevatorStateObservable, LoadUnloadTime), true);
 }