Index: denali.pro =================================================================== diff -u -rc8de9dc4cb679628ac9c0c9551bc43ad3c415d4a -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- denali.pro (.../denali.pro) (revision c8de9dc4cb679628ac9c0c9551bc43ad3c415d4a) +++ denali.pro (.../denali.pro) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -14,6 +14,20 @@ DEFINES += DISABLE_KEEP_ALIVE } +# added this section to detect which compiler is running +# to decide device dependent decisions +# by defining a MACRO +# and use that MACRO for conditional build +message($$QMAKESPEC) +linux-g++ { + message(Linux.g++) + DEFINES += BUILD_FOR_GCC +} +linux-oe-generic-g++ { + message(Linux.poky) + DEFINES += BUILD_FOR_POKY +} + # The following define makes your compiler emit warnings if you use # any Qt feature that has been marked deprecated (the exact warnings # depend on your compiler). Refer to the documentation for the @@ -34,12 +48,14 @@ sources/utility \ sources/abstract \ sources/model \ + sources/model/settings \ sources/model/hd/adjustment \ sources/model/hd/alarm \ sources/model/hd/data \ sources/model/dg/data \ sources/model/dg/adjustment \ sources/view \ + sources/view/settings \ sources/view/hd/adjustment \ sources/view/hd/alarm \ sources/view/hd/data \ @@ -61,10 +77,9 @@ sources/ApplicationController.h \ \ # ---------- Models ---------- sources/model/MModel.h \ - #sources/model/MAbstractProgressData.h \ sources/model/MAbstract.h \ - sources/model/MDGDebugText.h \ - sources/model/MHDDebugText.h \ + \ # ---------- Models - settings + sources/model/settings/MSettings.h \ \ # ---------- Models - Alarm sources/model/hd/alarm/MAlarmStatusData.h \ sources/model/hd/alarm/MAlarmTriggered.h \ @@ -107,6 +122,7 @@ sources/model/hd/data/MPreTreatmentSelfTestDryData.h \ sources/model/hd/data/MPreTreatmentDisposablesPrimeData.h \ \ # ---------- Models - HD - Data + sources/model/hd/data/MHDDebugText.h \ sources/model/hd/data/MHDAccelerometerData.h \ sources/model/hd/data/MTreatmentTimeData.h \ sources/model/hd/data/MTreatmentFlowsData.h \ @@ -123,6 +139,7 @@ \ # ---------- Models - DG - Data - Pre-Treatment - Progress sources/model/dg/data/MDGFilterFlushData.h \ \ # ---------- Models - DG - Data + sources/model/dg/data/MDGDebugText.h \ sources/model/dg/data/MDGDrainPumpData.h \ sources/model/dg/data/MDGHeatersData.h \ sources/model/dg/data/MDGLoadCellReadingsData.h \ @@ -147,6 +164,7 @@ sources/gui/GuiView.h \ sources/gui/GuiController.h \ \ # ---------- Views ---------- + sources/storage/Settings.h \ sources/view/VTreatmentCreate.h \ sources/view/VEventSpy.h \ sources/view/VView.h \ @@ -222,7 +240,8 @@ \ # Utility sources/utility/crc.h \ sources/utility/format.h \ - sources/utility/types.h + sources/utility/types.h \ + sources/view/settings/VSettings.h # sources/configuration/display.h \ # sources/configuration/sound.h \ # sources/storage/settings.h \ @@ -239,9 +258,8 @@ sources/ApplicationController.cpp \ \ # ---------- Models ---------- sources/model/MAbstract.cpp \ -# sources/model/MAbstractProgressData.cpp \ - sources/model/MHDDebugText.cpp \ - sources/model/MDGDebugText.cpp \ + \ # ---------- Models - settings + sources/model/settings/MSettings.cpp \ \ # ---------- Models - Alarm sources/model/hd/alarm/MAlarmStatusData.cpp \ sources/model/hd/alarm/MAlarmTriggered.cpp \ @@ -282,6 +300,7 @@ sources/model/hd/data/MPreTreatmentStatesData.cpp \ sources/model/hd/data/MTreatmentStatesData.cpp \ \ # ---------- Models - HD - Data + sources/model/hd/data/MHDDebugText.cpp \ sources/model/hd/data/MHDAccelerometerData.cpp \ sources/model/hd/data/MTreatmentTimeData.cpp \ sources/model/hd/data/MTreatmentFlowsData.cpp \ @@ -298,6 +317,7 @@ \ # ---------- Models - DG - Data - Pre-Treatment - Progress sources/model/dg/data/MDGFilterFlushData.cpp \ \ # ---------- Models - DG - Data + sources/model/dg/data/MDGDebugText.cpp \ sources/model/dg/data/MDGDrainPumpData.cpp \ sources/model/dg/data/MDGHeatersData.cpp \ sources/model/dg/data/MDGLoadCellReadingsData.cpp \ @@ -321,6 +341,7 @@ sources/gui/GuiView.cpp \ sources/gui/GuiController.cpp \ \ # ---------- Views ---------- + sources/storage/Settings.cpp \ sources/view/VTreatmentCreate.cpp \ sources/view/VEventSpy.cpp \ sources/view/VPowerOff.cpp \ @@ -397,7 +418,8 @@ \ # Utility sources/utility/crc.cpp \ sources/utility/format.cpp \ - sources/utility/types.cpp + sources/utility/types.cpp \ + sources/view/settings/VSettings.cpp RESOURCES += \ Index: denali.pro.user =================================================================== diff -u -r7cc15ae5968205b241a08ca4646f283b8bf97b03 -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- denali.pro.user (.../denali.pro.user) (revision 7cc15ae5968205b241a08ca4646f283b8bf97b03) +++ denali.pro.user (.../denali.pro.user) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -1,6 +1,6 @@ - + EnvironmentId Index: en_US.udic =================================================================== diff -u -re0412efcf85964a18ec52ad80f233c45998eb45a -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- en_US.udic (.../en_US.udic) (revision e0412efcf85964a18ec52ad80f233c45998eb45a) +++ en_US.udic (.../en_US.udic) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -34,3 +34,5 @@ accelerometer Init Pre +initializer +conf Index: main.cpp =================================================================== diff -u -r5c15c47de2e809f385e91e6136526020d227cb43 -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- main.cpp (.../main.cpp) (revision 5c15c47de2e809f385e91e6136526020d227cb43) +++ main.cpp (.../main.cpp) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -333,6 +333,7 @@ //! - Initializing Application Controller _ApplicationController.init(Threads::_Application_Thread); + _ApplicationController.initSettings(); ////! - Initializing GUI Controller _GuiController.init(Threads::_Application_Thread); Index: resources/NotAttachedTestImages/1.png =================================================================== diff -u -r526137b088b43e51868cb241ce70b3cf52febae8 -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 Binary files differ Index: resources/NotAttachedTestImages/2.png =================================================================== diff -u -r526137b088b43e51868cb241ce70b3cf52febae8 -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 Binary files differ Index: resources/NotAttachedTestImages/3.png =================================================================== diff -u -r526137b088b43e51868cb241ce70b3cf52febae8 -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 Binary files differ Index: resources/settings/instructions/1.png =================================================================== diff -u Binary files differ Index: resources/settings/instructions/2.png =================================================================== diff -u Binary files differ Index: resources/settings/instructions/3.png =================================================================== diff -u Binary files differ Index: resources/settings/instructions/instructions.conf =================================================================== diff -u --- resources/settings/instructions/instructions.conf (revision 0) +++ resources/settings/instructions/instructions.conf (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -0,0 +1,10 @@ +[Disposables^Cartridge Installation] +. Unlock pump track . Lock pump track =1.png +Insert cartridge using alignment pins =2.png +HD machine door open / HD machine door closed =3.png + +[A^B] +2=5.png +0/1=4.png +3=6.png + Index: resources/settings/instructions/readme.md =================================================================== diff -u --- resources/settings/instructions/readme.md (revision 0) +++ resources/settings/instructions/readme.md (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -0,0 +1,25 @@ +this folder contains the files require for the screens in the applicaiton which are instructionBased. +it has to be in the .conf folder of the home directory, for applicaiton to be able to read it when running on the device. +when running on the VM it has to be in the application project under the resources. + +To meet the instruction requirement, applicaiotn needs to have a configuration file named: + - instructions.conf +which is the file that have the mapping of the image:description set for each instructionBased screen. +Each instructionBased screen in the map file shall have a section with the format of: + + - [^] + +and then for each instrcution image and description a line with the format of: + + - <Description>=<image file name> + +Not that the current instruction design won't allow more than one line of Description. +The naming and formats show that the instruction can not have '^' in the title or category and can not have '=' in the description. + +Example: + +[Disposables^Cartridge Installation] +. Unlock pump track . Lock pump track =1.png +Insert cartridge using alignment pins =2.png +HD machine door open / HD machine door closed =3.png + Index: sources/ApplicationController.cpp =================================================================== diff -u -ra3030123e885fb9f22dea5839c4e988896a257e4 -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- sources/ApplicationController.cpp (.../ApplicationController.cpp) (revision a3030123e885fb9f22dea5839c4e988896a257e4) +++ sources/ApplicationController.cpp (.../ApplicationController.cpp) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -5,16 +5,17 @@ * 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.cpp - * \author (last) Peter Lucia - * \date (last) 15-Oct-2020 - * \author (original) Behrouz NematiPour - * \date (original) 26-Aug-2020 + * \file ApplicationController.cpp + * \author (last) Behrouz NematiPour + * \date (last) 29-Mar-2021 + * \author (original) Behrouz NematiPour + * \date (original) 29-Mar-2021 * */ #include "ApplicationController.h" // Qt +#include <QtConcurrent/QtConcurrent> // Project #include "MainTimer.h" @@ -23,7 +24,10 @@ #include "DriveWatcher.h" #include "FileHandler.h" #include "GuiController.h" +#include "Settings.h" +#include "MSettings.h" + /*! * \brief ApplicationController::ApplicationController * \details Constructor @@ -119,8 +123,14 @@ this , SLOT( onExportLog())); connect(&_Logger , SIGNAL(didExportLogs()), - this , SLOT( onExport())); + this , SLOT( onExport ())); + // Settings - move to application thread + connect(this, SIGNAL(didSettingsInit()), + this, SLOT( onSettingsInit())); + connect(&_settingsWatcher, SIGNAL(finished ()), + this , SIGNAL(didSettingsUpdate())); + // ---- Signal/Slots ADJUST_TRANSMT_MODEL_BRIDGE_CONNECTIONS(_GuiController ) ACTION_RECEIVE_MODEL_BRIDGE_CONNECTIONS(_MessageDispatcher) @@ -441,3 +451,46 @@ } } // coco end + +/*! + * \brief ApplicationController::initSettings + * \details The external method available to request for initializing the settings + * To start the task in Application Tread, emits a signal which will call a slot to take care of the execution. + */ +void ApplicationController::initSettings() +{ + PRINT_THREAD_NAME // Main Thread + + // this emit guaranties that the slot will be called in the application thread + // also the signal is private so it will be used internally only. + emit didSettingsInit({}); +} + +/*! + * \brief ApplicationController::onSettingsInit + * \details The slot which will be called to start the settings initialization in Application thread. + * This method also initializes the Settings model singleton object to let it live in the Application thread. + * To start the setting initialization QConcurrent is used with QFuture to signal the Application when it's done. + */ +void ApplicationController::onSettingsInit() +{ + PRINT_THREAD_NAME + + // has been used here to create the object in the thread that Settings is leaving in, + // which currently is Application_Thread, since the Settings is created in that thread. + Q_UNUSED(_SettingModel) + + QFuture<void> mFuture = QtConcurrent::run(this, &ApplicationController::settingsInit); + _settingsWatcher.setFuture(mFuture); +} + +/*! + * \brief ApplicationController::settingsInit + * \details The Settings read function is called in this method. + * This callback function for the QCuncurrnent run. + */ +void ApplicationController::settingsInit() +{ + Storage::Settings settings; + settings.read(); +} Index: sources/ApplicationController.h =================================================================== diff -u -ra3030123e885fb9f22dea5839c4e988896a257e4 -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- sources/ApplicationController.h (.../ApplicationController.h) (revision a3030123e885fb9f22dea5839c4e988896a257e4) +++ sources/ApplicationController.h (.../ApplicationController.h) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -5,11 +5,11 @@ * 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) 15-Oct-2020 - * \author (original) Behrouz NematiPour - * \date (original) 26-Aug-2020 + * \file ApplicationController.h + * \author (last) Behrouz NematiPour + * \date (last) 29-Mar-2021 + * \author (original) Behrouz NematiPour + * \date (original) 29-Mar-2021 * */ #pragma once @@ -56,6 +56,11 @@ QThread *_thread = nullptr; bool _init = false; + QFutureWatcher<void> _settingsWatcher; + +public: + void initSettings(); + public slots: bool init(); bool init(QThread &vThread); @@ -74,6 +79,8 @@ void createFakeSequencedLongMessage (QVariantList &vData, const int vFakeDataLen); void createFakeSeqAtBeginLongMessage(QVariantList &vData, const int vFakeDataLen); + void settingsInit(); + 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 @@ -92,6 +99,8 @@ void onFailedTransmit(Sequence seq); + void onSettingsInit(); + signals: void didActionReceive (GuiActionType vAction, const QVariantList &vData); // UI <= HD/DG void didActionTransmit(GuiActionType vAction, const QVariantList &vData); // UI => HD/DG @@ -106,6 +115,20 @@ void didExport (); + /*! + * \brief didSettingsUpdate + * \details when the Settings reads the .conf files and fills the MSettings emits this signal + * this signal can be used buy the other object that need to access the MSettings to let them know data is ready. + */ + void didSettingsUpdate(); + /*! + * \brief didSettingsInit - private signal to start initializing settings + * \details This signal used internally to make the read task of the settings happen in Application_Thread + * It's because no thread assigned to Settings itself, since this class will be used only once + * and doesn't need a thread by itself + */ + void didSettingsInit (QPrivateSignal); + // ---- Signal/Slots ADJUST_TRANSMT_MODEL_BRIDGE_DEFINITIONS ACTION_RECEIVE_MODEL_BRIDGE_DEFINITIONS Index: sources/Threads.h =================================================================== diff -u -r64d87d540594252e8039ab2595016d98f1e3cc28 -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- sources/Threads.h (.../Threads.h) (revision 64d87d540594252e8039ab2595016d98f1e3cc28) +++ sources/Threads.h (.../Threads.h) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -18,14 +18,6 @@ #include <QThread> #include <QApplication> -// Application -#define PRINT_THREAD_NAME_ENABLE 1 -#if (PRINT_THREAD_NAME_ENABLE) - #define PRINT_THREAD_NAME qDebug() << __func__ << QThread::currentThread()->objectName() -#else - #define PRINT_THREAD_NAME -#endif - namespace Threads { extern QThread _CanFrame_Thread ; extern QThread _CanAcknow_Thread ; Index: sources/gui/GuiGlobals.cpp =================================================================== diff -u -rc8de9dc4cb679628ac9c0c9551bc43ad3c415d4a -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- sources/gui/GuiGlobals.cpp (.../GuiGlobals.cpp) (revision c8de9dc4cb679628ac9c0c9551bc43ad3c415d4a) +++ sources/gui/GuiGlobals.cpp (.../GuiGlobals.cpp) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -26,6 +26,7 @@ #include "MModel.h" #include "VView.h" +#include "VSettings.h" #include "VAlarmStatus.h" #include "VPowerOff.h" // states data Index: sources/gui/qml/components/StackItem.qml =================================================================== diff -u -r8d6f0d14c717e6f3eecb32b6acb4c4306d8eb608 -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- sources/gui/qml/components/StackItem.qml (.../StackItem.qml) (revision 8d6f0d14c717e6f3eecb32b6acb4c4306d8eb608) +++ sources/gui/qml/components/StackItem.qml (.../StackItem.qml) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -27,6 +27,8 @@ Item { id : _root property alias stackView: _stackView + visible: false + width : Variables.applicationWidth height: Variables.applicationHeight @@ -103,6 +105,15 @@ info() } + /*! + * \brief reset the stack to the bottom and only the first item will remain. + */ + function reset() { + stackView.clear() + stackView.push(stackView.initialItem) + info() + } + StackView { id : _stackView initialItem : null anchors.fill: parent Index: sources/gui/qml/compounds/InstructionView.qml =================================================================== diff -u -rbd01334f257c35b96b7b232beacbcd7fae60c852 -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- sources/gui/qml/compounds/InstructionView.qml (.../InstructionView.qml) (revision bd01334f257c35b96b7b232beacbcd7fae60c852) +++ sources/gui/qml/compounds/InstructionView.qml (.../InstructionView.qml) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -27,19 +27,21 @@ * as the current progress in each of the pre-treatment steps. */ Rectangle { id: _root - property var stepNames : [] - property var stepImages : [] + property string location : "" + property var stepNames : [] + property var stepImages : [] property alias currentStepIndex: _swipeview.currentIndex readonly property bool isEmpty : stepNames.length == 0 && stepImages.length == 0 readonly property bool firstStep : isEmpty || _swipeview.currentIndex == 0 readonly property bool lastStep : isEmpty || _swipeview.currentIndex == _swipeview.count - 1 - readonly property int frameGap : 47 + readonly property int frameVGap : 47 + readonly property int frameHGap : frameVGap * 1.5 readonly property int chevronWidth : 25 readonly property int chevronHeight : 35 - readonly property int chevronMargin : ( _root.frameGap - _root.chevronWidth ) / 2 + readonly property int chevronMargin : ( _root.frameHGap - _root.chevronWidth ) / 2 readonly property int outerRadius : 10 readonly property int innerRadius : 5 @@ -50,44 +52,53 @@ border.color : Colors.borderButton radius : _root.outerRadius - Text { id: _message - color : Colors.textMain - text : _root.stepNames.length ? _root.stepNames[_swipeview.currentIndex] : "" - anchors.top : _root.top - anchors.bottom : _innerFrame.top - anchors.horizontalCenter: _root.horizontalCenter - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - font.pixelSize: Fonts.fontPixelDialogText - } - Rectangle { id: _innerFrame color : Colors.transparent border.color : Colors.line anchors { fill : _root - margins : _root.frameGap + leftMargin : _root.frameHGap + rightMargin : _root.frameHGap + topMargin : _root.frameVGap + bottomMargin: _root.frameVGap } radius : _root.innerRadius - Item { id: _containerSwipeView - clip : true // it has to be clipped although not performace friendly, otherwise the other pages will be partially shown. - anchors.fill : parent - SwipeView { id: _swipeview - anchors.fill: parent - Repeater { - model: _root.stepNames - Loader { id: _content - active: SwipeView.isCurrentItem || SwipeView.isNextItem || SwipeView.isPreviousItem - sourceComponent: Item { - Image { id: _image - width : _containerSwipeView.width - height : _containerSwipeView.height - horizontalAlignment: Image.AlignHCenter - verticalAlignment: Image.AlignVCenter - fillMode: Image.PreserveAspectFit - source: _root.stepImages[index] - } + } + + Item { id: _containerSwipeView + clip : true // it has to be clipped although not performace friendly, otherwise the other pages will be partially shown. + anchors { + right : _innerFrame.right + left : _innerFrame.left + top : _root.top + bottom : _root.bottom + } + SwipeView { id: _swipeview + anchors.fill: parent + Repeater { + model: _root.stepNames + Loader { id: _content + anchors.bottom: parent.bottom + active: SwipeView.isCurrentItem || SwipeView.isNextItem || SwipeView.isPreviousItem + sourceComponent: Item { + Text { id: _message + text : _root.stepNames.length ? _root.stepNames[_swipeview.currentIndex] : "" + color : Colors.textMain + width : parent.width + height : _root.frameVGap + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + font.pixelSize: Fonts.fontPixelDialogText } + Image { id: _image + source: _root.stepImages.length ? "file:" + _root.location + _root.stepImages[_swipeview.currentIndex] : "" + width : _innerFrame.width + height : _innerFrame.height + anchors.centerIn: parent + horizontalAlignment: Image.AlignHCenter + verticalAlignment: Image.AlignVCenter + fillMode: Image.PreserveAspectFit + } } } } @@ -127,7 +138,7 @@ MouseArea { id: _mouseAreaLeft enabled : ! _root.firstStep - width : _root.frameGap + width : _root.frameHGap anchors.left : _root.left anchors.top : _root.top anchors.bottom : _root.bottom @@ -138,7 +149,7 @@ } MouseArea {id: _mouseAreaRight enabled : ! _root.lastStep - width : _root.frameGap + width : _root.frameHGap anchors.right : _root.right anchors.top : _root.top anchors.bottom : _root.bottom Index: sources/gui/qml/main.qml =================================================================== diff -u -rc8de9dc4cb679628ac9c0c9551bc43ad3c415d4a -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- sources/gui/qml/main.qml (.../main.qml) (revision c8de9dc4cb679628ac9c0c9551bc43ad3c415d4a) +++ sources/gui/qml/main.qml (.../main.qml) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -21,6 +21,8 @@ import Gui.View 0.1 import Gui.Actions 0.1 +import VSettings 0.1 + // View classes import VHDAccelerometer 0.1 import VTreatmentAdjustmentVersions 0.1 @@ -93,6 +95,8 @@ width : Variables.applicationWidth height: Variables.applicationHeight + VSettings { id: vSettings } + VHDOperationMode { id: vHDOperationMode } VPreTreatmentStates { id: vPreTreatmentStates } VHDTreatmentStates { id: vHDTreatmentStates } Index: sources/gui/qml/pages/MainStack.qml =================================================================== diff -u -r7cc15ae5968205b241a08ca4646f283b8bf97b03 -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- sources/gui/qml/pages/MainStack.qml (.../MainStack.qml) (revision 7cc15ae5968205b241a08ca4646f283b8bf97b03) +++ sources/gui/qml/pages/MainStack.qml (.../MainStack.qml) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -55,14 +55,17 @@ ScreenItem { id: _faultModeScreen PlaceHolderText { screenName: qsTr("FAULT MODE") } + onVisibleChanged: if (visible) _mainMenu.hidden = true } ScreenItem { id: _serviceModeScreen PlaceHolderText { screenName: qsTr("SERVICE MODE") } + onVisibleChanged: if (visible) _mainMenu.hidden = true } - ScreenItem { id: _InitialModeScreen + ScreenItem { id: _initialModeScreen PlaceHolderText { screenName: qsTr("INITIAL MODE") } + onVisibleChanged: if (visible) _mainMenu.hidden = true } MainHome { id: _mainHome @@ -73,7 +76,7 @@ Connections { target: vHDOperationMode onFaultChanged : { page( _faultModeScreen , vfault )} onServiceChanged : { page( _serviceModeScreen , vservice )} - onInitChanged : { page( _InitialModeScreen , vinit )} + onInitChanged : { page( _initialModeScreen , vinit )} onStandbyChanged : { page( _mainHome , vstandby )} onValidateParametersChanged : { page( _preTreatmentCreateStack , vvalidateParameters )} onPreTreatmentChanged : { page( _preTreatmentMainStack , vpreTreatment )} Index: sources/gui/qml/pages/pretreatment/PreTreatmentBase.qml =================================================================== diff -u -rbd01334f257c35b96b7b232beacbcd7fae60c852 -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- sources/gui/qml/pages/pretreatment/PreTreatmentBase.qml (.../PreTreatmentBase.qml) (revision bd01334f257c35b96b7b232beacbcd7fae60c852) +++ sources/gui/qml/pages/pretreatment/PreTreatmentBase.qml (.../PreTreatmentBase.qml) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -60,7 +60,7 @@ // vvvvvvvvvvvvvvvvvvvvvvvvv HEADER vvvvvvvvvvvvvvvvvvvvvvvvv // StepNavigationTitleBar { id: _titleBar - stepIndex : stackStepIndex // shall be defined in the parent stack + stepIndex : stackStepIndex // shall have a definition in the parent stack anchors.top : _root.top anchors.horizontalCenter : parent.horizontalCenter width : _root.width @@ -156,6 +156,20 @@ iconVisible: false } + Connections { target: vSettings + onSettingsChanged : { + if ( instructionBased ) { + var group = vSettings.groupFormat.arg(header.stepNames[stackStepIndex]).arg(title.text) + if ( vSettings.settings[group] !== undefined ) { + console.debug(" 0 ----- ", group, vSettings.settings[group].keys, vSettings.settings[group].values, vSettings.settings[group].location) + instruction.location = vSettings.settings[group].location + instruction.stepNames = vSettings.settings[group].keys + instruction.stepImages = vSettings.settings[group].values + } + } + } + } + onVisibleChanged: { if (checkList) checkList.resetItems() Index: sources/gui/qml/pages/pretreatment/PreTreatmentConsumablesStack.qml =================================================================== diff -u -r8d6f0d14c717e6f3eecb32b6acb4c4306d8eb608 -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- sources/gui/qml/pages/pretreatment/PreTreatmentConsumablesStack.qml (.../PreTreatmentConsumablesStack.qml) (revision 8d6f0d14c717e6f3eecb32b6acb4c4306d8eb608) +++ sources/gui/qml/pages/pretreatment/PreTreatmentConsumablesStack.qml (.../PreTreatmentConsumablesStack.qml) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -36,8 +36,6 @@ header.confirmVisible : true title.text : qsTr("Consumables Installation") instructionBased : true - instructionStepNames : testStepNames - instructionStepImages : testStepImages } PreTreatmentBase { id: _preTreatmentConsumablesSelfTest Index: sources/gui/qml/pages/pretreatment/PreTreatmentDisposablesStack.qml =================================================================== diff -u -r8d6f0d14c717e6f3eecb32b6acb4c4306d8eb608 -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- sources/gui/qml/pages/pretreatment/PreTreatmentDisposablesStack.qml (.../PreTreatmentDisposablesStack.qml) (revision 8d6f0d14c717e6f3eecb32b6acb4c4306d8eb608) +++ sources/gui/qml/pages/pretreatment/PreTreatmentDisposablesStack.qml (.../PreTreatmentDisposablesStack.qml) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -46,8 +46,6 @@ header.confirmVisible : true header.confirmText.text : qsTr("NEXT") instructionBased : true - instructionStepNames : testStepNames - instructionStepImages : testStepImages onConfirmClicked : { page( _preTreatmentDisposablesCartridgeConnetion )} } @@ -57,8 +55,6 @@ header.confirmVisible : true header.confirmText.text : qsTr("NEXT") instructionBased : true - instructionStepNames : testStepNames - instructionStepImages : testStepImages onBackClicked : { page( _preTreatmentDisposablesCartridgeInstallation )} onConfirmClicked : { page( _preTreatmentDisposablesHeparinSyringe )} } @@ -69,8 +65,6 @@ header.confirmVisible : true header.confirmText.text : qsTr("NEXT") instructionBased : true - instructionStepNames : testStepNames - instructionStepImages : testStepImages onBackClicked : { page( _preTreatmentDisposablesCartridgeConnetion )} onConfirmClicked : { page( _preTreatmentDisposablesSalineBag )} } @@ -81,8 +75,6 @@ header.confirmVisible : true header.confirmText.text : qsTr("CONFIRM") instructionBased : true - instructionStepNames : testStepNames - instructionStepImages : testStepImages onBackClicked : { page( _preTreatmentDisposablesHeparinSyringe )} onConfirmClicked : { vPreTreatmentAdjustmentDisposablesConfirm.doConfirm()} } Index: sources/gui/qml/pages/pretreatment/PreTreatmentMainStack.qml =================================================================== diff -u -r8d6f0d14c717e6f3eecb32b6acb4c4306d8eb608 -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- sources/gui/qml/pages/pretreatment/PreTreatmentMainStack.qml (.../PreTreatmentMainStack.qml) (revision 8d6f0d14c717e6f3eecb32b6acb4c4306d8eb608) +++ sources/gui/qml/pages/pretreatment/PreTreatmentMainStack.qml (.../PreTreatmentMainStack.qml) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -30,18 +30,6 @@ stackView.initialItem : null - // these are two test step definitions later will be read from file and will be available from a model - property var testStepNames: [ - ". Unlock pump track . Lock pump track", - "Insert cartridge using alignment pins", - "HD machine door open / HD machine door closed", - ] - property var testStepImages: [ - "file:/home/denali/Projects/application/resources/NotAttachedTestImages/1.png", - "file:/home/denali/Projects/application/resources/NotAttachedTestImages/2.png", - "file:/home/denali/Projects/application/resources/NotAttachedTestImages/3.png", - ] - PreTreatmentWaterSampleStack{ id: _preTreatmentWaterSampleStack } PreTreatmentConsumablesStack{ id: _preTreatmentConsumablesStack } PreTreatmentDisposablesStack{ id: _preTreatmentDisposablesStack } Index: sources/gui/qml/pages/pretreatment/PreTreatmentWaterSampleStack.qml =================================================================== diff -u -r8d6f0d14c717e6f3eecb32b6acb4c4306d8eb608 -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- sources/gui/qml/pages/pretreatment/PreTreatmentWaterSampleStack.qml (.../PreTreatmentWaterSampleStack.qml) (revision 8d6f0d14c717e6f3eecb32b6acb4c4306d8eb608) +++ sources/gui/qml/pages/pretreatment/PreTreatmentWaterSampleStack.qml (.../PreTreatmentWaterSampleStack.qml) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -28,7 +28,7 @@ StackItem { id: _root objectName: "_PreTreatmentSampleStack" - stackView.initialItem : null + stackView.initialItem : _preTreatmentFilterFlush property int stackStepIndex : 1 @@ -53,8 +53,6 @@ header.confirmText.text : qsTr("NEXT") title.text : qsTr("Water Sample") instructionBased : true - instructionStepNames : testStepNames - instructionStepImages : testStepImages footer.children: [ TouchRect { width: parent.splits @@ -69,8 +67,6 @@ header.backVisible : true title.text : qsTr("Water Sample Result") instructionBased : true - instructionStepNames : testStepNames - instructionStepImages : testStepImages footer.children: [ TouchRect { width: parent.splits @@ -89,8 +85,6 @@ PreTreatmentBase { id: _preTreatmentWaterSampleResultFail title.text : qsTr("Water Sample Result Failed") instructionBased : true - instructionStepNames : testStepNames - instructionStepImages : testStepImages footer.children: [ TouchRect { width: parent.spacing @@ -136,7 +130,7 @@ _mainMenu.hidden = true } else { - stackView.initialItem = null + reset() } } } Index: sources/gui/qml/pages/pretreatment/connection/PreTreatmentConnectionStack.qml =================================================================== diff -u -r8d6f0d14c717e6f3eecb32b6acb4c4306d8eb608 -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- sources/gui/qml/pages/pretreatment/connection/PreTreatmentConnectionStack.qml (.../PreTreatmentConnectionStack.qml) (revision 8d6f0d14c717e6f3eecb32b6acb4c4306d8eb608) +++ sources/gui/qml/pages/pretreatment/connection/PreTreatmentConnectionStack.qml (.../PreTreatmentConnectionStack.qml) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -46,8 +46,6 @@ header.confirmText.text : qsTr("CONTINUE") instructionBased : true - instructionStepNames : testStepNames - instructionStepImages : testStepImages } PreTreatmentBase { id: _preTreatmentStartTreatment @@ -56,8 +54,6 @@ title.text : qsTr("Start Treatment") header.confirmText.text : qsTr("START") instructionBased : true - // instructionStepNames : testStepNames - // instructionStepImages : testStepImages } Connections { target: vPreTreatmentStates Index: sources/gui/qml/pages/pretreatment/create/PreTreatmentCreateStack.qml =================================================================== diff -u -r7cc15ae5968205b241a08ca4646f283b8bf97b03 -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- sources/gui/qml/pages/pretreatment/create/PreTreatmentCreateStack.qml (.../PreTreatmentCreateStack.qml) (revision 7cc15ae5968205b241a08ca4646f283b8bf97b03) +++ sources/gui/qml/pages/pretreatment/create/PreTreatmentCreateStack.qml (.../PreTreatmentCreateStack.qml) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -29,18 +29,16 @@ stackView.initialItem : null - property int stackStepINdex : 0 + property int stackStepIndex : 0 PreTreatmentCreate { id: _pretreatmentCreate - header.stepIndex : stackStepINdex header.backVisible : true header.confirmVisible : true header.confirmText.text : qsTr("CONTINUE") title.text : qsTr("Create a Custom Treatment") } PreTreatmentConfirm { id: _pretreatmentConfirm - header.stepIndex : stackStepINdex header.backVisible : true header.confirmVisible : true title.text : qsTr("Confirm Treatment") Index: sources/gui/qml/pages/treatment/TreatmentStack.qml =================================================================== diff -u -r7cc15ae5968205b241a08ca4646f283b8bf97b03 -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- sources/gui/qml/pages/treatment/TreatmentStack.qml (.../TreatmentStack.qml) (revision 7cc15ae5968205b241a08ca4646f283b8bf97b03) +++ sources/gui/qml/pages/treatment/TreatmentStack.qml (.../TreatmentStack.qml) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -46,14 +46,14 @@ signal backClicked // Components - MainMenu { id: _treatmentMenu + MainMenu { id: _treatmentMenu y : Variables.mainMenuHeight * -1 position : MainMenu.Position.Top hidden : true titles : [ qsTr("Back") , qsTr("Treatment") , qsTr("Trending") , qsTr("Settings") ] spacing : 20 leftPdding : 20 - partitionWidth : 100 // Todo Important : max width should be the width for all + partitionWidth : 100 // Todo Important : max width should be the width for all bottons hasRightText : true hasLogo : true } @@ -151,16 +151,25 @@ } Connections { target: vHDOperationMode - onInTreatmentChanged : { if ( vinTreatment ) { push( _treatmentStart )}} + // The initail screen should be the Blood Prime, since that one is the earlier state in the list. + // also since it is being used in two stacks In-Treatment and also in End-Treatmet is has been defined in the MainStack. + onInTreatmentChanged : { page( _postTreatmentBloodPrime , vinTreatment )} } + Connections { target: _postTreatmentBloodPrime + onVisibleChanged: { + if (_postTreatmentBloodPrime.visible) { + _treatmentMenu.hidden = true + } + } + } + Connections { target: vHDTreatmentStates // in-Treatmet - onTxDialysisChanged : { if ( vtxDialysis ) { push( _treatmentStart )}} + onTxDialysisChanged : { page( _treatmentStart , vtxDialysis )} } Connections { target: _mainHome - onStartTreatment : push( _treatmentStart ) - onVisibleChanged : if (_mainHome.visible) _treatmentMenu.hidden = true + onStartTreatment : { page ( _treatmentStart )} } } Index: sources/gui/qml/pages/treatment/TreatmentStart.qml =================================================================== diff -u -r153409973471214f29d5fad170a8b4ec0f4c4f2e -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- sources/gui/qml/pages/treatment/TreatmentStart.qml (.../TreatmentStart.qml) (revision 153409973471214f29d5fad170a8b4ec0f4c4f2e) +++ sources/gui/qml/pages/treatment/TreatmentStart.qml (.../TreatmentStart.qml) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -141,7 +141,6 @@ // TEST : this is a test code since the back button has been removed // and also we don't have Treatment complete yet. if (vIndex == 0) { - _treatmentMenu.hidden = true backClicked() } } Index: sources/main.h =================================================================== diff -u -rc0c63c4b149dafea2b02e4cd31f223e392ff7818 -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- sources/main.h (.../main.h) (revision c0c63c4b149dafea2b02e4cd31f223e392ff7818) +++ sources/main.h (.../main.h) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -19,6 +19,14 @@ #include <QDebug> // Project +// Application +#define PRINT_THREAD_NAME_ENABLE 0 +#if (PRINT_THREAD_NAME_ENABLE) + #define PRINT_THREAD_NAME qDebug() << " ----- " << QThread::currentThread()->objectName() << __func__ ; +#else + #define PRINT_THREAD_NAME +#endif + // TODO : A singleton parent class needs to be created // to taking care of the Threading, init, quit, and so Fisheye: Tag 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 refers to a dead (removed) revision in file `sources/model/MDGDebugText.cpp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 refers to a dead (removed) revision in file `sources/model/MDGDebugText.h'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 refers to a dead (removed) revision in file `sources/model/MHDDebugText.cpp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 refers to a dead (removed) revision in file `sources/model/MHDDebugText.h'. Fisheye: No comparison available. Pass `N' to diff? Index: sources/model/dg/data/MDGDebugText.cpp =================================================================== diff -u --- sources/model/dg/data/MDGDebugText.cpp (revision 0) +++ sources/model/dg/data/MDGDebugText.cpp (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -0,0 +1,41 @@ +/*! + * + * 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 MDGDebugText.cpp + * \author (last) Behrouz NematiPour + * \date (last) 16-Oct-2020 + * \author (original) Behrouz NemaiPour + * \date (original) 13-Jul-2020 + * + */ +#include "MDGDebugText.h" + +using namespace Model; + +QVariantList MDGDebugText::parameters() const { + return { + _data + }; +} + +bool MDGDebugText::fromByteArray(const QByteArray &vByteArray, int *) { + // since this is a variable length debug text, it is not required to check for length + // Qt simple conversion is used. + _data = qPrintable(vByteArray); // Has to be printable + return true ; +} + +/*! + * \brief MDGDebugText::data + * \details Provides model's Data from the received messages data values + * \return Data + */ +MDGDebugText::Data MDGDebugText::data() const { + Data data; + data.text = _data; + return data; +} Index: sources/model/dg/data/MDGDebugText.h =================================================================== diff -u --- sources/model/dg/data/MDGDebugText.h (revision 0) +++ sources/model/dg/data/MDGDebugText.h (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -0,0 +1,74 @@ +/*! + * + * 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 MDGDebugText.h + * \author (last) Behrouz NematiPour + * \date (last) 16-Oct-2020 + * \author (original) Behrouz NemaiPour + * \date (original) 13-Jul-2020 + * + */ +#pragma once + +// Qt +#include <QString> + +// Project +#include "MAbstract.h" +#include "types.h" + +// forward declarations +class tst_models; + +namespace Model { + +/*! + * \brief The MDGDebugText class + * \details the Debug Text Message from DG + * + * | MSG | CAN ID | M.Box | Type | Ack | Src | Dest | Description | + * |:----:|:------:|:-----:|:----:|:---:|:---:|:----:|:---------------------------------------:| + * |0xFFF2| 0x070 | 17 | Event| N | DG | UI | DG debug text for UI to log ASCII text | + * + * | Payload | + * | | + * | 40 bytes, null term text + msg overhead will take 6 frames | + * + * \sa Data + * + * <h2 class="groupheader">Logging info</h2> + * | || + * | || + * | typeText | Datum | + * | unitText | DG | + * | infoText | Debug | + * + */ +class MDGDebugText : public MAbstract { + + // friends + friend class ::tst_models; + + QVariantList parameters() const override; + QString _data; + +public: + + Type_Enum typeText () const override { return Type_Enum::eDatum; } + Unit_Enum unitText () const override { return Unit_Enum::eDG ; } + QString infoText () const override { return QString("Debug") ; } + + struct Data { + QString text; + }; + + bool fromByteArray (const QByteArray &vByteArray , int *vIndex = nullptr) override; + Data data ( ) const ; +}; +} + +typedef Model::MDGDebugText::Data DGDebugTextData; Index: sources/model/hd/data/MHDDebugText.cpp =================================================================== diff -u --- sources/model/hd/data/MHDDebugText.cpp (revision 0) +++ sources/model/hd/data/MHDDebugText.cpp (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -0,0 +1,41 @@ +/*! + * + * 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 MHDDebugText.cpp + * \author (last) Behrouz NematiPour + * \date (last) 16-Oct-2020 + * \author (original) Behrouz NemaiPour + * \date (original) 13-Jul-2020 + * + */ +#include "MHDDebugText.h" + +using namespace Model; + +QVariantList MHDDebugText::parameters() const { + return { + _data + }; +} + +bool MHDDebugText::fromByteArray(const QByteArray &vByteArray, int *) { + // since this is a variable length debug text, it is not required to check for length + // Qt simple conversion is used. + _data = qPrintable(vByteArray); // Has to be printable + return true ; +} + +/*! + * \brief MHDDebugText::data + * \details Provides model's Data from the received messages data values + * \return Data + */ +MHDDebugText::Data MHDDebugText::data() const { + Data data; + data.text = _data; + return data; +} Index: sources/model/hd/data/MHDDebugText.h =================================================================== diff -u --- sources/model/hd/data/MHDDebugText.h (revision 0) +++ sources/model/hd/data/MHDDebugText.h (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -0,0 +1,74 @@ +/*! + * + * 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 MHDDebugText.h + * \author (last) Behrouz NematiPour + * \date (last) 16-Oct-2020 + * \author (original) Behrouz NemaiPour + * \date (original) 13-Jul-2020 + * + */ +#pragma once + +// Qt +#include <QString> + +// Project +#include "MAbstract.h" +#include "types.h" + +// forward declarations +class tst_models; + +namespace Model { + +/*! + * \brief The MHDDebugText class + * \details the Debug Text Message from HD + * + * | MSG | CAN ID | M.Box | Type | Ack | Src | Dest | Description | + * |:----:|:------:|:-----:|:----:|:---:|:---:|:----:|:---------------------------------------:| + * |0xFFF1| 0x020 | 6 | Event| N | HD | UI | HD debug text for UI to log ASCII text | + * + * | Payload | + * | | + * | 40 bytes, null term text + msg overhead will take 6 frames | + * + * \sa Data + * + * <h2 class="groupheader">Logging info</h2> + * | || + * | || + * | typeText | Datum | + * | unitText | HD | + * | infoText | Debug | + * + */ +class MHDDebugText : public MAbstract { + + // friends + friend class ::tst_models; + + QVariantList parameters() const override; + QString _data; + +public: + + Type_Enum typeText () const override { return Type_Enum::eDatum; } + Unit_Enum unitText () const override { return Unit_Enum::eHD ; } + QString infoText () const override { return QString("Debug") ; } + + struct Data { + QString text; + }; + + bool fromByteArray (const QByteArray &vByteArray , int *vIndex = nullptr) override; + Data data ( ) const ; +}; +} + +typedef Model::MHDDebugText::Data HDDebugTextData; Index: sources/model/settings/MSettings.cpp =================================================================== diff -u --- sources/model/settings/MSettings.cpp (revision 0) +++ sources/model/settings/MSettings.cpp (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -0,0 +1,58 @@ +/*! + * + * 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 MSettings.cpp + * \author (last) Behrouz NematiPour + * \date (last) 28-Mar-2021 + * \author (original) Behrouz NematiPour + * \date (original) 28-Mar-2021 + * + */ +#include "MSettings.h" + +// Qt +#include <QThread> + +// Project + +// name spaces +using namespace Storage; + +MSettings::MSettings(QObject *parent) : QObject(parent) { } + +QStringList MSettings::groups() +{ + QMutexLocker locker(&_mutex); + return _settings.keys(); +} + +QStringList MSettings::keys(const QString &vGroup) +{ + Q_UNUSED(vGroup) + const QMutexLocker locker(&_mutex); + return _settings[vGroup].keys; +} + +QVariantList MSettings::values(const QString &vGroup) +{ + QMutexLocker locker(&_mutex); + return _settings[vGroup].values; +} + +QString MSettings::location(const QString &vGroup) +{ + QMutexLocker locker(&_mutex); + return _location[vGroup]; +} + +void MSettings::add(const QString &vGroup, const QString &vKey, const QVariant &vValue, const QString &vLocation) +{ + QMutexLocker locker(&_mutex); + if ( ! _location.contains(vGroup) ) _location[vGroup] = vLocation; + _settings[vGroup].keys += vKey ; + _settings[vGroup].values += vValue; +} Index: sources/model/settings/MSettings.h =================================================================== diff -u --- sources/model/settings/MSettings.h (revision 0) +++ sources/model/settings/MSettings.h (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -0,0 +1,57 @@ +/*! + * + * 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 MSettings.h + * \author (last) Behrouz NematiPour + * \date (last) 28-Mar-2021 + * \author (original) Behrouz NematiPour + * \date (original) 28-Mar-2021 + * + */ +#pragma once + +// Qt +#include <QObject> +#include <QAbstractItemModel> +#include <QMutexLocker> + +// Project +#include "main.h" // Doxygen : don't remove + +// Define +#define _SettingModel Storage::MSettings::I() + +// namespace +namespace Storage { + +class MSettings : public QObject +{ + Q_OBJECT + + struct KeyValue { + QList<QString > keys; + QList<QVariant> values; + }; + + QMap<QString,KeyValue> _settings; + QMap<QString,QString > _location; + + QMutex _mutex; + + // Singleton + SINGLETON(MSettings) + +public: + QStringList groups (); + QStringList keys (const QString &vGroup); + QVariantList values (const QString &vGroup); + QString location(const QString &vGroup); + + void add (const QString &vGroup, const QString &vKey, const QVariant &vValue, const QString &vLocation); +}; + +} Index: sources/storage/DriveWatcher.cpp =================================================================== diff -u -ra3030123e885fb9f22dea5839c4e988896a257e4 -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- sources/storage/DriveWatcher.cpp (.../DriveWatcher.cpp) (revision a3030123e885fb9f22dea5839c4e988896a257e4) +++ sources/storage/DriveWatcher.cpp (.../DriveWatcher.cpp) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -8,7 +8,7 @@ * \file DriveWatcher.cpp * \author (last) Behrouz NematiPour * \date (last) 16-Oct-2020 - * \author (original) Behrouz NemaiPour + * \author (original) Behrouz NematiPour * \date (original) 17-Jul-2020 * */ Index: sources/storage/DriveWatcher.h =================================================================== diff -u -ra3030123e885fb9f22dea5839c4e988896a257e4 -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- sources/storage/DriveWatcher.h (.../DriveWatcher.h) (revision a3030123e885fb9f22dea5839c4e988896a257e4) +++ sources/storage/DriveWatcher.h (.../DriveWatcher.h) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -8,7 +8,7 @@ * \file DriveWatcher.h * \author (last) Behrouz NematiPour * \date (last) 16-Oct-2020 - * \author (original) Behrouz NemaiPour + * \author (original) Behrouz NematiPour * \date (original) 17-Jul-2020 * */ Index: sources/storage/FileHandler.cpp =================================================================== diff -u -r20ee20860851dbe0d38a3d2f202794f9d6ed5345 -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- sources/storage/FileHandler.cpp (.../FileHandler.cpp) (revision 20ee20860851dbe0d38a3d2f202794f9d6ed5345) +++ sources/storage/FileHandler.cpp (.../FileHandler.cpp) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -338,7 +338,6 @@ QFileInfoList FileHandler::find(const QString &vPath, QStringList vNameFilters) { // coco begin validated: Needs to manually create specific folder with specific files to check the functionality // manually tested - QFileInfoList fileInfoList; QDir dir(vPath); if (!dir.exists()) return fileInfoList; @@ -348,6 +347,7 @@ // the sorting may require to change from QDir::Time to QDir::Name // since the birthTime always returns invalid // and as part of our log naming we have the birthTime in file name. + // be careful that this function is being used in cases other only logging. QDir::Time ); return fileInfoList; @@ -363,3 +363,16 @@ return total; } // coco end + +/*! + * \brief FileHandler::subFolders + * \details Look for the sub-folder in folder vFolder. + * \param vFolder - the folder to search for the sub folders. + * \return list of the sub-folders in QString + */ +QStringList FileHandler::subFolders(const QString &vFolder) +{ + QDir dir(vFolder); + dir.setFilter(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Hidden | QDir::Readable); + return dir.entryList(); +} Index: sources/storage/FileHandler.h =================================================================== diff -u -ra3030123e885fb9f22dea5839c4e988896a257e4 -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- sources/storage/FileHandler.h (.../FileHandler.h) (revision a3030123e885fb9f22dea5839c4e988896a257e4) +++ sources/storage/FileHandler.h (.../FileHandler.h) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -46,8 +46,11 @@ static bool makeFolder (const QString &vFolder); static bool isMounted (const QString &vPath, bool *vIsReadOnly = nullptr); - static QFileInfoList find(const QString &vPath, QStringList vNameFilter, quint8 vRetainPercent); - static QFileInfoList find(const QString &vPath, QStringList vNameFilter); + + static QFileInfoList find(const QString &vPath, QStringList vNameFilters, quint8 vRetainPercent); + static QFileInfoList find(const QString &vPath, QStringList vNameFilters); static quint64 totalSize(const QFileInfoList &vFileInfoList); + + static QStringList subFolders(const QString &vFolder); }; } Index: sources/storage/Logger.cpp =================================================================== diff -u -ra3030123e885fb9f22dea5839c4e988896a257e4 -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- sources/storage/Logger.cpp (.../Logger.cpp) (revision a3030123e885fb9f22dea5839c4e988896a257e4) +++ sources/storage/Logger.cpp (.../Logger.cpp) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -57,7 +57,8 @@ checkLogPath(); initConnections(); - LOG_EVENT("UI," + tr("%1 Initialized").arg(metaObject()->className())); + LOG_EVENT("--------------------------------------------------\n" + "UI," + tr("%1 Initialized").arg(metaObject()->className())); return true; } Index: sources/storage/Settings.cpp =================================================================== diff -u --- sources/storage/Settings.cpp (revision 0) +++ sources/storage/Settings.cpp (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -0,0 +1,99 @@ +/*! + * + * 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 DriveWatcher.cpp + * \author (last) Behrouz NematiPour + * \date (last) 16-Oct-2020 + * \author (original) Behrouz NematiPour + * \date (original) 17-Jul-2020 + * + */ + +// Qt +#include <QFileInfo> +#include <QStorageInfo> +#include <QSettings> + +// Project +#include "StorageGlobals.h" +#include "FileHandler.h" +#include "MSettings.h" +#include "Logger.h" + +// namespace +using namespace Storage; + +#include "Settings.h" + +bool Settings::isValid(const QString &vSettingFile) +{ + if (! QFileInfo::exists(vSettingFile)) { + LOG_DEBUG("Setting file " + vSettingFile + " does not exist."); + return false; + } + return true; +} + +/*! + * \brief Settings::doRead - reads all the configuration files in the home folder + * \details + */ +int Settings::read() +{ + PRINT_THREAD_NAME + QStringList fileFilter = QStringList() << QString("*.%1").arg(_settingsExt); + QFileInfoList settingFiles = FileHandler::find (Storage::Settings_Path_Name, fileFilter); + QStringList settingFolders = FileHandler::subFolders(Storage::Settings_Path_Name); + for ( QString &settingFolder : settingFolders ) { + QString folder = settingFolder.prepend(Storage::Settings_Path_Name); + settingFiles += FileHandler::find(folder, fileFilter); + } + for (const auto &settingFile: settingFiles) { + if (! isValid(settingFile.absoluteFilePath())) continue; + + QFile file(settingFile.absoluteFilePath()); + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { + QString group = ""; + while (!file.atEnd()) { + QString line = file.readLine().replace('\n',""); + if (line.contains("[")) { + line.replace("[","").replace("]", ""); + group = line.trimmed(); + } + else { + if (group.isEmpty()) { + continue; + } + else { + if (line.contains('=')) { + QStringList keyValue = line.split('='); + QString key = keyValue[0].trimmed(); + QString value = keyValue[1].trimmed(); + QString location= settingFile.absolutePath().prepend("/") + "/"; + qDebug() << group << key << location + value; + _SettingModel.add(group, key, QVariant(value), location); + } + } + } + } + } + + // QSettings settings(settingFile.absoluteFilePath(), QSettings::IniFormat); + // for (const auto &group : settings.childGroups()) { + // settings.beginGroup(group); + // for (const auto &key: settings.allKeys()) { + // qDebug() << group << key << settingFile.absolutePath().prepend("/") + "/" + settings.value(key).toString(); + // _SettingModel.add(group, key, settings.value(key).toString(), settingFile.absolutePath().prepend("/") + "/"); + // } + // settings.endGroup(); + // } + + } + qDebug() << " ----- " << "DONE"; + return 0; +} + Index: sources/storage/Settings.h =================================================================== diff -u --- sources/storage/Settings.h (revision 0) +++ sources/storage/Settings.h (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -0,0 +1,53 @@ +/*! + * + * 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 DriveWatcher.h + * \author (last) Behrouz NematiPour + * \date (last) 26-Mar-2021 + * \author (original) Behrouz NematiPour + * \date (original) 26-Mar-2021 + * + */ +#pragma once + +// Qt +#include <QObject> +#include <QFutureWatcher> +#include <QString> + +// Project +#include "main.h" // Doxygen : don't remove +#include "StorageGlobals.h" +#include "Threads.h" + +// forward declarations +class tst_initializations; + +namespace Storage { + +class Settings +{ + // Settings + const char *_settingsExt = "conf"; + const char *_settingsFormat = "%1/%2.%3"; + +private: + const QString makeSetting(const char *vPath, const char *vFile) { + QString literal(_settingsFormat); + return QString(literal.arg(vPath).arg(vFile).arg(_settingsExt)); + } + + bool isValid(const QString &vSettingFile); + // bool read (const QString &vSettingFile); + +public: + Settings() {} + + int read(); +}; + +} Index: sources/storage/StorageGlobals.cpp =================================================================== diff -u -rbd01334f257c35b96b7b232beacbcd7fae60c852 -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision bd01334f257c35b96b7b232beacbcd7fae60c852) +++ sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -25,14 +25,26 @@ */ namespace Storage { + + /****** TO BE CONSISTENT, ALWAYS INCLUDE '/' AT THE END OF ALL THE FOLDER/DIR/PATH IN HERE ******/ + // USB const char *USB_Mount_Point = "/media/usb/"; const char *USB_File_System = "vfat"; - // Treatment - const char *Treatment_Base_Dir = "/media/sd-card/treatment/"; - const char *Treatment_Profiles_Dir = "/media/sd-card/treatment/profiles/"; - const char *Treatment_Parameter_Ranges_Path_JSON = "/media/sd-card/treatment/denali.conf"; - + // SD-CARD +#ifdef BUILD_FOR_POKY const char *SDCard_Base_Path_Name = "/media/sd-card/"; +#else + // should not be in the project application folder. [not tracking by git] + const char *SDCard_Base_Path_Name = "/home/denali/Desktop/sd-card/"; +#endif + + // Settings +#ifdef BUILD_FOR_POKY + const char *Settings_Path_Name = QDir::homePath() + ".conf/"; +#else + // should be in the project application folder. [is tracking by git] + const char *Settings_Path_Name = "/home/denali/Projects/application/resources/settings/"; +#endif } Index: sources/storage/StorageGlobals.h =================================================================== diff -u -rcb5477be624b09e13d5fc4498634ca621722fd0e -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision cb5477be624b09e13d5fc4498634ca621722fd0e) +++ sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -23,14 +23,9 @@ extern const char *USB_Mount_Point; 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 ; + // SD-CARD + extern const char *SDCard_Base_Path_Name; - // Treatment - extern const char *Treatment_Base_Dir ; - extern const char *Treatment_Profiles_Dir ; - extern const char *Treatment_Parameter_Ranges_Path_JSON; - extern const char *SDCard_Base_Path_Name ; + // Settings + extern const char *Settings_Path_Name; } Index: sources/view/VView.h =================================================================== diff -u -rc8de9dc4cb679628ac9c0c9551bc43ad3c415d4a -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 --- sources/view/VView.h (.../VView.h) (revision c8de9dc4cb679628ac9c0c9551bc43ad3c415d4a) +++ sources/view/VView.h (.../VView.h) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -102,6 +102,8 @@ #define REGISTER_VIEW_TYPES \ using namespace View; \ \ + REGISTER_TYPE( VSettings ) \ + \ REGISTER_TYPE( VAlarmStatus ) \ REGISTER_TYPE( VPowerOff ) \ /* Data - States */ \ Index: sources/view/settings/VSettings.cpp =================================================================== diff -u --- sources/view/settings/VSettings.cpp (revision 0) +++ sources/view/settings/VSettings.cpp (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -0,0 +1,58 @@ +/*! + * + * 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 VSettings.cpp + * \author (last) Behrouz NematiPour + * \date (last) 29-Mar-2021 + * \author (original) Behrouz NematiPour + * \date (original) 29-Mar-2021 + * + */ +#include "VSettings.h" +#include "MSettings.h" + +// Qt +#include <QDebug> + +// Project +#include "ApplicationController.h" +#include "MSettings.h" + +using namespace View; + +QVariantMap VSettings::settings() +{ + return _settings; +} + +QString VSettings::groupFormat() +{ + return "%1^%2"; +} + +VSettings::VSettings(QObject *parent) : QObject(parent) +{ + connect(&_ApplicationController, SIGNAL(didSettingsUpdate()), + this , SLOT( onSettingsUpdate())); +} + +void VSettings::onSettingsUpdate() +{ + for (const auto &group : _SettingModel.groups()) { + QVariantMap variantMap; + qDebug() << " ### " + << _SettingModel.keys (group) + << _SettingModel.values (group); + variantMap["location" ] = _SettingModel.location (group); + variantMap["keys" ] = _SettingModel.keys (group); + variantMap["values" ] = _SettingModel.values (group); + _settings[group] = variantMap; + } + qDebug() << "Data Ready"; + emit settingsChanged(); +} + Index: sources/view/settings/VSettings.h =================================================================== diff -u --- sources/view/settings/VSettings.h (revision 0) +++ sources/view/settings/VSettings.h (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) @@ -0,0 +1,46 @@ +/*! + * + * 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 VSettings.cpp + * \author (last) Behrouz NematiPour + * \date (last) 29-Mar-2021 + * \author (original) Behrouz NematiPour + * \date (original) 29-Mar-2021 + * + */ +#pragma once + +// Qt +#include <QObject> +#include <QVariantMap> + +// Project + +namespace View { + +class VSettings : public QObject +{ + Q_OBJECT + + QVariantMap _settings; + + Q_PROPERTY(QString groupFormat READ groupFormat CONSTANT) + Q_PROPERTY(QVariantMap settings READ settings NOTIFY settingsChanged) + QVariantMap settings(); + QString groupFormat(); + +public: + explicit VSettings(QObject *parent = nullptr); + +private slots: + void onSettingsUpdate(); + +signals: + void settingsChanged(); +}; + +}