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