Replace NULL by nullptr

This commit is contained in:
Thomas Basler 2023-12-11 20:23:45 +01:00
parent 47e905bcfc
commit 5e45006831
6 changed files with 16 additions and 16 deletions

View File

@ -21,7 +21,7 @@ private:
Task _loopTask; Task _loopTask;
AsyncWebSocket* _ws = NULL; AsyncWebSocket* _ws = nullptr;
char _buffer[BUFFER_SIZE]; char _buffer[BUFFER_SIZE];
uint16_t _buff_pos = 0; uint16_t _buff_pos = 0;
uint32_t _lastSend = 0; uint32_t _lastSend = 0;

View File

@ -30,7 +30,7 @@ typedef struct NetworkEventCbList {
network_event event; network_event event;
NetworkEventCbList() NetworkEventCbList()
: cb(NULL) : cb(nullptr)
, event(network_event::NETWORK_UNKNOWN) , event(network_event::NETWORK_UNKNOWN)
{ {
} }

View File

@ -13,7 +13,7 @@ public:
private: private:
void onPrometheusMetricsGet(AsyncWebServerRequest* request); void onPrometheusMetricsGet(AsyncWebServerRequest* request);
void addField(AsyncResponseStream* stream, String& serial, uint8_t idx, std::shared_ptr<InverterAbstract> inv, ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId, const char* metricName, const char* channelName = NULL); void addField(AsyncResponseStream* stream, String& serial, uint8_t idx, std::shared_ptr<InverterAbstract> inv, ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId, const char* metricName, const char* channelName = nullptr);
void addPanelInfo(AsyncResponseStream* stream, String& serial, uint8_t idx, std::shared_ptr<InverterAbstract> inv, ChannelType_t type, ChannelNum_t channel); void addPanelInfo(AsyncResponseStream* stream, String& serial, uint8_t idx, std::shared_ptr<InverterAbstract> inv, ChannelType_t type, ChannelNum_t channel);

View File

@ -128,7 +128,7 @@ const byteAssign_t* StatisticsParser::getAssignmentByChannelField(ChannelType_t
return &_byteAssignment[i]; return &_byteAssignment[i];
} }
} }
return NULL; return nullptr;
} }
fieldSettings_t* StatisticsParser::getSettingByChannelField(ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId) fieldSettings_t* StatisticsParser::getSettingByChannelField(ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId)
@ -138,13 +138,13 @@ fieldSettings_t* StatisticsParser::getSettingByChannelField(ChannelType_t type,
return &i; return &i;
} }
} }
return NULL; return nullptr;
} }
float StatisticsParser::getChannelFieldValue(ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId) float StatisticsParser::getChannelFieldValue(ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId)
{ {
const byteAssign_t* pos = getAssignmentByChannelField(type, channel, fieldId); const byteAssign_t* pos = getAssignmentByChannelField(type, channel, fieldId);
if (pos == NULL) { if (pos == nullptr) {
return 0; return 0;
} }
@ -174,7 +174,7 @@ float StatisticsParser::getChannelFieldValue(ChannelType_t type, ChannelNum_t ch
result /= static_cast<float>(div); result /= static_cast<float>(div);
const fieldSettings_t* setting = getSettingByChannelField(type, channel, fieldId); const fieldSettings_t* setting = getSettingByChannelField(type, channel, fieldId);
if (setting != NULL && _statisticLength > 0) { if (setting != nullptr && _statisticLength > 0) {
result += setting->offset; result += setting->offset;
} }
return result; return result;
@ -189,7 +189,7 @@ float StatisticsParser::getChannelFieldValue(ChannelType_t type, ChannelNum_t ch
bool StatisticsParser::setChannelFieldValue(ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId, float value) bool StatisticsParser::setChannelFieldValue(ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId, float value)
{ {
const byteAssign_t* pos = getAssignmentByChannelField(type, channel, fieldId); const byteAssign_t* pos = getAssignmentByChannelField(type, channel, fieldId);
if (pos == NULL) { if (pos == nullptr) {
return false; return false;
} }
@ -202,7 +202,7 @@ bool StatisticsParser::setChannelFieldValue(ChannelType_t type, ChannelNum_t cha
} }
const fieldSettings_t* setting = getSettingByChannelField(type, channel, fieldId); const fieldSettings_t* setting = getSettingByChannelField(type, channel, fieldId);
if (setting != NULL) { if (setting != nullptr) {
value -= setting->offset; value -= setting->offset;
} }
value *= static_cast<float>(div); value *= static_cast<float>(div);
@ -236,7 +236,7 @@ String StatisticsParser::getChannelFieldValueString(ChannelType_t type, ChannelN
bool StatisticsParser::hasChannelFieldValue(ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId) bool StatisticsParser::hasChannelFieldValue(ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId)
{ {
const byteAssign_t* pos = getAssignmentByChannelField(type, channel, fieldId); const byteAssign_t* pos = getAssignmentByChannelField(type, channel, fieldId);
return pos != NULL; return pos != nullptr;
} }
const char* StatisticsParser::getChannelFieldUnit(ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId) const char* StatisticsParser::getChannelFieldUnit(ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId)
@ -260,7 +260,7 @@ uint8_t StatisticsParser::getChannelFieldDigits(ChannelType_t type, ChannelNum_t
float StatisticsParser::getChannelFieldOffset(ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId) float StatisticsParser::getChannelFieldOffset(ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId)
{ {
const fieldSettings_t* setting = getSettingByChannelField(type, channel, fieldId); const fieldSettings_t* setting = getSettingByChannelField(type, channel, fieldId);
if (setting != NULL) { if (setting != nullptr) {
return setting->offset; return setting->offset;
} }
return 0; return 0;
@ -269,7 +269,7 @@ float StatisticsParser::getChannelFieldOffset(ChannelType_t type, ChannelNum_t c
void StatisticsParser::setChannelFieldOffset(ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId, float offset) void StatisticsParser::setChannelFieldOffset(ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId, float offset)
{ {
fieldSettings_t* setting = getSettingByChannelField(type, channel, fieldId); fieldSettings_t* setting = getSettingByChannelField(type, channel, fieldId);
if (setting != NULL) { if (setting != nullptr) {
setting->offset = offset; setting->offset = offset;
} else { } else {
_fieldSettings.push_back({ type, channel, fieldId, offset }); _fieldSettings.push_back({ type, channel, fieldId, offset });
@ -444,7 +444,7 @@ static float calcEffiencyCh0(StatisticsParser* iv, uint8_t arg0)
// arg0 = channel // arg0 = channel
static float calcIrradiation(StatisticsParser* iv, uint8_t arg0) static float calcIrradiation(StatisticsParser* iv, uint8_t arg0)
{ {
if (NULL != iv) { if (nullptr != iv) {
if (iv->getStringMaxPower(arg0) > 0) if (iv->getStringMaxPower(arg0) > 0)
return iv->getChannelFieldValue(TYPE_DC, static_cast<ChannelNum_t>(arg0), FLD_PDC) / iv->getStringMaxPower(arg0) * 100.0f; return iv->getChannelFieldValue(TYPE_DC, static_cast<ChannelNum_t>(arg0), FLD_PDC) / iv->getStringMaxPower(arg0) * 100.0f;
} }

View File

@ -357,7 +357,7 @@ INVERTER_CONFIG_T* ConfigurationClass::getFreeInverterSlot()
} }
} }
return NULL; return nullptr;
} }
INVERTER_CONFIG_T* ConfigurationClass::getInverterConfig(uint64_t serial) INVERTER_CONFIG_T* ConfigurationClass::getInverterConfig(uint64_t serial)
@ -368,7 +368,7 @@ INVERTER_CONFIG_T* ConfigurationClass::getInverterConfig(uint64_t serial)
} }
} }
return NULL; return nullptr;
} }
ConfigurationClass Configuration; ConfigurationClass Configuration;

View File

@ -102,7 +102,7 @@ void WebApiPrometheusClass::onPrometheusMetricsGet(AsyncWebServerRequest* reques
void WebApiPrometheusClass::addField(AsyncResponseStream* stream, String& serial, uint8_t idx, std::shared_ptr<InverterAbstract> inv, ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId, const char* metricName, const char* channelName) void WebApiPrometheusClass::addField(AsyncResponseStream* stream, String& serial, uint8_t idx, std::shared_ptr<InverterAbstract> inv, ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId, const char* metricName, const char* channelName)
{ {
if (inv->Statistics()->hasChannelFieldValue(type, channel, fieldId)) { if (inv->Statistics()->hasChannelFieldValue(type, channel, fieldId)) {
const char* chanName = (channelName == NULL) ? inv->Statistics()->getChannelFieldName(type, channel, fieldId) : channelName; const char* chanName = (channelName == nullptr) ? inv->Statistics()->getChannelFieldName(type, channel, fieldId) : channelName;
if (idx == 0 && type == TYPE_AC && channel == 0) { if (idx == 0 && type == TYPE_AC && channel == 0) {
stream->printf("# HELP opendtu_%s in %s\n", chanName, inv->Statistics()->getChannelFieldUnit(type, channel, fieldId)); stream->printf("# HELP opendtu_%s in %s\n", chanName, inv->Statistics()->getChannelFieldUnit(type, channel, fieldId));
stream->printf("# TYPE opendtu_%s %s\n", chanName, metricName); stream->printf("# TYPE opendtu_%s %s\n", chanName, metricName);