Index: main.cpp =================================================================== diff -u -r0470ff6f209ff0c5089f8f0849b6da04f60f8f41 -r08ab5b3dbe26b4c7b7bb2ac539b1cfd62a4676c7 --- main.cpp (.../main.cpp) (revision 0470ff6f209ff0c5089f8f0849b6da04f60f8f41) +++ main.cpp (.../main.cpp) (revision 08ab5b3dbe26b4c7b7bb2ac539b1cfd62a4676c7) @@ -7,18 +7,25 @@ * * \file main.cpp * \author (last) Behrouz NematiPour - * \date (last) 03-Aug-2020 + * \date (last) 16-Oct-2020 * \author (original) Behrouz NematiPour * \date (original) 24-Sep-2019 * */ /*! * \mainpage UI Software Design Description - * \section Detailed Description + * \details Detailed Description.\n * This document has been generated by Doxygen.\n * This document describes the detail description of the UI Application Software design.\n - * UI Application starts by Application Initialization which happens in \ref main.cpp "Initialization section".\n + * UI Application starts by Application Initialization which happens in \ref main() "Application Initialization".\n + * For information please see : + * - \ref main() + * - \subpage CommandLineSwitches + * - \subpage DenaliMessageStructure + * - \subpage MessageFlow + * - \subpage GeneralModelsDescription + * - \subpage MessageView */ // Qt @@ -31,17 +38,18 @@ #include // Project -#include "maintimer.h" -#include "caninterface.h" -#include "frameinterface.h" -#include "messageacknowmodel.h" -#include "messagedispatcher.h" -#include "applicationcontroller.h" -#include "guicontroller.h" -#include "logger.h" +#include "MainTimer.h" +#include "CanInterface.h" +#include "FrameInterface.h" +#include "MessageAcknowModel.h" +#include "MessageDispatcher.h" +#include "ApplicationController.h" +#include "GuiController.h" +#include "Logger.h" #include "DriveWatcher.h" -#include "threads.h" #include "BLEScanner.h" +#include "WifiInterface.h" +#include "Threads.h" // kernel #include @@ -73,30 +81,44 @@ bool gDisableUnhandledReport = false ; bool gDisableTimeout = false ; +bool gConsoleoutLogs = false ; bool gConsoleoutFrameInterface = false ; bool gConsoleoutCanInterface = false ; /*! - * \brief commandlineParse - * \details parses the command line arguments \n - * Usage: ./denali [options] \n - * Denali \n - * \n - * Options: \n - * -h, --help Displays this help. \n - * -v, --version Displays version information. \n - * -c, --canOut Show the Can Frame Output \n - * -m, --msgOut Show the Message Output \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 - * -f, --fake-message Test fake message data \n - * will use default sequenced long fake message \n - * if set to 00(default) \n - * will used only if correct intger value \n - * assigned for interval option \n + * \page CommandLineSwitches Denali Command Line Switches + * \verbatim + * Usage: ./denali [options] + * Denali + * + * Options: + * -h, --help Displays this help. + * -v, --version Displays version information. + * -c, --canOut Show the Can Frame Output + * -m, --msgOut Show the Message Output + * -l, --logOut Show the Logs Output + * -0, --enable-keep-awake Enable send low priority, empty message on + * the CANBus just to keep UI board CAN driver + * awake + * -i, --fake-interval Test fake message interval(ms) + * -f, --fake-message Test fake message data + * will use default sequenced long fake message + * if set to 00(default) + * will used only if correct integer value + * assigned for interval option + * -b, --fake-message-seq-at-begin Test fake message sequence at the beginning + * of the frame + * -u, --disable-unhandled-report Disable unhandled messages report as an + * error in the log + * -q, --disable-timeout Disables HD communication timeout + * + * \endverbatim */ +/*! + * \brief commandlineParse + * \details parses the command line arguments + * \ref CommandLineSwitches + */ void commandlineParse() { QCommandLineParser parser; parser.setApplicationDescription(QApplication::applicationName()); @@ -115,6 +137,11 @@ QCoreApplication::translate("main", "Show the Message Output")); parser.addOption(optionConsoleoutFrameInterface); + // --- -m : msgOut + QCommandLineOption optionConsoleoutLogs( + QStringList() << "l" << "logOut", + QCoreApplication::translate("main", "Show the Logs Output")); + parser.addOption(optionConsoleoutLogs); // --- -0 : enable-keep-awake (the fast mode) QCommandLineOption optionSendEmptyKeepAwake(QStringList() << "0" << "enable-keep-awake", @@ -133,13 +160,13 @@ QStringList() << "f" << "fake-message", QCoreApplication::translate("main", "Test fake message data\n" "will use default sequenced long fake message if set to 00(default)\n" - "will used only if correct intger value assigned for interval option"), + "will used only if correct integer value assigned for interval option"), QCoreApplication::translate("main", "data")); parser.addOption(optionFakeData); - // --- -b : fake-message-seq-atbegin + // --- -b : fake-message-seq-at-begin QCommandLineOption optionFakeSeqAtBegin( - QStringList() << "b" << "fake-message-seq-atbegin", + QStringList() << "b" << "fake-message-seq-at-begin", QCoreApplication::translate("main", "Test fake message sequence at the beginning of the frame")); parser.addOption(optionFakeSeqAtBegin); @@ -153,12 +180,12 @@ QCoreApplication::translate("main", "Disables HD communication timeout")); parser.addOption(optionDisableTimeout); - // --- parse command lines parser.process(*qApp); gConsoleoutCanInterface = parser.isSet(optionConsoleoutCanInterface ); gConsoleoutFrameInterface = parser.isSet(optionConsoleoutFrameInterface ); + gConsoleoutLogs = parser.isSet(optionConsoleoutLogs ); gDisableUnhandledReport = parser.isSet(optionDisableUnhandledReport ); gDisableTimeout = parser.isSet(optionDisableTimeout ); @@ -181,44 +208,57 @@ } } } + /*! * \brief setApplicationVersion - * \details sets up the application version regarding the environment valiables + * \details sets up the application version regarding the environment variables * 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; + bool ver_revis_empty = false; + QString ver_major = QString("%1").arg(VER_MAJOR ); + QString ver_minor = QString("%1").arg(VER_MINOR ); + QString ver_micro = QString("%1").arg(VER_MICRO ); + QString ver_revis = QString("%1").arg(VER_REVIS ); + QString ver_branch = QString("%1").arg(VER_BRANCH ); + + if (ver_revis.isEmpty()) { + ver_revis = VER_REVIS_DEV; + ver_revis_empty = true; } - QString ver_minor = QString("%1").arg(VER_MINOR); - if (ver_minor.isEmpty()) { - ver_minor = VER_MINOR_DEV; + + const char * masterbranch = "master"; + bool isOnMaster = !ver_branch.compare(masterbranch); + if (isOnMaster) { + ver_branch = ver_revis_empty ? masterbranch : ""; + ver_major += '.'; + ver_minor += '.'; + ver_micro += '.'; } - QString ver_micro = QString("%1").arg(VER_MICRO); - if (ver_micro.isEmpty()) { - ver_micro = VER_MICRO_DEV; + else { + ver_branch = VER_BRANCH ; + ver_revis = VER_REVIS_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)); + if ( ! ver_branch.isEmpty()) ver_branch += '.'; + QCoreApplication::setApplicationVersion( + QString("%1%2%3%4%5") + .arg(ver_branch) + .arg(ver_major) + .arg(ver_minor) + .arg(ver_micro) + .arg(ver_revis)); } #ifdef UNIT_TEST #include TEST_CLASS_INCLUDE QTEST_MAIN(TEST_CLASS_NAME) #else -/*! \brief Application Initialization\n - * Some part of the application need to be initialized out of any thread. - * So is initialized here to be initialized in the main thread. - * this section also includes: +/*! + * \brief Application Initialization + * \details Some part of the application need to be initialized out of any thread. + * So is initialized here to be initialized in the main thread. + * this section also includes: */ int main(int argc, char *argv[]) { @@ -228,6 +268,8 @@ signal(SIGTERM, signalhandler); #endif + qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard")); + //! - Qt Application initialization and parameters settings // Qt Core Application parameters settings QApplication::setApplicationName(QLatin1String("Denali")); @@ -257,7 +299,9 @@ Threads::registerTypes(); //! - Initializing Logger - _Logger.init(Threads::_Logger_Thread); + if(_Logger.init(Threads::_Logger_Thread)) { + _Logger.enableConsoleOut(gConsoleoutLogs); + } LOG_EVENT("UI," + QObject::tr("Application %1 Started,%2") .arg(app.applicationName ()) @@ -272,28 +316,32 @@ " \n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "); } - //! - Initializing USB Watcher + //! - Initializing the Drive Watcher _DriveWatcher.init(Threads::_DriveWatcher_Thread); - //! - Initializing CanBus Interface + //! - Initializing the CANBus Interface if (_CanInterface.init(Threads::_CanFrame_Thread)) { _CanInterface.enableConsoleOut(gConsoleoutCanInterface); } - //! - Initializing CanBus Message Handler + //! - Initializing the CANBus Message Handler _FrameInterface.init(Threads::_CanFrame_Thread); - //! - Initializing the CanBus Message Acknowledgment Model + //! - Initializing the CANBus Message Acknowledgment Model _MessageAcknowModel.init(Threads::_CanAcknow_Thread); - //! - Initializing CanBus Message Dispatcher + //! - Initializing the CANBus Message Dispatcher if (_MessageDispatcher.init(Threads::_CanMessage_Thread)) { _MessageDispatcher.enableConsoleOut(gConsoleoutFrameInterface); } //! - Initializing BLE Interface - _BLEScanner.init(); + _BLEScanner.doInit(); + //! - Initializing Wifi Interface + _WifiInterface.init(Threads::_Wifi_Thread); + _WifiInterface.start(); + //! - Initializing Application Controller _ApplicationController.init(Threads::_Application_Thread); @@ -303,8 +351,7 @@ //! - Initializing Main Timer _MainTimer.init(); - - //! - Initialize the Qml Viewer and starts GUI + //! - Initialize the QML Viewer and starts GUI int app_exec = -1; LOG_DEBUG("UI Initializing"); if ( startGui() ) {