Exemple #1
0
func Elevator_set_button_lamp(button Button, floor int, value bool) {
	val := 0
	if value {
		val = 1
	}
	C.elev_set_button_lamp(C.elev_button_type_t(button), C.int(floor), C.int(val))
}
Exemple #2
0
// ButtonLightOff turns it off
func ButtonLightOff(floor Floor, dir Direction) {
	if floor == 0 && dir == DirectionDown {
		dir = DirectionUp
	} else if floor == NumFloors-1 && dir == DirectionUp {
		dir = DirectionDown
	}
	mutex.Lock()
	C.elev_set_button_lamp(C.elev_button_type_t(dir), C.int(floor), 0)
	mutex.Unlock()
}
Exemple #3
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 #4
0
func Elev_set_button_lamp(button Elev_button_type_t, floor int, value int) {
	C.elev_set_button_lamp(C.elev_button_type_t(button), C.int(floor), C.int(value))
}
Exemple #5
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 #6
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 #7
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)
}
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 #9
0
func liftDriver_SetButtonLamp(button int, floor int, onOrOff bool) {
	C.elev_set_button_lamp(C.elev_button_type_t(button), C.int(floor), C.int(onOrOff))
}
func LiftDriver_SetButtonLamp(button types.ButtonType, floor int, onOrOff int) {
	C.elev_set_button_lamp(C.elev_button_type_t(C.int(button)), C.int(floor), C.int(onOrOff))
}
Exemple #11
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 #12
0
func SetButtonLamp(button ButtonType, floor, value int) {
	C.elev_set_button_lamp(C.elev_button_type_t(button), C.int(floor), C.int(value))
}
Exemple #13
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 #14
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
}