/*! * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * \copyright * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, * IN PART OR IN WHOLE, * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file vtreatmentadjustmentultrafiltrationstate.cpp * \date 5/20/2020 * \author Behrouz NematiPour * */ #include "vtreatmentadjustmentultrafiltrationstate.h" // Project #include "guicontroller.h" VIEW_DEF_CLASS_ADJUSTMENT(VTreatmentAdjustmentUltrafiltrationState, AdjustUltrafiltrationStateResponseData) void VTreatmentAdjustmentUltrafiltrationState::initConnections() { ACTION_VIEW_CONNECTION(AdjustUltrafiltrationStateResponseData); ADJUST_VIEW_CONNECTION( AdjustUltrafiltrationStateRequestData); } void VTreatmentAdjustmentUltrafiltrationState::onActionReceive(const AdjustUltrafiltrationStateResponseData &vData) { adjustment_Accepted ( vData.mAccepted ); if (adjustment_Accepted()) { // the response doesn't have the state so the requested state which has been accepted is used. isPaused ( _data.requestedState == AdjustUltrafiltrationStateRequestData::ePaused ); } // *** has to be the last to let the information to be set and then emit the signal *** // *** otherwise will use the previous values before being set. *** adjustment ( true ); } void View::VTreatmentAdjustmentUltrafiltrationState::doPause() { _data.requestedState = AdjustUltrafiltrationStateRequestData::ePaused; emit didAdjustment(_data); } void View::VTreatmentAdjustmentUltrafiltrationState::doResume() { _data.requestedState = AdjustUltrafiltrationStateRequestData::eRunning; emit didAdjustment(_data); } /*! * \brief View::VTreatmentAdjustmentUltrafiltrationState::text * \details The slot to ge the Reason Description * \return Reason description as string * \note The ultrafiltration state (Resume/Pause) change has no returned reason code and it's only bool. */ QString View::VTreatmentAdjustmentUltrafiltrationState::text() { // if there is a reason (passed) it will be used QString mText = VTreatmentAdjustmentResponseBase::text(); // coco begin validated : Manually tested. // Although currently there is no reson passed in the corespounding message. // But kept this code which seems reasonable to have a reason later. if (! mText.isEmpty()) return mText; // coco end // otherwise a general message will be created/passed. if (! adjustment_Accepted()) { qDebug() << "VTreatmentAdjustmentUltrafiltrationState::text()" << true; switch (_data.requestedState) { case AdjustUltrafiltrationStateRequestData::eRunning: mText = tr("Unable to Resume Ultrafiltration or already running"); break; case AdjustUltrafiltrationStateRequestData::ePaused: mText = tr("Unable to Pause Ultrafiltration or already paused"); break; } } else { qDebug() << "VTreatmentAdjustmentUltrafiltrationState::text()" << false; } return mText; }