Index: sources/canbus/MessageInterpreter.cpp =================================================================== diff -u -rfe9459548d7b0f6c1d8cb77c0e23d7a385b48fa2 -r80b8371f1a93481e05302cef6e474db802fda153 --- sources/canbus/MessageInterpreter.cpp (.../MessageInterpreter.cpp) (revision fe9459548d7b0f6c1d8cb77c0e23d7a385b48fa2) +++ sources/canbus/MessageInterpreter.cpp (.../MessageInterpreter.cpp) (revision 80b8371f1a93481e05302cef6e474db802fda153) @@ -19,12 +19,9 @@ // #include // Project -#include "Logger.h" #include "format.h" -#include "Settings.h" using namespace Can; -using namespace Model; #define DISABLE_CHECKIN_LOG 0 #define DEBUG_SIGNAL(vID, vMODEL) // qDebug() << vID << vMODEL; @@ -33,7 +30,7 @@ // would be better later to be replaced by a template method // like the notify method of received messages #define INTERPRET_TRANSMIT_MESSAGE(vMODEL) \ - if ( ! length ) { logInvalidLength(vActionId); return false; } \ + if ( ! length ) { logInvalidLength(); return false; } \ vCanId = vMODEL::canid(); \ vPayload = Format::fromVariant(vData); \ LOG_APPED_MSG(vActionId, vMODEL::toString(vData)); \ @@ -42,7 +39,7 @@ // another version of the INTERPRET_TRANSMIT_MESSAGE for empty messages // same later improvements apply to this MACRO as well. #define INTERPRET_TRSMT_MT_MESSAGE(vMODEL) \ - if ( length ) { logInvalidLength(vActionId); return false; } \ + if ( length ) { logInvalidLength(); return false; } \ vCanId = vMODEL::canid(); \ vPayload = Format::fromVariant(vData); \ LOG_APPED_MSG(vActionId, vMODEL::toString(vData)); \ @@ -68,11 +65,10 @@ * \return true on successful check and prepare. */ template -bool MessageInterpreter::notify(const Message &vMessage, QVariantList &vData, Gui::GuiActionType vIdCheck) +bool MessageInterpreter::notify(const Message &vMessage, QVariantList &vData) { bool ok = false; TModel tModel; - if ( ! isValidMessage(vMessage, vIdCheck) ) return ok; ok = tModel.fromByteArray(vMessage.data); tModel.toVariantList(vData); // disabled coco begin validated : Tested manually. This code will never go false @@ -81,8 +77,8 @@ if ( ! ok ) return false; // disabled coco end emit didActionReceive(tModel.data()); - LOG_APPED_MSG(vIdCheck, tModel.toString()); - DEBUG_SIGNAL(vIdCheck, typeid(TModel).name()) + //LOG_APPED_MSG(vIdCheck, tModel.toString()); // TODO is this needed? + //DEBUG_SIGNAL(vIdCheck, typeid(TModel).name()) // TODO is this needed? return ok; } @@ -93,15 +89,18 @@ * \param vType - The type of the message to be checked against * \return true on correct type */ -bool MessageInterpreter::isType(const Message &vMessage, Gui::GuiActionType vType) const +bool MessageInterpreter::isType(const Message &vMessage) const { + Q_UNUSED(vMessage); + /* if ( vMessage.actionId != vType ) { LOG_DEBUG(QString("Incorrect expected ID '%1', got '%2'") .arg(vType) .arg(vMessage.actionId) ); return false; } + */ return true; } @@ -116,22 +115,25 @@ * \param vType - The type of the message to be checked against * \return true on correct data length for the type vType */ -bool MessageInterpreter::isPayloadLenValid(const Message &vMessage, Gui::GuiActionType vType) const +bool MessageInterpreter::isPayloadLenValid(const Message &vMessage) const { int len = vMessage.data.length(); - QString mActionIdHexString = Format::toHexString(vMessage.actionId); - if ( ! payloadLen.contains(vType) ) { - LOG_DEBUG(QString("Undefined data length for received Message with ID '%1'").arg(mActionIdHexString)); + QString mActionIdHexString = Format::toHexString(0); + Q_UNUSED(mActionIdHexString); + Q_UNUSED(len); + /*if ( ! payloadLen.contains(vType) ) { + LOG_DEBUG(QString("Undefined data length for received Message with ID '%1'").arg(mActionIdHexString)); // TODO is this needed? return false; } if ( len < payloadLen[vType] ) { - LOG_DEBUG(QString("Incorrect data length (%2 of %3) for received Message with ID '%1'") + LOG_DEBUG(QString("Incorrect data length (%2 of %3) for received Message with ID '%1'") // TODO is this needed? .arg(mActionIdHexString) .arg(len) .arg(payloadLen[vType]) ); return false; } + */ return true; } @@ -140,11 +142,10 @@ * \details Logs invalid data length for the message type vActionId * \param vActionId - Message Type */ -void MessageInterpreter::logInvalidLength(const Gui::GuiActionType &vActionId) +void MessageInterpreter::logInvalidLength() { - QString mActionIdHexString = Format::toHexString(vActionId); - LOG_DEBUG(QString("Incorrect data length for transmit message with ID '%1'") - .arg(mActionIdHexString)); + //LOG_DEBUG(QString("Incorrect data length for transmit message with ID '%1'") + // .arg(mActionIdHexString)); // TODO is this needed? } /*! @@ -154,10 +155,11 @@ * \param vType - The type of the message to be checked against * \return true on valid massage */ -bool MessageInterpreter::isValidMessage(const Message &vMessage, Gui::GuiActionType vType) const +bool MessageInterpreter::isValidMessage(const Message &vMessage) const { - if ( ! isType (vMessage, vType) ) return false; - if ( ! isPayloadLenValid(vMessage, vType) ) return false; + Q_UNUSED(vMessage); + //if ( ! isType (vMessage, vType) ) return false; + //if ( ! isPayloadLenValid(vMessage, vType) ) return false; return true; } @@ -171,14 +173,14 @@ void MessageInterpreter::printUnhandled(const Message &vMessage) const { if ( logUnhandledMessage(vMessage)) return; // the message is defined as unhandled and can still be handled and logged, return. - if ( gDisableUnhandledReport ) return; // if the unhandled message error has been disabled, return. - QString mActionIdHexString = Format::toHexString(vMessage.actionId, false, eLenMessageIDDigits); + //if ( gDisableUnhandledReport ) return; // if the unhandled message error has been disabled, return. + QString mActionIdHexString = Format::toHexString(0, false, 0); QString logMessage = tr("Unhandled Message ID (HD)") + '\n' + QString("%1 # %2 %3") - .arg(int(vMessage.can_id), 3, 16, QChar('0')) + .arg(int(0), 3, 16, QChar('0')) .arg(mActionIdHexString) .arg(QString(vMessage.data.toHex('.'))).toUpper(); - LOG_DEBUG(logMessage); + //LOG_DEBUG(logMessage); // TODO is this needed? } /*! @@ -193,109 +195,14 @@ * \return true if the vActionId is valid. * This return value will be used later for error handling. */ -bool MessageInterpreter::interpretMessage(const Gui::GuiActionType &vActionId, const QVariantList &vData, QByteArray &vPayload, Can_Id &vCanId) +bool MessageInterpreter::interpretMessage(const QVariantList &vData, QByteArray &vPayload, Can_Id &vCanId) { + Q_UNUSED(vData); bool ok = true; if (vCanId == Can::Can_Id::eChlid_NONE ) vCanId = Can::Can_Id::eChlid_UI_HD ; vPayload.clear(); - int length = vData.length(); - // DEBUG: LOG_EVENT(QString("0x%0").arg(vActionId, 4, 16,QChar('0'))); - switch (vActionId) { // notice we are in transmit mode - case Gui::GuiActionType::ID_Acknow: // len: 0, can have zero len - break; // No data, Just registered - - case Gui::GuiActionType::ID_KeepAlive: // len: 255, can have any len - if ( length ) { // this message has a variable length - vPayload = Format::fromVariant(vData.first()); - } - if ( ! gDisableCheckInLog ) { - LOG_APPED_UI(QString("CheckIn")); - } - break; - - case Gui::GuiActionType::ID_RawData: // len: 255, can have any len - if ( length ) { // this message has a variable length - vPayload = Format::fromVariant(vData.first()); - } - LOG_APPED_UI(QString("RawData")); - break; - - // Generic Confirm - case Gui::GuiActionType::ID_DuetConfirmUIr : INTERPRET_TRANSMIT_MESSAGE(DuetConfirmUIrData ); break; - // RO Water - case Gui::GuiActionType::ID_DuetRoWaterModeUIi : INTERPRET_TRANSMIT_MESSAGE(DuetRoWaterModeUIiData ); break; - // Power Off - case Gui::GuiActionType::ID_PowerOff : INTERPRET_TRANSMIT_MESSAGE(AdjustPowerOffRequestData ); break; - // POST - case Gui::GuiActionType::ID_UIPostFinalResultData : INTERPRET_TRANSMIT_MESSAGE(AdjustUIPostFinalResultRequestData ); break; - // Settings - case Gui::GuiActionType::ID_AdjustServiceModeReq : INTERPRET_TRSMT_MT_MESSAGE(AdjustServiceModeRequestData ); break; - case Gui::GuiActionType::ID_AdjustVersionsUIRsp : INTERPRET_TRANSMIT_MESSAGE(AdjustVersionsResponseData ); break; - case Gui::GuiActionType::ID_AdjustVersionsUIReq : INTERPRET_TRANSMIT_MESSAGE(AdjustVersionsRequestData ); break; - case Gui::GuiActionType::ID_AdjustHDDateTimeReq : INTERPRET_TRANSMIT_MESSAGE(AdjustHDDateTimeRequestData ); break; - case Gui::GuiActionType::ID_AdjustDGDateTimeReq : INTERPRET_TRANSMIT_MESSAGE(AdjustDGDateTimeRequestData ); break; - case Gui::GuiActionType::ID_AdjustServiceDatesReq : INTERPRET_TRSMT_MT_MESSAGE(AdjustServiceDatesRequestData ); break; - case Gui::GuiActionType::ID_HDUsageInfoReq : INTERPRET_TRSMT_MT_MESSAGE(HDUsageInfoRequestData ); break; - case Gui::GuiActionType::ID_AdjustInstitutionalRecordReq : INTERPRET_TRSMT_MT_MESSAGE(AdjustInstitutionalRequestData ); break; - // Pre-Treatment - case Gui::GuiActionType::ID_AdjustInitTreatmentReq : INTERPRET_TRANSMIT_MESSAGE(AdjustInitTreatmentRequestData ); break; - case Gui::GuiActionType::ID_AdjustParametersValidationReq : INTERPRET_TRANSMIT_MESSAGE(AdjustParametersValidationRequestData ); break; - case Gui::GuiActionType::ID_AdjustParametersConfirmReq : INTERPRET_TRANSMIT_MESSAGE(AdjustParametersConfirmRequestData ); break; - case Gui::GuiActionType::ID_AdjustWaterSampleReq : INTERPRET_TRANSMIT_MESSAGE(AdjustWaterSampleRequestData ); break; - case Gui::GuiActionType::ID_AdjustWaterSampleResultReq : INTERPRET_TRANSMIT_MESSAGE(AdjustWaterSampleResultRequestData ); break; - case Gui::GuiActionType::ID_AdjustConsumablesConfirmReq : INTERPRET_TRSMT_MT_MESSAGE(AdjustConsumablesConfirmRequestData ); break; - case Gui::GuiActionType::ID_AdjustDisposablesConfirmReq : INTERPRET_TRSMT_MT_MESSAGE(AdjustDisposablesConfirmRequestData ); break; - case Gui::GuiActionType::ID_AdjustDisposablesPrimeReq : INTERPRET_TRSMT_MT_MESSAGE(AdjustDisposablesPrimeRequestData ); break; - case Gui::GuiActionType::ID_AdjustPatientConnectionBeginReq : INTERPRET_TRSMT_MT_MESSAGE(AdjustPatientConnectionBeginRequestData ); break; - case Gui::GuiActionType::ID_AdjustUltrafiltrationInitReq : INTERPRET_TRANSMIT_MESSAGE(AdjustUltrafiltrationInitRequestData ); break; - case Gui::GuiActionType::ID_AdjustPatientConnectionConfirmReq : INTERPRET_TRSMT_MT_MESSAGE(AdjustPatientConnectionConfirmRequestData ); break; - case Gui::GuiActionType::ID_AdjustStartTreatmentReq : INTERPRET_TRSMT_MT_MESSAGE(AdjustStartTreatmentRequestData ); break; - // in-treatment - case Gui::GuiActionType::ID_AdjustDurationReq : INTERPRET_TRANSMIT_MESSAGE(AdjustDurationRequestData ); break; - case Gui::GuiActionType::ID_AdjustBloodDialysateReq : INTERPRET_TRANSMIT_MESSAGE(AdjustBloodDialysateRequestData ); break; - case Gui::GuiActionType::ID_AdjustPressuresLimitsReq : INTERPRET_TRANSMIT_MESSAGE(AdjustPressuresLimitsRequestData ); break; - case Gui::GuiActionType::ID_AdjustSalineReq : INTERPRET_TRANSMIT_MESSAGE(AdjustSalineRequestData ); break; - case Gui::GuiActionType::ID_AdjustHeparinReq : INTERPRET_TRANSMIT_MESSAGE(AdjustHeparinRequestData ); break; - // in-treatment - ultrafiltration - case Gui::GuiActionType::ID_AdjustUltrafiltrationStateReq : INTERPRET_TRANSMIT_MESSAGE(AdjustUltrafiltrationStateRequestData ); break; - case Gui::GuiActionType::ID_AdjustUltrafiltrationEditReq : INTERPRET_TRANSMIT_MESSAGE(AdjustUltrafiltrationEditRequestData ); break; - case Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmReq : INTERPRET_TRANSMIT_MESSAGE(AdjustUltrafiltrationConfirmRequestData ); break; - // End-Treatment - case Gui::GuiActionType::ID_AdjustRinsebackReq : INTERPRET_TRANSMIT_MESSAGE(AdjustRinsebackRequestData ); break; - case Gui::GuiActionType::ID_AdjustRecirculateReq : INTERPRET_TRANSMIT_MESSAGE(AdjustRecirculateRequestData ); break; - case Gui::GuiActionType::ID_AdjustTreatmentEndReq : INTERPRET_TRANSMIT_MESSAGE(AdjustTreatmentEndRequestData ); break; - // Post-Treatment - case Gui::GuiActionType::ID_AdjustPatientDisconnectNotifyReq : INTERPRET_TRSMT_MT_MESSAGE(AdjustPatientDisconnectionNotifyRequestData ); break; - case Gui::GuiActionType::ID_AdjustPatientDisconnectConfirmReq : INTERPRET_TRSMT_MT_MESSAGE(AdjustPatientDisconnectionConfirmRequestData ); break; - case Gui::GuiActionType::ID_AdjustDisposablesRemovalConfirmReq : INTERPRET_TRSMT_MT_MESSAGE(AdjustDisposablesRemovalConfirmRequestData ); break; - case Gui::GuiActionType::ID_AdjustTreatmentLogReq : INTERPRET_TRSMT_MT_MESSAGE(AdjustTreatmentLogRequestData ); break; - // Disinfection - case Gui::GuiActionType::ID_AdjustDisinfectModeReq : INTERPRET_TRANSMIT_MESSAGE(AdjustDisinfectModeRequestData ); break; - case Gui::GuiActionType::ID_AdjustDisinfectStartReq : INTERPRET_TRANSMIT_MESSAGE(AdjustDisinfectStartRequestData ); break; - // DG Cleaning - case Gui::GuiActionType::ID_AdjustDGCleaningUsageReq : INTERPRET_TRSMT_MT_MESSAGE(AdjustDGCleaningUsageRequestData ); break; - - // alarms - case Gui::GuiActionType::ID_AlarmSilenceReq : INTERPRET_TRANSMIT_MESSAGE(AlarmSilenceRequestData ); break; - case Gui::GuiActionType::ID_AlarmUserActionReq : INTERPRET_TRANSMIT_MESSAGE(AlarmUserActionRequestData ); break; - case Gui::GuiActionType::ID_AlarmVolumeSetReq : INTERPRET_TRANSMIT_MESSAGE(AdjustHDAlarmVolumeRequestData ); break; - // disabled coco begin validated: Manually tested. This model class is a placeholder for the message 63(0x3F00) and there is no use case for this now. - case Gui::GuiActionType::ID_AlarmClearedConditionReq : INTERPRET_TRANSMIT_MESSAGE(AlarmClearedConditionRequestData ); break; - case Gui::GuiActionType::ID_AlarmActiveListReq : INTERPRET_TRSMT_MT_MESSAGE(AlarmActiveListRequestData ); break; - case Gui::GuiActionType::ID_AlarmTriggered : INTERPRET_TRANSMIT_MESSAGE(AlarmTriggeredRequestData ); break; - - // HD reset in service mode - case Gui::GuiActionType::ID_ResetHDInServiceModeReq : INTERPRET_TRSMT_MT_MESSAGE(AdjustHDResetInSrvcRequestData ); break; - - // disabled coco end - default: - QString mActionIdHexString = Format::toHexString(vActionId); - LOG_DEBUG(tr("Unknown transmit Message with ID '%1'").arg(mActionIdHexString)); - ok = false; - break; - } return ok; } @@ -421,117 +328,10 @@ { bool ok = false; vData.clear(); - switch (vMessage.actionId) { // notice we are in receive mode - // ----- Debug - case Gui::GuiActionType::ID_CANBusFaultCount : ok = canbusFaultCountData (vMessage, vData); /* TODO : implement notify<>() */ break; - case Gui::GuiActionType::ID_HDDebugText : ok = notify(vMessage, vData, Gui::GuiActionType::ID_HDDebugText ); break; - case Gui::GuiActionType::ID_HDGeneralEvent : ok = notify(vMessage, vData, Gui::GuiActionType::ID_HDGeneralEvent ); break; - // ----- Events - case Gui::GuiActionType::ID_Acknow : ok = true; /* TODO : implement notify<>() */ break; - case Gui::GuiActionType::ID_PowerOff : ok = notify(vMessage, vData, Gui::GuiActionType::ID_PowerOff ); break; - case Gui::GuiActionType::ID_ShuttingDown : ok = true; LOG_APPED("HD,ShuttingDown"); /* TODO : implement notify<>() */ break; - - case Gui::GuiActionType::ID_DuetConfirmHDi : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DuetConfirmHDi ); break; - - // ----- POST - 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_HDRTCEpochData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_HDRTCEpochData ); break; - - // ----- Settings - case Gui::GuiActionType::ID_AdjustServiceModeRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustServiceModeRsp ); break; - case Gui::GuiActionType::ID_AdjustVersionsHDReq : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustVersionsHDReq ); break; - case Gui::GuiActionType::ID_AdjustVersionsHDRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustVersionsHDRsp ); break; - case Gui::GuiActionType::ID_AdjustSerialHDRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustSerialHDRsp ); break; - 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; - case Gui::GuiActionType::ID_HDUsageInfoRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_HDUsageInfoRsp ); break; - case Gui::GuiActionType::ID_AdjustInstitutionalRecordRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustInstitutionalRecordRsp ); 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; - case Gui::GuiActionType::ID_TreatmentStates : ok = notify(vMessage, vData, Gui::GuiActionType::ID_TreatmentStates ); break; - case Gui::GuiActionType::ID_PostTreatmentStates : ok = notify(vMessage, vData, Gui::GuiActionType::ID_PostTreatmentStates ); break; - - // ----- Datum - case Gui::GuiActionType::ID_HDAccelerometerData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_HDAccelerometerData ); break; - case Gui::GuiActionType::ID_HDSyringePumpData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_HDSyringePumpData ); break; - case Gui::GuiActionType::ID_HDAirBubbleData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_HDAirBubbleData ); break; - case Gui::GuiActionType::ID_HDAirTrapData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_HDAirTrapData ); break; - case Gui::GuiActionType::ID_HDBloodLeakData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_HDBloodLeakData ); break; - - // ----- Datum - Treatment - case Gui::GuiActionType::ID_TreatmentRanges : ok = notify(vMessage, vData, Gui::GuiActionType::ID_TreatmentRanges ); break; - - // ----- Pre-Treatment - Datum - Progress - case Gui::GuiActionType::ID_SelfTestNoCartridgeData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_SelfTestNoCartridgeData ); break; - case Gui::GuiActionType::ID_SelfTestDryData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_SelfTestDryData ); break; - case Gui::GuiActionType::ID_DisposablesPrimeData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DisposablesPrimeData ); break; - // ----- Pre-Treatment - Adjust - case Gui::GuiActionType::ID_AdjustInitTreatmentRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustInitTreatmentRsp ); break; - case Gui::GuiActionType::ID_AdjustParametersValidationRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustParametersValidationRsp ); break; - case Gui::GuiActionType::ID_AdjustWaterSampleRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustWaterSampleRsp ); break; - case Gui::GuiActionType::ID_AdjustDisposablesConfirmRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustDisposablesConfirmRsp ); break; - case Gui::GuiActionType::ID_AdjustDisposablesPrimeRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustDisposablesPrimeRsp ); break; - case Gui::GuiActionType::ID_AdjustPatientConnectionBeginRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustPatientConnectionBeginRsp ); break; - case Gui::GuiActionType::ID_AdjustUltrafiltrationInitRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustUltrafiltrationInitRsp ); break; - case Gui::GuiActionType::ID_AdjustPatientConnectionConfirmRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustPatientConnectionConfirmRsp ); break; - case Gui::GuiActionType::ID_AdjustStartTreatmentRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustStartTreatmentRsp ); break; - - // ----- In-Treatment - Datum - case Gui::GuiActionType::ID_TreatmentTime : ok = notify(vMessage, vData, Gui::GuiActionType::ID_TreatmentTime ); break; - case Gui::GuiActionType::ID_BloodFlow : ok = notify(vMessage, vData, Gui::GuiActionType::ID_BloodFlow ); break; - case Gui::GuiActionType::ID_DialysateInletFlow : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DialysateInletFlow ); break; - case Gui::GuiActionType::ID_DialysateOutletFlow : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DialysateOutletFlow ); break; - case Gui::GuiActionType::ID_PressureOcclusion : ok = notify(vMessage, vData, Gui::GuiActionType::ID_PressureOcclusion ); break; - case Gui::GuiActionType::ID_Saline : ok = notify(vMessage, vData, Gui::GuiActionType::ID_Saline ); break; - case Gui::GuiActionType::ID_Heparin : ok = notify(vMessage, vData, Gui::GuiActionType::ID_Heparin ); break; - case Gui::GuiActionType::ID_Rinseback : ok = notify(vMessage, vData, Gui::GuiActionType::ID_Rinseback ); break; - case Gui::GuiActionType::ID_Recirculate : ok = notify(vMessage, vData, Gui::GuiActionType::ID_Recirculate ); break; - case Gui::GuiActionType::ID_BloodPrime : ok = notify(vMessage, vData, Gui::GuiActionType::ID_BloodPrime ); break; - case Gui::GuiActionType::ID_TreatmentStop : ok = notify(vMessage, vData, Gui::GuiActionType::ID_TreatmentStop ); break; - // ----- In-Treatment Adjust - case Gui::GuiActionType::ID_AdjustDurationRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustDurationRsp ); break; - case Gui::GuiActionType::ID_AdjustBloodDialysateRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustBloodDialysateRsp ); break; - case Gui::GuiActionType::ID_AdjustPressuresLimitsRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustPressuresLimitsRsp ); break; - case Gui::GuiActionType::ID_AdjustSalineRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustSalineRsp ); break; - case Gui::GuiActionType::ID_AdjustUltrafiltrationStateRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustUltrafiltrationStateRsp ); break; - case Gui::GuiActionType::ID_AdjustHeparinRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustHeparinRsp ); break; - case Gui::GuiActionType::ID_AdjustRinsebackRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustRinsebackRsp ); break; - case Gui::GuiActionType::ID_AdjustRecirculateRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustRecirculateRsp ); break; - case Gui::GuiActionType::ID_AdjustTreatmentEndRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustTreatmentEndRsp ); break; - - // ----- Post-Treatment Adjust - case Gui::GuiActionType::ID_AdjustPatientDisconnectConfirmRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustPatientDisconnectConfirmRsp ); break; - case Gui::GuiActionType::ID_AdjustDisposablesRemovalConfirmRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustDisposablesRemovalConfirmRsp); break; - case Gui::GuiActionType::ID_AdjustTreatmentLogRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustTreatmentLogRsp ); break; - // ----- Treatment Log - case Gui::GuiActionType::ID_TreatmentLogAvrgeData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_TreatmentLogAvrgeData ); break; - case Gui::GuiActionType::ID_TreatmentLogAlarmData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_TreatmentLogAlarmData ); break; - case Gui::GuiActionType::ID_TreatmentLogEventData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_TreatmentLogEventData ); break; - // ----- Disinfection - Adjust - case Gui::GuiActionType::ID_AdjustDisinfectModeRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustDisinfectModeRsp ); break; - case Gui::GuiActionType::ID_AdjustDisinfectStartRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustDisinfectStartRsp ); break; - // these need to be standard and use notify as well - case Gui::GuiActionType::ID_AdjustUltrafiltrationEditRsp : ok = adjustUltrafiltrationEdit (vMessage, vData); /* TODO : implement notify<>() */ break; - case Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmRsp : ok = adjustUltrafiltrationConfirm (vMessage, vData); /* TODO : implement notify<>() */ break; - - // ----- Alarms - case Gui::GuiActionType::ID_AlarmStatus : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AlarmStatus ); break; - case Gui::GuiActionType::ID_AlarmTriggered : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AlarmTriggered ); break; - case Gui::GuiActionType::ID_AlarmCleared : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AlarmCleared ); break; - case Gui::GuiActionType::ID_AlarmVolumeSetRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AlarmVolumeSetRsp ); break; - // disabled coco begin validated: Manually tested. This model class is a placeholder for the message 63(0x3F00) and there is no use case for this now. - case Gui::GuiActionType::ID_AlarmClearedConditionRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AlarmClearedConditionRsp ); break; - case Gui::GuiActionType::ID_AlarmActiveListRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AlarmActiveListRsp ); break; - // disabled coco end - // unhandled messages: these will only be logged as received message // there has nothing been defined for these messages. - default : printUnhandled (vMessage ); break; - } + printUnhandled(vMessage); return ok; } @@ -553,44 +353,8 @@ { bool ok = false; vData.clear(); - switch (vMessage.actionId) { // notice we are in receive mode - case Gui::GuiActionType::ID_Acknow : ok = true; /* TODO : implement notify<>() */ break; - case Gui::GuiActionType::ID_DGCheckIn : ok = true; /* TODO : implement notify<>() */ - LOG_APPED(QString("DG,CheckIn," + QVariant(vData).toStringList().join(','))); break; - // ----- POST - case Gui::GuiActionType::ID_DGPostSingleResultData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGPostSingleResultData ); break; - case Gui::GuiActionType::ID_DGPostFinalResultData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGPostFinalResultData ); break; + printUnhandled(vMessage); - // DG data messages - case Gui::GuiActionType::ID_DGROPumpData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGROPumpData ); break; - case Gui::GuiActionType::ID_DGPressuresData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGPressuresData ); break; - case Gui::GuiActionType::ID_DGDrainPumpData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGDrainPumpData ); break; - case Gui::GuiActionType::ID_DGOperationModeData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGOperationModeData ); break; - case Gui::GuiActionType::ID_DGReservoirData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGReservoirData ); break; - case Gui::GuiActionType::ID_DGValvesStatesData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGValvesStatesData ); break; - case Gui::GuiActionType::ID_DGHeatersData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGHeatersData ); break; - case Gui::GuiActionType::ID_DGLoadCellReadingsData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGLoadCellReadingsData ); break; - case Gui::GuiActionType::ID_DGTemperaturesData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGTemperaturesData ); break; - case Gui::GuiActionType::ID_DGDebugText : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGDebugText ); break; - case Gui::GuiActionType::ID_DGGeneralEvent : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGGeneralEvent ); break; - case Gui::GuiActionType::ID_DGAccelerometerData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGAccelerometerData ); break; - case Gui::GuiActionType::ID_DGConductivityData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGConductivityData ); break; - // ----- Datum - Pre-Treatment progress - case Gui::GuiActionType::ID_DGFilterFlushData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGFilterFlushData ); break; - // DG Response Messages - case Gui::GuiActionType::ID_AdjustVersionsDGRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustVersionsDGRsp ); break; - case Gui::GuiActionType::ID_AdjustSerialDGRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustSerialDGRsp ); break; - case Gui::GuiActionType::ID_AdjustServiceDatesDGRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustServiceDatesDGRsp ); break; - case Gui::GuiActionType::ID_AdjustDGDateTimeRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustDGDateTimeRsp ); break; - case Gui::GuiActionType::ID_AdjustDGCleaningUsageRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustDGCleaningUsageRsp ); break; - // RO Water - case Gui::GuiActionType::ID_DuetRoWaterStatDGq : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DuetRoWaterStatDGq ); break; - case Gui::GuiActionType::ID_DuetRoWaterModeDGr : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DuetRoWaterModeDGr ); break; - // unhandled messages: these will only be logged as received message - // there has nothing been defined for these messages. - default : printUnhandled (vMessage ); break; - } - return ok; } @@ -610,7 +374,7 @@ { // TODO : review other methods bool ok = false; - if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_CANBusFaultCount) ) return ok; + if ( ! isValidMessage(vMessage) ) return ok; QVariantList mData; int index = 0; @@ -624,56 +388,7 @@ return ok; } -// ---------- ---------- ---------- ---------- ---------- Adjustments ---------- ---------- ---------- ---------- ---------- // /*! - * \brief MessageInterpreter::adjustUltrafiltrationEditData - * \details This method interprets Treatment Ultrafiltration Volume Adjustment Response message data - * in vMessage of type Message. - * \param vMessage - The vMessage of type Message which contains all the data, - * require to be interpreted. - * \param vData - Treatment Ultrafiltration Volume Adjustment Response data - * \return true if the data can be extracted as defined for Treatment Ultrafiltration Volume Adjustment Response Message ID - */ -bool MessageInterpreter::adjustUltrafiltrationEdit(const Message &vMessage, QVariantList &vData) -{ - bool ok = false; - if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_AdjustUltrafiltrationEditRsp) ) return ok; - - Model::MAdjustUltrafiltrationEditResponse mData; - ok = mData.fromByteArray(vMessage.data); - LOG_APPED("HD," + mData.toString()); // TODO : Not Standard - - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - - return ok; -} - -/*! - * \brief MessageInterpreter::adjustUltrafiltrationConfirmData - * \details This method interprets Treatment Ultrafiltration Volume Adjustment Confirm Response message data - * in vMessage of type Message. - * \param vMessage - The vMessage of type Message which contains all the data, - * require to be interpreted. - * \param vData - Treatment Ultrafiltration Volume Adjustment Confirm Response data - * \return true if the data can be extracted as defined for Treatment Ultrafiltration Volume Adjustment Confirm Response Message ID - */ -bool MessageInterpreter::adjustUltrafiltrationConfirm(const Message &vMessage, QVariantList &vData) -{ - bool ok = false; - if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmRsp) ) return ok; - - Model::MAdjustUltrafiltrationConfirmResponse mData; - ok = mData.fromByteArray(vMessage.data); - LOG_APPED("HD," + mData.toString()); // TODO : Not Standard - - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - - return ok; -} - -/*! * \brief MessageInterpreter::updateUnhandledMessages * \return this method is converting the general settings messages/unhandled (Storage::Settings_Category_MessagesUnhandled) group of settings to the message interpreter specific map structure. * it is done for performance to keep the lookup table shorter and faster. @@ -682,16 +397,7 @@ */ void MessageInterpreter::updateUnhandledMessages() { - QString category = Storage::Settings_Category_MessagesUnhandled; - QStringList groups = _Settings.groups(category); - // DEBUG: qDebug() << groups; - for(const auto &group: qAsConst(groups)) { - bool ok; - quint16 id = QString(group).toUInt(&ok,16); - if (!ok) continue; - _messageList[ id ] = _Settings.keys(category, group); - // DEBUG: qDebug() << _Settings.keys(group); - } + // TODO is this needed? } /*! @@ -702,7 +408,7 @@ */ bool MessageInterpreter::logUnhandledMessage(const Message &vMessage) const { bool ok = false; - quint16 id = vMessage.actionId; + quint16 id = 0; // TODO what is instead? QString logString = QString("%1,").arg(id,4,16); if (_messageList.contains(id)) { ok = true; @@ -762,12 +468,12 @@ } } } - LOG_APPED(logString); + //LOG_APPED(logString); // TODO is this needed? } else { - if ( gDisableUnhandledReport ) { // if the unhandled message error has been disabled, return. - LOG_DEBUG(QString("Undefined unhandled message [%1]").arg(id, 0, 16)); - } + //if ( gDisableUnhandledReport ) { // if the unhandled message error has been disabled, return. + // LOG_DEBUG(QString("Undefined unhandled message [%1]").arg(id, 0, 16)); + //} // TODO is this needed? } return ok; }