Index: main.cpp =================================================================== diff -u -r584874a724b2d3e8c98247d3b0e42d6a34ce9478 -r7936e751fe1cd3517d0d548b53fef41f41b4db4a --- main.cpp (.../main.cpp) (revision 584874a724b2d3e8c98247d3b0e42d6a34ce9478) +++ main.cpp (.../main.cpp) (revision 7936e751fe1cd3517d0d548b53fef41f41b4db4a) @@ -380,7 +380,7 @@ gActiveCANBus = value; } } - + qDebug() << "CAN int" << gActiveCANBus; if (parser.isSet(optionSendEmptyKeepAwake)) gSendEmptyKeepAwake = true; bool ok = false; Index: sources/StateController.cpp =================================================================== diff -u -r424c81d03f7d915d39ab962f652c0b565f465bf7 -r7936e751fe1cd3517d0d548b53fef41f41b4db4a --- sources/StateController.cpp (.../StateController.cpp) (revision 424c81d03f7d915d39ab962f652c0b565f465bf7) +++ sources/StateController.cpp (.../StateController.cpp) (revision 7936e751fe1cd3517d0d548b53fef41f41b4db4a) @@ -1,6 +1,7 @@ #include #include +#include #include "StateController.h" #include "ApplicationController.h" @@ -153,6 +154,10 @@ resp.append(u32Var.value); GetValue(payload.toByteArray(), index, u32Var); + _treatmentParams.heparinPreStopMin = u32Var.value; + resp.append(u32Var.value); + + GetValue(payload.toByteArray(), index, u32Var); _treatmentParams.salineBolusVolML = u32Var.value; resp.append(u32Var.value); @@ -209,14 +214,16 @@ _sendMessages.append(resp); _isSendListReady = true; - qDebug() << "Treatment params from TPAR" << _treatmentParams.bloodFlowRateMLPM << - _treatmentParams.dialysateFlowRateMLPM << _treatmentParams.txDurationMins << - _treatmentParams.dialysateTemperatureC; + qDebug() << "Treatment params from TPAR" << _treatmentParams.bloodFlowRateMLPM + << _treatmentParams.dialysateFlowRateMLPM << _treatmentParams.txDurationMins + << _treatmentParams.dialysateTemperatureC << _treatmentParams.rinsebackFlowRateMLPM + << _treatmentParams.venousPresLimitWindowMMHG; } else if (!_treatmentParams.hasTxParamsBeenInitialized) { _treatmentParams.bloodFlowRateMLPM = DEF_TX_PARAM_BLOOD_FLOW_RATE_MLPM; _treatmentParams.dialysateFlowRateMLPM = DEF_TX_PARAM_DIAL_FLOW_RATE_MLPM; _treatmentParams.txDurationMins = DEF_TX_PARAM_PRESCRIBED_DUR_MIN; + _treatmentParams.heparinPreStopMin = 0; _treatmentParams.salineBolusVolML = DEF_TX_PARAM_SALINE_BOLUS_VOL_ML; _treatmentParams.acidConc = 0; _treatmentParams.bicarbConc = 0; @@ -239,11 +246,19 @@ void StateController::prepareOcclusionBroadcastData() { - // TODO a random variation here + float artUpperFloatWindowMMHG = static_cast(200); + float artLowerFloatWindowMMHG = static_cast(_treatmentParams.areterialPresLimitWindowMMHG); + + float venUpperFloatWindowMMHG = static_cast(200); + float venLowerFloatWindowMMHG = static_cast(_treatmentParams.venousPresLimitWindowMMHG); + + float artRandomMMHG = _randNumGenerator.generateDouble() * (artUpperFloatWindowMMHG - artLowerFloatWindowMMHG) + artLowerFloatWindowMMHG; + float venRandomMMHG = _randNumGenerator.generateDouble() * (venUpperFloatWindowMMHG - venLowerFloatWindowMMHG) + venLowerFloatWindowMMHG; + QVariantList msg; msg.append(static_cast(ID_PRESSURE_OCCLUSION_DATA_BC)); msg.append(Can_Id::eChlid_HD_Sync); - msg.append(10.2); msg.append(12.3); msg.append(0); msg.append(0); msg.append(0); + msg.append(artRandomMMHG); msg.append(venRandomMMHG); msg.append(0); msg.append(0); msg.append(0); msg.append(0); msg.append(0); msg.append(0); msg.append(0); msg.append(0); msg.append(0); msg.append(0); _isBroadcastListReady = false; @@ -465,18 +480,6 @@ prepareTreatmentTimeChangeResponse(accept, _treatmentVars.prescribedTreatmentTimeS, _treatmentVars.prescribedMaxUFVolML); - /* - QVariantList resp; - resp.append(static_cast(ID_USER_TX_TIME_CHANGES_RESP)); - resp.append(Can_Id::eChlid_HD_UI); - resp.append(accept); - resp.append(0); - resp.append(_treatmentVars.prescribedTreatmentTimeS /SECONDS_PER_MINUTE); - resp.append(_treatmentVars.prescribedMaxUFVolML); - _isSendListReady = false; - _sendMessages.append(resp); - _isSendListReady = true; -*/ } qint32 StateController::handleMsgBBPayload(const QVariant &payload) @@ -1458,7 +1461,7 @@ txStates[4] = rbSubState; prepareStatesBroadcastData(ID_HD_TX_STATES_BC, txStates); - qDebug() << "End treatment on entry"; + qDebug() << "End treatment on entry" << rbTargetVolML; _treatmentVars.broadcastIntervalCount = 0; _hasUserConfirmedToProceed = false; @@ -1523,7 +1526,7 @@ rbCountDownS--; rinsebackBC[2] = rbCountDownS; } - + prepareOcclusionBroadcastData(); prepareStatesBroadcastData(ID_HD_TX_STATES_BC, txStates); prepareRinsebackBroadcastData(rinsebackVolsML, rinsebackBC); prepareTreatmentTimeBroadcastData(); Index: sources/StateController.h =================================================================== diff -u -r424c81d03f7d915d39ab962f652c0b565f465bf7 -r7936e751fe1cd3517d0d548b53fef41f41b4db4a --- sources/StateController.h (.../StateController.h) (revision 424c81d03f7d915d39ab962f652c0b565f465bf7) +++ sources/StateController.h (.../StateController.h) (revision 7936e751fe1cd3517d0d548b53fef41f41b4db4a) @@ -3,6 +3,7 @@ #include #include +#include #include "main.h" #include "MessageGlobals.h" @@ -133,6 +134,7 @@ quint32 bloodFlowRateMLPM; quint32 dialysateFlowRateMLPM; quint32 txDurationMins; + quint32 heparinPreStopMin; quint32 salineBolusVolML; quint32 acidConc; quint32 bicarbConc; @@ -166,6 +168,7 @@ QList _broadcastMessages; QList _sendMessages; QHash _treatmentRcvdMessages; + QRandomGenerator _randNumGenerator; bool _isBroadcastListReady; // TODO use a mutex bool _isSendListReady; // Todo use a mutex Treatment_Variables _treatmentVars; Index: sources/canbus/MessageDispatcher.cpp =================================================================== diff -u -r260229a756a3ee29c681132bdc4d32204c215ceb -r7936e751fe1cd3517d0d548b53fef41f41b4db4a --- sources/canbus/MessageDispatcher.cpp (.../MessageDispatcher.cpp) (revision 260229a756a3ee29c681132bdc4d32204c215ceb) +++ sources/canbus/MessageDispatcher.cpp (.../MessageDispatcher.cpp) (revision 7936e751fe1cd3517d0d548b53fef41f41b4db4a) @@ -282,8 +282,10 @@ * \param vActionId - The ActionID of the message * \param vData - The data of the Message */ +/* void MessageDispatcher::actionTransmit(const QVariantList &vData, Sequence vSequence, Can_Id vCanId) { + Q_UNUSED(vCanId) txCount(); if (vSequence == 0) { // initialize // it's obvious that this assignment does not effect outside of the function. @@ -297,29 +299,27 @@ Can_Id canid = Can::Can_Id::eChlid_UI_HD; // TODO figure out //vCanId; if (! _interpreter.interpretMessage(vData, mData, canid)) { LOG_DEBUG(QString("Incorrect Message, cannot be interpreted, %1").arg(Format::toHexString(vActionId))); // TODO : LogInfo Improvement - qDebug() << "Cannot Interpret"; return; } - qDebug() << "Got to action" << mData << vCanId << vData[0]; + // TODO : Create a buildFrames method FrameList frameList; Sequence mSequence = vSequence; - bool mNeedsAcknow = false; //needsAcknow(vCanId); + bool mNeedsAcknow = true; //needsAcknow(vCanId); if (mNeedsAcknow) { mSequence = -mSequence; if ( ! gDisableAcknowLog ) { - LOG_APPED_UI(tr("Ack Req, Sq:%1, ID:%2").arg(mSequence).arg(Format::toHexString(vActionId))); + LOG_APPED_UI(tr("Ack Req, Sq:%1, ID:%2").arg(mSequence).arg(Format::toHexString(vActionId))); } #ifdef DEBUG_ACKBACK_HD_TO_UI - qDebug() << tr(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ UI AckReq : %1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ").arg(mSequence); + qDebug() << tr(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ UI AckReq : %1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ").arg(mSequence); #endif } // disabled coco begin validated: Has been tested manually but in this function this cannot be false because the message interpreter is doing the same validation. // still checking here in case the logic has changed therefore buildFrame should still validate the message for developer safety. if ( ! _builder.buildFrames(0, mData, frameList, mSequence) ) { LOG_DEBUG(QString("Incorrect Message cannot be built")); // TODO : LogInfo Improvement - qDebug() << "Cannot build message"; return; } // disabled coco end @@ -334,6 +334,7 @@ framesTransmit(canid, frameList); } +*/ /*! * \brief MessageDispatcher::framesTransmit * \details iterates through all the frames and emits to send the frames @@ -377,9 +378,24 @@ */ bool MessageDispatcher::checkAcknowReceived(const Message &vMessage, const QString &vSrcText) { - Q_UNUSED(vMessage); - Q_UNUSED(vSrcText); - return true; + enum GuiActionsType_Enum /* : quint16 QML does not support enum types */ { + ID_Acknow = 0xFFFF, + }; + + int mActionId = vMessage.actionId; + Sequence mSequence = vMessage.sequence; + bool ok = false; + if ( mActionId == ID_Acknow ) { + ok = true; + if ( ! gDisableAcknowLog ) { + LOG_APPED(tr(" ,%1,Ack Bak, Sq:%2").arg(vSrcText).arg(mSequence)); + } +#ifdef DEBUG_ACKBACK_HD_TO_UI + qDebug() << tr(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ HD AckBak : %1 %2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ").arg(mSequence).arg(vMessage.actionId); +#endif + emit didAcknowReceive(mSequence); + } + return ok; } /*! @@ -391,13 +407,15 @@ */ bool MessageDispatcher::checkAcknowTransmit(const Message &vMessage, const QString &vSrcText) { + enum GuiActionsType_Enum /* : quint16 QML does not support enum types */ { + ID_Acknow = 0xFFFF, + }; + bool ok = false; - int mActionId = 0; + int mActionId = vMessage.actionId; Sequence mSequence = vMessage.sequence; - // UI shall acknowledge the messages is intended for UI. if ( ! needsAcknow(vMessage.can_id)) return ok; // false - if (mSequence < 0) { ok = true; if ( ! gDisableAcknowLog ) { @@ -409,7 +427,13 @@ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ UI AckBak is immediately handled at the same place. QString dstText; Can_Id dstID = MessageInterpreter::identifyDestination(vMessage.can_id, &dstText); - actionTransmit({}, -mSequence, dstID); + Q_UNUSED(dstID) + + QVariantList msg; + msg.append(static_cast(ID_Acknow)); + msg.append(Can_Id::eChlid_HD_UI); + + actionTransmit(msg, -mSequence); if ( ! gDisableAcknowLog ) { LOG_APPED_UI(tr("Ack Bak, Sq:%1, Dst:%2").arg(-mSequence).arg(dstText)); } @@ -434,6 +458,7 @@ QVariantList mData; QString srcText; MessageInterpreter::identifySource(vMessage.can_id, &srcText); + if ( ! checkAcknowReceived(vMessage, srcText) ) { // check if the message was an acknowledge. checkAcknowTransmit(vMessage, srcText); // then if needs acknow send it immediately. } Index: sources/canbus/MessageDispatcher.h =================================================================== diff -u -r584874a724b2d3e8c98247d3b0e42d6a34ce9478 -r7936e751fe1cd3517d0d548b53fef41f41b4db4a --- sources/canbus/MessageDispatcher.h (.../MessageDispatcher.h) (revision 584874a724b2d3e8c98247d3b0e42d6a34ce9478) +++ sources/canbus/MessageDispatcher.h (.../MessageDispatcher.h) (revision 7936e751fe1cd3517d0d548b53fef41f41b4db4a) @@ -121,7 +121,7 @@ void quitThread(); // NOTE: vSequence = 0 has been removed to differentiate the overloading - void actionTransmit (const QVariantList &vData, Sequence vSequence, Can_Id vCanId = Can::Can_Id::eChlid_UI_HD); + //void actionTransmit (const QVariantList &vData, Sequence vSequence, Can_Id vCanId = Can::Can_Id::eChlid_UI_HD); void actionTransmit (const QVariantList &vData, Sequence vSequence = 0); // For dry-demo void framesTransmit (Can_Id vCan_Id, const FrameList &vFrameList); Index: sources/canbus/MessageInterpreter.cpp =================================================================== diff -u -r260229a756a3ee29c681132bdc4d32204c215ceb -r7936e751fe1cd3517d0d548b53fef41f41b4db4a --- sources/canbus/MessageInterpreter.cpp (.../MessageInterpreter.cpp) (revision 260229a756a3ee29c681132bdc4d32204c215ceb) +++ sources/canbus/MessageInterpreter.cpp (.../MessageInterpreter.cpp) (revision 7936e751fe1cd3517d0d548b53fef41f41b4db4a) @@ -209,7 +209,7 @@ int length = vData.length(); Q_UNUSED(length); INTERPRET_TRANSMIT_MESSAGE(); - qDebug() << "Len" << length << vData[0] << vPayload; + return ok; } @@ -287,6 +287,10 @@ if (vText) *vText = "DI"; 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; + default: if (vText) *vText = "XX"; return Can_Id::eChlid_UI_Sync; @@ -319,7 +323,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 : 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. + 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. } } else { Index: sources/storage/Logger.cpp =================================================================== diff -u -r5a248f0a45889844aa027f4f4a0661aa539975f0 -r7936e751fe1cd3517d0d548b53fef41f41b4db4a --- sources/storage/Logger.cpp (.../Logger.cpp) (revision 5a248f0a45889844aa027f4f4a0661aa539975f0) +++ sources/storage/Logger.cpp (.../Logger.cpp) (revision 7936e751fe1cd3517d0d548b53fef41f41b4db4a) @@ -326,7 +326,7 @@ QString fileName; if ( ! gLogLongName ) { fileName = _logFileNameDate - + _fileSeparator + "denali"; + + _fileSeparator + "drydemo"; } else { fileName = _logFileNameDate