Пример #1
0
func (elevinf *Elevatorinfo) ReceiveOrders() {
	// for {
	floorbutton, directionbutton := elevdriver.GetButton()

	if elevinf.state != EMERGENCY || (elevinf.state == EMERGENCY || elevinf.event == ORDER) {
		for i := 1; i < 4; i++ { // First column of the order slice refers to UP buttons
			if i == floorbutton && directionbutton == 1 {
				//elevinf.internal_orders[i-1][0] = 1
				elevinf.external_orders[i-1][0] = 1
			}
		}
		for i := 2; i < 5; i++ { // Second column of the order slice refers to DOWN buttons
			if i == floorbutton && directionbutton == 2 {
				//elevinf.internal_orders[i-1][1] = 1
				elevinf.external_orders[i-1][1] = 1
			}
		}
	}
	for i := 1; i < 5; i++ { // Third column of the order slice refers to COMMAND buttons
		if i == floorbutton && directionbutton == 0 {
			elevinf.internal_orders[i-1][2] = 1
		}
	}
	// Clearing the unused spaces
	elevinf.internal_orders[3][0] = 0
	elevinf.internal_orders[0][1] = 0
	elevinf.external_orders[3][0] = 0
	elevinf.external_orders[0][1] = 0

	floorbutton = 0
	directionbutton = 0
	fmt.Printf("recievedorder\n")
	// time.Sleep(1*time.Millisecond)
	// }
}
Пример #2
0
func (elevinf *Elevatorinfo) ReceiveOrders() {

	floorbutton, directionbutton := elevdriver.GetButton()

	// Skal ideelt sett fjerne denne if'en, andre kan ta seg av eksterne ordre...
	// if elevinf.state != EMERGENCY || (elevinf.state == EMERGENCY || elevinf.event == ORDER) {
	for i := 1; i < 4; i++ { // First column of the order slice refers to UP buttons
		if i == floorbutton && directionbutton == 1 {
			fmt.Printf("Someone wants up...\n")
			elevinf.external_orders[i-1][0] = 1
		}
	}
	for i := 2; i < 5; i++ { // Second column of the order slice refers to DOWN buttons
		if i == floorbutton && directionbutton == 2 {
			fmt.Printf("Someone wants down...\n")
			elevinf.external_orders[i-1][1] = 1
		}
	}
	// }
	for i := 1; i < 5; i++ { // Third column of the order slice refers to COMMAND buttons
		if i == floorbutton && directionbutton == 0 {
			elevinf.internal_orders[i-1][2] = 1
		}
	}
	// Clearing the unused spaces
	elevinf.internal_orders[3][0] = 0
	elevinf.internal_orders[0][1] = 0
	elevinf.external_orders[3][0] = 0
	elevinf.external_orders[0][1] = 0

}
Пример #3
0
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)
		}
	}
}