Beispiel #1
0
func doorTimeout(ch Channels) {
	switch def.LocalElevator.State {
	case def.DOOR_OPEN:
		ch.DoorLight <- false
		def.LocalElevator.Dir = queue.ChooseDir(def.LocalElevator.Floor, def.LocalElevator.Dir)
		ch.MotorDir <- def.LocalElevator.Dir
		if def.LocalElevator.Dir == def.DIR_STOP {
			def.LocalElevator.State = def.IDLE
		} else {
			def.LocalElevator.State = def.MOVING
		}
	default:
	}
}
Beispiel #2
0
func newOrder(ch Channels) {
	switch def.LocalElevator.State {
	case def.MOVING:
		//Do nothing
	case def.IDLE:
		def.LocalElevator.Dir = queue.ChooseDir(def.LocalElevator.Floor, def.LocalElevator.Dir)
		if queue.ShouldStop(def.LocalElevator.Floor, def.LocalElevator.Dir) {
			def.LocalElevator.State = def.DOOR_OPEN
			ch.DoorLight <- true
			ch.DoorTimerReset <- true
			ch.OrderTimerReset <- true
		} else {
			ch.MotorDir <- def.LocalElevator.Dir
			def.LocalElevator.State = def.MOVING
		}
	case def.DOOR_OPEN:
		if queue.ShouldStop(def.LocalElevator.Floor, def.LocalElevator.Dir) {
			ch.DoorTimerReset <- true
		}
	default:
	}
}