Exemplo n.º 1
0
//ClearOrderLocal is called by the local elevator, and clears both internal and external orders. Calls ClearOrder.
func ClearOrderLocal(floor driver.Floor, dir driver.Direction) {
	// Turn off inside too
	shouldStop[driver.DirectionNone][floor] = false
	driver.ButtonLightOff(floor, driver.DirectionNone)
	dir = currentDir
	RemoveFromLog(int(floor))
	ClearOrder(floor, dir)
}
Exemplo n.º 2
0
// ClearOrder means an order is completed (either remotely or locally). Does not clear internal orders, but is called by ClearOrderLocal.
func ClearOrder(floor driver.Floor, dir driver.Direction) {
	if floor == 0 {
		dir = driver.DirectionDown
	} else if floor == driver.NumFloors-1 {
		dir = driver.DirectionUp
	}
	shouldStop[dir][floor] = false
	driver.ButtonLightOff(floor, dir)

	// Clear from pendingOrders
	for o := pendingOrders.Front(); o != nil; o = o.Next() {
		v := o.Value.(*order)
		if v.floor == floor && v.dir == dir {
			v.timer.Stop()
			pendingOrders.Remove(o)
			break
		}
	}
}