Index: sources/cloudsync/CloudSyncController.cpp =================================================================== diff -u -r80250cfdbe58a3df17950d342212f155d52d3971 -r72a7f822f243d779f0d23e8060671dc59aacc748 --- sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision 80250cfdbe58a3df17950d342212f155d52d3971) +++ sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision 72a7f822f243d779f0d23e8060671dc59aacc748) @@ -23,8 +23,8 @@ #include "GuiController.h" #include "DeviceController.h" #include "FileHandler.h" +#include "crc.h" - /*! * \brief CloudSyncController::CloudSyncController * \details Constructor @@ -203,9 +203,9 @@ if ( count < eMessage_Count ) { error = eError_Count ; ok = false; goto lErr; } index = eMessage_Timestamp ; message.timestamp = items[index].toInt (&ok); if (!ok) { error = eError_Timestamp ; ok = false; goto lErr; } index = eMessage_Sequence ; message.sequence = items[index].toUInt(&ok); if (!ok) { error = eError_Sequence ; ok = false; goto lErr; } + index = eMessage_CRC ; message.crc = items[index].toUInt(&ok); if (!ok) { error = eError_CRC ; ok = false; goto lErr; } index = eMessage_MessageID ; message.id = items[index].toInt (&ok); if (!ok) { error = eError_MessageID ; ok = false; goto lErr; } index = eMessage_ParamCount; message.paramCount = items[index].toInt (&ok); if (!ok) { error = eError_ParamCount ; ok = false; goto lErr; } - index = eMessage_CRC ; message.crc = items[index].toUInt(&ok); if (!ok) { error = eError_CRC ; ok = false; goto lErr; } // check the parameters count if ( count - eMessage_Count < message.paramCount ) { error = eError_Parameter ; ok = false; goto lErr; } @@ -224,9 +224,9 @@ case eError_Count : args = { count , eMessage_Count }; break; case eError_Timestamp : args = { items[index].trimmed() }; break; case eError_Sequence : args = { items[index].trimmed() }; break; + case eError_CRC : args = { items[index].trimmed() }; break; case eError_MessageID : args = { items[index].trimmed() }; break; case eError_ParamCount : args = { items[index].trimmed() }; break; - case eError_CRC : args = { items[index].trimmed() }; break; case eError_Parameter : args = { count - eMessage_Count , message.paramCount }; break; default : break; } @@ -249,9 +249,9 @@ case eError_Count : text = tr( "E,CS,Incorrect header" ) ; break; case eError_Timestamp : text = tr( "E,CS,Incorrect timestamp" ) ; break; case eError_Sequence : text = tr( "E,CS,Incorrect sequence" ) ; break; + case eError_CRC : text = tr( "E,CS,Incorrect CRC" ) ; break; case eError_MessageID : text = tr( "E,CS,Incorrect ID" ) ; break; case eError_ParamCount : text = tr( "E,CS,Incorrect parameter length" ) ; break; - case eError_CRC : text = tr( "E,CS,Incorrect CRC" ) ; break; case eError_Parameter : text = tr( "E,CS,Incorrect parameter count" ) ; break; case eError_NoHistory : text = tr( "E,CS,No history available for the request" ) ; break; case eError_LogFolder : text = tr( "E,CS,The log folder cannot be created." ) ; break; @@ -272,9 +272,9 @@ case eError_Count : info = QString( "[%1:%2/%3]" ).arg( vErrorID ).arg( item(0) ).arg( item(1) ) ; break; case eError_Timestamp : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break; case eError_Sequence : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break; + case eError_CRC : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break; case eError_MessageID : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break; case eError_ParamCount : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break; - case eError_CRC : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break; case eError_Parameter : 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; default : info = QString( "[%1]" ).arg( vErrorID ) ; break; @@ -351,12 +351,14 @@ bool ok = true; QVariantList args ; Errors_Enum error = eError_OK; + quint8 crc = 0; // no crc generation for now. QString inpBuff; _date_inp_File = _location + // The location _dateFormatted + _dateSeparator + _inp_File; // The file name inpBuff = QString::number(_secSinceEpoch); inpBuff += _separator + QString::number(_seq++); + inpBuff += _separator + QString::number(crc); inpBuff += _separator + vData; inpBuff += '\n'; @@ -383,7 +385,10 @@ Errors_Enum error = eError_OK; if ( ! _lastReceivedData.contains( vAction ) ) { error = eError_NoHistory; args = { vAction }; ok = false; goto lErr; } - sendUIBuff(QString("%1,%2").arg(vAction).arg(_lastReceivedData[ vAction ].join(_separator))); + sendUIBuff(QString("%1,%2,%3") + .arg(vAction) + .arg(_lastReceivedData[ vAction ].count()) + .arg(_lastReceivedData[ vAction ].join(_separator))); return ok; @@ -400,8 +405,6 @@ */ void CloudSyncController::onActionReceive(GuiActionType vAction, const QVariantList &vData) { - QString inpBuff; - // convert the data to the string list store/fetching it out from history. // the original vData will be used if their actual values needed. QStringList data; @@ -419,12 +422,7 @@ // store the last message data _lastReceivedData[eMessageID_DeviceState] = data; - - // prepare the buffer - inpBuff = QString::number(eMessageID_DeviceState); - for (auto var : vData) - { inpBuff += _separator + var.toString(); } - if ( ! sendUIBuff(inpBuff) ) break; + sendUIHistory (eMessageID_DeviceState); default: break; } Index: sources/cloudsync/CloudSyncController.h =================================================================== diff -u -r80250cfdbe58a3df17950d342212f155d52d3971 -r72a7f822f243d779f0d23e8060671dc59aacc748 --- sources/cloudsync/CloudSyncController.h (.../CloudSyncController.h) (revision 80250cfdbe58a3df17950d342212f155d52d3971) +++ sources/cloudsync/CloudSyncController.h (.../CloudSyncController.h) (revision 72a7f822f243d779f0d23e8060671dc59aacc748) @@ -73,9 +73,9 @@ eError_Count , eError_Timestamp , eError_Sequence , + eError_CRC , eError_MessageID , eError_ParamCount , - eError_CRC , eError_Parameter , eError_NoHistory , @@ -90,19 +90,19 @@ enum Message_Enum { eMessage_Timestamp , eMessage_Sequence , + eMessage_CRC , eMessage_MessageID , eMessage_ParamCount , - eMessage_CRC , eMessage_Count , }; typedef QStringList Params; struct Message { qint64 timestamp = 0; quint32 sequence = 0; + quint8 crc = 0; qint32 id = 0; qint64 paramCount = 0; - quint8 crc = 0; Params params { }; }; Index: sources/model/hd/alarm/MAlarmMapping.cpp =================================================================== diff -u -rd35857defcdfb3ab07573a90ca57997bb825463e -r72a7f822f243d779f0d23e8060671dc59aacc748 --- sources/model/hd/alarm/MAlarmMapping.cpp (.../MAlarmMapping.cpp) (revision d35857defcdfb3ab07573a90ca57997bb825463e) +++ sources/model/hd/alarm/MAlarmMapping.cpp (.../MAlarmMapping.cpp) (revision 72a7f822f243d779f0d23e8060671dc59aacc748) @@ -7,7 +7,7 @@ * * \file MAlarmMapping.cpp * \author (last) Behrouz NematiPour - * \date (last) 11-Dec-2021 + * \date (last) 13-Dec-2021 * \author (original) Behrouz NematiPour * \date (original) 03-May-2021 *