/*! * * Copyright (c) 2020-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 Threads.cpp * \author (last) Behrouz NematiPour * \date (last) 18-Jul-2023 * \author (original) Behrouz NematiPour * \date (original) 26-Aug-2020 * */ #include "Threads.h" // Qt #include #include // Application #include "MessageGlobals.h" /*! * \details All the Thread has been and shall be defined in here * And will be assigned to a required class from main thread. * \note quitThreads() needs to be called when the application execution event loop is done * this has currently been done in main.cpp in main() after the qpp.exe() is done. */ namespace Threads { QThread _CanFrame_Thread ; QThread _CanAcknow_Thread ; QThread _CanMessage_Thread ; QThread _DeviceController_Thread; QThread _Logger_Thread ; QThread _Application_Thread ; QThread _Gui_Thread ; QThread _Wifi_Thread ; QThread _Bluetooth_Thread ; QThread _CloudSync_Thread ; /*! * \brief registerTypes * \details this method has to be called before any class which uses these types * and also is handled by threads * It seems qt is using the meta objects for threading signal/slots * and it requires any type which has been used in this context to be registered. */ void registerTypes() { // Logger : This is required for Signal/Slots in threading. qRegisterMetaType("LogType"); qRegisterMetaType("Logger::LogType"); // CanInterface : This is required for Signal/Slots in threading. qRegisterMetaType("QCanBusFrame"); // FrameInterface : This is required for Signal/Slots in threading. qRegisterMetaType("Can_Id"); // MessageAcknowModel : This is required for Signal/Slots in threading. qRegisterMetaType("Sequence"); // MessageAcknowModel : This is required for Signal/Slots in threading. qRegisterMetaType("FrameList"); } /*! * \brief quitThread * \details quits the thread vThread and wait for it to be destroyed. * \param vThread - the thread */ void quitThread(QThread &vThread) { vThread.quit(); // validated vThread.wait(); // validated } /*! * \brief quitThreads * \details quits the list of the threads which has been defined * int the Threads namespace * \note It requires to be updated by developer if any more thread has been added */ void quitThreads() { quitThread(_CloudSync_Thread ); quitThread(_CanFrame_Thread ); quitThread(_CanAcknow_Thread ); quitThread(_CanMessage_Thread ); quitThread(_DeviceController_Thread ); quitThread(_Bluetooth_Thread ); quitThread(_Wifi_Thread ); quitThread(_Application_Thread ); quitThread(_Gui_Thread ); quitThread(_Logger_Thread ); } }