Index: sources/canbus/MessageInterpreter.cpp =================================================================== diff -u -r301c0a2101eb9374145ae274c8d91460fc9a6a62 -r2d5e51a42abdf392801371aea2d2dbcb197a1da2 --- sources/canbus/MessageInterpreter.cpp (.../MessageInterpreter.cpp) (revision 301c0a2101eb9374145ae274c8d91460fc9a6a62) +++ sources/canbus/MessageInterpreter.cpp (.../MessageInterpreter.cpp) (revision 2d5e51a42abdf392801371aea2d2dbcb197a1da2) @@ -25,6 +25,7 @@ using namespace Can; using namespace Model; +#define DISABLE_CHECKIN_LOG 0 #define DEBUG_SIGNAL(vID, vMODEL) // qDebug() << vID << vMODEL; @@ -169,8 +170,8 @@ */ void MessageInterpreter::printUnhandled(const Message &vMessage) const { - if ( logUnhandledMessage(vMessage)) return; - if ( gDisableUnhandledReport ) return; + 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("%1 # %2 %3") @@ -226,8 +227,9 @@ if ( length ) { // this message has a variable length vPayload = Format::fromVariant(vData[0]); } - // DEBUG: +#if DISABLE_CHECKIN_LOG == 0 LOG_EVENT_UI(QString("CheckIn")); +#endif break; case Gui::GuiActionType::ID_RawData: // len: 255, can have any len @@ -321,6 +323,15 @@ if (vText) *vText = "DG"; return Can_Source::eCan_DG; + 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; + default: if (vText) *vText = "XX"; return Can_Source::eCan_Unknown; @@ -349,6 +360,15 @@ if (vText) *vText = "DG"; return Can_Id::eChlid_UI_DG; + 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; + default: if (vText) *vText = "XX"; return Can_Id::eChlid_UI_Sync; @@ -359,6 +379,11 @@ * \brief MessageInterpreter::interpretMessage * \details This method will call appropriate message interpreter * for received messages from HD or DG regarding the Can_Id. + * This function checks to identify the source of the message. + * if it is from HD or DG then checks the standard handled messages with strongly typed models. + * we still have a chance in each HD/DG interpreter to log the unhandled messages. + * if the source is none of the HD or DG it doesn't go to the individual interpreters, + * and the message will identified as unhandled immediately. * \param vCan_Id - The Channel Id of the CANBus frame. * \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. @@ -375,7 +400,7 @@ 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 : logUnhandledMessage(vMessage ); break; // ok is still false. + default : printUnhandled (vMessage ); break; // ok is false, the individual interpreters for ?HD/DG should not be called, and it should be done here. } return ok; } @@ -399,18 +424,18 @@ vData.clear(); switch (vMessage.actionId) { // notice we are in receive mode // ----- Debug - case Gui::GuiActionType::ID_CANBusFaultCount : ok = canbusFaultCountData (vMessage, vData); break; // TODO : implement notify<>() + case Gui::GuiActionType::ID_CANBusFaultCount : ok = canbusFaultCountData (vMessage, vData); /* TODO : implement notify<>() */ break; case Gui::GuiActionType::ID_HDDebugText : ok = notify(vMessage, vData, Gui::GuiActionType::ID_HDDebugText ); break; case Gui::GuiActionType::ID_HDGeneralEvent : ok = notify(vMessage, vData, Gui::GuiActionType::ID_HDGeneralEvent ); break; // ----- Events - case Gui::GuiActionType::ID_Acknow : ok = true; break; // TODO : implement notify<>() + case Gui::GuiActionType::ID_Acknow : ok = true; /* TODO : implement notify<>() */ break; case Gui::GuiActionType::ID_PowerOff : ok = notify(vMessage, vData, Gui::GuiActionType::ID_PowerOff ); break; - case Gui::GuiActionType::ID_ShuttingDown : ok = true; LOG_EVENT("HD,ShuttingDown"); break; // TODO : implement notify<>() + case Gui::GuiActionType::ID_ShuttingDown : ok = true; LOG_EVENT("HD,ShuttingDown"); /* TODO : implement notify<>() */ break; // ----- POST case Gui::GuiActionType::ID_HDPostSingleResultData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_HDPostSingleResultData ); break; - case Gui::GuiActionType::ID_HDPostFinalResultData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_HDPostFinalResultData ); break; + case Gui::GuiActionType::ID_HDPostFinalResultData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_HDPostFinalResultData ); break; // ----- Settings case Gui::GuiActionType::ID_AdjustVersionsHDReq : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustVersionsHDReq ); break; @@ -489,8 +514,8 @@ case Gui::GuiActionType::ID_AdjustChemicalConfirmRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustChemicalConfirmRsp ); break; // these need to be standard and use notify as well - case Gui::GuiActionType::ID_AdjustUltrafiltrationEditRsp : ok = adjustUltrafiltrationEdit (vMessage, vData); break; // TODO : implement notify<>() - case Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmRsp : ok = adjustUltrafiltrationConfirm (vMessage, vData); break; // TODO : implement notify<>() + case Gui::GuiActionType::ID_AdjustUltrafiltrationEditRsp : ok = adjustUltrafiltrationEdit (vMessage, vData); /* TODO : implement notify<>() */ break; + case Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmRsp : ok = adjustUltrafiltrationConfirm (vMessage, vData); /* TODO : implement notify<>() */ break; // ----- Alarms case Gui::GuiActionType::ID_AlarmStatus : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AlarmStatus ); break; @@ -504,7 +529,7 @@ // unhandled messages: these will only be logged as received message // there has nothing been defined for these messages. - default : printUnhandled(vMessage); break; + default : printUnhandled (vMessage ); break; } return ok; @@ -528,11 +553,9 @@ bool ok = false; vData.clear(); switch (vMessage.actionId) { // notice we are in receive mode - case Gui::GuiActionType::ID_Acknow : ok = true; break; // TODO : implement notify<>() - case Gui::GuiActionType::ID_DGCheckIn: // TODO : implement notify<>() - ok = true; - LOG_EVENT(QString("DG,CheckIn," + QVariant(vData).toStringList().join(','))); - break; + case Gui::GuiActionType::ID_Acknow : ok = true; /* TODO : implement notify<>() */ break; + case Gui::GuiActionType::ID_DGCheckIn : ok = true; /* TODO : implement notify<>() */ + LOG_EVENT(QString("DG,CheckIn," + QVariant(vData).toStringList().join(','))); break; // ----- POST case Gui::GuiActionType::ID_DGPostSingleResultData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGPostSingleResultData ); break; case Gui::GuiActionType::ID_DGPostFinalResultData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGPostFinalResultData ); break; @@ -566,7 +589,7 @@ // unhandled messages: these will only be logged as received message // there has nothing been defined for these messages. - default : printUnhandled(vMessage); break; + default : printUnhandled (vMessage ); break; } return ok; @@ -687,10 +710,12 @@ for ( int i = 0; i < items.count(); i++ ) { QString item = items[i]; if (i == 0) { - switch (identifySource(vMessage.can_id)) { - case Can_Source::eCan_HD: logString = "HD,~" + item; break; - case Can_Source::eCan_DG: logString = "DG,~" + item; break; - default : logString = "XX,~" + item; break; + 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; } } else {