Commit b777d38b authored by Michael Ott's avatar Michael Ott
Browse files

Allow for wildcards (* and ?) to be used when specifying sensornames

parent cd53294b
......@@ -109,7 +109,7 @@ void DCDBQuery::genOutput(std::list<DCDB::SensorDataStoreReading> &results, quer
DCDB::TimeStamp ts = (*reading).timeStamp;
/* Print the sensor's public name */
std::cout << start->first << ",";
std::cout << start->first.name << ",";
/* Print the time stamp */
if (useLocalTime)
......@@ -180,6 +180,9 @@ void DCDBQuery::doQuery(const char* hostname, std::list<std::string> sensors, DC
exit(EXIT_FAILURE);
}
/* Initialize the SensorConfig interface */
DCDB::SensorConfig sensorConfig(connection);
/* Iterate over list of sensors requested by the user */
for (std::list<std::string>::iterator it = sensors.begin(); it != sensors.end(); it++) {
notifyOverflow = false;
......@@ -229,32 +232,31 @@ void DCDBQuery::doQuery(const char* hostname, std::list<std::string> sensors, DC
queryCfg.unit = DCDB::UnitConv::fromString(modifierStr);
}
}
queries.insert(std::pair<std::string,queryConfig_t>(sensorName, queryCfg));
std::list<DCDB::PublicSensor> publicSensors;
sensorConfig.getPublicSensorsByWildcard(publicSensors, sensorName.c_str());
for (auto sen: publicSensors) {
queries.insert(std::pair<DCDB::PublicSensor,queryConfig_t>(sen, queryCfg));
}
}
}
/* Initialize the SensorConfig interface */
DCDB::SensorConfig sensorConfig(connection);
std::string prevSensorName;
for (auto q: queries) {
if (q.first != prevSensorName) {
if (q.first.name != prevSensorName) {
std::pair<queryMap_t::iterator, queryMap_t::iterator> range = queries.equal_range(q.first);
DCDB::PublicSensor sen;
sensorConfig.getPublicSensorByName(sen, q.first.c_str());
/* Base scaling factor and unit of the public sensor */
baseUnit = DCDB::UnitConv::fromString(sen.unit);
baseScalingFactor = sen.scaling_factor;
baseUnit = DCDB::UnitConv::fromString(q.first.unit);
baseScalingFactor = q.first.scaling_factor;
std::list<DCDB::SensorDataStoreReading> results;
DCDB::Sensor sensor(connection, sen);
DCDB::Sensor sensor(connection, q.first);
sensor.query(results, start, end, DCDB::AGGREGATE_NONE);
genOutput(results, range.first, range.second);
if(notifyOverflow)
std::cout << "Overflow detected." << std::endl;
prevSensorName = q.first;
prevSensorName = q.first.name;
}
}
......
......@@ -58,7 +58,7 @@ typedef struct queryConfig {
DCDB::Unit unit;
DCDB_OP_TYPE operation;
} queryConfig_t;
typedef std::multimap<std::string, queryConfig_t> queryMap_t;
typedef std::multimap<DCDB::PublicSensor, queryConfig_t> queryMap_t;
typedef enum {
CONVERT_OK,
......@@ -70,7 +70,7 @@ protected:
bool useLocalTime;
bool useRawOutput;
std::multimap<std::string, queryConfig_t> queries;
queryMap_t queries;
double baseScalingFactor;
DCDB::Unit baseUnit;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment