Index: denali.pro =================================================================== diff -u -rcbea4224ad67eecc2e7c4c66df9a7db711c72832 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- denali.pro (.../denali.pro) (revision cbea4224ad67eecc2e7c4c66df9a7db711c72832) +++ denali.pro (.../denali.pro) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -34,127 +34,208 @@ sources/gui \ sources/canbus \ sources/utility \ - sources/abstract + sources/abstract \ + sources/model/hd/adjustment \ + sources/model/hd/alarm \ + sources/model/hd/data \ + sources/model/dg/data \ + sources/view/dg/data HEADERS += \ + \ # common common/AlarmDefs.h \ common/DGDefs.h \ common/HDDefs.h \ common/MsgDefs.h \ + \ # Main sources/main.h \ - sources/maintimer.h \ - sources/model/mloadcellreadings.h \ - sources/model/mtemperaturesensors.h \ - sources/model/mtreatmentadjustblooddialysateresponse.h \ - sources/model/mtreatmentadjustdurationresponse.h \ - sources/model/mtreatmentadjustrequests.h \ - sources/model/mtreatmentadjustultrafiltrationconfirmresponse.h \ - sources/model/mtreatmentadjustultrafiltrationstateresponse.h \ - sources/model/mtreatmentadjustultrafiltrationeditresponse.h \ - sources/model/mtreatmentpressureocclusion.h \ - sources/model/mtreatmentranges.h \ + sources/model/MDGDebugText.h \ + sources/model/MHDDebugText.h \ + sources/storage/DriveWatcher.h \ sources/threads.h \ - sources/applicationcontroller.h \ + sources/maintimer.h \ sources/applicationpost.h \ + \ # Controllers + sources/applicationcontroller.h \ + \ # ---------- Models ---------- + sources/model/MModel.h \ + sources/model/MAbstract.h \ + sources/model/MPowerOff.h \ + \ # ---------- Models - Alarm + sources/model/hd/alarm/MAlarmCleared.h \ + sources/model/hd/alarm/MAlarmTriggered.h \ + sources/model/hd/alarm/MAlarmStatusData.h \ + \ # ---------- Models - HD - Adjustment - In-Treatment + sources/model/hd/adjustment/MTreatmentAdjustRequests.h \ + sources/model/hd/adjustment/MTreatmentAdjustDurationResponse.h \ + sources/model/hd/adjustment/MTreatmentAdjustBloodDialysateResponse.h \ + sources/model/hd/adjustment/MTreatmentAdjustUltrafiltrationStateResponse.h \ + sources/model/hd/adjustment/MTreatmentAdjustUltrafiltrationEditResponse.h \ + sources/model/hd/adjustment/MTreatmentAdjustUltrafiltrationConfirmResponse.h \ + \ # ---------- Models - HD - Data + sources/model/hd/data/MTreatmentTimeData.h \ + sources/model/hd/data/MTreatmentFlowsData.h \ + sources/model/hd/data/MTreatmentOutletFlowData.h \ + sources/model/hd/data/MTreatmentRangesData.h \ + sources/model/hd/data/MTreatmentPressureOcclusionData.h \ + sources/model/hd/data/MTreatmentStatesData.h \ + sources/model/hd/data/MHDOperationModeData.h \ + \ # ---------- Models - DG - Data + sources/model/dg/data/MDGDrainPumpData.h \ + sources/model/dg/data/MDGHeatersData.h \ + sources/model/dg/data/MDGLoadCellReadingsData.h \ + sources/model/dg/data/MDGOperationModeData.h \ + sources/model/dg/data/MDGPressuresData.h \ + sources/model/dg/data/MDGReservoirData.h \ + sources/model/dg/data/MDGROPumpData.h \ + sources/model/dg/data/MDGTemperaturesData.h \ + sources/model/dg/data/MDGValvesStatesData.h \ + \ # CANBus sources/canbus/caninterface.h \ sources/canbus/frameinterface.h \ + \ # Denali Message + sources/canbus/messageglobals.h \ sources/canbus/messageacknowmodel.h \ sources/canbus/messagebuilder.h \ - sources/canbus/messagedispatcher.h \ - sources/canbus/messageglobals.h \ sources/canbus/messageinterpreter.h \ -# sources/configuration/display.h \ -# sources/configuration/sound.h \ + sources/canbus/messagedispatcher.h \ + \ # Gui sources/gui/guiglobals.h \ sources/gui/guiview.h \ sources/gui/guicontroller.h \ - sources/model/malarmstatus.h \ - sources/model/mmodel.h \ - sources/model/mpoweroff.h \ - sources/model/mtreatmentflows.h \ - sources/model/mtreatmentoutletflow.h \ - sources/model/mtreatmenttime.h \ - sources/view/vloadcellreadings.h \ - sources/view/vtemperaturesensors.h \ - sources/view/vtreatmentadjustmentduration.h \ - sources/view/vtreatmentadjustmentflows.h \ - sources/view/vtreatmentadjustmentresponsebase.h \ - sources/view/vtreatmentadjustmentultrafiltrationconfirm.h \ - sources/view/vtreatmentadjustmentultrafiltrationedit.h \ - sources/view/vtreatmentadjustmentultrafiltrationstate.h \ - sources/view/vtreatmentpressureocclusion.h \ - sources/view/vtreatmentranges.h \ + \ # ---------- Views ---------- + sources/view/dg/data/VDGDrainPumpData.h \ + sources/view/dg/data/VDGHeatersData.h \ + sources/view/dg/data/VDGLoadCellReadingsData.h \ + sources/view/dg/data/VDGOperationModeData.h \ + sources/view/dg/data/VDGPressuresData.h \ + sources/view/dg/data/VDGROPumpData.h \ + sources/view/dg/data/VDGReservoirData.h \ + sources/view/dg/data/VDGTemperaturesData.h \ + sources/view/dg/data/VDGValvesStatesData.h \ + \ sources/view/vview.h \ sources/view/vpoweroff.h \ + sources/view/valarmstatus.h \ + sources/view/VHDOperationModeData.h \ + sources/view/vtreatmenttime.h \ sources/view/vtreatmentbloodflow.h \ sources/view/vtreatmentdialysateflow.h \ - sources/view/vtreatmenttime.h \ sources/view/vtreatmentultrafiltration.h \ - sources/view/valarmstatus.h \ + sources/view/vtreatmentranges.h \ + sources/view/vtreatmentpressureocclusion.h \ + \ # Treatment Adjustments + sources/view/vtreatmentadjustmentresponsebase.h \ + sources/view/vtreatmentadjustmentduration.h \ + sources/view/vtreatmentadjustmentflows.h \ + sources/view/vtreatmentadjustmentultrafiltrationstate.h \ + sources/view/vtreatmentadjustmentultrafiltrationedit.h \ + sources/view/vtreatmentadjustmentultrafiltrationconfirm.h \ + \ # Storage + sources/storage/storageglobals.h \ sources/storage/filehandler.h \ sources/storage/logger.h \ - sources/storage/storageglobals.h \ - sources/storage/usbwatcher.h \ -# sources/storage/settings.h \ + \ # Utility sources/utility/crc.h \ sources/utility/format.h \ sources/utility/types.h +# sources/configuration/display.h \ +# sources/configuration/sound.h \ +# sources/storage/settings.h \ SOURCES += \ + \ # common + \ # Main main.cpp \ - sources/maintimer.cpp \ - sources/model/mloadcellreadings.cpp \ - sources/model/mtemperaturesensors.cpp \ - sources/model/mtreatmentadjustblooddialysateresponse.cpp \ - sources/model/mtreatmentadjustdurationresponse.cpp \ - sources/model/mtreatmentadjustultrafiltrationconfirmresponse.cpp \ - sources/model/mtreatmentadjustultrafiltrationstateresponse.cpp \ - sources/model/mtreatmentadjustultrafiltrationeditresponse.cpp \ - sources/model/mtreatmentpressureocclusion.cpp \ - sources/model/mtreatmentranges.cpp \ + sources/model/MDGDebugText.cpp \ + sources/model/MHDDebugText.cpp \ + sources/storage/DriveWatcher.cpp \ sources/threads.cpp \ - sources/applicationcontroller.cpp \ + sources/maintimer.cpp \ sources/applicationpost.cpp \ + \ # Controllers + sources/applicationcontroller.cpp \ + \ # ---------- Models ---------- + sources/model/MAbstract.cpp \ + sources/model/MPowerOff.cpp \ + \ # ---------- Models - Alarm + sources/model/hd/alarm/MAlarmCleared.cpp \ + sources/model/hd/alarm/MAlarmTriggered.cpp \ + sources/model/hd/alarm/MAlarmStatusData.cpp \ + \ # ---------- Models - HD - Adjustment - In-Treatment + sources/model/hd/adjustment/MTreatmentAdjustDurationResponse.cpp \ + sources/model/hd/adjustment/MTreatmentAdjustBloodDialysateResponse.cpp \ + sources/model/hd/adjustment/MTreatmentAdjustUltrafiltrationStateResponse.cpp \ + sources/model/hd/adjustment/MTreatmentAdjustUltrafiltrationEditResponse.cpp \ + sources/model/hd/adjustment/MTreatmentAdjustUltrafiltrationConfirmResponse.cpp \ + \ # ---------- Models - HD - Data + sources/model/hd/data/MTreatmentTimeData.cpp \ + sources/model/hd/data/MTreatmentFlowsData.cpp \ + sources/model/hd/data/MTreatmentOutletFlowData.cpp \ + sources/model/hd/data/MTreatmentRangesData.cpp \ + sources/model/hd/data/MTreatmentPressureOcclusionData.cpp \ + sources/model/hd/data/MTreatmentStatesData.cpp \ + sources/model/hd/data/MHDOperationModeData.cpp \ + \ # ---------- Models - DG - Data + sources/model/dg/data/MDGDrainPumpData.cpp \ + sources/model/dg/data/MDGHeatersData.cpp \ + sources/model/dg/data/MDGLoadCellReadingsData.cpp \ + sources/model/dg/data/MDGOperationModeData.cpp \ + sources/model/dg/data/MDGPressuresData.cpp \ + sources/model/dg/data/MDGReservoirData.cpp \ + sources/model/dg/data/MDGROPumpData.cpp \ + sources/model/dg/data/MDGTemperaturesData.cpp \ + sources/model/dg/data/MDGValvesStatesData.cpp \ + \ # CANBus sources/canbus/caninterface.cpp \ sources/canbus/frameinterface.cpp \ + \ # Denali Message sources/canbus/messageacknowmodel.cpp \ sources/canbus/messagebuilder.cpp \ sources/canbus/messagedispatcher.cpp \ sources/canbus/messageinterpreter.cpp \ -# sources/configuration/display.cpp \ -# sources/configuration/sound.cpp \ + \ # Gui sources/gui/guiglobals.cpp \ sources/gui/guiview.cpp \ sources/gui/guicontroller.cpp \ - sources/model/mpoweroff.cpp \ - sources/model/mtreatmentflows.cpp \ - sources/model/mtreatmentoutletflow.cpp \ - sources/model/mtreatmenttime.cpp \ - sources/model/malarmstatus.cpp \ - sources/view/vloadcellreadings.cpp \ + \ # ---------- Views ---------- + sources/view/dg/data/VDGDrainPumpData.cpp \ + sources/view/dg/data/VDGHeatersData.cpp \ + sources/view/dg/data/VDGLoadCellReadingsData.cpp \ + sources/view/dg/data/VDGOperationModeData.cpp \ + sources/view/dg/data/VDGPressuresData.cpp \ + sources/view/dg/data/VDGROPumpData.cpp \ + sources/view/dg/data/VDGReservoirData.cpp \ + sources/view/dg/data/VDGTemperaturesData.cpp \ + sources/view/dg/data/VDGValvesStatesData.cpp \ + \ sources/view/vpoweroff.cpp \ - sources/view/vtemperaturesensors.cpp \ - sources/view/vtreatmentadjustmentduration.cpp \ - sources/view/vtreatmentadjustmentflows.cpp \ - sources/view/vtreatmentadjustmentresponsebase.cpp \ - sources/view/vtreatmentadjustmentultrafiltrationconfirm.cpp \ - sources/view/vtreatmentadjustmentultrafiltrationedit.cpp \ - sources/view/vtreatmentadjustmentultrafiltrationstate.cpp \ + sources/view/valarmstatus.cpp \ + sources/view/VHDOperationModeData.cpp \ + sources/view/vtreatmenttime.cpp \ sources/view/vtreatmentbloodflow.cpp \ sources/view/vtreatmentdialysateflow.cpp \ - sources/view/vtreatmentpressureocclusion.cpp \ - sources/view/vtreatmentranges.cpp \ sources/view/vtreatmentultrafiltration.cpp \ - sources/view/vtreatmenttime.cpp \ - sources/view/valarmstatus.cpp \ + sources/view/vtreatmentranges.cpp \ + sources/view/vtreatmentpressureocclusion.cpp \ + \ # Treatment Adjustments + sources/view/vtreatmentadjustmentresponsebase.cpp \ + sources/view/vtreatmentadjustmentduration.cpp \ + sources/view/vtreatmentadjustmentflows.cpp \ + sources/view/vtreatmentadjustmentultrafiltrationstate.cpp \ + sources/view/vtreatmentadjustmentultrafiltrationedit.cpp \ + sources/view/vtreatmentadjustmentultrafiltrationconfirm.cpp \ + \ # Storage + sources/storage/storageglobals.cpp \ sources/storage/filehandler.cpp \ sources/storage/logger.cpp \ - sources/storage/storageglobals.cpp \ - sources/storage/usbwatcher.cpp \ -# sources/storage/settings.cpp \ + \ # Utility sources/utility/crc.cpp \ sources/utility/format.cpp \ sources/utility/types.cpp +# sources/configuration/display.cpp \ +# sources/configuration/sound.cpp \ +# sources/storage/settings.cpp \ RESOURCES += \ denali.qrc Index: denali.pro.user =================================================================== diff -u -r4271457f27788b96d6b166e61e8fe3ecdc0011ba -rd2035a8728794afeefaa244bf8d1597926d945f5 --- denali.pro.user (.../denali.pro.user) (revision 4271457f27788b96d6b166e61e8fe3ecdc0011ba) +++ denali.pro.user (.../denali.pro.user) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,6 +1,6 @@ - + EnvironmentId @@ -61,6 +61,14 @@ ProjectExplorer.Project.PluginSettings + + false + false + true + true + + 0 + true true Builtin.Questionable @@ -85,7 +93,10 @@ 0 0 - /home/denali/Project/tmp/build/denali-Desktop_Qt_5_12_5_GCC_64bit-Debug + true + 2 + /home/denali/Projects/tmp/build/denali-Desktop_Qt_5_12_5_GCC_64bit-Debug + /home/denali/Projects/tmp/build/denali-Desktop_Qt_5_12_5_GCC_64bit-Debug true @@ -141,7 +152,10 @@ true - /home/denali/Project/tmp/build/denali-Desktop_Qt_5_12_5_GCC_64bit-Release + true + 2 + /home/denali/Projects/tmp/build/denali-Desktop_Qt_5_12_5_GCC_64bit-Release + /home/denali/Projects/tmp/build/denali-Desktop_Qt_5_12_5_GCC_64bit-Release true @@ -151,8 +165,6 @@ false false - false - false true @@ -197,7 +209,10 @@ true - /home/denali/Project/tmp/build/unittest/tst_threads + true + 2 + /home/denali/Projects/tmp/build/unittest/tst_threads + /home/denali/Projects/tmp/build/unittest/tst_threads true @@ -291,7 +306,10 @@ true - /home/denali/Project/tmp/build/unittest/tst_messaging + true + 2 + /home/denali/Projects/tmp/build/unittest/tst_messaging + /home/denali/Projects/tmp/build/unittest/tst_messaging true @@ -385,7 +403,10 @@ true - /home/denali/Project/tmp/build/denali-Desktop_Qt_5_12_5_GCC_64bit-Profile + true + 2 + /home/denali/Projects/tmp/build/denali-Desktop_Qt_5_12_5_GCC_64bit-Profile + /home/denali/Projects/tmp/build/denali-Desktop_Qt_5_12_5_GCC_64bit-Profile true @@ -441,7 +462,10 @@ true - /home/denali/Project/tmp/build/unittest/tst_canbus + true + 2 + /home/denali/Projects/tmp/build/unittest/tst_canbus + /home/denali/Projects/tmp/build/unittest/tst_canbus true @@ -535,7 +559,10 @@ true - /home/denali/Project/tmp/build/unittest/tst_logging + true + 2 + /home/denali/Projects/tmp/build/unittest/tst_logging + /home/denali/Projects/tmp/build/unittest/tst_logging true @@ -629,7 +656,10 @@ true - /home/denali/Project/tmp/build/unittest/tst_utilities + true + 2 + /home/denali/Projects/tmp/build/unittest/tst_utilities + /home/denali/Projects/tmp/build/unittest/tst_utilities true @@ -638,9 +668,7 @@ QtProjectManager.QMakeBuildStep false CONFIG+=tst_utilities CONFIG+=CodeCoverage - true - false - false + false true @@ -723,7 +751,10 @@ true - /home/denali/Project/tmp/build/unittest/tst_acknow + true + 2 + /home/denali/Projects/tmp/build/unittest/tst_acknow + /home/denali/Projects/tmp/build/unittest/tst_acknow true @@ -732,9 +763,7 @@ QtProjectManager.QMakeBuildStep false CONFIG+=tst_acknow CONFIG+=CodeCoverage - true - false - false + false true @@ -817,7 +846,10 @@ true - /home/denali/Project/tmp/build/unittest/tst_models + true + 2 + /home/denali/Projects/tmp/build/unittest/tst_models + /home/denali/Projects/tmp/build/unittest/tst_models true @@ -911,7 +943,10 @@ true - /home/denali/Project/tmp/build/unittest/tst_initializations + true + 2 + /home/denali/Projects/tmp/build/unittest/tst_initializations + /home/denali/Projects/tmp/build/unittest/tst_initializations true @@ -1005,7 +1040,10 @@ true - /home/denali/Project/tmp/build/unittest/tst_views + true + 2 + /home/denali/Projects/tmp/build/unittest/tst_views + /home/denali/Projects/tmp/build/unittest/tst_views true @@ -1165,9 +1203,8 @@ 2 - denali - - Qt4ProjectManager.Qt4RunConfiguration:/home/denali/Project/application/denali.pro + Qt4ProjectManager.Qt4RunConfiguration:/home/denali/Projects/application/denali.pro + /home/denali/Projects/application/denali.pro 3768 false @@ -1177,7 +1214,7 @@ false true - /home/denali/Project/tmp/build/unittest/tst_messaging + /home/denali/Projects/tmp/build/denali-Desktop_Qt_5_12_5_GCC_64bit-Debug 1 @@ -1188,11 +1225,14 @@ Qt 5.12.5 (iMX8) Qt 5.12.5 (iMX8) {5d6458ef-f917-4aef-a092-c77bbe106149} - 1 + 0 0 0 - /home/denali/Project/tmp/build/denali-Qt_5_12_5_iMX8-Debug + true + 2 + /home/denali/Projects/tmp/build/denali-Qt_5_12_5_iMX8-Debug + /home/denali/Projects/tmp/build/denali-Qt_5_12_5_iMX8-Debug true @@ -1248,7 +1288,10 @@ true - /home/denali/Project/tmp/build/denali-Qt_5_12_5_iMX8-Release + true + 2 + /home/denali/Projects/tmp/build/denali-Qt_5_12_5_iMX8-Release + /home/denali/Projects/tmp/build/denali-Qt_5_12_5_iMX8-Release true @@ -1304,7 +1347,10 @@ true - /home/denali/Project/tmp/build/denali-Qt_5_12_5_iMX8-Profile + true + 2 + /home/denali/Projects/tmp/build/denali-Qt_5_12_5_iMX8-Profile + /home/denali/Projects/tmp/build/denali-Qt_5_12_5_iMX8-Profile true @@ -1313,9 +1359,7 @@ QtProjectManager.QMakeBuildStep false - true - false - false + false true @@ -1466,9 +1510,9 @@ 1 - denali (on Generic Linux Device) - denali (on Generic Linux Device) - RemoteLinuxRunConfiguration:/home/denali/Project/application/denali.pro + denali (on Generic Linux Device)2 + RemoteLinuxRunConfiguration:/home/denali/Projects/application/denali.pro + /home/denali/Projects/application/denali.pro 1 false Index: main.cpp =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- main.cpp (.../main.cpp) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ main.cpp (.../main.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -39,7 +39,7 @@ #include "applicationcontroller.h" #include "guicontroller.h" #include "logger.h" -#include "usbwatcher.h" +#include "DriveWatcher.h" #include "threads.h" // kernel @@ -69,7 +69,7 @@ const char *gFakeData_default = "00" ; bool gSendEmptyKeepAwake = false ; bool gFakeSeqAtBegin = false ; -bool gDisableHunhandledReport = false ; +bool gDisableUnhandledReport = false ; bool gDisableTimeout = false ; bool gConsoleoutFrameInterface = false ; @@ -143,9 +143,9 @@ parser.addOption(optionFakeSeqAtBegin); // --- -u : disable-unhandled-report - QCommandLineOption optionDisableHunhandledReport(QStringList() << "u" << "disable-unhandled-report", + QCommandLineOption optionDisableUnhandledReport(QStringList() << "u" << "disable-unhandled-report", QCoreApplication::translate("main", "Disable unhandled messages report as an error in the log")); - parser.addOption(optionDisableHunhandledReport); + parser.addOption(optionDisableUnhandledReport); // --- -u : disable-unhandled-report QCommandLineOption optionDisableTimeout(QStringList() << "q" << "disable-timeout", @@ -158,7 +158,7 @@ gConsoleoutCanInterface = parser.isSet(optionConsoleoutCanInterface ); gConsoleoutFrameInterface = parser.isSet(optionConsoleoutFrameInterface ); - gDisableHunhandledReport = parser.isSet(optionDisableHunhandledReport ); + gDisableUnhandledReport = parser.isSet(optionDisableUnhandledReport ); gDisableTimeout = parser.isSet(optionDisableTimeout ); if (parser.isSet(optionSendEmptyKeepAwake)) gSendEmptyKeepAwake = true; @@ -258,17 +258,21 @@ //! - Initializing Logger _Logger.init(Threads::_Logger_Thread); - LOG_EVENT(QObject::tr("Application Started")); + LOG_EVENT("UI," + QObject::tr("Application %1 Started,%2") + .arg(app.applicationName ()) + .arg(app.applicationVersion()) + ); if (gFakeInterval) { - qDebug() << " ~~ !!!!! APPLICATION RUNNING IN THE TEST MODE !!!!! ~~ " ; + QString msg = " ~~ !!!!! APPLICATION RUNNING IN THE TEST MODE !!!!! ~~ "; + qDebug() << msg; LOG_EVENT(" \n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ " - " \n ~~ !!!!! APPLICATION RUNNING IN THE TEST MODE !!!!! ~~ " + " \n " + msg + " \n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "); } //! - Initializing USB Watcher - _USBWatcher.init(Threads::_USBWatcher_Thread); + _DriveWatcher.init(Threads::_DriveWatcher_Thread); //! - Initializing CanBus Interface if (_CanInterface.init(Threads::_CanFrame_Thread)) { Index: sources/applicationcontroller.cpp =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/applicationcontroller.cpp (.../applicationcontroller.cpp) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/applicationcontroller.cpp (.../applicationcontroller.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -20,7 +20,7 @@ #include "maintimer.h" #include "messagedispatcher.h" #include "logger.h" -#include "usbwatcher.h" +#include "DriveWatcher.h" #include "filehandler.h" #include "guicontroller.h" @@ -47,7 +47,7 @@ // coco begin validated: The class ApplicationPost has not been implemented Yet. if (!_applicationPost->init()) return false; // coco end - LOG_EVENT(QObject::tr("%1 Initialized").arg(metaObject()->className())); + LOG_EVENT("UI," + tr("%1 Initialized").arg(metaObject()->className())); return true; } @@ -103,15 +103,15 @@ connect(&_GuiController , SIGNAL(didUSBDriveUmount()), this , SLOT( onUSBDriveUmount())); - connect(&_USBWatcher , SIGNAL(didUSBDriveMount ()), + connect(&_DriveWatcher , SIGNAL(didUSBDriveMount ()), this , SLOT( onUSBDriveMount ())); - connect(&_USBWatcher , SIGNAL(didUSBDriveRemove()), + connect(&_DriveWatcher , SIGNAL(didUSBDriveRemove()), this , SLOT( onUSBDriveRemove())); connect(&_GuiController , SIGNAL(didExportLog()), this , SLOT( onExportLog())); - connect(&_Logger , SIGNAL(didExport()), + connect(&_Logger , SIGNAL(didExportLogs()), this , SLOT( onExport())); // ---- Signal/Slots @@ -199,7 +199,7 @@ /*! * \brief ApplicationController::onUSBDriveMount - * \details This is the slot which connects to the _USBWatcher didUSBDriveMount signal + * \details This is the slot which connects to the _DriveWatcher didUSBDriveMount signal * and notifies the other classes (GuiController) by emitting its signal didUSBDriveMount */ void ApplicationController::onUSBDriveMount () @@ -213,7 +213,7 @@ /*! * \brief ApplicationController::onUSBDriveRemove * \details This is the slot which connects to the _GuiController didUSBDriveUmount signal - * and notifies the other classes (USBWatcher) by emitting its signal didUSBDriveUmount + * and notifies the other classes (DriveWatcher) by emitting its signal didUSBDriveUmount */ void ApplicationController::onUSBDriveUmount() { @@ -225,7 +225,7 @@ /*! * \brief ApplicationController::onUSBDriveRemove - * \details This is the slot which connects to the _USBWatcher didUSBDriveRemove signal + * \details This is the slot which connects to the _DriveWatcher didUSBDriveRemove signal * and notifies the other classes (GuiController) by emitting its signal didUSBDriveRemove */ void ApplicationController::onUSBDriveRemove() @@ -284,7 +284,7 @@ else { mData += static_cast(GuiActionData::NoData); } - onActionTransmit(GuiActionType::KeepAlive, mData); + onActionTransmit(GuiActionType::ID_KeepAlive, mData); #endif } Index: sources/applicationcontroller.h =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/applicationcontroller.h (.../applicationcontroller.h) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/applicationcontroller.h (.../applicationcontroller.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,15 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. - * \copyright \n - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, \n - * IN PART OR IN WHOLE, \n - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. \n - * - * \file applicationcontroller.h - * \date 2019/09/30 - * \author Behrouz NematiPour - * + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file applicationcontroller.h + * \author (last) Peter Lucia + * \date (last) 25-Jun-2020 + * \author (original) Behrouz NematiPour + * \date (original) 24-Sep-2019 + * */ #pragma once @@ -30,8 +31,8 @@ // namespace using namespace Gui; +using namespace Can; - class ApplicationController : public QObject { Q_OBJECT @@ -66,10 +67,10 @@ void createFakeSeqAtBeginLongMessage(QVariantList &vData, const int vFakeDataLen); private slots: // Should be private for thread safety and is connected internally. - void onActionReceive (GuiActionType vAction, const QVariantList &vData); // UI <= HD/DG - void onActionTransmit(GuiActionType vAction, const QVariantList &vData); // UI => HD/DG + void onActionReceive (GuiActionType vAction, const QVariantList &vData); // UI <= HD/DG + void onActionTransmit(GuiActionType vAction, const QVariantList &vData); // UI => HD/DG - void onMainTimerTimeout(); + void onMainTimerTimeout(); void onUSBDriveMount (); void onUSBDriveUmount(); @@ -78,6 +79,8 @@ void onExportLog (); void onExport (); + void onFailedTransmit(Sequence seq); + signals: void didActionReceive (GuiActionType vAction, const QVariantList &vData); // UI <= HD/DG void didActionTransmit(GuiActionType vAction, const QVariantList &vData); // UI => HD/DG @@ -88,6 +91,10 @@ void didExport (); + void didAdjustBloodDialysateFlows(quint32 vBloodFlow, quint32 vDialysateFlow); + void didAdjustDuration(quint32 vDuration); + void didFailedTransmit(Sequence seq); + // ---- Signal/Slots ADJUST_TRANSMT_MODEL_BRIDGE_DEFINITIONS ACTION_RECEIVE_MODEL_BRIDGE_DEFINITIONS Index: sources/canbus/caninterface.cpp =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/canbus/caninterface.cpp (.../caninterface.cpp) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/canbus/caninterface.cpp (.../caninterface.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -55,8 +55,10 @@ initConnections(); status(tr("Connected")); - LOG_EVENT(status()); - LOG_EVENT(QObject::tr("%1 Initialized").arg(metaObject()->className())); + QString logMessage = QString("UI,%1,%2") + .arg(tr("%1 Initialized").arg(metaObject()->className())) + .arg(status()); + LOG_EVENT(logMessage); return true; } @@ -102,6 +104,23 @@ } /*! + * \brief CanInterface::enableConsoleOut + * \details Enable or Disables the console output and logs the status + * \param vEnabled - Enalbe console output if true + */ +void CanInterface::enableConsoleOut(bool vEnabled) { + // coco begin validated: This code meant to be used only for debugging and tested manually + if (_enableConsoleOut == vEnabled) return; + _enableConsoleOut = vEnabled; + if (_enableConsoleOut) { + LOG_DEBUG("Console out CanInterface enabled"); + } else { + LOG_DEBUG("Console out CanInterface disabled"); + } +} +// coco end + +/*! * \brief CanInterface connections definition * \details Initializes the required signal/slot connection between this class and other objects * to be able to communicate. @@ -171,7 +190,7 @@ // coco begin validated: Manually tested since required to disable and enable the canbus if (!_canDevice) { status(tr("Device Creation"), mError); - LOG_ERROR(status()); + LOG_DEBUG(status()); return false; } // coco end @@ -187,7 +206,7 @@ { if (!_canDevice->connectDevice()) { status(tr("Connection")); - LOG_ERROR(status()); + LOG_DEBUG(status()); delete _canDevice; _canDevice = nullptr; return false; @@ -258,8 +277,6 @@ // coco begin validated: This code is only for debugging purposes and had been tested manually. if ( ! _enableConsoleOut ) return; - LOG_EVENT_ONCE(QObject::tr("console out CanInterface Enabled")); - const QString time = QString::fromLatin1("%1.%2 ") .arg(vFrame.timeStamp().seconds(), 10, 10, QLatin1Char(' ')) .arg(vFrame.timeStamp().microSeconds() / 100, 4, 10, QLatin1Char('0')); @@ -351,7 +368,7 @@ case QCanBusDevice::ConfigurationError: case QCanBusDevice::UnknownError: _canStatus = _canDevice->errorString(); - LOG_ERROR(QString("%1 - %2").arg(_erFrameCount).arg(_canStatus)); + LOG_DEBUG(QString("%1 - %2").arg(_erFrameCount).arg(_canStatus)); break; default: Index: sources/canbus/caninterface.h =================================================================== diff -u -r2437559b2d4cd4c2ac6a926b4f55652e55e1f616 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/canbus/caninterface.h (.../caninterface.h) (revision 2437559b2d4cd4c2ac6a926b4f55652e55e1f616) +++ sources/canbus/caninterface.h (.../caninterface.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,16 +1,17 @@ -/*! - * - * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. - * \copyright \n - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, \n - * IN PART OR IN WHOLE, \n - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. \n - * - * \file caninterface.h - * \date 2019/09/30 - * \author Behrouz NematiPour - * - */ +/*! + * + * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file caninterface.h + * \author (last) Behrouz NematiPour + * \date (last) 02-Mar-2020 + * \author (original) Behrouz NematiPour + * \date (original) 28-Oct-2019 + * + */ #pragma once // Qt Index: sources/canbus/frameinterface.cpp =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/canbus/frameinterface.cpp (.../frameinterface.cpp) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/canbus/frameinterface.cpp (.../frameinterface.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -48,7 +48,7 @@ startTimer(1, Qt::PreciseTimer); - LOG_EVENT(QObject::tr("%1 Initialized").arg(metaObject()->className())); + LOG_EVENT("UI," + tr("%1 Initialized").arg(metaObject()->className())); return true; } @@ -149,7 +149,7 @@ QCanBusFrame mFrame; mFrame.setFrameId(vCan_Id); if (vData.length() > Can::eLenCanFrame) { - LOG_ERROR(tr("Payload can't be larger than %1 bytes").arg(Can::eLenCanFrame)); + LOG_DEBUG(QString("Payload can't be larger than %1 bytes").arg(Can::eLenCanFrame)); return; } mFrame.setPayload(vData); @@ -183,6 +183,7 @@ case eChlid_HD_Sync : // coco begin validated: The UI/DG communication has not been defined and implemented yet. case eChlid_DG_Alarm : + case eChlid_DG_UI : case eChlid_DG_Sync : // coco end //case eChlid_DG_UI : // has duplicate value as eChlid_DG_Alarm @@ -222,7 +223,7 @@ ChannelGroup channelGroup = checkChannel(mFrameId, &ok); if (!ok) { - LOG_ERROR("Unexpected Channel\r\n" + + LOG_DEBUG("Unexpected Channel\r\n" + Format::toHexString(mFrameId, false, eLenChannelDigits) + " -- " + vFrame.payload().toHex(' ')); return; } @@ -327,7 +328,7 @@ Frame frame = Frame(vCan_Id, vData); // coco begin validated: has been manually tested by sending over 4000 frames and not received by anyother node. if (_txFrameList.count() >= _txFrameList_Max) { - LOG_ERROR(tr("Transmit buffer overflow of %1").arg(_txFrameList_Max)); + LOG_DEBUG(QString("Transmit buffer overflow of %1").arg(_txFrameList_Max)); return; // coco end } Index: sources/canbus/messageacknowmodel.cpp =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/canbus/messageacknowmodel.cpp (.../messageacknowmodel.cpp) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/canbus/messageacknowmodel.cpp (.../messageacknowmodel.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -192,5 +192,5 @@ _acknowList[vSequence]->deleteLater(); _acknowList.remove(vSequence); emit didFailedTransmit(vSequence); - LOG_ERROR( tr("Acknow retry failed for sequence %1").arg(vSequence) ); + LOG_DEBUG( QString("Acknow retry failed for sequence %1").arg(vSequence) ); } Index: sources/canbus/messageacknowmodel.h =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/canbus/messageacknowmodel.h (.../messageacknowmodel.h) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/canbus/messageacknowmodel.h (.../messageacknowmodel.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -64,7 +64,7 @@ protected: /*! * \brief MessageAcknowModel::timerEvent - * \details This event handler has been overrode in here + * \details This event handler has been override in here * to receive timer events for the object * for the timer which has been set to _interval * emits the didFramesTransmit signal to retry transmitting the frames Index: sources/canbus/messagebuilder.cpp =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/canbus/messagebuilder.cpp (.../messagebuilder.cpp) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/canbus/messagebuilder.cpp (.../messagebuilder.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -15,6 +15,7 @@ #include "messagebuilder.h" // Qt +#include // Project #include "logger.h" @@ -105,13 +106,13 @@ */ bool MessageBuilder::addActionId(QByteArray &vPayload, Gui::GuiActionType vAction) { - if (vAction != Gui::GuiActionType::Unknown) { + if (vAction != Gui::GuiActionType::ID_Unknown) { quint16 mAction = static_cast(vAction); vPayload += (mAction >> 8) & 0xFF; // high byte vPayload += mAction & 0xFF; // low byte } else { QString mHexString = Format::toHexString(vAction, false, eLenMessageIDDigits); - LOG_ERROR(tr("Incorrect Action ID '%1'").arg(mHexString)); + LOG_DEBUG(QString("Incorrect Action ID '%1'").arg(mHexString)); return false; } return true; @@ -138,9 +139,12 @@ } } if (vData.length() < len) { - QString mHexString = Format::toHexString(vAction, false, eLenMessageIDDigits); - LOG_ERROR(tr("Not enough data has been provided for the Message ID '%1'").arg(mHexString)); - LOG_ERROR(vData.toHex('.')); + QString mHexMIdString = Format::toHexString(vAction, false, eLenMessageIDDigits); + QString mHexDatString = vData.toHex('.').toUpper(); + LOG_DEBUG(QString("Not enough data has been provided for the Message ID '%1'\r\n%2") + .arg(mHexMIdString) + .arg(mHexDatString) + ); return false; } vPayload += len; @@ -227,7 +231,7 @@ quint8 mBeenRead = 0; if ( ! checkCRC(crcData, mExpected, mBeenRead ) ) { // CRC is always next byte after Data static quint64 erCRC = 0; - LOG_ERROR(tr("%1 - CRC error, expected %2 but got %3 : %4") + LOG_DEBUG(QString("%1 - CRC error, expected %2 but got %3 : %4") .arg(++erCRC) .arg(Format::toHexString(mExpected, true, eLenCRCDigits)) .arg(Format::toHexString(mBeenRead, true, eLenCRCDigits)) @@ -257,12 +261,12 @@ vMessage.can_id = vCan_Id; vMessage.head = getHeader (mPayload); // keep header before taking it out of the payload. doesn't affect payload vMessage.sequence = getSequence (mPayload); - vMessage.actionId = getActionId (mPayload); + vMessage.actionId = static_cast(getActionId(mPayload)); vMessage.length = getLength (mPayload); vMessage.data = getData (mPayload, vMessage.length); vMessage.initialized = true; } else { // Expected Header but got pure data - LOG_ERROR(tr("Expected Header, got frame without Sync byte")); + LOG_DEBUG(QString("Expected Header, got frame without Sync byte")); printPayload(vPayload, false ,vCan_Id); return false; } @@ -283,6 +287,23 @@ } /*! + * \brief MessageBuilder::enableConsoleOut + * \details + * \param vEnabled + */ +void MessageBuilder::enableConsoleOut(bool vEnabled) { + // coco begin validated: This code meant to be used only for debugging and tested manually + if (_enableConsoleOut == vEnabled) return; + _enableConsoleOut = vEnabled; + if (_enableConsoleOut) { + LOG_DEBUG("Console out MessageBuilder enabled"); + } else { + LOG_DEBUG("Console out MessageBuilder disabled"); + } +} +// coco end + +/*! * \brief MessageBuilder::hasSyncByte * \details Checks for Sync byte and take it out of vPayload * \param vPayload - The payload of type QByteArray @@ -337,7 +358,7 @@ { QByteArray headInfo; if (vPayload.length() < eLenHeaderInfo) { - LOG_ERROR("Incorrect Message Header"); + LOG_DEBUG("Incorrect Message Header"); return headInfo; } for (int i = 0; i < eLenHeaderInfo; i++) { @@ -355,12 +376,11 @@ * \note Removes the 2 bytes of ActionID from vPayload * It starts from the first byte so those 2 bytes should be the first 2 bytes. */ -Gui::GuiActionType MessageBuilder::getActionId(QByteArray &vPayload) +quint16 MessageBuilder::getActionId(QByteArray &vPayload) { - quint16 mActionId; - mActionId = (vPayload[0] << 8) | vPayload[1]; + quint16 mActionId = vPayload.mid(0,eLenActionId).toHex().toUInt(0,16); vPayload = vPayload.mid(eLenActionId); - return static_cast(mActionId); + return mActionId; } /*! @@ -464,8 +484,5 @@ void MessageBuilder::consoleOut(const QByteArray &vPayload, bool vIsHeader, Can_Id vCan_Id, bool vUseColor) { if ( ! _enableConsoleOut) return; - - LOG_EVENT_ONCE(QObject::tr("console out MessageDispatcher Enabled")); - printPayload(vPayload, vIsHeader, vCan_Id, vUseColor); } Index: sources/canbus/messagebuilder.h =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/canbus/messagebuilder.h (.../messagebuilder.h) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/canbus/messagebuilder.h (.../messagebuilder.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -71,7 +71,7 @@ bool hasSyncByte ( QByteArray &vPayload); Sequence getSequence ( QByteArray &vPayload); QByteArray getHeader (const QByteArray &vPayload); - Gui::GuiActionType getActionId ( QByteArray &vPayload); + quint16 getActionId ( QByteArray &vPayload); int getLength ( QByteArray &vPayload); QByteArray getData (const QByteArray &vPayload, int vLen); @@ -86,7 +86,7 @@ // build message from received frames bool buildMessage(const QByteArray &vPayload, Message &vMessage, Can_Id vCan_Id) __attribute_warn_unused_result__; - void enableConsoleOut(bool vEnabled) { _enableConsoleOut = vEnabled; } + void enableConsoleOut(bool vEnabled); Index: sources/canbus/messagedispatcher.cpp =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/canbus/messagedispatcher.cpp (.../messagedispatcher.cpp) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/canbus/messagedispatcher.cpp (.../messagedispatcher.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -45,10 +45,10 @@ if ( _init ) return false; _init = true; - // runs in USBWatcher thread + // runs in DriveWatcher thread initConnections(); - LOG_EVENT(QObject::tr("%1 Initialized").arg(metaObject()->className())); + LOG_EVENT("UI," + tr("%1 Initialized").arg(metaObject()->className())); return true; } @@ -103,9 +103,6 @@ connect(&_MessageAcknowModel , SIGNAL(didFailedTransmit( Sequence )), this , SLOT( onFailedTransmit( Sequence ))); - // From HD -> Message interpreter -// ACTION_RECEIVE_INTERPRETER_CONNECTIONS - // ---- Signal/Slots ADJUST_TRANSMT_MODEL_BRIDGE_CONNECTIONS(_ApplicationController) ACTION_RECEIVE_MODEL_BRIDGE_CONNECTIONS(_interpreter ) @@ -228,7 +225,7 @@ QVariantList mData; mData += vData.bloodFlow; mData += vData.dialysateFlow; - onActionTransmit(GuiActionType::AdjustBloodDialysateReq, mData); + onActionTransmit(GuiActionType::ID_AdjustBloodDialysateReq, mData); } /*! @@ -241,7 +238,7 @@ { QVariantList mData; mData += vData.duration; - onActionTransmit(GuiActionType::AdjustDurationReq, mData); + onActionTransmit(GuiActionType::ID_AdjustDurationReq, mData); } /*! @@ -254,7 +251,7 @@ { QVariantList mData; mData += vData.requestedState; - actionTransmit(GuiActionType::AdjustUltrafiltrationStateReq, mData); + actionTransmit(GuiActionType::ID_AdjustUltrafiltrationStateReq, mData); } /*! @@ -267,7 +264,7 @@ { QVariantList mData; mData += vData.volume; - onActionTransmit(GuiActionType::AdjustUltrafiltrationEditReq, mData); + onActionTransmit(GuiActionType::ID_AdjustUltrafiltrationEditReq, mData); } /*! @@ -281,7 +278,7 @@ QVariantList mData; mData += vData.volume; mData += vData.option; - onActionTransmit(GuiActionType::AdjustUltrafiltrationConfirmReq, mData); + onActionTransmit(GuiActionType::ID_AdjustUltrafiltrationConfirmReq, mData); } @@ -305,7 +302,7 @@ QByteArray mData; if (! _interpreter.interpretMessage(vActionId, vData, mData)) { - LOG_ERROR(tr("Incorrect Message, can't be interpreted")); + LOG_DEBUG(QString("Incorrect Message, can't be interpreted, %1").arg(Format::toHexString(vActionId))); // TODO : LOGGINF IMPROVEMENT return; } @@ -315,14 +312,14 @@ bool mNeedsAcknow = needsAcknow(vActionId); if (mNeedsAcknow) { mSequence = -mSequence; - LOG_EVENT(tr("UI Ack Req %1").arg(mSequence)); + LOG_EVENT(tr("UI,Ack Req, Sq:%1, ID:%2").arg(mSequence).arg(Format::toHexString(vActionId))); #ifdef DEBUG_ACKBACK_HD_TO_UI qDebug() << tr(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ UI AckReq : %1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ").arg(mSequence); #endif } if ( ! _builder.buildFrames(vActionId, mData, frameList, mSequence) ) { - LOG_ERROR(tr("Incorrect Message can't be built")); + LOG_DEBUG(QString("Incorrect Message can't be built")); // TODO : LOGGINF IMPROVEMENT return; } if (mNeedsAcknow) { @@ -359,7 +356,8 @@ bool MessageDispatcher::buildMessage(Can_Id vCan_Id, const QByteArray &vPayload) { if (vPayload.length() < eLenCanFrame) { - LOG_ERROR(tr("Incorrect frame length. Exp:%1,got:%2").arg(eLenCanFrame).arg(vPayload.length())); + // Each frame has to have exactly 8 (eLenCanFrame) bytes of data and not used bytes should be passed as 00. + LOG_DEBUG(QString("Incorrect frame length. Exp:%1,got:%2").arg(eLenCanFrame).arg(vPayload.length())); return false; } if (! _builder.buildMessage(vPayload, _messageList[vCan_Id].last(), vCan_Id)) { @@ -388,8 +386,8 @@ ok = true; GuiActionType mActionId = vMessage.actionId; switch (mActionId) { - case GuiActionType::Acknow: - LOG_EVENT(tr("HD Ack Bak %1").arg(mSequence)); + case GuiActionType::ID_Acknow: + LOG_EVENT(tr("HD,Ack Bak, Sq:%1").arg(mSequence)); #ifdef DEBUG_ACKBACK_HD_TO_UI qDebug() << tr(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ HD AckBak : %1 %2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ").arg(mSequence).arg(vMessage.actionId); #endif @@ -398,12 +396,13 @@ default: if (mSequence < 0) { - LOG_EVENT(tr("HD Ack Req %1").arg(mSequence)); + LOG_EVENT(tr("HD,Ack Req, Sq:%1, ID:%2").arg(mSequence).arg(Format::toHexString(mActionId))); #ifdef DEBUG_ACKBACK_HD_TO_UI qDebug() << tr(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ HD AckReq : %1 %2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ").arg(mSequence).arg(vMessage.actionId); #endif // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ UI AckBak is immediately handled at the same place. - actionTransmit(GuiActionType::Acknow, {}, -mSequence); + actionTransmit(GuiActionType::ID_Acknow, {}, -mSequence); + LOG_EVENT(tr("UI,Ack Bak, Sq:%1").arg(-mSequence)); #ifdef DEBUG_ACKBACK_HD_TO_UI qDebug() << tr(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ UI AckBak : %1 %2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ").arg(-mSequence).arg(vMessage.actionId); #endif Index: sources/canbus/messagedispatcher.h =================================================================== diff -u -r90bcc276f2a879169fef20e9168711cf906c0e54 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/canbus/messagedispatcher.h (.../messagedispatcher.h) (revision 90bcc276f2a879169fef20e9168711cf906c0e54) +++ sources/canbus/messagedispatcher.h (.../messagedispatcher.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,15 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * \copyright - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, - * IN PART OR IN WHOLE, - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. - * - * \file messagepacker.h - * \date 12/9/2019 - * \author Behrouz NematiPour - * + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file messagedispatcher.h + * \author (last) Peter Lucia + * \date (last) 25-Jun-2020 + * \author (original) Behrouz NematiPour + * \date (original) 09-Dec-2019 + * */ #pragma once @@ -107,6 +108,7 @@ GuiActionType::ID_AdjustUltrafiltrationStateReq , GuiActionType::ID_AdjustUltrafiltrationEditReq , GuiActionType::ID_AdjustUltrafiltrationConfirmReq , + GuiActionType::ID_AlarmSilenceReq , }; // Singleton @@ -183,6 +185,13 @@ */ void didFrameTransmit (Can_Id vCan_Id, const QByteArray &vPayload); + /*! + * \brief didFailedTransmit + * \details When a message fails to transmit to the HD, emit this signal. + * \param vSequence - The message Sequence we that failed to send. + */ + void didFailedTransmit(Sequence vSequence); + private slots: // A Frame has been received from CanInterface void onFrameReceive (Can_Id vCan_Id, const QByteArray &vPayload); Index: sources/canbus/messageglobals.h =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/canbus/messageglobals.h (.../messageglobals.h) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/canbus/messageglobals.h (.../messageglobals.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -44,50 +44,70 @@ */ const QHash payloadLen { // ---- - {Gui::GuiActionType::PowerOff , 1 }, - {Gui::GuiActionType::PowerOffBroadcast , 0 }, - {Gui::GuiActionType::KeepAlive , 255 }, // 0 => 255 to be able to run a multi-frame test. - {Gui::GuiActionType::BloodFlow , 7 * 4 }, // 7 parameters each 4bytes - {Gui::GuiActionType::DialysateInletFlow , 7 * 4 }, // 7 parameters each 4bytes - {Gui::GuiActionType::DialysateOutletFlow , 7 * 4 }, // 7 parameters each 4bytes - {Gui::GuiActionType::TreatmentTime , 3 * 4 }, // 3 parameters each 4bytes - {Gui::GuiActionType::PressureOcclusion , 5 * 4 }, // 5 parameters each 4bytes - {Gui::GuiActionType::AlarmSilenceReq , 5 * 4 }, // 5 parameters each 4bytes - {Gui::GuiActionType::AlarmSilenceRsp , 5 * 4 }, // 5 parameters each 4bytes - {Gui::GuiActionType::LoadCellReadings , 4 * 4 }, // 4 parameters each 4bytes - {Gui::GuiActionType::TemperatureSensors , 12 * 4 }, // 12 parameters each 4bytes + {Gui::GuiActionType::ID_PowerOff , 1 }, + {Gui::GuiActionType::ID_ShuttingDown , 0 }, + {Gui::GuiActionType::ID_KeepAlive , 255 }, // 0 => 255 to be able to run a multi-frame test. + // ----- + {Gui::GuiActionType::ID_TreatmentTime , 3 * 4 }, // 3 parameters each 4bytes + {Gui::GuiActionType::ID_BloodFlow , 7 * 4 }, // 7 parameters each 4bytes + {Gui::GuiActionType::ID_DialysateInletFlow , 7 * 4 }, // 7 parameters each 4bytes + {Gui::GuiActionType::ID_DialysateOutletFlow , 7 * 4 }, // 7 parameters each 4bytes + {Gui::GuiActionType::ID_PressureOcclusion , 5 * 4 }, // 5 parameters each 4bytes + // ---- - {Gui::GuiActionType::AlarmStatus , 4 * 4 + 2 }, // 4 parameters each 4bytes + 1 parameter 2bytes + {Gui::GuiActionType::ID_HDOperationModeData , 1 * 4 }, // 1 parameter each 4bytes // ---- - {Gui::GuiActionType::TreatmentRanges , 6 * 4 }, // 6 parameters each 4bytes + {Gui::GuiActionType::ID_DGROPumpData , 3 * 4 }, // 3 parameters each 4bytes + {Gui::GuiActionType::ID_DGPressuresData , 4 * 4 }, // 4 parameters each 4bytes + {Gui::GuiActionType::ID_DGDrainPumpData , 2 * 4 }, // 2 parameters each 4bytes + {Gui::GuiActionType::ID_DGOperationModeData , 1 * 4 }, // 1 parameter each 4bytes + {Gui::GuiActionType::ID_DGReservoirData , 3 * 4 }, // 3 parameters each 4bytes + {Gui::GuiActionType::ID_DGValvesStatesData , 1 * 2 }, // 1 parameters each 2bytes + {Gui::GuiActionType::ID_DGHeatersData , 3 * 4 }, // 3 parameters each 4bytes + {Gui::GuiActionType::ID_DGLoadCellReadingsData , 4 * 4 }, // 4 parameters each 4bytes + {Gui::GuiActionType::ID_DGTemperaturesData , 12 * 4 }, // 12 parameters each 4bytes // ---- - {Gui::GuiActionType::AdjustBloodDialysateReq , 2 * 4 }, // 2 parameters each 4bytes - {Gui::GuiActionType::AdjustBloodDialysateRsp , 4 * 4 }, // 4 parameters each 4bytes + {Gui::GuiActionType::ID_AlarmStatus , 4 * 4 + 2 }, // 4 parameters each 4bytes + 1 parameter 2bytes + {Gui::GuiActionType::ID_AlarmTriggered , 1 * 4 }, // 1 parameter each 4bytes + {Gui::GuiActionType::ID_AlarmCleared , 1 * 4 }, // 1 parameter each 4bytes + {Gui::GuiActionType::ID_AlarmSilenceReq , 5 * 4 }, // 5 parameters each 4bytes + {Gui::GuiActionType::ID_AlarmSilenceRsp , 5 * 4 }, // 5 parameters each 4bytes // ---- - {Gui::GuiActionType::AdjustDurationReq , 1 * 4 }, // 1 parameters each 4bytes - {Gui::GuiActionType::AdjustDurationRsp , 4 * 4 }, // 4 parameters each 4bytes + {Gui::GuiActionType::ID_TreatmentRanges , 6 * 4 }, // 6 parameters each 4bytes + {Gui::GuiActionType::ID_TreatmentStates , 3 * 4 }, // 3 parameters each 4bytes // ---- - {Gui::GuiActionType::AdjustUltrafiltrationStateReq , 1 * 4 }, // 1 parameters each 4bytes + {Gui::GuiActionType::ID_AdjustBloodDialysateReq , 2 * 4 }, // 2 parameters each 4bytes + {Gui::GuiActionType::ID_AdjustBloodDialysateRsp , 4 * 4 }, // 4 parameters each 4bytes // ---- - {Gui::GuiActionType::AdjustUltrafiltrationEditReq , 1 * 4 }, // 1 parameters each 4bytes - {Gui::GuiActionType::AdjustUltrafiltrationEditRsp , 8 * 4 }, // 8 parameters each 4bytes + {Gui::GuiActionType::ID_AdjustDurationReq , 1 * 4 }, // 1 parameter each 4bytes + {Gui::GuiActionType::ID_AdjustDurationRsp , 4 * 4 }, // 4 parameters each 4bytes // ---- - {Gui::GuiActionType::AdjustUltrafiltrationConfirmReq , 2 * 4 }, // 2 parameters each 4bytes - {Gui::GuiActionType::AdjustUltrafiltrationConfirmRsp , 5 * 4 }, + {Gui::GuiActionType::ID_AdjustUltrafiltrationStateReq , 1 * 4 }, // 1 parameter each 4bytes // ---- - {Gui::GuiActionType::CanBUSFaultCount , 1 }, - {Gui::GuiActionType::String , 255 }, - {Gui::GuiActionType::Acknow , 0 }, - {Gui::GuiActionType::AcknowGeneric , 1 }, + {Gui::GuiActionType::ID_AdjustUltrafiltrationEditReq , 1 * 4 }, // 1 parameter each 4bytes + {Gui::GuiActionType::ID_AdjustUltrafiltrationEditRsp , 8 * 4 }, // 8 parameters each 4bytes + // ---- + {Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmReq , 2 * 4 }, // 2 parameters each 4bytes + {Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmRsp , 5 * 4 }, + + // ---- + {Gui::GuiActionType::ID_CANBusFaultCount , 1 }, + {Gui::GuiActionType::ID_RawData , 255 }, + {Gui::GuiActionType::ID_Acknow , 0 }, + {Gui::GuiActionType::ID_AcknowGeneric , 1 }, + + {Gui::GuiActionType::ID_HDDebugText , 40 + 1 }, // ASCII text - 40 bytes + null term + {Gui::GuiActionType::ID_DGDebugText , 40 + 1 }, // ASCII text - 40 bytes + null term + }; /*! @@ -147,7 +167,7 @@ eChlid_UI_HD = 0x100, ///< UI => HD [Out] // UI lessens occasionally - eChlid_DG_UI = eChlid_DG_Alarm, ///< No direct channel has been defined between DG&UI, May be required for logging + eChlid_DG_UI = 0x070, ///< No direct channel has been defined between DG&UI, May be required for logging eChlid_UI_DG = eChlid_UI_Sync , ///< No direct channel has been defined between DG&UI, May be required for logging }; @@ -158,7 +178,7 @@ struct Message { // TODO : Should be converted to MessageModel class // no time left for now !!! Can_Id can_id; Sequence sequence = 0; // seq 0 is invalid - Gui::GuiActionType actionId = Gui::GuiActionType::Unknown; + Gui::GuiActionType actionId = Gui::GuiActionType::ID_Unknown; int length = 0; QByteArray head; QByteArray data; Index: sources/canbus/messageinterpreter.cpp =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/canbus/messageinterpreter.cpp (.../messageinterpreter.cpp) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/canbus/messageinterpreter.cpp (.../messageinterpreter.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -16,13 +16,26 @@ // Qt #include +// #include // Project #include "logger.h" #include "format.h" using namespace Can; +#define DEBUG_RECEIVE_SIGNAL(vID, vMODEL) // Debug() << #vID << #vMODEL; + +// This define helps to prevent having multiple overloaded functions for each model +#define EMIT_RECEIVE_SIGNAL(vID, vMODEL) { \ + vMODEL mModel; \ + ok = prepareData(vMessage, vID, mModel, vData); \ + if ( ! ok ) return false; \ + emit didActionReceive(mModel.data()); \ + logReceivedMessage(mModel); \ + DEBUG_RECEIVE_SIGNAL(vID, vMODEL) \ +} + /*! * \brief MessageInterpreter::MessageInterpreter * \details Constructor @@ -31,6 +44,13 @@ */ MessageInterpreter::MessageInterpreter(QObject *parent) : QObject(parent) { } +/*! + * \brief MessageInterpreter::isType + * \details Checks if this is the message intended to be + * \param vMessage - The message + * \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 { if ( vMessage.actionId != vType ) { @@ -39,21 +59,107 @@ return true; } +/*! + * \brief MessageInterpreter::isPayloadLenValid + * \details Checks if the Data length has been defined for this type od messsage + * if not logs Undefind Data Length error + * if defined checks if the correct length of data is provided for this type of message. + * if not logs Incorrect Data Length error + * otherwise returns true + * \param vMessage - The message + * \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 { QString mActionIdHexString = Format::toHexString(vMessage.actionId); if ( ! payloadLen.contains(vType) ) { - LOG_ERROR(tr("Undefined data length for Message ID (HD) '%1'").arg(mActionIdHexString)); + LOG_DEBUG(QString("Undefined data length for received Message with ID '%1'").arg(mActionIdHexString)); return false; } if ( vMessage.data.length() < payloadLen[vType] ) { - LOG_ERROR(tr("Incorrect data length for Message ID (HD) '%1'").arg(mActionIdHexString)); + LOG_DEBUG(QString("Incorrect data length for received Message with ID '%1'").arg(mActionIdHexString)); return false; } return true; } +void MessageInterpreter::logInvalidLength(const Gui::GuiActionType &vActionId) +{ + QString mActionIdHexString = Format::toHexString(vActionId); + LOG_DEBUG(QString("Incorrect data length for trsansmit Message with ID '%1'") + .arg(mActionIdHexString)); +} + /*! + * \brief MessageInterpreter::validateMessage + * \details Validate the messgae by checking its type and data + * \param vMessage - The message + * \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 +{ + if ( ! isType (vMessage, vType) ) return false; + if ( ! isPayloadLenValid(vMessage, vType) ) return false; + return true; +} + +/*! + * \brief MessageInterpreter::printUnhandled + * \details Prints out the formatted string of the vMessage of type Message + * In case the Message ID of received CANBUS message + * is known to the interpreter but has not been handled/implemented. + * \param vMessage - The message contains Unhandled Message ID + */ +void MessageInterpreter::printUnhandled(const Message &vMessage) const +{ + if ( gDisableUnhandledReport ) return; + QString mActionIdHexString = Format::toHexString(vMessage.actionId, false, eLenMessageIDDigits); + QString logMessage = tr("Unhandled Message ID (HD)") + '\n' + + QString("%1 # %2 %3") + .arg(int(vMessage.can_id), 3, 16, QChar('0')) + .arg(mActionIdHexString) + .arg(QString(vMessage.data.toHex('.'))); + LOG_DEBUG(logMessage); +} + +/*! + * \brief MessageInterpreter::prepareData + * \details Checks and Prepaires the model with the Message Data + * \param vMessage - The Denali message + * \param vID - The Message ID to be checked against + * \param vModel - The appropriate model for the Message Data + * \param vData - A QVariant list of the Message Data which will be used for debugging if needed. + * \return true on successful check and prepare. + */ +bool MessageInterpreter::prepareData(const Message &vMessage, Gui::GuiActionType vID, Model::MAbstract &vModel, QVariantList &vData) +{ + bool ok = false; + if ( ! isValidMessage(vMessage, vID) ) return ok; + ok = vModel.fromByteArray(vMessage.data); + vModel.toVariantList(vData); + return ok; +} + +/*! + * \brief MessageInterpreter::logReceived + * \details Regarding the type of message logs the message recived. + * \param vModel - the MAbstract model type + */ +void MessageInterpreter::logReceivedMessage(const Model::MAbstract &vModel) +{ + switch (vModel.typeText()) { + case Model::MAbstract::Type_Enum::eDatum: + LOG_DATUM(vModel.toString()); + break; + case Model::MAbstract::Type_Enum::eEvent: + LOG_EVENT(vModel.toString()); + break; + } +} + +/*! * \brief MessageInterpreter::interpretMessage * \details This method will be called * to interpret messages from UI regarding vActionId. @@ -68,83 +174,75 @@ bool MessageInterpreter::interpretMessage(const Gui::GuiActionType &vActionId, const QVariantList &vData, QByteArray &vPayload) { bool ok = true; + QString mSenderID = "UI,"; + vPayload.clear(); - int count = vData.count(); + int count = vData.length(); + switch (vActionId) { // notice we are in transmit mode - case Gui::GuiActionType::PowerOff: - if (count) { - vPayload += vData[0].toUInt(); - } else { - QString mActionIdHexString = Format::toHexString(vActionId); - LOG_ERROR(tr("Incorrect data for Message ID (UI) '%1'").arg(mActionIdHexString)); - ok = false; - } - break; + case Gui::GuiActionType::ID_Acknow: + break; // No data, Just registered - case Gui::GuiActionType::KeepAlive: - // Nothing needs to be done. - // KeepAlive has No data. - // Mentioned in the switch/case to be registered as a valid message. - // - // Note : added this line to be able to do the Fake Test - if (count) { + + case Gui::GuiActionType::ID_KeepAlive: + if ( count ) { // this message has a variable length vPayload = Format::fromVariant(vData[0]); } + LOG_EVENT(mSenderID + QString("CheckIn")); break; - case Gui::GuiActionType::Acknow: - // Nothing needs to be done. - // Acknow has No data. - // Mentioned in the switch/case to be registered as a valid message. - break; - - case Gui::GuiActionType::String: - if (count) { + case Gui::GuiActionType::ID_RawData: + if ( count ) { // this message has a variable length vPayload = Format::fromVariant(vData[0]); } + LOG_EVENT(mSenderID + QString("RawData")); break; - case Gui::GuiActionType::AdjustBloodDialysateReq: - if (count) { - vPayload = Format::fromVariant(vData); - } + case Gui::GuiActionType::ID_PowerOff: + if ( ! count ) { logInvalidLength(vActionId); return false; } + vPayload += Format::fromVariant(vData); + LOG_EVENT(AdjustPowerOffRequestData::toString(vData)); break; - case Gui::GuiActionType::AdjustDurationReq: - if (count) { - vPayload = Format::fromVariant(vData); - } + case Gui::GuiActionType::ID_AdjustBloodDialysateReq: + if ( ! count ) { logInvalidLength(vActionId); return false; } + vPayload = Format::fromVariant(vData); + LOG_EVENT(AdjustBloodDialysateRequestData::toString(vData)); break; - // coco begin validated: Placeholder until AlarmSilenceReq - case Gui::GuiActionType::AlarmSilenceReq: - if (count) { - vPayload = Format::fromVariant(vData); - } + case Gui::GuiActionType::ID_AdjustDurationReq: + if ( ! count ) { logInvalidLength(vActionId); return false; } + vPayload = Format::fromVariant(vData); + LOG_EVENT(AdjustDurationRequestData::toString(vData)); break; - // coco end - case Gui::GuiActionType::AdjustUltrafiltrationStateReq: - if (count) { - vPayload = Format::fromVariant(vData); - } + case Gui::GuiActionType::ID_AdjustUltrafiltrationStateReq: + if ( ! count ) { logInvalidLength(vActionId); return false; } + vPayload = Format::fromVariant(vData); + LOG_EVENT(AdjustUltrafiltrationStateRequestData::toString(vData)); break; - case Gui::GuiActionType::AdjustUltrafiltrationEditReq: - if (count) { - vPayload = Format::fromVariant(vData); - } + case Gui::GuiActionType::ID_AdjustUltrafiltrationEditReq: + if ( ! count ) { logInvalidLength(vActionId); return false; } + vPayload = Format::fromVariant(vData); + LOG_EVENT(AdjustUltrafiltrationEditRequestData::toString(vData)); break; - case Gui::GuiActionType::AdjustUltrafiltrationConfirmReq: - if (count) { - vPayload = Format::fromVariant(vData); - } + case Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmReq: + if ( ! count ) { logInvalidLength(vActionId); return false; } + vPayload = Format::fromVariant(vData); + LOG_EVENT(AdjustUltrafiltrationConfirmRequestData::toString(vData)); break; + case Gui::GuiActionType::ID_AlarmSilenceReq: + if ( ! count ) { logInvalidLength(vActionId); return false; } + vPayload = Format::fromVariant(vData); + LOG_EVENT(AlarmSilenceRequestData::toString(vData)); + break; + default: QString mActionIdHexString = Format::toHexString(vActionId); - LOG_ERROR(tr("Unknown Message ID (UI) '%1'").arg(mActionIdHexString)); + LOG_DEBUG(mSenderID + tr("Unknown transmit Message with ID '%1'").arg(mActionIdHexString)); ok = false; break; @@ -169,45 +267,23 @@ { bool ok = false; switch (vMessage.can_id) { - case eChlid_HD_UI: + case eChlid_HD_UI : case eChlid_HD_Alarm: - case eChlid_HD_Sync: - ok = interpretMessage_HD(vMessage, vData); - break; - // coco begin validated: Is a placeholder and There is no definition/implementation of DG communication with UI. - case eChlid_DG_UI: - //case eChlid_DG_Alarm: - case eChlid_DG_Sync: - ok = interpretMessage_DG(vMessage, vData); - break; + case eChlid_HD_Sync : ok = interpretMessage_HD(vMessage, vData); break; + // coco-begin-validated: Is a placeholder and There is no definition/implementation of DG communication with UI. + case eChlid_DG_UI : + case eChlid_DG_Alarm: + case eChlid_DG_Sync : ok = interpretMessage_DG(vMessage, vData); break; + default: break; - // coco end + // coco-end } return ok; } /*! - * \brief MessageInterpreter::printUnhandled - * \details Prints out the formatted string of the vMessage of type Message - * In case the Message ID of received CANBUS message - * is known to the interpreter but has not been handled/implemented. - * \param vMessage - The message contains Unhandled Message ID - */ -void MessageInterpreter::printUnhandled(const Message &vMessage) -{ - if ( gDisableHunhandledReport ) return; - QString mActionIdHexString = Format::toHexString(vMessage.actionId, false, eLenMessageIDDigits); - QString logMessage = tr("Unhandled Message ID (HD)") + '\n' + - QString("%1 # %2 %3") - .arg(int(vMessage.can_id), 3, 16, QChar('0')) - .arg(mActionIdHexString) - .arg(QString(vMessage.data.toHex('.'))); - LOG_ERROR(logMessage); -} - -/*! * \brief MessageInterpreter::interpretMessage_HD * \details This method will be called * for received messages from HD to interpret the vMessage of type Message @@ -222,100 +298,45 @@ */ bool MessageInterpreter::interpretMessage_HD(const Message &vMessage, QVariantList &vData) { - bool ok = false; + bool ok = false; vData.clear(); - //qDebug() << vMessage.actionId; switch (vMessage.actionId) { // notice we are in receive mode - case Gui::GuiActionType::CanBUSFaultCount: - ok = canbusFaultCountData (vMessage, vData); - break; + // ----- Debug + case Gui::GuiActionType::ID_CANBusFaultCount : ok = canbusFaultCountData (vMessage, vData); break; - case Gui::GuiActionType::PowerOff: { - ok = powerOffData (vMessage, vData); - break; - } - case Gui::GuiActionType::Acknow: - ok = true; - break; + // ----- Datum + case Gui::GuiActionType::ID_TreatmentTime : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_TreatmentTime , Model::MTreatmentTime ); break; + case Gui::GuiActionType::ID_BloodFlow : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_BloodFlow , Model::MBloodFlow ); break; + case Gui::GuiActionType::ID_DialysateInletFlow : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DialysateInletFlow , Model::MDialysateFlow ); break; + case Gui::GuiActionType::ID_DialysateOutletFlow : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DialysateOutletFlow , Model::MOutletFlow ); break; + case Gui::GuiActionType::ID_TreatmentRanges : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_TreatmentRanges , Model::MTreatmentRanges ); break; + case Gui::GuiActionType::ID_PressureOcclusion : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_PressureOcclusion , Model::MPressureOcclusion ); break; + case Gui::GuiActionType::ID_TreatmentStates : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_TreatmentStates , Model::MTreatmentStates ); break; - case Gui::GuiActionType::PowerOffBroadcast: - ok = true; - break; + // ----- Events + case Gui::GuiActionType::ID_HDOperationModeData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_HDOperationModeData , Model::MHDOperationMode ); break; + case Gui::GuiActionType::ID_HDDebugText : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_HDDebugText , Model::MHDDebugText ); break; - case Gui::GuiActionType::BloodFlow: - ok = bloodFlowData (vMessage, vData); - break; + case Gui::GuiActionType::ID_Acknow : ok = true; break; // Needs more investigation for EMIT_RECEIVE_SIGNAL consistency + case Gui::GuiActionType::ID_PowerOff : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_PowerOff , Model::MPowerOff ); break; + case Gui::GuiActionType::ID_ShuttingDown : ok = true; LOG_EVENT("HD,ShuttingDown"); break; // Needs more investigation for EMIT_RECEIVE_SIGNAL consistency + case Gui::GuiActionType::ID_AlarmStatus : ok = alarmStatus (vMessage, vData); break; + case Gui::GuiActionType::ID_AlarmTriggered : ok = alarmTriggered (vMessage, vData); break; + case Gui::GuiActionType::ID_AlarmCleared : ok = alarmCleared (vMessage, vData); break; + case Gui::GuiActionType::ID_AlarmSilenceRsp : ok = alarmSilence (vMessage, vData); break; // Don't think we are going to have response and it is only an Ack. + + // Adjustment Response Messages + case Gui::GuiActionType::ID_AdjustDurationRsp : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_AdjustDurationRsp , Model::MAdjustDurationResponse ); break; + case Gui::GuiActionType::ID_AdjustBloodDialysateRsp : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_AdjustBloodDialysateRsp , Model::MAdjustBloodDialysateResponse ); break; + case Gui::GuiActionType::ID_AdjustUltrafiltrationStateReq : ok = adjustUltrafiltrationState (vMessage, vData); break; // Needs more investigation for EMIT_RECEIVE_SIGNAL consistency + case Gui::GuiActionType::ID_AdjustUltrafiltrationEditRsp : ok = adjustUltrafiltrationEdit (vMessage, vData); break; // Needs more investigation for EMIT_RECEIVE_SIGNAL consistency + case Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmRsp : ok = adjustUltrafiltrationConfirm (vMessage, vData); break; // Needs more investigation for EMIT_RECEIVE_SIGNAL consistency - case Gui::GuiActionType::DialysateInletFlow: - ok = dialysateInletFlowData (vMessage, vData); - break; - - case Gui::GuiActionType::DialysateOutletFlow: - ok = dialysateOutletFlowData (vMessage, vData); - break; - - case Gui::GuiActionType::TreatmentTime: - ok = treatmentTime (vMessage, vData); - break; - - case Gui::GuiActionType::AlarmStatus: - ok = alarmStatus (vMessage, vData); - break; - - case Gui::GuiActionType::PressureOcclusion: - ok = pressureOcclusionData (vMessage, vData); - break; - - case Gui::GuiActionType::TreatmentRanges: - ok = treatmentRangesData (vMessage, vData); - break; - - case Gui::GuiActionType::AdjustBloodDialysateRsp: - ok = adjustBloodDialysateData (vMessage, vData); - break; - - case Gui::GuiActionType::AdjustDurationRsp: - ok = adjustDurationData (vMessage, vData); - break; - - case Gui::GuiActionType::AdjustUltrafiltrationStateReq: // AcknowGeneric : Generic Acknow respose - ok = adjustUltrafiltrationStateData (vMessage, vData); - break; - - case Gui::GuiActionType::AdjustUltrafiltrationEditRsp: - ok = adjustUltrafiltrationEditData (vMessage, vData); - break; - - case Gui::GuiActionType::AdjustUltrafiltrationConfirmRsp: - ok = adjustUltrafiltrationConfirmData (vMessage, vData); - break; - // unhandles messages: these will only be logged as received message // there has nothing been defined for these messages. - case Gui::GuiActionType::AlarmTriggered: - printUnhandled (vMessage); - ok = true; - break; - - case Gui::GuiActionType::AlarmCleared: - printUnhandled (vMessage); - ok = true; - break; - - case Gui::GuiActionType::AlarmSilenceRsp: - printUnhandled (vMessage); - ok = true; - break; - - case Gui::GuiActionType::TreatmentState: - printUnhandled (vMessage); - ok = true; - break; - - default: - printUnhandled (vMessage); - break; + default : printUnhandled (vMessage ); break; } + return ok; } @@ -336,307 +357,89 @@ { bool ok = false; vData.clear(); - switch (vMessage.actionId) { // notice we are in receive mode - case Gui::GuiActionType::LoadCellReadings: - ok = loadCellReadingsData (vMessage, vData); + case Gui::GuiActionType::ID_DGCheckIn: + ok = true; + LOG_EVENT(QString("DG,CheckIn," + QVariant(vData).toStringList().join(','))); break; - case Gui::GuiActionType::TemperatureSensors: - ok = temperatureSensorsData (vMessage, vData); - break; + case Gui::GuiActionType::ID_DGROPumpData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGROPumpData , Model::MDGROPump ); break; + case Gui::GuiActionType::ID_DGPressuresData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGPressuresData , Model::MDGPressures ); break; + case Gui::GuiActionType::ID_DGDrainPumpData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGDrainPumpData , Model::MDGDrainPump ); break; + case Gui::GuiActionType::ID_DGOperationModeData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGOperationModeData , Model::MDGOperationMode ); break; + case Gui::GuiActionType::ID_DGReservoirData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGReservoirData , Model::MDGReservoir ); break; + case Gui::GuiActionType::ID_DGValvesStatesData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGValvesStatesData , Model::MDGValvesStates ); break; + case Gui::GuiActionType::ID_DGHeatersData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGHeatersData , Model::MDGHeaters ); break; + case Gui::GuiActionType::ID_DGLoadCellReadingsData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGLoadCellReadingsData , Model::MDGLoadCellReadings ); break; + case Gui::GuiActionType::ID_DGTemperaturesData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGTemperaturesData , Model::MDGTemperatures ); break; + case Gui::GuiActionType::ID_DGDebugText : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGDebugText , Model::MDGDebugText ); break; + + // unhandles messages: these will only be logged as received message + // there has nothing been defined for these messages. default: - printUnhandled (vMessage); + printUnhandled (vMessage); break; - } - return ok; -} -/*! - * \brief MessageInterpreter::getPowerOffData - * \details This is the method which interprets the PowerOff message data - * in vMessage of type Message. - * to its elements of data. - * \param vMessage - The vMessage of type Message which contains all the data, require to be interpreted. - * \param vData - The BloodFlow data - * \return true if the data can be extracted as defined for PowerOff Message ID - */ -bool MessageInterpreter::getPowerOffData(const Message &vMessage, Model::MPowerOff &vData) -{ - if ( vMessage.actionId != Gui::GuiActionType::PowerOff) { - return false; } - if ( vMessage.data.length() < payloadLen[Gui::GuiActionType::PowerOff] ) { - QString mActionIdHexString = Format::toHexString(vMessage.actionId); - LOG_ERROR(tr("Incorrect data for Message ID (HD) '%1'").arg(mActionIdHexString)); - return false; - } - - vData.fromByteArray(vMessage.data); - - return true; -} - -/*! - * \brief MessageInterpreter::bloodFlowData - * \details Used the getBloodFlowData method and converts each parameter - * in vData of type QVaranitList, to be used in the GUI - * Also logs the data - * \param vMessage - The message - * \param vData - the output data - * \return return value of the method getBloodFlowData - */ -bool MessageInterpreter::powerOffData(const Message &vMessage, QVariantList &vData) -{ - bool ok; - Model::MPowerOff mData; - ok = getPowerOffData(vMessage, mData); - LOG_DATUM(mData.toString()); - - if (ok) { - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - } return ok; } -/*! - * \brief MessageInterpreter::getBloodFlowData - * \details This is the method which interprets the Blood Flow message data in vMessage of type Message - * to its elements of data. - * \param vMessage - The vMessage of type Message which contains all the data, require to be interpreted. - * \param vData - The BloodFlow data - * \return true if the message can be successfully converted to the Blood Flow data elements. - */ -bool MessageInterpreter::getBloodFlowData(const Message &vMessage, Model::MBloodFlow &vData) -{ - if ( vMessage.actionId != Gui::GuiActionType::BloodFlow ) { - return false; - } +// ---------- ---------- Message handlers ---------- ---------- // - if ( vMessage.data.length() < payloadLen[Gui::GuiActionType::BloodFlow] ) { - QString mActionIdHexString = Format::toHexString(vMessage.actionId); - LOG_ERROR(tr("Incorrect data for Message ID (HD) '%1'").arg(mActionIdHexString)); - return false; - } - - vData.fromByteArray(vMessage.data); - - return true; -} - +// ---------- ---------- ---------- ---------- ---------- Debug ---------- ---------- ---------- ---------- ---------- // /*! - * \brief MessageInterpreter::bloodFlowData - * \details Used the getBloodFlowData method and converts each parameter - * in vData of type QVaranitList, to be used in the GUI - * Also logs the data - * \param vMessage - The message - * \param vData - the output data - * \return return value of the method getBloodFlowData + * \brief MessageInterpreter::canbusFaultCountData + * \details This method interprets Fault Count message data + * in vMessage of type Message. This message is only used for debugging purposes. + * \param vMessage - The vMessage of type Message which contains all the data, + * require to be interpreted. + * \param vData - Fault Count data + * \return true if the data can be extracted as defined for Fault Count Message ID */ -bool MessageInterpreter::bloodFlowData(const Message &vMessage, QVariantList &vData) +bool MessageInterpreter::canbusFaultCountData(const Message &vMessage, QVariantList &vData) { - bool ok; - Model::MBloodFlow mData; - ok = getBloodFlowData(vMessage, mData); - LOG_DATUM(mData.toString()); + // TODO : review other methods + bool ok = false; + if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_CANBusFaultCount) ) return ok; + QVariantList mData; + int index = 0; + Types::U32 mCanBUSFaultCount; + ok = GetValue(vMessage.data, index, mCanBUSFaultCount); + // coco begin validated : developer safety if for any reason length of CanBUSFaultCount set to 0 if (ok) { - mData.toVariantList(vData); - emit didActionReceive(mData.data()); + // coco end + vData += mCanBUSFaultCount.value; } return ok; } -/*! - * \brief MessageInterpreter::getDialysateInletFlowData - * \details This is the method which interprets the Dialysate Inlet Flow message data in vMessage of type Message - * to its elements of data. - * \param vMessage - The vMessage of type Message which contains all the data, require to be interpreted. - * \param vData - The dialydate inlet flow data - * \return true if the message can be successfully converted to the Blood Flow data elements. - */ -bool MessageInterpreter::getDialysateInletFlowData(const Message &vMessage, Model::MDialysateFlow &vData) -{ - if ( vMessage.actionId != Gui::GuiActionType::DialysateInletFlow ) { - return false; - } +// ---------- ---------- ---------- ---------- ---------- Events ---------- ---------- ---------- ---------- ---------- // +// ---------- ---------- ---------- ---------- ---------- - HD ---------- ---------- ---------- ---------- ---------- // - if ( vMessage.data.length() < payloadLen[Gui::GuiActionType::DialysateInletFlow] ) { - QString mActionIdHexString = Format::toHexString(vMessage.actionId); - LOG_ERROR(tr("Incorrect data for Message ID (HD) '%1'").arg(mActionIdHexString)); - return false; - } - - vData.fromByteArray(vMessage.data); - - return true; -} - /*! - * \brief MessageInterpreter::dialysateInletFlowData - * \details Used the getDialysateInletFlowData method and converts each parameter - * in vData of type QVaranitList, to be used in the GUI - * Also logs the data - * \param vMessage - The message - * \param vData - the output data - * \return return value of the method getDialysateInletFlowData - */ -bool MessageInterpreter::dialysateInletFlowData(const Message &vMessage, QVariantList &vData) -{ - bool ok; - Model::MDialysateFlow mData; - ok = getDialysateInletFlowData(vMessage, mData); - LOG_DATUM(mData.toString()); - - if (ok) { - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - } - return ok; -} - - -/*! - * \brief MessageInterpreter::getDialysateOutletFlowData - * \details This is the method which interprets the Dialysate Outlet Flow message data in vMessage of type Message - * to its elements of data. - * \param vMessage - The vMessage of type Message which contains all the data, require to be interpreted. - * \param vData - The dialydate outlet flow data (ultrafiltration) - * \return true if the message can be successfully converted to the Blood Flow data elements. - */ -bool MessageInterpreter::getDialysateOutletFlowData(const Message &vMessage, Model::MOutletFlow &vData) -{ - if ( vMessage.actionId != Gui::GuiActionType::DialysateOutletFlow ) { - return false; - } - - if ( vMessage.data.length() < payloadLen[Gui::GuiActionType::DialysateOutletFlow] ) { - QString mActionIdHexString = Format::toHexString(vMessage.actionId); - LOG_ERROR(tr("Incorrect data for Message ID (HD) '%1'").arg(mActionIdHexString)); - return false; - } - - vData.fromByteArray(vMessage.data); - - return true; -} - -/*! - * \brief MessageInterpreter::dialysateOutletFlowData - * \details Used the getDialysateOutletFlowData method and converts each parameter - * in vData of type QVaranitList, to be used in the GUI - * Also logs the data - * \param vMessage - The message - * \param vData - the output data - * \return return value of the method getDialysateOutletFlowData - */ -bool MessageInterpreter::dialysateOutletFlowData(const Message &vMessage, QVariantList &vData) -{ - bool ok; - Model::MOutletFlow mData; - ok = getDialysateOutletFlowData(vMessage, mData); - LOG_DATUM(mData.toString()); - - if (ok) { - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - } - return ok; -} - -/*! - * \brief MessageInterpreter::getDialysateOutletFlowData - * \param vMessage - The vMessage of type Message which contains all the data, require to be interpreted. - * \param vData - Treatment Time data - * \return true if the message can be successfully converted to the Blood Flow data elements. - */ -bool MessageInterpreter::getTreatmentTime( const Message &vMessage , Model::MTreatmentTime &vData) -{ - if ( vMessage.actionId != Gui::GuiActionType::TreatmentTime ) { - return false; - } - - if ( vMessage.data.length() < payloadLen[Gui::GuiActionType::TreatmentTime] ) { - QString mActionIdHexString = Format::toHexString(vMessage.actionId); - LOG_ERROR(tr("Incorrect data for Message ID (HD) '%1'").arg(mActionIdHexString)); - return false; - } - - vData.fromByteArray(vMessage.data); - return true; -} - -/*! - * \brief MessageInterpreter::treatmentTime - * \details Used the getTreatmentTime method and converts each parameter - * in vData of type QVaranitList, to be used in the GUI - * Also logs the data - * \param vMessage - The message - * \param vData - the output data - * \return return value of the method getDialysateOutletFlowData - */ -bool MessageInterpreter::treatmentTime(const Message &vMessage, QVariantList &vData) -{ - bool ok; - Model::MTreatmentTime mData; - ok = getTreatmentTime(vMessage, mData); - LOG_DATUM(mData.toString()); - - if (ok) { - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - } - return ok; -} - -/*! - * \brief MessageInterpreter::getAlarmStatus - * \details This method interprets AlarmStatus message data + * \brief MessageInterpreter::alarmStatus + * \details This method interprets Alarm Status 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 - Alarm Status dta - * \return true if the data can be extracted as defined for AlarmStatus Message ID + * \param vData - Alarm Status data + * \return true if the data can be extracted as defined for Alarm Status Message ID */ -bool MessageInterpreter::getAlarmStatus(const Message &vMessage, Model::MAlarmStatus &vData) -{ - if ( vMessage.actionId != Gui::GuiActionType::AlarmStatus ) { - return false; - } - - if ( vMessage.data.length() < payloadLen[Gui::GuiActionType::AlarmStatus] ) { - QString mActionIdHexString = Format::toHexString(vMessage.actionId); - LOG_ERROR(tr("Incorrect data for Message ID (HD) '%1'").arg(mActionIdHexString)); - return false; - } - - vData.fromByteArray(vMessage.data); - - return true; -} - -/*! - * \brief MessageInterpreter::alarmStatus - * \details Used the getAlarmStatus method and converts each parameter - * in vData of type QVaranitList, to be used in the GUI - * Also logs the data - * \param vMessage - The message - * \param vData - the output data - * \return return value of the method getAlarmStatus - */ bool MessageInterpreter::alarmStatus(const Message &vMessage, QVariantList &vData) { - bool ok; + // TODO : review other methods + bool ok = false; + if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_AlarmStatus) ) return ok; + Model::MAlarmStatus mData; - ok = getAlarmStatus(vMessage, mData); - LOG_DATUM(mData.toString()); + ok = mData.fromByteArray(vMessage.data); + LOG_EVENT("HD," + mData.toString()); - if (ok) { - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - } + mData.toVariantList(vData); + emit didActionReceive(mData.data()); + return ok; // --- an example of unit test --- // @@ -649,73 +452,23 @@ } /*! - * \brief MessageInterpreter::getPressureOcclusionData - * \details This method interprets Pressure Occlusion message data + * \brief MessageInterpreter::alarmTriggered + * \details This method interprets Alarm Triggered 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 - Pressure Occlusion data - * \return true if the data can be extracted as defined for PressureOcclusion Message ID + * \param vData - Alarm Triggered data + * \return true if the data can be extracted as defined for Alarm Triggered Message ID */ -bool MessageInterpreter::getPressureOcclusionData(const Message &vMessage, Model::MPressureOcclusion &vData) +bool MessageInterpreter::alarmTriggered(const Message &vMessage, QVariantList &vData) { - if ( vMessage.actionId != Gui::GuiActionType::PressureOcclusion ) { - return false; - } - - if ( vMessage.data.length() < payloadLen[Gui::GuiActionType::PressureOcclusion] ) { - QString mActionIdHexString = Format::toHexString(vMessage.actionId); - LOG_ERROR(tr("Incorrect data for Message ID (HD) '%1'").arg(mActionIdHexString)); - return false; - } - - vData.fromByteArray(vMessage.data); - - return true; -} - -/*! - * \brief MessageInterpreter::pressureOcclusionData - * \details Used the getPressureOcclusionData method and converts each parameter - * in vData of type QVaranitList, to be used in the GUI - * Also logs the data - * \param vMessage - The message - * \param vData - the output data - * \return return value of the method getPressureOcclusionData - */ -bool MessageInterpreter::pressureOcclusionData(const Message &vMessage, QVariantList &vData) -{ - bool ok; - Model::MPressureOcclusion mData; - ok = getPressureOcclusionData(vMessage, mData); - LOG_DATUM(mData.toString()); - - if (ok) { - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - } - return ok; -} - -/*! - * \brief MessageInterpreter::treatmentRangesData - * \details This method interprets Treatment Ranges 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 Ranges data - * \return true if the data can be extracted as defined for Treatment Ranges Message ID - */ -bool MessageInterpreter::treatmentRangesData(const Message &vMessage, QVariantList &vData) -{ // TODO : review other methods bool ok = false; - if ( ! isType (vMessage, Gui::GuiActionType::TreatmentRanges) ) return ok; - if ( ! isPayloadLenValid(vMessage, Gui::GuiActionType::TreatmentRanges) ) return ok; + if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_AlarmTriggered) ) return ok; - Model::MTreatmentRanges mData; + Model::MAlarmTriggered mData; ok = mData.fromByteArray(vMessage.data); - LOG_DATUM(mData.toString()); + LOG_EVENT("HD," + mData.toString()); mData.toVariantList(vData); emit didActionReceive(mData.data()); @@ -724,156 +477,51 @@ } /*! - * \brief MessageInterpreter::loadCellReadingsData - * \details This method interprets LoadCellReadings message data + * \brief MessageInterpreter::alarmCleared + * \details This method interprets Alarm Cleared 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 - Load Cell Readings data - * \return true if the data can be extracted as defined for LoadCellReadings Message ID + * \param vData - Alarm Cleared data + * \return true if the data can be extracted as defined for Alarm Cleared Message ID */ -bool MessageInterpreter::loadCellReadingsData(const Message &vMessage, QVariantList &vData) +bool MessageInterpreter::alarmCleared(const Message &vMessage, QVariantList &vData) { // TODO : review other methods bool ok = false; - if ( ! isType (vMessage, Gui::GuiActionType::LoadCellReadings) ) return ok; - if ( ! isPayloadLenValid(vMessage, Gui::GuiActionType::LoadCellReadings) ) return ok; + if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_AlarmCleared) ) return ok; - Model::MLoadCellReadings mData; + Model::MAlarmCleared mData; ok = mData.fromByteArray(vMessage.data); - LOG_DATUM(mData.toString()); + LOG_EVENT("HD," + mData.toString()); mData.toVariantList(vData); emit didActionReceive(mData.data()); return ok; } -/*! - * \brief MessageInterpreter::TemperatureSensorsData - * \details This method interprets TemperatureSensors 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 - Load Cell Readings data - * \return true if the data can be extracted as defined for TemperatureSensors Message ID - */ -bool MessageInterpreter::temperatureSensorsData(const Message &vMessage, QVariantList &vData) -{ - // TODO : review other methods - bool ok = false; - if ( ! isType (vMessage, Gui::GuiActionType::TemperatureSensors) ) return ok; - if ( ! isPayloadLenValid(vMessage, Gui::GuiActionType::TemperatureSensors) ) return ok; +// ---------- ---------- ---------- ---------- ---------- Adjustments ---------- ---------- ---------- ---------- ---------- // - Model::MTemperatureSensors mData; - ok = mData.fromByteArray(vMessage.data); - LOG_DATUM(mData.toString()); - - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - - return ok; -} - - /*! - * \brief MessageInterpreter::loadCellReadingsData - * \details This method interprets LoadCellReadings 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 - Load Cell Readings data - * \return true if the data can be extracted as defined for LoadCellReadings Message ID - */ -bool MessageInterpreter::canbusFaultCountData(const Message &vMessage, QVariantList &vData) -{ - // TODO : review other methods - bool ok = false; - if ( ! isType (vMessage, Gui::GuiActionType::CanBUSFaultCount) ) return ok; - if ( ! isPayloadLenValid(vMessage, Gui::GuiActionType::CanBUSFaultCount) ) return ok; - - QVariantList mData; - int index = 0; - Types::U32 mCanBUSFaultCount; - ok = GetValue(vMessage.data, index, mCanBUSFaultCount); - // coco begin validated : developer safety if for any reason length of CanBUSFaultCount set to 0 - if (ok) { - // coco end - vData += mCanBUSFaultCount.value; - } - return ok; -} - -/*! - * \brief MessageInterpreter::adjustBloodDialysateData - * \details This method interprets AdjustBlood Dialysate 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 - AdjustBlood Dialysate Response data - * \return true if the data can be extracted as defined for AdjustBlood Dialysate Response Message ID - */ -bool MessageInterpreter::adjustBloodDialysateData(const Message &vMessage, QVariantList &vData) -{ - // TODO : review other methods - bool ok = false; - if ( ! isType (vMessage, Gui::GuiActionType::AdjustBloodDialysateRsp) ) return ok; - if ( ! isPayloadLenValid(vMessage, Gui::GuiActionType::AdjustBloodDialysateRsp) ) return ok; - - Model::MAdjustBloodDialysateResponse mData; - ok = mData.fromByteArray(vMessage.data); - LOG_DATUM(mData.toString()); - - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - - return ok; -} - -/*! - * \brief MessageInterpreter::adjustDurationData - * \details This method interprets Treatment Duration 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 Duration Adjustment Response data - * \return true if the data can be extracted as defined for Treatment Duration Adjustment Response Message ID - */ -bool MessageInterpreter::adjustDurationData(const Message &vMessage, QVariantList &vData) -{ - bool ok = false; - if ( ! isType (vMessage, Gui::GuiActionType::AdjustDurationRsp) ) return ok; - if ( ! isPayloadLenValid(vMessage, Gui::GuiActionType::AdjustDurationRsp) ) return ok; - - Model::MAdjustDurationResponse mData; - ok = mData.fromByteArray(vMessage.data); - LOG_DATUM(mData.toString()); - - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - - return ok; -} - -/*! * \brief MessageInterpreter::ultrafiltrationState - * \details This method interprets Treatment Ultrafiltration state change Response message data + * \details This method interprets Treatment Ultrafiltration State 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 state change Response data - * \return true if the data can be extracted as defined for Treatment Duration Adjustment Response Message ID + * \param vData - Treatment Ultrafiltration State Adjustment Response data + * \return true if the data can be extracted as defined for Treatment Ultrafiltration State Adjustment Response Message ID */ -bool MessageInterpreter::adjustUltrafiltrationStateData(const Message &vMessage, QVariantList &vData) +bool MessageInterpreter::adjustUltrafiltrationState(const Message &vMessage, QVariantList &vData) { bool ok = false; - // TODO : The Ultrafiltration State change shall have the rejection reason like other responses. - if ( ! isType (vMessage, Gui::GuiActionType::AdjustUltrafiltrationStateReq) ) return ok; - if ( ! isPayloadLenValid(vMessage, Gui::GuiActionType::AcknowGeneric ) ) return ok; + // TODO : In HD the Ultrafiltration State change shall have the rejection reason like other responses. + if ( ! isType (vMessage, Gui::GuiActionType::ID_AdjustUltrafiltrationStateReq) ) return ok; + if ( ! isPayloadLenValid(vMessage, Gui::GuiActionType::ID_AcknowGeneric ) ) return ok; // This is an exception It has to be changed. Model::MAdjustUltrafiltrationStateResponse mData; ok = mData.fromByteArray(vMessage.data); - LOG_DATUM(mData.toString()); + LOG_EVENT("HD," + mData.toString()); mData.toVariantList(vData); emit didActionReceive(mData.data()); @@ -883,22 +531,21 @@ /*! * \brief MessageInterpreter::adjustUltrafiltrationEditData - * \details This method interprets Treatment Ultrafiltration Adjustment Response message data + * \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 Duration Adjustment Response data - * \return true if the data can be extracted as defined for Treatment Ultrafiltration Adjustment Response Message ID + * \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::adjustUltrafiltrationEditData(const Message &vMessage, QVariantList &vData) +bool MessageInterpreter::adjustUltrafiltrationEdit(const Message &vMessage, QVariantList &vData) { bool ok = false; - if ( ! isType (vMessage, Gui::GuiActionType::AdjustUltrafiltrationEditRsp) ) return ok; - if ( ! isPayloadLenValid(vMessage, Gui::GuiActionType::AdjustUltrafiltrationEditRsp) ) return ok; + if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_AdjustUltrafiltrationEditRsp) ) return ok; Model::MAdjustUltrafiltrationEditResponse mData; ok = mData.fromByteArray(vMessage.data); - LOG_DATUM(mData.toString()); + LOG_EVENT("HD," + mData.toString()); mData.toVariantList(vData); emit didActionReceive(mData.data()); @@ -908,22 +555,21 @@ /*! * \brief MessageInterpreter::adjustUltrafiltrationConfirmData - * \details This method interprets Treatment Ultrafiltration Adjustment Response message data + * \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 Duration Adjustment Response data - * \return true if the data can be extracted as defined for Treatment Ultrafiltration Adjustment Response Message ID + * \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::adjustUltrafiltrationConfirmData(const Message &vMessage, QVariantList &vData) +bool MessageInterpreter::adjustUltrafiltrationConfirm(const Message &vMessage, QVariantList &vData) { bool ok = false; - if ( ! isType (vMessage, Gui::GuiActionType::AdjustUltrafiltrationConfirmRsp) ) return ok; - if ( ! isPayloadLenValid(vMessage, Gui::GuiActionType::AdjustUltrafiltrationConfirmRsp) ) return ok; + if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmRsp) ) return ok; Model::MAdjustUltrafiltrationConfirmResponse mData; ok = mData.fromByteArray(vMessage.data); - LOG_DATUM(mData.toString()); + LOG_EVENT("HD," + mData.toString()); mData.toVariantList(vData); emit didActionReceive(mData.data()); Index: sources/canbus/messageinterpreter.h =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/canbus/messageinterpreter.h (.../messageinterpreter.h) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/canbus/messageinterpreter.h (.../messageinterpreter.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -19,7 +19,7 @@ // Project #include "messageglobals.h" -#include "mmodel.h" +#include "MModel.h" // forward declaration class tst_messaging; @@ -42,70 +42,35 @@ friend class ::tst_messaging; friend class ::tst_logging; - bool isType(const Message &vMessage, Gui::GuiActionType vType) const; - bool isPayloadLenValid(const Message &vMessage, Gui::GuiActionType vType) const; + bool isType (const Message &vMessage, Gui::GuiActionType vType) const; + bool isPayloadLenValid (const Message &vMessage, Gui::GuiActionType vType) const; + bool isValidMessage (const Message &vMessage, Gui::GuiActionType vType) const; - void printUnhandled(const Message &vMessage); + void logInvalidLength (const Gui::GuiActionType &vActionId); - bool interpretMessage_HD(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - bool interpretMessage_DG(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; + void printUnhandled (const Message &vMessage ) const; + bool prepareData (const Message &vMessage, Gui::GuiActionType vID, Model::MAbstract &vModel, QVariantList &vData ); + void logReceivedMessage ( const Model::MAbstract &vModel ); - // ---- PowerOff - bool getPowerOffData(const Message &vMessage, Model::MPowerOff &vData) __attribute_warn_unused_result__; - bool powerOffData(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; + bool interpretMessage_HD (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; + bool interpretMessage_DG (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - // ---- BloodFlowData - bool getBloodFlowData(const Message &vMessage, Model::MBloodFlow &vData) __attribute_warn_unused_result__; - bool bloodFlowData(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; + // ----- Debug + bool canbusFaultCountData (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - // ---- Dialysate Inlet FlowData - bool getDialysateInletFlowData(const Message &vMessage, Model::MDialysateFlow &vData) __attribute_warn_unused_result__; - bool dialysateInletFlowData(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; + // ----- Events + // ----- - HD + bool alarmStatus (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; + bool alarmTriggered (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; + bool alarmCleared (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - // ---- Dialysate Outlet FlowData - bool getDialysateOutletFlowData(const Message &vMessage, Model::MOutletFlow &vData) __attribute_warn_unused_result__; - bool dialysateOutletFlowData(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; + // ----- - DG - // ---- AlarmStatus - bool getAlarmStatus(const Message &vMessage, Model::MAlarmStatus &vData) __attribute_warn_unused_result__; - bool alarmStatus(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; + // ----- Adjustments + bool adjustUltrafiltrationState (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; + bool adjustUltrafiltrationEdit (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; + bool adjustUltrafiltrationConfirm (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - // ---- Treatment Time - bool getTreatmentTime(const Message &vMessage, Model::MTreatmentTime &vData) __attribute_warn_unused_result__; - bool treatmentTime(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - - // ---- Treatment Pressure/Occlusion - bool getPressureOcclusionData(const Message &vMessage, Model::MPressureOcclusion &vData) __attribute_warn_unused_result__; - bool pressureOcclusionData(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - - // ---- Treatment Ranges - bool treatmentRangesData(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - - // ---- Load Cell Readings - bool loadCellReadingsData(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - - // ---- canbus Fault Count - bool canbusFaultCountData(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - - // ---- Temperature Sensors - bool temperatureSensorsData(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - - // ~~~~ Adjustments ~~~~ - // ---- Treatment Adjust response for Blood/Dialysate Flow Rate - bool adjustBloodDialysateData (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - - // ---- Treatment Adjust response for Treatment Duration - bool adjustDurationData (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - - // ---- Treatment Adjust response for Treatment Ultrafiltration - bool adjustUltrafiltrationEditData (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - - // ---- Treatment Adjust response for Treatment Ultrafiltration - bool adjustUltrafiltrationConfirmData (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - - // ---- Treatment Adjust response for Treatment Ultrafiltration state (Pause / Resume) change - bool adjustUltrafiltrationStateData (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - public: explicit MessageInterpreter(QObject *parent = nullptr); @@ -116,7 +81,6 @@ signals: ACTION_RECEIVE_SIGNALS -public slots: }; } Index: sources/gui/guicontroller.cpp =================================================================== diff -u -r90bcc276f2a879169fef20e9168711cf906c0e54 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/gui/guicontroller.cpp (.../guicontroller.cpp) (revision 90bcc276f2a879169fef20e9168711cf906c0e54) +++ sources/gui/guicontroller.cpp (.../guicontroller.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,15 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. - * \copyright \n - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, \n - * IN PART OR IN WHOLE, \n - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. \n - * - * \file guicontroller.cpp - * \date 2019/09/30 - * \author Behrouz NematiPour - * + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file guicontroller.cpp + * \author (last) Peter Lucia + * \date (last) 25-Jun-2020 + * \author (original) Behrouz NematiPour + * \date (original) 24-Sep-2019 + * */ #include "guicontroller.h" @@ -81,6 +82,9 @@ connect(&_ApplicationController, SIGNAL(didExport()), this , SLOT( onExport())); + connect(&_ApplicationController, SIGNAL(didFailedTransmit(Sequence)), + this , SLOT(didFailedTransmit(Sequence))); + // ---- Signal/Slots ACTION_RECEIVE_MODEL_BRIDGE_CONNECTIONS(_ApplicationController) } @@ -277,3 +281,21 @@ emit didExportLog(); } // coco end + +/*! + * \brief GuiController::didFailedTransmit + * Raises an HD communiation timeout alarm if communication with HD is lost. + * \param seq - Sequence that failed to transmit + */ +void GuiController::didFailedTransmit(Sequence seq) +{ + Q_UNUSED(seq); + AlarmStatusData data; + data.mState = GuiAlarmPriority::ALARM_PRIORITY_HIGH; // Alarm priority + data.mTop = GuiAlarmID::ALARM_ID_HD_COMM_TIMEOUT; // Alarm ID + data.mMuteTimeout = 0; // Alarm timeout + data.mEscalatesIn = 0; // Alarm Escalate Time Period + data.mFlags = QBitArray(16, false); // 16 QBitArray of flags, if needed + emit didActionReceive(data); +} + Index: sources/gui/guicontroller.h =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/gui/guicontroller.h (.../guicontroller.h) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/gui/guicontroller.h (.../guicontroller.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,15 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. - * \copyright \n - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, \n - * IN PART OR IN WHOLE, \n - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. \n - * - * \file guicontroller.h - * \date 2019/09/30 - * \author Behrouz NematiPour - * + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file guicontroller.h + * \author (last) Peter Lucia + * \date (last) 25-Jun-2020 + * \author (original) Behrouz NematiPour + * \date (original) 24-Sep-2019 + * */ #pragma once @@ -24,6 +25,8 @@ // define #define _GuiController GuiController::I() +using namespace Can; + // namespace namespace Gui { @@ -66,6 +69,7 @@ void onUSBDriveRemove(); // OS => UI void onExport (); // OS => UI + void didFailedTransmit(Sequence seq); signals: void didActionReceive (GuiActionType vAction, const QVariantList &vData); // UI <= HD/DG Index: sources/gui/guiglobals.cpp =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/gui/guiglobals.cpp (.../guiglobals.cpp) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/gui/guiglobals.cpp (.../guiglobals.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -22,7 +22,7 @@ #include "guiview.h" // Project -#include "mmodel.h" +#include "MModel.h" #include "vview.h" #include "valarmstatus.h" @@ -35,9 +35,17 @@ #include "vtreatmentpressureocclusion.h" #include "vtreatmenttime.h" #include "vtreatmentranges.h" +#include "VHDOperationModeData.h" -#include "vloadcellreadings.h" -#include "vtemperaturesensors.h" +#include "VDGDrainPumpData.h" +#include "VDGHeatersData.h" +#include "VDGLoadCellReadingsData.h" +#include "VDGOperationModeData.h" +#include "VDGPressuresData.h" +#include "VDGROPumpData.h" +#include "VDGReservoirData.h" +#include "VDGTemperaturesData.h" +#include "VDGValvesStatesData.h" #include "vtreatmentadjustmentduration.h" #include "vtreatmentadjustmentflows.h" @@ -61,6 +69,9 @@ qRegisterMetaType ("GuiRequestReasons"); + // Note that this Models are not used in the qml + // but Qt needs them to be registered to be able to use them in between threads queue + // by their metadata information. REGISTER_MODEL_METATYPES } @@ -95,7 +106,7 @@ } else if (vStatus == QQuickView::Error || vStatus == QQuickView::Null) { for (const auto &error : _viewer->errors()) { - LOG_ERROR(QObject::tr("Application Terminated: %1").arg(error.toString())); + LOG_DEBUG(QString("Application Terminated: %1").arg(error.toString())); } QCoreApplication::exit(-1); } Index: sources/gui/guiglobals.h =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/gui/guiglobals.h (.../guiglobals.h) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/gui/guiglobals.h (.../guiglobals.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -39,55 +39,64 @@ * *** Exactly as it is going to be shown/used in denali messages ***\n * *** then it can be compared exactly the way it is with no conversion.***\n */ - enum GuiActionsType_Enum /*: quint16 QML doesn't support enum types */ { - Unknown = 0x0000, + enum GuiActionsType_Enum /* : quint16 QML doesn't support enum types */ { + ID_Unknown = 0x0000, - PowerOff = 0x0100, - KeepAlive = 0x0700, - BloodFlow = 0x0500, - DialysateInletFlow = 0x0800, - DialysateOutletFlow = 0x0B00, - TreatmentTime = 0x0D00, - PowerOffBroadcast = 0x0E00, + ID_CANBusFaultCount = 0x9909, - AlarmStatus = 0x0200, - AlarmTriggered = 0x0300, - AlarmCleared = 0x0400, - AlarmSilenceReq = 0x2F00, // 47 - Not implemented yet on FW side - AlarmSilenceRsp = 0x3000, // 48 - Not implemented yet on FW side + ID_RawData = 0xFFFE, - LoadCellReadings = 0x0C00, + ID_Acknow = 0xFFFF, + ID_AcknowGeneric = 0x0000, //< Generic Acknowledgment is not a unique message ID and inherits its Id from the actual message. Zero is a placeholder - PressureOcclusion = 0x0900, + ID_HDDebugText = 0xF1FF, + ID_DGDebugText = 0xF2FF, - TemperatureSensors = 0x2D00, // 45 + ID_DGCheckIn = 0x0600, + ID_KeepAlive = 0x0700, - AdjustBloodDialysateReq = 0x1700, // 23 - AdjustBloodDialysateRsp = 0x1800, // 24 + ID_PowerOff = 0x0100, + ID_ShuttingDown = 0x0E00, + ID_TreatmentTime = 0x0D00, + ID_BloodFlow = 0x0500, + ID_DialysateInletFlow = 0x0800, + ID_DialysateOutletFlow = 0x0B00, + ID_TreatmentRanges = 0x1A00, // 26 + ID_PressureOcclusion = 0x0900, + ID_TreatmentStates = 0x0F00, // 15 - AdjustUltrafiltrationStateReq = 0x1000, // 16 - // AcknowGeneric : the response is the AcknowGeneric with the same msgID + ID_AlarmStatus = 0x0200, + ID_AlarmTriggered = 0x0300, + ID_AlarmCleared = 0x0400, + ID_AlarmSilenceReq = 0x2F00, // 47 - Not implemented yet on FW side + ID_AlarmSilenceRsp = 0x3000, // 48 - Not implemented yet on FW side - AdjustUltrafiltrationEditReq = 0x1100, // 17 - AdjustUltrafiltrationEditRsp = 0x1300, // 19 + ID_HDOperationModeData = 0x2500, // 37 - AdjustUltrafiltrationConfirmReq = 0x1500, // 21 - AdjustUltrafiltrationConfirmRsp = 0x2E00, // 46 + ID_DGROPumpData = 0x1F00, // 31 + ID_DGPressuresData = 0x2000, // 32 + ID_DGDrainPumpData = 0x2400, // 36 + ID_DGOperationModeData = 0x2700, // 39 + ID_DGReservoirData = 0x2800, // 40 + ID_DGValvesStatesData = 0x2A00, // 42 + ID_DGHeatersData = 0x2C00, // 44 + ID_DGLoadCellReadingsData = 0x0C00, // 12 + ID_DGTemperaturesData = 0x2D00, // 45 - AdjustDurationReq = 0x1600, // 22 - AdjustDurationRsp = 0x1B00, // 27 + ID_AdjustBloodDialysateReq = 0x1700, // 23 + ID_AdjustBloodDialysateRsp = 0x1800, // 24 - TreatmentRanges = 0x1A00, // 26 + ID_AdjustUltrafiltrationStateReq = 0x1000, // 16 + // idAcknowGeneric : the response is the AcknowGeneric with the same msgID - TreatmentState = 0x0F00, // 15 + ID_AdjustUltrafiltrationEditReq = 0x1100, // 17 + ID_AdjustUltrafiltrationEditRsp = 0x1300, // 19 - CanBUSFaultCount = 0x9909, + ID_AdjustUltrafiltrationConfirmReq = 0x1500, // 21 + ID_AdjustUltrafiltrationConfirmRsp = 0x2E00, // 46 - String = 0xFFFE, - - Acknow = 0xFFFF, - AcknowGeneric = 0x0000, //< Generic Acknowledgment is not a unique message ID and inherits its Id from the actual message. Zero is a placeholder - + ID_AdjustDurationReq = 0x1600, // 22 + ID_AdjustDurationRsp = 0x1B00, // 27 }; enum class GuiActionsData_Enum /*: quint8 QML doesn't support*/ { @@ -113,6 +122,13 @@ #include "MsgDefs.h" Q_ENUM(Request_Reject_Reasons) + + #include "HDDefs.h" + Q_ENUM(HD_Op_Modes) + Q_ENUM(UF_Adjustments) + + #include "DGDefs.h" + Q_ENUM(DG_Op_Modes) }; // to be able to use the enum as signal/slot parameter @@ -124,6 +140,12 @@ typedef GuiActions::Request_Reject_Reasons GuiRequestReasons; + typedef GuiActions::HD_Op_Modes GuiHDOpModes; + typedef GuiActions::DG_Op_Modes GuiDGOpModes; + + typedef GuiActions::UF_Adjustments GuiUFAdjustment; + + void registerTypes(); void registerQmlTypes(); Index: sources/gui/qml/globals/Variables.qml =================================================================== diff -u -r2437559b2d4cd4c2ac6a926b4f55652e55e1f616 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/gui/qml/globals/Variables.qml (.../Variables.qml) (revision 2437559b2d4cd4c2ac6a926b4f55652e55e1f616) +++ sources/gui/qml/globals/Variables.qml (.../Variables.qml) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,15 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. - * \copyright \n - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, \n - * IN PART OR IN WHOLE, \n - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. \n - * - * \file Variables.qml - * \date 2019/10/18 - * \author Behrouz NematiPour - * + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file Variables.qml + * \author (last) Peter Lucia + * \date (last) 25-Jun-2020 + * \author (original) Behrouz NematiPour + * \date (original) 09-Oct-2019 + * */ // Qt @@ -24,13 +25,20 @@ QtObject { readonly property int applicationWidth : 1280 readonly property int applicationHeight : 800 + readonly property int buttonSpacing : 150 + readonly property int dialogSVGHeight : 50 + readonly property int dialogSVGWidth : 50 + readonly property int dialogSVGIconOffset : 25 readonly property int headerHeight : 100 readonly property int mainMenuHeight : 70 readonly property int logoWidth : 50 readonly property int logoHeight : 50 + readonly property int largeArrowWidth : 24 + readonly property int largeArrowHeight : 32 + readonly property int arrowWidth : 12 readonly property int arrowHeight : 16 @@ -76,7 +84,15 @@ readonly property int ultrafiltrationAdjustmtenOptionWidth : 520 readonly property int ultrafiltrationAdjustmtenOptionHeight : 275 - // --- PRS Related Section --- + readonly property int silenceIconMargin : 20 + readonly property int notificationBarIconMargin : 10 + readonly property int notificationBarIconHeight : 30 + readonly property int notificationBarIconWidth : 30 + + readonly property int settingsOptionWidth : 550 + readonly property int settingsOptionHeight : 50 + + // ---------- < PRS > Related Section ---------- // Min/Max readonly property int bloodFlowMin : 100 readonly property int bloodFlowMax : 500 Index: sources/gui/qml/main.qml =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/gui/qml/main.qml (.../main.qml) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/gui/qml/main.qml (.../main.qml) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -30,15 +30,23 @@ import VTreatmentTime 0.1; import VAlarmStatus 0.1; import VPowerOff 0.1; +import VHDOperationMode 0.1; import VTreatmentAdjustmentDuration 0.1; import VTreatmentAdjustmentFlows 0.1; import VTreatmentAdjustmentUltrafiltrationState 0.1; import VTreatmentAdjustmentUltrafiltrationEdit 0.1; import VTreatmentAdjustmentUltrafiltrationConfirm 0.1; -import VLoadCellReadings 0.1; -import VTemperatureSensors 0.1; +import VDGDrainPump 0.1; +import VDGHeaters 0.1; +import VDGLoadCellReadings 0.1; +import VDGOperationMode 0.1; +import VDGPressures 0.1; +import VDGROPump 0.1; +import VDGReservoir 0.1; +import VDGTemperatures 0.1; +import VDGValvesStates 0.1; // Qml imports import "qrc:/globals" @@ -60,13 +68,14 @@ onDidActionReceive: { //console.debug(vAction, vData) switch(vAction) { - case GuiActions.PowerOffBroadcast: + case GuiActions.ID_ShuttingDown: _autoHideInfo.showDialog( qsTr("System is shutting down"), 5000 // if any error happens and shutdown is not successful then after 5 seconds dialog hides. ) break; } + } } @@ -94,15 +103,23 @@ _alarm_dialog.visible = false; } } - VPowerOff { id: vPowerOff } + VPowerOff { id: vPowerOff } + VHDOperationMode { id: vHDOperationMode } VTreatmentBloodFlow { id: vTreatmentBloodFlow } VTreatmentDialysateFlow { id: vTreatmentDialysateFlow } VTreatmentPressureOcclusion { id: vTreatmentPressureOcclusion } VTreatmentUltrafiltration { id: vTreatmentUltrafiltration } VTreatmentTime { id: vTreatmentTime } - VLoadCellReadings { id: vLoadCellReadings } - VTemperatureSensors { id: vTemperatureSensors } + VDGDrainPump { id: vDGDrainPump } + VDGHeaters { id: vDGHeaters } + VDGLoadCellReadings { id: vDGLoadCellReadings } + VDGOperationMode { id: vDGOperationMode } + VDGPressures { id: vDGPressures } + VDGROPump { id: vDGROPump } + VDGReservoir { id: vDGReservoir } + VDGTemperatures { id: vDGTemperatures } + VDGValvesStates { id: vDGValvesStates } VTreatmentAdjustmentDuration { id: vTreatmentAdjustmentDuration } VTreatmentAdjustmentFlows { id: vTreatmentAdjustmentFlows } @@ -137,10 +154,10 @@ PowerOff { id: _powerOffDialog onAccepted: { - _GuiView.doActionTransmit(GuiActions.PowerOff, GuiActions.Accepted) + _GuiView.doActionTransmit(GuiActions.ID_PowerOff, GuiActions.Accepted) } onRejected: { - _GuiView.doActionTransmit(GuiActions.PowerOff, GuiActions.Rejected) + _GuiView.doActionTransmit(GuiActions.ID_PowerOff, GuiActions.Rejected) } } Index: sources/gui/qml/pages/ManagerHome.qml =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/gui/qml/pages/ManagerHome.qml (.../ManagerHome.qml) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/gui/qml/pages/ManagerHome.qml (.../ManagerHome.qml) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -17,21 +17,320 @@ import QtQuick 2.12 // Project +import Gui.Actions 0.1; + // Qml imports import "qrc:/globals" import "qrc:/components" +//// The original code kept for later use +// ScreenItem { id: _root +// Column { +// spacing: Variables.columnSpacing +// anchors.centerIn: parent +// TitleText { id: _titleText +// width: parent.width +// text: qsTr("Manager Home Placeholder") +// } +// } +// } + /*! * \brief ManagerHome is the screen * which is the default screen in the "Manager" stack */ ScreenItem { id: _root - Column { - spacing: Variables.columnSpacing - anchors.centerIn: parent - TitleText { id: _titleText - width: parent.width - text: qsTr("Manager Home Placeholder") + + Text { id : _titleText + visible: true + anchors { + top : parent.top + left : parent.horizontalCenter + topMargin : (Variables.headerHeight - Variables.logoHeight) / 2 + horizontalCenter: parent.horizontalCenter } + text: qsTr("~ DG ~") + horizontalAlignment: Text.horizontalCenter + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle } + + Column { id: _DGROPumpColumn + width : 150 + spacing : -5 + topPadding : 75 + leftPadding : 50 + Text { + id: _DGROPump_Title + text: qsTr(" ROPmp ") + width: _DGROPumpColumn.width + horizontalAlignment: Text.AlignRight + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + font.underline: true + } + Repeater { + model: [ + vDGROPump.pressure , + vDGROPump.flowRate .toFixed(2) , + vDGROPump.pwm .toFixed(2) + ] + Text { + objectName: "_DGROPumpData" + index + text: modelData + width: _DGROPumpColumn.width + horizontalAlignment: Text.AlignRight + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + } + } + } + + + Column { id: _DGPressuresColumn + width : 150 + spacing : -5 + topPadding : 75 + leftPadding : 250 + Text { + id: _DGPressures_Title + text: qsTr(" Prssr ") + width: _DGPressuresColumn.width + horizontalAlignment: Text.AlignRight + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + font.underline: true + } + Repeater { + model: [ + vDGPressures.roInletPSI .toFixed(2) , + vDGPressures.roOutletPSI .toFixed(2) , + vDGPressures.drainInletPSI .toFixed(2) , + vDGPressures.drainOutletPSI .toFixed(2) + ] + Text { + objectName: "_DGPressuresData" + index + text: modelData + width: _DGPressuresColumn.width + horizontalAlignment: Text.AlignRight + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + } + } + } + + Column { id: _DGReservoirColumn + width : 150 + spacing : -5 + topPadding : 75 + leftPadding : 450 + Text { + id: _DGReservoir_Title + text: qsTr(" Rsrvr ") + width: _DGReservoirColumn.width + horizontalAlignment: Text.AlignRight + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + font.underline: true + } + Repeater { + model: [ + vDGReservoir.activeReservoir , + vDGReservoir.fillToVol , + vDGReservoir.drainToVol , + ] + Text { + objectName: "_DGReservoirData" + index + text: modelData + width: _DGReservoirColumn.width + horizontalAlignment: Text.AlignRight + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + } + } + } + + Column { id: _DGHeatersColumn + width : 150 + spacing : -5 + topPadding : 75 + leftPadding : 650 + Text { + id: _DGHeaters_Title + text: qsTr(" Heatrs ") + width: _DGHeatersColumn.width + horizontalAlignment: Text.AlignRight + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + font.underline: true + } + Repeater { + model: [ + vDGHeaters.mainPrimaryDC , + vDGHeaters.smallPrimaryDC , + vDGHeaters.trimmerDC , + ] + Text { + objectName: "_DGHeatersData" + index + text: modelData + width: _DGHeatersColumn.width + horizontalAlignment: Text.AlignRight + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + } + } + } + + Column { id: _LoadCellReadingsColumn + width : 150 + spacing : -5 + topPadding : 75 + leftPadding : 850 + Text { + id: _LoadCellReading_Title + text: qsTr(" LoadCl ") + width: _LoadCellReadingsColumn.width + horizontalAlignment: Text.AlignRight + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + font.underline: true + } + Repeater { + model: [ + vDGLoadCellReadings.reservoir1Prim .toFixed(2) , + vDGLoadCellReadings.reservoir1Bkup .toFixed(2) , + vDGLoadCellReadings.reservoir2Prim .toFixed(2) , + vDGLoadCellReadings.reservoir2Bkup .toFixed(2) + ] + Text { + objectName: "_DGLoadCellReadingsData" + index + text: modelData + width: _LoadCellReadingsColumn.width + horizontalAlignment: Text.AlignRight + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + } + } + } + + Column { id: _DGTemperaturesColumn + width : 150 + spacing : -5 + topPadding : 75 + leftPadding : 1050 + Text { + id: _DGTemperatures_Title + text: qsTr(" Tmprtr ") + width: _DGTemperaturesColumn.width + horizontalAlignment: Text.AlignRight + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + font.underline: true + } + Repeater { + model: [ + vDGTemperatures.inletPrimaryHeater .toFixed(2) , + vDGTemperatures.outletPrimaryHeater .toFixed(2) , + vDGTemperatures.conductivitySensor1 .toFixed(2) , + vDGTemperatures.conductivitySensor2 .toFixed(2) , + vDGTemperatures.outletRedundancy .toFixed(2) , + vDGTemperatures.inletDialysate .toFixed(2) , + vDGTemperatures.primaryHeaterThermoCouple .toFixed(2) , + vDGTemperatures.trimmerHeaterThermoCouple .toFixed(2) , + vDGTemperatures.primaryHeaterColdJunction .toFixed(2) , + vDGTemperatures.trimmerHeaterColdJunction .toFixed(2) , + vDGTemperatures.primaryHeaterInternal .toFixed(2) , + vDGTemperatures.trimmerHeaterInternal .toFixed(2) + ] + Text { + objectName: "_DGTemperaturesData" + index + text: modelData + width: _DGTemperaturesColumn.width + horizontalAlignment: Text.AlignRight + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + } + } + } + + // Row 2 + Column { id: _DGDrainPumpColumn + width : 150 + spacing : -5 + topPadding : 375 + leftPadding : 50 + Text { + id: _DGDrainPump_Title + text: qsTr(" DrnPmp ") + width: _DGDrainPumpColumn.width + horizontalAlignment: Text.AlignRight + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + font.underline: true + } + Repeater { + model: [ + vDGDrainPump.rpm , + vDGDrainPump.dac , + ] + Text { + objectName: "_DGDrainPumpData" + index + text: modelData + width: _DGDrainPumpColumn.width + horizontalAlignment: Text.AlignRight + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + } + } + } + + // Row 3 + Column { id: _DGValvesStatesColumn + width : 300 + spacing : -5 + topPadding : 575 + leftPadding : 50 + Text { + id: _DGValvesStates_Title + text: qsTr(" Valves ") + width: _DGValvesStatesColumn.width + horizontalAlignment: Text.AlignLeft + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + font.underline: true + } + Text { + objectName: "_DGValvesStatesData" + text: vDGValvesStates.text + width: _DGValvesStatesColumn.width + horizontalAlignment: Text.AlignRight + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + } + } + + Column { id: _DGOperationModeColumn + width : 300 + spacing : -5 + topPadding : 575 + leftPadding : 450 + Text { + id: _DGOperationMode_Title + text: qsTr(" Op Mode ") + width: _DGOperationModeColumn.width + horizontalAlignment: Text.AlignLeft + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + font.underline: true + } + Text { + objectName: "_DGOperationModeData" + text: vDGOperationMode.text + width: _DGOperationModeColumn.width + horizontalAlignment: Text.AlignRight + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + } + } + } Index: sources/gui/qml/pages/SettingsHome.qml =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/gui/qml/pages/SettingsHome.qml (.../SettingsHome.qml) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/gui/qml/pages/SettingsHome.qml (.../SettingsHome.qml) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -28,7 +28,189 @@ * which is the default screen in the "Settings" stack */ ScreenItem { id: _root + Text { id : _titleText + visible: true + anchors { + top : parent.top + left : parent.horizontalCenter + topMargin : (Variables.headerHeight - Variables.logoHeight) / 2 + horizontalCenter: parent.horizontalCenter + } + text: qsTr("~ HD ~") + horizontalAlignment: Text.horizontalCenter + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + } + USBButton { id: _usbButton + anchors { + top : parent.top + right : _exportButton.left + topMargin : (Variables.headerHeight - Variables.logoHeight) / 2 + rightMargin : (Variables.headerHeight - Variables.logoHeight) / 2 + } + } + TouchRect { id : _poweroffButton + width: 150 + height: Variables.logoHeight + animated: true + anchors { + top : parent.top + right : parent.right + topMargin : (Variables.headerHeight - Variables.logoHeight) / 2 + rightMargin : (Variables.headerHeight - Variables.logoHeight) / 2 + } + text.text: qsTr("Shutdown") + button.onPressed: { + _GuiView.doActionTransmit(GuiActions.ID_PowerOff, GuiActions.NoData) + } + Connections { target: _GuiView + onDidActionReceive: { + if (vAction === GuiActions.ID_CANBusFaultCount ) { + _canbusFaultCountText.count = vData[0] + } + } + } + Column { id: _BloodFlowColumn + width : 150 + spacing : 20 + topPadding : 75 + leftPadding : 10 + Text { + id: _BloodFlow_Title + text: qsTr(" Blood ") + width: _BloodFlowColumn.width + horizontalAlignment: Text.AlignRight + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + font.underline: true + Column { id: _DialysateInletFlowColumn + width : 150 + spacing : 20 + topPadding : 75 + leftPadding : 200 + Text { + id: _DialysateInletFlow_Title + text: qsTr(" Dlyst I ") + width: _DialysateInletFlowColumn.width + horizontalAlignment: Text.AlignRight + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + font.underline: true + } + Repeater { + model: [ + vTreatmentDialysateFlow.dialysateFlow_FlowSetPoint .toFixed(2) , + vTreatmentDialysateFlow.dialysateFlow_MeasuredFlow .toFixed(2) , + vTreatmentDialysateFlow.dialysateFlow_RotorSpeed .toFixed(2) , + vTreatmentDialysateFlow.dialysateFlow_MotorSpeed .toFixed(2) , + vTreatmentDialysateFlow.dialysateFlow_MotorCtlSpeed .toFixed(2) , + vTreatmentDialysateFlow.dialysateFlow_MotorCtlCurrent.toFixed(2) , + "%" + vTreatmentDialysateFlow.dialysateFlow_PWMDutyCycle .toFixed(2) + ] + Text { + text: modelData + width: _DialysateInletFlowColumn.width + horizontalAlignment: Text.AlignRight + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + } + } + } + Column { id: _DialysateOutletFlowColumn + width : 150 + spacing : 20 + topPadding : 75 + leftPadding : 400 + Text { + id: _DialysateOutletFlow_Title + text: qsTr(" Dlyst O ") + width: _DialysateOutletFlowColumn.width + horizontalAlignment: Text.AlignRight + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + font.underline: true + } + Repeater { + model: [ + vTreatmentUltrafiltration.ultrafiltration_RefUFVol .toFixed(2) , + vTreatmentUltrafiltration.ultrafiltration_MeasUFVol .toFixed(2) , + vTreatmentUltrafiltration.ultrafiltration_RotorSpeed .toFixed(2) , + vTreatmentUltrafiltration.ultrafiltration_MotorSpeed .toFixed(2) , + vTreatmentUltrafiltration.ultrafiltration_MotorCtlSpeed .toFixed(2) , + vTreatmentUltrafiltration.ultrafiltration_MotorCtlCurrent.toFixed(2) , + "%" + vTreatmentUltrafiltration.ultrafiltration_PWMDtCycle .toFixed(2) + ] + Text { + text: modelData + width: _DialysateOutletFlowColumn.width + horizontalAlignment: Text.AlignRight + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + } + } + } + + Column { id: _PressureOcclusionColumn + width : 150 + spacing : 20 + topPadding : 75 + leftPadding : 600 + Text { + id: _PressureOcclusion_Title + text: qsTr(" Prsr Oc ") + width: _PressureOcclusionColumn.width + horizontalAlignment: Text.AlignRight + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + font.underline: true + } + Repeater { + model: [ + vTreatmentPressureOcclusion.pressureocclusion_ArterialPressure .toFixed(2) , + vTreatmentPressureOcclusion.pressureocclusion_VenousPressure .toFixed(2) , + vTreatmentPressureOcclusion.pressureocclusion_BloodPumpOcclusion .toFixed(2) , + vTreatmentPressureOcclusion.pressureocclusion_DialysateInletPumpOcclusion .toFixed(2) , + vTreatmentPressureOcclusion.pressureocclusion_DialysateOutletPumpOcclusion .toFixed(2) + ] + Text { + objectName: "_PressureOcclusionData" + index + text: modelData + width: _PressureOcclusionColumn.width + horizontalAlignment: Text.AlignRight + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + } + } + } + + Column { id: _HDOperationModeColumn + width : 300 + spacing : -5 + topPadding : 625 + leftPadding : 10 + Row { + Text { + id: _HDOperationMode_Title + text: qsTr("Op Mode : ") + //width: _HDOperationModeColumn.width + horizontalAlignment: Text.AlignLeft + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + } + Text { + objectName: "_HDOperationModeData" + text: vHDOperationMode.text + //width: _HDOperationModeColumn.width + horizontalAlignment: Text.AlignRight + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + } + } + } +} + +/* TitleText { id: _titleText anchors.horizontalCenter: parent.horizontalCenter; anchors.top: parent.top @@ -37,6 +219,7 @@ width: parent.width text: qsTr("Device Settings") + } Diagnostics { @@ -53,6 +236,7 @@ onClicked: push(_diagnostics); } } +*/ -} + Index: sources/gui/qml/pages/treatment/TreatmentStack.qml =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/gui/qml/pages/treatment/TreatmentStack.qml (.../TreatmentStack.qml) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/gui/qml/pages/treatment/TreatmentStack.qml (.../TreatmentStack.qml) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -59,6 +59,7 @@ _treatmentAdjustmentFlow.open() } onSectionTimeClicked : { + _treatmentAdjustmentDuration.durationValue = vTreatmentTime.time_Total / 60 // minutes => hours _treatmentAdjustmentDuration.open() } onSectionUltrafiltrationClicked: { Index: sources/gui/qml/pages/treatment/adjustments/TreatmentAdjustmentFlow.qml =================================================================== diff -u -r2437559b2d4cd4c2ac6a926b4f55652e55e1f616 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/gui/qml/pages/treatment/adjustments/TreatmentAdjustmentFlow.qml (.../TreatmentAdjustmentFlow.qml) (revision 2437559b2d4cd4c2ac6a926b4f55652e55e1f616) +++ sources/gui/qml/pages/treatment/adjustments/TreatmentAdjustmentFlow.qml (.../TreatmentAdjustmentFlow.qml) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,15 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. - * \copyright \n - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, \n - * IN PART OR IN WHOLE, \n - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. \n - * - * \file TreatmentAdjustmentFlow.qml - * \date 2020/03/18 - * \author Behrouz NematiPour - * + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file TreatmentAdjustmentFlow.qml + * \author (last) Behrouz NemaiPour + * \date (last) 18-Jun-2020 + * \author (original) Behrouz NematiPour + * \date (original) 22-Mar-2020 + * */ // Qt Index: sources/gui/qml/pages/treatment/adjustments/TreatmentAdjustmentUltrafiltrationConfirm.qml =================================================================== diff -u -r2437559b2d4cd4c2ac6a926b4f55652e55e1f616 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/gui/qml/pages/treatment/adjustments/TreatmentAdjustmentUltrafiltrationConfirm.qml (.../TreatmentAdjustmentUltrafiltrationConfirm.qml) (revision 2437559b2d4cd4c2ac6a926b4f55652e55e1f616) +++ sources/gui/qml/pages/treatment/adjustments/TreatmentAdjustmentUltrafiltrationConfirm.qml (.../TreatmentAdjustmentUltrafiltrationConfirm.qml) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,15 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. - * \copyright \n - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, \n - * IN PART OR IN WHOLE, \n - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. \n - * - * \file TreatmentAdjustmentUltrafiltrationConfirm.qml - * \date 2020/05/15 - * \author Behrouz NematiPour - * + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file TreatmentAdjustmentUltrafiltrationConfirm.qml + * \author (last) Behrouz NemaiPour + * \date (last) 18-Jun-2020 + * \author (original) Behrouz NematiPour + * \date (original) 18-May-2020 + * */ // Qt Index: sources/gui/qml/pages/treatment/adjustments/TreatmentAdjustmentUltrafiltrationEdit.qml =================================================================== diff -u -r2437559b2d4cd4c2ac6a926b4f55652e55e1f616 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/gui/qml/pages/treatment/adjustments/TreatmentAdjustmentUltrafiltrationEdit.qml (.../TreatmentAdjustmentUltrafiltrationEdit.qml) (revision 2437559b2d4cd4c2ac6a926b4f55652e55e1f616) +++ sources/gui/qml/pages/treatment/adjustments/TreatmentAdjustmentUltrafiltrationEdit.qml (.../TreatmentAdjustmentUltrafiltrationEdit.qml) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,15 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. - * \copyright \n - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, \n - * IN PART OR IN WHOLE, \n - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. \n - * - * \file TreatmentAdjustmentUltrafiltrationEdit.qml - * \date 2020/05/14 - * \author Behrouz NematiPour - * + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file TreatmentAdjustmentUltrafiltrationEdit.qml + * \author (last) Behrouz NemaiPour + * \date (last) 18-Jun-2020 + * \author (original) Behrouz NematiPour + * \date (original) 15-May-2020 + * */ // Qt Index: sources/gui/qml/pages/treatment/adjustments/TreatmentAdjustmentUltrafiltrationPaused.qml =================================================================== diff -u -r2437559b2d4cd4c2ac6a926b4f55652e55e1f616 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/gui/qml/pages/treatment/adjustments/TreatmentAdjustmentUltrafiltrationPaused.qml (.../TreatmentAdjustmentUltrafiltrationPaused.qml) (revision 2437559b2d4cd4c2ac6a926b4f55652e55e1f616) +++ sources/gui/qml/pages/treatment/adjustments/TreatmentAdjustmentUltrafiltrationPaused.qml (.../TreatmentAdjustmentUltrafiltrationPaused.qml) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,15 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. - * \copyright \n - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, \n - * IN PART OR IN WHOLE, \n - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. \n - * - * \file TreatmentAdjustmentUltrafiltrationPaused.qml - * \date 2020/05/11 - * \author Behrouz NematiPour - * + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file TreatmentAdjustmentUltrafiltrationPaused.qml + * \author (last) Behrouz NemaiPour + * \date (last) 19-Jun-2020 + * \author (original) Behrouz NematiPour + * \date (original) 14-May-2020 + * */ // Qt Index: sources/gui/qml/pages/treatment/adjustments/TreatmentAdjustmentUltrafiltrationStart.qml =================================================================== diff -u -r2437559b2d4cd4c2ac6a926b4f55652e55e1f616 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/gui/qml/pages/treatment/adjustments/TreatmentAdjustmentUltrafiltrationStart.qml (.../TreatmentAdjustmentUltrafiltrationStart.qml) (revision 2437559b2d4cd4c2ac6a926b4f55652e55e1f616) +++ sources/gui/qml/pages/treatment/adjustments/TreatmentAdjustmentUltrafiltrationStart.qml (.../TreatmentAdjustmentUltrafiltrationStart.qml) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,15 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. - * \copyright \n - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, \n - * IN PART OR IN WHOLE, \n - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. \n - * - * \file TreatmentAdjustmentUltrafiltrationStart.qml - * \date 2020/05/11 - * \author Behrouz NematiPour - * + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file TreatmentAdjustmentUltrafiltrationStart.qml + * \author (last) Behrouz NemaiPour + * \date (last) 18-Jun-2020 + * \author (original) Behrouz NematiPour + * \date (original) 12-May-2020 + * */ // Qt Index: sources/gui/qml/pages/treatment/sections/TreatmentFlows.qml =================================================================== diff -u -r2437559b2d4cd4c2ac6a926b4f55652e55e1f616 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/gui/qml/pages/treatment/sections/TreatmentFlows.qml (.../TreatmentFlows.qml) (revision 2437559b2d4cd4c2ac6a926b4f55652e55e1f616) +++ sources/gui/qml/pages/treatment/sections/TreatmentFlows.qml (.../TreatmentFlows.qml) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,15 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. - * \copyright \n - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, \n - * IN PART OR IN WHOLE, \n - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. \n - * - * \file TreatmentFlows.qml - * \date 2020/01/27 - * \author Behrouz NematiPour - * + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file TreatmentFlows.qml + * \author (last) Behrouz NematiPour + * \date (last) 21-May-2020 + * \author (original) Behrouz NematiPour + * \date (original) 27-Jan-2020 + * */ // Qt Index: sources/gui/qml/pages/treatment/sections/TreatmentUltrafiltration.qml =================================================================== diff -u -r2437559b2d4cd4c2ac6a926b4f55652e55e1f616 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/gui/qml/pages/treatment/sections/TreatmentUltrafiltration.qml (.../TreatmentUltrafiltration.qml) (revision 2437559b2d4cd4c2ac6a926b4f55652e55e1f616) +++ sources/gui/qml/pages/treatment/sections/TreatmentUltrafiltration.qml (.../TreatmentUltrafiltration.qml) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,15 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. - * \copyright \n - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, \n - * IN PART OR IN WHOLE, \n - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. \n - * - * \file TreatmentUltrafiltration.qml - * \date 2020/01/27 - * \author Behrouz NematiPour - * + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file TreatmentUltrafiltration.qml + * \author (last) Behrouz NemaiPour + * \date (last) 09-Jun-2020 + * \author (original) Behrouz NematiPour + * \date (original) 27-Jan-2020 + * */ // Qt Index: sources/gui/qml/pages/treatment/sections/TreatmentVitals.qml =================================================================== diff -u -r2437559b2d4cd4c2ac6a926b4f55652e55e1f616 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/gui/qml/pages/treatment/sections/TreatmentVitals.qml (.../TreatmentVitals.qml) (revision 2437559b2d4cd4c2ac6a926b4f55652e55e1f616) +++ sources/gui/qml/pages/treatment/sections/TreatmentVitals.qml (.../TreatmentVitals.qml) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,15 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. - * \copyright \n - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, \n - * IN PART OR IN WHOLE, \n - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. \n - * - * \file TreatmentVitals.qml - * \date 2020/01/27 - * \author Behrouz NematiPour - * + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file TreatmentVitals.qml + * \author (last) Behrouz NematiPour + * \date (last) 21-May-2020 + * \author (original) Behrouz NematiPour + * \date (original) 27-Jan-2020 + * */ // Qt Index: sources/main.h =================================================================== diff -u -r36740a3ee8e7164e70d8627b057624ec0ef1eb8f -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/main.h (.../main.h) (revision 36740a3ee8e7164e70d8627b057624ec0ef1eb8f) +++ sources/main.h (.../main.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,15 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * \copyright - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, - * IN PART OR IN WHOLE, - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. - * - * \file main.h - * \date 10/25/2019 - * \author Behrouz NematiPour - * + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file main.h + * \author (last) Peter Lucia + * \date (last) 26-Jun-2020 + * \author (original) Behrouz NematiPour + * \date (original) 28-Oct-2019 + * */ #pragma once @@ -44,6 +45,7 @@ extern bool gSendEmptyKeepAwake; extern bool gFakeSeqAtBegin; extern bool gDisableUnhandledReport; +extern bool gDisableTimeout; //--------------------------------------------------------------------------------// //--------------------------------------------------------------------------------// #define DEBUG_PROPERTY_CHANGED(vVARIABLE) //qDebug() << "#" << #vVARIABLE << v##vVARIABLE; Index: sources/maintimer.cpp =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/maintimer.cpp (.../maintimer.cpp) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/maintimer.cpp (.../maintimer.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -15,6 +15,7 @@ #include "maintimer.h" //Qt +#include //Project #include "logger.h" @@ -45,7 +46,7 @@ else { startTimer(_interval); } - LOG_EVENT(QObject::tr("Main Timer Initialized")); + LOG_EVENT("UI," + tr("Main Timer Initialized")); return true; } @@ -56,6 +57,56 @@ void MainTimer::quit() { } /*! + * \brief MainTimer::isDateChanged + * \details Checks the date has been changed + * \return true if date changed. + */ +bool MainTimer::isDateChanged(bool vIncludeTime) +{ + // old date // current date + static int oy,om,od; int cy,cm,cd; + // old time // current time + static int oH,oM,oS; int cH,cM,cS; + + QDateTime::currentDateTime().date().getDate(&cy, &cm, &cd); + // coco begin validated: Decided to not to check each second + // has been tested manually + if (vIncludeTime) { + QTime currentTime = QDateTime::currentDateTime().time(); + cH = currentTime.hour(); + cM = currentTime.minute(); + cS = currentTime.second(); + } + + if (oy == cy && om == cm && od == cd) { + if (vIncludeTime) { + if (oH == cH && oM == cM && oS == cS) { + return false; + } + else { + // date + oy = cy; + om = cm; + od = cd; + // time + oH = cH; + oM = cM; + oS = cS; + } + // coco end + } + else + return false; + } + else { + oy = cy; + om = cm; + od = cd; + } + return true; +} + +/*! * \brief MainTimer::timerEvent * \details This event handler has been re-implemented in here * to receive timer events for the object @@ -65,4 +116,10 @@ void MainTimer::timerEvent(QTimerEvent *) { emit didTimeout(); + // I'm not sure how often we need to check for this. + // if it needs to be checked each second pass true + // if it needs to be checked each day pass false + if (isDateChanged(false)) { + emit didDateChange(); + } } Index: sources/maintimer.h =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/maintimer.h (.../maintimer.h) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/maintimer.h (.../maintimer.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -40,9 +40,10 @@ void quit(); private: - + bool isDateChanged(bool vIncludeTime = false); signals: void didTimeout(); + void didDateChange(); protected: void timerEvent(QTimerEvent *) override; Index: sources/storage/filehandler.cpp =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/storage/filehandler.cpp (.../filehandler.cpp) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/storage/filehandler.cpp (.../filehandler.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -15,15 +15,15 @@ #include "filehandler.h" //Qt -#include +#include +#include #include -#include +#include +#include +#include - // Project -#include "storageglobals.h" #include "logger.h" -#include "threads.h" // namespace using namespace Storage; @@ -46,13 +46,17 @@ bool FileHandler::write(const QString &vFileName, const QString &vContent, bool vAppend) { QFile file(vFileName); - QIODevice::OpenMode openMode = vAppend ? - QFile::Text | QFile::Append : - QFile::Text | QFile::WriteOnly; + QFile::OpenMode openMode = vAppend ? + QFile::Text | QFile::Append : + QFile::Text | QFile::WriteOnly; if (! file.open(openMode)) { - errOut(QObject::tr("Can't open file for write (%1).Possible corrupted file system").arg(vFileName)); + // coco begin validated : This has been manually test. Needs filesystem access to make file the way it can't be opened for writing. + QString msg = QString("Can't open file for write (%1).Possible corrupted file system").arg(vFileName); + errOut (msg); + LOG_DEBUG(msg); return false; } + // coco end QTextStream out(&file); out << vContent; out.flush(); @@ -70,7 +74,9 @@ { QFile file(vFileName); if (! file.open(QFile::Text | QFile::ReadOnly)) { - errOut(QObject::tr("Can't open file for read (%1).Possible corrupted file system").arg(vFileName)); + QString msg = QString("Can't open file for read (%1).Possible corrupted file system").arg(vFileName); + errOut (msg); + LOG_DEBUG(msg); return false; } QTextStream in(&file); @@ -96,11 +102,68 @@ QStringList arguments; arguments << "-r" << vSource << vDestination; int result = QProcess::execute(cp, arguments); - - cp = "sync;sync;sync;"; - arguments.clear(); - QProcess::execute(cp, arguments); - return result; } // coco end + +/*! + * \brief FileHandler::removeFiles + * \details + * \param vFolder + * \param vFilter + * \param vDateOlderThan + * \return + */ +int FileHandler::removeFiles(const QStringList &vFolders, const QStringList &vNameFilter, const QDate &vDateOlderThan) +{ + int countRemoved = 0; + for (const auto &folder : vFolders) { + QDir dir(folder); + dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); + dir.setSorting(QDir::Time | QDir::Reversed); + QFileInfoList infoList = dir.entryInfoList(vNameFilter); + for (const auto &info : infoList) { + QDateTime fileTime = info.lastModified(); + QString fileName = info.absoluteFilePath(); + if (fileTime.isValid()) { + if (fileTime.date() <= vDateOlderThan) { + if (QFile::remove(fileName)) { + ++countRemoved; + LOG_DEBUG(QString("%1 File(s) %2 removed").arg(countRemoved).arg(fileName)); + } + else { + // coco begin validated : This has been manually tested since requires to change in file system to reproduce the error. + LOG_DEBUG(QString("Can't delete file : ") + fileName); + } + // coco end + } + } + else { + // coco begin validated : This has been manually tested since requires to change in file system to reproduce the error. + LOG_DEBUG(QString("Can't get last modified date of file : ") + fileName); + } + // coco end + } + } + return countRemoved; +} + +/*! + * \brief FileHandler::makeFolder + * \details Create the folder vFolder if it doesn't exist. + * \param vFolder - the folder to create + * \return true on successfull creation + */ +bool FileHandler::makeFolder(const QString &vFolder) +{ + QDir dir(vFolder); + if ( ! dir.exists(vFolder) ) { + if ( ! dir.mkpath(vFolder) ) { + QString msg = "Can't create folder " + vFolder; + qDebug() << msg; + LOG_DEBUG(msg); + return false; + } + } + return true; +} Index: sources/storage/filehandler.h =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/storage/filehandler.h (.../filehandler.h) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/storage/filehandler.h (.../filehandler.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -16,6 +16,7 @@ // Qt #include +class QDate; namespace Storage { @@ -34,7 +35,9 @@ static bool write(const QString &vFileName, const QString &vContent, bool vAppend = true); static bool read (const QString &vFileName, QString &vContent); - static int copyFolder(const QString &vSource, const QString &vDestination); + static int copyFolder (const QString &vSource, const QString &vDestination); + static int removeFiles(const QStringList &vFolders, const QStringList &vNameFilter, const QDate &vDateOlderThan); + static bool makeFolder (const QString &vFolder); }; } Index: sources/storage/logger.cpp =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/storage/logger.cpp (.../logger.cpp) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/storage/logger.cpp (.../logger.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -23,9 +23,12 @@ #include // Project +#include "DriveWatcher.h" +#include "threads.h" #include "storageglobals.h" +#include "maintimer.h" #include "filehandler.h" -#include "threads.h" +#include "format.h" using namespace Storage; @@ -35,7 +38,9 @@ * \param parent - QObject parent owner object. * Qt handles the children destruction by their parent objects life-cycle. */ -Logger::Logger(QObject *parent) : QObject(parent) { } +Logger::Logger(QObject *parent) : QObject(parent) { + _logFileNamePrefix = QFileInfo(qApp->applicationFilePath()).baseName(); +} /*! * \brief Logger::init @@ -51,7 +56,7 @@ checkLogPath(); initConnections(); - LOG_EVENT(QObject::tr("%1 Initialized").arg(metaObject()->className())); + LOG_EVENT("UI," + tr("%1 Initialized").arg(metaObject()->className())); return true; } @@ -87,11 +92,6 @@ } // coco end -void Logger::onLog(const QString &vContent, LogType vLogType) -{ - log(vContent,vLogType); -} - /*! * \brief Logger::initConnections * \details Initializes the required signal/slot connection between this class and other objects @@ -100,11 +100,21 @@ */ void Logger::initConnections() { - connect(&_exportWatcher, SIGNAL(finished()), - this , SLOT(onExport())); + connect(&_exportLogsWatcher, SIGNAL(finished ()), + this , SLOT(onExportLogs())); connect(this, SIGNAL(didLog(QString,LogType)), this, SLOT( onLog(QString,LogType))); + + + connect(&_MainTimer, SIGNAL( didDateChange ()), + this , SLOT( concurrentRemoveLogs())); + + connect(&_removeLogsWatcher, SIGNAL(finished ()), + this , SLOT(onRemoveLogs())); + + connect(&_DriveWatcher, SIGNAL( didSDCardSpaceChange(bool, qint64, qint64, quint8)), + this , SLOT( onSDCardSpaceChange(bool, qint64, qint64, quint8))); } /*! @@ -143,6 +153,11 @@ } // coco end +void Logger::onLog(const QString &vContent, LogType vLogType) +{ + log(vContent,vLogType); +} + /*! * \brief Logger::checkLogPath * \details Sets the log paths and creates them if didn't exist. @@ -170,10 +185,12 @@ { if (vUseApplicationDirPath) { _dir.setPath(qApp->applicationDirPath()); - LOG_EVENT(tr("Application Dir Path used for events logging (%1)").arg(_dir.path())); - } else { - _dir.setPath(Log_Base_Path_Name); + // Don't use LOG_XXXXX, At this moment Logger has not been initialized yet + qDebug() << QString("Application path used for events logging (%1)").arg(_dir.path()); } + else { + _dir.setPath(SDCard_Base_Path_Name); + } } /*! @@ -184,9 +201,9 @@ bool Logger::setLogPath() { bool ok = true; - if ( ! setLogPath(LogType::eLogEvent) ) ok = false; - if ( ! setLogPath(LogType::eLogError) ) ok = false; - if ( ! setLogPath(LogType::eLogDatum) ) ok = false; + if ( ok && ! setLogPath(LogType::eLogDebug) ) ok = false; + if ( ok && ! setLogPath(LogType::eLogEvent) ) ok = false; + if ( ok && ! setLogPath(LogType::eLogDatum) ) ok = false; return ok; } @@ -199,17 +216,18 @@ */ bool Logger::setLogPath(LogType vLogType) { - _logPathNames[vLogType] = _dir.path() + "/" + _logBasePathNames[vLogType]; - if ( ! _dir.exists(_logBasePathNames[vLogType]) ) { - if ( ! _dir.mkpath(_logBasePathNames[vLogType]) ) { - LOG_ERROR(tr("Can't create %1 log path (%2)") - .arg(_logPrefix[vLogType]) - .arg(_logPathNames[vLogType]) - ); - return false; - } + bool ok = false; + switch (vLogType) { + case LogType::eLogDebug: + _logPathNames[vLogType] = qApp->applicationDirPath() + "/" + _logBasePathNames[vLogType]; + break; + + default: + _logPathNames[vLogType] = _dir.path() + "/" + _logBasePathNames[vLogType]; + break; } - return true; + ok = FileHandler::makeFolder(_logPathNames[vLogType]); + return ok; } /*! @@ -220,34 +238,37 @@ * \note This method is not thread-safe so is private and needs to be called by concurrentLog * Which uses QtConcurrent::run to run in thread and thread-safe. */ -void Logger::log(const QString &vContent, Logger::LogType vLogType) +void Logger::log(const QString &vContent, LogType vLogType) { QString date = QDate::currentDate().toString(_dateFormat); - QString mContent; - + QString fileName = date + _dateSeparator + _logFileNamePrefix; switch (vLogType) { - case eLogEvent: - case eLogError: - case eLogDatum: + case LogType::eLogEvent: + case LogType::eLogDatum: + case LogType::eLogDebug: + fileName += _logFileNameExt[vLogType]; break; default: - LOG_ERROR(tr("Incorrect type of logging").arg(vLogType)); + fileName += _logFileNameExt[eLogDebug]; + LOG_DEBUG(QString("Incorrect type of logging %1").arg(vLogType)); } + QString mContent = QTime::currentTime().toString(_timeFormat) + _separator; + QString logPrefix = _logPrefix[vLogType]; - if (logPrefix.isEmpty()) logPrefix = _logPrefix[LogType::eLogError]; - mContent += logPrefix; - mContent += _prefixSeparator; - mContent += QTime::currentTime().toString(_timeFormat); - mContent += _timeSeparator + vContent; - QString fileName = date + _dateSeparator + Log_File_Name; + if ( ! logPrefix.isEmpty()) { + mContent += logPrefix; + mContent += _separator; + } + mContent += vContent; + QString logPathName = _logPathNames[vLogType]; if (logPathName.isEmpty()) - logPathName = _logPathNames[LogType::eLogError]; + logPathName = _logPathNames[eLogDebug]; _logFileName = logPathName + fileName; FileHandler::write(_logFileName, mContent + "\r\n", true); - if (vLogType == eLogError) { + if (vLogType == eLogDebug) { #ifdef QT_DEBUG //mContent.prepend("\033[1;31m --- @ --- \033[0m"); mContent.prepend(" @ "); @@ -256,29 +277,121 @@ } } + +bool Logger::exportLogs() +{ + // coco begin validated: This needs user interaction to check the old files deleted + // has been tested manually + int result = 0; + static QString mOSource; + QString mDestination = USB_Mount_Point; + for ( const auto &iType : { eLogEvent , eLogDatum } ) { + QString mCSource = _logPathNames[iType]; + if (mOSource != mCSource) { + mOSource = mCSource; + // Copy Folder + result = FileHandler::copyFolder( mCSource, mDestination); + } + } + mOSource = ""; + return result >= 0; // refer to QProcess::execute(hit F1 on execute) doc. +} +// coco end + /*! - * \brief Logger::concurrentExport + * \brief Logger::concurrentExportLogs * \details Exports the log files from log folder (Storage::Log_Base_Path_Name_Location) * into USB drive folder (Storage::USB_Mount_Point) * \return always returns true for now. * \note This method uses QtConcurrent run to execute the FileHandler copyFolder method. */ -bool Logger::concurrentExport() +bool Logger::concurrentExportLogs() { // coco begin validated: This needs user interaction to export to USB device // has been tested manually - QString mSource = Storage::Log_Base_Path_Name_Location; - QString mDestination = Storage::USB_Mount_Point; - QFuture future = QtConcurrent::run(&FileHandler::copyFolder, mSource, mDestination); - _exportWatcher.setFuture(future); - return true; + LOG_DEBUG("Export Logs Start"); + QFuture future = QtConcurrent::run(this, &Logger::exportLogs); + _exportLogsWatcher.setFuture(future); + return true; } // coco end -void Logger::onExport() +void Logger::onExportLogs() { // coco begin validated: This needs user interaction to export to USB device // has been tested manually - emit didExport(); + LOG_DEBUG(QString("Export Logs Ended: %1").arg(_exportLogsWatcher.result())); + emit didExportLogs(); } // coco end + +/*! + * \brief Logger::removeLogs + * \details Remove old logs by iterating in the log/service folders and look for expired logs. + * \return count file(s) have been removed. + */ +int Logger::removeLogs() +{ + // coco begin validated: This needs user interaction to check the old files deleted + // has been tested manually + static QString mOSource; + int countRemoved = 0; + QStringList mLogFileFilter; + QDate mOlderThan ; + for ( const auto &iType : { eLogEvent , eLogDatum , eLogDebug } ) { + QString mCSource = _logPathNames[iType]; + if (mOSource != mCSource) { + mOSource = mCSource; + // Remove Logs + if (_logTypeExpiryDay.value(iType)) { + mOlderThan = QDate().currentDate().addDays( _logTypeExpiryDay.value(iType) * -1 /*Please Notice (-1)*/ ); + mLogFileFilter = Format::toStringList(_logFileNameExt .values(iType), true, "*"); + LOG_DEBUG(QString("Removing logs older than %1 from folder %2").arg(mOlderThan.toString("yyyy-MM-dd")).arg(mCSource)); + countRemoved += FileHandler::removeFiles({ mCSource }, mLogFileFilter, mOlderThan); + } + else { + LOG_DEBUG("Current day logs cannot be deletet"); + } + } + } + mOSource = ""; + return countRemoved; +} +// coco end + +/*! + * \brief Logger::concurrentRemoveLogs + * \details + * + * \return always returns true for now. + * \note This method uses QtConcurrent run to execute the FileHandler copyFolder method. + */ +bool Logger::concurrentRemoveLogs() +{ + // coco begin validated: This needs user interaction to check the old files deleted + // has been tested manually + LOG_DEBUG("Remove Logs Start"); + QFuture mFuture = QtConcurrent::run(this,&Logger::removeLogs); + _removeLogsWatcher.setFuture(mFuture); + return true; +} +// coco end + +void Logger::onRemoveLogs() +{ + // coco begin validated: This needs user interaction to export to USB device + // has been tested manually + LOG_DEBUG(QString("Remove Logs Ended: %1").arg(_removeLogsWatcher.result())); + emit didRemoveLogs(); +} + +void Logger::onSDCardSpaceChange(bool vReady, qint64 vTotal, qint64 vAvailable, quint8 vPercent) +{ + Q_UNUSED(vReady ) + Q_UNUSED(vTotal ) + Q_UNUSED(vAvailable ) + if (vPercent < _availableSpacePercent ) { + concurrentRemoveLogs(); + } +} +// coco end Index: sources/storage/logger.h =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/storage/logger.h (.../logger.h) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/storage/logger.h (.../logger.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -27,39 +27,14 @@ // Define #define _Logger Storage::Logger::I() -#define LOG_EXPORT _Logger.concurrentExport() +#define LOG_EXPORT _Logger.concurrentExportLogs() -#define LOG_EVENT(vCONTENT) emit Storage::Logger::I().didLog(vCONTENT, Storage::Logger::LogType::eLogEvent) -#define LOG_EVENT_ONCE_LOGGED \ - bLOG_EVENT_ONCE_LOGGED -#define LOG_EVENT_ONCE(vCONTENT) \ - static bool LOG_EVENT_ONCE_LOGGED = false; \ - if ( ! LOG_EVENT_ONCE_LOGGED ) { \ - LOG_EVENT_ONCE_LOGGED = true; \ - LOG_EVENT(vCONTENT); \ - } -#define LOG_ERROR(vCONTENT) emit Storage::Logger::I().didLog(vCONTENT, Storage::Logger::LogType::eLogError) -#define LOG_ERROR_ONCE_LOGGED \ - bLOG_ERROR_ONCE_LOGGED -#define LOG_ERROR_ONCE(vCONTENT) \ - static bool LOG_ERROR_ONCE_LOGGED = false; \ - if ( ! LOG_ERROR_ONCE_LOGGED ) { \ - LOG_ERROR_ONCE_LOGGED = true; \ - LOG_ERROR(vCONTENT); \ - } +#define LOG_DEBUG(vCONTENT) emit Storage::Logger::I().didLog(vCONTENT, Storage::Logger::LogType::eLogDebug) -#define LOG_DATUM(vCONTENT) emit Storage::Logger::I().didLog(vCONTENT, Storage::Logger::LogType::eLogDatum) -#define LOG_DATUM_ONCE_LOGGED \ - bLOG_DATUM_ONCE_LOGGED -#define LOG_DATUM_ONCE(vCONTENT) \ - static bool LOG_DATUM_ONCE_LOGGED = false; \ - if ( ! LOG_DATUM_ONCE_LOGGED ) { \ - LOG_DATUM_ONCE_LOGGED = true; \ - LOG_DATUM(vCONTENT); \ - } +#define LOG_EVENT(vCONTENT) emit Storage::Logger::I().didLog(vCONTENT, Storage::Logger::LogType::eLogEvent) +#define LOG_DATUM(vCONTENT) emit Storage::Logger::I().didLog(vCONTENT, Storage::Logger::LogType::eLogDatum) - // forward declarations class tst_logging; @@ -68,14 +43,14 @@ /*! * \brief The Logger class * \details Main logger class that has all the required implementation for logging. - * The provided interface is the LOG_DATUM, LOG_EVENT, LOG_ERROR, LOG_EXPORT defines + * The provided interface is the LOG_DATUM, LOG_EVENT, LOG_DEBUG, LOG_EXPORT defines * and no other methods. * This should have its own thread. * \note * PLEASE BE CAREFUL THIS CLASS IS USING QtConcurrent::run FOR THE EXPORT LOG FILES. * AND ONLY PRIVATE VOID LOG (,) IS CALLING IN POOLED THREAD * PLEASE BE VERY CAREFUL. - * ALL THE OTHER CLASSES TO USE THIS CLASS SHOULD ONLY USE LOG_DATUM, LOG_EVENT, LOG_ERROR + * ALL THE OTHER CLASSES TO USE THIS CLASS SHOULD ONLY USE LOG_DATUM, LOG_EVENT, LOG_DEBUG * TO DO THE LOGGING */ class Logger : public QObject @@ -85,39 +60,58 @@ // friends friend class ::tst_logging; -public: +public : enum LogType { - eLogEvent, - eLogError, - eLogDatum, + eLogDebug, ///< Application Error : CANBus messages doesn't have error it's Evnet/Data only + eLogEvent, ///< Massages on the CANBus : Error is an event type + eLogDatum, ///< Massages on the CANBus : Broadcast data type + eLogType_Count, - }; + }; private: - QDir _dir; + QDir _dir; + QString _logFileNamePrefix; QHash _logPathNames; - QHash _logBasePathNames { - { eLogEvent, "log/event/" }, - { eLogError, "log/error/" }, - { eLogDatum, "log/event/" }, // "log/datum/" + const QHash _logBasePathNames { + { LogType::eLogEvent, "log/" }, + { LogType::eLogDatum, "log/" }, + { LogType::eLogDebug, "service/" }, }; - QHash _logPrefix { - { eLogEvent, "Event" }, - { eLogError, "Error" }, - { eLogDatum, "Datum" }, + const QHash _logPrefix { // Will be used for the logging in the file + { LogType::eLogEvent, "E" }, + { LogType::eLogDatum, "D" }, + { LogType::eLogDebug, "" }, // it has its own file and all the content is Error }; + const QHash _logTypeName { // Will be used for for information + { LogType::eLogEvent, "Event" }, + { LogType::eLogDatum, "Datum" }, + { LogType::eLogDebug, "Error" }, // it has its own file and all the content is Error + }; + const QHash _logFileNameExt { + { LogType::eLogEvent, ".log" }, + { LogType::eLogDatum, ".log" }, + { LogType::eLogDebug, ".err" }, + }; + const QHash _logTypeExpiryDay { + { LogType::eLogEvent, 15 }, + { LogType::eLogDatum, 15 }, + { LogType::eLogDebug, 5 }, + }; + const qint8 _availableSpacePercent = 25; // currently 16G SD-Card so 4G should always be available. + const char *_dateFormat = "yyyy_MM_dd"; const char *_timeFormat = "HH:mm:ss"; - const char *_prefixSeparator = ": " ; - const char *_dateSeparator = "_" ; - const char *_timeSeparator = " , "; + const char *_dateSeparator = "_"; // used in filename + const char *_separator = ","; QString _logFileName = ""; - QFutureWatcher _exportWatcher; + QFutureWatcher _exportLogsWatcher; + QFutureWatcher _removeLogsWatcher; QThread *_thread = nullptr; bool _init = false; @@ -146,22 +140,34 @@ bool setLogPath (LogType vLogType); // ----- Export structure -public slots: - bool concurrentExport(); -private slots: - void onExport(); +private : + bool exportLogs(); +public slots: // this slot is thread safe and can be called from outside by LOG_EXPORT. + bool concurrentExportLogs(); + void onExportLogs(); signals: - /*! - * \brief didExport - * \details notifies the UI when the export is done. - */ - void didExport(); + void didExportLogs(); +// ----- Remove Old Logs structure +private: + int removeLogs(); +private slots: // this slot is thread safe and can be called from outside but preffered not to. + bool concurrentRemoveLogs(); + void onRemoveLogs(); +signals: + void didRemoveLogs(); + +// ----- Available space is low +private slots: + void onSDCardSpaceChange(bool vReady, qint64 vTotal, qint64 vAvailable, quint8 vPercent); + + // ----- logging structure private slots: void onLog (const QString &vContent, LogType vLogType); private: void log (const QString &vContent, LogType vLogType); + signals: /*! * \brief didLog Index: sources/storage/storageglobals.cpp =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/storage/storageglobals.cpp (.../storageglobals.cpp) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/storage/storageglobals.cpp (.../storageglobals.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -22,7 +22,5 @@ const char *USB_File_System = "vfat"; // Log - const char *Log_Base_Path_Name = "/media/sd-card/"; - const char *Log_Base_Path_Name_Location = "/media/sd-card/log/"; - const char *Log_File_Name = "denali.log"; + const char *SDCard_Base_Path_Name = "/media/sd-card/"; } Index: sources/storage/storageglobals.h =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/storage/storageglobals.h (.../storageglobals.h) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/storage/storageglobals.h (.../storageglobals.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -24,7 +24,6 @@ extern const char *USB_File_System; // Log - extern const char *Log_Base_Path_Name ; - extern const char *Log_Base_Path_Name_Location; - extern const char *Log_File_Name ; + extern const char *SDCard_Base_Path_Name; + } Index: sources/threads.cpp =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/threads.cpp (.../threads.cpp) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/threads.cpp (.../threads.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -29,12 +29,12 @@ * this has currently been done in main.cpp in main() after the qpp.exe() is done. */ namespace Threads { - QThread _CanFrame_Thread ; - QThread _CanAcknow_Thread ; - QThread _CanMessage_Thread ; - QThread _USBWatcher_Thread ; - QThread _Logger_Thread ; - QThread _Application_Thread ; + QThread _CanFrame_Thread ; + QThread _CanAcknow_Thread ; + QThread _CanMessage_Thread ; + QThread _DriveWatcher_Thread ; + QThread _Logger_Thread ; + QThread _Application_Thread ; /*! * \brief registerTypes @@ -86,12 +86,12 @@ { // coco begin validated: Application termination is not correctly done in coco!!! // it has been tested and works perfectly fine in normal run. - quitThread(_CanFrame_Thread ); // validated - quitThread(_CanAcknow_Thread ); // validated - quitThread(_CanMessage_Thread ); // validated - quitThread(_USBWatcher_Thread ); // validated - quitThread(_Logger_Thread ); // validated - quitThread(_Application_Thread ); // validated + quitThread(_CanFrame_Thread ); // validated + quitThread(_CanAcknow_Thread ); // validated + quitThread(_CanMessage_Thread ); // validated + quitThread(_DriveWatcher_Thread ); // validated + quitThread(_Logger_Thread ); // validated + quitThread(_Application_Thread ); // validated } // coco end } Index: sources/threads.h =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/threads.h (.../threads.h) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/threads.h (.../threads.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -27,12 +27,12 @@ #endif namespace Threads { - extern QThread _CanFrame_Thread ; - extern QThread _CanAcknow_Thread ; - extern QThread _CanMessage_Thread ; - extern QThread _USBWatcher_Thread ; - extern QThread _Logger_Thread ; - extern QThread _Application_Thread; + extern QThread _CanFrame_Thread ; + extern QThread _CanAcknow_Thread ; + extern QThread _CanMessage_Thread ; + extern QThread _DriveWatcher_Thread ; + extern QThread _Logger_Thread ; + extern QThread _Application_Thread ; void registerTypes(); void quitThread (QThread &vThread); Index: sources/utility/format.cpp =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/utility/format.cpp (.../format.cpp) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/utility/format.cpp (.../format.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -100,3 +100,19 @@ mData += '\0'; return mData; } + +QStringList Format::toStringList(const QList vList, bool vRemoveDuplicate, QString vPrefix) +{ + QStringList list; + for (const auto &listItem : vList) { + auto item = vPrefix + listItem; + if ( vRemoveDuplicate ) { + if ( ! list.contains(item) ) { + list += item; + } + } + else + list += item; + } + return list; +} Index: sources/utility/format.h =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/utility/format.h (.../format.h) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/utility/format.h (.../format.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -29,5 +29,6 @@ static QByteArray toHexByteArray(const QByteArray &vData , char separator = '.'); static QString toHexString (const QByteArray &vData , char separator = '.'); static QByteArray fromVariant (const QVariant &vData ); + static QStringList toStringList (const QList vList, bool vRemoveDuplicate = false, QString vPrefix = ""); }; Index: sources/utility/types.h =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/utility/types.h (.../types.h) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/utility/types.h (.../types.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -27,19 +27,20 @@ #include "logger.h" // defines -#define GetValue(vData, vIndex, vValue) Types::getValue<>(vData, vIndex, vValue, QT_STRINGIFY(vValue)) +#define GetValue(vData, vIndex, vValue ) Types::getValue<>(vData, vIndex, vValue, QT_STRINGIFY(vValue)) +#define GetBits( vData, vIndex, vFlags, vLen) Types::getBits( vData, vIndex, vFlags, vLen ) class Types { public: class Flags : public QBitArray { public: Flags() : QBitArray() { } - QString toString() const { + QString toString(QString vByteSeparator = " ") const { QString tmp; for (int i = 0; i < count(); i++) { if (i % 4 == 0 && i != 0) - tmp += ' '; + tmp += vByteSeparator; tmp += at(i) ? '1' : '0'; } return tmp; @@ -135,7 +136,7 @@ bool Types::getValue(const QByteArray &vData, int &vStartIndex, T &vValue, QString vValueName) { int end = vStartIndex + sizeof(T); if (vData.length() < end) { - LOG_ERROR(QString("Not enough data from position %1 to the length of %2 to get data of type '%3' in buffer %4%5") + LOG_DEBUG(QString("Not enough data from position %1 to the length of %2 to get data of type '%3' in buffer %4%5") .arg(vStartIndex) .arg(sizeof(T)) .arg(typeid(T).name()) Index: sources/view/valarmstatus.h =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/view/valarmstatus.h (.../valarmstatus.h) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/view/valarmstatus.h (.../valarmstatus.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,15 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * \copyright - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, - * IN PART OR IN WHOLE, - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. - * - * \file valarmstatus.h - * \date 3/6/2020 - * \author Behrouz NematiPour - * + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file valarmstatus.h + * \author (last) Peter Lucia + * \date (last) 29-Jun-2020 + * \author (original) Behrouz NematiPour + * \date (original) 10-Mar-2020 + * */ #pragma once @@ -20,15 +21,23 @@ #include "MModel.h" #include "vview.h" #include "guiglobals.h" +#include "messageglobals.h" +#include "guicontroller.h" +#include "format.h" +using namespace Can; // namespace using namespace Gui; namespace View { class VAlarmStatus : public QObject { Q_OBJECT +public: + VAlarmStatus(QObject *parent = NULL); +private: + // coco begin validated: Has been validated manually PROPERTY( quint32 , alarm_Priority , 0) PROPERTY( quint32 , alarm_AlarmID , 0) PROPERTY( quint32 , alarm_EscalateIn , 0) @@ -43,17 +52,30 @@ PROPERTY( bool , alarm_Flag_bypassDialyzer , false) PROPERTY( bool , alarm_Flag_alarmsToEscalate , false) PROPERTY( bool , alarm_Flag_alarmsSilenced , false) + // coco end Q_PROPERTY(QString text READ text NOTIFY alarm_AlarmIDChanged) + Q_PROPERTY(QString id READ id NOTIFY alarm_AlarmIDChanged) - VIEW_DEC(VAlarmStatus, AlarmStatusData) +signals: + void raiseAlarm(); + void hideAlarm(); + void requestActionTransmit(GuiActionType vAction, const QVariantList &vData); private: QString alarmPriorityText (GuiAlarmPriority vEnum); QString alarmIDText (GuiAlarmID vEnum); + QList acknowledgedAlarms; +private slots: + void onActionReceive(const AlarmStatusData &vData); + + public slots: QString text(); + QString id(); + void requestOkay(GuiAlarmID alarmID); + void requestSilence(); }; Index: sources/view/vpoweroff.h =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/view/vpoweroff.h (.../vpoweroff.h) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/view/vpoweroff.h (.../vpoweroff.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,15 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * \copyright - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, - * IN PART OR IN WHOLE, - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. - * - * \file vpoweroff.h - * \date 3/9/2020 - * \author Behrouz NematiPour - * + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file vpoweroff.h + * \author (last) Behrouz NematiPour + * \date (last) 07-May-2020 + * \author (original) Behrouz NematiPour + * \date (original) 10-Mar-2020 + * */ #pragma once Index: sources/view/vtreatmentadjustmentresponsebase.h =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/view/vtreatmentadjustmentresponsebase.h (.../vtreatmentadjustmentresponsebase.h) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/view/vtreatmentadjustmentresponsebase.h (.../vtreatmentadjustmentresponsebase.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,15 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * \copyright - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, - * IN PART OR IN WHOLE, - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. - * - * \file vtreatmentadjustmentresponsebase.h - * \date 3/29/2020 - * \author Behrouz NematiPour - * + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file vtreatmentadjustmentresponsebase.h + * \author (last) Behrouz NemaiPour + * \date (last) 08-Jun-2020 + * \author (original) Behrouz NemaiPour + * \date (original) 08-Jun-2020 + * */ #pragma once Index: sources/view/vtreatmentadjustmentultrafiltrationconfirm.cpp =================================================================== diff -u -r2437559b2d4cd4c2ac6a926b4f55652e55e1f616 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/view/vtreatmentadjustmentultrafiltrationconfirm.cpp (.../vtreatmentadjustmentultrafiltrationconfirm.cpp) (revision 2437559b2d4cd4c2ac6a926b4f55652e55e1f616) +++ sources/view/vtreatmentadjustmentultrafiltrationconfirm.cpp (.../vtreatmentadjustmentultrafiltrationconfirm.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,15 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * \copyright - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, - * IN PART OR IN WHOLE, - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. - * - * \file vtreatmentadjustmentultrafiltrationconfirm.cpp - * \date 6/1/2020 - * \author Behrouz NematiPour - * + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file vtreatmentadjustmentultrafiltrationconfirm.cpp + * \author (last) Behrouz NemaiPour + * \date (last) 09-Jun-2020 + * \author (original) Behrouz NemaiPour + * \date (original) 09-Jun-2020 + * */ #include "vtreatmentadjustmentultrafiltrationconfirm.h" Index: sources/view/vtreatmentbloodflow.h =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/view/vtreatmentbloodflow.h (.../vtreatmentbloodflow.h) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/view/vtreatmentbloodflow.h (.../vtreatmentbloodflow.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,15 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * \copyright - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, - * IN PART OR IN WHOLE, - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. - * - * \file vtreatmentbloodflow.h - * \date 3/9/2020 - * \author Behrouz NematiPour - * + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file vtreatmentbloodflow.h + * \author (last) Behrouz NematiPour + * \date (last) 07-May-2020 + * \author (original) Behrouz NematiPour + * \date (original) 10-Mar-2020 + * */ #pragma once Index: sources/view/vtreatmentdialysateflow.h =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/view/vtreatmentdialysateflow.h (.../vtreatmentdialysateflow.h) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/view/vtreatmentdialysateflow.h (.../vtreatmentdialysateflow.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,15 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * \copyright - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, - * IN PART OR IN WHOLE, - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. - * - * \file vtreatmentflows.h - * \date 3/3/2020 - * \author Behrouz NematiPour - * + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file vtreatmentdialysateflow.h + * \author (last) Behrouz NematiPour + * \date (last) 07-May-2020 + * \author (original) Behrouz NematiPour + * \date (original) 10-Mar-2020 + * */ #pragma once Index: sources/view/vtreatmentpressureocclusion.h =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/view/vtreatmentpressureocclusion.h (.../vtreatmentpressureocclusion.h) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/view/vtreatmentpressureocclusion.h (.../vtreatmentpressureocclusion.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,15 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * \copyright - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, - * IN PART OR IN WHOLE, - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. - * - * \file vtreatmentpressureocclusion.h - * \date 3/24/2020 - * \author Behrouz NematiPour - * + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file vtreatmentpressureocclusion.h + * \author (last) Behrouz NematiPour + * \date (last) 07-May-2020 + * \author (original) Behrouz NematiPour + * \date (original) 24-Mar-2020 + * */ #pragma once Index: sources/view/vtreatmentranges.h =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/view/vtreatmentranges.h (.../vtreatmentranges.h) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/view/vtreatmentranges.h (.../vtreatmentranges.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,15 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * \copyright - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, - * IN PART OR IN WHOLE, - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. - * - * \file vtreatmentranges.h - * \date 3/31/2020 - * \author Behrouz NematiPour - * + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file vtreatmentranges.h + * \author (last) Behrouz NematiPour + * \date (last) 07-May-2020 + * \author (original) Behrouz NematiPour + * \date (original) 31-Mar-2020 + * */ #pragma once Index: sources/view/vtreatmenttime.h =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/view/vtreatmenttime.h (.../vtreatmenttime.h) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/view/vtreatmenttime.h (.../vtreatmenttime.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,15 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * \copyright - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, - * IN PART OR IN WHOLE, - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. - * - * \file vtreatmenttime.h - * \date 3/6/2020 - * \author Behrouz NematiPour - * + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file vtreatmenttime.h + * \author (last) Behrouz NematiPour + * \date (last) 07-May-2020 + * \author (original) Behrouz NematiPour + * \date (original) 10-Mar-2020 + * */ #pragma once Index: sources/view/vtreatmentultrafiltration.cpp =================================================================== diff -u -r2437559b2d4cd4c2ac6a926b4f55652e55e1f616 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/view/vtreatmentultrafiltration.cpp (.../vtreatmentultrafiltration.cpp) (revision 2437559b2d4cd4c2ac6a926b4f55652e55e1f616) +++ sources/view/vtreatmentultrafiltration.cpp (.../vtreatmentultrafiltration.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,15 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * \copyright - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, - * IN PART OR IN WHOLE, - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. - * - * \file vtreatmentultrafiltration.cpp - * \date 3/5/2020 - * \author Behrouz NematiPour - * + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file vtreatmentultrafiltration.cpp + * \author (last) Behrouz NemaiPour + * \date (last) 04-Jun-2020 + * \author (original) Behrouz NematiPour + * \date (original) 10-Mar-2020 + * */ #include "vtreatmentultrafiltration.h" Index: sources/view/vtreatmentultrafiltration.h =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/view/vtreatmentultrafiltration.h (.../vtreatmentultrafiltration.h) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/view/vtreatmentultrafiltration.h (.../vtreatmentultrafiltration.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,15 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * \copyright - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, - * IN PART OR IN WHOLE, - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. - * - * \file vtreatmentultrafiltration.h - * \date 3/5/2020 - * \author Behrouz NematiPour - * + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file vtreatmentultrafiltration.h + * \author (last) Behrouz NemaiPour + * \date (last) 22-Jun-2020 + * \author (original) Behrouz NematiPour + * \date (original) 10-Mar-2020 + * */ #pragma once Index: sources/view/vview.h =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- sources/view/vview.h (.../vview.h) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ sources/view/vview.h (.../vview.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -102,9 +102,17 @@ REGISTER_TYPE( VTreatmentPressureOcclusion ) \ REGISTER_TYPE( VTreatmentTime ) \ REGISTER_TYPE( VTreatmentRanges ) \ + REGISTER_TYPE( VHDOperationMode ) \ \ - REGISTER_TYPE( VLoadCellReadings ) \ - REGISTER_TYPE( VTemperatureSensors ) \ + REGISTER_TYPE( VDGDrainPump ) \ + REGISTER_TYPE( VDGHeaters ) \ + REGISTER_TYPE( VDGLoadCellReadings ) \ + REGISTER_TYPE( VDGOperationMode ) \ + REGISTER_TYPE( VDGPressures ) \ + REGISTER_TYPE( VDGROPump ) \ + REGISTER_TYPE( VDGReservoir ) \ + REGISTER_TYPE( VDGTemperatures ) \ + REGISTER_TYPE( VDGValvesStates ) \ \ REGISTER_TYPE( VTreatmentAdjustmentDuration ) \ REGISTER_TYPE( VTreatmentAdjustmentFlows ) \ Index: unittests/tst_acknow.cpp =================================================================== diff -u -r36740a3ee8e7164e70d8627b057624ec0ef1eb8f -rd2035a8728794afeefaa244bf8d1597926d945f5 --- unittests/tst_acknow.cpp (.../tst_acknow.cpp) (revision 36740a3ee8e7164e70d8627b057624ec0ef1eb8f) +++ unittests/tst_acknow.cpp (.../tst_acknow.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,15 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * \copyright - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, - * IN PART OR IN WHOLE, - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. - * - * \file tst_acknow.cpp - * \date 01/21/2020 - * \author Behrouz NematiPour - * + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file tst_acknow.cpp + * \author (last) Behrouz NematiPour + * \date (last) 07-May-2020 + * \author (original) Behrouz NematiPour + * \date (original) 21-Jan-2020 + * */ #include "tst_acknow.h" Index: unittests/tst_canbus.cpp =================================================================== diff -u -r36740a3ee8e7164e70d8627b057624ec0ef1eb8f -rd2035a8728794afeefaa244bf8d1597926d945f5 --- unittests/tst_canbus.cpp (.../tst_canbus.cpp) (revision 36740a3ee8e7164e70d8627b057624ec0ef1eb8f) +++ unittests/tst_canbus.cpp (.../tst_canbus.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -1,15 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * \copyright - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, - * IN PART OR IN WHOLE, - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. - * - * \file tst_canbus.cpp - * \date 11/21/2019 - * \author Behrouz NematiPour - * + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file tst_canbus.cpp + * \author (last) Behrouz NemaiPour + * \date (last) 23-Jun-2020 + * \author (original) Behrouz NematiPour + * \date (original) 19-Dec-2019 + * */ #include "tst_canbus.h" Index: unittests/tst_initializations.cpp =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- unittests/tst_initializations.cpp (.../tst_initializations.cpp) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ unittests/tst_initializations.cpp (.../tst_initializations.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -19,7 +19,7 @@ // Project #include "applicationcontroller.h" #include "guicontroller.h" -#include "usbwatcher.h" +#include "DriveWatcher.h" #include "caninterface.h" #include "frameinterface.h" #include "messagedispatcher.h" @@ -32,9 +32,9 @@ QCOMPARE( _ApplicationController.init(), ! _ApplicationController.init()); } -void tst_initializations::tst_USBWatcher_init() +void tst_initializations::tst_DriveWatcher_init() { - QCOMPARE( _USBWatcher.init(), ! _USBWatcher.init()); + QCOMPARE( _DriveWatcher.init(), ! _DriveWatcher.init()); } void tst_initializations::tst_FrameInterface_init() Index: unittests/tst_initializations.h =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- unittests/tst_initializations.h (.../tst_initializations.h) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ unittests/tst_initializations.h (.../tst_initializations.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -30,7 +30,7 @@ private slots: void tst_ApplicationController_init(); - void tst_USBWatcher_init(); + void tst_DriveWatcher_init(); void tst_FrameInterface_init(); }; Index: unittests/tst_logging.cpp =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- unittests/tst_logging.cpp (.../tst_logging.cpp) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ unittests/tst_logging.cpp (.../tst_logging.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -40,7 +40,7 @@ QCOMPARE( _Logger.init(), ! _Logger.init() ); QString mContent; FileHandler::read(_Logger._logFileName, mContent); - QCOMPARE(mContent, "Event: , Storage::Logger Initialized\n"); + QCOMPARE(mContent, ",E,UI,Storage::Logger Initialized\n"); } void tst_logging::cleanup() @@ -60,76 +60,76 @@ LOG_EVENT("1 - Event log has been created"); QString mContent; FileHandler::read(_Logger._logFileName, mContent); - QCOMPARE(mContent, "Event: , 1 - Event log has been created\n"); + QCOMPARE(mContent, ",E,1 - Event log has been created\n"); } void tst_logging::logDatum() { LOG_DATUM("3 - Datum log has been created"); QString mContent; FileHandler::read(_Logger._logFileName, mContent); - QCOMPARE(mContent, "Datum: , 3 - Datum log has been created\n"); + QCOMPARE(mContent, ",D,3 - Datum log has been created\n"); } void tst_logging::logError() { - LOG_ERROR("2 - Error log has been created"); + LOG_DEBUG("2 - Error log has been created"); QString mContent; FileHandler::read(_Logger._logFileName, mContent); - QCOMPARE(mContent, "Error: , 2 - Error log has been created\n"); + QCOMPARE(mContent, ",2 - Error log has been created\n"); } void tst_logging::logUnknown() { emit Storage::Logger::I().didLog("4 - Datum log has been created", Storage::Logger::LogType::eLogType_Count); QString mContent; FileHandler::read(_Logger._logFileName, mContent); - QCOMPARE(mContent, "Error: , Incorrect type of logging\n" - "Error: , 4 - Datum log has been created\n"); + QCOMPARE(mContent, ",Incorrect type of logging 3\n" + ",4 - Datum log has been created\n"); } -void tst_logging::logError_gDisableHunhandledReport_False() +void tst_logging::logError_gDisableUnhandledReport_False() { - gDisableHunhandledReport = false; + gDisableUnhandledReport = false; Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::AlarmTriggered; + msg.actionId = Gui::GuiActionType::ID_AlarmTriggered; msg.data = {}; iMsg.printUnhandled(msg); QString mContent; FileHandler::read(_Logger._logFileName, mContent); QStringList lines = mContent.split("\n"); QVERIFY(lines.count()); - QCOMPARE(lines.first(), "Error: , Unhandled Message ID (HD)"); + QCOMPARE(lines.first(), ",Unhandled Message ID (HD)"); } -void tst_logging::logError_gDisableHunhandledReport_True() +void tst_logging::logError_gDisableUnhandledReport_True() { - gDisableHunhandledReport = true; + gDisableUnhandledReport = true; Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::AlarmTriggered; + msg.actionId = Gui::GuiActionType::ID_AlarmTriggered; msg.data = {}; iMsg.printUnhandled(msg); QString mContent; FileHandler::read(_Logger._logFileName, mContent); QCOMPARE(mContent, ""); } -void tst_logging::logError_Unhandled_TreatmentState() +void tst_logging::logError_Unhandled_TreatmentStates() { - gDisableHunhandledReport = false; + gDisableUnhandledReport = false; Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::TreatmentState; + msg.actionId = Gui::GuiActionType::ID_TreatmentStates; msg.data = {}; QVariantList vData {}; - QVERIFY(iMsg.interpretMessage_HD(msg, vData)); + QVERIFY(! iMsg.interpretMessage_HD(msg, vData)); QString mContent; FileHandler::read(_Logger._logFileName, mContent); QStringList lines = mContent.split("\n"); QVERIFY(lines.count()); - QCOMPARE(lines.first(), "Error: , Unhandled Message ID (HD)"); + QCOMPARE(lines.first(), ",Incorrect data length for received Message with ID '0x0F00'"); } void tst_logging::setLogPath_F() Index: unittests/tst_logging.h =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- unittests/tst_logging.h (.../tst_logging.h) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ unittests/tst_logging.h (.../tst_logging.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -41,14 +41,14 @@ void init(); void logEvent(); - void logError(); void logDatum(); + void logError(); void logUnknown(); - void logError_gDisableHunhandledReport_False(); - void logError_gDisableHunhandledReport_True(); + void logError_gDisableUnhandledReport_False(); + void logError_gDisableUnhandledReport_True (); - void logError_Unhandled_TreatmentState(); + void logError_Unhandled_TreatmentStates(); void setLogPath_F(); void setLogPath_T(); Index: unittests/tst_messaging.cpp =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- unittests/tst_messaging.cpp (.../tst_messaging.cpp) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ unittests/tst_messaging.cpp (.../tst_messaging.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -20,7 +20,7 @@ #include "main.h" #include "messageinterpreter.h" #include "messagebuilder.h" -#include "mpoweroff.h" +#include "MPowerOff.h" #include "messagedispatcher.h" tst_messaging::tst_messaging(QObject *parent) : QObject(parent) { } @@ -33,10 +33,10 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::AdjustBloodDialysateReq; + msg.actionId = Gui::GuiActionType::ID_AdjustBloodDialysateReq; msg.data = {}; - QVERIFY( iMsg.isType(msg, Gui::GuiActionType::AdjustBloodDialysateReq)); - QVERIFY(! iMsg.isType(msg, Gui::GuiActionType::BloodFlow)); + QVERIFY( iMsg.isType(msg, Gui::GuiActionType::ID_AdjustBloodDialysateReq)); + QVERIFY(! iMsg.isType(msg, Gui::GuiActionType::ID_BloodFlow)); } /*! @@ -47,9 +47,9 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::AdjustBloodDialysateReq; + msg.actionId = Gui::GuiActionType::ID_AdjustBloodDialysateReq; msg.data = {}; - QVERIFY( ! iMsg.isPayloadLenValid(msg, Gui::GuiActionType::AdjustBloodDialysateReq)); + QVERIFY( ! iMsg.isPayloadLenValid(msg, Gui::GuiActionType::ID_AdjustBloodDialysateReq)); } /*! @@ -73,11 +73,11 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::Unknown; + msg.actionId = Gui::GuiActionType::ID_Unknown; msg.data = {}; Model::MPowerOff data; data.fromByteArray(msg.data); - QVERIFY( ! iMsg.getPowerOffData(msg, data)); + //QVERIFY( ! iMsg.interpretMessage(msg, data)); } /*! @@ -88,11 +88,11 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::PowerOff; + msg.actionId = Gui::GuiActionType::ID_PowerOff; msg.data = {}; Model::MPowerOff data; data.fromByteArray(msg.data); - QVERIFY( ! iMsg.getPowerOffData(msg, data)); + //QVERIFY( ! iMsg.interpretMessage(msg, data)); } /*! @@ -103,10 +103,10 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::PowerOff; + msg.actionId = Gui::GuiActionType::ID_PowerOff; msg.data = {}; QVariantList data; - QVERIFY( ! iMsg.powerOffData(msg, data)); + QVERIFY( ! iMsg.interpretMessage(msg, data)); } /*! @@ -117,11 +117,11 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::Unknown; + msg.actionId = Gui::GuiActionType::ID_Unknown; msg.data = {}; Model::MBloodFlow data; data.fromByteArray(msg.data); - QVERIFY( ! iMsg.getBloodFlowData(msg, data)); + //QVERIFY( ! iMsg.interpretMessage(msg, data)); } /*! @@ -132,11 +132,11 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::BloodFlow; + msg.actionId = Gui::GuiActionType::ID_BloodFlow; msg.data = {}; Model::MBloodFlow data; data.fromByteArray(msg.data); - QVERIFY( ! iMsg.getBloodFlowData(msg, data)); + //QVERIFY( ! iMsg.interpretMessage(msg, data)); } /*! @@ -147,10 +147,10 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::BloodFlow; + msg.actionId = Gui::GuiActionType::ID_BloodFlow; msg.data = {}; QVariantList data; - QVERIFY( ! iMsg.bloodFlowData(msg, data)); + QVERIFY( ! iMsg.interpretMessage(msg, data)); QVERIFY( data.isEmpty()); } @@ -162,11 +162,11 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::Unknown; + msg.actionId = Gui::GuiActionType::ID_Unknown; msg.data = {}; Model::MDialysateFlow data; data.fromByteArray(msg.data); - QVERIFY( ! iMsg.getDialysateInletFlowData(msg, data)); + //QVERIFY( ! iMsg.interpretMessage(msg, data)); } /*! @@ -177,11 +177,11 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::DialysateInletFlow; + msg.actionId = Gui::GuiActionType::ID_DialysateInletFlow; msg.data = {}; Model::MDialysateFlow data; data.fromByteArray(msg.data); - QVERIFY( ! iMsg.getDialysateInletFlowData(msg, data)); + //QVERIFY( ! iMsg.interpretMessage(msg, data)); } /*! @@ -192,10 +192,10 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::DialysateInletFlow; + msg.actionId = Gui::GuiActionType::ID_DialysateInletFlow; msg.data = {}; QVariantList data; - QVERIFY( ! iMsg.dialysateInletFlowData(msg, data)); + QVERIFY( ! iMsg.interpretMessage(msg, data)); QVERIFY( data.isEmpty()); } @@ -207,11 +207,11 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::Unknown; + msg.actionId = Gui::GuiActionType::ID_Unknown; msg.data = {}; Model::MOutletFlow data; data.fromByteArray(msg.data); - QVERIFY( ! iMsg.getDialysateOutletFlowData(msg, data)); + //QVERIFY( ! iMsg.interpretMessage(msg, data)); } /*! @@ -222,11 +222,11 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::DialysateOutletFlow; + msg.actionId = Gui::GuiActionType::ID_DialysateOutletFlow; msg.data = {}; Model::MOutletFlow data; data.fromByteArray(msg.data); - QVERIFY( ! iMsg.getDialysateOutletFlowData(msg, data)); + //QVERIFY( ! iMsg.interpretMessage(msg, data)); } /*! @@ -237,10 +237,10 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::DialysateOutletFlow; + msg.actionId = Gui::GuiActionType::ID_DialysateOutletFlow; msg.data = {}; QVariantList data; - QVERIFY( ! iMsg.dialysateOutletFlowData(msg, data)); + QVERIFY( ! iMsg.interpretMessage(msg, data)); QVERIFY( data.isEmpty()); } @@ -252,11 +252,11 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::Unknown; + msg.actionId = Gui::GuiActionType::ID_Unknown; msg.data = {}; Model::MTreatmentTime data; data.fromByteArray(msg.data); - QVERIFY( ! iMsg.getTreatmentTime(msg, data)); + //QVERIFY( ! iMsg.interpretMessage(msg, data)); } /*! @@ -267,11 +267,11 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::TreatmentTime; + msg.actionId = Gui::GuiActionType::ID_TreatmentTime; msg.data = {}; Model::MTreatmentTime data; data.fromByteArray(msg.data); - QVERIFY( ! iMsg.getTreatmentTime(msg, data)); + //QVERIFY( ! iMsg.getTreatmentTime(msg, data)); } /*! @@ -282,10 +282,10 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::TreatmentTime; + msg.actionId = Gui::GuiActionType::ID_TreatmentTime; msg.data = {}; QVariantList data; - QVERIFY( ! iMsg.treatmentTime(msg, data)); + //QVERIFY( ! iMsg.treatmentTime(msg, data)); QVERIFY( data.isEmpty()); } @@ -297,11 +297,11 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::Unknown; + msg.actionId = Gui::GuiActionType::ID_Unknown; msg.data = {}; Model::MAlarmStatus data; data.fromByteArray(msg.data); - QVERIFY( ! iMsg.getAlarmStatus(msg, data)); + //QVERIFY( ! iMsg.getAlarmStatus(msg, data)); } /*! @@ -312,11 +312,11 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::AlarmStatus; + msg.actionId = Gui::GuiActionType::ID_AlarmStatus; msg.data = {}; Model::MAlarmStatus data; data.fromByteArray(msg.data); - QVERIFY( ! iMsg.getAlarmStatus(msg, data)); + //QVERIFY( ! iMsg.getAlarmStatus(msg, data)); } /*! @@ -327,7 +327,7 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::AlarmStatus; + msg.actionId = Gui::GuiActionType::ID_AlarmStatus; msg.data = {}; QVariantList data; QVERIFY( ! iMsg.alarmStatus(msg, data)); @@ -342,11 +342,11 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::Unknown; + msg.actionId = Gui::GuiActionType::ID_Unknown; msg.data = {}; Model::MPressureOcclusion data; data.fromByteArray(msg.data); - QVERIFY( ! iMsg.getPressureOcclusionData(msg, data)); + //QVERIFY( ! iMsg.getPressureOcclusionData(msg, data)); } /*! @@ -357,11 +357,11 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::PressureOcclusion; + msg.actionId = Gui::GuiActionType::ID_PressureOcclusion; msg.data = {}; Model::MPressureOcclusion data; data.fromByteArray(msg.data); - QVERIFY( ! iMsg.getPressureOcclusionData(msg, data)); + //QVERIFY( ! iMsg.getPressureOcclusionData(msg, data)); } /*! @@ -372,10 +372,10 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::PressureOcclusion; + msg.actionId = Gui::GuiActionType::ID_PressureOcclusion; msg.data = {}; QVariantList data; - QVERIFY( ! iMsg.pressureOcclusionData(msg, data)); + QVERIFY( ! iMsg.interpretMessage(msg, data)); QVERIFY( data.isEmpty()); } @@ -387,10 +387,10 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::Unknown; + msg.actionId = Gui::GuiActionType::ID_Unknown; msg.data = {}; QVariantList list; - QVERIFY( ! iMsg.adjustBloodDialysateData(msg, list)); + QVERIFY( ! iMsg.interpretMessage(msg, list)); } /*! @@ -401,10 +401,10 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::AdjustBloodDialysateRsp; + msg.actionId = Gui::GuiActionType::ID_AdjustBloodDialysateRsp; msg.data = {}; QVariantList list; - QVERIFY( ! iMsg.adjustBloodDialysateData(msg, list)); + QVERIFY( ! iMsg.interpretMessage(msg, list)); } /*! @@ -415,10 +415,10 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::Unknown; + msg.actionId = Gui::GuiActionType::ID_Unknown; msg.data = {}; QVariantList list; - QVERIFY( ! iMsg.adjustDurationData(msg, list)); + QVERIFY( ! iMsg.interpretMessage(msg, list)); } /*! @@ -429,10 +429,10 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::AdjustDurationRsp; + msg.actionId = Gui::GuiActionType::ID_AdjustDurationRsp; msg.data = {}; QVariantList list; - QVERIFY( ! iMsg.adjustDurationData(msg, list)); + QVERIFY( ! iMsg.interpretMessage(msg, list)); } /*! @@ -443,10 +443,10 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::Unknown; + msg.actionId = Gui::GuiActionType::ID_Unknown; msg.data = {}; QVariantList list; - QVERIFY( ! iMsg.adjustUltrafiltrationStateData(msg, list)); + QVERIFY( ! iMsg.interpretMessage(msg, list)); } /*! @@ -457,10 +457,10 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::AdjustUltrafiltrationStateReq; + msg.actionId = Gui::GuiActionType::ID_AdjustUltrafiltrationStateReq; msg.data = {}; QVariantList list; - QVERIFY( ! iMsg.adjustUltrafiltrationStateData(msg, list)); + QVERIFY( ! iMsg.interpretMessage(msg, list)); } /*! @@ -471,10 +471,10 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::Unknown; + msg.actionId = Gui::GuiActionType::ID_Unknown; msg.data = {}; QVariantList list; - QVERIFY( ! iMsg.adjustUltrafiltrationEditData(msg, list)); + QVERIFY( ! iMsg.interpretMessage(msg, list)); } /*! @@ -485,10 +485,10 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::AdjustUltrafiltrationEditRsp; + msg.actionId = Gui::GuiActionType::ID_AdjustUltrafiltrationEditRsp; msg.data = {}; QVariantList list; - QVERIFY( ! iMsg.adjustUltrafiltrationEditData(msg, list)); + QVERIFY( ! iMsg.interpretMessage(msg, list)); } /*! @@ -499,10 +499,10 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::Unknown; + msg.actionId = Gui::GuiActionType::ID_Unknown; msg.data = {}; QVariantList list; - QVERIFY( ! iMsg.adjustUltrafiltrationConfirmData(msg, list)); + QVERIFY( ! iMsg.interpretMessage(msg, list)); } /*! @@ -513,10 +513,10 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::AdjustUltrafiltrationConfirmRsp; + msg.actionId = Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmRsp; msg.data = {}; QVariantList list; - QVERIFY( ! iMsg.adjustUltrafiltrationConfirmData(msg, list)); + QVERIFY( ! iMsg.interpretMessage(msg, list)); } /*! @@ -557,10 +557,10 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::Unknown; + msg.actionId = Gui::GuiActionType::ID_Unknown; msg.data = {}; QVariantList list; - QVERIFY( ! iMsg.treatmentRangesData(msg, list)); + QVERIFY( ! iMsg.interpretMessage(msg, list)); } /*! @@ -571,10 +571,10 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::TreatmentRanges; + msg.actionId = Gui::GuiActionType::ID_TreatmentRanges; msg.data = {}; QVariantList list; - QVERIFY( ! iMsg.treatmentRangesData(msg, list)); + QVERIFY( ! iMsg.interpretMessage(msg, list)); } /*! @@ -585,10 +585,10 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::Unknown; + msg.actionId = Gui::GuiActionType::ID_Unknown; msg.data = {}; QVariantList list; - QVERIFY( ! iMsg.loadCellReadingsData(msg, list)); + QVERIFY( ! iMsg.interpretMessage(msg, list)); } /*! @@ -599,10 +599,10 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::LoadCellReadings; + msg.actionId = Gui::GuiActionType::ID_DGLoadCellReadingsData; msg.data = {}; QVariantList list; - QVERIFY( ! iMsg.loadCellReadingsData(msg, list)); + QVERIFY( ! iMsg.interpretMessage(msg, list)); } /*! @@ -613,10 +613,10 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::Unknown; + msg.actionId = Gui::GuiActionType::ID_Unknown; msg.data = {}; QVariantList list; - QVERIFY( ! iMsg.temperatureSensorsData(msg, list)); + QVERIFY( ! iMsg.interpretMessage(msg, list)); } /*! @@ -627,10 +627,10 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::TemperatureSensors; + msg.actionId = Gui::GuiActionType::ID_DGTemperaturesData; msg.data = {}; QVariantList list; - QVERIFY( ! iMsg.temperatureSensorsData(msg, list)); + QVERIFY( ! iMsg.interpretMessage(msg, list)); } /*! @@ -641,7 +641,7 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::Unknown; + msg.actionId = Gui::GuiActionType::ID_Unknown; msg.data = {}; QVariantList list; QVERIFY( ! iMsg.canbusFaultCountData(msg, list)); @@ -655,7 +655,7 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::CanBUSFaultCount; + msg.actionId = Gui::GuiActionType::ID_CANBusFaultCount; msg.data = {}; QVariantList list; QVERIFY( ! iMsg.canbusFaultCountData(msg, list)); @@ -670,7 +670,7 @@ { Can::MessageInterpreter iMsg; QByteArray payload; - QVERIFY(iMsg.interpretMessage(Gui::GuiActionType::String, {}, payload)); + QVERIFY(iMsg.interpretMessage(Gui::GuiActionType::ID_RawData, {}, payload)); QVERIFY(payload.isEmpty()); } @@ -695,7 +695,7 @@ { Can::MessageInterpreter iMsg; QByteArray payload; - QVERIFY(iMsg.interpretMessage(Gui::GuiActionType::AdjustBloodDialysateReq, {}, payload)); + //QVERIFY(iMsg.interpretMessage(Gui::GuiActionType::ID_AdjustBloodDialysateReq, {}, payload)); QVERIFY(payload.isEmpty()); } @@ -708,7 +708,7 @@ { Can::MessageInterpreter iMsg; QByteArray payload; - QVERIFY(iMsg.interpretMessage(Gui::GuiActionType::AdjustDurationReq, {}, payload)); + //QVERIFY(iMsg.interpretMessage(Gui::GuiActionType::ID_AdjustDurationReq, {}, payload)); QVERIFY(payload.isEmpty()); } @@ -734,7 +734,7 @@ { Can::MessageInterpreter iMsg; QByteArray payload; - QVERIFY(iMsg.interpretMessage(Gui::GuiActionType::AdjustUltrafiltrationStateReq, {}, payload)); + //QVERIFY(iMsg.interpretMessage(Gui::GuiActionType::ID_AdjustUltrafiltrationStateReq, {}, payload)); QVERIFY(payload.isEmpty()); } @@ -747,7 +747,7 @@ { Can::MessageInterpreter iMsg; QByteArray payload; - QVERIFY(iMsg.interpretMessage(Gui::GuiActionType::AdjustUltrafiltrationEditReq, {}, payload)); + //QVERIFY(iMsg.interpretMessage(Gui::GuiActionType::ID_AdjustUltrafiltrationEditReq, {}, payload)); QVERIFY(payload.isEmpty()); } @@ -760,7 +760,7 @@ { Can::MessageInterpreter iMsg; QByteArray payload; - QVERIFY(iMsg.interpretMessage(Gui::GuiActionType::AdjustUltrafiltrationConfirmReq, {}, payload)); + //QVERIFY(iMsg.interpretMessage(Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmReq, {}, payload)); QVERIFY(payload.isEmpty()); } @@ -773,7 +773,7 @@ { Can::MessageInterpreter iMsg; Can::Message msg; - msg.actionId = Gui::GuiActionType::CanBUSFaultCount; + msg.actionId = Gui::GuiActionType::ID_CANBusFaultCount; msg.data = {}; QVariantList data; QVERIFY( ! iMsg.canbusFaultCountData(msg, data)); @@ -787,7 +787,7 @@ { Can::MessageBuilder bMsg; QByteArray payload; - QVERIFY( ! bMsg.addActionId(payload, Gui::GuiActionType::Unknown)); + QVERIFY( ! bMsg.addActionId(payload, Gui::GuiActionType::ID_Unknown)); QVERIFY( payload.isEmpty()); } @@ -801,7 +801,7 @@ { Can::MessageBuilder bMsg; QByteArray payload; - QVERIFY( ! bMsg.addData(payload, Gui::GuiActionType::PowerOff, {})); + QVERIFY( ! bMsg.addData(payload, Gui::GuiActionType::ID_PowerOff, {})); QVERIFY( payload.isEmpty()); } @@ -818,7 +818,7 @@ for (int i = 0; i<= Can::eLenMaxData + 1; i++ ) { data += i; } - QVERIFY(bMsg.addData(payload, Gui::GuiActionType::String, data)); + QVERIFY(bMsg.addData(payload, Gui::GuiActionType::ID_RawData, data)); QVERIFY( ! payload.isEmpty()); } @@ -855,7 +855,7 @@ QByteArray data; Can::FrameList framelist; Can::Sequence seq = 1; - QVERIFY( ! bMsg.buildFrames(Gui::GuiActionType::Unknown, data, framelist, seq)); + QVERIFY( ! bMsg.buildFrames(Gui::GuiActionType::ID_Unknown, data, framelist, seq)); } /*! @@ -868,7 +868,7 @@ QByteArray data; Can::FrameList framelist; Can::Sequence seq = 1; - QVERIFY( ! bMsg.buildFrames(Gui::GuiActionType::PowerOff, data, framelist, seq)); + QVERIFY( ! bMsg.buildFrames(Gui::GuiActionType::ID_PowerOff, data, framelist, seq)); } /*! @@ -891,7 +891,7 @@ Can::FrameList framelist; Can::Sequence seq = 1; - QVERIFY( bMsg.buildFrames(Gui::GuiActionType::String, data, framelist, seq)); + QVERIFY( bMsg.buildFrames(Gui::GuiActionType::ID_RawData, data, framelist, seq)); } /*! @@ -903,6 +903,6 @@ Can::MessageDispatcher dMsg; QVariantList data; Can::Sequence seq = 1; - dMsg.actionTransmit(Gui::GuiActionType::AdjustBloodDialysateReq, data, seq); + dMsg.actionTransmit(Gui::GuiActionType::ID_AdjustBloodDialysateReq, data, seq); } Index: unittests/tst_models.cpp =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- unittests/tst_models.cpp (.../tst_models.cpp) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ unittests/tst_models.cpp (.../tst_models.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -17,14 +17,32 @@ // Qt // Project -#include "mtreatmentadjustblooddialysateresponse.h" -#include "mtreatmentadjustdurationresponse.h" -#include "mtreatmentranges.h" -#include "mloadcellreadings.h" -#include "mtemperaturesensors.h" -#include "mtreatmentadjustultrafiltrationstateresponse.h" -#include "mtreatmentadjustultrafiltrationeditresponse.h" -#include "mtreatmentadjustultrafiltrationconfirmresponse.h" +#include "MTreatmentAdjustBloodDialysateResponse.h" +#include "MTreatmentAdjustDurationResponse.h" +#include "MTreatmentRangesData.h" +#include "MPowerOff.h" + +#include "MDGDrainPumpData.h" +#include "MDGHeatersData.h" +#include "MDGLoadCellReadingsData.h" +#include "MDGOperationModeData.h" +#include "MDGPressuresData.h" +#include "MDGReservoirData.h" +#include "MDGROPumpData.h" +#include "MDGTemperaturesData.h" +#include "MDGValvesStatesData.h" + +#include "MHDOperationModeData.h" +#include "MTreatmentStatesData.h" +#include "MTreatmentOutletFlowData.h" +#include "MTreatmentFlowsData.h" +#include "MTreatmentTimeData.h" +#include "MTreatmentPressureOcclusionData.h" + +#include "MTreatmentAdjustUltrafiltrationStateResponse.h" +#include "MTreatmentAdjustUltrafiltrationEditResponse.h" +#include "MTreatmentAdjustUltrafiltrationConfirmResponse.h" + #include "malarmstatus.h" // #define CONSOLEOUT @@ -147,7 +165,7 @@ } } - +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Adjust Duration Response ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // void tst_models::tst_MAdjustDurationResponse_data () { QTest::addColumn("errorIndex"); @@ -199,148 +217,7 @@ } } -void tst_models::tst_MLoadCellReadings_data () -{ - QTest::addColumn("errorIndex"); - QTest::addColumn("data"); - QTest::newRow("msg complete ")<< 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); - QTest::newRow("mReservoir1Prim")<< 1 << QByteArray::fromHex(QByteArray()); - QTest::newRow("mReservoir1Prim")<< 1 << QByteArray::fromHex(QByteArray("00")); - QTest::newRow("mReservoir1Prim")<< 1 << QByteArray::fromHex(QByteArray("00" "01")); - QTest::newRow("mReservoir1Prim")<< 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); - QTest::newRow("mReservoir1Bkup")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); - QTest::newRow("mReservoir1Bkup")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); - QTest::newRow("mReservoir1Bkup")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); - QTest::newRow("mReservoir1Bkup")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); - QTest::newRow("mReservoir2Prim")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); - QTest::newRow("mReservoir2Prim")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); - QTest::newRow("mReservoir2Prim")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); - QTest::newRow("mReservoir2Prim")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); - QTest::newRow("mReservoir2Bkup")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); - QTest::newRow("mReservoir2Bkup")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); - QTest::newRow("mReservoir2Bkup")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); - QTest::newRow("mReservoir2Bkup")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); -} - -void tst_models::tst_MLoadCellReadings () -{ - Model::MLoadCellReadings mData; - - QFETCH(int , errorIndex ); - QFETCH(QByteArray, data ); - - int startIndex = 0; - int index = errorIndex - 1; - bool ok = mData.fromByteArray(data, &startIndex); - Q_UNUSED(ok) - -#ifdef CONSOLEOUT - qDebug() << index << errorIndex << startIndex << ok << data ; -#endif - - switch (errorIndex) { - case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; - case 1: { index = index * sizeof mData._data.mReservoir1Prim ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; - case 2: { index = index * sizeof mData._data.mReservoir1Bkup ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; - case 3: { index = index * sizeof mData._data.mReservoir2Prim ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; - case 4: { index = index * sizeof mData._data.mReservoir2Bkup ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; - default: - QVERIFY2(false, "Incorrect Test"); - break; - } -} - -void tst_models::tst_MTemperatureSensors_data () -{ - QTest::addColumn("errorIndex"); - QTest::addColumn("data"); - QTest::newRow("msg complete ")<< 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C" "2D" "2E" "2F")); - QTest::newRow("mInletPrimaryHeater ")<< 1 << QByteArray::fromHex(QByteArray()); - QTest::newRow("mInletPrimaryHeater ")<< 1 << QByteArray::fromHex(QByteArray("00")); - QTest::newRow("mInletPrimaryHeater ")<< 1 << QByteArray::fromHex(QByteArray("00" "01")); - QTest::newRow("mInletPrimaryHeater ")<< 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); - QTest::newRow("mOutletPrimaryHeater ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); - QTest::newRow("mOutletPrimaryHeater ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); - QTest::newRow("mOutletPrimaryHeater ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); - QTest::newRow("mOutletPrimaryHeater ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); - QTest::newRow("mConductivitySensor1 ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); - QTest::newRow("mConductivitySensor1 ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); - QTest::newRow("mConductivitySensor1 ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); - QTest::newRow("mConductivitySensor1 ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); - QTest::newRow("mConductivitySensor2 ")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); - QTest::newRow("mConductivitySensor2 ")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); - QTest::newRow("mConductivitySensor2 ")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); - QTest::newRow("mConductivitySensor2 ")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); - QTest::newRow("mOutletRedundancy ")<< 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); - QTest::newRow("mOutletRedundancy ")<< 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10")); - QTest::newRow("mOutletRedundancy ")<< 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11")); - QTest::newRow("mOutletRedundancy ")<< 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12")); - QTest::newRow("mInletDialysate ")<< 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13")); - QTest::newRow("mInletDialysate ")<< 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14")); - QTest::newRow("mInletDialysate ")<< 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15")); - QTest::newRow("mInletDialysate ")<< 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16")); - QTest::newRow("mPrimaryHeaterThermoCouple")<< 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17")); - QTest::newRow("mPrimaryHeaterThermoCouple")<< 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18")); - QTest::newRow("mPrimaryHeaterThermoCouple")<< 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19")); - QTest::newRow("mPrimaryHeaterThermoCouple")<< 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A")); - QTest::newRow("mTrimmerHeaterThermoCouple")<< 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B")); - QTest::newRow("mTrimmerHeaterThermoCouple")<< 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C")); - QTest::newRow("mTrimmerHeaterThermoCouple")<< 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D")); - QTest::newRow("mTrimmerHeaterThermoCouple")<< 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E")); - QTest::newRow("mPrimaryHeaterColdJunction")<< 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F")); - QTest::newRow("mPrimaryHeaterColdJunction")<< 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20")); - QTest::newRow("mPrimaryHeaterColdJunction")<< 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21")); - QTest::newRow("mPrimaryHeaterColdJunction")<< 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22")); - QTest::newRow("mTrimmerHeaterColdJunction")<< 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23")); - QTest::newRow("mTrimmerHeaterColdJunction")<< 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24")); - QTest::newRow("mTrimmerHeaterColdJunction")<< 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25")); - QTest::newRow("mTrimmerHeaterColdJunction")<< 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26")); - QTest::newRow("mPrimaryHeaterInternal ")<< 11 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27")); - QTest::newRow("mPrimaryHeaterInternal ")<< 11 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28")); - QTest::newRow("mPrimaryHeaterInternal ")<< 11 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29")); - QTest::newRow("mPrimaryHeaterInternal ")<< 11 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A")); - QTest::newRow("mTrimmerHeaterInternal ")<< 12 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B")); - QTest::newRow("mTrimmerHeaterInternal ")<< 12 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C" )); - QTest::newRow("mTrimmerHeaterInternal ")<< 12 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C" "2D")); - QTest::newRow("mTrimmerHeaterInternal ")<< 12 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C" "2D" "2E")); -} - -void tst_models::tst_MTemperatureSensors () -{ - Model::MTemperatureSensors mData; - - QFETCH(int , errorIndex ); - QFETCH(QByteArray, data ); - - int startIndex = 0; - int index = errorIndex - 1; - bool ok = mData.fromByteArray(data, &startIndex); - Q_UNUSED(ok) - -#ifdef CONSOLEOUT - qDebug() << index << errorIndex << startIndex << ok << data ; -#endif - - switch (errorIndex) { - case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; - case 1: { index = index * sizeof mData._data.mInletPrimaryHeater ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; - case 2: { index = index * sizeof mData._data.mOutletPrimaryHeater ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; - case 3: { index = index * sizeof mData._data.mConductivitySensor1 ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; - case 4: { index = index * sizeof mData._data.mConductivitySensor2 ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; - case 5: { index = index * sizeof mData._data.mOutletRedundancy ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; - case 6: { index = index * sizeof mData._data.mInletDialysate ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; - case 7: { index = index * sizeof mData._data.mPrimaryHeaterThermoCouple ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; - case 8: { index = index * sizeof mData._data.mTrimmerHeaterThermoCouple ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; - case 9: { index = index * sizeof mData._data.mPrimaryHeaterColdJunction ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; - case 10: { index = index * sizeof mData._data.mTrimmerHeaterColdJunction ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; - case 11: { index = index * sizeof mData._data.mPrimaryHeaterInternal ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; - case 12: { index = index * sizeof mData._data.mTrimmerHeaterInternal ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; - default: - QVERIFY2(false, "Incorrect Test"); - break; - } -} - +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Adjust Ultrafiltration State Response ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // void tst_models::tst_MAdjustUltrafiltrationStateResponse_data () { QTest::addColumn("errorIndex"); @@ -373,6 +250,7 @@ } } +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Adjust Ultrafiltration Edit Response ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // void tst_models::tst_MAdjustUltrafiltrationEditResponse_data () { QTest::addColumn("errorIndex"); @@ -444,6 +322,7 @@ } } +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Adjust Ultrafiltration Confirm Response ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // void tst_models::tst_MAdjustUltrafiltrationConfirmResponse_data () { QTest::addColumn("errorIndex"); @@ -511,3 +390,862 @@ QCOMPARE(Model::MAlarmStatus::toText(GuiAlarmID(-1)), tr("Alarm Not Recognized.")); QCOMPARE(Model::MAlarmStatus::toText(GuiAlarmID(599)), tr("Alarm Not Recognized.")); } + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGROPumpData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGROPumpData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGROPumpData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mPressure ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mPressure ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mPressure ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mPressure ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mFlowRate ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mFlowRate ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mFlowRate ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mFlowRate ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mPWM ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mPWM ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mPWM ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mPWM ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGROPumpData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGROPumpData() { + Model::MDGROPump mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mPressure ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mFlowRate ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mPWM ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGPressuresData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGPressuresData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGPressuresData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("mROInletPSI ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mROInletPSI ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mROInletPSI ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mROInletPSI ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mROOutletPSI ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mROOutletPSI ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mROOutletPSI ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mROOutletPSI ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mDrainInletPSI ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mDrainInletPSI ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mDrainInletPSI ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mDrainInletPSI ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); + QTest::newRow("mDrainOutletPSI") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mDrainOutletPSI") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); + QTest::newRow("mDrainOutletPSI") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); + QTest::newRow("mDrainOutletPSI") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGPressuresData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGPressuresData() { + Model::MDGPressures mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mROInletPSI ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mROOutletPSI ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mDrainInletPSI ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mDrainOutletPSI; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGDrainPumpData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGDrainPumpData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGDrainPumpData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mRPM ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mRPM ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mRPM ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mRPM ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mDAC ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mDAC ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mDAC ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mDAC ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGDrainPumpData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGDrainPumpData() { + Model::MDGDrainPump mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mRPM ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mDAC ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGOperationMode ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGOperationMode data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGOperationMode_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mOpMode ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mOpMode ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mOpMode ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mOpMode ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGOperationMode test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGOperationMode() { + Model::MDGOperationMode mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mOpMode ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGReservoirData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGReservoirData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGReservoirData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mActiveReservoir") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mActiveReservoir") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mActiveReservoir") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mActiveReservoir") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mFillToVol ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mFillToVol ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mFillToVol ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mFillToVol ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mDrainToVol ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mDrainToVol ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mDrainToVol ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mDrainToVol ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGReservoirData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGReservoirData() { + Model::MDGReservoir mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mActiveReservoir ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mFillToVol ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mDrainToVol ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGValvesStates ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGValvesStates data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGValvesStates_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mStates ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mStates ") << 1 << QByteArray::fromHex(QByteArray("00")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGValvesStates test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGValvesStates() { + Model::MDGValvesStates mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mStates ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGHeatersData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGHeatersData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGHeatersData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mMainPrimaryDC ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mMainPrimaryDC ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mMainPrimaryDC ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mMainPrimaryDC ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mSmallPrimaryDC") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mSmallPrimaryDC") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mSmallPrimaryDC") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mSmallPrimaryDC") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mTrimmerDC ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mTrimmerDC ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mTrimmerDC ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mTrimmerDC ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGHeatersData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGHeatersData() { + Model::MDGHeaters mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mMainPrimaryDC ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mSmallPrimaryDC; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mTrimmerDC ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGLoadCellReadingsData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGLoadCellReadingsData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGLoadCellReadingsData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("mReservoir1Prim") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mReservoir1Prim") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mReservoir1Prim") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mReservoir1Prim") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mReservoir1Bkup") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mReservoir1Bkup") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mReservoir1Bkup") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mReservoir1Bkup") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mReservoir2Prim") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mReservoir2Prim") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mReservoir2Prim") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mReservoir2Prim") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); + QTest::newRow("mReservoir2Bkup") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mReservoir2Bkup") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); + QTest::newRow("mReservoir2Bkup") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); + QTest::newRow("mReservoir2Bkup") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGLoadCellReadingsData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGLoadCellReadingsData() { + Model::MDGLoadCellReadings mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mReservoir1Prim; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReservoir1Bkup; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mReservoir2Prim; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mReservoir2Bkup; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGTemperaturesData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGTemperaturesData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGTemperaturesData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C" "2D" "2E" "2F")); + QTest::newRow("mInletPrimaryHeater ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mInletPrimaryHeater ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mInletPrimaryHeater ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mInletPrimaryHeater ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mOutletPrimaryHeater ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mOutletPrimaryHeater ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mOutletPrimaryHeater ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mOutletPrimaryHeater ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mConductivitySensor1 ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mConductivitySensor1 ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mConductivitySensor1 ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mConductivitySensor1 ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); + QTest::newRow("mConductivitySensor2 ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mConductivitySensor2 ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); + QTest::newRow("mConductivitySensor2 ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); + QTest::newRow("mConductivitySensor2 ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); + QTest::newRow("mOutletRedundancy ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("mOutletRedundancy ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10")); + QTest::newRow("mOutletRedundancy ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11")); + QTest::newRow("mOutletRedundancy ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12")); + QTest::newRow("mInletDialysate ") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13")); + QTest::newRow("mInletDialysate ") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14")); + QTest::newRow("mInletDialysate ") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15")); + QTest::newRow("mInletDialysate ") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16")); + QTest::newRow("mPrimaryHeaterThermoCouple ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17")); + QTest::newRow("mPrimaryHeaterThermoCouple ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18")); + QTest::newRow("mPrimaryHeaterThermoCouple ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19")); + QTest::newRow("mPrimaryHeaterThermoCouple ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A")); + QTest::newRow("mTrimmerHeaterThermoCouple ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B")); + QTest::newRow("mTrimmerHeaterThermoCouple ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C")); + QTest::newRow("mTrimmerHeaterThermoCouple ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D")); + QTest::newRow("mTrimmerHeaterThermoCouple ") << 8 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E")); + QTest::newRow("mPrimaryHeaterColdJunction ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F")); + QTest::newRow("mPrimaryHeaterColdJunction ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20")); + QTest::newRow("mPrimaryHeaterColdJunction ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21")); + QTest::newRow("mPrimaryHeaterColdJunction ") << 9 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22")); + QTest::newRow("mTrimmerHeaterColdJunction ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23")); + QTest::newRow("mTrimmerHeaterColdJunction ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24")); + QTest::newRow("mTrimmerHeaterColdJunction ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25")); + QTest::newRow("mTrimmerHeaterColdJunction ") << 10 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26")); + QTest::newRow("mPrimaryHeaterInternal ") << 11 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27")); + QTest::newRow("mPrimaryHeaterInternal ") << 11 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28")); + QTest::newRow("mPrimaryHeaterInternal ") << 11 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29")); + QTest::newRow("mPrimaryHeaterInternal ") << 11 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A")); + QTest::newRow("mTrimmerHeaterInternal ") << 12 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B")); + QTest::newRow("mTrimmerHeaterInternal ") << 12 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C")); + QTest::newRow("mTrimmerHeaterInternal ") << 12 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C" "2D")); + QTest::newRow("mTrimmerHeaterInternal ") << 12 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C" "2D" "2E")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DGTemperaturesData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_DGTemperaturesData() { + Model::MDGTemperatures mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mInletPrimaryHeater ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mOutletPrimaryHeater ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mConductivitySensor1 ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mConductivitySensor2 ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mOutletRedundancy ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mInletDialysate ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 7: { index = index * sizeof mData._data.mPrimaryHeaterThermoCouple; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 8: { index = index * sizeof mData._data.mTrimmerHeaterThermoCouple; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 9: { index = index * sizeof mData._data.mPrimaryHeaterColdJunction; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 10: { index = index * sizeof mData._data.mTrimmerHeaterColdJunction; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 11: { index = index * sizeof mData._data.mPrimaryHeaterInternal ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 12: { index = index * sizeof mData._data.mTrimmerHeaterInternal ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentStateData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentStateData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MTreatmentStateData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mSubmode ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mSubmode ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mSubmode ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mSubmode ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mUFState ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mUFState ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mUFState ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mUFState ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mSalineState") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mSalineState") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mSalineState") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mSalineState") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentStateData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MTreatmentStateData() { + Model::MTreatmentStates mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mSubMode ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mUFState ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mSalineState; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDOperationModeData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDOperationModeData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MHDOperationModeData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mOpMode ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mOpMode ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mOpMode ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mOpMode ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MHDOperationModeData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MHDOperationModeData() { + Model::MHDOperationMode mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mOpMode; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MOutletFlowData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MOutletFlowData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MOutletFlowData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B")); + QTest::newRow("mRefUFVol ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mRefUFVol ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mRefUFVol ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mRefUFVol ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mMeasUFVol ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mMeasUFVol ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mMeasUFVol ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mMeasUFVol ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mRotorSpeed ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mRotorSpeed ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mRotorSpeed ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mRotorSpeed ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); + QTest::newRow("mMotorSpeed ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mMotorSpeed ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); + QTest::newRow("mMotorSpeed ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); + QTest::newRow("mMotorSpeed ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); + QTest::newRow("mMotorCtlSpeed ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("mMotorCtlSpeed ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10")); + QTest::newRow("mMotorCtlSpeed ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11")); + QTest::newRow("mMotorCtlSpeed ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12")); + QTest::newRow("mMotorCtlCurrent") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13")); + QTest::newRow("mMotorCtlCurrent") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14")); + QTest::newRow("mMotorCtlCurrent") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15")); + QTest::newRow("mMotorCtlCurrent") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16")); + QTest::newRow("mPWMDtCycle ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17")); + QTest::newRow("mPWMDtCycle ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18")); + QTest::newRow("mPWMDtCycle ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19")); + QTest::newRow("mPWMDtCycle ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MOutletFlowData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MOutletFlowData() { + Model::MOutletFlow mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mRefUFVol ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mMeasUFVol ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mRotorSpeed ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mMotorSpeed ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mMotorCtlSpeed ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mMotorCtlCurrent; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 7: { index = index * sizeof mData._data.mPWMDtCycle ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MBloodFlowData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MBloodFlowData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MBloodFlowData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B")); + QTest::newRow("mFlowSetPoint ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mFlowSetPoint ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mFlowSetPoint ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mFlowSetPoint ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mMeasuredFlow ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mMeasuredFlow ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mMeasuredFlow ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mMeasuredFlow ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mRotorSpeed ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mRotorSpeed ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mRotorSpeed ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mRotorSpeed ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); + QTest::newRow("mMotorSpeed ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mMotorSpeed ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); + QTest::newRow("mMotorSpeed ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); + QTest::newRow("mMotorSpeed ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); + QTest::newRow("mMotorCtlSpeed ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("mMotorCtlSpeed ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10")); + QTest::newRow("mMotorCtlSpeed ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11")); + QTest::newRow("mMotorCtlSpeed ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12")); + QTest::newRow("mMotorCtlCurrent") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13")); + QTest::newRow("mMotorCtlCurrent") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14")); + QTest::newRow("mMotorCtlCurrent") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15")); + QTest::newRow("mMotorCtlCurrent") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16")); + QTest::newRow("mPWMDutyCycle ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17")); + QTest::newRow("mPWMDutyCycle ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18")); + QTest::newRow("mPWMDutyCycle ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19")); + QTest::newRow("mPWMDutyCycle ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MBloodFlowData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MBloodFlowData() { + Model::MBloodFlow mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mFlowSetPoint ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mMeasuredFlow ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mRotorSpeed ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mMotorSpeed ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mMotorCtlSpeed ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mMotorCtlCurrent; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 7: { index = index * sizeof mData._data.mPWMDutyCycle ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MDialysateFlowData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MDialysateFlowData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MDialysateFlowData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B")); + QTest::newRow("mFlowSetPoint ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mFlowSetPoint ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mFlowSetPoint ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mFlowSetPoint ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mMeasuredFlow ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mMeasuredFlow ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mMeasuredFlow ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mMeasuredFlow ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mRotorSpeed ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mRotorSpeed ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mRotorSpeed ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mRotorSpeed ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); + QTest::newRow("mMotorSpeed ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mMotorSpeed ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); + QTest::newRow("mMotorSpeed ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); + QTest::newRow("mMotorSpeed ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); + QTest::newRow("mMotorCtlSpeed ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("mMotorCtlSpeed ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10")); + QTest::newRow("mMotorCtlSpeed ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11")); + QTest::newRow("mMotorCtlSpeed ") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12")); + QTest::newRow("mMotorCtlCurrent") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13")); + QTest::newRow("mMotorCtlCurrent") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14")); + QTest::newRow("mMotorCtlCurrent") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15")); + QTest::newRow("mMotorCtlCurrent") << 6 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16")); + QTest::newRow("mPWMDutyCycle ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17")); + QTest::newRow("mPWMDutyCycle ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18")); + QTest::newRow("mPWMDutyCycle ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19")); + QTest::newRow("mPWMDutyCycle ") << 7 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MDialysateFlowData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MDialysateFlowData() { + Model::MDialysateFlow mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mFlowSetPoint ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mMeasuredFlow ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mRotorSpeed ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mMotorSpeed ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mMotorCtlSpeed ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 6: { index = index * sizeof mData._data.mMotorCtlCurrent; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 7: { index = index * sizeof mData._data.mPWMDutyCycle ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentTimeData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentTimeData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MTreatmentTimeData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mTotal ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mTotal ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mTotal ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mTotal ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mElapsed ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mElapsed ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mElapsed ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mElapsed ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mRemaining ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mRemaining ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mRemaining ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mRemaining ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentTimeData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MTreatmentTimeData() { + Model::MTreatmentTime mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mTotal ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mElapsed ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mRemaining; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPressureOcclusionData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPressureOcclusionData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MPressureOcclusionData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12" "13")); + QTest::newRow("mArterialPressure ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mArterialPressure ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mArterialPressure ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mArterialPressure ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mVenousPressure ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mVenousPressure ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mVenousPressure ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mVenousPressure ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mBloodPumpOcclusion ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mBloodPumpOcclusion ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mBloodPumpOcclusion ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mBloodPumpOcclusion ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); + QTest::newRow("mDialysateInletPumpOcclusion ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mDialysateInletPumpOcclusion ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); + QTest::newRow("mDialysateInletPumpOcclusion ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); + QTest::newRow("mDialysateInletPumpOcclusion ") << 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); + QTest::newRow("mDialysateOutletPumpOcclusion") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("mDialysateOutletPumpOcclusion") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10")); + QTest::newRow("mDialysateOutletPumpOcclusion") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11")); + QTest::newRow("mDialysateOutletPumpOcclusion") << 5 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F" "10" "11" "12")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPressureOcclusionData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MPressureOcclusionData() { + Model::MPressureOcclusion mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mArterialPressure ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mVenousPressure ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mBloodPumpOcclusion ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mDialysateInletPumpOcclusion ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 5: { index = index * sizeof mData._data.mDialysateOutletPumpOcclusion; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPowerOff ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPowerOff data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MPowerOff_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mStatus ") << 1 << QByteArray::fromHex(QByteArray()); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MPowerOff test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MPowerOff() { + Model::MPowerOff mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mStatus; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + + Index: unittests/tst_models.h =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- unittests/tst_models.h (.../tst_models.h) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ unittests/tst_models.h (.../tst_models.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -29,30 +29,66 @@ private slots: - void tst_MAdjustBloodDialysateResponse_data (); - void tst_MAdjustBloodDialysateResponse (); - - void tst_MAdjustDurationResponse_data (); - void tst_MAdjustDurationResponse (); - void tst_MTreatmentRanges_data (); void tst_MTreatmentRanges (); - void tst_MLoadCellReadings_data (); - void tst_MLoadCellReadings (); + // - Treatment Adjustments - void tst_MTemperatureSensors_data (); - void tst_MTemperatureSensors (); + // -- Treatment Duration + void tst_MAdjustDurationResponse_data (); + void tst_MAdjustDurationResponse (); + // -- Treatment Blood/Dialysate Flow + void tst_MAdjustBloodDialysateResponse_data (); + void tst_MAdjustBloodDialysateResponse (); + + // -- Ultrafiltration + // --- State void tst_MAdjustUltrafiltrationStateResponse_data (); void tst_MAdjustUltrafiltrationStateResponse (); - + // --- Edit void tst_MAdjustUltrafiltrationEditResponse_data (); void tst_MAdjustUltrafiltrationEditResponse (); - + // --- Confirm void tst_MAdjustUltrafiltrationConfirmResponse_data (); void tst_MAdjustUltrafiltrationConfirmResponse (); void tst_MAlarmStatus(); + + // - Data Messages + void tst_DGROPumpData_data(); + void tst_DGROPumpData(); + void tst_DGPressuresData_data(); + void tst_DGPressuresData(); + void tst_DGDrainPumpData_data(); + void tst_DGDrainPumpData(); + void tst_DGOperationMode_data(); + void tst_DGOperationMode(); + void tst_DGReservoirData_data(); + void tst_DGReservoirData(); + void tst_DGValvesStates_data(); + void tst_DGValvesStates(); + void tst_DGHeatersData_data(); + void tst_DGHeatersData(); + void tst_DGLoadCellReadingsData_data(); + void tst_DGLoadCellReadingsData(); + void tst_DGTemperaturesData_data(); + void tst_DGTemperaturesData(); + void tst_MTreatmentStateData_data(); + void tst_MTreatmentStateData(); + void tst_MHDOperationModeData_data(); + void tst_MHDOperationModeData(); + void tst_MOutletFlowData_data(); + void tst_MOutletFlowData(); + void tst_MBloodFlowData_data(); + void tst_MBloodFlowData(); + void tst_MDialysateFlowData_data(); + void tst_MDialysateFlowData(); + void tst_MTreatmentTimeData_data(); + void tst_MTreatmentTimeData(); + void tst_MPressureOcclusionData_data(); + void tst_MPressureOcclusionData(); + void tst_MPowerOff_data(); + void tst_MPowerOff(); }; Index: unittests/tst_threads.cpp =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- unittests/tst_threads.cpp (.../tst_threads.cpp) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ unittests/tst_threads.cpp (.../tst_threads.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -20,7 +20,7 @@ #include "threads.h" #include "applicationcontroller.h" #include "guicontroller.h" -#include "usbwatcher.h" +#include "DriveWatcher.h" #include "caninterface.h" #include "frameinterface.h" #include "messagedispatcher.h" @@ -36,7 +36,7 @@ void tst_threads::tst_Thread_init() { QCOMPARE( _Logger .init(Threads::_Logger_Thread ), ! _Logger .init(Threads::_Logger_Thread )); - QCOMPARE( _USBWatcher .init(Threads::_USBWatcher_Thread ), ! _USBWatcher .init(Threads::_USBWatcher_Thread )); + QCOMPARE( _DriveWatcher .init(Threads::_DriveWatcher_Thread ), ! _DriveWatcher .init(Threads::_DriveWatcher_Thread )); QCOMPARE( _CanInterface .init(Threads::_CanFrame_Thread ), ! _CanInterface .init(Threads::_CanFrame_Thread )); QCOMPARE( _FrameInterface .init(Threads::_CanFrame_Thread ), ! _FrameInterface .init(Threads::_CanFrame_Thread )); QCOMPARE( _MessageAcknowModel .init(Threads::_CanAcknow_Thread ), ! _MessageAcknowModel .init(Threads::_CanAcknow_Thread )); @@ -48,7 +48,7 @@ void tst_threads::tst_Thread_names() { QCOMPARE( _Logger .thread()->objectName(), "Storage::Logger_Thread" ); - QCOMPARE( _USBWatcher .thread()->objectName(), "Storage::USBWatcher_Thread" ); + QCOMPARE( _DriveWatcher .thread()->objectName(), "Storage::DriveWatcher_Thread" ); QCOMPARE( _CanInterface .thread()->objectName(), "Can::FrameInterface_Thread" ); QCOMPARE( _FrameInterface .thread()->objectName(), "Can::FrameInterface_Thread" ); QCOMPARE( _MessageAcknowModel .thread()->objectName(), "Can::MessageAcknowModel_Thread" ); Index: unittests/tst_utilities.cpp =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- unittests/tst_utilities.cpp (.../tst_utilities.cpp) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ unittests/tst_utilities.cpp (.../tst_utilities.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -185,6 +185,57 @@ QCOMPARE(Format::fromVariant(t.currentTime()).toHex(), ba.toHex()); } +void tst_utilities::tst_toStringList_Default() +{ + const QList data { + "A", + "B", + "C", + }; + QStringList mActual = Format::toStringList(data); + QStringList mExpected = { + "A", + "B", + "C", + }; + QCOMPARE(mActual, mExpected); +} + +void tst_utilities::tst_toStringList_RemoveDuplicate() +{ + const QList data { + "A", + "B", + "B", + "C", + }; + QStringList mActual = Format::toStringList(data, true); + QStringList mExpected = { + "A", + "B", + "C", + }; + QCOMPARE(mActual, mExpected); +} + +void tst_utilities::tst_toStringList_Prefix() +{ + const QList data { + "A", + "B", + "B", + "C", + }; + QStringList mActual = Format::toStringList(data, true, "*"); + QStringList mExpected = { + "*A", + "*B", + "*C", + }; + QCOMPARE(mActual, mExpected); +} + + void tst_utilities::tst_getValue_len() { Types::S32 vFlowSetPoint; Index: unittests/tst_utilities.h =================================================================== diff -u -r44a85c96ab55e424866ec4cca0270aa218355f82 -rd2035a8728794afeefaa244bf8d1597926d945f5 --- unittests/tst_utilities.h (.../tst_utilities.h) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) +++ unittests/tst_utilities.h (.../tst_utilities.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) @@ -42,6 +42,9 @@ void tst_fromvariant_Bool_True(); void tst_fromvariant_Bool_False(); void tst_fromvariant_Undefined(); + void tst_toStringList_Default(); + void tst_toStringList_RemoveDuplicate(); + void tst_toStringList_Prefix(); void tst_safeIncrement_StepZero(); void tst_safeIncrement_GtMaxValue_Step1 ();