예제 #1
0
func GetFloorSignal() int {
	if C.io_read_bit(C.SENSOR_FLOOR1) != 0 {
		return 0
	} else if C.io_read_bit(C.SENSOR_FLOOR2) != 0 {
		return 1
	} else if C.io_read_bit(C.SENSOR_FLOOR3) != 0 {
		return 2
	} else if C.io_read_bit(C.SENSOR_FLOOR4) != 0 {
		return 3
	} else {
		return -1
	}
}
예제 #2
0
func createIntButtonListener(ch chan int) {
	//TODO think about fault tolerance here
	var prevStateIntBtn1 int = 0
	var StateIntBtn1 int = 0
	var prevStateIntBtn2 int = 0
	var StateIntBtn2 int = 0
	var prevStateIntBtn3 int = 0
	var StateIntBtn3 int = 0
	var prevStateIntBtn4 int = 0
	var StateIntBtn4 int = 0
	for {
		time.Sleep(time.Millisecond * 10)

		StateIntBtn1 = int(C.io_read_bit(C.FLOOR_COMMAND1))
		if StateIntBtn1 != prevStateIntBtn1 {
			prevStateIntBtn1 = StateIntBtn1
			if StateIntBtn1 == 1 {
				ch <- INT_BTN_1
			}
		}

		StateIntBtn2 = int(C.io_read_bit(C.FLOOR_COMMAND2))
		if StateIntBtn2 != prevStateIntBtn2 {
			prevStateIntBtn2 = StateIntBtn2
			if StateIntBtn2 == 1 {
				ch <- INT_BTN_2
			}
		}

		StateIntBtn3 = int(C.io_read_bit(C.FLOOR_COMMAND3))
		if StateIntBtn3 != prevStateIntBtn3 {
			prevStateIntBtn3 = StateIntBtn3
			if StateIntBtn3 == 1 {
				ch <- INT_BTN_3
			}
		}

		StateIntBtn4 = int(C.io_read_bit(C.FLOOR_COMMAND4))
		if StateIntBtn4 != prevStateIntBtn4 {
			prevStateIntBtn4 = StateIntBtn4
			if StateIntBtn4 == 1 {
				ch <- INT_BTN_4
			}
		}
	}
}
예제 #3
0
func IoReadBit(channel int) bool {
	var i int = int(C.io_read_bit(C.int(channel)))
	if i == 1 {
		return true
	} else {
		return false
	}
}
예제 #4
0
func RunBottomFloor() {
	if GetFloorSignal() != 0 {
		C.io_set_bit(C.MOTORDIR)
		//time.Sleep(time.Second * 1)
		C.io_write_analog(C.MOTOR, 2800)
		for C.io_read_bit(C.SENSOR_FLOOR1) == 0 {
			SetFloorIndicator(GetFloorSignal())
			time.Sleep(time.Millisecond * 200)
		}
		SetFloorIndicator(GetFloorSignal())
		C.io_write_analog(C.MOTOR, 0)
	}
}
예제 #5
0
func ReadButton(button int, floor int) bool {
	if floor < 0 || floor >= N_FLOORS || button < 0 || button > N_BUTTON_TYPES {
		return false
	}

	var BTN_CHANNELS = [N_FLOORS][N_BUTTON_TYPES]int{
		{C.BUTTON_UP1, C.BUTTON_DOWN1, C.BUTTON_COMMAND1},
		{C.BUTTON_UP2, C.BUTTON_DOWN2, C.BUTTON_COMMAND2},
		{C.BUTTON_UP3, C.BUTTON_DOWN3, C.BUTTON_COMMAND3},
		{C.BUTTON_UP4, C.BUTTON_DOWN4, C.BUTTON_COMMAND4}}

	return (int(C.io_read_bit(C.int(BTN_CHANNELS[floor][button]))) != 0)
}
예제 #6
0
파일: io.go 프로젝트: CzarXerxes/Sanntid
func Io_read_bit(channel int) int {
	return int(C.io_read_bit(C.int(channel)))
}
예제 #7
0
파일: io.go 프로젝트: eleneme/sanntid
func ioReadBit(channel int) bool {
	return int(C.io_read_bit(C.int(channel))) != 0
}
예제 #8
0
파일: io.go 프로젝트: pigswillfly/RealTime
func IO_Read_Bit(channel int) int {
	return C.io_read_bit(C.int(channel))
}
예제 #9
0
func IO_Read_Bit(channel int) bool {
	return int(C.io_read_bit(C.int(channel))) != 0
}
예제 #10
0
func createExtButtonListener(ch chan int) {
	var prevStateExtBtn1Up int = 0
	var StateExtBtn1Up int = 0
	var prevStateExtBtn2Up int = 0
	var StateExtBtn2Up int = 0
	var prevStateExtBtn2Down int = 0
	var StateExtBtn2Down int = 0
	var prevStateExtBtn3Up int = 0
	var StateExtBtn3Up int = 0
	var prevStateExtBtn3Down int = 0
	var StateExtBtn3Down int = 0
	var prevStateExtBtn4Down int = 0
	var StateExtBtn4Down int = 0
	for {
		time.Sleep(time.Millisecond * 10)

		StateExtBtn1Up = int(C.io_read_bit(C.FLOOR_UP1))
		if StateExtBtn1Up != prevStateExtBtn1Up {
			prevStateExtBtn1Up = StateExtBtn1Up
			if StateExtBtn1Up == 1 {
				ch <- EXT_BTN_1_UP
			}
		}

		StateExtBtn2Up = int(C.io_read_bit(C.FLOOR_UP2))
		if StateExtBtn2Up != prevStateExtBtn2Up {
			prevStateExtBtn2Up = StateExtBtn2Up
			if StateExtBtn2Up == 1 {
				ch <- EXT_BTN_2_UP
			}
		}

		StateExtBtn2Down = int(C.io_read_bit(C.FLOOR_DOWN2))
		if StateExtBtn2Down != prevStateExtBtn2Down {
			prevStateExtBtn2Down = StateExtBtn2Down
			if StateExtBtn2Down == 1 {
				ch <- EXT_BTN_2_DOWN
			}
		}

		StateExtBtn3Up = int(C.io_read_bit(C.FLOOR_UP3))
		if StateExtBtn3Up != prevStateExtBtn3Up {
			prevStateExtBtn3Up = StateExtBtn3Up
			if StateExtBtn3Up == 1 {
				ch <- EXT_BTN_3_UP
			}
		}

		StateExtBtn3Down = int(C.io_read_bit(C.FLOOR_DOWN3))
		if StateExtBtn3Down != prevStateExtBtn3Down {
			prevStateExtBtn3Down = StateExtBtn3Down
			if StateExtBtn3Down == 1 {
				ch <- EXT_BTN_3_DOWN
			}
		}

		StateExtBtn4Down = int(C.io_read_bit(C.FLOOR_DOWN4))
		if StateExtBtn4Down != prevStateExtBtn4Down {
			prevStateExtBtn4Down = StateExtBtn4Down
			if StateExtBtn4Down == 1 {
				ch <- EXT_BTN_4_DOWN
			}
		}
	}
}
예제 #11
0
func io_readBit(channel int) int {
	n, err := C.io_read_bit(C.int(channel))
	checkError(err)
	return int(n)
}
예제 #12
0
func Io_ReadBit(channel int) bool {
	n, err := C.io_read_bit(C.int(channel))
	checkError(err)
	return citob(n)
}
예제 #13
0
func IoReadBit(channel int) bool {
	return bool(int(C.io_read_bit(C.int(channel))) != 0)
}