Exemplo n.º 1
0
  public List<SensorData> getSensorDataList(int id) {
    Sensor sens = ts.getSensor(id);
    ArrayList<SensorData> newlist = new ArrayList<>();
    if (sens != null) {
      if (sens.getDataTypes() == 1 || sens.getDataTypes() == 3) {
        newlist.add(
            new SensorData(
                sens.getId(),
                0,
                "temp",
                String.valueOf(sens.getTemperature()),
                sens.getTimeStampString()));
      }

      if (sens.getDataTypes() == 2 || sens.getDataTypes() == 3) {
        newlist.add(
            new SensorData(
                sens.getId(),
                1,
                "hum",
                String.valueOf(sens.getHumidity()),
                sens.getTimeStampString()));
      }
    }
    return newlist;
  }
Exemplo n.º 2
0
  public List<SensorData> getSensors() {
    ArrayList<Sensor> lista = ts.getSensors();
    ArrayList<SensorData> newlist = new ArrayList<>();

    for (Sensor sens : lista) {
      if (sens.getTimeStampAge() < 30) {
        if (sens.getDataTypes() == 1 || sens.getDataTypes() == 3) {
          newlist.add(
              new SensorData(
                  sens.getId(),
                  0,
                  "temp",
                  String.valueOf(sens.getTemperature()),
                  sens.getTimeStampString()));
        }

        if (sens.getDataTypes() == 2 || sens.getDataTypes() == 3) {
          newlist.add(
              new SensorData(
                  sens.getId(),
                  1,
                  "hum",
                  String.valueOf(sens.getHumidity()),
                  sens.getTimeStampString()));
        }
      }
    }
    return newlist;
  }