-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathinverter.h
49 lines (38 loc) · 1.02 KB
/
inverter.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
#ifndef ___INVERTER_H
#define ___INVERTER_H
#include <atomic>
#include <thread>
#include <mutex>
#include <string>
using namespace std;
class cInverter {
unsigned char buf[1024]; //internal work buffer
char warnings[1024];
char status1[1024];
char status2[1024];
char mode;
std::string device;
std::mutex m;
std::thread t1;
std::atomic_bool quit_thread{false};
void SetMode(char newmode);
bool CheckCRC(unsigned char *buff, int len);
bool query(const char *cmd);
uint16_t cal_crc_half(uint8_t *pin, uint8_t len);
public:
cInverter(std::string devicename);
void poll();
void runMultiThread() {
t1 = std::thread(&cInverter::poll, this);
}
void terminateThread() {
quit_thread = true;
t1.join();
}
string *GetQpiriStatus();
string *GetQpigsStatus();
string *GetWarnings();
int GetMode();
void ExecuteCmd(const std::string cmd);
};
#endif // ___INVERTER_H