Index: denali.pro =================================================================== diff -u -r376859852f4d1a07263c44524aec347db29e0133 -r61f16c988a159401c92730b4cbfca5085c77222f --- denali.pro (.../denali.pro) (revision 376859852f4d1a07263c44524aec347db29e0133) +++ denali.pro (.../denali.pro) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -44,6 +44,7 @@ INCLUDEPATH += \ common \ sources \ + sources/device \ sources/storage \ sources/gui \ sources/canbus \ @@ -97,15 +98,18 @@ sources/Threads.h \ sources/MainTimer.h \ sources/AlarmGenerator.h \ + sources/device/DeviceGlobals.h \ sources/ApplicationPost.h \ \ # Controllers sources/ApplicationController.h \ + sources/device/DeviceController.h \ sources/storage/Settings.h \ sources/storage/TreatmentLog.h \ sources/wifi/WifiInterface.h \ \ # ---------- Models ---------- sources/model/MModel.h \ sources/model/MAbstract.h \ + sources/device/DeviceModels.h \ \ # ---------- Models - settings sources/model/settings/MSettings.h \ sources/model/settings/MWifiNetwork.h \ @@ -223,6 +227,7 @@ sources/view/VEventSpy.h \ sources/view/VView.h \ sources/view/VPowerOff.h \ + sources/device/DeviceView.h \ \ # ---------- Views - Settings sources/view/settings/VDateTime.h \ sources/view/settings/VSettings.h \ @@ -306,8 +311,6 @@ sources/storage/StorageGlobals.h \ sources/storage/Logger.h \ sources/storage/FileHandler.h \ - sources/storage/FileSaver.h \ - sources/storage/DriveWatcher.h \ \ # Utility sources/utility/crc.h \ sources/utility/format.h \ @@ -323,11 +326,13 @@ sources/ApplicationPost.cpp \ \ # Controllers sources/ApplicationController.cpp \ + sources/device/DeviceController.cpp \ sources/storage/Settings.cpp \ sources/storage/TreatmentLog.cpp \ sources/wifi/WifiInterface.cpp \ \ # ---------- Models ---------- sources/model/MAbstract.cpp \ + sources/device/DeviceModels.cpp \ \ # ---------- Models - settings sources/model/settings/MSettings.cpp \ \ # ---------- Models - Alarm @@ -436,6 +441,7 @@ sources/view/VTreatmentCreate.cpp \ sources/view/VEventSpy.cpp \ sources/view/VPowerOff.cpp \ + sources/device/DeviceView.cpp \ \ # ---------- Views - Alarm sources/view/hd/alarm/VAlarmStatus.cpp \ sources/view/hd/alarm/VAlarmActiveList.cpp \ @@ -521,8 +527,6 @@ sources/storage/StorageGlobals.cpp \ sources/storage/FileHandler.cpp \ sources/storage/Logger.cpp \ - sources/storage/DriveWatcher.cpp \ - sources/storage/FileSaver.cpp \ \ # Utility sources/utility/crc.cpp \ sources/utility/format.cpp \ Index: denali.pro.user =================================================================== diff -u -re5ec01a49240a211877006f2958b1f378ebfb610 -r61f16c988a159401c92730b4cbfca5085c77222f --- denali.pro.user (.../denali.pro.user) (revision e5ec01a49240a211877006f2958b1f378ebfb610) +++ denali.pro.user (.../denali.pro.user) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -1,6 +1,6 @@ - + EnvironmentId Index: en_US.udic =================================================================== diff -u -r376859852f4d1a07263c44524aec347db29e0133 -r61f16c988a159401c92730b4cbfca5085c77222f --- en_US.udic (.../en_US.udic) (revision 376859852f4d1a07263c44524aec347db29e0133) +++ en_US.udic (.../en_US.udic) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -122,3 +122,7 @@ FIXME HDAlarm VAlarm +VDevice +acknow +Gui +Gui Index: main.cpp =================================================================== diff -u -r6816b783f50e08267aa016d64350bc020080d901 -r61f16c988a159401c92730b4cbfca5085c77222f --- main.cpp (.../main.cpp) (revision 6816b783f50e08267aa016d64350bc020080d901) +++ main.cpp (.../main.cpp) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -46,7 +46,7 @@ #include "ApplicationController.h" #include "GuiController.h" #include "Logger.h" -#include "DriveWatcher.h" +#include "DeviceController.h" #include "WifiInterface.h" #include "Threads.h" @@ -320,8 +320,8 @@ " \n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "); } - //! - Initializing the Drive Watcher - _DriveWatcher.init(Threads::_DriveWatcher_Thread); + //! - Initializing the Device Controller + _DeviceController.init(Threads::_DeviceController_Thread); //! - Initializing the CANBus Interface if (_CanInterface.init(Threads::_CanFrame_Thread)) { Index: sources/ApplicationController.cpp =================================================================== diff -u -r6816b783f50e08267aa016d64350bc020080d901 -r61f16c988a159401c92730b4cbfca5085c77222f --- sources/ApplicationController.cpp (.../ApplicationController.cpp) (revision 6816b783f50e08267aa016d64350bc020080d901) +++ sources/ApplicationController.cpp (.../ApplicationController.cpp) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -21,7 +21,7 @@ #include "MainTimer.h" #include "MessageDispatcher.h" #include "Logger.h" -#include "DriveWatcher.h" +#include "DeviceController.h" #include "FileHandler.h" #include "GuiController.h" #include "Settings.h" @@ -108,16 +108,16 @@ // USB drive connect(&_GuiController , SIGNAL(didUSBDriveUmount()), this , SLOT( onUSBDriveUmount())); - connect(&_DriveWatcher , SIGNAL(didUSBDriveMount ()), - this , SLOT( onUSBDriveMount ())); - connect(&_DriveWatcher , SIGNAL(didUSBDriveRemove()), - this , SLOT( onUSBDriveRemove())); + connect(&_DeviceController , SIGNAL(didUSBDriveMount ()), + this , SLOT( onUSBDriveMount ())); + connect(&_DeviceController , SIGNAL(didUSBDriveRemove()), + this , SLOT( onUSBDriveRemove())); // SD Card - connect(&_DriveWatcher , SIGNAL(didSDCardStateChange(bool, bool)), - this , SLOT( onSDCardStateChange(bool, bool))); - connect(&_DriveWatcher , SIGNAL(didSDCardSpaceTooLow(quint8)), - this , SLOT( onSDCardSpaceTooLow(quint8))); + connect(&_DeviceController , SIGNAL(didSDCardStateChange(bool, bool)), + this , SLOT( onSDCardStateChange(bool, bool))); + connect(&_DeviceController , SIGNAL(didSDCardSpaceTooLow(quint8)), + this , SLOT( onSDCardSpaceTooLow(quint8))); connect(&_GuiController , SIGNAL(didExportLog()), this , SLOT( onExportLog())); @@ -132,6 +132,14 @@ connect(&_settingsWatcher, SIGNAL(finished ()), this , SLOT(onSettingsUpdate())); + + // Gui -> App + connect(&_GuiController , SIGNAL(didAttributeRequest(const DeviceBrightnessRequestData &)), + this , SLOT( onAttributeRequest(const DeviceBrightnessRequestData &))); + // App <- Dev + connect(&_DeviceController , SIGNAL(didAttributeResponse(const DeviceBrightnessResponseData &)), + this , SLOT( onAttributeResponse(const DeviceBrightnessResponseData &))); + // ---- Signal/Slots ADJUST_TRANSMT_MODEL_BRIDGE_CONNECTIONS(_GuiController ) ACTION_RECEIVE_MODEL_BRIDGE_CONNECTIONS(_MessageDispatcher) @@ -217,7 +225,7 @@ /*! * \brief ApplicationController::onUSBDriveMount - * \details This is the slot which connects to the _DriveWatcher didUSBDriveMount signal + * \details This is the slot which connects to the _DeviceController didUSBDriveMount signal * and notifies the other classes (GuiController) by emitting its signal didUSBDriveMount */ void ApplicationController::onUSBDriveMount () @@ -231,7 +239,7 @@ /*! * \brief ApplicationController::onUSBDriveRemove * \details This is the slot which connects to the _GuiController didUSBDriveUmount signal - * and notifies the other classes (DriveWatcher) by emitting its signal didUSBDriveUmount + * and notifies the other classes (DeviceController) by emitting its signal didUSBDriveUmount */ void ApplicationController::onUSBDriveUmount() { @@ -243,7 +251,7 @@ /*! * \brief ApplicationController::onUSBDriveRemove - * \details This is the slot which connects to the _DriveWatcher didUSBDriveRemove signal + * \details This is the slot which connects to the _DeviceController didUSBDriveRemove signal * and notifies the other classes (GuiController) by emitting its signal didUSBDriveRemove */ void ApplicationController::onUSBDriveRemove() @@ -256,7 +264,7 @@ /*! * \brief ApplicationController::onSDCardStateChange - * \details This is the slot which connects to the _DriveWatcher didSDCardStateChange signal + * \details This is the slot which connects to the _DeviceController didSDCardStateChange signal * and notifies the other classes (GuiController) by emitting its signal didSDCardStateChange * \param vIsReady - SDCard is Ready * \param vIsReadOnly - SDCard is ReadOnly @@ -272,7 +280,7 @@ /*! * \brief ApplicationController::onSDCardSpaceTooLow - * \details The handler slot for the didSDCardSpaceTooLow signal comes form DriveWatcher + * \details The handler slot for the didSDCardSpaceTooLow signal comes form DeviceController * \param vAvailablePercent - the minimum limit of available storage space */ void ApplicationController::onSDCardSpaceTooLow(quint8 vAvailablePercent) Index: sources/ApplicationController.h =================================================================== diff -u -rf688ed9f1c64a2603a6d10fbb090b257a43e1f6f -r61f16c988a159401c92730b4cbfca5085c77222f --- sources/ApplicationController.h (.../ApplicationController.h) (revision f688ed9f1c64a2603a6d10fbb090b257a43e1f6f) +++ sources/ApplicationController.h (.../ApplicationController.h) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -124,6 +124,18 @@ */ void didSettingsInit (QPrivateSignal); +signals : void didAttributeRequest (const DeviceBrightnessRequestData &); +private slots : void onAttributeRequest (const DeviceBrightnessRequestData &vData) { + qDebug() << "_ApplicationController" << __FUNCTION__; + emit didAttributeRequest(vData); // Gui -> App + } + +signals : void didAttributeResponse(const DeviceBrightnessResponseData &); +private slots : void onAttributeResponse(const DeviceBrightnessResponseData &vData) { + qDebug() << "_ApplicationController" << __FUNCTION__; + emit didAttributeResponse(vData); // Gui <- App + } + // ---- Signal/Slots ADJUST_TRANSMT_MODEL_BRIDGE_DEFINITIONS ACTION_RECEIVE_MODEL_BRIDGE_DEFINITIONS Index: sources/Threads.cpp =================================================================== diff -u -r7077e38c74db9cccb5496ffefcf8936c0916de76 -r61f16c988a159401c92730b4cbfca5085c77222f --- sources/Threads.cpp (.../Threads.cpp) (revision 7077e38c74db9cccb5496ffefcf8936c0916de76) +++ sources/Threads.cpp (.../Threads.cpp) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -32,7 +32,7 @@ QThread _CanFrame_Thread ; QThread _CanAcknow_Thread ; QThread _CanMessage_Thread ; - QThread _DriveWatcher_Thread ; + QThread _DeviceController_Thread; QThread _Logger_Thread ; QThread _Application_Thread ; QThread _Wifi_Thread ; @@ -90,7 +90,7 @@ quitThread(_CanFrame_Thread ); quitThread(_CanAcknow_Thread ); quitThread(_CanMessage_Thread ); - quitThread(_DriveWatcher_Thread ); + quitThread(_DeviceController_Thread ); quitThread(_Logger_Thread ); quitThread(_Wifi_Thread ); quitThread(_Application_Thread ); Index: sources/Threads.h =================================================================== diff -u -r7077e38c74db9cccb5496ffefcf8936c0916de76 -r61f16c988a159401c92730b4cbfca5085c77222f --- sources/Threads.h (.../Threads.h) (revision 7077e38c74db9cccb5496ffefcf8936c0916de76) +++ sources/Threads.h (.../Threads.h) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -19,13 +19,13 @@ #include namespace Threads { - extern QThread _CanFrame_Thread ; - extern QThread _CanAcknow_Thread ; - extern QThread _CanMessage_Thread ; - extern QThread _DriveWatcher_Thread ; - extern QThread _Logger_Thread ; - extern QThread _Application_Thread ; - extern QThread _Wifi_Thread ; + extern QThread _CanFrame_Thread ; + extern QThread _CanAcknow_Thread ; + extern QThread _CanMessage_Thread ; + extern QThread _DeviceController_Thread ; + extern QThread _Logger_Thread ; + extern QThread _Application_Thread ; + extern QThread _Wifi_Thread ; void registerTypes(); void quitThread (QThread &vThread); Index: sources/canbus/MessageDispatcher.cpp =================================================================== diff -u -rf734248435a849bf26d13f6e78d0ad4c1002d019 -r61f16c988a159401c92730b4cbfca5085c77222f --- sources/canbus/MessageDispatcher.cpp (.../MessageDispatcher.cpp) (revision f734248435a849bf26d13f6e78d0ad4c1002d019) +++ sources/canbus/MessageDispatcher.cpp (.../MessageDispatcher.cpp) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -45,7 +45,7 @@ if ( _init ) return false; _init = true; - // runs in DriveWatcher thread + // runs in the thread initConnections(); LOG_DEBUG("UI," + tr("%1 Initialized").arg(metaObject()->className())); @@ -789,6 +789,49 @@ return true; } +bool MessageDispatcher::checkAcknowReceived(const Message &vMessage, const char *src) +{ + GuiActionType mActionId = vMessage.actionId; + Sequence mSequence = vMessage.sequence; + bool ok = false; + if ( mActionId == GuiActionType::ID_Acknow ) { + ok = true; + #ifndef DISABLE_ACKNOW_CHECKIN_MESSAGE_LOG + LOG_EVENT(tr("%1,Ack Bak, Sq:%2").arg(src).arg(mSequence)); + #endif + #ifdef DEBUG_ACKBACK_HD_TO_UI + qDebug() << tr(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ HD AckBak : %1 %2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ").arg(mSequence).arg(vMessage.actionId); + #endif + emit didAcknowReceive(mSequence); + } + return ok; +} + +bool MessageDispatcher::checkAcknowTransmit(const Message &vMessage, const char *src) +{ + bool ok = false; + GuiActionType mActionId = vMessage.actionId; + Sequence mSequence = vMessage.sequence; + if (mSequence < 0) { + ok = true; + #ifndef DISABLE_ACKNOW_CHECKIN_MESSAGE_LOG + LOG_EVENT(tr("%1,Ack Req, Sq:%2, ID:%3").arg(src).arg(mSequence).arg(Format::toHexString(mActionId))); + #endif + #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::ID_Acknow, {}, -mSequence); + #ifndef DISABLE_ACKNOW_CHECKIN_MESSAGE_LOG + LOG_EVENT(tr("UI,Ack Bak, Sq:%1").arg(-mSequence)); + #endif + #ifdef DEBUG_ACKBACK_HD_TO_UI + qDebug() << tr(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ UI AckBak : %1 %2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ").arg(-mSequence).arg(vMessage.actionId); + #endif + } + return ok; +} + /*! * \brief MessageDispatcher::interpretMessage * \details Calls the MessageInterpreter interpretMessage method @@ -801,47 +844,19 @@ { bool ok = false; QVariantList mData; - Sequence mSequence = vMessage.sequence; - Can_Source src = MessageInterpreter::identifySource(vMessage.can_id); - QString ids = (src == Can_Source::eCan_HD) ? "HD" : ((src == Can_Source::eCan_DG) ? "DG" : "XX"); + Can_Source srcID = MessageInterpreter::identifySource(vMessage.can_id); + const char *srcText = (srcID == Can_Source::eCan_HD) ? "HD" : ((srcID == Can_Source::eCan_DG) ? "DG" : "XX"); + if ( ! checkAcknowReceived(vMessage, srcText) ) { // check if the message was an acknowledge. + checkAcknowTransmit(vMessage, srcText); // then if needs acknow send it immediately. + } + // coco begin validated: Has been validated manually. If MessageInterpreter::interpretMessage fails, this also returns false - if (_interpreter.interpretMessage(vMessage, mData)) { - // coco end + if ( _interpreter.interpretMessage( vMessage, mData ) ) { ok = true; - GuiActionType mActionId = vMessage.actionId; - switch (mActionId) { - case GuiActionType::ID_Acknow: - #ifndef DISABLE_ACKNOW_CHECKIN_MESSAGE_LOG - LOG_EVENT(tr("%1,Ack Bak, Sq:%2").arg(ids).arg(mSequence)); - #endif - #ifdef DEBUG_ACKBACK_HD_TO_UI - qDebug() << tr(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ HD AckBak : %1 %2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ").arg(mSequence).arg(vMessage.actionId); - #endif - emit didAcknowReceive(mSequence); - break; - - default: - if (mSequence < 0) { - #ifndef DISABLE_ACKNOW_CHECKIN_MESSAGE_LOG - LOG_EVENT(tr("%1,Ack Req, Sq:%2, ID:%3").arg(ids).arg(mSequence).arg(Format::toHexString(mActionId))); - #endif - #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::ID_Acknow, {}, -mSequence); - #ifndef DISABLE_ACKNOW_CHECKIN_MESSAGE_LOG - LOG_EVENT(tr("UI,Ack Bak, Sq:%1").arg(-mSequence)); - #endif - #ifdef DEBUG_ACKBACK_HD_TO_UI - qDebug() << tr(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ UI AckBak : %1 %2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ").arg(-mSequence).arg(vMessage.actionId); - #endif - } - emit didActionReceive(mActionId, mData); - break; - - } + emit didActionReceive(vMessage.actionId, mData); } + // coco end + _messageList[vMessage.can_id].removeLast(); return ok; } Index: sources/canbus/MessageDispatcher.h =================================================================== diff -u -ra89b5249df072be403141463d7d88728b66a848e -r61f16c988a159401c92730b4cbfca5085c77222f --- sources/canbus/MessageDispatcher.h (.../MessageDispatcher.h) (revision a89b5249df072be403141463d7d88728b66a848e) +++ sources/canbus/MessageDispatcher.h (.../MessageDispatcher.h) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -180,6 +180,9 @@ Sequence txCount(); Sequence rxCount(); + bool checkAcknowReceived(const Message &vMessage, const char *src); + bool checkAcknowTransmit(const Message &vMessage, const char *src); + signals: /*! * \brief didActionReceive Index: sources/device/DeviceController.cpp =================================================================== diff -u --- sources/device/DeviceController.cpp (revision 0) +++ sources/device/DeviceController.cpp (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -0,0 +1,475 @@ +/*! + * + * 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 DeviceController.cpp + * \author (last) Behrouz NematiPour + * \date (last) 29-May-2021 + * \author (original) Behrouz NematiPour + * \date (original) 17-Jul-2020 + * + */ +#include "DeviceController.h" + +// Linux +#include +#include + +// Qt +#include +#include +#include + +// Project +#include "StorageGlobals.h" +#include "Logger.h" +#include "ApplicationController.h" +#include "FileHandler.h" + +// namespace +using namespace Storage; + +/*! + * \brief DeviceController::DeviceController + * \details Constructor + * \param parent - QObject parent owner object. + * Qt handles the children destruction by their parent objects life-cycle. + */ +DeviceController::DeviceController(QObject *parent) : QObject(parent) { + _processBrightness .setParent(this); +} + +/*! + * \brief DeviceController::init + * \details Initializes the class by setting the connections and starting the timer + * \return False if it has been called before. + */ +bool DeviceController::init() +{ + if ( _init ) return false; + _init = true; + + // runs in DeviceController thread + initConnections(); + startTimer(_interval); + + return true; +} + +/*! + * \brief DeviceController::init + * \details Initialized the Class by calling the init() method first + * And initializes the thread vThread by calling initThread + * on success init(). + * \param vThread - the thread + * \return returns the return value of the init() method + */ +bool DeviceController::init(QThread &vThread) +{ + if ( ! init() ) return false; + initThread(vThread); + return true; +} + +/*! + * \brief DeviceController::quit + * \details quits the class + * Calls quitThread + */ +void DeviceController::quit() +{ + // coco begin validated: Application termination is not correctly done in coco!!! + // it has been tested and works perfectly fine in normal run. + quitThread(); // validated +} +// coco end + +void DeviceController::onRemoveLogs(bool vInProgress) +{ + // coco begin validated: The log in progress requires user interaction + // it has been tested and works fine in normal run. + _pauseSpaceCheck = vInProgress; +} +// coco end + +/*! + * \brief DeviceController::initConnections + * \details Initializes the required signal/slot connection between this class and other objects + * to be able to communicate. + */ +void DeviceController::initConnections() +{ + connect(&_ApplicationController, SIGNAL(didUSBDriveUmount()), + this , SLOT( onUSBDriveUmount())); + connect(&_Logger , SIGNAL(didRemoveLogs(bool)), + this , SLOT( onRemoveLogs(bool))); + + + + // App -> Dev + connect(&_ApplicationController , SIGNAL(didAttributeRequest(const DeviceBrightnessRequestData &)), + this , SLOT( onAttributeRequest(const DeviceBrightnessRequestData &))); + connect(&_processBrightness , SIGNAL( finished(int)), + this, SLOT(onProcessBrightnessFinished(int))); +} + +/*! + * \brief ApplicationController::initThread + * \details Moves this object into the thread vThread. + * And checks that this method is called from main thread. + * Also connects quitThread to application aboutToQuit. + * \param vThread - the thread + */ +void DeviceController::initThread(QThread &vThread) +{ + // runs in main thread + Q_ASSERT_X(QThread::currentThread() == qApp->thread() , __func__, "The Class initialization must be done in Main Thread" ); + _thread = &vThread; + _thread->setObjectName(QString("%1_Thread").arg(metaObject()->className())); + connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(quit())); + _thread->start(); + moveToThread(_thread); +} + +/*! + * \brief DeviceController::quitThread + * \details Moves this object to main thread to be handled by QApplicaiton + * And to be destroyed there. + */ +void DeviceController::quitThread() +{ + // coco begin validated: Application termination is not correctly done in coco!!! + // it has been tested and works perfectly fine in normal run. + + if ( ! _thread ) return; + + // runs in thread + moveToThread(qApp->thread()); // validated +} +// coco end + +/*! + * \brief DeviceController::usbSeek + * \details Tries to look for the available USB devices + * Starts from sda1 to sdz1. + * \note will only look for the first partition if there is any + * \param vDevice - Found device (/dev/sda1) + * \return true if a device found + */ +bool DeviceController::usbSeek(QString &vDevice) +{ + // coco begin validated: Needed User Interaction so tested manually + // This function cannot be tested on any device other than target + // because only on device the usb is /dev/sdX# and others are mmblk___ + // but on VM and normal Linuxes all drives are /dev/sdX# and cannot be identified as USB. + // And the difference between how USB is detected and sd-card is that + // for the USB we need to look into /dev/sdX# + // but for the sd-card we look for the mounted path which is much easier. + // That's why indication of the sd-card is more accurate than USB at least on VM. + QString dev = "/dev/sd"; + QString device = ""; + for (char a = 'a'; a <= 'z'; a++) { + device = dev + a + '1'; + if (QFileInfo::exists(device)) { + vDevice = device; + return true; // application is deciding on the first existing drive + } + } + vDevice = device; + return false; + // coco end +} + +/*! + * \brief DeviceController::driveSpaceCheck + * \param vPath - Device mount point + * \param vTotalBytes - Total volume size in bytes + * \param vAvailableBytes - Size (in bytes) available for the current user + * \param vPercent - The percentage of available space + * \return - The drive mounted and ready + * \note if device ejected manually system assumes it's still ready. + */ +bool DeviceController::driveSpaceCheck(const QString &vPath, qint64 &vTotalBytes, qint64 &vAvailableBytes, bool *vIsReadOnly) +{ + // coco begin validated: Needed User Interaction to make the device not ready so tested manually + bool isReadOnly; + if (! FileHandler::isMounted(vPath, &isReadOnly)) return false; + if (vIsReadOnly) *vIsReadOnly = isReadOnly; + QStorageInfo storage(vPath); + bool isReady = storage.isReady(); + if (isReady) { + vTotalBytes = storage.bytesTotal(); + vAvailableBytes = storage.bytesAvailable(); + } + return isReady; +} +// coco end + +/*! + * \brief DeviceController::timerEvent + * \details This event handler has been re-implemented in here + * to receive timer events for the object + * for the timer which has been set to _checkInterval + * Runs the usbCheck on interval + */ +void DeviceController::timerEvent(QTimerEvent *) +{ + usbCheck(); + sdcardSpaceCheck(); +} + +/*! + * \brief DeviceController::usbCheck + * \details Runs usbSeek to mount or umount or remove it + * regarding the state it's in. + */ +void DeviceController::usbCheck() +{ + // coco begin validated: Needed User Interaction so tested manually + QString device = ""; + if (usbSeek(device)) { + if (! _umounted ) { + usbMount(device); + } else { + usbUmount(USB_Mount_Point); + } + } else { + if ( ! _removed ) { + usbRemove(); + } + } + // coco end +} + +/*! + * \brief DeviceController::sdcardFreeSpaceCheck + * \details Checks the drivers for available free space. + */ +void DeviceController::sdcardSpaceCheck() +{ + // coco begin validated: Needed User Interaction so tested manually + + // Old Info ; // Current info + static bool mOIsReady ; bool mCIsReady ; + static bool mOIsReadOnly; bool mCIsReadOnly ; + static qint64 mOTotal ; qint64 mCTotal ; + static qint64 mOAvailable ; qint64 mCAvailable ; + + mCIsReady = driveSpaceCheck(Storage::SDCard_Base_Path_Name, mCTotal, mCAvailable, &mCIsReadOnly); + /// DEBUG: qDebug() << " ===== " << Storage::SDCard_Base_Path_Name << mCIsReady; + if (mOIsReadOnly != mCIsReadOnly || mOIsReady != mCIsReady) { + mOIsReadOnly = mCIsReadOnly; + emit didSDCardStateChange(mCIsReady, mCIsReadOnly); + } + + if (! mCIsReady ) { + mOIsReady = mCIsReady; + mOTotal = 0; + mOAvailable = 0; + return; + } + + quint8 mPercent = mCTotal ? ((100 * mCAvailable) / mCTotal) : 0; + if (mPercent < _minRequiredAvailableSpacePercent) { + LOG_DEBUG(QString("SD-CARD space lower than %1%").arg(_minRequiredAvailableSpacePercent)); + emit didSDCardSpaceChange(mCIsReady, mCTotal, mCAvailable, mPercent); + emit didSDCardSpaceTooLow(_minRequiredAvailableSpacePercent); + } + + /// DEBUG: qDebug() << Storage::SDCard_Base_Path_Name << mCIsReady << mOTotal << mCTotal << (mOTotal == mCTotal) << mOAvailable << mCAvailable << (mOAvailable == mCAvailable) << mPercent << mCIsReadOnly; + + if (mOTotal == mCTotal && + mOAvailable == mCAvailable) { + return; + } + + mOIsReady = mCIsReady ; + mOTotal = mCTotal ; + mOAvailable = mCAvailable ; + if (_pauseSpaceCheck) return; + emit didSDCardSpaceChange(mCIsReady, mCTotal, mCAvailable, mPercent); + /// DEBUG: qDebug() << Storage::SDCard_Base_Path_Name << mCIsReady << mCTotal << mCAvailable << mPercent ; +} +// coco end + +/*! + * \brief DeviceController::usbError + * \details Logs any error which has been happened + * On USB device vDevice + * \note When this method has been called error number will be read from errno variable, + * Which has been set by umount or mount. + * \param vDevice + */ +void DeviceController::usbError(const QString &vDevice) +{ + // coco begin validated: This needs user interaction to plug-in/out the USB device + // has been tested manually + QString error; + static QString lastError; + switch (errno) { + case EBUSY: + error = tr("%1 - Device or resource busy (%2)").arg(errno).arg(vDevice); + _mounted = true; + break; + + default: + error = tr("%1 - %2 (%3 , %4)").arg(errno).arg(strerror(errno)).arg(vDevice).arg(USB_Mount_Point); + break; + + } + if (error != lastError) { + LOG_DEBUG(error); + lastError = error; + } +} +// coco end + +/*! + * \brief DeviceController::onUSBDriveUmount + * \details This is the slot connected to the _ApplicationController's didUSBDriveUmount SIGNAL, + * To notify the USB drive detach. + */ +void DeviceController::onUSBDriveUmount() +{ + // coco begin validated: This needs user interaction to plug-in/out the USB device + // has been tested manually + _umounted = true; +} +// coco end + +/*! + * \brief DeviceController::usbMount + * \details Mounts the USB device vDevice + * \note Emits didUSBDriveMount signal + * \param vDevice - USB device to be mounted (e.g. /dev/sda1) + * \return true on successful mount + */ +bool DeviceController::usbMount(const QString &vDevice) +{ + // coco begin validated: This needs user interaction to plug-in the USB device + // has been tested manually + bool ok; + _usbDrive = vDevice.toLatin1().constData(); + ok = ::mount(_usbDrive, USB_Mount_Point, USB_File_System,MS_SYNCHRONOUS , "") == 0; + if (ok) { + _mounted = true; + _removed = false; + LOG_DEBUG(QString("USB flash drive %1 has been mounted on %2").arg(vDevice).arg(USB_Mount_Point)); + emit didUSBDriveMount(); + } else { + usbError(vDevice); + } + return ok; +} +// coco end + +/*! + * \brief DeviceController::usbUmount + * \details Unmounts the USB device vDevice + * \note Emits didUSBDriveUmount signal + * \param vDevice - USB device to be unmounted (e.g. /dev/sda1) + * \return true on successful unmount + */ +bool DeviceController::usbUmount(const QString &vDevice) +{ + // coco begin validated: This needs user interaction to plug-out the USB device + // has been tested manually + bool ok; + ok = ::umount(vDevice.toLatin1().constData()) == 0; + if (ok) { + _mounted = false; + LOG_DEBUG(QString("USB drive %2 unmounted").arg(vDevice)); + emit didUSBDriveUmount(); + } else { + // the error is irrelevant, commented out for now + //usbError(vDevice); + } + return ok; +} +// coco end + +/*! + * \brief DeviceController::usbRemove + * \details Removed the USB mount point + * So next time it is not mounted as next device. + * \note Emits didUSBDriveRemove signal + */ +void DeviceController::usbRemove() +{ + // coco begin validated: This needs user interaction to plug-out the USB device + // has been tested manually + usbUmount(USB_Mount_Point); + _umounted = false; + _removed = true; + LOG_DEBUG("USB drive removed"); + emit didUSBDriveRemove(); +} +// coco end + +/*! + * \brief DeviceController::checkScript + * \details Prepends the script folder path to the script name and checks if the script exists and is executable. + * \param vScript : The script name with full path which will be set in this parameter passed argument. + * \param vShellScript : The shell script name + * \return true if succeeds and false otherwise */ +bool DeviceController::checkScript(QString &vScript, const QString &vShellScript) +{ + vScript = _scriptsFolder + vShellScript; + QFileInfo info(vScript); + if ( ! info.exists () ) { LOG_DEBUG(QString("script %1 does not exist." ).arg(vScript)); return false; } + if ( ! info.isExecutable() ) { LOG_DEBUG(QString("script %1 is not executable." ).arg(vScript)); return false; } + return true; +} + +/*! + * \brief DeviceController::doBrightness + * \details Sets the brightness level + * \param vBrightness + */ +void DeviceController::onAttributeRequest(const DeviceBrightnessRequestData &vData) +{ + qDebug() << "_DeviceController" << __FUNCTION__; + // check that script exists. + QString script; if ( ! checkScript(script, Brightness_Set ) ) return; + // extract the required data + quint8 mBrightnessPercent = vData.mBrightnessPercent; + // check if the process is not running + if ( _processBrightness.state() != QProcess::NotRunning ) return; + // check the data is valid + if ( _brightness_min > mBrightnessPercent || mBrightnessPercent > _brightness_max ) { + LOG_DEBUG(QString("Out of range brightness [%1]").arg(mBrightnessPercent)); + return; + } + QList _allowableValues; + for ( quint8 i = _brightness_min; i <= _brightness_max; i += _brightness_res ) + _allowableValues += i; + if ( ! _allowableValues.contains(mBrightnessPercent) ) { + LOG_DEBUG(QString("Incorrect brightness value [%1]").arg(mBrightnessPercent)); + return; + } + // keep the requested data + _brightness_val = mBrightnessPercent / 10; // convert the percent to device value + // run the process + _processBrightness.start(script, QStringList() << QString::number(_brightness_val)); +} + +/*! + * \brief DeviceController::onProcessBrightnessFinished + * \details Called when the process to set the brightness has finished + * \param vExitCode (int) the exit code + */ +void DeviceController::onProcessBrightnessFinished(int vExitCode) +{ + DeviceBrightnessResponseData data; + if ( vExitCode != 0 ) { + LOG_DEBUG(QString("Failed Brightness [%1]").arg(vExitCode)); + data.mAccepted = false ; + data.mReason = vExitCode ; + return; + } + data.mBrightnessPercent = _brightness_val * 10; // convert the device value to percent + emit didAttributeResponse(data); +} Index: sources/device/DeviceController.h =================================================================== diff -u --- sources/device/DeviceController.h (revision 0) +++ sources/device/DeviceController.h (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -0,0 +1,171 @@ +/*! + * + * 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 DeviceController.h + * \author (last) Behrouz NematiPour + * \date (last) 29-May-2021 + * \author (original) Behrouz NematiPour + * \date (original) 17-Jul-2020 + * + */ +#pragma once + +// Qt +#include +#include + +// Project +#include "main.h" // Doxygen : don't remove +#include "Threads.h" +#include "DeviceModels.h" + +// Define +#define _DeviceController Storage::DeviceController::I() + +// forward declarations +class tst_initializations; + +namespace Storage { + +/*! + * \brief The DeviceController class + * \details This class is the device controller meaning all the device interactions and settings like Volume(Device), Brightness, WiFi, Date, Time, etc + * has to be done through this controller and it's dedicated thread and by using the QProcess(es) which is a call to the administrative shell scripts. + * It also is watching for the USB and SD-Card drives in Linux file system. + * It has the interval of 1000 ms and will look if any device between /dev/sda1 to /dev/sdz1 exists then will mount it in /media/usb, + * and does check if the SD-Card has been mounted under /media/sdcard, + * but for SD-Card doesn't try to mount it and it has to be mounted prior to UI Application start + * and that's because from UI Application perspective it is not a removable/hot-plug device (although physically it is). + * This class works in its own thread and will send notification by emitting signals about the USB device status + * which are Mounted, Unmounted, Removed + * and SD-Card space conditions changes. + * \note : - 'Removed' is when no USB device present. + * - Only brightness is using this class currently + */ +class DeviceController : public QObject +{ + Q_OBJECT + + // Singleton + SINGLETON(DeviceController) + + // friends + friend class ::tst_initializations; + + bool _mounted = false; + bool _umounted = false; + bool _removed = false; + const char *_usbDrive = ""; + const int _interval = 1000; // in ms + + const qint8 _minRequiredAvailableSpacePercent = 10; + + QThread *_thread = nullptr; + bool _init = false; + + bool _pauseSpaceCheck = false; + + const QString _scriptsFolder = Storage::Scripts_Path_Name; + + const quint8 _brightness_min = 20 ; + const quint8 _brightness_max = 100 ; + const quint8 _brightness_res = 20 ; + quint8 _brightness_val = 100 ; + QProcess _processBrightness ; + +public slots : void onAttributeRequest (const DeviceBrightnessRequestData &vData); +signals : void didAttributeResponse (const DeviceBrightnessResponseData &); +private slots : void onProcessBrightnessFinished(int vExitCode); + +public slots: + bool init(); + bool init(QThread &vThread); + +private slots: + void quit(); + void onRemoveLogs(bool vInProgress); + + +protected: + void timerEvent(QTimerEvent *) override; + +private: + void initConnections(); + + void initThread(QThread &vThread); + void quitThread(); + + bool usbSeek(QString &vDevice); + + bool driveSpaceCheck(const QString &vPath, qint64 &vTotalBytes, qint64 &vAvailableBytes, bool *vIsReadOnly = nullptr); + + bool checkScript(QString &vScript, const QString &vShellScript); +signals: + /*! + * \brief didUSBDriveMount + * \details notifies UI when USB device is available and has been mounted. + */ + void didUSBDriveMount (); + + /*! + * \brief didUSBDriveUmount + * \details notifies USB watcher on UI(user) request for USB umount. + */ + void didUSBDriveUmount(); + + /*! + * \brief didUSBDriveRemove + * \details notifies UI when USB device has been removed(not exists). + */ + void didUSBDriveRemove(); + + /*! + * \brief didSDCardFreeSpaceChange + * \param vReady - Device is mounted and ready + * \note if device ejected manually system assumes it's still ready. + * \param vTotal - Returns the total volume size in bytes. + * Returns -1 if QStorageInfo object is not valid + * \param vAvailable - Returns the size (in bytes) available for the current user. + * It returns the total size available if the user is the root user or a system administrator. + * This size can be less than or equal to the free size returned by bytesFree() function. + * Returns -1 if QStorageInfo object is not valid. + * \param vPercent - The percentage of available space. + * \note Will emitted if only one of the publishing parameter changes. + */ + void didSDCardSpaceChange(bool vReady, qint64 vTotal, qint64 vAvailable, quint8 vPercent); + + /*! + * \brief didSDCardStateChange + * \details If SDCard state changes like removed or is not present this signal will emit. + */ + void didSDCardStateChange(bool vIsReady, bool vIsReadOnly); + + /*! + * \brief didSDCardSpaceTooLow + * \details this signal will emit ones the available space left on the SD-Card + * is less than minimum required percentage defined in _minRequiredAvailableSpacePercent. + * \param vAvailablePercent + */ + void didSDCardSpaceTooLow(quint8 vAvailablePercent); + + void didActionReceive( const DeviceBrightnessResponseData &vBrightness ); + +private slots: + // ----- USB + void usbCheck(); + + bool usbMount (const QString &vDevice); + bool usbUmount(const QString &vDevice); + void usbRemove(); + void usbError (const QString &vDevice); + + void onUSBDriveUmount(); + + // ----- SDCard + void sdcardSpaceCheck(); +}; +} Index: sources/device/DeviceGlobals.h =================================================================== diff -u --- sources/device/DeviceGlobals.h (revision 0) +++ sources/device/DeviceGlobals.h (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -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 VDeviceGlobals.h + * \author (last) Behrouz NematiPour + * \date (last) 01-Jun-2021 + * \author (original) Behrouz NematiPour + * \date (original) 01-Jun-2021 + * + */ +#pragma once + +// Qt +#include + +#define ATTRIBUTE( vTYPE, vATTRIBUTE, vDEFAULT ) \ + private: \ + /*! the private property member variable */ \ + vTYPE _##vATTRIBUTE = vDEFAULT; \ + /*! the property definition */ \ + Q_PROPERTY( vTYPE vATTRIBUTE \ + READ vATTRIBUTE \ + WRITE vATTRIBUTE \ + NOTIFY vATTRIBUTE##Changed) \ + /*! the READ/getter method */ \ + vTYPE vATTRIBUTE ( ) { \ + return _##vATTRIBUTE; \ + } \ + /*! the WRITE method */ \ + void vATTRIBUTE (const vTYPE & v##vATTRIBUTE ) { \ + vATTRIBUTE ( v##vATTRIBUTE, true ); \ + } \ + /*! the UPDATE method */ \ + void _##vATTRIBUTE##_ (const vTYPE & v##vATTRIBUTE ) { \ + vATTRIBUTE ( v##vATTRIBUTE,false ); \ + } \ + /*! the setter method */ \ + void vATTRIBUTE (const vTYPE & v##vATTRIBUTE, \ + bool vIsRequest ) { \ + if ( _##vATTRIBUTE != v##vATTRIBUTE ) { \ + _##vATTRIBUTE = v##vATTRIBUTE ; \ + emit vATTRIBUTE##Changed ( _##vATTRIBUTE ); \ + } \ + if ( vIsRequest ) \ + vATTRIBUTE##Request ( v##vATTRIBUTE ); \ + } \ + Q_SIGNALS: /*! the signals for property bindings(Changed) and communications */ \ + void vATTRIBUTE##Changed (const vTYPE & v##vATTRIBUTE ); \ + private : /*! the function is called once the property is set in qml as request */ \ + void vATTRIBUTE##Request (const vTYPE & v##vATTRIBUTE ); \ + + //private slots: + // void on##vATTRIBUTE##Response(const vTYPE & v##vATTRIBUTE ); + Index: sources/device/DeviceModels.cpp =================================================================== diff -u --- sources/device/DeviceModels.cpp (revision 0) +++ sources/device/DeviceModels.cpp (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -0,0 +1,26 @@ +/*! + * + * 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 MDeviceResponseBase.cpp + * \author (last) Behrouz NematiPour + * \date (last) 01-Jun-2021 + * \author (original) Behrouz NematiPour + * \date (original) 01-Jun-2021 + * + */ +#include "DeviceModels.h" + +using namespace Model; + +/*! + * \brief MAdjustChemicalConfirmResponse::data + * \details Provides model's Data from the received messages data values + * \return Data + */ +DeviceBrightnessResponseData MDeviceBrightnessResponse::data() const { + return _data; +} Index: sources/device/DeviceModels.h =================================================================== diff -u --- sources/device/DeviceModels.h (revision 0) +++ sources/device/DeviceModels.h (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -0,0 +1,105 @@ +/*! + * + * 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 DeviceModels.h + * \author (last) Behrouz NematiPour + * \date (last) 01-Jun-2021 + * \author (original) Behrouz NematiPour + * \date (original) 01-Jun-2021 + * + */ +#pragma once + +// Qt +#include + +// Project +#include "MAbstract.h" +#include "types.h" + + +// forward declarations +class tst_models; + +namespace Model { + +/*! + * \brief The MDeviceRequestBase class + * \details The base class of the all devices requests models + */ +class MDeviceRequestBase { +protected: + /*! + * \brief toString + * \details the global toString function for all the request message models + * which is mainly used for logging and debugging. + * \param vStringPrefix - a prefix string to be inserted after senderID (UI) and parameter values list. + * This is comma separated. + * \param vParameters - list of parameter values of the model as a comma separated string. + * \return QString + */ + static QString toString (const QString &vStringPrefix, const QVariant &vParameters) { + QString senderID = "UI,"; + return QString(senderID + vStringPrefix + "," + vParameters.toStringList().join(',')); + } +}; + +/*! + * \brief The MDeviceResponseBase class + * \details The base class of the all devices responses models + */ +class MDeviceResponseBase : public MAbstract { + + // friends + friend class ::tst_models; + + QVariantList parameters() const override; + +public: + + Type_Enum typeText () const override { return Type_Enum::eEvent ; } + Unit_Enum unitText () const override { return Unit_Enum::eDV ; } + QString infoText () const override { return QString("DeviceBase") ; } + + struct Data { + bool mAccepted = true; /*!< Accepted value of type quint32 extracted out */ + quint32 mReason = 0 ; /*!< Reason value of type quint32 extracted out */ + }; + + MDeviceResponseBase () { } + + bool fromByteArray (const QByteArray &, int * = nullptr) override { return false; /* no conversion needed */ } +}; + + +// ------------------------------------------------------------------ + +class MDeviceBrightnessResponse : MDeviceResponseBase { +public: + struct Data : MDeviceResponseBase::Data { + quint8 mBrightnessPercent = 0; + } _data; + + QString infoText () const override { return QString("DeviceBrightness") ; } + Data data () const ; +}; + +class MDeviceBrightnessRequest : public MDeviceRequestBase { +public: + struct Data { + quint8 mBrightnessPercent = 100; + } _data; + + QString toString() { + return MDeviceRequestBase::toString("DeviceBrightness", { _data.mBrightnessPercent }); + } +}; + +} + +typedef Model::MDeviceBrightnessRequest ::Data DeviceBrightnessRequestData; +typedef Model::MDeviceBrightnessResponse::Data DeviceBrightnessResponseData; Index: sources/device/DeviceView.cpp =================================================================== diff -u --- sources/device/DeviceView.cpp (revision 0) +++ sources/device/DeviceView.cpp (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -0,0 +1,79 @@ +/*! + * + * 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 VDevice.cpp + * \author (last) Behrouz NematiPour + * \date (last) 16-Oct-2020 + * \author (original) Behrouz NematiPour + * \date (original) 23-Aug-2020 + * + */ +#include "DeviceView.h" + +// Qt + +// Project +#include "ApplicationController.h" +#include "GuiController.h" +#include "GuiGlobals.h" + + +// // defines +// #define CONNECT_GUI( vATTRIBUTE ) +// connect(_GuiController , SIGNAL( didAttributeRespond(Device##vATTRIBUTE##RespondData)), +// this , SLOT( onAttributeRespond(Device##vATTRIBUTE##RespondData))); +// connect(this , SIGNAL( didAttributeRequest(Device##vATTRIBUTE##RequestData)), +// _GuiController , SLOT( doAttributeRespond(Device##vATTRIBUTE##RequestData))); +// + +VIEW_DEF_CLASS(VDevice) + +void VDevice::initConnections() +{ + // to convert the value to the model and emit the signal to go to the controller (Qml -> View) + connect(this , SIGNAL(didAttributeRequest(const DeviceBrightnessRequestData &)), + &_GuiController , SLOT( doAttributeRequest(const DeviceBrightnessRequestData &))); + + // View <- Gui + connect(&_GuiController , SIGNAL(didAttributeResponse(const DeviceBrightnessResponseData &)), + this , SLOT( onAttributeResponse(const DeviceBrightnessResponseData &))); +} + +// developer implementation section +void VDevice::brightnessRequest(const quint8 &vValue) { + qDebug() << "HERE Request" << vValue; + DeviceBrightnessRequestData data; + data.mBrightnessPercent = vValue; + emit didAttributeRequest(data); +} + +/*! + * \brief VDevice::onAttributeResponse + * \param vData + * + * HERE Request 100 + * _GuiController doAttributeRequest + * _ApplicationController onAttributeRequest + * _DeviceController onAttributeRequest + * _ApplicationController onAttributeResponse + * _GuiController onAttributeResponse + * HERE Response 100 + * + */ +void VDevice::onAttributeResponse(const DeviceBrightnessResponseData &vData) { + qDebug() << "HERE Response" << vData.mBrightnessPercent; + if ( vData.mAccepted ) { + _brightness_(vData.mBrightnessPercent); + } + + accepted(vData.mAccepted); + reason (vData.mReason ); + + // has to be the last one + response(true); +} + Index: sources/device/DeviceView.h =================================================================== diff -u --- sources/device/DeviceView.h (revision 0) +++ sources/device/DeviceView.h (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -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 DeviceView.h + * \author (last) Behrouz NematiPour + * \date (last) 01-Jun-2021 + * \author (original) Behrouz NematiPour + * \date (original) 01-Jun-2021 + * + */ +#pragma once + +// Qt +#include + +// Project +#include "main.h" // Doxygen : don't remove +#include "VView.h" +#include "DeviceGlobals.h" +#include "DeviceModels.h" + +// define +#define _VDevice View::VDevice::I() + + +// namespace +namespace View { + +/*! + * \brief The VDevice class + * \details The device view to interact with the UI. + * + */ +class VDevice : public QObject { + Q_OBJECT + + PROPERTY( bool , accepted , 0) + TRIGGER ( quint32 , reason , 0) + TRIGGER ( bool , response , true) + + ATTRIBUTE ( quint8 , brightness , 0 ) + + VIEW_DEC_CLASS(VDevice) + +signals: void didAttributeRequest (const DeviceBrightnessRequestData &vData); +private slots: void onAttributeResponse(const DeviceBrightnessResponseData &vData); + +}; +} Index: sources/gui/GuiController.cpp =================================================================== diff -u -r6816b783f50e08267aa016d64350bc020080d901 -r61f16c988a159401c92730b4cbfca5085c77222f --- sources/gui/GuiController.cpp (.../GuiController.cpp) (revision 6816b783f50e08267aa016d64350bc020080d901) +++ sources/gui/GuiController.cpp (.../GuiController.cpp) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -95,6 +95,10 @@ connect(&_ApplicationController, SIGNAL(didFailedTransmit(Sequence)), this , SLOT( onFailedTransmit(Sequence))); + // Gui <- App + connect(&_ApplicationController, SIGNAL(didAttributeResponse(const DeviceBrightnessResponseData &)), + this , SLOT( onAttributeResponse(const DeviceBrightnessResponseData &))); + // ---- Signal/Slots ACTION_RECEIVE_MODEL_BRIDGE_CONNECTIONS(_ApplicationController) } Index: sources/gui/GuiController.h =================================================================== diff -u -ra3030123e885fb9f22dea5839c4e988896a257e4 -r61f16c988a159401c92730b4cbfca5085c77222f --- sources/gui/GuiController.h (.../GuiController.h) (revision a3030123e885fb9f22dea5839c4e988896a257e4) +++ sources/gui/GuiController.h (.../GuiController.h) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -100,6 +100,18 @@ void didExportLog(); void didExport (); +signals : void didAttributeRequest (const DeviceBrightnessRequestData &); +public slots : void doAttributeRequest (const DeviceBrightnessRequestData &vData) { + qDebug() << "_GuiController" << __FUNCTION__; + emit didAttributeRequest(vData); // Gui -> App + } + +signals : void didAttributeResponse(const DeviceBrightnessResponseData &); +private slots : void onAttributeResponse(const DeviceBrightnessResponseData &vData) { + qDebug() << "_GuiController" << __FUNCTION__; + emit didAttributeResponse(vData); // Gui <- App + } + // ---- Signal/Slots ADJUST_TRANSMT_MODEL_BRIDGE_DEFINITIONS_PUBLIC ACTION_RECEIVE_MODEL_BRIDGE_DEFINITIONS Index: sources/gui/GuiGlobals.cpp =================================================================== diff -u -r376859852f4d1a07263c44524aec347db29e0133 -r61f16c988a159401c92730b4cbfca5085c77222f --- sources/gui/GuiGlobals.cpp (.../GuiGlobals.cpp) (revision 376859852f4d1a07263c44524aec347db29e0133) +++ sources/gui/GuiGlobals.cpp (.../GuiGlobals.cpp) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -22,6 +22,9 @@ #include "GuiView.h" #include "VEventSpy.h" +// Device +#include "DeviceView.h" + // Project #include "VView.h" // Settings Index: sources/gui/GuiView.cpp =================================================================== diff -u -r2216ac6ac7f77437a7c29ac8b4043be01bc4609e -r61f16c988a159401c92730b4cbfca5085c77222f --- sources/gui/GuiView.cpp (.../GuiView.cpp) (revision 2216ac6ac7f77437a7c29ac8b4043be01bc4609e) +++ sources/gui/GuiView.cpp (.../GuiView.cpp) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -16,7 +16,7 @@ // Project #include "GuiView.h" #include "GuiController.h" -#include "DriveWatcher.h" +#include "DeviceController.h" // namespace using namespace Gui; @@ -63,8 +63,8 @@ this , SLOT( onSDCardStateChange(bool,bool))); /// TEST: Test the space on GUI, not sure if we keep it. - connect(&_DriveWatcher, SIGNAL( didSDCardSpaceChange(bool, qint64, qint64, quint8)), - this , SLOT( onSDCardSpaceChange(bool, qint64, qint64, quint8))); + connect(&_DeviceController, SIGNAL( didSDCardSpaceChange(bool, qint64, qint64, quint8)), + this , SLOT( onSDCardSpaceChange(bool, qint64, qint64, quint8))); connect(&_GuiController, SIGNAL(didExport()), this , SLOT( onExport())); Index: sources/gui/GuiView.h =================================================================== diff -u -r2216ac6ac7f77437a7c29ac8b4043be01bc4609e -r61f16c988a159401c92730b4cbfca5085c77222f --- sources/gui/GuiView.h (.../GuiView.h) (revision 2216ac6ac7f77437a7c29ac8b4043be01bc4609e) +++ sources/gui/GuiView.h (.../GuiView.h) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -51,11 +51,10 @@ PROPERTY(quint8 , sdPercent , 0 ) PROPERTY(quint8 , sdIsLow , false ) - // this property will be set if the sd-card space gets lower than required amount in percent that has been defined in DriveWatcher. + // this property will be set if the sd-card space gets lower than required amount in percent that has been defined in DeviceController. PROPERTY(qint8 , sdTooLowPecent, -1) // -1 means the event never happened // coco end - PROPERTY(bool , usbReady , false) PROPERTY(bool , usbRemoved , true ) Index: sources/gui/qml/AlarmItem.qml =================================================================== diff -u -r376859852f4d1a07263c44524aec347db29e0133 -r61f16c988a159401c92730b4cbfca5085c77222f --- sources/gui/qml/AlarmItem.qml (.../AlarmItem.qml) (revision 376859852f4d1a07263c44524aec347db29e0133) +++ sources/gui/qml/AlarmItem.qml (.../AlarmItem.qml) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -84,7 +84,7 @@ NotificationDialog { id : _alarmDialog // this will change later to the actual message text // and the instruction would be in the dialog content - titleText : qsTr("Alarm") + titleText : qsTr("Alarm") + " " + "[" + vAlarmStatus.alarm_AlarmID + "]" description : vAlarmStatus.text alarmID : vAlarmStatus.alarm_AlarmID isSilenced : vAlarmStatus.alarm_Flag_alarmsSilenced Index: sources/gui/qml/SDItem.qml =================================================================== diff -u -r7077e38c74db9cccb5496ffefcf8936c0916de76 -r61f16c988a159401c92730b4cbfca5085c77222f --- sources/gui/qml/SDItem.qml (.../SDItem.qml) (revision 7077e38c74db9cccb5496ffefcf8936c0916de76) +++ sources/gui/qml/SDItem.qml (.../SDItem.qml) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -30,6 +30,7 @@ */ Rectangle { id: _root // TEST : SD-Card not present may need to be handled with better indication(s). + signal clicked signal doubleClicked color : Colors.transparent @@ -59,8 +60,9 @@ color : ! _GuiView.sdIsReady ? "red" : _GuiView.sdIsReadOnly ? "gray" : _GuiView.sdIsLow ? Colors.red : "green" } - MouseArea { - anchors.fill: parent - onDoubleClicked: _root.doubleClicked() + MouseArea { id: _mouseArea + anchors.fill : parent + onClicked : _root.clicked() + onDoubleClicked : _root.doubleClicked() } } Index: sources/gui/qml/components/Slider.qml =================================================================== diff -u -r8a5dbf556a66524fbe4b60ac1573182a0bd27617 -r61f16c988a159401c92730b4cbfca5085c77222f --- sources/gui/qml/components/Slider.qml (.../Slider.qml) (revision 8a5dbf556a66524fbe4b60ac1573182a0bd27617) +++ sources/gui/qml/components/Slider.qml (.../Slider.qml) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -151,6 +151,7 @@ active : ticks anchors.fill : parent sourceComponent : TickMarks { + thickness : 2 decimal : _root.decimal minimum : _root.minimum maximum : _root.maximum Index: sources/gui/qml/main.qml =================================================================== diff -u -r376859852f4d1a07263c44524aec347db29e0133 -r61f16c988a159401c92730b4cbfca5085c77222f --- sources/gui/qml/main.qml (.../main.qml) (revision 376859852f4d1a07263c44524aec347db29e0133) +++ sources/gui/qml/main.qml (.../main.qml) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -21,10 +21,12 @@ import Gui.View 0.1 import Gui.Actions 0.1 - // View classes import VHDAccelerometer 0.1 +// Device +import VDevice 0.1 + // Settings import VSettings 0.1 import VAdjustmentVersions 0.1 @@ -110,6 +112,7 @@ width : Variables.applicationWidth height: Variables.applicationHeight + VDevice { id: vDevice } VSettings { id: vSettings } VAdjustmentVersions { id: vAdjustmentVersions } VDateTime { id: vDateTime } @@ -244,16 +247,17 @@ font.pixelSize: 14 } - DiagnosticsDialog { id: _diagnosticsDialog } - SDItem { - onDoubleClicked:{ + PowerItem { id: _powerItem } + SDItem { id: _sdItem; + property bool request: true + onDoubleClicked : { _diagnosticsDialog.open() } } - PowerItem { id: _powerItem } - AlarmItem { id: _alarmItem } - Keyboard { id: _keyboard } + AlarmItem { id: _alarmItem ; z: 998 } + DiagnosticsDialog { id: _diagnosticsDialog; z: 999 } + // NotificationBar has to be anchored to the main menu and if it is moved into the AlarmItem // then cannot be anchored. NotificationBar { id: _alarmBar @@ -265,4 +269,6 @@ timeout : _alarmItem.timeout backgroundFading : vHDOperationMode.fault } + + Keyboard { id: _keyboard } } Index: sources/gui/qml/pages/posttreatment/PostTreatmentReview.qml =================================================================== diff -u -r577ab4647b2584d4e32b26797281ec1543d2e1aa -r61f16c988a159401c92730b4cbfca5085c77222f --- sources/gui/qml/pages/posttreatment/PostTreatmentReview.qml (.../PostTreatmentReview.qml) (revision 577ab4647b2584d4e32b26797281ec1543d2e1aa) +++ sources/gui/qml/pages/posttreatment/PostTreatmentReview.qml (.../PostTreatmentReview.qml) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -74,7 +74,7 @@ itemsText : vPostTreatmentAdjustmentTreatmentLog.parametersTitle itemsValue : vPostTreatmentAdjustmentTreatmentLog.parametersText itemsUnit : vPostTreatmentAdjustmentTreatmentLog.parametersUnit - itemsValueLeftMargin : 350 // if decreased maybe covered by title + itemsValueLeftMargin : 350 // if decreased may be covered by title itemsUnitLeftMargin : 470 // if increased will be covered by chevron if touchable itemsTouchable : [ 0,0,0,0,1,0,0,0,0,0, Index: sources/gui/qml/pages/settings/SettingsStack.qml =================================================================== diff -u -r56ad953ae404fcf6956bd4f76b7a54b12d0285d3 -r61f16c988a159401c92730b4cbfca5085c77222f --- sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision 56ad953ae404fcf6956bd4f76b7a54b12d0285d3) +++ sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -64,8 +64,8 @@ qsTr("Factory Reset" ), // FactoryReset ] property var itemsEnabled : [ - false , // Information - false , // VolumeBrightness + true , // Information + true , // VolumeBrightness true , // WiFi false , // Bluetooth true , // DGSettings @@ -82,14 +82,80 @@ true , // WiFi true , // Bluetooth true , // DGSettings - ! serviceMode , // Services + ! serviceMode , // Services serviceMode , // SetDateTime serviceMode , // Language serviceMode , // Calibration serviceMode , // SWUpdate serviceMode , // FactoryReset ] + SettingsBase { id: _settingsInformation + itemIndex : SettingsStack.Information + } + + SettingsBase { id: _settingsVolumeBrightness + itemIndex : SettingsStack.VolumeBrightness + Column { + spacing: 50 + anchors.centerIn: parent + Row { + anchors.horizontalCenter: parent.horizontalCenter + Label { + anchors.verticalCenter: parent.verticalCenter + text: qsTr("Brightness") + } + Slider { id : _brightness + anchors.verticalCenter: parent.verticalCenter + width : 500 + step : 20 // no zero + minimum : 20 // 1 + maximum : 100 // 5 + height : 5 + ticks : true + onReleased : vDevice.brightness = _brightness.value + Connections { target: vDevice + // in case the value is rejecte it will be set to the previous value + // also the init value shall be set when navigate to the screen + onBrightnessChanged: _brightness.value = vDevice.brightness + } + } + } + Row { + anchors.horizontalCenter: parent.horizontalCenter + Label { + anchors.verticalCenter: parent.verticalCenter + text: qsTr("Alarm Volume") + } + Slider { id : _alarmVolume + anchors.verticalCenter: parent.verticalCenter + width : 500 + step : 20 // no zero + minimum : 20 // 1 + maximum : 100 // 5 + height : 5 + ticks : true + } + } + Row { + anchors.horizontalCenter: parent.horizontalCenter + Label { + anchors.verticalCenter: parent.verticalCenter + text: qsTr("System Volume") + } + Slider { id : _systemVolume + anchors.verticalCenter: parent.verticalCenter + width : 500 + step : 20 // no zero + minimum : 20 // 1 + maximum : 100 // 5 + height : 5 + ticks : true + } + } + } + } + SettingsDateTime { id: _settingsDateTime itemIndex : SettingsStack.SetDateTime } @@ -142,26 +208,39 @@ itemsVisible : _root.itemsVisible onItemClicked : { switch (vIndex) { + case SettingsStack.Information: + push(_settingsInformation) + break + + case SettingsStack.VolumeBrightness: + push(_settingsVolumeBrightness) + break + case SettingsStack.SetDateTime: vDateTime.doInit() push( _settingsDateTime ) _settingsDateTime.setFocus() break + case SettingsStack.WiFi: vNetwork.doInit() push( _settingsWiFi ) // _settingsWiFi.setFocus() // No keyboard popup. break + case SettingsStack.Bluetooth: push( _settingsBluetooth ) break + case SettingsStack.DGSettings: push( _settingsDGSettings ) break + case SettingsStack.Services: push(_servicePassword) _servicePassword.setFocus() break + default: console.debug("Unknown Index", vIndex) break Index: sources/main.h =================================================================== diff -u -r7077e38c74db9cccb5496ffefcf8936c0916de76 -r61f16c988a159401c92730b4cbfca5085c77222f --- sources/main.h (.../main.h) (revision 7077e38c74db9cccb5496ffefcf8936c0916de76) +++ sources/main.h (.../main.h) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -114,7 +114,6 @@ emit vVARIABLE##Entered( _##vVARIABLE ); \ } \ } - //--------------------------------------------------------------------------------// #define PROPERTY_BASE(vTYPE , vVARIABLE , vDEFVALUE, vSIGNAL) \ /*! \brief Qt Property declaration @@ -145,17 +144,14 @@ } //--------------------------------------------------------------------------------// #define PROPERTY( vTYPE , vVARIABLE , vDEFVALUE ) \ - \ PROPERTY_BASE( vTYPE , vVARIABLE , vDEFVALUE , Changed ) \ PROPERTY_SLOT( vTYPE , vVARIABLE) //--------------------------------------------------------------------------------// #define TRIGGER( vTYPE , vVARIABLE , vDEFVALUE ) \ - \ PROPERTY_BASE( vTYPE , vVARIABLE , vDEFVALUE , Triggered) \ TRIGGER_SLOT ( vTYPE , vVARIABLE) //--------------------------------------------------------------------------------// #define STATE( vTYPE , vVARIABLE , vDEFVALUE ) \ - \ PROPERTY_BASE( vTYPE , vVARIABLE , vDEFVALUE , Entered ) \ STATE_SLOT ( vTYPE , vVARIABLE) //--------------------------------------------------------------------------------// Index: sources/model/MAbstract.h =================================================================== diff -u -ra89b5249df072be403141463d7d88728b66a848e -r61f16c988a159401c92730b4cbfca5085c77222f --- sources/model/MAbstract.h (.../MAbstract.h) (revision a89b5249df072be403141463d7d88728b66a848e) +++ sources/model/MAbstract.h (.../MAbstract.h) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -69,6 +69,7 @@ eUI, eHD, eDG, + eDV, }; private: @@ -80,7 +81,8 @@ const QMap _unitText { {Unit_Enum::eUI, "UI"}, {Unit_Enum::eHD, "HD"}, - {Unit_Enum::eDG, "DG"} + {Unit_Enum::eDG, "DG"}, + {Unit_Enum::eDV, "DV"} }; public: Index: sources/model/MModel.h =================================================================== diff -u -ra89b5249df072be403141463d7d88728b66a848e -r61f16c988a159401c92730b4cbfca5085c77222f --- sources/model/MModel.h (.../MModel.h) (revision a89b5249df072be403141463d7d88728b66a848e) +++ sources/model/MModel.h (.../MModel.h) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -16,6 +16,9 @@ #include "main.h" +// device +#include "DeviceModels.h" + // models #include "MSettings.h" #include "MAdjustPowerOff.h" @@ -235,6 +238,9 @@ \details Registers the models in the Qt MetaType so it can be used in signal/slots between threads. */ #define REGISTER_MODEL_METATYPES \ + /* Devices */ \ + REGISTER_METATYPE( DeviceBrightnessRequestData ) \ + REGISTER_METATYPE( DeviceBrightnessResponseData ) \ /* Settings */ \ REGISTER_METATYPE( SettingsData ) \ REGISTER_METATYPE( WifiNetworkData ) \ Fisheye: Tag 61f16c988a159401c92730b4cbfca5085c77222f refers to a dead (removed) revision in file `sources/storage/DriveWatcher.cpp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 61f16c988a159401c92730b4cbfca5085c77222f refers to a dead (removed) revision in file `sources/storage/DriveWatcher.h'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 61f16c988a159401c92730b4cbfca5085c77222f refers to a dead (removed) revision in file `sources/storage/FileSaver.cpp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 61f16c988a159401c92730b4cbfca5085c77222f refers to a dead (removed) revision in file `sources/storage/FileSaver.h'. Fisheye: No comparison available. Pass `N' to diff? Index: sources/storage/Logger.cpp =================================================================== diff -u -r376859852f4d1a07263c44524aec347db29e0133 -r61f16c988a159401c92730b4cbfca5085c77222f --- sources/storage/Logger.cpp (.../Logger.cpp) (revision 376859852f4d1a07263c44524aec347db29e0133) +++ sources/storage/Logger.cpp (.../Logger.cpp) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -24,7 +24,7 @@ #include // Project -#include "DriveWatcher.h" +#include "DeviceController.h" #include "Threads.h" #include "StorageGlobals.h" #include "MainTimer.h" @@ -114,8 +114,8 @@ connect(&_removeLogsWatcher, SIGNAL(finished ()), this , SLOT(onRemoveLogs())); - connect(&_DriveWatcher, SIGNAL( didSDCardSpaceChange(bool, qint64, qint64, quint8)), - this , SLOT( onSDCardSpaceChange(bool, qint64, qint64, quint8))); + connect(&_DeviceController, SIGNAL( didSDCardSpaceChange(bool, qint64, qint64, quint8)), + this , SLOT( onSDCardSpaceChange(bool, qint64, qint64, quint8))); } /*! @@ -166,7 +166,7 @@ void Logger::checkLogPath() { setLogBasePath(); // try to use /media/sd_card on device - // coco begin validated: It can only happen if the file system is readonly for any reason. + // coco begin validated: It can only happen if the file system is read-only for any reason. // it has been tested and works perfectly fine in normal run. if (! setLogPath()) { // check and create log folders & if unsuccessful then // coco end Index: sources/storage/Logger.h =================================================================== diff -u -r500c7850040d66c4829d95c366095e222f834489 -r61f16c988a159401c92730b4cbfca5085c77222f --- sources/storage/Logger.h (.../Logger.h) (revision 500c7850040d66c4829d95c366095e222f834489) +++ sources/storage/Logger.h (.../Logger.h) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -202,9 +202,9 @@ signals: /*! * \brief didRemoveLogs - * \details This signal will be emitted mainly for DriveWatcher to not to emit the signal that Logger is connected to + * \details This signal will be emitted mainly for DeviceController to not to emit the signal that Logger is connected to * , while the logging cleanup is in progress, otherwise if the log cleanup takes more that 1sec (current interval) - * in the DriveWatcher then the cleanup will be called again for no good reason. + * in the DeviceController then the cleanup will be called again for no good reason. * \param vInProgress - true if the log cleanup is in progress, false otherwise. */ void didRemoveLogs(bool vInProgress); Index: sources/storage/Settings.cpp =================================================================== diff -u -r56ad953ae404fcf6956bd4f76b7a54b12d0285d3 -r61f16c988a159401c92730b4cbfca5085c77222f --- sources/storage/Settings.cpp (.../Settings.cpp) (revision 56ad953ae404fcf6956bd4f76b7a54b12d0285d3) +++ sources/storage/Settings.cpp (.../Settings.cpp) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -5,7 +5,7 @@ * 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 + * \file Settings.cpp * \author (last) Behrouz NematiPour * \date (last) 16-Oct-2020 * \author (original) Behrouz NematiPour Index: sources/storage/Settings.h =================================================================== diff -u -r56ad953ae404fcf6956bd4f76b7a54b12d0285d3 -r61f16c988a159401c92730b4cbfca5085c77222f --- sources/storage/Settings.h (.../Settings.h) (revision 56ad953ae404fcf6956bd4f76b7a54b12d0285d3) +++ sources/storage/Settings.h (.../Settings.h) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -5,7 +5,7 @@ * 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 + * \file Settings.h * \author (last) Behrouz NematiPour * \date (last) 26-Mar-2021 * \author (original) Behrouz NematiPour Index: sources/storage/StorageGlobals.cpp =================================================================== diff -u -r7077e38c74db9cccb5496ffefcf8936c0916de76 -r61f16c988a159401c92730b4cbfca5085c77222f --- sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision 7077e38c74db9cccb5496ffefcf8936c0916de76) +++ sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -21,7 +21,7 @@ * \brief Storage * \details The container of the constant global variable withing Storage namespace members. * For example it currently includes USB mount root folder and SD Card mount root folder and such, - * which is used by Logger, DriveWatcher, ... . + * which is used by Logger, DeviceController, ... . */ namespace Storage { @@ -105,4 +105,9 @@ const char *WifiSettings_SubnetMask = "wifi/subnetmask"; const char *WifiSettings_DNS = "wifi/dns"; const char *WifiSettings_UseDHCP = "wifi/useDHCP"; + + // Brightness + const char *Brightness_Set = "brightness_set.sh"; + const char *Brightness_Get = "brightness_get.sh"; + } Index: sources/storage/StorageGlobals.h =================================================================== diff -u -r7077e38c74db9cccb5496ffefcf8936c0916de76 -r61f16c988a159401c92730b4cbfca5085c77222f --- sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision 7077e38c74db9cccb5496ffefcf8936c0916de76) +++ sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -72,4 +72,8 @@ extern const char *WifiSettings_DNS; extern const char *WifiSettings_UseDHCP; + // Brightness + extern const char *Brightness_Set; + extern const char *Brightness_Get; + } Index: sources/view/VView.h =================================================================== diff -u -r376859852f4d1a07263c44524aec347db29e0133 -r61f16c988a159401c92730b4cbfca5085c77222f --- sources/view/VView.h (.../VView.h) (revision 376859852f4d1a07263c44524aec347db29e0133) +++ sources/view/VView.h (.../VView.h) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -101,6 +101,8 @@ //--------------------------------------------------------------------------------// #define REGISTER_VIEW_TYPES \ using namespace View; \ + /* Device */ \ + REGISTER_TYPE( VDevice ) \ /* Settings */ \ REGISTER_TYPE( VSettings ) \ REGISTER_TYPE( VAdjustmentVersions ) \ Index: unittests/tst_initializations.cpp =================================================================== diff -u -r64d87d540594252e8039ab2595016d98f1e3cc28 -r61f16c988a159401c92730b4cbfca5085c77222f --- unittests/tst_initializations.cpp (.../tst_initializations.cpp) (revision 64d87d540594252e8039ab2595016d98f1e3cc28) +++ unittests/tst_initializations.cpp (.../tst_initializations.cpp) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -19,7 +19,7 @@ // Project #include "ApplicationController.h" #include "GuiController.h" -#include "DriveWatcher.h" +#include "DeviceController.h" #include "CanInterface.h" #include "FrameInterface.h" #include "MessageDispatcher.h" @@ -32,9 +32,9 @@ QCOMPARE( _ApplicationController.init(), ! _ApplicationController.init()); } -void tst_initializations::tst_DriveWatcher_init() +void tst_initializations::tst_DeviceController_init() { - QCOMPARE( _DriveWatcher.init(), ! _DriveWatcher.init()); + QCOMPARE( _DeviceController.init(), ! _DeviceController.init()); } void tst_initializations::tst_FrameInterface_init() Index: unittests/tst_initializations.h =================================================================== diff -u -rcc1e9d6d55c816f3fcd626dc6948cca24da283b3 -r61f16c988a159401c92730b4cbfca5085c77222f --- unittests/tst_initializations.h (.../tst_initializations.h) (revision cc1e9d6d55c816f3fcd626dc6948cca24da283b3) +++ unittests/tst_initializations.h (.../tst_initializations.h) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -29,6 +29,6 @@ private slots: void tst_ApplicationController_init(); - void tst_DriveWatcher_init(); + void tst_DeviceController_init(); void tst_FrameInterface_init(); }; Index: unittests/tst_threads.cpp =================================================================== diff -u -r64d87d540594252e8039ab2595016d98f1e3cc28 -r61f16c988a159401c92730b4cbfca5085c77222f --- unittests/tst_threads.cpp (.../tst_threads.cpp) (revision 64d87d540594252e8039ab2595016d98f1e3cc28) +++ unittests/tst_threads.cpp (.../tst_threads.cpp) (revision 61f16c988a159401c92730b4cbfca5085c77222f) @@ -20,7 +20,7 @@ #include "Threads.h" #include "ApplicationController.h" #include "GuiController.h" -#include "DriveWatcher.h" +#include "DeviceController.h" #include "CanInterface.h" #include "FrameInterface.h" #include "MessageDispatcher.h" @@ -35,25 +35,25 @@ void tst_threads::tst_Thread_init() { - QCOMPARE( _Logger .init(Threads::_Logger_Thread ), ! _Logger .init(Threads::_Logger_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 )); - QCOMPARE( _MessageDispatcher .init(Threads::_CanMessage_Thread ), ! _MessageDispatcher .init(Threads::_CanMessage_Thread )); - QCOMPARE( _ApplicationController .init(Threads::_Application_Thread ), ! _ApplicationController .init(Threads::_Application_Thread )); - QCOMPARE( _GuiController .init(Threads::_Application_Thread ), ! _GuiController .init(Threads::_Application_Thread )); + QCOMPARE( _Logger .init(Threads::_Logger_Thread ), ! _Logger .init(Threads::_Logger_Thread )); + QCOMPARE( _DeviceController .init(Threads::_DeviceController_Thread ), ! _DeviceController .init(Threads::_DeviceController_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 )); + QCOMPARE( _MessageDispatcher .init(Threads::_CanMessage_Thread ), ! _MessageDispatcher .init(Threads::_CanMessage_Thread )); + QCOMPARE( _ApplicationController .init(Threads::_Application_Thread ), ! _ApplicationController .init(Threads::_Application_Thread )); + QCOMPARE( _GuiController .init(Threads::_Application_Thread ), ! _GuiController .init(Threads::_Application_Thread )); } void tst_threads::tst_Thread_names() { - QCOMPARE( _Logger .thread()->objectName(), "Storage::Logger_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" ); - QCOMPARE( _MessageDispatcher .thread()->objectName(), "Can::MessageDispatcher_Thread" ); - QCOMPARE( _ApplicationController .thread()->objectName(), "Gui::GuiController_Thread" ); - QCOMPARE( _GuiController .thread()->objectName(), "Gui::GuiController_Thread" ); + QCOMPARE( _Logger .thread()->objectName(), "Storage::Logger_Thread" ); + QCOMPARE( _DeviceController .thread()->objectName(), "Storage::DeviceController_Thread" ); + QCOMPARE( _CanInterface .thread()->objectName(), "Can::FrameInterface_Thread" ); + QCOMPARE( _FrameInterface .thread()->objectName(), "Can::FrameInterface_Thread" ); + QCOMPARE( _MessageAcknowModel .thread()->objectName(), "Can::MessageAcknowModel_Thread" ); + QCOMPARE( _MessageDispatcher .thread()->objectName(), "Can::MessageDispatcher_Thread" ); + QCOMPARE( _ApplicationController .thread()->objectName(), "Gui::GuiController_Thread" ); + QCOMPARE( _GuiController .thread()->objectName(), "Gui::GuiController_Thread" ); }