Index: sources/canbus/MessageDispatcher.cpp =================================================================== diff -u -rf91ee3bac4f77fc7a0fe8d122c8c49b34b6984ec -rc0b30f1fa82d0121706351057ab52b3bb1141459 --- sources/canbus/MessageDispatcher.cpp (.../MessageDispatcher.cpp) (revision f91ee3bac4f77fc7a0fe8d122c8c49b34b6984ec) +++ sources/canbus/MessageDispatcher.cpp (.../MessageDispatcher.cpp) (revision c0b30f1fa82d0121706351057ab52b3bb1141459) @@ -19,6 +19,8 @@ #include // Project +#include "Logger.h" +#include "ApplicationController.h" #include "FrameInterface.h" #include "MessageAcknowModel.h" @@ -46,7 +48,7 @@ // runs in the thread initConnections(); - //LOG_DEBUG(tr("%1 Initialized").arg(metaObject()->className())); // TODO is this needed? + LOG_DEBUG(QString("%1 Initialized").arg(metaObject()->className())); return true; } @@ -96,6 +98,10 @@ connect(&_MessageAcknowModel , SIGNAL(didFailedTransmit( Sequence )), this , SLOT( onFailedTransmit( Sequence ))); + + // Application Settings are ready + connect(&_ApplicationController, SIGNAL(didSettingsDone ()), + this , SLOT( onSettingsDone ())); } /*! @@ -152,17 +158,17 @@ // disabled coco end _messageList[vCan_Id].append(Message()); } - + qDebug() << "5" <<__FUNCTION__; // build the message and check. if (! buildMessage(vCan_Id, vPayload)) { return; } Message mMessage = _messageList[vCan_Id].last(); + qDebug() << "6" <<__FUNCTION__; // TODO : must be moved to a MessageModel class if (mMessage.isComplete()) { rxCount(); - qDebug() << " On dispatch"; #ifdef DEBUG_OUT_OF_SYNC if (_rxSequence != mMessage.sequence) { qDebug() << tr("Out of Sync : %1 , %2").arg(_rxSequence).arg(mMessage.sequence); @@ -218,10 +224,6 @@ _interpreter.updateUnhandledMessages(); } -// ---------------------------------------------------------------------------------------------------- - -// ---------------------------------------------------------------------------------------------------- - /*! * \brief MessageDispatcher::actionTransmit * \details This method is called by slot MessageDispatcher::onActionTransmit @@ -240,21 +242,22 @@ vSequence = _txSequence; } + quint8 vActionId = 0; QByteArray mData; Can_Id canid = vCanId; if (! _interpreter.interpretMessage(vData, mData, canid)) { - //LOG_DEBUG(QString("Incorrect Message, cannot be interpreted, %1").arg(Format::toHexString(vActionId))); // TODO : LogInfo Improvement // TODO is this needed? + LOG_DEBUG(QString("Incorrect Message, cannot be interpreted, %1").arg(Format::toHexString(vActionId))); // TODO : LogInfo Improvement return; } // TODO : Create a buildFrames method FrameList frameList; Sequence mSequence = vSequence; - bool mNeedsAcknow = needsAcknow(canid); + bool mNeedsAcknow = needsAcknow(vCanId); if (mNeedsAcknow) { mSequence = -mSequence; if ( ! gDisableAcknowLog ) { - //LOG_APPED_UI(tr("Ack Req, Sq:%1, ID:%2").arg(mSequence).arg(Format::toHexString(vActionId))); // TODO is this needed? + LOG_APPED_UI(tr("Ack Req, Sq:%1, ID:%2").arg(mSequence).arg(Format::toHexString(vActionId))); } #ifdef DEBUG_ACKBACK_HD_TO_UI qDebug() << tr(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ UI AckReq : %1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ").arg(mSequence); @@ -264,7 +267,7 @@ // disabled coco begin validated: Has been tested manually but in this function this cannot be false because the message interpreter is doing the same validation. // still checking here in case the logic has changed therefore buildFrame should still validate the message for developer safety. if ( ! _builder.buildFrames(mData, frameList, mSequence) ) { - //LOG_DEBUG(QString("Incorrect Message cannot be built")); // TODO : LogInfo Improvement // TODO is this needed? + LOG_DEBUG(QString("Incorrect Message cannot be built")); // TODO : LogInfo Improvement return; } // disabled coco end @@ -303,7 +306,7 @@ { if (vPayload.length() < eLenCanFrame) { // Each frame has to have exactly 8 (eLenCanFrame) bytes of data and unused bytes should be passed as 00. - //LOG_DEBUG(QString("Incorrect frame length. Exp:%1,got:%2").arg(eLenCanFrame).arg(vPayload.length())); + LOG_DEBUG(QString("Incorrect frame length. Exp:%1,got:%2").arg(eLenCanFrame).arg(vPayload.length())); return false; } if (! _builder.buildMessage(vPayload, _messageList[vCan_Id].last(), vCan_Id)) { @@ -322,20 +325,25 @@ */ bool MessageDispatcher::checkAcknowReceived(const Message &vMessage, const QString &vSrcText) { + Q_UNUSED(vMessage); Q_UNUSED(vSrcText); + return true; + /* + GuiActionType mActionId = vMessage.actionId; Sequence mSequence = vMessage.sequence; bool ok = false; - if ( false ) { + if ( mActionId == GuiActionType::ID_Acknow ) { ok = true; if ( ! gDisableAcknowLog ) { - //LOG_APPED(tr(" ,%1,Ack Bak, Sq:%2").arg(vSrcText).arg(mSequence)); + LOG_APPED(tr(" ,%1,Ack Bak, Sq:%2").arg(vSrcText).arg(mSequence)); } #ifdef DEBUG_ACKBACK_HD_TO_UI qDebug() << tr(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ HD AckBak : %1 %2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ").arg(mSequence).arg(vMessage.actionId); #endif emit didAcknowReceive(mSequence); } return ok; +*/ } /*! @@ -347,8 +355,8 @@ */ bool MessageDispatcher::checkAcknowTransmit(const Message &vMessage, const QString &vSrcText) { - Q_UNUSED(vSrcText); bool ok = false; + int mActionId = 0; Sequence mSequence = vMessage.sequence; // UI shall acknowledge the messages is intended for UI. @@ -357,18 +365,17 @@ if (mSequence < 0) { ok = true; if ( ! gDisableAcknowLog ) { - //LOG_APPED(tr(" ,%1,Ack Req, Sq:%2, ID:%3").arg(vSrcText).arg(mSequence).arg(Format::toHexString(mActionId))); + LOG_APPED(tr(" ,%1,Ack Req, Sq:%2, ID:%3").arg(vSrcText).arg(mSequence).arg(Format::toHexString(mActionId))); } #ifdef DEBUG_ACKBACK_HD_TO_UI qDebug() << tr(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ HD AckReq : %1 %2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ").arg(mSequence).arg(vMessage.actionId); #endif // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ UI AckBak is immediately handled at the same place. QString dstText; Can_Id dstID = MessageInterpreter::identifyDestination(vMessage.can_id, &dstText); - Q_UNUSED(dstID); - //actionTransmit(GuiActionType::ID_Acknow, {}, -mSequence, dstID); // TODO is this needed? + actionTransmit({}, -mSequence, dstID); if ( ! gDisableAcknowLog ) { - //LOG_APPED_UI(tr("Ack Bak, Sq:%1, Dst:%2").arg(-mSequence).arg(dstText)); + LOG_APPED_UI(tr("Ack Bak, Sq:%1, Dst:%2").arg(-mSequence).arg(dstText)); } #ifdef DEBUG_ACKBACK_HD_TO_UI qDebug() << tr(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ UI AckBak : %1 %2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ").arg(-mSequence).arg(vMessage.actionId); @@ -440,6 +447,16 @@ } // disabled coco end +/*! + * \brief MessageDispatcher::needsAcknow + * \details List of the Action types which need Acknow + * \param vActionId - Action Type id + * \return true if needs an Acknow + */ +bool MessageDispatcher::needsAcknow() +{ + return 0; +} /*! * \brief MessageDispatcher::needsAcknow