-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_old.cpp
More file actions
49 lines (39 loc) · 1.95 KB
/
Copy pathmain_old.cpp
File metadata and controls
49 lines (39 loc) · 1.95 KB
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
#include <iostream>
#include "include/DataBuffer.h"
#include "include/CPP2InfluxDB.h"
#include "include/HTTPRequest.h"
#include <boost/date_time/gregorian/gregorian.hpp>
using namespace std;
int main() {
DataBuffer dataBuffer;
// try dataBuffer
cout << dataBuffer << endl;
dataBuffer.data["Temperature"] = 4.5;
cout << dataBuffer << endl;
dataBuffer.data["AirPressure"] = 1021;
cout << dataBuffer << endl;
DataBufferProperties DBP = possibleDataBufferValues.at("Temperature");
if ((dataBuffer.data["Temperature"] <= DBP.maxValue) && (dataBuffer.data["Temperature"] >= DBP.minValue)) {
cout << "Temperature is within its range." << endl;
cout << "Temperature : " << dataBuffer.data["Temperature"] << " " << DBP.unitOfMeasure << endl;
}
//try CPP2InfluxDB
CPP2InfluxDB& dbi = CPP2InfluxDB::getInstance();
dbi.init();
dbi.writeToDataBase(dataBuffer);
dataBuffer = dbi.readFromDataBase(dataBuffer);
cout << "dataBuffer content " << dataBuffer << endl;
cout << "getDBFailure " << dbi.getDBFailure() << endl;
dbi.writeStatusOK(true);
cout << "statusOK " << dbi.readStatusOK() << endl;
//try http-request
HTTPRequest req;
req.post("http://localhost:8086/write?db=test3","forecast,datatype=temperature value=50");
//req.post("http://localhost:8086/query?q=create+database+test400&db=_internal");
//req.get("http://localhost:8086/query?pretty=true&db=test3&q=SELECT+*+FROM+forecast");
//string answer = req.get("http://localhost:8086/query?pretty=true&db=WeatherData&q=SELECT+Lufttemperatur_2m+FROM+point+where+DataSource+=+'Forecast'+and+time+=+'2015-08-18T23:00:00.00000000Z'+%2B+1000h");
string answer = req.get("http://localhost:8086/query?pretty=true&db=WeatherData&q=SELECT+Lufttemperatur_2m+FROM+point");
cout << answer;
//req.get("http://api.openweathermap.org/data/2.5/weather?lat=52.9&lon=9.2&APPID=08854a5d6fe0754f2670f5fa5127a831");
return 0 ;
}