// 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") } } } } } }
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))) }
func ButtonPushed(button Button_type, floor int) int { return int(C.elev_get_button_signal(C.elev_button_type_t(button), C.int(floor))) }
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) }
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 }
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))) }
func GetButtonSignal(button ButtonType, floor int) int { return int(C.elev_get_button_signal(C.elev_button_type_t(button), C.int(floor))) }
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 }