Index: sources/applicationcontroller.cpp =================================================================== diff -u -r8f6f7c11390e3ed6d918f1717d8e8b7ae5b7e5c6 -r846a9ebc350e33be4affab3cc4c136248900015d --- sources/applicationcontroller.cpp (.../applicationcontroller.cpp) (revision 8f6f7c11390e3ed6d918f1717d8e8b7ae5b7e5c6) +++ sources/applicationcontroller.cpp (.../applicationcontroller.cpp) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -1,29 +1,34 @@ /*! * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. - * \copyright \n - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, \n - * IN PART OR IN WHOLE, \n - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. \n + * \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 - * \date 2019/09/30 - * \author Behrouz NematiPour + * \file applicationcontroller.cpp + * \author (last) Behrouz NematiPour + * \date (last) 25-Aug-2020 + * \author (original) Behrouz NematiPour + * \date (original) 24-Sep-2019 * */ #include "applicationcontroller.h" // Qt +#include +#include // Project -#include "guiglobals.h" #include "maintimer.h" -#include "guicontroller.h" #include "messagedispatcher.h" #include "logger.h" -#include "usbwatcher.h" +#include "DriveWatcher.h" #include "filehandler.h" +#include "guicontroller.h" + +using namespace Storage; + /*! * \brief ApplicationController::ApplicationController * \details Constructor @@ -44,10 +49,11 @@ _init = true; initConnections(); + // coco begin validated: The class ApplicationPost has not been implemented Yet. if (!_applicationPost->init()) return false; + // coco end + LOG_EVENT("UI," + tr("%1 Initialized").arg(metaObject()->className())); - LOG_EVENT(QObject::tr("%1 Initialized").arg(metaObject()->className())); - return true; } @@ -75,7 +81,7 @@ { // coco begin validated: Application termination is not correctly done in coco!!! // it has been tested and works perfectly fine in normal run. - quitThread(); + quitThread(); // validated } // coco end @@ -97,22 +103,30 @@ connect(&_MessageDispatcher, SIGNAL(didActionReceive(GuiActionType, const QVariantList &)), this , SLOT( onActionReceive(GuiActionType, const QVariantList &))); + connect(&_MessageDispatcher, SIGNAL(didFailedTransmit(Sequence)), + this , SLOT( onFailedTransmit(Sequence))); + + // USB drive connect(&_GuiController , SIGNAL(didUSBDriveUmount()), this , SLOT( onUSBDriveUmount())); - connect(&_USBWatcher , SIGNAL(didUSBDriveMount ()), + connect(&_DriveWatcher , SIGNAL(didUSBDriveMount ()), this , SLOT( onUSBDriveMount ())); - connect(&_USBWatcher , SIGNAL(didUSBDriveRemove()), + connect(&_DriveWatcher , SIGNAL(didUSBDriveRemove()), this , SLOT( onUSBDriveRemove())); + // SD Card + connect(&_DriveWatcher , SIGNAL(didSDCardStateChange(bool, bool)), + this , SLOT( onSDCardStateChange(bool, bool))); + + connect(&_GuiController , SIGNAL(didExportLog()), this , SLOT( onExportLog())); - connect(&_Logger , SIGNAL(didExport()), + connect(&_Logger , SIGNAL(didExportLogs()), this , SLOT( onExport())); - connect(&_GuiController , SIGNAL(didAdjustBloodDialysateFlows(quint32, quint32)), - this , SLOT( onAdjustBloodDialysateFlows(quint32, quint32))); - + // ---- Signal/Slots + ADJUST_TRANSMT_MODEL_BRIDGE_CONNECTIONS(_GuiController ) ACTION_RECEIVE_MODEL_BRIDGE_CONNECTIONS(_MessageDispatcher) } @@ -147,11 +161,21 @@ if ( ! _thread ) return; // runs in thread - moveToThread(qApp->thread()); + moveToThread(qApp->thread()); // validated } // coco end /*! + * \brief ApplicationController::onFailedTransmit + * Called when we failed to get a response back from the HD + * \param seq - The sequence that failed to send to the HD. + */ +void ApplicationController::onFailedTransmit(Sequence seq) +{ + emit didFailedTransmit(seq); +} + +/*! * \brief Process the requested action * \details Processes the requested action * \param vAction - User requested Action @@ -186,60 +210,82 @@ /*! * \brief ApplicationController::onUSBDriveMount - * \details This is the slot which connects to the _USBWatcher didUSBDriveMount signal + * \details This is the slot which connects to the _DriveWatcher didUSBDriveMount signal * and notifies the other classes (GuiController) by emitting its signal didUSBDriveMount */ void ApplicationController::onUSBDriveMount () { + // coco begin validated: This needs user interaction to plug-in USB device + // has been tested manually emit didUSBDriveMount(); } +// coco end /*! * \brief ApplicationController::onUSBDriveRemove * \details This is the slot which connects to the _GuiController didUSBDriveUmount signal - * and notifies the other classes (USBWatcher) by emitting its signal didUSBDriveUmount + * and notifies the other classes (DriveWatcher) by emitting its signal didUSBDriveUmount */ void ApplicationController::onUSBDriveUmount() { + // coco begin validated: This needs user interaction to plug-in USB device + // has been tested manually emit didUSBDriveUmount(); } +// coco end /*! * \brief ApplicationController::onUSBDriveRemove - * \details This is the slot which connects to the _USBWatcher didUSBDriveRemove signal + * \details This is the slot which connects to the _DriveWatcher didUSBDriveRemove signal * and notifies the other classes (GuiController) by emitting its signal didUSBDriveRemove */ void ApplicationController::onUSBDriveRemove() { + // coco begin validated: This needs user interaction to plug-in USB device + // has been tested manually emit didUSBDriveRemove(); } +// coco end /*! + * \brief ApplicationController::onSDCardStateChange + * \details This is the slot which connects to the _DriveWatcher didSDCardStateChange signal + * and notifies the other classes (GuiController) by emitting its signal didSDCardStateChange + * \param vIsReady - SdCard is Ready + * \param vIsReadOnly - SdCard is ReadOnly + */ +void ApplicationController::onSDCardStateChange(bool vIsReady, bool vIsReadOnly) +{ + // coco begin validated: This needs user interaction to plug-in SD Card + // has been tested manually + emit didSDCardStateChange(vIsReady, vIsReadOnly); +} +// coco end + +/*! * \brief ApplicationController::onExportLog * \details the slot which will be called by UI to so the log export. */ void ApplicationController::onExportLog() { + // coco begin validated: This needs user interaction to plug-in USB device + // has been tested manually LOG_EXPORT; } +// coco end /*! * \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 + // has been tested manually emit didExport(); } +// coco end -void ApplicationController::onAdjustBloodDialysateFlows(quint32 vBloodFlow, quint32 vDialysateFlow) -{ - QVariantList mData; - mData += vBloodFlow; - mData += vDialysateFlow; - onActionTransmit(GuiActionType::AdjustBloodDialysateReq, mData); -} - /*! * \brief ApplicationController::keepAlive * \details This is the message which has to be send over the CANBUS @@ -250,16 +296,21 @@ #ifndef DISABLE_KEEP_ALIVE QVariantList mData; int mFakeDataLen = gFakeData.length(); + // 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 if (mFakeDataLen) { if (gFakeSeqAtBegin) { createFakeSeqAtBeginLongMessage(mData, mFakeDataLen); } else { createFakeSequencedLongMessage (mData, mFakeDataLen); } - } else { + } + // coco end + else { mData += static_cast(GuiActionData::NoData); } - onActionTransmit(GuiActionType::KeepAlive, mData); + onActionTransmit(GuiActionType::ID_KeepAlive, mData); #endif } @@ -271,6 +322,9 @@ */ void ApplicationController::createFakeSequencedLongMessage(QVariantList &vData, const int vFakeDataLen) { + // 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; if (vFakeDataLen == 1 && gFakeData == QByteArray::fromHex(gFakeData_default)) { static quint16 txCount = 0; @@ -313,6 +367,7 @@ vData += gFakeData; } } +// coco end /*! * \brief ApplicationController::createFakeSequencedAtBeginLongMessage @@ -322,6 +377,9 @@ */ void ApplicationController::createFakeSeqAtBeginLongMessage(QVariantList &vData, const int vFakeDataLen) { + // 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; if (vFakeDataLen == 1 && gFakeData == QByteArray::fromHex(gFakeData_default)) { static quint32 txCount = 0; @@ -370,3 +428,4 @@ vData += gFakeData; } } +// coco end