Index: main.cpp =================================================================== diff -u -rd3edfbd78f021082f37c7ee79a5a31a57b2808d4 -r44a85c96ab55e424866ec4cca0270aa218355f82 --- main.cpp (.../main.cpp) (revision d3edfbd78f021082f37c7ee79a5a31a57b2808d4) +++ main.cpp (.../main.cpp) (revision 44a85c96ab55e424866ec4cca0270aa218355f82) @@ -1,15 +1,16 @@ /*! - * + * * 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 - * - * \file main.cpp - * \date 2019/09/30 - * \author Behrouz NematiPour - * + * \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 main.cpp + * \author (last) Peter Lucia + * \date (last) 26-Jun-2020 + * \author (original) Behrouz NematiPour + * \date (original) 24-Sep-2019 + * */ /*! @@ -27,6 +28,7 @@ #include #include #include +#include // Project #include "maintimer.h" @@ -65,9 +67,10 @@ int gFakeInterval = 0 ; QByteArray gFakeData = "" ; const char *gFakeData_default = "00" ; -bool gSendEmptyKeepAwake = true ; +bool gSendEmptyKeepAwake = false ; bool gFakeSeqAtBegin = false ; bool gDisableHunhandledReport = false ; +bool gDisableTimeout = false ; bool gConsoleoutFrameInterface = false ; bool gConsoleoutCanInterface = false ; @@ -83,7 +86,7 @@ * -v, --version Displays version information. \n * -c, --canOut Show the Can Frame Output \n * -m, --msgOut Show the Message Output \n - * -0, --disable-keep-awake Disable send low priority, empty message on \n + * -0, --enable-keep-awake Enable send low priority, empty message on \n * the CANBus just to keep UI board CAN driver \n * awake \n * -i, --fake-interval Test fake message interval(ms) \n @@ -99,31 +102,32 @@ parser.addHelpOption(); parser.addVersionOption(); - // --- + // --- -c : canOut QCommandLineOption optionConsoleoutCanInterface( QStringList() << "c" << "canOut", QCoreApplication::translate("main", "Show the Can Frame Output")); parser.addOption(optionConsoleoutCanInterface); - // --- + // --- -m : msgOut QCommandLineOption optionConsoleoutFrameInterface( QStringList() << "m" << "msgOut", QCoreApplication::translate("main", "Show the Message Output")); parser.addOption(optionConsoleoutFrameInterface); - // --- - QCommandLineOption optionSendEmptyKeepAwake(QStringList() << "0" << "disable-keep-awake", - QCoreApplication::translate("main", "Disable send low priority, empty message on the CANBus just to keep UI board CAN driver awake")); + + // --- -0 : enable-keep-awake (the fast mode) + QCommandLineOption optionSendEmptyKeepAwake(QStringList() << "0" << "enable-keep-awake", + QCoreApplication::translate("main", "Enable send low priority, empty message on the CANBus just to keep UI board CAN driver awake")); parser.addOption(optionSendEmptyKeepAwake); - // --- + // --- -i : fake-interval QCommandLineOption optionFakeInterval( QStringList() << "i" << "fake-interval", QCoreApplication::translate("main", "Test fake message interval(ms)"), QCoreApplication::translate("main", "interval")); parser.addOption(optionFakeInterval); - // --- + // --- -f : fake-message QCommandLineOption optionFakeData( QStringList() << "f" << "fake-message", QCoreApplication::translate("main", "Test fake message data\n" @@ -132,26 +136,32 @@ QCoreApplication::translate("main", "data")); parser.addOption(optionFakeData); - // --- + // --- -b : fake-message-seq-atbegin QCommandLineOption optionFakeSeqAtBegin( QStringList() << "b" << "fake-message-seq-atbegin", QCoreApplication::translate("main", "Test fake message sequence at the beginning of the frame")); parser.addOption(optionFakeSeqAtBegin); - // --- + // --- -u : disable-unhandled-report QCommandLineOption optionDisableHunhandledReport(QStringList() << "u" << "disable-unhandled-report", QCoreApplication::translate("main", "Disable unhandled messages report as an error in the log")); parser.addOption(optionDisableHunhandledReport); + // --- -u : disable-unhandled-report + QCommandLineOption optionDisableTimeout(QStringList() << "q" << "disable-timeout", + QCoreApplication::translate("main", "Disables HD communication timeout")); + parser.addOption(optionDisableTimeout); - // --- + + // --- parse command lines parser.process(*qApp); gConsoleoutCanInterface = parser.isSet(optionConsoleoutCanInterface ); gConsoleoutFrameInterface = parser.isSet(optionConsoleoutFrameInterface ); gDisableHunhandledReport = parser.isSet(optionDisableHunhandledReport ); + gDisableTimeout = parser.isSet(optionDisableTimeout ); - if (parser.isSet(optionSendEmptyKeepAwake)) gSendEmptyKeepAwake = false; + if (parser.isSet(optionSendEmptyKeepAwake)) gSendEmptyKeepAwake = true; bool ok = false; if (parser.isSet(optionFakeInterval)) { @@ -170,6 +180,35 @@ } } } +/*! + * \brief setApplicationVersion + * \details sets up the application version regarding the environment valiables + * which are set by bamboo and if those are not set value of 0 will be used + * and revision(build) version will be set to current date/time. + */ +void setApplicationVersion() { + QString ver_major = QString("%1").arg(VER_MAJOR); + if (ver_major.isEmpty()) { + ver_major = VER_MAJOR_DEV; + } + QString ver_minor = QString("%1").arg(VER_MINOR); + if (ver_minor.isEmpty()) { + ver_minor = VER_MINOR_DEV; + } + QString ver_micro = QString("%1").arg(VER_MICRO); + if (ver_micro.isEmpty()) { + ver_micro = VER_MICRO_DEV; + } + QString ver_revis = QString("%1").arg(VER_REVIS); + if (ver_revis.isEmpty()) { + ver_revis = VER_REVIS_DEV; + } + QCoreApplication::setApplicationVersion(QString("%1.%2.%3.%4") + .arg(ver_major) + .arg(ver_minor) + .arg(ver_micro) + .arg(ver_revis)); +} #ifdef UNIT_TEST #include TEST_CLASS_INCLUDE @@ -201,14 +240,7 @@ app.thread()->setObjectName("Main Thread"); //! - Setting the application version regarding the Bamboo build number. - QString ver_revis = QString("%1").arg(VER_REVIS); - if (ver_revis.isEmpty()) { - ver_revis = QString("%1").arg(VER_DEVEL); - } - QCoreApplication::setApplicationVersion(QString("%1.%2.%3") - .arg(VER_MAJOR) - .arg(VER_MINOR) - .arg(ver_revis)); + setApplicationVersion(); //! - Parse the command line arguments commandlineParse(); @@ -264,10 +296,11 @@ _MainTimer.init(); //! - Initialize the Qml Viewer and starts GUI - startGui(); + int app_exec = -1; + if ( startGui() ) { + app_exec = app.exec(); + } - int app_exec = app.exec(); - // Due to Qt Error the CAN Device cannot be disable/enable from withing another thread // (other than main thread which is the owner of the CanDevice). // So it needs to be done here in main thread.