/*! * * Copyright (c) 2019-2024 Diality Inc. - All Rights Reserved. * \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) Behrouz NematiPour * \date (last) 09-Feb-2024 * \author (original) Behrouz NematiPour * \date (original) 24-Sep-2019 * */ /*! * \mainpage UI Software Design 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() "Application Initialization".\n * For information please see : * - \ref main() * - \subpage CommandLineSwitches * - \subpage DenaliMessageStructure * - \subpage MessageFlow * - \subpage GeneralModelsDescription * - \subpage MessageView */ // Qt #include #include #include #include #include #include #include // FW #include "Compatible.h" // Project #include "FileHandler.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 "DeviceController.h" #include "WifiInterface.h" #include "BluetoothInterface.h" #include "CloudSyncController.h" #include "Threads.h" // kernel #include /*! * \brief signalhandler * \details When application terminates it quits gracefully. * \param sig - The Linux signal causes the termination. */ void signalhandler(int sig) { if (sig == SIGINT) { qDebug() << QObject::tr("Application terminated by SIGINT"); qApp->quit(); } else if (sig == SIGTERM) { qDebug() << QObject::tr("Application terminated by SIGTERM"); qApp->quit(); } } int gFakeInterval = 0 ; QByteArray gFakeData = "" ; const char *gFakeData_default = "00" ; bool gSendEmptyKeepAwake = false ; bool gFakeSeqAtBegin = false ; bool gDisableUnhandledReport = false ; bool gDisableDialinUnhandled = false ; bool gDisableTimeout = false ; bool gDisableAlarmNoMinimize = false ; bool gDisableSDCFailLogStop = false ; bool gDisableCloudSyncFailStop = false ; bool gDisableCheckInLog = false ; bool gDisableAcknowLog = false ; bool gConsoleoutLogs = false ; bool gConsoleoutFrameInterface = false ; bool gConsoleoutCanInterface = false ; bool gEnableDryDemo = false ; QString gActiveCANBus = "can0"; bool gEnableManufacturing = false ; bool gEnableUpdating = false ; bool gUseRootHome = false ; bool gLongLogName = false ; QString gParserErrorText = ""; QString gStandard_tmp = QString("/%1/").arg("tmp"); /*! * \page CommandLineSwitches Denali Command Line Switches * \verbatim * Usage: ./denali [options] * Denali * * Options: * -h, --help Displays help on commandline options. * --help-all Displays help including Qt specific * options. * -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 * -d, --disable-dialin-unhandled Disable the Dialin messages logged as * unhandled * -q, --disable-timeout Disables HD communication timeout * -a, --disable-alarm-no-minimize Disables alarm no minimize * -S, --disable-sd-card-fail-log-stop disable-sd-card-fail-log-stop * -C, --disable-cloudsync-fail-stop disable-cloudsync-fail-stop * -k, --disable-check-in-log Disables Check-In Log * -K, --disable-acknow-log Disables Acknowledgment Log * -D, --enable-dry-demo Enables Dry-Demo Mode * -A, --active-can-bus Sets the Active CANBus [Shall start with * 'can' or 'vcan] * -E, --enable-manufacturing Enables the manufacturing mode to * configure the system for the first time. * -R, --use-root-home In case the application is not in * Manufacturing Setup but needs to use root * home folder for configurations. * -U, --enable-Update-mode Enables the update mode to update only * necessary files during the update and * keep the rest. * \endverbatim */ /*! * \brief commandlineParse * \details parses the command line arguments * \ref CommandLineSwitches */ void commandlineParse() { QCommandLineParser parser; parser.setApplicationDescription(QApplication::applicationName()); 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); // --- -l : logOut 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", 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" "will use default sequenced long fake message if set to 00(default)\n" "will used only if correct integer value assigned for interval option"), QCoreApplication::translate("main", "data")); parser.addOption(optionFakeData); // --- -b : fake-message-seq-at-begin QCommandLineOption optionFakeSeqAtBegin( QStringList() << "b" << "fake-message-seq-at-begin", QCoreApplication::translate("main", "Test fake message sequence at the beginning of the frame")); parser.addOption(optionFakeSeqAtBegin); // --- -u : disable-unhandled-report QCommandLineOption optionDisableUnhandledReport( QStringList() << "u" << "disable-unhandled-report", QCoreApplication::translate("main", "Disable unhandled messages report as an error in the log")); parser.addOption(optionDisableUnhandledReport); // --- -d : disable-dialin-unhandled QCommandLineOption optionDisableDialinUnhandled( QStringList() << "d" << "disable-dialin-unhandled", QCoreApplication::translate("main", "Disable the Dialin messages logged as unhandled")); parser.addOption(optionDisableDialinUnhandled); // --- -q : disable-timeout QCommandLineOption optionDisableTimeout( QStringList() << "q" << "disable-timeout", QCoreApplication::translate("main", "Disables HD communication timeout")); parser.addOption(optionDisableTimeout); // --- -a : disable-alarm-no-minimize QCommandLineOption optionDisableAlarmMoMinimize( QStringList() << "a" << "disable-alarm-no-minimize", QCoreApplication::translate("main", "Disables alarm no minimize")); parser.addOption(optionDisableAlarmMoMinimize); // --- -S : disable-sd-card-fail-log-stop QCommandLineOption optionDisableSDCardFailLogStop( QStringList() << "S" << "disable-sd-card-fail-log-stop", QCoreApplication::translate("main", "disable-sd-card-fail-log-stop")); parser.addOption(optionDisableSDCardFailLogStop); // --- -C : disable-cloudsync-fail-stop QCommandLineOption optionDisableCloudSyncFailStop( QStringList() << "C" << "disable-cloudsync-fail-stop", QCoreApplication::translate("main", "disable-cloudsync-fail-stop")); parser.addOption(optionDisableCloudSyncFailStop); // --- -k : disable-Check-in-log (keep-alive) QCommandLineOption optionDisableCheckInLog( QStringList() << "k" << "disable-check-in-log", QCoreApplication::translate("main", "Disables Check-In Log")); parser.addOption(optionDisableCheckInLog); // --- -K : disable-acknow-log (Acknowledge) QCommandLineOption optionDisableAcknowLog( QStringList() << "K" << "disable-acknow-log", QCoreApplication::translate("main", "Disables Acknowledgment Log")); parser.addOption(optionDisableAcknowLog); // --- -D : enable-dry-demo QCommandLineOption optionEnableDryDemo( QStringList() << "D" << "enable-dry-demo", QCoreApplication::translate("main", "Enables Dry-Demo Mode")); parser.addOption(optionEnableDryDemo); // --- -A : active-can-bus QCommandLineOption optionActiveCANBus( QStringList() << "A" << "active-can-bus", QCoreApplication::translate("main", "Sets the Active CANBus [Shall start with 'can' or 'vcan]"), QCoreApplication::translate("main", "CANBus")); parser.addOption(optionActiveCANBus); // --- -E : enable-manufacturing QCommandLineOption optionEnableManufacturing( QStringList() << "E" << "enable-manufacturing", QCoreApplication::translate("main", "Enables the manufacturing mode to configure the system for the first time.")); parser.addOption(optionEnableManufacturing); // --- -R : use-root-home QCommandLineOption optionUseRootHome( QStringList() << "R" << "use-root-home", QCoreApplication::translate("main", "In case the application is not in Manufacturing Setup but needs to use root home folder for configurations.")); parser.addOption(optionUseRootHome); // --- -U : Update mode QCommandLineOption optionEnableUpdating( QStringList() << "U" << "enable-update-mode", QCoreApplication::translate("main", "Enables the update mode to update only necessary files during the update and keep the rest.")); parser.addOption(optionEnableUpdating); // --- -L : use-long-log-name QCommandLineOption optionLongLogName( QStringList() << "L" << "use-long-log-name", QCoreApplication::translate("main", "Use the log file name format\n_