Index: denali.pro.user =================================================================== diff -u -r94f7349bd073a732dba5295250fc0e26f740743c -r2b00ad4142892e8d9e768ef58f139611e9d670c0 --- denali.pro.user (.../denali.pro.user) (revision 94f7349bd073a732dba5295250fc0e26f740743c) +++ denali.pro.user (.../denali.pro.user) (revision 2b00ad4142892e8d9e768ef58f139611e9d670c0) @@ -1,14 +1,14 @@ - + EnvironmentId {67370740-e20f-4fc6-be45-6652e866a8bf} ProjectExplorer.Project.ActiveTarget - 0 + 1 ProjectExplorer.Project.EditorSettings @@ -999,7 +999,7 @@ true false - + /home/denali/Project/tmp/build/denali-Desktop_Qt_5_12_5_GCC_64bit-Debug 1 Index: main.cpp =================================================================== diff -u -r805119c460b4a266d6401c8705f4427e7fbe270f -r2b00ad4142892e8d9e768ef58f139611e9d670c0 --- main.cpp (.../main.cpp) (revision 805119c460b4a266d6401c8705f4427e7fbe270f) +++ main.cpp (.../main.cpp) (revision 2b00ad4142892e8d9e768ef58f139611e9d670c0) @@ -38,7 +38,9 @@ #include "logger.h" #include "usbwatcher.h" #include "threads.h" +#include "filehandler.h" + #include /*! * \brief signalhandler @@ -59,6 +61,49 @@ } } +int gFakeInterval; +QString gFakeData; +bool gConsoleoutFrameInterface = false; +bool gConsoleoutCanInterface = false; + +/*! + * \brief enableFakeTestData + * \details reads the test.dat from the application folder and sets the global variables + * also regarding the command line arguments passed to the application sets the console out. + */ +void enableFakeTestData() { + QString mContent; + QString mTestDat = QApplication::applicationDirPath() + "/test.dat"; + qDebug() << mTestDat; + if (Storage::FileHandler::read(mTestDat, mContent)) { + QStringList mLines = mContent.split('\n'); + if (mLines.count() > 1) { + bool ok = false; + QString mInterval = mLines[0]; + int interval = mInterval.toInt(&ok); + if (ok) { + gFakeInterval = interval; + } + gFakeData = mLines[1]; + gFakeData = QByteArray::fromHex(gFakeData.toLatin1()); + qDebug() << " ~~ !!!!! APPLICATION RUNNING IN THE TEST MODE !!!!! ~~ " ; + LOG_EVENT(" \n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ " + " \n ~~ !!!!! APPLICATION RUNNING IN THE TEST MODE !!!!! ~~ " + " \n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "); + + } + } + + QStringList args = qApp->arguments(); + if (args.length() >= 2) { + gConsoleoutFrameInterface = args[1] == "1"; + } + if (args.length() >= 3) { + gConsoleoutCanInterface = args[2] == "1"; + } + +} + #ifdef UNIT_TEST #include TEST_CLASS_INCLUDE QTEST_MAIN(TEST_CLASS_NAME) @@ -88,17 +133,6 @@ QApplication app(argc, argv); app.thread()->setObjectName("Main Thread"); - // Test code for debugging can messages - bool _consoleoutFrameInterface = false; - bool _consoleoutCanInterface = false; - QStringList args = app.arguments(); - if (args.length() >= 2) { - _consoleoutFrameInterface = args[1] == "1"; - } - if (args.length() >= 3) { - _consoleoutCanInterface = args[2] == "1"; - } - //! - Setting the application version regarding the Bamboo build number. QString ver_revis = QString("%1").arg(VER_REVIS); if (ver_revis.isEmpty()) { @@ -124,12 +158,15 @@ LOG_EVENT(QObject::tr("Application Started")); + // Test code for debugging can messages + enableFakeTestData(); + //! - Initializing USB Watcher _USBWatcher.init(Threads::_USBWatcher_Thread); //! - Initializing CanBus Interface if (_CanInterface.init(Threads::_CanFrame_Thread)) { - _CanInterface.enableConsoleOut(_consoleoutCanInterface); + _CanInterface.enableConsoleOut(gConsoleoutCanInterface); } //! - Initializing CanBus Message Handler @@ -140,7 +177,7 @@ //! - Initializing CanBus Message Dispatcher if (_MessageDispatcher.init(Threads::_CanMessage_Thread)) { - _MessageDispatcher.enableConsoleOut(_consoleoutFrameInterface); + _MessageDispatcher.enableConsoleOut(gConsoleoutFrameInterface); } //! - Initializing Application Controller Index: sources/applicationcontroller.cpp =================================================================== diff -u -r805119c460b4a266d6401c8705f4427e7fbe270f -r2b00ad4142892e8d9e768ef58f139611e9d670c0 --- sources/applicationcontroller.cpp (.../applicationcontroller.cpp) (revision 805119c460b4a266d6401c8705f4427e7fbe270f) +++ sources/applicationcontroller.cpp (.../applicationcontroller.cpp) (revision 2b00ad4142892e8d9e768ef58f139611e9d670c0) @@ -236,7 +236,11 @@ { #ifndef DISABLE_KEEP_ALIVE QVariantList mData; - mData += static_cast(GuiActionData::NoData); + if (gFakeData.length()) { + mData += gFakeData; + } else { + mData += static_cast(GuiActionData::NoData); + } onActionTransmit(GuiActionType::KeepAlive, mData); #endif } Index: sources/canbus/caninterface.cpp =================================================================== diff -u -r94f7349bd073a732dba5295250fc0e26f740743c -r2b00ad4142892e8d9e768ef58f139611e9d670c0 --- sources/canbus/caninterface.cpp (.../caninterface.cpp) (revision 94f7349bd073a732dba5295250fc0e26f740743c) +++ sources/canbus/caninterface.cpp (.../caninterface.cpp) (revision 2b00ad4142892e8d9e768ef58f139611e9d670c0) @@ -328,6 +328,7 @@ case QCanBusDevice::ConfigurationError: case QCanBusDevice::UnknownError: _canStatus = _canDevice->errorString(); + LOG_ERROR(_canStatus); break; default: break; @@ -343,10 +344,15 @@ * \param vFramesCount - The framesCount argument is set to the number of frames * that were written in this payload. */ -void CanInterface::onFrameWritten(qint64 /*vFramesCount*/) +void CanInterface::onFrameWritten(qint64 vFramesCount) { - //_txFrameCount = vFramesCount; - //qDebug() << "onFrameWritten::FramesCount : " << vFramesCount; + static FrameCount mFrameCount = 0; + if ( mFrameCount + vFramesCount <= FrameCount_MAX ) { + mFrameCount += vFramesCount; + } else { + mFrameCount = vFramesCount - (FrameCount_MAX - vFramesCount); + } + qDebug() << mFrameCount; } /*! Index: sources/canbus/messageglobals.h =================================================================== diff -u -r426208cdb707400759bdc663b871ece9d1208aed -r2b00ad4142892e8d9e768ef58f139611e9d670c0 --- sources/canbus/messageglobals.h (.../messageglobals.h) (revision 426208cdb707400759bdc663b871ece9d1208aed) +++ sources/canbus/messageglobals.h (.../messageglobals.h) (revision 2b00ad4142892e8d9e768ef58f139611e9d670c0) @@ -37,7 +37,7 @@ */ const QHash payloadLen { {Gui::GuiActionType::PowerOff , 1 }, - {Gui::GuiActionType::KeepAlive , 0 }, + {Gui::GuiActionType::KeepAlive , 255 }, // 0 => 255 to be able to run a multi-frame test. {Gui::GuiActionType::BloodFlow , 7 * 4 }, // 7 parameters each 4bytes {Gui::GuiActionType::DialysateInletFlow , 7 * 4 }, // 7 parameters each 4bytes {Gui::GuiActionType::DialysateOutletFlow, 7 * 4 }, // 7 parameters each 4bytes Index: sources/canbus/messageinterpreter.cpp =================================================================== diff -u -r426208cdb707400759bdc663b871ece9d1208aed -r2b00ad4142892e8d9e768ef58f139611e9d670c0 --- sources/canbus/messageinterpreter.cpp (.../messageinterpreter.cpp) (revision 426208cdb707400759bdc663b871ece9d1208aed) +++ sources/canbus/messageinterpreter.cpp (.../messageinterpreter.cpp) (revision 2b00ad4142892e8d9e768ef58f139611e9d670c0) @@ -65,6 +65,9 @@ // Nothing needs to be done. // KeepAlive has No data. // Mentioned in the switch/case to be registered as a valid message. + + // Note : added this line to be able to do the Fake Test + vPayload = Format::fromVariant(vData[0]); break; case Gui::GuiActionType::Acknow: Index: sources/gui/guiview.h =================================================================== diff -u -rc6a09899d2e46dc0bda5a6b994aa257953626f97 -r2b00ad4142892e8d9e768ef58f139611e9d670c0 --- sources/gui/guiview.h (.../guiview.h) (revision c6a09899d2e46dc0bda5a6b994aa257953626f97) +++ sources/gui/guiview.h (.../guiview.h) (revision 2b00ad4142892e8d9e768ef58f139611e9d670c0) @@ -25,7 +25,7 @@ // namespace namespace Gui { -class GuiView : public QQuickItem +class GuiView : public QObject { Q_OBJECT Index: sources/main.h =================================================================== diff -u -rc6a09899d2e46dc0bda5a6b994aa257953626f97 -r2b00ad4142892e8d9e768ef58f139611e9d670c0 --- sources/main.h (.../main.h) (revision c6a09899d2e46dc0bda5a6b994aa257953626f97) +++ sources/main.h (.../main.h) (revision 2b00ad4142892e8d9e768ef58f139611e9d670c0) @@ -40,3 +40,6 @@ static vCLASS _instance; \ return _instance; \ } + +extern int gFakeInterval; +extern QString gFakeData; Index: sources/maintimer.cpp =================================================================== diff -u -r8c69137f18382bdc55a5678e6ed44a7683fe4dea -r2b00ad4142892e8d9e768ef58f139611e9d670c0 --- sources/maintimer.cpp (.../maintimer.cpp) (revision 8c69137f18382bdc55a5678e6ed44a7683fe4dea) +++ sources/maintimer.cpp (.../maintimer.cpp) (revision 2b00ad4142892e8d9e768ef58f139611e9d670c0) @@ -17,6 +17,7 @@ //Project #include "logger.h" +#include "filehandler.h" /*! * \brief MainTimer::MainTimer @@ -33,7 +34,11 @@ */ bool MainTimer::init() { - startTimer(_interval); + if (gFakeInterval) { + startTimer(gFakeInterval); + } else { + startTimer(_interval); + } LOG_EVENT(QObject::tr("Main Timer Initialized")); return true; }