Added method to detect whether a inverter is producing

This commit is contained in:
Thomas Basler 2022-10-01 02:00:56 +02:00
parent 3d68f502c4
commit a261eb838c
2 changed files with 12 additions and 2 deletions

View File

@ -40,6 +40,15 @@ const char* InverterAbstract::name()
return _name; return _name;
} }
bool InverterAbstract::isProducing()
{
if (!Statistics()->hasChannelFieldValue(CH0, FLD_PAC)) {
return false;
}
return Statistics()->getChannelFieldValue(CH0, FLD_PAC) > 0;
}
AlarmLogParser* InverterAbstract::EventLog() AlarmLogParser* InverterAbstract::EventLog()
{ {
return _alarmLogParser.get(); return _alarmLogParser.get();
@ -112,8 +121,7 @@ uint8_t InverterAbstract::verifyAllFragments(CommandAbstract* cmd)
Serial.println(F("All missing")); Serial.println(F("All missing"));
if (cmd->getSendCount() <= MAX_RESEND_COUNT) { if (cmd->getSendCount() <= MAX_RESEND_COUNT) {
return FRAGMENT_ALL_MISSING_RESEND; return FRAGMENT_ALL_MISSING_RESEND;
} } else {
else {
cmd->gotTimeout(this); cmd->gotTimeout(this);
return FRAGMENT_ALL_MISSING_TIMEOUT; return FRAGMENT_ALL_MISSING_TIMEOUT;
} }

View File

@ -37,6 +37,8 @@ public:
virtual const byteAssign_t* getByteAssignment() = 0; virtual const byteAssign_t* getByteAssignment() = 0;
virtual const uint8_t getAssignmentCount() = 0; virtual const uint8_t getAssignmentCount() = 0;
bool isProducing();
void clearRxFragmentBuffer(); void clearRxFragmentBuffer();
void addRxFragment(uint8_t fragment[], uint8_t len); void addRxFragment(uint8_t fragment[], uint8_t len);
uint8_t verifyAllFragments(CommandAbstract* cmd); uint8_t verifyAllFragments(CommandAbstract* cmd);