Index: sources/cloudsync/CloudSyncController.cpp =================================================================== diff -u -r79a6cfcb10472261f3ec26eaf0baf6f1245cd311 -r7e503c5459ec77a2816d6c7789da9b206cedbe8a --- sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision 79a6cfcb10472261f3ec26eaf0baf6f1245cd311) +++ sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision 7e503c5459ec77a2816d6c7789da9b206cedbe8a) @@ -320,6 +320,8 @@ case eError_CredentialCopy : text = tr( "CS The credentials file copy failed." ) ; break; case eError_CredentialRemove: text = tr( "CS The credentials file remove failed." ) ; break; case eError_CredentialEmpty : text = tr( "CS The credentials folder is empty." ) ; break; + case eError_TxCodeNoParam : text = tr( "CS No Treatment Code provided." ) ; break; + case eError_TxCodeEmpty : text = tr( "CS The provided Treatment Code is empty." ) ; break; } return text; } @@ -359,6 +361,8 @@ case eError_CredentialCopy : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break; case eError_CredentialRemove: info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break; case eError_CredentialEmpty : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break; + case eError_TxCodeNoParam : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break; + case eError_TxCodeEmpty : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break; } return info; } @@ -564,13 +568,23 @@ // Same parameters will be sent for these messages for now, so data is not changed. switch (vAction) { - // case GuiActionType::ID_PreTreatmentStates : // has not been discussed how to be sent out. - // case GuiActionType::ID_TreatmentStates : // has not been discussed how to be sent out. - // 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 : - if (saveUIHistory(eMessageID_DeviceState , vData )) // if not empty, nor duplicate, and saved - sendUIHistory(eMessageID_DeviceState ); + case GuiActionType::ID_HDOperationModeData : { + // ---------------------------------------------------------------------------------------- + // DEBUG : disable the HD HW message on the device on CloudSync integration testing. + // currently it is always on fault and resets CloudSync inp log + QVariantList varData = vData; + QStringList strData = Format::fromVariantList(vData); + if ( strData.length() == 2 ) { + if ( strData[0] == "0" ) { + if ( strData[1] == "1") { varData = {0,0}; } // use Fault, wait4Tx instead of 0,0 to send fault. to able to simulate and bypass HD. + else { return; } + } + } + // ---------------------------------------------------------------------------------------- + + if (saveDeviceState(varData)) // if not empty, nor duplicate, and saved + sendDeviceState(); + } break; case GuiActionType::ID_AdjustSerialHDRsp : @@ -594,6 +608,7 @@ void CloudSyncController::onTreatmentLogSave(const QString &/*vDeviceID*/, const QString &/*vPatientID*/, const QString &vFileName) { QVariantList data { /*vDeviceID, vPatientID,*/ vFileName }; + 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 ); } @@ -617,19 +632,35 @@ case eMessageID_ResetFactory : ok = sendResetFactory ( ); break; case eMessageID_DeviceState : ok = sendDeviceState ( ); break; + case eMessageID_TxCodeDisplay : ok = sendTxCodeDisplay ( vMessage ); break; + case eMessageID_TxReport : /* No Req/Rsp, it is event based */ break; // This message doesn't have the response since there is no request. UI will send when the data ready by HD. } return ok; } /*! + * \brief CloudSyncController::saveDeviceState + * \details Saves the device state in the history for later request + * \param vData - the device information + * \return + */ +bool CloudSyncController::saveDeviceState(const QVariantList &vData) +{ + bool ok = false; + ok = saveUIHistory(eMessageID_DeviceState, vData); + return ok; +} + +/*! * \brief CloudSyncController::sendDeviceState * \return Sends the last received device state from history to CloudSync */ bool CloudSyncController::sendDeviceState() { bool ok = false; + sendCredentialsSend(); // TODO: This has to be removed later, it is a workaround for Cloud issue, during our talk with KBM. ok = sendUIHistory(eMessageID_DeviceState); return ok; } @@ -716,6 +747,30 @@ } /*! + * \brief CloudSyncController::sendTxCodeDisplay + * \details reads the received Tx Code from CloudSync app and notifies with a signal. + * \param vMessage : message containing the Tx Code. + * \return true on successful extracting the Tc Code. + */ +bool CloudSyncController::sendTxCodeDisplay(const CloudSyncController::Message &vMessage) +{ + bool ok = true; + QString mTxCode; + + // although it has been checked in the interpreter, we won't risk the crash and check the list empty. + if ( vMessage.params.isEmpty() ) { toLog(eError_TxCodeNoParam , {}); ok = false; goto lOut; } + + mTxCode = vMessage.params[0].trimmed(); + if ( mTxCode.isEmpty() ) { toLog(eError_TxCodeEmpty , {}); ok = false; goto lOut; } + + emit didTxCodeReceive ( mTxCode ); + qDebug() << " ---------- " << mTxCode; + +lOut: + return ok; +} + +/*! * \brief CloudSyncController::sendDeviceRegister * \details sends the device registration request * \return true on successful send.