The expiration time for new job artifacts in CI/CD pipelines is now 30 days (GitLab default). Previously generated artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

sensor.cpp 2.01 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
 * Sensor.cpp
 *
 *  Created on: 28 Apr 2017
 *      Author: ottmi
 */

#include <iostream>
#include <dcdb/sensor.h>
#include <dcdb/sensorconfig.h>
#include <dcdb/virtualsensor.h>

namespace DCDB {

  Sensor::Sensor(DCDB::Connection* connection, std::string publicName) {
    this->connection = connection;
    this->publicName = publicName;
  }

  Sensor::~Sensor() {
    // TODO Auto-generated destructor stub
  }

  void Sensor::query(std::list<SensorDataStoreReading>& result, TimeStamp& start, TimeStamp& end) {
    /* Initialize the SensorConfig interface */
    DCDB::SensorConfig sensorConfig(connection);
    DCDB::SensorDataStore sensorDataStore(connection);

    DCDB::PublicSensor publicSensor;
    switch (sensorConfig.getPublicSensorByName(publicSensor, publicName.c_str())) {
    case DCDB::SC_OK:
      break;
    case DCDB::SC_INVALIDSESSION:
      std::cout << "Invalid session." << std::endl;
      return;
    case DCDB::SC_UNKNOWNSENSOR:
      std::cout << "Unknown sensor: " << publicName << std::endl;
      return;
    default:
      std::cout << "Unknown error." << std::endl;
      return;
    }

    if (publicSensor.is_virtual) {
        DCDB::VSensor vSen(connection, publicSensor);
        vSen.query(result, start, end);
    }
    else {
        /* Expand the pattern into a list of existing sensors in the time range */
        std::list<DCDB::SensorId> sensorIds;
        switch (sensorConfig.getSensorListForPattern(sensorIds, publicSensor.pattern, start, end)) {
        case DCDB::SC_OK:
          break;
        case DCDB::SC_INVALIDPATTERN:
          std::cout << "Invalid pattern." << std::endl;
          return;
        default:
          std::cout << "Unknown error." << std::endl;
          return;
        }

        /* Iterate over the expanded list of sensorIds and output the results in CSV format */
        for (std::list<DCDB::SensorId>::iterator sit = sensorIds.begin(); sit != sensorIds.end(); sit++) {
            sensorDataStore.query(result, *sit, start, end);
        }
    }
  }

} /* namespace DCDB */