Merge PR #208: SMA: Improve datetime performance

master
jenkins 2025-05-22 15:29:03 +02:00
commit 7f1d6cbf82
2 changed files with 4 additions and 4 deletions

View File

@ -152,7 +152,7 @@ void SpeedwireMeter::evaluateReachable()
// Note: the meter sends every second the data on the multicast
// If the meter has not sent data within the last 5 seconds it seems not to be reachable
bool reachable = false;
if (QDateTime::currentDateTime().toMSecsSinceEpoch() - m_lastSeenTimestamp < 5000) {
if (QDateTime::currentMSecsSinceEpoch() - m_lastSeenTimestamp < 5000) {
reachable = true;
}
@ -200,7 +200,7 @@ void SpeedwireMeter::processData(const QHostAddress &senderAddress, quint16 send
qCDebug(dcSma()).noquote() << "Meter: Measurements received from" << QString("%1:%2").arg(senderAddress.toString()).arg(senderPort) << "Serial number:" << serialNumber << "Model ID:" << modelId;
// Make sure the rate is at max 1Hz, some meters send much more data, which creates an uneccessary load
if (QDateTime::currentDateTime().toMSecsSinceEpoch() - m_lastSeenTimestamp < 1000)
if (QDateTime::currentMSecsSinceEpoch() - m_lastSeenTimestamp < 1000)
return;
// Parse the packet data
@ -319,7 +319,7 @@ void SpeedwireMeter::processData(const QHostAddress &senderAddress, quint16 send
}
// Save the current timestamp for reachable evaluation
m_lastSeenTimestamp = QDateTime::currentDateTime().toMSecsSinceEpoch();
m_lastSeenTimestamp = QDateTime::currentMSecsSinceEpoch();
evaluateReachable();
emit valuesUpdated();

View File

@ -54,7 +54,7 @@ QString SunnyWebBox::getPlantOverview()
if (!m_lastRequest.isNull()) {
// According to the documentation, the interval between 2 requests should not be less than 30 seconds.
if (QDateTime::currentDateTime().toMSecsSinceEpoch() - m_lastRequest.toMSecsSinceEpoch() < 30000) {
if (QDateTime::currentMSecsSinceEpoch() - m_lastRequest.toMSecsSinceEpoch() < 30000) {
return QString();
}
}