Index: sources/view/VTreatmentCreate.cpp =================================================================== diff -u -r9e234daa89b49df33be6faeaa597e6592526b539 -red0d4b2c30034692c21e5f4997edd253ca7d855b --- sources/view/VTreatmentCreate.cpp (.../VTreatmentCreate.cpp) (revision 9e234daa89b49df33be6faeaa597e6592526b539) +++ sources/view/VTreatmentCreate.cpp (.../VTreatmentCreate.cpp) (revision ed0d4b2c30034692c21e5f4997edd253ca7d855b) @@ -36,14 +36,14 @@ connect(&_GuiController, SIGNAL(didActionReceive(AdjustTreatmentParametersResponseData)), this, SLOT(doActionReceive(AdjustTreatmentParametersResponseData))); - connect(this, SIGNAL(requestSelectParameters(StartTreatmentRequestData)), - &_GuiController, SLOT(doAdjustment(StartTreatmentRequestData))); + connect(this, SIGNAL(requestSelectParameters(TreatmentStartRequestData)), + &_GuiController, SLOT(doAdjustment(TreatmentStartRequestData))); - connect(this, SIGNAL(requestConfirm(ConfirmTreatmentRequestData)), - &_GuiController, SLOT(doAdjustment(ConfirmTreatmentRequestData))); + connect(this, SIGNAL(requestConfirm(TreatmentConfirmRequestData)), + &_GuiController, SLOT(doAdjustment(TreatmentConfirmRequestData))); - connect(&_GuiController, SIGNAL(didActionReceive(StartTreatmentResponseData)), - this, SLOT(doActionReceive(StartTreatmentResponseData))); + connect(&_GuiController, SIGNAL(didActionReceive(TreatmentStartResponseData)), + this, SLOT(doActionReceive(TreatmentStartResponseData))); connect(this, SIGNAL(requestConcurrentSave(QString,QString,bool)), &_FileSaver, SLOT(onConcurrentSave(QString,QString,bool))); @@ -62,7 +62,7 @@ if (!FileHandler::readJSON(path, obj)) { // TODO: notify user - LOG_EVENT(tr("Could not load treatment parameter ranges from %0").arg(path)); + LOG_EVENT(tr("Could not load treatment parameter ranges from %1").arg(path)); return QJsonObject(); } @@ -83,7 +83,7 @@ else if (key == GET_VARIABLE_NAME(heparinStopTimeMin)) _heparinStopTimeMin = value.toInt(); else if (key == GET_VARIABLE_NAME(heparinStopTimeMax)) _heparinStopTimeMax = value.toInt(); else if (key == GET_VARIABLE_NAME(salineBolusVolumeMin)) _salineBolusVolumeMin = value.toInt(); - else if (key == GET_VARIABLE_NAME(salineBolusVolumeMax)) _salineBolusVolumeMax = value.toInt(); + else if (key == GET_VARIABLE_NAME(salineBolusVolumeMax)) _salineBolusVolumeMax = value.toInt(); // options else if (key == GET_VARIABLE_NAME(acidConcentrateOptions)) _acidConcentrateOptions = jsonArrayToStringList(value.toArray()); else if (key == GET_VARIABLE_NAME(bicarbonateConcentrateOptions)) _bicarbonateConcentrateOptions = jsonArrayToStringList(value.toArray()); @@ -328,7 +328,7 @@ emit fwValidationFailed(enumToString(static_cast(data.requestValid))); } - qDebug() << "fw validation success = " << success; + LOG_DEBUG(QString("FW Validation Success? %1").arg(success)); if (success) { @@ -345,13 +345,15 @@ * to start selecting treatment parameters, cancel, or start the treatment * @param messageData */ -void VTreatmentCreate::doActionReceive(const StartTreatmentResponseData &messageData) +void VTreatmentCreate::doActionReceive(const TreatmentStartResponseData &messageData) { - qDebug() << "Received response after start treatment request: " << messageData.startTreatmentResponse; + LOG_DEBUG(QString("Received response after start treatment request: %1, Reason: %2") + .arg(messageData.startTreatmentResponse) + .arg(messageData.startTreatmentRejectReason)); if (messageData.startTreatmentResponse != 1) return; - if (startTreatmentRequest.request == StartTreatmentRequestData::eCancel) + if (startTreatmentRequest.request == TreatmentStartRequestData::eCancel) goToNextPage(false); else goToNextPage(true); @@ -365,7 +367,7 @@ */ void VTreatmentCreate::goToNextPage(bool forward) { - qDebug() << __FUNCTION__ << pageToShow; + LOG_DEBUG(QString("Create treatment: go to page #%1").arg(pageToShow)); switch (pageToShow) { @@ -435,9 +437,8 @@ * application controller will save the data to disk. */ void VTreatmentCreate::doFinishedConfirm() { - qDebug() << "Finished create treatment confirm..."; + LOG_DEBUG(QString("Finished create treatment confirm...")); - QJsonObject obj { {"bloodFlowRate", QString::number(treatmentData.bloodFlowRate)}, {"dialysateFlowRate", QString::number(treatmentData.dialysateFlowRate)}, @@ -463,7 +464,7 @@ saveNewTreatment(obj); // Tell FW we confirm - confirmTreatmentRequest.request = ConfirmTreatmentRequestData::eConfirm; + confirmTreatmentRequest.request = TreatmentConfirmRequestData::eConfirm; emit requestConfirm(confirmTreatmentRequest); // no FW response required @@ -486,6 +487,7 @@ i++; } QString filename = QString("%0treatment%1.json").arg(dir).arg(i); + _requestedSaveNewTreatmentProfile = true; emit requestConcurrentSave(filename, document.toJson(), false); return filename; } @@ -548,12 +550,21 @@ return FileHandler::write(filename, csvData); } +/*! + * \brief VTreatmentCreate::onFinishedSaveNewTreatment + * Called when any file has been saved to disk. If this + * class requested the + * \param success - (bool) Whether saving was successful + */ void VTreatmentCreate::onFinishedSaveNewTreatment(bool success) { - if (success) { - qDebug() << "------------------> Saved a new treatment."; - } else { - qDebug() << "------------------> Failed to save new treatment."; + if (_requestedSaveNewTreatmentProfile) { + if (success) { + LOG_DEBUG("Treatment profile saved successfully."); + } else { + LOG_DEBUG("Failed to save the treatment profile."); + } + _requestedSaveNewTreatmentProfile = false; } } @@ -569,16 +580,6 @@ } /** - * \brief VCreateTreatment::start - * Called when user is ready to begin a new treatment. - */ -void VTreatmentCreate::doStartTreatment() { - qDebug() << "Requesting to start a treatment..."; - startTreatmentRequest.request = StartTreatmentRequestData::eStartTreatment; - emit requestSelectParameters(startTreatmentRequest); -} - -/** * \brief VCreateTreatment::validate * Validates the create new treatment input. * \param vData - the selected TreatmentParametersData @@ -869,7 +870,7 @@ void VTreatmentCreate::doSelectParameters() { qDebug() << "Sending request to FW to select parameters..."; - startTreatmentRequest.request = StartTreatmentRequestData::eSelectParams; + startTreatmentRequest.request = TreatmentStartRequestData::eSelectParams; emit requestSelectParameters(startTreatmentRequest); } @@ -880,19 +881,19 @@ void VTreatmentCreate::doCancelSelectingParameters() { qDebug() << "Sending request to FW to cancel selecting parameters..."; - startTreatmentRequest.request = StartTreatmentRequestData::eCancel; + startTreatmentRequest.request = TreatmentStartRequestData::eCancel; emit requestSelectParameters(startTreatmentRequest); } /** * @brief VCreateTreatment::doCancelConfirmParameters - * Notifies FW the user has cancelled confirming the treatment parameters + * Notifies FW the user has canceled confirming the treatment parameters */ void VTreatmentCreate::doCancelConfirmParameters() { // Tell FW we cancel confirm qDebug() << "Telling FW user is cancelling confirm treatment parameters..."; - confirmTreatmentRequest.request = ConfirmTreatmentRequestData::eCancel; + confirmTreatmentRequest.request = TreatmentConfirmRequestData::eCancel; emit requestConfirm(confirmTreatmentRequest); goToNextPage(false); }