Code Refactoring: Use internal inverter instance in gotTimeout method
This commit is contained in:
parent
6a7bed0ecf
commit
6d6d62bb77
@ -94,7 +94,7 @@ PowerLimitControlType ActivePowerControlCommand::getType()
|
|||||||
return (PowerLimitControlType)(((uint16_t)_payload[14] << 8) | _payload[15]);
|
return (PowerLimitControlType)(((uint16_t)_payload[14] << 8) | _payload[15]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActivePowerControlCommand::gotTimeout(InverterAbstract& inverter)
|
void ActivePowerControlCommand::gotTimeout()
|
||||||
{
|
{
|
||||||
inverter.SystemConfigPara()->setLastLimitCommandSuccess(CMD_NOK);
|
_inv->SystemConfigPara()->setLastLimitCommandSuccess(CMD_NOK);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,7 @@ public:
|
|||||||
virtual String getCommandName() const;
|
virtual String getCommandName() const;
|
||||||
|
|
||||||
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
|
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
|
||||||
virtual void gotTimeout(InverterAbstract& inverter);
|
virtual void gotTimeout();
|
||||||
|
|
||||||
void setActivePowerLimit(const float limit, const PowerLimitControlType type = RelativNonPersistent);
|
void setActivePowerLimit(const float limit, const PowerLimitControlType type = RelativNonPersistent);
|
||||||
float getLimit() const;
|
float getLimit() const;
|
||||||
|
|||||||
@ -57,7 +57,7 @@ bool AlarmDataCommand::handleResponse(InverterAbstract& inverter, const fragment
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlarmDataCommand::gotTimeout(InverterAbstract& inverter)
|
void AlarmDataCommand::gotTimeout()
|
||||||
{
|
{
|
||||||
inverter.EventLog()->setLastAlarmRequestSuccess(CMD_NOK);
|
_inv->EventLog()->setLastAlarmRequestSuccess(CMD_NOK);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,5 +10,5 @@ public:
|
|||||||
virtual String getCommandName() const;
|
virtual String getCommandName() const;
|
||||||
|
|
||||||
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
|
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
|
||||||
virtual void gotTimeout(InverterAbstract& inverter);
|
virtual void gotTimeout();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -125,7 +125,7 @@ void CommandAbstract::convertSerialToPacketId(uint8_t buffer[], const uint64_t s
|
|||||||
buffer[0] = s.b[3];
|
buffer[0] = s.b[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandAbstract::gotTimeout(InverterAbstract& inverter)
|
void CommandAbstract::gotTimeout()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -38,7 +38,7 @@ public:
|
|||||||
virtual CommandAbstract* getRequestFrameCommand(const uint8_t frame_no);
|
virtual CommandAbstract* getRequestFrameCommand(const uint8_t frame_no);
|
||||||
|
|
||||||
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id) = 0;
|
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id) = 0;
|
||||||
virtual void gotTimeout(InverterAbstract& inverter);
|
virtual void gotTimeout();
|
||||||
|
|
||||||
// Sets the amount how often the specific command is resent if all fragments where missing
|
// Sets the amount how often the specific command is resent if all fragments where missing
|
||||||
virtual uint8_t getMaxResendCount() const;
|
virtual uint8_t getMaxResendCount() const;
|
||||||
|
|||||||
@ -55,9 +55,9 @@ bool PowerControlCommand::handleResponse(InverterAbstract& inverter, const fragm
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PowerControlCommand::gotTimeout(InverterAbstract& inverter)
|
void PowerControlCommand::gotTimeout()
|
||||||
{
|
{
|
||||||
inverter.PowerCommand()->setLastPowerCommandSuccess(CMD_NOK);
|
_inv->PowerCommand()->setLastPowerCommandSuccess(CMD_NOK);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PowerControlCommand::setPowerOn(const bool state)
|
void PowerControlCommand::setPowerOn(const bool state)
|
||||||
|
|||||||
@ -10,7 +10,7 @@ public:
|
|||||||
virtual String getCommandName() const;
|
virtual String getCommandName() const;
|
||||||
|
|
||||||
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
|
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
|
||||||
virtual void gotTimeout(InverterAbstract& inverter);
|
virtual void gotTimeout();
|
||||||
|
|
||||||
void setPowerOn(const bool state);
|
void setPowerOn(const bool state);
|
||||||
void setRestart();
|
void setRestart();
|
||||||
|
|||||||
@ -68,7 +68,7 @@ bool RealTimeRunDataCommand::handleResponse(InverterAbstract& inverter, const fr
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RealTimeRunDataCommand::gotTimeout(InverterAbstract& inverter)
|
void RealTimeRunDataCommand::gotTimeout()
|
||||||
{
|
{
|
||||||
inverter.Statistics()->incrementRxFailureCount();
|
_inv->Statistics()->incrementRxFailureCount();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,5 +10,5 @@ public:
|
|||||||
virtual String getCommandName() const;
|
virtual String getCommandName() const;
|
||||||
|
|
||||||
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
|
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
|
||||||
virtual void gotTimeout(InverterAbstract& inverter);
|
virtual void gotTimeout();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -68,7 +68,7 @@ bool SystemConfigParaCommand::handleResponse(InverterAbstract& inverter, const f
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemConfigParaCommand::gotTimeout(InverterAbstract& inverter)
|
void SystemConfigParaCommand::gotTimeout()
|
||||||
{
|
{
|
||||||
inverter.SystemConfigPara()->setLastLimitRequestSuccess(CMD_NOK);
|
_inv->SystemConfigPara()->setLastLimitRequestSuccess(CMD_NOK);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,5 +10,5 @@ public:
|
|||||||
virtual String getCommandName() const;
|
virtual String getCommandName() const;
|
||||||
|
|
||||||
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
|
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
|
||||||
virtual void gotTimeout(InverterAbstract& inverter);
|
virtual void gotTimeout();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -226,7 +226,7 @@ uint8_t InverterAbstract::verifyAllFragments(CommandAbstract& cmd)
|
|||||||
if (cmd.getSendCount() <= cmd.getMaxResendCount()) {
|
if (cmd.getSendCount() <= cmd.getMaxResendCount()) {
|
||||||
return FRAGMENT_ALL_MISSING_RESEND;
|
return FRAGMENT_ALL_MISSING_RESEND;
|
||||||
} else {
|
} else {
|
||||||
cmd.gotTimeout(*this);
|
cmd.gotTimeout();
|
||||||
return FRAGMENT_ALL_MISSING_TIMEOUT;
|
return FRAGMENT_ALL_MISSING_TIMEOUT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -237,7 +237,7 @@ uint8_t InverterAbstract::verifyAllFragments(CommandAbstract& cmd)
|
|||||||
if (_rxFragmentRetransmitCnt++ < cmd.getMaxRetransmitCount()) {
|
if (_rxFragmentRetransmitCnt++ < cmd.getMaxRetransmitCount()) {
|
||||||
return _rxFragmentLastPacketId + 1;
|
return _rxFragmentLastPacketId + 1;
|
||||||
} else {
|
} else {
|
||||||
cmd.gotTimeout(*this);
|
cmd.gotTimeout();
|
||||||
return FRAGMENT_RETRANSMIT_TIMEOUT;
|
return FRAGMENT_RETRANSMIT_TIMEOUT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -249,16 +249,16 @@ uint8_t InverterAbstract::verifyAllFragments(CommandAbstract& cmd)
|
|||||||
if (_rxFragmentRetransmitCnt++ < cmd.getMaxRetransmitCount()) {
|
if (_rxFragmentRetransmitCnt++ < cmd.getMaxRetransmitCount()) {
|
||||||
return i + 1;
|
return i + 1;
|
||||||
} else {
|
} else {
|
||||||
cmd.gotTimeout(*this);
|
cmd.gotTimeout();
|
||||||
return FRAGMENT_RETRANSMIT_TIMEOUT;
|
return FRAGMENT_RETRANSMIT_TIMEOUT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cmd.handleResponse(*this, _rxFragmentBuffer, _rxFragmentMaxPacketId)) {
|
if (!cmd.handleResponse(*this, _rxFragmentBuffer, _rxFragmentMaxPacketId)) {
|
||||||
cmd.gotTimeout(*this);
|
cmd.gotTimeout();
|
||||||
return FRAGMENT_HANDLE_ERROR;
|
return FRAGMENT_HANDLE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FRAGMENT_OK;
|
return FRAGMENT_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user