Index: sources/canbus/MessageInterpreter.cpp =================================================================== diff -u -r43668888e2a573f688493685ce3535c3b2117558 -r47baa703592f0e21098cb21c0ed267de4e958b2f --- sources/canbus/MessageInterpreter.cpp (.../MessageInterpreter.cpp) (revision 43668888e2a573f688493685ce3535c3b2117558) +++ sources/canbus/MessageInterpreter.cpp (.../MessageInterpreter.cpp) (revision 47baa703592f0e21098cb21c0ed267de4e958b2f) @@ -34,7 +34,7 @@ // like the notify method of received messages #define INTERPRET_TRANSMIT_MESSAGE() \ /*if ( ! length ) { logInvalidLength(vActionId); return false; }*/ \ - vCanId = eChlid_HD_Sync; /*vMODEL::canid();*/ \ + vCanId = eChlid_TD_Sync; /*vMODEL::canid();*/ \ vPayload = Format::fromVariant(vData); \ /*LOG_APPED_MSG(vActionId, vMODEL::toString(vData));*/ \ /*DEBUG_SIGNAL(0, typeid(vMODEL).name())*/ @@ -180,7 +180,7 @@ if ( logUnhandledMessage(vMessage)) return; // the message is defined as unhandled and can still be handled and logged, return. if ( gDisableUnhandledReport ) return; // if the unhandled message error has been disabled, return. QString mActionIdHexString = Format::toHexString(vMessage.actionId, false, eLenMessageIDDigits); - QString logMessage = tr("Unhandled Message ID (HD)") + '\n' + + QString logMessage = tr("Unhandled Message ID (TD)") + '\n' + QString("%1 # %2 %3") .arg(int(vMessage.can_id), 3, 16, QChar('0')) .arg(mActionIdHexString) @@ -204,7 +204,7 @@ { bool ok = true; if (vCanId == Can::Can_Id::eChlid_NONE ) - vCanId = Can::Can_Id::eChlid_UI_HD ; + vCanId = Can::Can_Id::eChlid_UI_TD ; vPayload.clear(); int length = vData.length(); Q_UNUSED(length); @@ -222,37 +222,41 @@ Can_Source MessageInterpreter::identifySource(Can_Id vCanId, QString *vText) { switch (vCanId) { - case eChlid_HD_DG : // 0x008, ///< HD => DG - case eChlid_HD_UI : // 0x020, ///< HD => UI - case eChlid_HD_Alarm: // 0x001, ///< HD alarm broadcast - case eChlid_HD_Sync : // 0x040, ///< HD sync broadcast - if (vText) *vText = "HD"; - return Can_Source::eCan_HD; + case eChlid_TD_DD : + case eChlid_TD_UI : + case eChlid_TD_Alarm: + case eChlid_TD_Sync : + if (vText) *vText = "TD"; + return Can_Source::eCan_TD; - case eChlid_DG_HD : // 0x010, ///< DG => HD - case eChlid_DG_UI : // 0x070, ///< DG => UI - case eChlid_DG_Alarm: // 0x002, ///< DG alarm broadcast - case eChlid_DG_Sync : // 0x080, ///< DG sync broadcast - if (vText) *vText = "DG"; - return Can_Source::eCan_DG; + case eChlid_DD_TD : + case eChlid_DD_FP : + //case eChlid_DD_UI : // has duplicate value as eChlid_DD_Sync + case eChlid_DD_Alarm: + case eChlid_DD_Sync : + if (vText) *vText = "DD"; + return Can_Source::eCan_DD; - case eDialin_HD : // 0x400, ///< dialin => HD - case eHD_Dialin : // 0x401, ///< HD => dialin - case eDialin_DG : // 0x402, ///< dialin => DG - case eDG_Dialin : // 0x403, ///< DG => dialin - case eDialin_UI : // 0x404, ///< dialin => UI - case eUI_Dialin : // 0x405, ///< UI => dialin - if (vText) *vText = "DI"; - return Can_Source::eCan_DI; + //case eChlid_FP_UI : // has duplicate value as eChlid_FP_Sync + case eChlid_FP_Alarm: + case eChlid_FP_Sync : + if (vText) *vText = "FP"; + return Can_Source::eCan_FP; - case eChlid_UI_HD : // 0x100, ///< UI for dry demo - if (vText) *vText = "UI"; - return Can_Source::eCan_UI; - // TODO why no break? + case eDialin_TD : + case eTD_Dialin : + case eDialin_DD : + case eDD_Dialin : + case eDialin_FP : + case eFP_Dialin : + case eDialin_UI : + case eUI_Dialin : + if (vText) *vText = "DI"; + return Can_Source::eCan_DI; - default: - if (vText) *vText = "XX"; - return Can_Source::eCan_Unknown; + default: + if (vText) *vText = "XX"; + return Can_Source::eCan_Unknown; } } @@ -266,34 +270,40 @@ Can_Id MessageInterpreter::identifyDestination(Can_Id vCanId, QString *vText) { switch (vCanId) { - case eChlid_HD_UI : // 0x020, ///< HD => UI - case eChlid_HD_Alarm: // 0x001, ///< HD alarm broadcast - case eChlid_HD_Sync : // 0x040, ///< HD sync broadcast - if (vText) *vText = "HD"; - return Can_Id::eChlid_UI_HD; + case eChlid_TD_UI : + case eChlid_TD_Alarm: + case eChlid_TD_Sync : + if (vText) *vText = "TD"; + return Can_Id::eChlid_UI_TD; - case eChlid_DG_UI : // 0x070, ///< DG => UI - case eChlid_DG_Alarm: // 0x002, ///< DG alarm broadcast - case eChlid_DG_Sync : // 0x080, ///< DG sync broadcast - if (vText) *vText = "DG"; - return Can_Id::eChlid_UI_DG; + //case eChlid_DD_UI : // has duplicate value as eChlid_DD_Sync + case eChlid_DD_FP : + case eChlid_DD_Alarm: + case eChlid_DD_Sync : + if (vText) *vText = "DD"; + return Can_Id::eChlid_UI_DD; - case eDialin_HD : // 0x400, ///< dialin => HD - case eHD_Dialin : // 0x401, ///< HD => dialin - case eDialin_DG : // 0x402, ///< dialin => DG - case eDG_Dialin : // 0x403, ///< DG => dialin - case eDialin_UI : // 0x404, ///< dialin => UI - case eUI_Dialin : // 0x405, ///< UI => dialin - if (vText) *vText = "DI"; - return Can_Id::eChlid_UI_Sync; + // FP is not designed to directly communicate with UI + //case eChlid_FP_UI : // has duplicate value as eChlid_FP_Sync + case eChlid_FP_Alarm: + case eChlid_FP_Sync : + if (vText) *vText = "FP"; + return Can_Id::eChlid_UI_Sync; - case eChlid_UI_HD : // 0x100, ///< UI for dry demo - if (vText) *vText = "HD"; - return Can_Id::eChlid_HD_UI; + case eDialin_TD : + case eTD_Dialin : + case eDialin_DD : + case eDD_Dialin : + case eDialin_FP : + case eFP_Dialin : + case eDialin_UI : + case eUI_Dialin : + if (vText) *vText = "DI"; + return Can_Id::eChlid_UI_Sync; - default: - if (vText) *vText = "XX"; - return Can_Id::eChlid_UI_Sync; + default: + if (vText) *vText = "XX"; + return Can_Id::eChlid_UI_Sync; } } @@ -321,9 +331,10 @@ if ( ! gLogUnhandledOnly ) { switch (identifySource(vMessage.can_id)) { - case Can_Source::eCan_HD: ok = interpretMessage_HD(vMessage, vData); break; - case Can_Source::eCan_DG: ok = interpretMessage_DG(vMessage, vData); break; - default : printUnhandled (vMessage ); /*qDebug() << "2" <<__FUNCTION__;*/ break; // ok is false, the individual interpreters for ?HD/DG should not be called, and it should be done here. + case Can_Source::eCan_TD: ok = interpretMessage_TD(vMessage, vData); break; + case Can_Source::eCan_DD: ok = interpretMessage_DD(vMessage, vData); break; + case Can_Source::eCan_FP: ok = interpretMessage_FP(vMessage, vData); break; + default : printUnhandled (vMessage ); break; // ok is false, the individual interpreters for ?HD/DG should not be called, and it should be done here. } } else { @@ -335,9 +346,9 @@ } /*! - * \brief MessageInterpreter::interpretMessage_HD + * \brief MessageInterpreter::interpretMessage_TD * \details This method will be called - * for received messages from HD to interpret the vMessage of type Message + * for received messages from TD to interpret the vMessage of type Message * to vData of type QVariantList which UI understands regarding the Can_Id. * \param vMessage - The complete message of type Message which needs to be interpreted. * \param vActionId - The ActionId of GuiActionType which will be extracted from vMessage. @@ -347,7 +358,7 @@ * \return true if the message CANBus channel is in the range which can be interpreted, false otherwise. * This return value will be used later to emit MessageDispatcher::didActionReceive signal or not */ -bool MessageInterpreter::interpretMessage_HD(const Message &vMessage, QVariantList &vData) +bool MessageInterpreter::interpretMessage_TD(const Message &vMessage, QVariantList &vData) { bool ok = false; vData.clear(); @@ -358,9 +369,9 @@ } /*! - * \brief MessageInterpreter::interpretMessage_DG + * \brief MessageInterpreter::interpretMessage_DD * \details This method will be called - * for received messages from DG to interpret the vMessage of type Message + * for received messages from DD to interpret the vMessage of type Message * to vData of type QVariantList which UI understands regarding the Can_Id. * \param vMessage - The complete message of type Message which needs to be interpreted. * \param vActionId - The ActionId of GuiActionType which will be extracted from vMessage. @@ -370,7 +381,7 @@ * \return true if the message CANBus channel is in the range which can be interpreted, false otherwise. * This return value will be used later to emit MessageDispatcher::didActionReceive signal or not */ -bool MessageInterpreter::interpretMessage_DG(const Message &vMessage, QVariantList &vData) +bool MessageInterpreter::interpretMessage_DD(const Message &vMessage, QVariantList &vData) { bool ok = false; vData.clear(); @@ -380,6 +391,29 @@ return ok; } +/*! + * \brief MessageInterpreter::interpretMessage_FP + * \details This method will be called + * for received messages from FP to interpret the vMessage of type Message + * to vData of type QVariantList which UI understands regarding the Can_Id. + * \param vMessage - The complete message of type Message which needs to be interpreted. + * \param vActionId - The ActionId of GuiActionType which will be extracted from vMessage. + * \param vData - The values of QVariantList which is understandable for UI + * and has been extracted from hex values of the CANBus Message Payload + * in vMessage of type Message regarding each Message Id definition. + * \return true if the message CANBus channel is in the range which can be interpreted, false otherwise. + * This return value will be used later to emit MessageDispatcher::didActionReceive signal or not + */ +bool MessageInterpreter::interpretMessage_FP(const Message &vMessage, QVariantList &vData) +{ + bool ok = false; + vData.clear(); + Q_UNUSED(vMessage); + // TODO print unhandled? + + return ok; +} + // ---------- ---------- Message handlers ---------- ---------- // // ---------- ---------- ---------- ---------- ---------- Debug ---------- ---------- ---------- ---------- ---------- // @@ -440,28 +474,25 @@ */ bool MessageInterpreter::logUnhandledMessage(const Message &vMessage) const { bool ok = false; - quint16 id = vMessage.actionId; - QString logString = QString("%1,").arg(id,4,16); - QVariantList logVariant; - logVariant.append(id); + quint16 msg_id = vMessage.actionId; + QString logString = QString("%1,").arg(msg_id,4,16); + QString can_id; + QString item = ""; - if (_messageList.contains(id)) { + identifySource(vMessage.can_id, &can_id); // Message Can Channel. + logString += can_id + ","; + // qDebug() << __FUNCTION__ << logString; + + if (_messageList.contains(msg_id)) { ok = true; - QStringList items = _messageList[id]; + QStringList items = _messageList[msg_id]; int index = 0; for ( int i = 0; i < items.count(); i++ ) { - QString item = items[i]; - if (i == 0) { - QString ID; - switch (identifySource(vMessage.can_id, &ID)) { - case Can_Source::eCan_HD: logString += ID + ",~" + item; break; - case Can_Source::eCan_DG: logString += ID + ",~" + item; break; - case Can_Source::eCan_DI: logString += ID + ",~" + item; break; - default : logString += ID + ",~" + item; break; - } + item = items[i]; + if (i == 0) { // Message Name/Identifier + logString += "~" + item; } - else { - logVariant.append(vMessage.data); + else { // Message payload data if ( item == "F32" ) { Types::F32 param; if (! GetValue(vMessage.data, index, param )) logString += ",?"; @@ -504,18 +535,12 @@ } } } - LOG_APPED(logString); - if ((id != 0x700) && (id != 0xFFFF) ) { - // Message 0x0700 is UI check in. It is not needed to be processed for dry demo - // Message 0xFFFF is the ack message and it is not needed to be processed for dry demo - qDebug() << "Message" << logString; - emit didUnhandledMsgReady(logVariant); - } } else { if ( gDisableUnhandledReport ) { // if the unhandled message error has been disabled, return. - LOG_DEBUG(QString("Undefined unhandled message [%1]").arg(id, 0, 16)); + LOG_DEBUG(QString("Undefined unhandled message [%1]").arg(msg_id, 0, 16)); } } + LOG_APPED(logString + item); return ok; }