Пример #1
0
  @SimpleFunction(description = "Remove data colleciton task of a specific sensor")
  public void RemoveSensorCollection(String sensorName) {
    if (mPipeline != null) {
      if (!sensorMapping.containsKey(sensorName)) {
        form.dispatchErrorOccurredEvent(
            SensorDB.this,
            "AddSensorCollection",
            ErrorMessages.ERROR_SENSORDB_NOTAVAILABLE,
            sensorName);
      }

      if (mPipeline.getActiveSensor().containsKey(sensorName)) {
        mPipeline.removeSensorCollection(sensorName);

        // if all sensor collection are removed, and if there are no more pipeline tasks in funf
        // then stop foreground
        if (!mBoundFunfManager.hasRegisteredJobs() && Launcher.isForeground()) {
          Log.i(TAG, "make funfManager stop foreground");
          Launcher.stopForeground(mainUIThreadActivity);
        }

      } else {
        // TODO: throw an exception saying the sensor is not active
        form.dispatchErrorOccurredEvent(
            SensorDB.this,
            "AddSensorCollection",
            ErrorMessages.ERROR_SENSORDB_NOTACTIVE,
            sensorName);
      }
    } else {
      Log.v(TAG, "Funf was killed by the system. In normal case, should not be here...");
    }
  }
Пример #2
0
  @SimpleFunction(
      description =
          "Add sensor colleciton task for a specific sensor with"
              + " specified period (in seconds)")
  public void AddSensorCollection(String sensorName, int period) {
    // add to the list

    if (mPipeline != null) {
      // mapp the sensor to some probe's className
      if (sensorMapping.containsKey(sensorName)) {
        mPipeline.addSensorCollection(sensorName, period);

        // make the service on the foreground
        if (!Launcher.isForeground()) {
          Log.i(TAG, "make funfManager in the foreground....");
          Launcher.startForeground(mainUIThreadActivity);
        }

      } else {
        // TODO: throw an exception, saying the sensor does not exist, please
        // check the sensorMap
        form.dispatchErrorOccurredEvent(
            SensorDB.this,
            "AddSensorCollection",
            ErrorMessages.ERROR_SENSORDB_NOTAVAILABLE,
            sensorName);
      }
    } else {
      Log.v(TAG, "AddSensorCollection, pipeline is null, funf is killed by the system.");
    }
  }