Index: sources/ApplicationController.cpp =================================================================== diff -u -r3e64d98e243484505a44d99b13826097cb6b01eb -r142f2ddb8ce284c52c0add2acf3ac81f471b78de --- sources/ApplicationController.cpp (.../ApplicationController.cpp) (revision 3e64d98e243484505a44d99b13826097cb6b01eb) +++ sources/ApplicationController.cpp (.../ApplicationController.cpp) (revision 142f2ddb8ce284c52c0add2acf3ac81f471b78de) @@ -1,15 +1,15 @@ /*! * - * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. + * Copyright (c) 2020-2022 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 ApplicationController.cpp * \author (last) Behrouz NematiPour - * \date (last) 29-Mar-2021 + * \date (last) 28-Sep-2022 * \author (original) Behrouz NematiPour - * \date (original) 29-Mar-2021 + * \date (original) 26-Aug-2020 * */ #include "ApplicationController.h" @@ -22,7 +22,7 @@ #include "MessageDispatcher.h" #include "Logger.h" #include "DeviceController.h" -#include "FileHandler.h" +//#include "FileHandler.h" #include "GuiController.h" #include "Settings.h" #include "MSettings.h" @@ -75,11 +75,11 @@ */ void ApplicationController::quit() { - // coco begin validated: Application termination is not correctly done in coco!!! + // disabled 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 +// disabled coco end /*! * \brief ApplicationController::initConnections @@ -93,6 +93,8 @@ this , SLOT(onPOSTWiFi (bool))); connect(&_post , SIGNAL( didBluetooth(bool)), this , SLOT(onPOSTBluetooth(bool))); + connect(&_post , SIGNAL( didCloudSync(bool)), + this , SLOT(onPOSTCloudSync(bool))); connect(&_post , SIGNAL( didFail (Gui::GuiAlarmID )), this , SLOT(onPOSTFail (Gui::GuiAlarmID ))); @@ -114,24 +116,34 @@ this , SLOT( onFailedTransmit(Sequence))); // USB drive - connect(&_GuiController , SIGNAL(didUSBDriveUmount()), - this , SLOT( onUSBDriveUmount())); + connect(&_GuiController , SIGNAL(didUSBDriveUmount()), + this , SLOT( onUSBDriveUmount())); connect(&_DeviceController , SIGNAL(didUSBDriveMount ()), this , SLOT( onUSBDriveMount ())); connect(&_DeviceController , SIGNAL(didUSBDriveRemove()), this , SLOT( onUSBDriveRemove())); + connect(&_DeviceController , SIGNAL(didUSBSpaceChange(bool, qint64, qint64, quint8)), + this , SLOT( onUSBSpaceChange(bool, qint64, qint64, quint8))); // SD Card connect(&_DeviceController , SIGNAL(didSDCardStateChange(bool, bool)), this , SLOT( onSDCardStateChange(bool, bool))); + connect(&_DeviceController , SIGNAL(didSDCardSpaceChange(bool, qint64, qint64, quint8)), + this , SLOT( onSDCardSpaceChange(bool, qint64, qint64, quint8))); connect(&_DeviceController , SIGNAL(didSDCardSpaceTooLow(quint8)), this , SLOT( onSDCardSpaceTooLow(quint8))); - connect(&_GuiController , SIGNAL(didExportLog()), - this , SLOT( onExportLog())); + connect(&_GuiController , SIGNAL(didExportLog (const GuiStringIndexMap &)), + this , SLOT( onExportLog (const GuiStringIndexMap &))); + connect(&_GuiController , SIGNAL(didExportService (const GuiStringIndexMap &)), + this , SLOT( onExportService (const GuiStringIndexMap &))); + connect(&_GuiController , SIGNAL(didExportTreatment (const GuiStringIndexMap &)), + this , SLOT( onExportTreatment (const GuiStringIndexMap &))); - connect(&_Logger , SIGNAL(didExportLogs()), - this , SLOT( onExport ())); + connect(&_Logger , SIGNAL(didExportLogs ()), + this , SLOT( onExport ())); + connect(&_Logger , SIGNAL(didExportStat (quint32, const QString &, quint8)), + this , SLOT( onExportStat (quint32, const QString &, quint8))); // Settings - move to application thread connect(this, SIGNAL(didSettingsInit()), @@ -173,15 +185,15 @@ */ void ApplicationController::quitThread() { - // coco begin validated: Application termination is not correctly done in coco!!! + // disabled 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 +// disabled coco end /*! * \brief ApplicationController::onFailedTransmit @@ -233,11 +245,11 @@ */ void ApplicationController::onUSBDriveMount () { - // coco begin validated: This needs user interaction to plug-in USB device + // disabled coco begin validated: This needs user interaction to plug-in USB device // has been tested manually emit didUSBDriveMount(); } -// coco end +// disabled coco end /*! * \brief ApplicationController::onUSBDriveRemove @@ -246,11 +258,11 @@ */ void ApplicationController::onUSBDriveUmount() { - // coco begin validated: This needs user interaction to plug-in USB device + // disabled coco begin validated: This needs user interaction to plug-in USB device // has been tested manually emit didUSBDriveUmount(); } -// coco end +// disabled coco end /*! * \brief ApplicationController::onUSBDriveRemove @@ -259,12 +271,15 @@ */ void ApplicationController::onUSBDriveRemove() { - // coco begin validated: This needs user interaction to plug-in USB device - // has been tested manually emit didUSBDriveRemove(); } -// coco end +void ApplicationController::onUSBSpaceChange(bool vReady, qint64 vTotal, qint64 vAvailable, quint8 vPercent) +{ + //DEBUG:0: qDebug() << "ApplicationController::onUSBSpaceChange" << vReady << vTotal << vAvailable << vPercent; + emit didUSBSpaceChange(vReady, vTotal, vAvailable, vPercent); +} + /*! * \brief ApplicationController::onSDCardStateChange * \details This is the slot which connects to the _DeviceController didSDCardStateChange signal @@ -274,50 +289,71 @@ */ void ApplicationController::onSDCardStateChange(bool vIsReady, bool vIsReadOnly) { - // 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; + //DEBUG:0: qDebug() << " ***** ApplicationController " << Storage::SDCard_Base_Path_Name << vIsReady; emit didSDCardStateChange(vIsReady, vIsReadOnly); } -// coco end +void ApplicationController::onSDCardSpaceChange(bool vReady, qint64 vTotal, qint64 vAvailable, quint8 vPercent) +{ + emit didSDCardSpaceChange(vReady, vTotal, vAvailable, vPercent); +} + /*! * \brief ApplicationController::onSDCardSpaceTooLow * \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) { - // coco begin validated: This needs user interaction to plug-in SD Card + // disabled coco begin validated: This needs user interaction to plug-in SD Card // has been tested manually emit didSDCardSpaceTooLow(vAvailablePercent); } -// coco end +// disabled coco end /*! * \brief ApplicationController::onExportLog * \details the slot which will be called by UI to so the log export. */ -void ApplicationController::onExportLog() +void ApplicationController::onExportLog(const GuiStringIndexMap &vExportList) { - // coco begin validated: This needs user interaction to plug-in USB device - // has been tested manually - LOG_EXPORT; + LOG_EXPORTLOG(vExportList); } -// coco end +/*! + * \brief ApplicationController::onExportService + * \details the slot which will be called by UI to do the service log export. + */ +void ApplicationController::onExportService(const GuiStringIndexMap &vExportList) +{ + LOG_EXPORTERR(vExportList); +} +/*! + * \brief ApplicationController::onExportTreatment + * \details the slot which will be called by UI to do the treatment treatment log export. + */ +void ApplicationController::onExportTreatment(const GuiStringIndexMap &vExportList) +{ + LOG_EXPORTTRT(vExportList); +} /*! * \brief ApplicationController::onExport * \details the slot which will be called by logger is done exporting. */ void ApplicationController::onExport() { - // coco begin validated: This needs user interaction to plug-in USB device + // disabled coco begin validated: This needs user interaction to plug-in USB device // has been tested manually emit didExport(); } -// coco end +void ApplicationController::onExportStat(quint32 vIndex, const QString &vFileName, quint8 vPercent) +{ + // DEBUG: qDebug() << "1" << vIndex << vFileName << vPercent; + emit didExportStat(vIndex, vFileName, vPercent); +} +// disabled coco end + /*! * \brief ApplicationController::keepAlive * \details This is the message which has to be send over the CANBus @@ -339,7 +375,7 @@ createFakeSequencedLongMessage (mData, mFakeDataLen); } } - // coco end + // disabled coco end else { mData += static_cast(GuiActionData::NoData); } @@ -355,7 +391,7 @@ */ void ApplicationController::createFakeSequencedLongMessage(QVariantList &vData, const int vFakeDataLen) { - // coco begin validated: This is a fake data generator for CANBus missing/swapped frames Testing + // disabled coco begin validated: This is a fake data generator for CANBus missing/swapped frames Testing // will never be executed on the product // has been tested manually QByteArray data; @@ -401,7 +437,7 @@ vData += gFakeData; } } -// coco end +// disabled coco end /*! * \brief ApplicationController::createFakeSequencedAtBeginLongMessage @@ -411,7 +447,7 @@ */ void ApplicationController::createFakeSeqAtBeginLongMessage(QVariantList &vData, const int vFakeDataLen) { - // coco begin validated: This is a fake data generator for CANBus missing/swapped frames Testing + // disabled coco begin validated: This is a fake data generator for CANBus missing/swapped frames Testing // will never be executed on the product // has been tested manually QByteArray data; @@ -462,7 +498,7 @@ vData += gFakeData; } } -// coco end +// disabled coco end /*! * \brief ApplicationController::initSettings @@ -500,9 +536,13 @@ void ApplicationController::onSettingsUpdate() { onActionReceive(SettingsData()); -} + // call initialization functions when setting's ready. + _Settings.datetimeFormat(); + emit didSettingsDone(); +} + /*! * \brief ApplicationController::onPOSTWiFi * \details Starts the WiFi Interface @@ -511,6 +551,7 @@ if (vPass) { _WifiInterface.doStart(); } + emit didPOSTWiFi(vPass); } /*! @@ -524,17 +565,26 @@ } else { _BluetoothInterface.doNotifyStatePOSTError(); + emit didPOSTBluetooth(vPass); } } +/*! + * \brief ApplicationController::onPOSTCloudSync + * \details Notifies the CloudSync POST status + */ +void ApplicationController::onPOSTCloudSync(bool vPass) +{ + emit didPOSTCloudSync(vPass); +} /*! * \brief ApplicationController::onPOSTFail * \details sends the Alarm Trigger message, used when the POST Failed. * \param vAlarmID */ void ApplicationController::onPOSTFail(GuiAlarmID vAlarmID) { - emit didActionTransmit(GuiActionType::ID_AlarmTriggered, { vAlarmID ,0,0,0,0}); + emit didActionTransmit(GuiActionType::ID_AlarmTriggered, {vAlarmID ,0,0,0,0,0,0,0}); } /*!