From a261eb838c2b023b378be6709df5594c3061a276 Mon Sep 17 00:00:00 2001 From: Thomas Basler Date: Sat, 1 Oct 2022 02:00:56 +0200 Subject: [PATCH] Added method to detect whether a inverter is producing --- lib/Hoymiles/src/inverters/InverterAbstract.cpp | 12 ++++++++++-- lib/Hoymiles/src/inverters/InverterAbstract.h | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/Hoymiles/src/inverters/InverterAbstract.cpp b/lib/Hoymiles/src/inverters/InverterAbstract.cpp index 77250bf..386a4b0 100644 --- a/lib/Hoymiles/src/inverters/InverterAbstract.cpp +++ b/lib/Hoymiles/src/inverters/InverterAbstract.cpp @@ -40,6 +40,15 @@ const char* InverterAbstract::name() return _name; } +bool InverterAbstract::isProducing() +{ + if (!Statistics()->hasChannelFieldValue(CH0, FLD_PAC)) { + return false; + } + + return Statistics()->getChannelFieldValue(CH0, FLD_PAC) > 0; +} + AlarmLogParser* InverterAbstract::EventLog() { return _alarmLogParser.get(); @@ -112,8 +121,7 @@ uint8_t InverterAbstract::verifyAllFragments(CommandAbstract* cmd) Serial.println(F("All missing")); if (cmd->getSendCount() <= MAX_RESEND_COUNT) { return FRAGMENT_ALL_MISSING_RESEND; - } - else { + } else { cmd->gotTimeout(this); return FRAGMENT_ALL_MISSING_TIMEOUT; } diff --git a/lib/Hoymiles/src/inverters/InverterAbstract.h b/lib/Hoymiles/src/inverters/InverterAbstract.h index 7fedcd7..3738f97 100644 --- a/lib/Hoymiles/src/inverters/InverterAbstract.h +++ b/lib/Hoymiles/src/inverters/InverterAbstract.h @@ -37,6 +37,8 @@ public: virtual const byteAssign_t* getByteAssignment() = 0; virtual const uint8_t getAssignmentCount() = 0; + bool isProducing(); + void clearRxFragmentBuffer(); void addRxFragment(uint8_t fragment[], uint8_t len); uint8_t verifyAllFragments(CommandAbstract* cmd);