Index: denali.pro.user =================================================================== diff -u -rb35749f48a7d6801bc0257cfe6c4762b6a38aeb7 -r5967e3c458599ea7af0f298e844eef89004acb03 --- denali.pro.user (.../denali.pro.user) (revision b35749f48a7d6801bc0257cfe6c4762b6a38aeb7) +++ denali.pro.user (.../denali.pro.user) (revision 5967e3c458599ea7af0f298e844eef89004acb03) @@ -1,6 +1,6 @@ - + EnvironmentId @@ -93,7 +93,7 @@ Qt 5.15.10 (iMX8) Qt 5.15.10 (iMX8) {ada4083c-13b6-4ac8-a486-71ff00b060da} - 0 + 1 0 0 @@ -263,15 +263,15 @@ RemoteLinux.DirectUploadStep /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Debug/denali - /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Release/denali /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Debug/denali /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Debug/denali + /home/denali/Projects/tmp/build/build-denali-Qt_5_15_10_iMX8-Release/denali 192.168.10.186 + 192.168.10.186 192.168.10.228 192.168.10.228 - 192.168.10.186 /home/root @@ -287,15 +287,15 @@ 2023-01-18T20:13:36.296 - 2023-01-17T18:06:25.579 - 2023-01-17T18:18:03.749 2023-01-18T17:47:08.797 + 2023-01-17T18:18:03.749 + 2023-01-17T18:06:25.579 2023-01-18T20:13:33.000 - 2023-01-17T18:05:42.000 - 2023-01-17T18:17:25.000 2023-01-18T17:47:04.000 + 2023-01-17T18:17:25.000 + 2023-01-17T18:05:42.000 2 @@ -347,6 +347,7 @@ true + 0 0 /home/denali/Projects/application/imake.sh %{sourceDir} ProjectExplorer.ProcessStep @@ -389,7 +390,6 @@ false false - --disable-alarm-no-minimize Debug Qt4ProjectManager.Qt4BuildConfiguration Index: imake.sh =================================================================== diff -u -r6210028a421d6259963bf172efbe4f23abfecf2f -r5967e3c458599ea7af0f298e844eef89004acb03 --- imake.sh (.../imake.sh) (revision 6210028a421d6259963bf172efbe4f23abfecf2f) +++ imake.sh (.../imake.sh) (revision 5967e3c458599ea7af0f298e844eef89004acb03) @@ -22,7 +22,7 @@ fi if [[ "$2" == "0" ]]; then - echo " ********** skipped the cppcheck call **********" + echo " ********** skipped the cppcheck call **********" else ./cppcheck.sh fi Index: sources/cloudsync/CloudSyncController.cpp =================================================================== diff -u -r928a1ed5d70358fc00c49df45725f989d16c370e -r5967e3c458599ea7af0f298e844eef89004acb03 --- sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision 928a1ed5d70358fc00c49df45725f989d16c370e) +++ sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision 5967e3c458599ea7af0f298e844eef89004acb03) @@ -95,8 +95,8 @@ this , SLOT( onWatchFileChange (const QString &))); connect(&_MessageDispatcher , SIGNAL(didActionReceive (GuiActionType , const QVariantList &)), this , SLOT( onActionReceive (GuiActionType , const QVariantList &))); - connect(&_TreatmentLog , SIGNAL(didTreatmentLogSave(const QString &, const QString &, const QString &)), - this , SLOT( onTreatmentLogSave(const QString &, const QString &, const QString &))); + connect(&_TreatmentLog , SIGNAL(didTxPending (const QString &)), + this , SLOT( onTxPending (const QString &))); connect(this , SIGNAL(didInitComplete ()), this , SLOT( onInitComplete ()),Qt::QueuedConnection); // it has to be queued connection, don't remove it. } @@ -148,7 +148,6 @@ // a simple touch or a check-in message? testWatchBuffDate(); testDeviceInfoWait(); - testPendingTxReports(); } /*! @@ -637,19 +636,12 @@ } } -/*! - * \brief CloudSyncController::onTreatmentLogSave - * \details The slot being called when the TreatmentLogController notifies the CloudSyncController, about the treatment log being successfully saved. - * \param vDeviceID - Device ID - * \param vPatientID - Patient ID - * \param vFileName - The complete Treatment log path and file name. - */ -void CloudSyncController::onTreatmentLogSave(const QString &/*vDeviceID*/, const QString &/*vPatientID*/, const QString &vFileName) +void CloudSyncController::onTxPending(const QString &vFileName) { - QVariantList data { /*vDeviceID, vPatientID,*/ vFileName }; + // if (! isRegistered() ) return; + qint32 messageID = UI2CS(static_cast( eMessageID_TxReport )); sendCredentialsSend(); // TODO: This has to be removed later, it is a workaround for Cloud issue, during our talk with KBM. - saveUIHistory(eMessageID_TxReport, data ); - sendUIHistory(eMessageID_TxReport ); + sendUIBuff(makeUIBuff( messageID , { vFileName } )); } /*! @@ -706,13 +698,6 @@ return ok; } -void CloudSyncController::testPendingTxReports() -{ - QFileInfoList fileInfos; - fileInfos = Storage::FileHandler::find(_TreatmentLog.logPathPending(), {"*.log"}); - qDebug() << fileInfos; -} - /*! * \brief CloudSyncController::doResetFactory * \details does the reset factory Index: sources/cloudsync/CloudSyncController.h =================================================================== diff -u -r928a1ed5d70358fc00c49df45725f989d16c370e -r5967e3c458599ea7af0f298e844eef89004acb03 --- sources/cloudsync/CloudSyncController.h (.../CloudSyncController.h) (revision 928a1ed5d70358fc00c49df45725f989d16c370e) +++ sources/cloudsync/CloudSyncController.h (.../CloudSyncController.h) (revision 5967e3c458599ea7af0f298e844eef89004acb03) @@ -199,7 +199,7 @@ private slots: void onWatchFileChange (const QString &vFile); void onActionReceive (GuiActionType vAction, const QVariantList &vData); - void onTreatmentLogSave(const QString &vDeviceID , const QString &vPatientID , const QString &vFileName ); + void onTxPending (const QString &vFileName ); void onInitComplete (); signals: @@ -260,9 +260,6 @@ bool saveDeviceState (const QVariantList &vData); bool sendDeviceState (); // eMessageID_DeviceState - // Tx Report - void testPendingTxReports (); // eMessageID_TxReport - // reset Factory bool doResetFactory (); // eMessageID_ResetFactory bool sendResetFactory (); // eMessageID_ResetFactory Index: sources/storage/TreatmentLog.cpp =================================================================== diff -u -r6210028a421d6259963bf172efbe4f23abfecf2f -r5967e3c458599ea7af0f298e844eef89004acb03 --- sources/storage/TreatmentLog.cpp (.../TreatmentLog.cpp) (revision 6210028a421d6259963bf172efbe4f23abfecf2f) +++ sources/storage/TreatmentLog.cpp (.../TreatmentLog.cpp) (revision 5967e3c458599ea7af0f298e844eef89004acb03) @@ -43,6 +43,7 @@ TreatmentLog::TreatmentLog(QObject *parent) : QObject(parent) { initConnections(); logPath(Logger::eLogTrtmt, _Logger.logPath(Logger::eLogTrtmt)); + startTimer(_interval); } @@ -65,6 +66,15 @@ } /*! + * \brief TreatmentLog::timerEvent + * \details The overloaded method of the main class to capture the QObject timer. + */ +void TreatmentLog::timerEvent(QTimerEvent *) +{ + testPendingTxReports(); +} + +/*! * \brief TreatmentLog::initModel * Initializing the model for the constant values. * \param vData - the response model data. @@ -322,6 +332,9 @@ _treatmentLogAlarmData.clear(); _treatmentLogEventData.clear(); _lastTxInfo.mStatus = ok; + + sendPending(); // reset the timer to find the latest saved pending and ask for Tx Code. + return ok; } @@ -333,10 +346,6 @@ { LOG_DEBUG(QString("Save Treatment Log Ended: %1").arg(_saveWatcher.result())); isIdle(true); - if ( _lastTxInfo.mStatus ) - emit didTreatmentLogSave( _lastTxInfo.mDeviceID , - _lastTxInfo.mPatientID , - _lastTxInfo.mFileName ); } // ----- Export @@ -415,8 +424,17 @@ void TreatmentLog::onTxCodeReceive(const QString &vTxCode) { _txCode = vTxCode; + // This has to be checked before the addTxCode, + // because that function will change the _lastTxInfo.mFilename after it is moved from pending. + bool isLastTxInfo = ! _lastTxInfo.mFileName.isEmpty() && _pendingTx == _lastTxInfo.mFileName; + + // getting the Tx out of pending and add the received Tx in the file addTxCode(); - emit didTxCodeReceive(_txCode); + + if ( isLastTxInfo ) { + // avoid updating the screen with another pending Tx in queue + emit didTxCodeReceive(_txCode); + } } /*! @@ -427,7 +445,7 @@ bool TreatmentLog::addTxCode() { bool ok = true; - QString src = _lastTxInfo.mFileName; + QString src = _pendingTx; QString dst = _treatmentLogPath + QFileInfo(src).fileName(); QString logContent; ADDTITLE("Title"); @@ -450,5 +468,49 @@ LOG_DEBUG(QString("Couldn't remove pending treatment log file '%1'").arg(src)); return ok; } + _lastTxInfo.mFileName = dst; // Update the last Tx file to the new location [ export ] + sendPending(); // start looking for the next pending, instead of waiting to timeout return ok; } + +/*! + * \brief TreatmentLog::sendPending + * \details Resets the pending counter to immediately/ASAP as for the pending and won't waits for the timeout. + */ +void TreatmentLog::sendPending() +{ + _pendingCounter = 0; +} + +/*! + * \brief TreatmentLog::testPendingTxReports + * \details this function count downs for the _pendingInterval + * when the _pendingCounter reaches 0 will search for the files + * in the _TreatmentLog.logPathPending() + * and if there is any will get the recent file in the list + * and asks for the TxCode by emitting the didTxPending signal + */ +void TreatmentLog::testPendingTxReports() +{ + qDebug() << _pendingCounter; + if ( _pendingCounter ) { + _pendingCounter -- ; + return; + } + else { + _pendingCounter = _pendingInterval; // every minute + } + + QFileInfoList pendingFiles; + pendingFiles = Storage::FileHandler::find(_TreatmentLog.logPathPending(), {"*.log"}); + // look into the list. + // if there are pending files, + // send a request only for the top on the list + // * When gets the Tx Code, moves from pending then next one comes to top + // the process repeats until there is no file in pending + if ( pendingFiles.count() ) { + // the most recent/first Tx file, to first ask for the current treatment which has just saved as pending on screen + _pendingTx = pendingFiles.first().absoluteFilePath(); + emit didTxPending( _pendingTx ); + } +} Index: sources/storage/TreatmentLog.h =================================================================== diff -u -r928a1ed5d70358fc00c49df45725f989d16c370e -r5967e3c458599ea7af0f298e844eef89004acb03 --- sources/storage/TreatmentLog.h (.../TreatmentLog.h) (revision 928a1ed5d70358fc00c49df45725f989d16c370e) +++ sources/storage/TreatmentLog.h (.../TreatmentLog.h) (revision 5967e3c458599ea7af0f298e844eef89004acb03) @@ -40,6 +40,10 @@ { Q_OBJECT + const int _interval = 1000; // 1s + const int _pendingInterval= 60 ; // 1m + int _pendingCounter = 0 ; // + QString _treatmentLogPath; QString _treatmentLogPath_Pending; @@ -76,11 +80,12 @@ QString mPatientID = ""; QString mFileName = ""; } - _lastTxInfo; + _lastTxInfo; - QString _deviceID = ""; - QString _txCode = ""; // content of this value comes from CloudSync App. + QString _deviceID = ""; + QString _txCode = ""; // content of this value comes from CloudSync App. + QString _pendingTx = ""; enum Role { eValue, @@ -215,10 +220,17 @@ bool exportLog (); void exportLogConcurrent(); bool addTxCode(); + void sendPending(); + // Pending Tx Report + void testPendingTxReports (); // eMessageID_TxReport + NOTIFIER(isIdle) SINGLETON(TreatmentLog) +protected: + void timerEvent(QTimerEvent *) override; + public: void initModel(const AdjustTreatmentLogResponseData &vData, const QString &vPatientID); @@ -244,12 +256,10 @@ void doExport (); signals: - void didTreatmentLogSave( const QString &vDeviceID , - const QString &vPatientID , - const QString &vFileName ); - void didTxCodeReceive ( const QString &vTxCode ); + void didTxPending ( const QString &vFileName ); + void didTxCodeReceive ( const QString &vTxCode ); - void didNotification ( const QString &vNotification); + void didNotification ( const QString &vNotification ); }; }