Index: denali.pro =================================================================== diff -u -r9b54c54dbe75f2bd6d04ea73d48e1247682002e8 -rbcb57845e03fef70d9268623e93219cd160546ef --- denali.pro (.../denali.pro) (revision 9b54c54dbe75f2bd6d04ea73d48e1247682002e8) +++ denali.pro (.../denali.pro) (revision bcb57845e03fef70d9268623e93219cd160546ef) @@ -117,6 +117,7 @@ \ # Controllers sources/ApplicationController.h \ sources/device/DeviceController.h \ + sources/model/hd/data/post/MHDDateTimeData.h \ sources/storage/Settings.h \ sources/storage/TreatmentLog.h \ sources/wifi/WifiInterface.h \ @@ -387,6 +388,7 @@ \ # Controllers sources/ApplicationController.cpp \ sources/device/DeviceController.cpp \ + sources/model/hd/data/post/MHDDataTimeData.cpp \ sources/model/ui/data/MUIBloodPressureData.cpp \ sources/storage/Settings.cpp \ sources/storage/TreatmentLog.cpp \ Index: sources/ApplicationPost.cpp =================================================================== diff -u -r7c86f3854db9ad02d95681203198d75a0d65c9fa -rbcb57845e03fef70d9268623e93219cd160546ef --- sources/ApplicationPost.cpp (.../ApplicationPost.cpp) (revision 7c86f3854db9ad02d95681203198d75a0d65c9fa) +++ sources/ApplicationPost.cpp (.../ApplicationPost.cpp) (revision bcb57845e03fef70d9268623e93219cd160546ef) @@ -36,6 +36,7 @@ */ void ApplicationPost::start() { + QString postLogFileName = qApp->applicationDirPath() + "/" + Storage::POST_LOG; if (Storage::FileHandler::read(postLogFileName, _content)) { _isShaSum = checkShaSum (); Index: sources/canbus/MessageDispatcher.h =================================================================== diff -u -r159f2bb0317c7c3c0336e4cb80c7fef3f87e329a -rbcb57845e03fef70d9268623e93219cd160546ef --- sources/canbus/MessageDispatcher.h (.../MessageDispatcher.h) (revision 159f2bb0317c7c3c0336e4cb80c7fef3f87e329a) +++ sources/canbus/MessageDispatcher.h (.../MessageDispatcher.h) (revision bcb57845e03fef70d9268623e93219cd160546ef) @@ -163,6 +163,8 @@ GuiActionType::ID_TreatmentLogAvrgeData , GuiActionType::ID_TreatmentLogAlarmData , GuiActionType::ID_TreatmentLogEventData , + // POST HD->UI + GuiActionType::ID_HDDateTimeData , }; public slots: Index: sources/canbus/MessageGlobals.h =================================================================== diff -u -r159f2bb0317c7c3c0336e4cb80c7fef3f87e329a -rbcb57845e03fef70d9268623e93219cd160546ef --- sources/canbus/MessageGlobals.h (.../MessageGlobals.h) (revision 159f2bb0317c7c3c0336e4cb80c7fef3f87e329a) +++ sources/canbus/MessageGlobals.h (.../MessageGlobals.h) (revision bcb57845e03fef70d9268623e93219cd160546ef) @@ -64,6 +64,7 @@ {Gui::GuiActionType::ID_DGPostFinalResultData , 1 * 4 }, // 1 parameters each 4bytes {Gui::GuiActionType::ID_UIPostFinalResultData , 1 * 4 }, // 1 parameters each 4bytes {Gui::GuiActionType::ID_UIPostFinalResultHDReq , 0 * 4 }, // 0 parameters + {Gui::GuiActionType::ID_HDDateTimeData , 1 * 4 }, // 1 parameters each 4bytes // Service Mode {Gui::GuiActionType::ID_AdjustServiceModeReq , 0 * 4 }, // 0 parameters each 4bytes Index: sources/canbus/MessageInterpreter.cpp =================================================================== diff -u -r159f2bb0317c7c3c0336e4cb80c7fef3f87e329a -rbcb57845e03fef70d9268623e93219cd160546ef --- sources/canbus/MessageInterpreter.cpp (.../MessageInterpreter.cpp) (revision 159f2bb0317c7c3c0336e4cb80c7fef3f87e329a) +++ sources/canbus/MessageInterpreter.cpp (.../MessageInterpreter.cpp) (revision bcb57845e03fef70d9268623e93219cd160546ef) @@ -432,6 +432,7 @@ case Gui::GuiActionType::ID_HDPostSingleResultData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_HDPostSingleResultData ); break; case Gui::GuiActionType::ID_HDPostFinalResultData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_HDPostFinalResultData ); break; case Gui::GuiActionType::ID_UIPostFinalResultHDReq : ok = notify(vMessage, vData, Gui::GuiActionType::ID_UIPostFinalResultHDReq ); break; + case Gui::GuiActionType::ID_HDDateTimeData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_HDDateTimeData ); break; // ----- Settings case Gui::GuiActionType::ID_AdjustServiceModeRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustServiceModeRsp ); break; @@ -441,7 +442,6 @@ case Gui::GuiActionType::ID_AdjustServiceDatesHDRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustServiceDatesHDRsp ); break; case Gui::GuiActionType::ID_AdjustHDDateTimeRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustHDDateTimeRsp ); break; - // ----- States case Gui::GuiActionType::ID_HDOperationModeData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_HDOperationModeData ); break; case Gui::GuiActionType::ID_PreTreatmentStates : ok = notify(vMessage, vData, Gui::GuiActionType::ID_PreTreatmentStates ); break; Index: sources/gui/GuiGlobals.h =================================================================== diff -u -r159f2bb0317c7c3c0336e4cb80c7fef3f87e329a -rbcb57845e03fef70d9268623e93219cd160546ef --- sources/gui/GuiGlobals.h (.../GuiGlobals.h) (revision 159f2bb0317c7c3c0336e4cb80c7fef3f87e329a) +++ sources/gui/GuiGlobals.h (.../GuiGlobals.h) (revision bcb57845e03fef70d9268623e93219cd160546ef) @@ -115,6 +115,7 @@ ID_AdjustHDDateTimeRsp = 0x6E00, // 110 ID_AdjustDGDateTimeReq = 0x6F00, // 111 ID_AdjustDGDateTimeRsp = 0x7000, // 112 + ID_HDDateTimeData = 0x0A00, // 10 // State Messages ID_HDOperationModeData = 0x2500, // 37 Index: sources/model/MModel.h =================================================================== diff -u -r159f2bb0317c7c3c0336e4cb80c7fef3f87e329a -rbcb57845e03fef70d9268623e93219cd160546ef --- sources/model/MModel.h (.../MModel.h) (revision 159f2bb0317c7c3c0336e4cb80c7fef3f87e329a) +++ sources/model/MModel.h (.../MModel.h) (revision bcb57845e03fef70d9268623e93219cd160546ef) @@ -63,6 +63,7 @@ #include "MHDAirTrapData.h" #include "MHDBloodLeakData.h" #include "MHDAirBubbleData.h" +#include "MHDDateTimeData.h" // Debugging Messages #include "MHDDebugText.h" @@ -277,6 +278,7 @@ REGISTER_METATYPE( DGPostFinalResultData ) \ REGISTER_METATYPE( AdjustUIPostFinalResultRequestData ) \ REGISTER_METATYPE( UIPostFinalResultHDRequestData ) \ + REGISTER_METATYPE( HDDateTimeData ) \ /* Devices */ \ REGISTER_METATYPE( DeviceBrightnessRequestData ) \ REGISTER_METATYPE( DeviceBrightnessResponseData ) \ @@ -468,6 +470,7 @@ ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, DGPostSingleResultData ) \ ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, DGPostFinalResultData ) \ ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, UIPostFinalResultHDRequestData ) \ + ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, HDDateTimeData ) \ /* */ \ ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, SettingsData ) \ ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, HDOperationModeData ) \ @@ -654,6 +657,7 @@ ACTION_RECEIVE_BRIDGE_DEFINITION( HDPostFinalResultData ) \ ACTION_RECEIVE_BRIDGE_DEFINITION( DGPostSingleResultData ) \ ACTION_RECEIVE_BRIDGE_DEFINITION( DGPostFinalResultData ) \ + ACTION_RECEIVE_BRIDGE_DEFINITION( HDDateTimeData ) \ /* The slot implementation is different in Dispatcher, App, Gui, so only signal is here. */ \ ACTION_RECEIVE_SIGNAL ( UIPostFinalResultHDRequestData ) \ \ @@ -941,6 +945,7 @@ ACTION_RECEIVE_SIGNAL( DGPostSingleResultData ) \ ACTION_RECEIVE_SIGNAL( DGPostFinalResultData ) \ ACTION_RECEIVE_SIGNAL( UIPostFinalResultHDRequestData ) \ + ACTION_RECEIVE_SIGNAL( HDDateTimeData ) \ /* Received signals */ \ /* NO RESPONSE message model here */ \ ACTION_RECEIVE_SIGNAL( SettingsData ) \ Index: sources/model/hd/alarm/MAlarmMapping.cpp =================================================================== diff -u -re096005921a136cd711a77af3f918e05bfcccf3b -rbcb57845e03fef70d9268623e93219cd160546ef --- sources/model/hd/alarm/MAlarmMapping.cpp (.../MAlarmMapping.cpp) (revision e096005921a136cd711a77af3f918e05bfcccf3b) +++ sources/model/hd/alarm/MAlarmMapping.cpp (.../MAlarmMapping.cpp) (revision bcb57845e03fef70d9268623e93219cd160546ef) @@ -7,7 +7,7 @@ * * \file MAlarmMapping.cpp * \author (last) Behrouz NematiPour - * \date (last) 10-Jul-2023 + * \date (last) 12-Jul-2023 * \author (original) Behrouz NematiPour * \date (original) 03-May-2021 * Index: sources/model/hd/data/post/MHDDataTimeData.cpp =================================================================== diff -u --- sources/model/hd/data/post/MHDDataTimeData.cpp (revision 0) +++ sources/model/hd/data/post/MHDDataTimeData.cpp (revision bcb57845e03fef70d9268623e93219cd160546ef) @@ -0,0 +1,41 @@ +/*! + * + * Copyright (c) 2020-2023 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file MHDDateTimeData.cpp + * \author (last) Behrouz NematiPour + * \date (last) 17-Apr-2021 + * \author (original) Behrouz NemaiPour + * \date (original) 02-Jul-2020 + * + */ +#include "MHDDateTimeData.h" + +using namespace Model; + +QVariantList MHDDateTimeData::parameters() const { + return { + _data.mEpoch.value + }; +} + +bool MHDDateTimeData::fromByteArray(const QByteArray &vByteArray, int *vIndex) { + int index = 0; // message data start position + if (GetValue(vByteArray, index, _data.mEpoch )) + return true ; + else { if(vIndex) *vIndex = index; return false; } +} + +/*! + * \brief MHDDateTimeData::data + * \details Provides model's Data from the received messages data values + * \return Data + */ +MHDDateTimeData::Data MHDDateTimeData::data() const { + Data data; + data.mEpoch = _data.mEpoch .value; + return data; +} Index: sources/model/hd/data/post/MHDDateTimeData.h =================================================================== diff -u --- sources/model/hd/data/post/MHDDateTimeData.h (revision 0) +++ sources/model/hd/data/post/MHDDateTimeData.h (revision bcb57845e03fef70d9268623e93219cd160546ef) @@ -0,0 +1,81 @@ +/*! + * + * Copyright (c) 2022-2023 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file MHDAirTrapData.h + * \author (last) Behrouz NematiPour + * \date (last) 09-Mar-2022 + * \author (original) Michael Garthwaite + * \date (original) 23-Feb-2022 + * + */ +#pragma once + + +// Qt +#include + +// Project +#include "MAbstract.h" +#include "types.h" + +// forward declarations +class tst_models; + +namespace Model { + +/*! + * \brief The MHDDateTimeData class + * \details The HD datetime data model + * + * | MSG | CAN ID | Type | Ack | Src | Dst | Description | + * |:----:|:------:|:------:|:---:|:---:|:---:|:-----------: | + * |0x0A00| 0x020 | 1 Hz | N | HD | UI | HD datetime Data | + * + * | Payload || + * | || + * | #1:(U32) | \ref Data::mEpoch | + * + * \sa Data + * + *

Logging info

+ * | || + * | || + * | typeText | Datum | + * | unitText | HD | + * | infoText | Epoch | + * + */ +class MHDDateTimeData : public MAbstract { + + // friends + friend class ::tst_models; + + QVariantList parameters() const override; + + struct { + Types::U32 mEpoch; + } _data; + +public: + + Type_Enum typeText() const override { return Type_Enum::eDatum ; } + Unit_Enum unitText() const override { return Unit_Enum::eHD ; } + QString infoText() const override { return QString("HDDateTimeEpoch") ; } + + + struct Data { + quint32 mEpoch = 0; ///< HD datetime epoch + }; + + MHDDateTimeData () { } + bool fromByteArray (const QByteArray &vByteArray , int *vIndex = nullptr) override; + Data data ( ) const ; + +}; +} + +typedef Model::MHDDateTimeData::Data HDDateTimeData; Index: sources/view/settings/VDateTime.cpp =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -rbcb57845e03fef70d9268623e93219cd160546ef --- sources/view/settings/VDateTime.cpp (.../VDateTime.cpp) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/view/settings/VDateTime.cpp (.../VDateTime.cpp) (revision bcb57845e03fef70d9268623e93219cd160546ef) @@ -32,6 +32,7 @@ ACTION_VIEW_CONNECTION(AdjustDGDateTimeResponseData); ADJUST_VIEW_CONNECTION( AdjustHDDateTimeRequestData); ADJUST_VIEW_CONNECTION( AdjustDGDateTimeRequestData); + ACTION_VIEW_CONNECTION(HDDateTimeData); connect(&_process, SIGNAL( finished(int)), this, SLOT(onSetDateUIFinished(int))); @@ -75,25 +76,16 @@ day ( vDay ); hour ( vHour ); minute ( vMinute ); - quint32 epoch = - QDateTime( - QDate(_year .toInt() , - _month .toInt() , - _day .toInt()), - QTime(_hour .toInt() , - _minute .toInt()) - ).toSecsSinceEpoch(); - // the accepted format of the Linux data command: - // example: 2021-03-16 16:24:00 - QString mDateTime = QString("%1-%2-%3 %4:%5:%6") - .arg(_year ) - .arg(_month ) - .arg(_day ) - .arg(_hour ) - .arg(_minute) - .arg(_second); + const QDateTime currentDateTime ( QDate(_year .toInt() , + _month .toInt() , + _day .toInt()), + QTime(_hour .toInt() , + _minute .toInt())); + quint32 epoch = currentDateTime.toSecsSinceEpoch(); + QString mDateTime = currentDateTime.toString(_UIDateTimeStringFormat); + LOG_DEBUG(tr("SetDateTime %1").arg(mDateTime)); status("Setting date and time ..."); @@ -247,3 +239,26 @@ quint16 military = _currentDateTime.time().hour() * 100 + _currentDateTime.time().minute(); greeting(military); } + +/*! + * + * \brief VHDPOSTData::onActionReceive + * \details received response model data handler + * \param vData - model data + */ +void VDateTime::onActionReceive(const HDDateTimeData &vData) +{ + // Doing a single update of the HD-UI RTC sync on start-up + static bool _hasDoneHDSyncRTC = false; + if ( !_hasDoneHDSyncRTC ) { + QDateTime hdRTCTime; + hdRTCTime.setSecsSinceEpoch(vData.mEpoch); + + QString newDateTimeString = hdRTCTime.toString(_UIDateTimeStringFormat); + dateTimeUI(newDateTimeString); + + qDebug() << "Sync HD-UI RTC | HD Epoch: " << vData.mEpoch << " | datetime : " << newDateTimeString; + + _hasDoneHDSyncRTC = true; // indicate HD-UI RTC sync'd + } +} Index: sources/view/settings/VDateTime.h =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -rbcb57845e03fef70d9268623e93219cd160546ef --- sources/view/settings/VDateTime.h (.../VDateTime.h) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/view/settings/VDateTime.h (.../VDateTime.h) (revision bcb57845e03fef70d9268623e93219cd160546ef) @@ -24,6 +24,7 @@ #include "VAdjustmentResponseBase.h" #include "MAdjustHDDateTimeResponse.h" #include "MAdjustDGDateTimeResponse.h" +#include "MHDDateTimeData.h" // forward declarations @@ -63,6 +64,10 @@ void timerEvent(QTimerEvent *event) override; private: + // the accepted format of the Linux data command: + // example: 2021-03-16 16:24:00 + const char* _UIDateTimeStringFormat = "yyyy-MM-dd hh:mm:ss"; + QDateTime _currentDateTime ; int _timerInterval = 1000; // ms QProcess _process ; @@ -97,6 +102,7 @@ VIEW_DEC_CLASS(VDateTime) VIEW_DEC_SLOT (AdjustHDDateTimeResponseData) VIEW_DEC_SLOT (AdjustDGDateTimeResponseData) + VIEW_DEC_SLOT (HDDateTimeData) void greeting(quint16 vMilitaryTime);