Code Refactoring: Use internal inverter instance in gotTimeout method

This commit is contained in:
Thomas Basler 2024-05-16 19:55:01 +02:00
parent 6a7bed0ecf
commit 6d6d62bb77
13 changed files with 22 additions and 22 deletions

View File

@ -94,7 +94,7 @@ PowerLimitControlType ActivePowerControlCommand::getType()
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);
}

View File

@ -17,7 +17,7 @@ public:
virtual String getCommandName() const;
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);
float getLimit() const;

View File

@ -57,7 +57,7 @@ bool AlarmDataCommand::handleResponse(InverterAbstract& inverter, const fragment
return true;
}
void AlarmDataCommand::gotTimeout(InverterAbstract& inverter)
void AlarmDataCommand::gotTimeout()
{
inverter.EventLog()->setLastAlarmRequestSuccess(CMD_NOK);
_inv->EventLog()->setLastAlarmRequestSuccess(CMD_NOK);
}

View File

@ -10,5 +10,5 @@ public:
virtual String getCommandName() const;
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
virtual void gotTimeout(InverterAbstract& inverter);
virtual void gotTimeout();
};

View File

@ -125,7 +125,7 @@ void CommandAbstract::convertSerialToPacketId(uint8_t buffer[], const uint64_t s
buffer[0] = s.b[3];
}
void CommandAbstract::gotTimeout(InverterAbstract& inverter)
void CommandAbstract::gotTimeout()
{
}

View File

@ -38,7 +38,7 @@ public:
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 void gotTimeout(InverterAbstract& inverter);
virtual void gotTimeout();
// Sets the amount how often the specific command is resent if all fragments where missing
virtual uint8_t getMaxResendCount() const;

View File

@ -55,9 +55,9 @@ bool PowerControlCommand::handleResponse(InverterAbstract& inverter, const fragm
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)

View File

@ -10,7 +10,7 @@ public:
virtual String getCommandName() const;
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 setRestart();

View File

@ -68,7 +68,7 @@ bool RealTimeRunDataCommand::handleResponse(InverterAbstract& inverter, const fr
return true;
}
void RealTimeRunDataCommand::gotTimeout(InverterAbstract& inverter)
void RealTimeRunDataCommand::gotTimeout()
{
inverter.Statistics()->incrementRxFailureCount();
_inv->Statistics()->incrementRxFailureCount();
}

View File

@ -10,5 +10,5 @@ public:
virtual String getCommandName() const;
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
virtual void gotTimeout(InverterAbstract& inverter);
virtual void gotTimeout();
};

View File

@ -68,7 +68,7 @@ bool SystemConfigParaCommand::handleResponse(InverterAbstract& inverter, const f
return true;
}
void SystemConfigParaCommand::gotTimeout(InverterAbstract& inverter)
void SystemConfigParaCommand::gotTimeout()
{
inverter.SystemConfigPara()->setLastLimitRequestSuccess(CMD_NOK);
_inv->SystemConfigPara()->setLastLimitRequestSuccess(CMD_NOK);
}

View File

@ -10,5 +10,5 @@ public:
virtual String getCommandName() const;
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
virtual void gotTimeout(InverterAbstract& inverter);
virtual void gotTimeout();
};

View File

@ -226,7 +226,7 @@ uint8_t InverterAbstract::verifyAllFragments(CommandAbstract& cmd)
if (cmd.getSendCount() <= cmd.getMaxResendCount()) {
return FRAGMENT_ALL_MISSING_RESEND;
} else {
cmd.gotTimeout(*this);
cmd.gotTimeout();
return FRAGMENT_ALL_MISSING_TIMEOUT;
}
}
@ -237,7 +237,7 @@ uint8_t InverterAbstract::verifyAllFragments(CommandAbstract& cmd)
if (_rxFragmentRetransmitCnt++ < cmd.getMaxRetransmitCount()) {
return _rxFragmentLastPacketId + 1;
} else {
cmd.gotTimeout(*this);
cmd.gotTimeout();
return FRAGMENT_RETRANSMIT_TIMEOUT;
}
}
@ -249,14 +249,14 @@ uint8_t InverterAbstract::verifyAllFragments(CommandAbstract& cmd)
if (_rxFragmentRetransmitCnt++ < cmd.getMaxRetransmitCount()) {
return i + 1;
} else {
cmd.gotTimeout(*this);
cmd.gotTimeout();
return FRAGMENT_RETRANSMIT_TIMEOUT;
}
}
}
if (!cmd.handleResponse(*this, _rxFragmentBuffer, _rxFragmentMaxPacketId)) {
cmd.gotTimeout(*this);
cmd.gotTimeout();
return FRAGMENT_HANDLE_ERROR;
}