Пример #1
0
func OnDoorTimeout(hwCh def.HardwareChan) {
	switch Elevator.Behaviour {
	case doorOpen:
		Elevator.Dir = queue.ChooseDirection(Elevator.Floor, Elevator.Dir)
		hwCh.DoorLamp <- false
		hwCh.MotorDir <- Elevator.Dir
		if Elevator.Dir == def.DirStop {
			Elevator.Behaviour = idle
		} else {
			Elevator.Behaviour = moving
		}
	}
}
Пример #2
0
func OnNewRequest(OutgoingMsg chan<- def.Message, hwCh def.HardwareChan) {
	switch Elevator.Behaviour {
	case doorOpen:
		if queue.ShouldStop(Elevator.Floor, Elevator.Dir) {
			hwCh.DoorTimerReset <- true
			queue.RemoveLocalRequestsAt(Elevator.Floor, OutgoingMsg)
		}
	case moving:
		//Do nothing
	case idle:
		Elevator.Dir = queue.ChooseDirection(Elevator.Floor, Elevator.Dir)
		if Elevator.Dir == def.DirStop {
			hwCh.DoorLamp <- true
			hwCh.DoorTimerReset <- true
			queue.RemoveLocalRequestsAt(Elevator.Floor, OutgoingMsg)
			Elevator.Behaviour = doorOpen
		} else {
			hwCh.MotorDir <- Elevator.Dir
			Elevator.Behaviour = moving
		}
	}
}