Added method to detect whether an inverter is reachable
This commit is contained in:
parent
a261eb838c
commit
862b65e844
@ -23,6 +23,12 @@ bool RealTimeRunDataCommand::handleResponse(InverterAbstract* inverter, fragment
|
|||||||
inverter->Statistics()->appendFragment(offs, fragment[i].fragment, fragment[i].len);
|
inverter->Statistics()->appendFragment(offs, fragment[i].fragment, fragment[i].len);
|
||||||
offs += (fragment[i].len);
|
offs += (fragment[i].len);
|
||||||
}
|
}
|
||||||
|
inverter->Statistics()->resetRxFailureCount();
|
||||||
inverter->Statistics()->setLastUpdate(millis());
|
inverter->Statistics()->setLastUpdate(millis());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RealTimeRunDataCommand::gotTimeout(InverterAbstract* inverter)
|
||||||
|
{
|
||||||
|
inverter->Statistics()->incrementRxFailureCount();
|
||||||
|
}
|
||||||
@ -7,4 +7,5 @@ public:
|
|||||||
explicit RealTimeRunDataCommand(uint64_t target_address = 0, uint64_t router_address = 0, time_t time = 0);
|
explicit RealTimeRunDataCommand(uint64_t target_address = 0, uint64_t router_address = 0, time_t time = 0);
|
||||||
|
|
||||||
virtual bool handleResponse(InverterAbstract* inverter, fragment_t fragment[], uint8_t max_fragment_id);
|
virtual bool handleResponse(InverterAbstract* inverter, fragment_t fragment[], uint8_t max_fragment_id);
|
||||||
|
virtual void gotTimeout(InverterAbstract* inverter);
|
||||||
};
|
};
|
||||||
@ -49,6 +49,11 @@ bool InverterAbstract::isProducing()
|
|||||||
return Statistics()->getChannelFieldValue(CH0, FLD_PAC) > 0;
|
return Statistics()->getChannelFieldValue(CH0, FLD_PAC) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool InverterAbstract::isReachable()
|
||||||
|
{
|
||||||
|
return Statistics()->getRxFailureCount() <= MAX_ONLINE_FAILURE_COUNT;
|
||||||
|
}
|
||||||
|
|
||||||
AlarmLogParser* InverterAbstract::EventLog()
|
AlarmLogParser* InverterAbstract::EventLog()
|
||||||
{
|
{
|
||||||
return _alarmLogParser.get();
|
return _alarmLogParser.get();
|
||||||
|
|||||||
@ -23,6 +23,7 @@ enum {
|
|||||||
#define MAX_RF_FRAGMENT_COUNT 13
|
#define MAX_RF_FRAGMENT_COUNT 13
|
||||||
#define MAX_RETRANSMIT_COUNT 5 // Used to send the retransmit package
|
#define MAX_RETRANSMIT_COUNT 5 // Used to send the retransmit package
|
||||||
#define MAX_RESEND_COUNT 4 // Used if all packages are missing
|
#define MAX_RESEND_COUNT 4 // Used if all packages are missing
|
||||||
|
#define MAX_ONLINE_FAILURE_COUNT 2
|
||||||
|
|
||||||
class CommandAbstract;
|
class CommandAbstract;
|
||||||
|
|
||||||
@ -38,6 +39,7 @@ public:
|
|||||||
virtual const uint8_t getAssignmentCount() = 0;
|
virtual const uint8_t getAssignmentCount() = 0;
|
||||||
|
|
||||||
bool isProducing();
|
bool isProducing();
|
||||||
|
bool isReachable();
|
||||||
|
|
||||||
void clearRxFragmentBuffer();
|
void clearRxFragmentBuffer();
|
||||||
void addRxFragment(uint8_t fragment[], uint8_t len);
|
void addRxFragment(uint8_t fragment[], uint8_t len);
|
||||||
|
|||||||
@ -112,6 +112,21 @@ void StatisticsParser::setChannelMaxPower(uint8_t channel, uint16_t power)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StatisticsParser::resetRxFailureCount()
|
||||||
|
{
|
||||||
|
_rxFailureCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatisticsParser::incrementRxFailureCount()
|
||||||
|
{
|
||||||
|
_rxFailureCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t StatisticsParser::getRxFailureCount()
|
||||||
|
{
|
||||||
|
return _rxFailureCount;
|
||||||
|
}
|
||||||
|
|
||||||
static float calcYieldTotalCh0(StatisticsParser* iv, uint8_t arg0)
|
static float calcYieldTotalCh0(StatisticsParser* iv, uint8_t arg0)
|
||||||
{
|
{
|
||||||
float yield = 0;
|
float yield = 0;
|
||||||
|
|||||||
@ -113,6 +113,10 @@ public:
|
|||||||
uint16_t getChannelMaxPower(uint8_t channel);
|
uint16_t getChannelMaxPower(uint8_t channel);
|
||||||
void setChannelMaxPower(uint8_t channel, uint16_t power);
|
void setChannelMaxPower(uint8_t channel, uint16_t power);
|
||||||
|
|
||||||
|
void resetRxFailureCount();
|
||||||
|
void incrementRxFailureCount();
|
||||||
|
uint32_t getRxFailureCount();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t _payloadStatistic[STATISTIC_PACKET_SIZE] = {};
|
uint8_t _payloadStatistic[STATISTIC_PACKET_SIZE] = {};
|
||||||
uint8_t _statisticLength = 0;
|
uint8_t _statisticLength = 0;
|
||||||
@ -120,4 +124,6 @@ private:
|
|||||||
|
|
||||||
const byteAssign_t* _byteAssignment;
|
const byteAssign_t* _byteAssignment;
|
||||||
uint8_t _byteAssignmentCount;
|
uint8_t _byteAssignmentCount;
|
||||||
|
|
||||||
|
uint32_t _rxFailureCount = 0;
|
||||||
};
|
};
|
||||||
Loading…
Reference in New Issue
Block a user