/
NGHP.h
100 lines (81 loc) · 1.99 KB
/
NGHP.h
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* NGHP.h
*
* Created on: Sep 8, 2014
* Author: dupes
*/
#ifndef NGHP_H_
#define NGHP_H_
#include <string>
#include <vector>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <iterator>
#include "HttpCurl.h"
using namespace std;
class NGHP
{
private:
string m_host;
HttpCurl m_http;
string getQuery(string url);
public:
/**
* host: http://localhost http://10.10.0.1
* connectTimeout: delay in seconds to wait for tcp connect to complete
*/
NGHP(string host, int connectTimeout = 0);
virtual ~NGHP();
/**
* read a variable from the controller
* example variables: hp_duration, hp_reduction, hp_W
* expected return value: var = value
* example: hp_duration = 7200
*/
string getCVar(string var);
/**
* set the value of a variable on the controller
* example variables: hp_duration, hp_reduciton
* expected return value: var = value OK
* example: hp_duration = 7200 OK
*/
string setCVar(string var, string value);
/**
* reads a value from the controller and converts the result
* to an int
* internally calls getCVar
*/
int getCVarInt(string var);
/**
* reads a variable from the controller and converts the result
* to a double
* internally calls getCVar
*/
double getCVarDouble(string var);
/**
* writes a double variable to the controller
* internally calls setCVar
*/
string setCVarInt(string var, int value);
string setCVarDouble(string var, double value);
/**
* the next 5 convenience functions can be used to read and write
* the 3 variables defined by the controller
* since hw_W is read only, only a get function is defined
*/
string setDuration(int duration);
int getDuration();
string setReduction(double reduction);
double getReduction();
int getCurrentPower();
/**
* the following three functions are the HTTP response
* use them to determine if the HTTP call was
* successful
*/
string getResponseCode();
string getResponseMessage();
string getResponseBody();
};
#endif /* NGHP_H_ */