@Override
 protected void addGenericConfig(JSONObject json, SensorConfig config) throws JSONException {
   Long sleepLength = (Long) config.getParameter(SLEEP_LENGTH);
   if (sleepLength != null) {
     json.put(SLEEP_LENGTH, sleepLength);
     json.put(
         IS_ADAPTIVELY_SENSED,
         (Boolean) config.getParameter(PullSensorConfig.ADAPTIVE_SENSING_ENABLED));
   }
 }
 public static SensorConfig getDefault() {
   SensorConfig sensorConfig = new SensorConfig();
   sensorConfig.setParameter(FORCE_ENABLE_SENSOR, DEFAULT_FORCE_ENABLE);
   sensorConfig.setParameter(
       PullSensorConfig.POST_SENSE_SLEEP_LENGTH_MILLIS, DEFAULT_SLEEP_INTERVAL);
   sensorConfig.setParameter(PullSensorConfig.NUMBER_OF_SENSE_CYCLES, DEFAULT_SAMPLING_CYCLES);
   sensorConfig.setParameter(
       PullSensorConfig.SENSE_WINDOW_LENGTH_PER_CYCLE_MILLIS,
       DEFAULT_SAMPLING_WINDOW_SIZE_PER_CYCLE_MILLIS);
   return sensorConfig;
 }
  protected SensorConfig getGenericConfig(JSONObject json) {
    SensorConfig config = new SensorConfig();
    try {
      Long sleepLength = (Long) json.get(SLEEP_LENGTH);
      config.setParameter(SLEEP_LENGTH, sleepLength);

      Boolean isAdaptivelySensed = (Boolean) json.get(IS_ADAPTIVELY_SENSED);
      config.setParameter(PullSensorConfig.ADAPTIVE_SENSING_ENABLED, isAdaptivelySensed);
    } catch (Exception e) {
    }
    return config;
  }
Example #4
0
 public SensorData getCurrentSensorData(boolean oneOffSensing) throws ESException {
   SensorData sensorData = ((PullSensor) sensor).sense();
   // since this is a one-off query for sensor data, sleep interval
   // is not relevant in this case
   if (sensorData != null) {
     // remove sleep length value for the case of one-off sensing
     if (oneOffSensing) {
       SensorConfig sensorConfig = sensorData.getSensorConfig();
       sensorConfig.removeParameter(PullSensorConfig.POST_SENSE_SLEEP_LENGTH_MILLIS);
     }
   }
   return sensorData;
 }