Android Open Source - Sensors2OSC Parameters






From Project

Back to project page Sensors2OSC.

License

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.

Java Source Code

package org.sensors2.osc.sensors;
// w  ww  .j  a  va2s  .  com
import android.content.Context;
import android.content.res.Resources;

import org.sensors2.osc.R;

/**
 * Created by thomas on 05.11.14.
 */
public class Parameters extends org.sensors2.common.sensors.Parameters {
  private final String oscPrefix;
  private final String name;

  public Parameters(int sensorType, Context applicationContext){
    super(sensorType);
    switch (sensorType){
      // 1 int TYPE_ACCELEROMETER A constant describing an accelerometer sensor type.
      case 1:
        this.name = getString(R.string.sensor_accelerometer, applicationContext);
        this.oscPrefix = "accelerometer/";
        break;
      // 2 int TYPE_MAGNETIC_FIELD A constant describing a magnetic field sensor type.
      case 2:
        this.name = getString(R.string.sensor_magnetic_field, applicationContext);
        this.oscPrefix = "magneticfield/";
        break;
      // 3 int TYPE_ORIENTATION This constant was deprecated in API level 8. use SensorManager.getOrientation() instead.
      case 3:
        this.name = getString(R.string.sensor_orientation, applicationContext);
        this.oscPrefix = "orientation/";
        break;
      // 4 int TYPE_GYROSCOPE A constant describing a gyroscope sensor type
      case 4:
        this.name = getString(R.string.sensor_gyroscope, applicationContext);
        this.oscPrefix = "gyroscope/";
        break;
      // 5 int TYPE_LIGHT A constant describing a light sensor type.
      case 5:
        this.name = getString(R.string.sensor_light, applicationContext);
        this.oscPrefix = "light";
        break;
      // 6 int TYPE_PRESSURE A constant describing a pressure sensor type
      case 6:
        this.name = getString(R.string.sensor_pressure, applicationContext);
        this.oscPrefix = "pressure";
        break;
      // 7 int TYPE_TEMPERATURE This constant was deprecated in API level 14. use Sensor.TYPE_AMBIENT_TEMPERATURE instead.
      case 7:
        this.name = getString(R.string.sensor_temperature, applicationContext);
        this.oscPrefix = "temperature";
        break;
      // 8 int TYPE_PROXIMITY A constant describing a proximity sensor type.
      case 8:
        this.name = getString(R.string.sensor_proximity, applicationContext);
        this.oscPrefix = "proximity";
        break;
      // 9 int TYPE_GRAVITY A constant describing a gravity sensor type.
      case 9:
        this.name = getString(R.string.sensor_gravity, applicationContext);
        this.oscPrefix = "gravity/";
        break;
      // 10 int TYPE_LINEAR_ACCELERATION A constant describing a linear acceleration sensor type.
      case 10:
        this.name = getString(R.string.sensor_linear_acceleration, applicationContext);
        this.oscPrefix = "linearacceleration/";
        break;
      // 11 int TYPE_ROTATION_VECTOR A constant describing a rotation vector sensor type.
      case 11:
        this.name = getString(R.string.sensor_rotation_vector, applicationContext);
        this.oscPrefix = "rotationvector/";
        break;
      // 12 int TYPE_RELATIVE_HUMIDITY A constant describing a relative humidity sensor type.
      case 12:
        this.name = getString(R.string.sensor_relative_humidity, applicationContext);
        this.oscPrefix = "relativehumidity";
        break;
      // 13 int TYPE_AMBIENT_TEMPERATURE A constant describing an ambient temperature sensor type
      case 13:
        this.name = getString(R.string.sensor_absolute_humidity, applicationContext);
        this.oscPrefix = "absolutehumidity";
        break;
      // 14 int TYPE_MAGNETIC_FIELD_UNCALIBRATED A constant describing an uncalibrated magnetic field sensor type.
      case 14:
        this.name = getString(R.string.sensor_magnetic_field_uncalibrated, applicationContext);
        this.oscPrefix = "magneticfielduncalibrated/";
        break;
      // 15 int TYPE_GAME_ROTATION_VECTOR A constant describing an uncalibrated rotation vector sensor type.
      case 15:
        this.name = getString(R.string.sensor_game_rotation_vector, applicationContext);
        this.oscPrefix = "gamerotationvector/";
        break;
      // 16 int TYPE_GYROSCOPE_UNCALIBRATED A constant describing an uncalibrated gyroscope sensor type.
      case 16:
        this.name = getString(R.string.sensor_gyroscope_uncalibrated, applicationContext);
        this.oscPrefix = "gyroscopeuncalibrated/";
        break;
      default:
        throw new IllegalArgumentException();
    }
  }

  private String getString(int stringId, Context context) {
    Resources res = context.getResources();
    return res.getString(stringId);
  }

  public String getOscPrefix() {
    return oscPrefix;
  }

  public String getName() {
    return name;
  }
}




Java Source Code List

org.sensors2.osc.ApplicationTest.java
org.sensors2.osc.activities.AboutActivity.java
org.sensors2.osc.activities.SettingsActivity.java
org.sensors2.osc.activities.StartUpActivity.java
org.sensors2.osc.communication.OscCommunication.java
org.sensors2.osc.communication.OscConfiguration.java
org.sensors2.osc.communication.OscDispatcher.java
org.sensors2.osc.communication.SensorConfiguration.java
org.sensors2.osc.fragments.SensorFragment.java
org.sensors2.osc.fragments.SensorGroupFragment.java
org.sensors2.osc.sensors.Parameters.java
org.sensors2.osc.sensors.Settings.java