/* This function sets the value of the stop lamp. */ func setStopLamp(value bool) { if value { driver.IOSetBit(LIGHT_STOP) } else { driver.IOClearBit(LIGHT_STOP) } }
/* This function sets the value of the door lamp */ func setDoorLamp(value bool) { if value { driver.IOSetBit(LIGHT_DOOR_OPEN) } else { driver.IOClearBit(LIGHT_DOOR_OPEN) } }
/* This function sets the indicator at a given floor. */ func setFloorIndicator(floor int) { // Binary encoding, one light is always on 00, 01, 10 or 11 if floor >= typedef.N_FLOORS || floor < 0 { log.Println("HARDWARE:\t Tried to set indicator on invalid floor.") // todo set floor to nearest valid floor. } if bool((floor & 0x02) != 0) { driver.IOSetBit(LIGHT_FLOOR_IND1) } else { driver.IOClearBit(LIGHT_FLOOR_IND1) } if bool((floor & 0x01) != 0) { driver.IOSetBit(LIGHT_FLOOR_IND2) } else { driver.IOClearBit(LIGHT_FLOOR_IND2) } }
/* This function/channel (called from another goroutine) sets the light of a specific type at the given floor to the specified value. */ func setButtonLight(floor, buttonType int, value bool) error { // TODO -> Some acceptance test for the arguments.. if value { driver.IOSetBit(lightChannelMatrix[floor][buttonType]) } else { driver.IOClearBit(lightChannelMatrix[floor][buttonType]) } return nil }
/* This function/channel(called from another goroutine) sets the direction of the motor(any other direction than 0/STOP means it will run in this direction immediately). */ func setMotorDirection(direction int) error { fmt.Printf("HARDWARE:\t Setting motor direction: %d\n", direction) if direction == 0 { driver.IOWriteAnalog(MOTOR, 0) } else if direction > 0 { driver.IOClearBit(MOTORDIR) driver.IOWriteAnalog(MOTOR, motorspeed) } else if direction < 0 { driver.IOSetBit(MOTORDIR) driver.IOWriteAnalog(MOTOR, motorspeed) } // TODO -> Do some acceptance test to see if the direction was set. // return some error.New().. // If acceptance test completes. return nil }