Index: sources/canbus/messagedispatcher.h =================================================================== diff -u -re1605219ac2baf49ef21d0889f845ac53d59c3c1 -r56d00a82669a7a2c00ab90109a89dbec8db27527 --- sources/canbus/messagedispatcher.h (.../messagedispatcher.h) (revision e1605219ac2baf49ef21d0889f845ac53d59c3c1) +++ sources/canbus/messagedispatcher.h (.../messagedispatcher.h) (revision 56d00a82669a7a2c00ab90109a89dbec8db27527) @@ -18,17 +18,18 @@ // Project #include "main.h" -#include "messageglobals.h" #include "messagebuilder.h" #include "messageinterpreter.h" // define -#define _MessageDispatcher MessageDispatcher::I() +#define _MessageDispatcher Can::MessageDispatcher::I() // forward declarations class tst_canbus; -using namespace Gui; +// since this class is the interface between GUI and Can +// it needs to use Gui namespace otherwise it makes code hard to read. +using namespace Gui; namespace Can { /*! * \brief The MessageDispatcher class \n @@ -82,24 +83,36 @@ { Q_OBJECT + // friends + friend class ::tst_canbus; + QHash _messageList; MessageBuilder _builder; MessageInterpreter _interpreter; - // friends - friend class ::tst_canbus; + QThread *_thread = nullptr; + bool _init = false; - // Singleton - SINGLETON(MessageDispatcher) -public: +// Singleton +SINGLETON(MessageDispatcher) + +public slots: bool init(); + bool init(QThread &vThread); + +private slots: void quit(); + +public: void enableConsoleOut(bool vEnable) { _builder.enableConsoleOut(vEnable); } private: void initConnections(); + void initThread(QThread &vThread); + void quitThread(); + void actionTransmit(GuiActionType vActionId, const QVariantList &vData); signals: @@ -119,11 +132,11 @@ * \param vCanId - Target channel of the CANBUS message * \param vPayload - The payload of the message to be sent */ - void didFrameTransmit(Can_Id vCanId , const QByteArray &vPayload); + void didFrameTransmit(Can_Id vCanId , const QByteArray &vPayload); private slots: // A Frame has been received from CanInterface - void onFrameReceive (Can_Id vCanId , const QByteArray &vPayload); + void onFrameReceive (Can_Id vCanId , const QByteArray &vPayload); // An Action has been requested to be transmitted. void onActionTransmit(GuiActionType vActionId, const QVariantList &vData);