Index: sources/canbus/messageinterpreter.cpp =================================================================== diff -u -r56e378f7504701b9e9a9dccaf205aef2fd52c58e -r59b5801d8ba3e121ea3e7f36057cb15454ea9e9a --- sources/canbus/messageinterpreter.cpp (.../messageinterpreter.cpp) (revision 56e378f7504701b9e9a9dccaf205aef2fd52c58e) +++ sources/canbus/messageinterpreter.cpp (.../messageinterpreter.cpp) (revision 59b5801d8ba3e121ea3e7f36057cb15454ea9e9a) @@ -6,8 +6,8 @@ * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file messageinterpreter.cpp - * \author (last) Behrouz NematiPour - * \date (last) 20-Aug-2020 + * \author (last) Peman Montazemi + * \date (last) 6-Nov-2020 * \author (original) Behrouz NematiPour * \date (original) 13-Dec-2019 * @@ -46,8 +46,7 @@ * \return true on successful check and prepare. */ template -bool MessageInterpreter::notify(const Message &vMessage, QVariantList &vData, Gui::GuiActionType vIdCheck) -{ +bool MessageInterpreter::notify(const Message &vMessage, QVariantList &vData, Gui::GuiActionType vIdCheck) { bool ok = false; TModel tModel; if ( ! isValidMessage(vMessage, vIdCheck) ) return ok; @@ -71,8 +70,7 @@ * \param vType - The type of the message to be checked against * \return true on correct type */ -bool MessageInterpreter::isType(const Message &vMessage, Gui::GuiActionType vType) const -{ +bool MessageInterpreter::isType(const Message &vMessage, Gui::GuiActionType vType) const { if ( vMessage.actionId != vType ) { return false; } @@ -90,8 +88,7 @@ * \param vType - The type of the message to be checked against * \return true on correct data length for the type vType */ -bool MessageInterpreter::isPayloadLenValid(const Message &vMessage, Gui::GuiActionType vType) const -{ +bool MessageInterpreter::isPayloadLenValid(const Message &vMessage, Gui::GuiActionType vType) const { QString mActionIdHexString = Format::toHexString(vMessage.actionId); if ( ! payloadLen.contains(vType) ) { LOG_DEBUG(QString("Undefined data length for received Message with ID '%1'").arg(mActionIdHexString)); @@ -109,8 +106,7 @@ * \details Logs invalid data length for the message type vActionId * \param vActionId - Message Type */ -void MessageInterpreter::logInvalidLength(const Gui::GuiActionType &vActionId) -{ +void MessageInterpreter::logInvalidLength(const Gui::GuiActionType &vActionId) { QString mActionIdHexString = Format::toHexString(vActionId); LOG_DEBUG(QString("Incorrect data length for transmit message with ID '%1'") .arg(mActionIdHexString)); @@ -123,8 +119,7 @@ * \param vType - The type of the message to be checked against * \return true on valid massage */ -bool MessageInterpreter::isValidMessage(const Message &vMessage, Gui::GuiActionType vType) const -{ +bool MessageInterpreter::isValidMessage(const Message &vMessage, Gui::GuiActionType vType) const { if ( ! isType (vMessage, vType) ) return false; if ( ! isPayloadLenValid(vMessage, vType) ) return false; return true; @@ -137,8 +132,7 @@ * is known to the interpreter but has not been handled/implemented. * \param vMessage - The message contains Unhandled Message ID */ -void MessageInterpreter::printUnhandled(const Message &vMessage) const -{ +void MessageInterpreter::printUnhandled(const Message &vMessage) const { if ( gDisableUnhandledReport ) return; QString mActionIdHexString = Format::toHexString(vMessage.actionId, false, eLenMessageIDDigits); QString logMessage = tr("Unhandled Message ID (HD)") + '\n' + @@ -154,8 +148,7 @@ * \details Regarding the type of message logs the message received. * \param vModel - the MAbstract model type */ -void MessageInterpreter::logReceivedMessage(const Model::MAbstract &vModel) -{ +void MessageInterpreter::logReceivedMessage(const Model::MAbstract &vModel) { switch (vModel.typeText()) { case Model::MAbstract::Type_Enum::eDatum: LOG_DATUM(vModel.toString()); @@ -178,8 +171,7 @@ * \return true if the vActionId is valid. * This return value will be used later for error handling. */ -bool MessageInterpreter::interpretMessage(const Gui::GuiActionType &vActionId, const QVariantList &vData, QByteArray &vPayload) -{ +bool MessageInterpreter::interpretMessage(const Gui::GuiActionType &vActionId, const QVariantList &vData, QByteArray &vPayload) { bool ok = true; QString mSenderID = "UI,"; @@ -253,6 +245,10 @@ LOG_EVENT(AlarmSilenceRequestData::toString(vData)); break; + case Gui::GuiActionType::ID_AdjustVersionsReq: + LOG_EVENT(AdjustVersionsRequestData::toString(vData)); + break; + default: QString mActionIdHexString = Format::toHexString(vActionId); LOG_DEBUG(mSenderID + tr("Unknown transmit Message with ID '%1'").arg(mActionIdHexString)); @@ -276,8 +272,7 @@ * \return true if the message 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(const Message &vMessage, QVariantList &vData) -{ +bool MessageInterpreter::interpretMessage(const Message &vMessage, QVariantList &vData) { bool ok = false; switch (vMessage.can_id) { case eChlid_HD_UI : @@ -309,8 +304,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_HD(const Message &vMessage, QVariantList &vData) { bool ok = false; vData.clear(); switch (vMessage.actionId) { // notice we are in receive mode @@ -326,6 +320,7 @@ case Gui::GuiActionType::ID_PressureOcclusion : ok = notify(vMessage, vData, Gui::GuiActionType::ID_PressureOcclusion ); break; case Gui::GuiActionType::ID_TreatmentStates : ok = notify(vMessage, vData, Gui::GuiActionType::ID_TreatmentStates ); break; case Gui::GuiActionType::ID_Saline : ok = notify(vMessage, vData, Gui::GuiActionType::ID_Saline ); break; + case Gui::GuiActionType::ID_HDAccelerometerData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_HDAccelerometerData ); break; // ----- Events case Gui::GuiActionType::ID_HDOperationModeData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_HDOperationModeData ); break; @@ -342,6 +337,7 @@ case Gui::GuiActionType::ID_AdjustDurationRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustDurationRsp ); break; case Gui::GuiActionType::ID_AdjustBloodDialysateRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustBloodDialysateRsp); break; case Gui::GuiActionType::ID_AdjustSalineRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustSalineRsp ); break; + case Gui::GuiActionType::ID_AdjustHDVersionsRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustHDVersionsRsp ); break; // ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustUltrafiltrationStateReq); break; // this message has been inherited from MAbstract and should use notify but since the response message is not standard can't use notify yet. @@ -371,8 +367,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_DG(const Message &vMessage, QVariantList &vData) { bool ok = false; vData.clear(); switch (vMessage.actionId) { // notice we are in receive mode @@ -391,13 +386,13 @@ case Gui::GuiActionType::ID_DGLoadCellReadingsData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGLoadCellReadingsData); break; case Gui::GuiActionType::ID_DGTemperaturesData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGTemperaturesData ); break; case Gui::GuiActionType::ID_DGDebugText : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGDebugText ); break; + case Gui::GuiActionType::ID_DGAccelerometerData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGAccelerometerData ); break; // unhandled messages: these will only be logged as received message // there has nothing been defined for these messages. default: printUnhandled (vMessage); break; - } return ok; @@ -415,8 +410,7 @@ * \param vData - Fault Count data * \return true if the data can be extracted as defined for Fault Count Message ID */ -bool MessageInterpreter::canbusFaultCountData(const Message &vMessage, QVariantList &vData) -{ +bool MessageInterpreter::canbusFaultCountData(const Message &vMessage, QVariantList &vData) { // TODO : review other methods bool ok = false; if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_CANBusFaultCount) ) return ok; @@ -430,6 +424,7 @@ // coco end vData += mCanBUSFaultCount.value; } + return ok; } @@ -469,8 +464,7 @@ * \param vData - Alarm Triggered data * \return true if the data can be extracted as defined for Alarm Triggered Message ID */ -bool MessageInterpreter::alarmTriggered(const Message &vMessage, QVariantList &vData) -{ +bool MessageInterpreter::alarmTriggered(const Message &vMessage, QVariantList &vData) { // TODO : review other methods bool ok = false; if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_AlarmTriggered) ) return ok; @@ -494,8 +488,7 @@ * \param vData - Alarm Cleared data * \return true if the data can be extracted as defined for Alarm Cleared Message ID */ -bool MessageInterpreter::alarmCleared(const Message &vMessage, QVariantList &vData) -{ +bool MessageInterpreter::alarmCleared(const Message &vMessage, QVariantList &vData) { // TODO : review other methods bool ok = false; if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_AlarmCleared) ) return ok; @@ -521,8 +514,7 @@ * \param vData - Treatment Ultrafiltration State Adjustment Response data * \return true if the data can be extracted as defined for Treatment Ultrafiltration State Adjustment Response Message ID */ -bool MessageInterpreter::adjustUltrafiltrationState(const Message &vMessage, QVariantList &vData) -{ +bool MessageInterpreter::adjustUltrafiltrationState(const Message &vMessage, QVariantList &vData) { bool ok = false; // TODO : In HD the Ultrafiltration State change shall have the rejection reason like other responses. if ( ! isType (vMessage, Gui::GuiActionType::ID_AdjustUltrafiltrationStateReq) ) return ok; @@ -547,8 +539,7 @@ * \param vData - Treatment Ultrafiltration Volume Adjustment Response data * \return true if the data can be extracted as defined for Treatment Ultrafiltration Volume Adjustment Response Message ID */ -bool MessageInterpreter::adjustUltrafiltrationEdit(const Message &vMessage, QVariantList &vData) -{ +bool MessageInterpreter::adjustUltrafiltrationEdit(const Message &vMessage, QVariantList &vData) { bool ok = false; if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_AdjustUltrafiltrationEditRsp) ) return ok; @@ -571,8 +562,7 @@ * \param vData - Treatment Ultrafiltration Volume Adjustment Confirm Response data * \return true if the data can be extracted as defined for Treatment Ultrafiltration Volume Adjustment Confirm Response Message ID */ -bool MessageInterpreter::adjustUltrafiltrationConfirm(const Message &vMessage, QVariantList &vData) -{ +bool MessageInterpreter::adjustUltrafiltrationConfirm(const Message &vMessage, QVariantList &vData) { bool ok = false; if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmRsp) ) return ok;