public static void main(String[] args) throws InterruptedException { PropertyConfigurator.configure( testArduinoBridge.class.getResourceAsStream("/config/log4j.properties")); ultroTest test = new ultroTest(); SensorUltrasonic sensorUltrasonic = new SensorUltrasonic(); String serialName = SystemProperty.getProperty("ArduinoBridge.serialComName"); int serialRate = Integer.parseInt(SystemProperty.getProperty("ArduinoBridge.serialComRate")); ArduinoBridge arduinoBridge = new ArduinoBridgeImpl(serialName, serialRate); arduinoBridge.registerMessageListener(SensorEvent.SENSOR_ULTRASONIC_TYPE, sensorUltrasonic); sensorUltrasonic.addSenserListener(test); while (true) {} }
public testArduinoBridge() { arduinoBridge.registerMessageListener( ArduinoBridge.HALL_MSG_TYPE, new SensorListener() { @Override public void SensorEventProcess(SensorEvent e) { logger.info("Receive msg from serial : type hall"); } }); }