refs #875, fixed PQ null for DBus

This commit is contained in:
Klaus Basan
2017-02-07 18:58:40 +01:00
committed by Mathew Sutcliffe
parent 3c588e61fa
commit b77c04c99c

View File

@@ -34,6 +34,8 @@
#include <QList> #include <QList>
#include <QString> #include <QString>
#include <QtGlobal> #include <QtGlobal>
#include <limits>
#include <cmath>
namespace BlackMisc namespace BlackMisc
{ {
@@ -159,7 +161,8 @@ namespace BlackMisc
template <class MU, class PQ> template <class MU, class PQ>
void CPhysicalQuantity<MU, PQ>::marshallToDbus(QDBusArgument &argument) const void CPhysicalQuantity<MU, PQ>::marshallToDbus(QDBusArgument &argument) const
{ {
argument << this->value(UnitClass::defaultUnit()); constexpr double NaN = std::numeric_limits<double>::quiet_NaN();
argument << (this->isNull() ? NaN : this->value(UnitClass::defaultUnit()));
// argument << this->m_value; // argument << this->m_value;
// argument << this->m_unit; // argument << this->m_unit;
} }
@@ -168,8 +171,13 @@ namespace BlackMisc
void CPhysicalQuantity<MU, PQ>::unmarshallFromDbus(const QDBusArgument &argument) void CPhysicalQuantity<MU, PQ>::unmarshallFromDbus(const QDBusArgument &argument)
{ {
argument >> this->m_value; argument >> this->m_value;
// argument >> this->m_unit;
this->m_unit = UnitClass::defaultUnit(); this->m_unit = UnitClass::defaultUnit();
if (std::isnan(this->m_value))
{
this->setNull();
}
// argument >> this->m_value;
// argument >> this->m_unit;
} }
template <class MU, class PQ> template <class MU, class PQ>
@@ -251,6 +259,7 @@ namespace BlackMisc
template <class MU, class PQ> template <class MU, class PQ>
void CPhysicalQuantity<MU, PQ>::setNull() void CPhysicalQuantity<MU, PQ>::setNull()
{ {
this->m_value = 0;
this->m_unit = MU::nullUnit(); this->m_unit = MU::nullUnit();
} }