/*! * * Copyright (c) 2019-2020 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 ApplicationPost.cpp * \author (last) Behrouz NematiPour * \date (last) 08-Sep-2020 * \author (original) Behrouz NematiPour * \date (original) 26-Aug-2020 * */ #include "ApplicationPost.h" // Qt #include #include // Project #include "Logger.h" #include "FileHandler.h" /*! * \brief ApplicationPost::ApplicationPost * \details Constructor * \param parent - QObject parent owner object. * Qt handles the children destruction by their parent objects life-cycle. */ ApplicationPost::ApplicationPost(QObject *parent) : QObject(parent) { } /*! * \brief ApplicationPost::start * \details Starting the post application initialization * \return */ void ApplicationPost::start() { QString postLogFileName = qApp->applicationDirPath() + "/" + Storage::POST_LOG; if (Storage::FileHandler::read(postLogFileName, _content) ) { _isFileSystem = checkFileSystem (); _isCANBus = checkCANBus (); _isDisplay = checkDisplay (); _isTouch = checkTouch (); _isSDCard = checkSDCard (); _isRtc = checkRtc (); _isWiFi = checkWiFi (); _isBluetooth = checkBluetooth (); _isEthernet = checkEthernet (); _isSound = checkSound (); // Please take care that, all of the checks have to be done so they need to be assigned to a variable and then, and them, // otherwise on the first fail rest will not run by compiler optimization. _isDone = _isFileSystem && _isCANBus && _isDisplay && _isTouch && _isSDCard && _isRtc && // _isWiFi && // is not mandatory and the device can still be used without it. Alarm will be triggered to notify user in Active Alarm List., // _isBluetooth && // is not mandatory and the device can still be used without it. Alarm will be triggered to notify user in Active Alarm List., _isEthernet && _isSound ; } else { LOG_EVENT(tr("The POST log file could not be read.")); } emit didDone(_isDone); } /*! * \brief ApplicationPost::checkFileSystem * \details Checks the File System Integrity * \return false if there is an issue [No Implementation yet (always true)]. */ bool ApplicationPost::checkFileSystem() { bool ok = true; //TODO: it will be done after consulting as part of CyberSecurity if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_FILESYSTEM); else emit didFileSystem(); return ok; } /*! * \brief ApplicationPost::checkCANBus * \details Checks the CANBus driver is loaded and the bus is functional * \return false if there is an issue. */ bool ApplicationPost::checkCANBus() { bool ok = _content.contains(_postmsg_canbus); if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_CANBUS); else emit didCANBus(); return ok; } /*! * \brief ApplicationPost::checkDisplay * \details Checks the display driver is loaded * \return false if there is an issue [No Implementation yet (always true)]. */ bool ApplicationPost::checkDisplay() { bool ok = true; //TODO: do the test : not a good test has been found yet. if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_DISPLAY); else emit didDisplay(); return ok; } /*! * \brief ApplicationPost::checkTouchScreen * \details Checks the touch driver is loaded * \return false if there is an issue. */ bool ApplicationPost::checkTouch() { bool ok = _content.contains(_postmsg_touch); if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_TOUCH); else emit didTouch(); return ok; } /*! * \brief ApplicationPost::checkSDCard * \details Checks the SD-Card drive is loaded and functional * \return false if there is an issue. */ bool ApplicationPost::checkSDCard() { bool ok = _content.contains(_postmsg_sdcard); if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_SDCARD); else emit didSDCard(); return ok; } /*! * \brief ApplicationPost::CRC * \details Checks the RTC driver is loaded and functional * \return false if there is an issue */ bool ApplicationPost::checkRtc() { bool ok = _content.contains(_postmsg_rtc); if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_RTC); else emit didRtc(); return ok; } /*! * \brief ApplicationPost::checkWiFi * \details Checks the WiFi driver is loaded and functional * \return false if there is an issue [No Implementation yet (always true)]. */ bool ApplicationPost::checkWiFi() { bool ok = true; //TODO: _content.contains(_postmsg_wifi); if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_WIFI); else emit didWiFi(); return ok; } /*! * \brief ApplicationPost::checkBluetooth * \details Checks the Bluetooth driver is loaded and functional * \return false if there is an issue [No Implementation yet (always false)]. */ bool ApplicationPost::checkBluetooth() { bool ok = _content.contains(_postmsg_bluetooth); if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_BLUETOOTH); else emit didBluetooth(); return ok; } /*! * \brief ApplicationPost::checkEthernet * \details Checks the Ethernet driver is loaded and functional. * \return false if there is an issue [No Implementation yet (always true)]. */ bool ApplicationPost::checkEthernet() { bool ok = true; // do the test : we are not using this for now since it has been removed from the PRS. if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_ETHERNET); else emit didEthernet(); return ok; } /*! * \brief ApplicationPost::checkSound * \details Checks the sound driver is loaded. * \return false if there is an issue [No Implementation yet (always true)]. */ bool ApplicationPost::checkSound() { bool ok = true; // do the test if (! ok) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_SOUND); else emit didSound(); return ok; }