コード例 #1
0
ファイル: fsm.go プロジェクト: larstokle/SanntidsHeis
func motorError() {
	driver.RunStop()
	fmt.Printf("\n\n================== ERROR, ELEVATOR MOTOR NOT WORKING PROPERLY ==========\n\n")
	if floor := driver.GetFloorSignal(); floor != -1 {
		fmt.Printf("Elevator at floor %d, door opened\n", floor)
	}
	fmt.Printf("took %d seconds to reach new floor when running, try fixing the problem and restart\n", MOTOR_ERROR_SEC)
	fmt.Printf("Program exiting now!\n")
	fmt.Printf("\n===============================================================================\n\n\n")
	os.Exit(1)
}
コード例 #2
0
ファイル: eventmgr.go プロジェクト: larstokle/SanntidsHeis
func CheckFloorSignal() <-chan int {
	event := make(chan int)
	lastFloorState := -1
	fmt.Println("eventmgr: CheckFloorSignal started\n")
	go func() {
		for {
			newFloorState := driver.GetFloorSignal()
			if newFloorState != lastFloorState {
				lastFloorState = newFloorState
				if newFloorState != -1 {
					if DEBUG_CHANNELS {
						fmt.Println("eventMgr: newFloorState %d ", newFloorState)
					}
					event <- newFloorState
				}
			}
			time.Sleep(time.Millisecond * 20)
		}
	}()
	return event
}