61 lines
1.6 KiB
C++
61 lines
1.6 KiB
C++
#ifndef ___INVERTER_H
|
|
#define ___INVERTER_H
|
|
|
|
#include <string>
|
|
#include <thread>
|
|
#include <mutex>
|
|
#include <vector>
|
|
|
|
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;
|
|
|
|
// Buffer sizes for different commands
|
|
int buf_qpiri;
|
|
int buf_qpiws;
|
|
int buf_qmod;
|
|
int buf_qpigs;
|
|
int last_reply_size;
|
|
|
|
int openSerial();
|
|
void closeSerial(int fd);
|
|
bool sendCommand(int fd, const std::string &cmd);
|
|
bool readReply(int fd, std::string &payload);
|
|
|
|
void SetMode(char newmode);
|
|
bool CheckCRC(unsigned char *buff, int len);
|
|
bool query(const char *cmd, int replysize);
|
|
int query_auto(const char *cmd, int max_size);
|
|
uint16_t cal_crc_half(uint8_t *pin, uint8_t len);
|
|
|
|
public:
|
|
cInverter(std::string devicename, int qpiri, int qpiws, int qmod, int qpigs);
|
|
void poll();
|
|
void runMultiThread() {
|
|
std::thread t1(&cInverter::poll, this);
|
|
t1.detach();
|
|
}
|
|
|
|
string *GetQpiriStatus();
|
|
string *GetQpigsStatus();
|
|
string *GetWarnings();
|
|
|
|
int GetMode();
|
|
void ExecuteCmd(const std::string cmd);
|
|
void AutoDiscoverBufferSizes();
|
|
int DiscoverParallelInverters(); // Returns number of parallel inverters
|
|
string GetParallelStatus(int inverter_num); // Get QPGS data for specific inverter
|
|
int QueryParallelQpgs(int count, std::vector<std::string> &replies);
|
|
};
|
|
|
|
#endif // ___INVERTER_H
|