Update inverter.cpp allowing the usage of configured parameters

See commit: f7896ecd7e
This commit is contained in:
Maxwell
2020-03-10 10:02:25 +02:00
parent f7896ecd7e
commit de8bc8f812
+8 -5
View File
@@ -9,13 +9,16 @@
#include <fcntl.h> #include <fcntl.h>
#include <termios.h> #include <termios.h>
cInverter::cInverter(std::string devicename, int qpiri) { cInverter::cInverter(std::string devicename, int qpiri, int qpiws, int qmod, int qpigs) {
device = devicename; device = devicename;
status1[0] = 0; status1[0] = 0;
status2[0] = 0; status2[0] = 0;
warnings[0] = 0; warnings[0] = 0;
mode = 0; mode = 0;
qpiri = qpiri; qpiri = qpiri;
qpiws = qpiws;
qmod = qmod;
qpigs = qpigs;
} }
string *cInverter::GetQpigsStatus() { string *cInverter::GetQpigsStatus() {
@@ -154,13 +157,13 @@ bool cInverter::query(const char *cmd, int replysize) {
void cInverter::poll() { void cInverter::poll() {
int n,j; int n,j;
extern const int qpiri; extern const int qpiri, qpiws, qmod, qpigs;
while (true) { while (true) {
// Reading mode // Reading mode
if (!ups_qmod_changed) { if (!ups_qmod_changed) {
if (query("QMOD", 5)) { if (query("QMOD", qmod)) {
SetMode(buf[1]); SetMode(buf[1]);
ups_qmod_changed = true; ups_qmod_changed = true;
} }
@@ -168,7 +171,7 @@ void cInverter::poll() {
// reading status (QPIGS) // reading status (QPIGS)
if (!ups_qpigs_changed) { if (!ups_qpigs_changed) {
if (query("QPIGS", 110)) { if (query("QPIGS", qpigs)) {
m.lock(); m.lock();
strcpy(status1, (const char*)buf+1); strcpy(status1, (const char*)buf+1);
m.unlock(); m.unlock();
@@ -188,7 +191,7 @@ void cInverter::poll() {
// Get any device warnings... // Get any device warnings...
if (!ups_qpiws_changed) { if (!ups_qpiws_changed) {
if (query("QPIWS", 36)) { if (query("QPIWS", qpiws)) {
m.lock(); m.lock();
strcpy(warnings, (const char*)buf+1); strcpy(warnings, (const char*)buf+1);
m.unlock(); m.unlock();