コード例 #1
0
ファイル: lights.go プロジェクト: slizer6/elevator
func (elevinf *Elevatorinfo) CheckLights() { // Updates lights according to the order_arrays!
	// for {
	for i := 1; i < 4; i++ {
		if elevinf.external_orders[i-1][0] == 1 || elevinf.external_orders[i-1][0] == -1 {
			elevdriver.SetLight(i, 1)
		} else if elevinf.external_orders[i-1][0] == 0 {
			elevdriver.ClearLight(i, 1)
		}
	}
	for i := 2; i < 5; i++ {
		if elevinf.external_orders[i-1][1] == 1 || elevinf.external_orders[i-1][1] == -1 {
			elevdriver.SetLight(i, 2)
		} else if elevinf.external_orders[i-1][1] == 0 {
			elevdriver.ClearLight(i, 2)
		}
	}
	for i := 0; i < 4; i++ {
		if elevinf.internal_orders[i][2] == 1 {
			elevdriver.SetLight(i+1, 0)
		} else if elevinf.internal_orders[i][2] == 0 {
			elevdriver.ClearLight(i+1, 0)
		}
	}
	fmt.Printf("checkedlights\n")
	// time.Sleep(100*time.Millisecond)
	// }
}
コード例 #2
0
ファイル: elevtest.go プロジェクト: slizer6/elevator
func readButtons() {
	var current [FLOORS][3]bool
	for {
		floor, dir := elevdriver.GetButton()
		current[floor-1][dir] = !current[floor-1][dir]
		if current[floor-1][dir] {
			elevdriver.SetLight(floor, dir)
		} else {
			elevdriver.ClearLight(floor, dir)
		}
	}
}
コード例 #3
0
ファイル: lights.go プロジェクト: redbullnerd/elevator2
func (elevinf *Elevatorinfo) CheckLights() { // Updates lights according to the order_arrays!
	for i := 1; i < 4; i++ {
		if elevinf.external_orders[i-1][0] == 1 || elevinf.external_orders[i-1][0] == -1 {
			elevdriver.SetLight(i, 1)
		} else if elevinf.external_orders[i-1][0] == 0 {
			elevdriver.ClearLight(i, 1)
		}
	}
	for i := 2; i < 5; i++ {
		if elevinf.external_orders[i-1][1] == 1 || elevinf.external_orders[i-1][1] == -1 {
			elevdriver.SetLight(i, 2)
		} else if elevinf.external_orders[i-1][1] == 0 {
			elevdriver.ClearLight(i, 2)
		}
	}
	for i := 0; i < 4; i++ {
		if elevinf.internal_orders[i][2] == 1 {
			elevdriver.SetLight(i+1, 0)
		} else if elevinf.internal_orders[i][2] == 0 {
			elevdriver.ClearLight(i+1, 0)
		}
	}
}