Back to project page Sensors2OSC.
The source code is released under:
Author: Thomas Mayer <thomas@residuum.org> Antonio Deusany de Carvalho Junior Copyright (c) 2014 Thomas Mayer, Antonio Deusany de Carvalho Junior Permission is hereby granted, free of charge, to any...
If you think the Android project Sensors2OSC listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.sensors2.osc.communication; /* w w w . j a v a 2 s. c o m*/ import org.sensors2.common.sensors.DataDispatcher; import org.sensors2.common.sensors.Measurement; import java.util.ArrayList; import java.util.List; /** * Created by thomas on 07.11.14. */ public class OscDispatcher implements DataDispatcher { private List<SensorConfiguration> sensorConfigurations; public OscDispatcher() { this.sensorConfigurations = new ArrayList<SensorConfiguration>(); } public void addSensorConfiguration(SensorConfiguration sensorConfiguration) { this.sensorConfigurations.add(sensorConfiguration); } @Override public void dispatch(Measurement sensorData) { int length = sensorData.getValues().length; for (int i = 0; i < length; i++) { for (SensorConfiguration sensorConfiguration : this.sensorConfigurations) { if (sensorConfiguration.getIndex() == i && sensorConfiguration.getSensorType() == sensorData.getSensorType()) { this.trySend(sensorConfiguration, sensorData.getValues()[i]); } } } } private void trySend(SensorConfiguration sensorConfiguration, float value) { if (!sensorConfiguration.sendingNeeded(value)) { return; } new OscCommunication(OscConfiguration.getInstance()).execute(sensorConfiguration.getOscParam(), Float.toString(value)); } }