Index: sources/applicationcontroller.cpp =================================================================== diff -u -rde2f87e15fa05b1c45581cfedd8f1af0c47c2b48 -rc933552983a659ca4cc351ff4d43d07319adab1e --- sources/applicationcontroller.cpp (.../applicationcontroller.cpp) (revision de2f87e15fa05b1c45581cfedd8f1af0c47c2b48) +++ sources/applicationcontroller.cpp (.../applicationcontroller.cpp) (revision c933552983a659ca4cc351ff4d43d07319adab1e) @@ -17,8 +17,9 @@ // Project #include "guiglobals.h" +#include "maintimer.h" #include "guicontroller.h" -#include "messagehandler.h" +#include "messagedispatcher.h" // Singleton SINGLETON_INIT(ApplicationController) @@ -41,84 +42,69 @@ { if (!_fileHandler ->init()) return false; if (!_applicationPost->init()) return false; - connection(); + initConnections(); return true; } /*! * \brief GUI Controller connections definition */ -void ApplicationController::connection() +void ApplicationController::initConnections() { - // From GUI - connect(_GuiController , SIGNAL(didActionRequest(GuiActionType)), - this , SLOT( onActionRequest(GuiActionType))); - // From GUI - connect(_GuiController , SIGNAL(didActionPerform(GuiActionType,GuiActionInfo)), - this , SLOT( onActionPerform(GuiActionType, GuiActionInfo))); + connect(_MainTimer , SIGNAL( didTimeout()), + this , SLOT(onMainTimerTimeout())); + + // From GUI + connect(_GuiController , SIGNAL(didActionTransmit(GuiActionType, const QVariantList &)), + this , SLOT( onActionTransmit(GuiActionType, const QVariantList &))); // From HD/DG - connect(_MessageHandler, SIGNAL(didActionCommand(GuiActionType)), - this , SLOT( onActionCommand(GuiActionType))); - // From HD/DG - connect(_MessageHandler, SIGNAL(didActionConfirm(GuiActionType,GuiActionInfo)), - this , SLOT( onActionConfirm(GuiActionType, GuiActionInfo))); + connect(_MessageDispatcher, SIGNAL(didActionReceive(GuiActionType, const QVariantList &)), + this , SLOT( onActionReceive(GuiActionType, const QVariantList &))); } - /*! * \brief Process the requested action * \details Processes the requested action * \param vAction - User requested Action */ -void ApplicationController::onActionRequest(GuiActionType vAction) +void ApplicationController::onActionTransmit(GuiActionType vAction, const QVariantList &vData) { - // qDebug() << "ApplicationController.actionRequested : " << vAction; - // Process the requested action by GUI - // Process ... - emit didActionRequest(vAction); + emit didActionTransmit(vAction, vData); } /*! - * \brief Process the performed action - * \details An action which has been commanded by HD has been performed by GUI.\n - * GUI notifies that the action has been performed + * \brief An action has been confirmed + * \details GUI requested an action. + * In response HD confirmed the action. * \param vAction - * \param vInfo + * \param vData */ -void ApplicationController::onActionPerform(GuiActionType vAction, GuiActionInfo vInfo) +void ApplicationController::onActionReceive (GuiActionType vAction, const QVariantList &vData) { - // qDebug() << "ApplicationController.actionPerformed : " << vAction << vInfo; - // Process the performed action by GUI - // Process ... - emit didActionPerform(vAction, vInfo); + emit didActionReceive (vAction, vData); } /*! - * \brief Action commanded by HD - * \details An action has been commanded by HD, - * GUI requires to be notified to perform the action. - * \param vAction + * \brief ApplicationController::onMainTimerTimeout + * \details This slot is called by MainTimer::didTimeout each second + * to call required methods like keepAlive */ -void ApplicationController::onActionCommand(GuiActionType vAction) +void ApplicationController::onMainTimerTimeout() { - // qDebug() << "ApplicationController.actionCommanded : " << vAction; - // Process the command and notify GUI Controller - // Process ... - emit didActionCommand(vAction); + keepAlive(); } /*! - * \brief An action has been confirmed - * \details GUI requested an action. - * In response HD confirmed the action. - * \param vAction - * \param vInfo + * \brief ApplicationController::keepAlive + * \details This is the message which has to be send over the CANBUS + * as an monitor for other nodes on the bus to notify UI is alive */ -void ApplicationController::onActionConfirm(GuiActionType vAction, GuiActionInfo vInfo) +void ApplicationController::keepAlive() { - // qDebug() << "ApplicationController.actionConfirmed : " << vAction; - // Process the command and notify GUI Controller - // Process ... - emit didActionConfirm(vAction, vInfo); +#ifndef DISABLE_KEEP_ALIVE + QVariantList mData; + mData += static_cast(GuiActionData::NoData); + onActionTransmit(GuiActionType::KeepAlive, mData); +#endif }