Index: sources/canbus/messageinterpreter.cpp =================================================================== diff -u -r4d201ed69decd17c5fe8ed150fd90f194b35a486 -r732bc047743c99a157cf147f5313194867c1f5e3 --- sources/canbus/messageinterpreter.cpp (.../messageinterpreter.cpp) (revision 4d201ed69decd17c5fe8ed150fd90f194b35a486) +++ sources/canbus/messageinterpreter.cpp (.../messageinterpreter.cpp) (revision 732bc047743c99a157cf147f5313194867c1f5e3) @@ -169,10 +169,14 @@ ok = bloodFlowData (vMessage, vData); break; - case Gui::GuiActionType::DialysateFlow: - ok = dialysateFlowData (vMessage, vData); + case Gui::GuiActionType::DialysateInletFlow: + ok = dialysateInletFlowData (vMessage, vData); break; + case Gui::GuiActionType::DialysateOutletFlow: + ok = dialysateOutletFlowData (vMessage, vData); + break; + case Gui::GuiActionType::AlarmStatus: ok = alarmStatus (vMessage, vData); break; @@ -329,8 +333,8 @@ } /*! - * \brief MessageInterpreter::getDialysateFlowData - * \details This is the method which interprets the Dialysate Flow message data in vMessage of type Message + * \brief MessageInterpreter::getDialysateInletFlowData + * \details This is the method which interprets the Dialysate Inlet Flow message data in vMessage of type Message * to its elements of data. * \param vMessage - The vMessage of type Message which contains all the data, require to be interpreted. * \param vFlowSetPoint - Flow Set Point value of type signed int extracted out @@ -342,17 +346,17 @@ * \param vPWMDtCycle - PWM Duty Cycle in % value of type float extracted out * \return true if the message can be successfully converted to the Blood Flow data elements. */ -bool MessageInterpreter::getDialysateFlowData( +bool MessageInterpreter::getDialysateInletFlowData( const Message &vMessage , Types::S32 &vFlowSetPoint , Types::F32 &vMeasuredFlow , Types::F32 &vRotorSpeed , Types::F32 &vMotorSpeed, Types::F32 &vMotorCtlSpeed , Types::F32 &vMotorCtlCurrent , Types::F32 &vPWMDtCycle) { - if ( vMessage.actionId != Gui::GuiActionType::DialysateFlow ) { + if ( vMessage.actionId != Gui::GuiActionType::DialysateInletFlow ) { return false; } - if ( vMessage.data.length() < payloadLen[Gui::GuiActionType::DialysateFlow] ) { + if ( vMessage.data.length() < payloadLen[Gui::GuiActionType::DialysateInletFlow] ) { QString mActionIdHexString = Format::toHexString(vMessage.actionId); LOG_ERROR(tr("Incorrect data for Message ID (HD) '%1'").arg(mActionIdHexString)); return false; @@ -371,15 +375,15 @@ } /*! - * \brief MessageInterpreter::dialysateFlowData - * \details Used the getDialysateFlowData method and converts each parameter + * \brief MessageInterpreter::dialysateInletFlowData + * \details Used the getDialysateInletFlowData 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 + * \return return value of the method getDialysateInletFlowData */ -bool MessageInterpreter::dialysateFlowData(const Message &vMessage, QVariantList &vData) +bool MessageInterpreter::dialysateInletFlowData(const Message &vMessage, QVariantList &vData) { bool ok; Types::S32 mFlowSetPoint ; @@ -389,15 +393,15 @@ Types::F32 mMotorCtlSpeed ; Types::F32 mMotorCtlCurrent ; Types::F32 mPWMDtCycle ; - ok = getDialysateFlowData(vMessage , - mFlowSetPoint , - mMeasuredFlow , - mRotorSpeed , - mMotorSpeed , - mMotorCtlSpeed , - mMotorCtlCurrent , - mPWMDtCycle ); - LOG_DATUM(QString("Dialysate Flow(%1, %2, %3, %4, %5, %6, %7)") + ok = getDialysateInletFlowData(vMessage , + mFlowSetPoint , + mMeasuredFlow , + mRotorSpeed , + mMotorSpeed , + mMotorCtlSpeed , + mMotorCtlCurrent , + mPWMDtCycle ); + LOG_DATUM(QString("Dialysate Inlet Flow(%1, %2, %3, %4, %5, %6, %7)") .arg(mFlowSetPoint .value) .arg(mMeasuredFlow .value) .arg(mRotorSpeed .value) @@ -418,7 +422,100 @@ return ok; } + /*! + * \brief MessageInterpreter::getDialysateOutletFlowData + * \details This is the method which interprets the Dialysate Outlet Flow message data in vMessage of type Message + * to its elements of data. + * \param vMessage - The vMessage of type Message which contains all the data, require to be interpreted. + * \param vRefUFVol - Reference UF Volume value of type float extracted out + * \param vMeasUFVol - Measured UF Volume value of type float extracted out + * \param vRotorSpeed - Rotor Speed value of type float extracted out + * \param vMotorSpeed - Motor Speed value of type float extracted out + * \param vMotorCtlSpeed - Motor Controller Speed value of type float extracted out + * \param vMotorCtlCurrent - Motor Controller Current value of type float extracted out + * \param vPWMDtCycle - PWM Duty Cycle in % value of type float extracted out + * \return true if the message can be successfully converted to the Blood Flow data elements. + */ +bool MessageInterpreter::getDialysateOutletFlowData( + const Message &vMessage , + Types::F32 &vRefUFVol , Types::F32 &vMeasUFVol , + Types::F32 &vRotorSpeed , Types::F32 &vMotorSpeed , + Types::F32 &vMotorCtlSpeed , Types::F32 &vMotorCtlCurrent , Types::F32 &vPWMDtCycle) + +{ + if ( vMessage.actionId != Gui::GuiActionType::DialysateOutletFlow ) { + return false; + } + if ( vMessage.data.length() < payloadLen[Gui::GuiActionType::DialysateOutletFlow] ) { + QString mActionIdHexString = Format::toHexString(vMessage.actionId); + LOG_ERROR(tr("Incorrect data for Message ID (HD) '%1'").arg(mActionIdHexString)); + return false; + } + + int index = 0; // message data start position + Types::getValue<>(vMessage.data, index, vRefUFVol ); + Types::getValue<>(vMessage.data, index, vMeasUFVol ); + Types::getValue<>(vMessage.data, index, vRotorSpeed ); + Types::getValue<>(vMessage.data, index, vMotorSpeed ); + Types::getValue<>(vMessage.data, index, vMotorCtlSpeed ); + Types::getValue<>(vMessage.data, index, vMotorCtlCurrent); + Types::getValue<>(vMessage.data, index, vPWMDtCycle ); + + return true; +} + +/*! + * \brief MessageInterpreter::dialysateOutletFlowData + * \details Used the getDialysateOutletFlowData 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 getDialysateOutletFlowData + */ +bool MessageInterpreter::dialysateOutletFlowData(const Message &vMessage, QVariantList &vData) +{ + bool ok; + Types::F32 mRefUFVol ; + Types::F32 mMeasUFVol ; + Types::F32 mRotorSpeed ; + Types::F32 mMotorSpeed ; + Types::F32 mMotorCtlSpeed ; + Types::F32 mMotorCtlCurrent ; + Types::F32 mPWMDtCycle ; + ok = getDialysateOutletFlowData(vMessage, + mRefUFVol , + mMeasUFVol , + mRotorSpeed , + mMotorSpeed , + mMotorCtlSpeed , + mMotorCtlCurrent , + mPWMDtCycle ); + QString msg = QString("Dialysate Outlet Flow(%1, %2, %3, %4, %5, %6, %7)") + .arg(mRefUFVol .value) + .arg(mMeasUFVol .value) + .arg(mRotorSpeed .value) + .arg(mMotorSpeed .value) + .arg(mMotorCtlSpeed .value) + .arg(mMotorCtlCurrent .value) + .arg(mPWMDtCycle .value); + LOG_DATUM(msg); + qDebug() << msg; + + if (ok) { + vData += mRefUFVol .value; + vData += mMeasUFVol .value; + vData += mRotorSpeed .value; + vData += mMotorSpeed .value; + vData += mMotorCtlSpeed .value; + vData += mMotorCtlCurrent.value; + vData += mPWMDtCycle .value; + } + return ok; +} + +/*! * \brief MessageInterpreter::getAlarmStatus * \details This method interprets AlarmStatus message data * in vMessage of type Message.