Index: denali.pro.user =================================================================== diff -u -re125bd5cf13750eaf241d518b9c846139afaa81c -re159592e3a99658e661ab83fffef43322dc075f3 --- denali.pro.user (.../denali.pro.user) (revision e125bd5cf13750eaf241d518b9c846139afaa81c) +++ denali.pro.user (.../denali.pro.user) (revision e159592e3a99658e661ab83fffef43322dc075f3) @@ -1,6 +1,6 @@ - + EnvironmentId Index: en_US.udic =================================================================== diff -u -re125bd5cf13750eaf241d518b9c846139afaa81c -re159592e3a99658e661ab83fffef43322dc075f3 --- en_US.udic (.../en_US.udic) (revision e125bd5cf13750eaf241d518b9c846139afaa81c) +++ en_US.udic (.../en_US.udic) (revision e159592e3a99658e661ab83fffef43322dc075f3) @@ -83,3 +83,7 @@ HDOp DeviceID RO +umount +VStorage +USBDrive +SDCard Index: sources/ApplicationController.cpp =================================================================== diff -u -r6581def57942b1c1ef56a2f2feb74559946517b9 -re159592e3a99658e661ab83fffef43322dc075f3 --- sources/ApplicationController.cpp (.../ApplicationController.cpp) (revision 6581def57942b1c1ef56a2f2feb74559946517b9) +++ sources/ApplicationController.cpp (.../ApplicationController.cpp) (revision e159592e3a99658e661ab83fffef43322dc075f3) @@ -265,6 +265,7 @@ { // coco begin validated: This needs user interaction to plug-in SD Card // has been tested manually + /// DEBUG: qDebug() << " ***** ApplicationController " << Storage::SDCard_Base_Path_Name << vIsReady; emit didSDCardStateChange(vIsReady, vIsReadOnly); } // coco end Index: sources/gui/GuiController.cpp =================================================================== diff -u -ra3030123e885fb9f22dea5839c4e988896a257e4 -re159592e3a99658e661ab83fffef43322dc075f3 --- sources/gui/GuiController.cpp (.../GuiController.cpp) (revision a3030123e885fb9f22dea5839c4e988896a257e4) +++ sources/gui/GuiController.cpp (.../GuiController.cpp) (revision e159592e3a99658e661ab83fffef43322dc075f3) @@ -277,6 +277,7 @@ { // coco begin validated: This needs user interaction to plug-out the SD Card // has been tested manually + /// DEBUG: qDebug() << " ***** GuiController " << Storage::SDCard_Base_Path_Name << vIsReady; emit didSDCardStateChange(vIsReady, vIsReadOnly); } // coco end Index: sources/gui/GuiView.cpp =================================================================== diff -u -ra3030123e885fb9f22dea5839c4e988896a257e4 -re159592e3a99658e661ab83fffef43322dc075f3 --- sources/gui/GuiView.cpp (.../GuiView.cpp) (revision a3030123e885fb9f22dea5839c4e988896a257e4) +++ sources/gui/GuiView.cpp (.../GuiView.cpp) (revision e159592e3a99658e661ab83fffef43322dc075f3) @@ -16,6 +16,7 @@ // Project #include "GuiView.h" #include "GuiController.h" +#include "DriveWatcher.h" // namespace using namespace Gui; @@ -42,7 +43,7 @@ connect(&_GuiController, SIGNAL(didActionReceive (GuiActionType, const QVariantList &)), this , SLOT( onActionReceive (GuiActionType, const QVariantList &))); - // since we don't have access to this object because it is created in Qml. + // since we don't have access to this object because it is created in QML. // Connection to the GuiController made here // It should be defined in the class which wants to connect to signal. connect(this , SIGNAL(didActionTransmit(GuiActionType,const QVariantList &)), @@ -60,9 +61,11 @@ // SD Card connect(&_GuiController, SIGNAL(didSDCardStateChange(bool,bool)), this , SLOT( onSDCardStateChange(bool,bool))); - connect(&_GuiController, SIGNAL(didSDCardStateChange(bool,bool)), - 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(&_GuiController, SIGNAL(didExport()), this , SLOT( onExport())); @@ -162,14 +165,15 @@ /*! * \brief GuiView::onSDCardStateChange * \details emits didSDCardStateChange signal to notify other classes (UI) - * , the SD Card Stte has been changed. - * \param vIsReady - SdCard is Ready - * \param vIsReadOnly - SdCard is ReadOnly + * , the SD Card State has been changed. + * \param vIsReady - SDCard is Ready + * \param vIsReadOnly - SDCard is ReadOnly */ void GuiView::onSDCardStateChange(bool vIsReady, bool vIsReadOnly) { // coco begin validated: This needs user interaction to plug-in USB device // has been tested manually + /// DEBUG: qDebug() << " ***** GuiView " << Storage::SDCard_Base_Path_Name << vIsReady; sdIsReady (vIsReady ); sdIsReadOnly(vIsReadOnly); } @@ -213,3 +217,27 @@ emit didExportLog(); } // coco end + +/*! + * \brief GuiView::onSDCardSpaceChange + * \details SD Card storage space parameter change slot. + * This slot when called is calling the function concurrentRemoveLogs, + * if percent of available space vPercent is less than Storage::Available_Space_Percent, + * if the SD Card is ready (vReady is true) + * \param vReady - The SD Card is Ready + * \param vTotal - Total storage space on the SD Card + * \param vAvailable - Available storage space on the SD Card + * \param vPercent - Percent of available storage space on the SD Card + */ +void GuiView::onSDCardSpaceChange(bool vReady, qint64 vTotal, qint64 vAvailable, quint8 vPercent) +{ + // coco begin validated: This needs user interaction to change the SD card files system. + // has been tested manually + /// DEBUG: qDebug() << vReady << vTotal << vAvailable << vPercent << Storage::Available_Space_Percent; + Q_UNUSED(vReady) + sdTotal ( vTotal ); + sdAvail ( vAvailable ); + sdPercent ( vPercent ); + sdIsLow ( vPercent <= Storage::Available_Space_Percent ); +} +// coco end Index: sources/gui/GuiView.h =================================================================== diff -u -ra3030123e885fb9f22dea5839c4e988896a257e4 -re159592e3a99658e661ab83fffef43322dc075f3 --- sources/gui/GuiView.h (.../GuiView.h) (revision a3030123e885fb9f22dea5839c4e988896a257e4) +++ sources/gui/GuiView.h (.../GuiView.h) (revision e159592e3a99658e661ab83fffef43322dc075f3) @@ -46,6 +46,11 @@ PROPERTY(bool, sdIsReady , false) PROPERTY(bool, sdIsReadOnly, false) + PROPERTY(quint64, sdTotal , 0 ) + PROPERTY(quint64, sdAvail , 0 ) + 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. PROPERTY(qint8, sdTooLowPecent, -1) // -1 means the event never happened // coco end @@ -66,6 +71,7 @@ void onSDCardStateChange(bool vIsReady, bool vIsReadOnly); void onSDCardSpaceTooLow(quint8 vAvailablePercent); + void onSDCardSpaceChange(bool vReady, qint64 vTotal, qint64 vAvailable, quint8 vPercent); public slots: // is public since will be used in the UI and is in the same thread. void doActionTransmit(GuiActionType vAction, const QVariantList &vData); // UI => HD/DG Index: sources/gui/qml/SDItem.qml =================================================================== diff -u -r506a9e3db1a20bda1685e38c5e9041005c9a4a4f -re159592e3a99658e661ab83fffef43322dc075f3 --- sources/gui/qml/SDItem.qml (.../SDItem.qml) (revision 506a9e3db1a20bda1685e38c5e9041005c9a4a4f) +++ sources/gui/qml/SDItem.qml (.../SDItem.qml) (revision e159592e3a99658e661ab83fffef43322dc075f3) @@ -15,20 +15,19 @@ // Qt import QtQuick 2.12 -import QtQuick.VirtualKeyboard 2.2 + // Project // C++ imports // Qml imports import "qrc:/globals" +import "qrc:/components" - /*! * \brief Keyboard is the single keyboard in the entire applicaiton. */ -Rectangle { id: _SDNotification// TEST : SD-Card not present should be handled with better indication(s). +Rectangle { id: _root // TEST : SD-Card not present should be handled with better indication(s). color : Colors.transparent - border.color : ! _GuiView.sdIsReady ? Colors.red : _GuiView.sdIsReadOnly ? "gray" : "green" anchors { top : parent.top right : parent.right @@ -41,8 +40,19 @@ Text { id: _SDText anchors.centerIn: parent color: ! _GuiView.sdIsReady ? Colors.red : _GuiView.sdIsReadOnly ? "gray" : Colors.white - text: qsTr("SD") + text : ! _GuiView.sdIsReady ? qsTr("SD") : _GuiView.sdPercent font.pixelSize: 12 font.bold: true } + + ProgressCircle { + anchors.fill: parent + diameter: _root.width + minimum : 0 + maximum : _GuiView.sdTotal / 1000000 + value : _GuiView.sdAvail / 1000000 + thickness: 1 + color : ! _GuiView.sdIsReady ? "red" : _GuiView.sdIsReadOnly ? "gray" : _GuiView.sdIsLow ? Colors.red : "green" + } + } Index: sources/gui/qml/components/ProgressCircle.qml =================================================================== diff -u -rdb2238dcf17941be6a3c587b55a3ef06b94cee96 -re159592e3a99658e661ab83fffef43322dc075f3 --- sources/gui/qml/components/ProgressCircle.qml (.../ProgressCircle.qml) (revision db2238dcf17941be6a3c587b55a3ef06b94cee96) +++ sources/gui/qml/components/ProgressCircle.qml (.../ProgressCircle.qml) (revision e159592e3a99658e661ab83fffef43322dc075f3) @@ -28,7 +28,8 @@ property int maximum : 0 property int value : minimum property alias diameter : _circle.diameter - property alias thickness :_circle.thickness + property alias thickness : _circle.thickness + property color color : Colors.backgroundMainMenu width : _circle.width height : _circle.height @@ -39,6 +40,7 @@ Circle { id: _circle anchors.centerIn: parent + color : _root.color shadow.color : Colors.backgroundMainMenu angle : _private.value thickness : 2 Index: sources/storage/DriveWatcher.cpp =================================================================== diff -u -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 -re159592e3a99658e661ab83fffef43322dc075f3 --- sources/storage/DriveWatcher.cpp (.../DriveWatcher.cpp) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) +++ sources/storage/DriveWatcher.cpp (.../DriveWatcher.cpp) (revision e159592e3a99658e661ab83fffef43322dc075f3) @@ -241,7 +241,7 @@ 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); @@ -257,9 +257,12 @@ quint8 mPercent = mCTotal ? ((100 * mCAvailable) / mCTotal) : 0; if (mPercent < _minRequiredAvailableSpacePercent) { LOG_EVENT(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; @@ -270,6 +273,7 @@ mOAvailable = mCAvailable ; if (_pauseSpaceCheck) return; emit didSDCardSpaceChange(mCIsReady, mCTotal, mCAvailable, mPercent); + /// DEBUG: qDebug() << Storage::SDCard_Base_Path_Name << mCIsReady << mCTotal << mCAvailable << mPercent ; } // coco end Index: sources/storage/FileHandler.cpp =================================================================== diff -u -r94fc1cd187816ecbf176df26f9dc5601bf379f13 -re159592e3a99658e661ab83fffef43322dc075f3 --- sources/storage/FileHandler.cpp (.../FileHandler.cpp) (revision 94fc1cd187816ecbf176df26f9dc5601bf379f13) +++ sources/storage/FileHandler.cpp (.../FileHandler.cpp) (revision e159592e3a99658e661ab83fffef43322dc075f3) @@ -231,6 +231,7 @@ int lastIndex = path.size() - 1; if (path.at(lastIndex) == "/") path.remove(lastIndex, 1); // check to see if the path in the list of mounted rootPaths + /// DEBUG: qDebug() << " +++++ " << QStorageInfo::mountedVolumes(); foreach (const QStorageInfo &storage, QStorageInfo::mountedVolumes()) { if (storage.isValid() && storage.isReady()) { if ( storage.rootPath() == path ) { Index: sources/storage/Logger.cpp =================================================================== diff -u -r821bf955d0ba7e028bccfee7c04ca77cf80a0bd4 -re159592e3a99658e661ab83fffef43322dc075f3 --- sources/storage/Logger.cpp (.../Logger.cpp) (revision 821bf955d0ba7e028bccfee7c04ca77cf80a0bd4) +++ sources/storage/Logger.cpp (.../Logger.cpp) (revision e159592e3a99658e661ab83fffef43322dc075f3) @@ -345,7 +345,7 @@ // coco begin validated: This needs user interaction to check the old files deleted // Storage::FileHandler::find("/media/denali/0CAA-40C1/log/", {"*.err"}, 15); return 0; // has been tested manually - qDebug() << "int Logger::removeLogs()"; + LOG_DEBUG("Initializing log clean up"); static QString mOSource; static QString mOExtension; int removeCount = 0; @@ -374,9 +374,15 @@ LOG_DEBUG(QString("Current day log %1 cannot be deleted").arg(info.fileName())); } else { + QString mFileName = mCSource + info.fileName(); /// DEBUG: since it has been manually tested this will help next time for test. - /// qDebug() << "#" << mCSource + info.fileName(); - QFile::remove(info.fileName()); + /// qDebug() << "#" << mFileName; + bool ok = QFile::remove(mFileName); + if (ok) { + LOG_DEBUG(QString("Removing %1 succeeded").arg(mFileName)); + } else { + LOG_DEBUG(QString("Removing %1 failed" ).arg(mFileName)); + } } } } @@ -400,7 +406,7 @@ { // coco begin validated: This needs user interaction to check the old files deleted // has been tested manually - LOG_DEBUG("Remove Logs Start"); + LOG_DEBUG("Remove Logs Starting"); emit didRemoveLogs(true); QFuture mFuture = QtConcurrent::run(this, &Logger::removeLogs); _removeLogsWatcher.setFuture(mFuture); @@ -425,7 +431,7 @@ * \brief Logger::onSDCardSpaceChange * \details SD Card storage space parameter change slot. * This slot when called is calling the function concurrentRemoveLogs, - * if percent of available space vPercent is less than _availableSpacePercent, + * if percent of available space vPercent is less than Storage::Available_Space_Percent, * if the SD Card is ready (vReady is true) * \param vReady - The SD Card is Ready * \param vTotal - Total storage space on the SD Card @@ -439,7 +445,8 @@ Q_UNUSED(vTotal ) Q_UNUSED(vAvailable ) if ( ! vReady ) return; - if (vPercent < _availableSpacePercent ) { + /// DEBUG: qDebug() << vPercent << Storage::Available_Space_Percent; + if ( vPercent < Storage::Available_Space_Percent ) { concurrentRemoveLogs(); } } Index: sources/storage/Logger.h =================================================================== diff -u -r583d1953c783940c93f22c37b23daadb1ff3a09c -re159592e3a99658e661ab83fffef43322dc075f3 --- sources/storage/Logger.h (.../Logger.h) (revision 583d1953c783940c93f22c37b23daadb1ff3a09c) +++ sources/storage/Logger.h (.../Logger.h) (revision e159592e3a99658e661ab83fffef43322dc075f3) @@ -116,7 +116,7 @@ // be careful when defining these percentages // 1 - Since now both the Log and Datum are in the same place and file they have same percentage. // if separated then the percentage has to be separated - // 2 - the total in _logTypeExpiryDay in not 100 and it has to be summed up with _availableSpacePercent. + // 2 - the total in _logTypeExpiryDay is not 100 and it has to be summed up with Storage::Available_Space_Percent. // so it is 70% for Event/Datum + 15% Service + 15% free = 100% total const QHash _logTypeMaxUsageLimit { #ifdef MIXED_EVENT_DATUM @@ -129,8 +129,6 @@ { LogType::eLogDebug, 15 }, // in days }; - const qint8 _availableSpacePercent = 15; // currently 16GB SD-Card so 2.4GB should always be available. - const char *_dateFormat = "yyyy_MM_dd"; const char *_timeFormat = "HH:mm:ss"; Index: sources/storage/StorageGlobals.cpp =================================================================== diff -u -r506a9e3db1a20bda1685e38c5e9041005c9a4a4f -re159592e3a99658e661ab83fffef43322dc075f3 --- sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision 506a9e3db1a20bda1685e38c5e9041005c9a4a4f) +++ sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision e159592e3a99658e661ab83fffef43322dc075f3) @@ -33,11 +33,12 @@ const char *USB_File_System = "vfat"; // SD-CARD + const short Available_Space_Percent = 15; // currently 16GB SD-Card so 2.4GB should always be available. #ifdef BUILD_FOR_TARGET 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/"; + const char *SDCard_Base_Path_Name = "/media/denali/USB DISK"; #endif // Settings Index: sources/storage/StorageGlobals.h =================================================================== diff -u -r506a9e3db1a20bda1685e38c5e9041005c9a4a4f -re159592e3a99658e661ab83fffef43322dc075f3 --- sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision 506a9e3db1a20bda1685e38c5e9041005c9a4a4f) +++ sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision e159592e3a99658e661ab83fffef43322dc075f3) @@ -24,6 +24,7 @@ extern const char *USB_File_System; // SD-CARD + extern const short Available_Space_Percent; extern const char *SDCard_Base_Path_Name; // Settings