Index: sources/view/VDeviceInformation.cpp =================================================================== diff -u -r4c3c38d7f96cd63be776677bec5d1d0aa574611a -rfeb7724c8a7a2932650c5daa490c90923c9fbe77 --- sources/view/VDeviceInformation.cpp (.../VDeviceInformation.cpp) (revision 4c3c38d7f96cd63be776677bec5d1d0aa574611a) +++ sources/view/VDeviceInformation.cpp (.../VDeviceInformation.cpp) (revision feb7724c8a7a2932650c5daa490c90923c9fbe77) @@ -19,12 +19,15 @@ { // requests ADJUST_VIEW_CONNECTION(AdjustVersionsRequestData); + ADJUST_VIEW_CONNECTION(AdjustServiceRequestData); // responses ACTION_VIEW_CONNECTION(AdjustHDVersionsResponseData); ACTION_VIEW_CONNECTION(AdjustDGVersionsResponseData); ACTION_VIEW_CONNECTION(HDSerialNumberResponseData); ACTION_VIEW_CONNECTION(DGSerialNumberResponseData); + ACTION_VIEW_CONNECTION(AdjustHDServiceResponseData); + ACTION_VIEW_CONNECTION(AdjustDGServiceResponseData); init(); @@ -37,6 +40,7 @@ void VDeviceInformation::init() { doRequestHDDGVersions(); + doRequestServiceData(); mUIVersion(qApp->applicationVersion()); } @@ -83,9 +87,7 @@ return QStringList() << "HD Last Service Date" << "HD Next Service Date" << "DG Last Service Date" - << "DG Next Service Date" - << "Treatments" - << "Dialysate Liters"; + << "DG Next Service Date"; } /*! @@ -99,9 +101,7 @@ return QStringList() << mHDLastServiceDate() << mHDNextServiceDate() << mDGLastServiceDate() - << mDGNextServiceDate() - << QString("%1").arg(mTreatments()) - << QString("%1 L").arg(mDialysateLiters()); + << mDGNextServiceDate(); } /*! @@ -166,3 +166,44 @@ mDGSerialNumber(vData.serialNumber); } +/*! + * \brief VDeviceInformation::onActionReceive + * When the HD service response is received + * \param vData - (AdjustHDServiceResponseData) the version response + */ +void VDeviceInformation::onActionReceive(const AdjustHDServiceResponseData &vData) +{ + quint32 lastService = vData.mLastServiceDateEpoch; + quint32 nextService = vData.mLastServiceDateEpoch + vData.mServiceIntervalSeconds; + + mHDLastServiceDate(epochToString(lastService)); + mHDNextServiceDate(epochToString(nextService)); +} + +/*! + * \brief VDeviceInformation::onActionReceive + * When the DG service response is received + * \param vData - (AdjustDGServiceResponseData) the version response + */ +void VDeviceInformation::onActionReceive(const AdjustDGServiceResponseData &vData) +{ + quint32 lastService = vData.mLastServiceDateEpoch; + quint32 nextService = vData.mLastServiceDateEpoch + vData.mServiceIntervalSeconds; + + mDGLastServiceDate(epochToString(lastService)); + mDGNextServiceDate(epochToString(nextService)); +} + +/*! + * \brief VDeviceInformation::epochToString + * Converts an epoch to a formatted date and time + * \param vEpoch (quint32) the epoch + * \return (QString) the formatted date and time + */ +QString VDeviceInformation::epochToString(const quint32 &vEpoch) +{ + // This will have to be updated in Phase 2 when user can set the date and time format + // For now, default is (MM/DD/YYYY) + QDateTime dt = QDateTime::fromSecsSinceEpoch(vEpoch); + return dt.toString(QString("%1/%2/%3").arg(dt.date().month()).arg(dt.date().day()).arg(dt.date().year())); +}