Index: sources/cloudsync/CloudSyncController.cpp =================================================================== diff -u -r79e076cece4ba503be6c3834eb68d1e5cb1b882f -r75219a6e89b20f405aad0c12c5aed5937118b2ad --- sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision 79e076cece4ba503be6c3834eb68d1e5cb1b882f) +++ sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision 75219a6e89b20f405aad0c12c5aed5937118b2ad) @@ -312,6 +312,7 @@ case eError_ParamMismatch : text = tr( "CS Mismatch parameter count" ) ; break; case eError_ParamMissing : text = tr( "CS Missing parameter" ) ; break; case eError_NoHistory : text = tr( "CS No history available" ) ; break; + case eError_Duplicate : text = tr( "CS Duplicate data" ) ; break; case eError_LogFolder : text = tr( "CS The log folder cannot be created." ) ; break; case eError_LogFileInp : text = tr( "CS Error writing to the input file." ) ; break; case eError_CredentialFile : text = tr( "CS The credentials file does not exist." ) ; break; @@ -350,6 +351,7 @@ case eError_ParamMismatch : info = QString( "[%1:%2/%3]" ).arg( vErrorID ).arg( item(0) ).arg( item(1) ) ; break; case eError_ParamMissing : info = QString( "[%1:%2/%3]" ).arg( vErrorID ).arg( item(0) ).arg( item(1) ) ; break; case eError_NoHistory : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break; + case eError_Duplicate : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break; case eError_LogFolder : ; break; case eError_LogFileInp : ; break; case eError_CredentialFile : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break; @@ -431,10 +433,21 @@ .arg( msg ) .arg( len ) .arg( prm ) - ; + ; } /*! + * \brief CloudSyncController::isDuplicate + * \param vMessage - current action/messageID received. + * \param vData - current data to compare with the history + * \return true if duplicate + */ +bool CloudSyncController::isDuplicate(const qint32 vMessageID, const QStringList &vData) +{ + return _uiHistory.contains(vMessageID) && _uiHistory[vMessageID] == vData; +} + +/*! * \brief CloudSyncController::writeInpFile * \details Writes to the CS Input buffer * \param vBuffer - the string out buffer. @@ -497,12 +510,12 @@ qint32 messageID = UI2CS(static_cast(vAction)); QStringList data; - if ( vData.isEmpty() ) { error = eError_NoHistory; args = { messageID }; ok = false; goto lErr; } + if ( vData.isEmpty() ) { error = eError_NoHistory; args = { messageID }; ok = false; goto lErr; } - // convert the data to string list - for (auto datum : vData) { - data += datum.toString(); - } + data = Format::fromVariantList(vData); + + if ( isDuplicate(messageID, data) ) { error = eError_Duplicate; args = { messageID }; ok = false; return ok; } // goto lErr; } don't log it just ignore and return false. + // store the last message data _uiHistory[messageID] = data; @@ -556,8 +569,8 @@ // case GuiActionType::ID_PostTreatmentStates : // has not been discussed how to be sent out. // case GuiActionType::ID_DisinfectStates : // has not been discussed how to be sent out. case GuiActionType::ID_HDOperationModeData : - saveUIHistory(eMessageID_DeviceState , vData ); - sendUIHistory(eMessageID_DeviceState ); // can be removed if CS doesn't need it. + if (saveUIHistory(eMessageID_DeviceState , vData )) // if not empty, nor duplicate, and saved + sendUIHistory(eMessageID_DeviceState ); break; case GuiActionType::ID_AdjustSerialHDRsp :