Index: sources/canbus/messageinterpreter.cpp =================================================================== diff -u -rfeb3423b373dc2a2c4267ef9fcb4d924d738423d -r56d00a82669a7a2c00ab90109a89dbec8db27527 --- sources/canbus/messageinterpreter.cpp (.../messageinterpreter.cpp) (revision feb3423b373dc2a2c4267ef9fcb4d924d738423d) +++ sources/canbus/messageinterpreter.cpp (.../messageinterpreter.cpp) (revision 56d00a82669a7a2c00ab90109a89dbec8db27527) @@ -16,9 +16,8 @@ // Qt // Project -#include "types.h" -#include "format.h" #include "logger.h" +#include "format.h" using namespace Can; @@ -41,15 +40,15 @@ * \return true if the vActionId is valid. * This return value will be used later for error handling. */ -bool MessageInterpreter::interpretMessage(const GuiActionType &vActionId, const QVariantList &vData, QByteArray &vPayload) +bool MessageInterpreter::interpretMessage(const Gui::GuiActionType &vActionId, const QVariantList &vData, QByteArray &vPayload) { bool ok = true; vPayload.clear(); int l = vData.length(); quint8 ix = 0; switch (vActionId) { // notice we are in transmit mode - case GuiActionType::PowerOff: - ix = static_cast(GuiActionIndx::PowerOff_Response); + case Gui::GuiActionType::PowerOff: + ix = static_cast(Gui::GuiActionIndx::PowerOff_Response); if (l >= ix + 1) { quint8 tmp = vData[ix].toUInt(); vPayload += tmp; @@ -59,13 +58,13 @@ ok = false; } break; - case GuiActionType::KeepAlive: + case Gui::GuiActionType::KeepAlive: // Nothing needs to be done. // KeepAlive has No data. // Mentioned in the switch/case to be registered as a valid message. break; - case GuiActionType::String: + case Gui::GuiActionType::String: vPayload = Format::fromVariant(vData[0]); break; @@ -91,7 +90,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 Can_Id vCan_Id, const Message &vMessage, GuiActionType &vActionId, QVariantList &vData) +bool MessageInterpreter::interpretMessage(const Can_Id vCan_Id, const Message &vMessage, Gui::GuiActionType &vActionId, QVariantList &vData) { bool ok = false; switch (vCan_Id) { @@ -134,14 +133,14 @@ * \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, GuiActionType &vActionId, QVariantList &vData) +bool MessageInterpreter::interpretMessage_HD(const Message &vMessage, Gui::GuiActionType &vActionId, QVariantList &vData) { bool ok = true; vActionId = vMessage.actionId; vData.clear(); switch (vActionId) { // notice we are in receive mode - case GuiActionType::PowerOff: { + case Gui::GuiActionType::PowerOff: { quint8 mShowHide; ok = getPowerOffData(vMessage, mShowHide); if (ok) { @@ -151,23 +150,23 @@ break; } - case GuiActionType::BloodFlow: + case Gui::GuiActionType::BloodFlow: ok = bloodFlowData (vMessage, vData); break; - case GuiActionType::DialysateFlow: + case Gui::GuiActionType::DialysateFlow: ok = dialysateFlowData (vMessage, vData); break; - case GuiActionType::AlarmStatus: + case Gui::GuiActionType::AlarmStatus: ok = alarmStatus (vMessage, vData); break; - case GuiActionType::AlarmTriggered: + case Gui::GuiActionType::AlarmTriggered: printUnhandled (vMessage); break; - case GuiActionType::AlarmCleared: + case Gui::GuiActionType::AlarmCleared: printUnhandled (vMessage); break; @@ -191,7 +190,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, GuiActionType &vActionId, QVariantList &vData) +bool MessageInterpreter::interpretMessage_DG(const Message &vMessage, Gui::GuiActionType &vActionId, QVariantList &vData) { Q_UNUSED(vMessage ); Q_UNUSED(vActionId); @@ -214,7 +213,7 @@ { bool ok = true; int l = vMessage.data.length(); - quint8 ix = static_cast(GuiActionIndx::PowerOff_ShowHide); + quint8 ix = static_cast(Gui::GuiActionIndx::PowerOff_ShowHide); if (l >= ix + 1) { quint8 tmp = vMessage.data[ix]; vShowHide = tmp; @@ -246,10 +245,10 @@ Types::F32 &vMeasuredFlow , Types::F32 &vRotorSpeed , Types::F32 &vMotorSpeed, Types::F32 &vMotorCtlSpeed , Types::F32 &vMotorCtlCurrent , Types::F32 &vPWMDtCycle) { - if ( vMessage.actionId != GuiActionType::BloodFlow ) { + if ( vMessage.actionId != Gui::GuiActionType::BloodFlow ) { return false; } - if ( vMessage.data.length() < payloadLen[GuiActionType::BloodFlow] ) { + if ( vMessage.data.length() < payloadLen[Gui::GuiActionType::BloodFlow] ) { QString mActionIdHexString = Format::toHexString(vMessage.actionId); LOG_ERROR(tr("Incorrect data for Message ID (HD) '%1'").arg(mActionIdHexString)); return false; @@ -267,6 +266,15 @@ return true; } +/*! + * \brief MessageInterpreter::bloodFlowData + * \details Used the getBloodFlowData method and converts each parameter + * in vData of type QVaranitList, to be used in the GUI + * Also logs the data + * \param vMessage - The message + * \param vData - the output data + * \return return value of the method getBloodFlowData + */ bool MessageInterpreter::bloodFlowData(const Message &vMessage, QVariantList &vData) { bool ok; @@ -327,10 +335,10 @@ Types::F32 &vMotorCtlSpeed , Types::F32 &vMotorCtlCurrent , Types::F32 &vPWMDtCycle) { - if ( vMessage.actionId != GuiActionType::DialysateFlow ) { + if ( vMessage.actionId != Gui::GuiActionType::DialysateFlow ) { return false; } - if ( vMessage.data.length() < payloadLen[GuiActionType::DialysateFlow] ) { + if ( vMessage.data.length() < payloadLen[Gui::GuiActionType::DialysateFlow] ) { QString mActionIdHexString = Format::toHexString(vMessage.actionId); LOG_ERROR(tr("Incorrect data for Message ID (HD) '%1'").arg(mActionIdHexString)); return false; @@ -348,6 +356,15 @@ return true; } +/*! + * \brief MessageInterpreter::dialysateFlowData + * \details Used the getDialysateFlowData method and converts each parameter + * in vData of type QVaranitList, to be used in the GUI + * Also logs the data + * \param vMessage - The message + * \param vData - the output data + * \return return value of the method getDialysateFlowData + */ bool MessageInterpreter::dialysateFlowData(const Message &vMessage, QVariantList &vData) { bool ok; @@ -405,10 +422,10 @@ Types::U32 &vMuteTimeout, Types::U32 &vEscalatesIn, Types::Flags &vFlags) { - if ( vMessage.actionId != GuiActionType::AlarmStatus ) { + if ( vMessage.actionId != Gui::GuiActionType::AlarmStatus ) { return false; } - if ( vMessage.data.length() < payloadLen[GuiActionType::AlarmStatus] ) { + if ( vMessage.data.length() < payloadLen[Gui::GuiActionType::AlarmStatus] ) { QString mActionIdHexString = Format::toHexString(vMessage.actionId); LOG_ERROR(tr("Incorrect data for Message ID (HD) '%1'").arg(mActionIdHexString)); return false; @@ -423,6 +440,15 @@ return true; } +/*! + * \brief MessageInterpreter::alarmStatus + * \details Used the getAlarmStatus method and converts each parameter + * in vData of type QVaranitList, to be used in the GUI + * Also logs the data + * \param vMessage - The message + * \param vData - the output data + * \return return value of the method getAlarmStatus + */ bool MessageInterpreter::alarmStatus(const Message &vMessage, QVariantList &vData) { bool ok;