Exemple #1
0
// FloorButtonListener should be spawned as a goroutine
func FloorButtonListener(ch chan<- ButtonEvent) {
	var floorButtonState [3][NumFloors]bool

	for {
		for direction := DirectionUp; direction <= DirectionNone; direction++ {
			for floor := Floor(0); floor < NumFloors; floor++ {
				mutex.Lock()
				newState := C.elev_get_button_signal(C.elev_button_type_t(direction), C.int(floor)) != 0
				mutex.Unlock()
				if newState != floorButtonState[direction][floor] {
					floorButtonState[direction][floor] = newState

					// Only dispatch an event if it's pressed
					if newState {
						log.Debug("Button type ", direction, " floor ", floor, " pressed")
						ch <- ButtonEvent{Dir: direction, Floor: floor}
					} else {
						log.Bullshit("Button type ", direction, " floor ", floor, " released")
					}
				}
			}
		}
	}
}
Exemple #2
0
func Elev_get_button_signal(button Elev_button_type_t, floor int) int {
	return int(C.elev_get_button_signal(C.elev_button_type_t(button), C.int(floor)))
}
Exemple #3
0
func ButtonPushed(button Button_type, floor int) int {
	return int(C.elev_get_button_signal(C.elev_button_type_t(button), C.int(floor)))
}
Exemple #4
0
func Elevator_is_button_pushed(button Button, floor int) bool {
	return (C.elev_get_button_signal(C.elev_button_type_t(button), C.int(floor)) != 0)
}
Exemple #5
0
func liftDriver_GetButtonSignal(button int, floor int) bool {
	return int(C.elev_get_button_signal(C.elev_button_type(button)))
}
func LiftDriver_GetButtonSignal(button types.ButtonType, floor int) bool {
	return int(C.elev_get_button_signal(C.elev_button_type_t(C.int(button)), C.int(floor))) != 0
}
Exemple #7
0
func ElevGetButtonSignal(buttonType int, floor int) int {
	return int(C.elev_get_button_signal(C.elev_button_type_t(C.int(buttonType)), C.int(floor)))
}
Exemple #8
0
func GetButtonSignal(button ButtonType, floor int) int {
	return int(C.elev_get_button_signal(C.elev_button_type_t(button), C.int(floor)))
}
Exemple #9
0
func Elev_get_button_signal(button int, floor int) bool {
	return int(C.elev_get_button_signal(C.elev_button_type_t(button), C.int(floor))) != 0
}