/*! * * 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 VHDTreatmentStatesData.cpp * \author (last) Behrouz NematiPour * \date (last) 07-Feb-2021 * \author (original) Behrouz NematiPour * \date (original) 13-Aug-2020 * */ #include "VHDTreatmentStatesData.h" // Project #include "GuiController.h" VIEW_DEF_CLASS(VHDTreatmentStates) /*! * \brief VTreatmentAdjustmentSaline::initConnections * \details Initializes the message(s) connection * \note This class not only listens to its dedicated message TreatmentStatesData, * But also listens to other messages which affect ultrafiltration and saline bolus state. * These extra messages are AdjustSalineResponseData , AdjustUltrafiltrationStateResponseData. * Which ever comes first will set its related properties. * Since the properties wont set twice if they have the same value it doesn't affect performance so much. * Also FW suppose to send the TreatmentStatesData related message immediately after the two others. */ void VHDTreatmentStates::initConnections() { ACTION_VIEW_CONNECTION(TreatmentStatesData ); // these messages sending the same states as in message 15 (TreatmentStates above) // it is redundant and with a better messaging protocol // the one in the Adjustment messages should be removed since it is not sent on each state change // and will be sent only once to the request. ACTION_VIEW_CONNECTION(AdjustUltrafiltrationStateResponseData ); ACTION_VIEW_CONNECTION(AdjustSalineResponseData ); ACTION_VIEW_CONNECTION(AdjustHeparinResponseData ); } /*! * \brief VHDTreatmentStates::onActionReceive * \details sets the properties for the received data of Treatment States * \param vData - Treatment States data */ void VHDTreatmentStates::onActionReceive(const TreatmentStatesData &vData) { subMode ( vData.mSubMode ); ufState ( vData.mUFState ); salineState ( vData.mSalineState ); // Ultrafiltration states ufStart ( vData.mUFState == GuiUFStates ::UF_START_STATE ); ufPaused ( vData.mUFState == GuiUFStates ::UF_PAUSED_STATE ); ufRunning ( vData.mUFState == GuiUFStates ::UF_RUNNING_STATE ); ufOff ( vData.mUFState == GuiUFStates ::UF_OFF_STATE ); ufCompleted ( vData.mUFState == GuiUFStates ::UF_COMPLETED_STATE ); // Saline Bolus states sbIdle ( vData.mSalineState == GuiSalineStates ::SALINE_BOLUS_STATE_IDLE ); sbWaitPump ( vData.mSalineState == GuiSalineStates ::SALINE_BOLUS_STATE_WAIT_FOR_PUMPS_STOP ); sbRunning ( vData.mSalineState == GuiSalineStates ::SALINE_BOLUS_STATE_IN_PROGRESS ); sbMaxReached ( vData.mSalineState == GuiSalineStates ::SALINE_BOLUS_STATE_MAX_DELIVERED ); // Heparin States hpOff ( vData.mHeparinState == GuiHeparinStates ::HEPARIN_STATE_OFF ); hpPaused ( vData.mHeparinState == GuiHeparinStates ::HEPARIN_STATE_PAUSED ); hpInitial_bolus ( vData.mHeparinState == GuiHeparinStates ::HEPARIN_STATE_INITIAL_BOLUS ); hpDispensing ( vData.mHeparinState == GuiHeparinStates ::HEPARIN_STATE_DISPENSING ); hpCompleted ( vData.mHeparinState == GuiHeparinStates ::HEPARIN_STATE_COMPLETED ); hpEmpty ( vData.mHeparinState == GuiHeparinStates ::HEPARIN_STATE_EMPTY ); // Treatment states // Treatment states - Basics txStart ( vData.mSubMode == GuiTreatmentStates ::TREATMENT_START_STATE ); // Treatment states - Dialysis txDialysis ( vData.mSubMode == GuiTreatmentStates ::TREATMENT_DIALYSIS_STATE ); // NOTE: For Rinseback and Recirculate // 1 - it seems we may never need the txRinseback // since in the Rinseback state parameter of the Treatment State the first state of each has the same meaning // it may only be used to know when those parameters have valid values to update the properties. // Kept for now because cannot be sure that it will change later or not. // 2 - if there could be a way to export enums to qml and qml can raise an error if an incorrect enum used, // then it would is absolutely preferred to use enum instead of properties // currently if just one property being defined/used to send the current state to the qml, there is no way to make sure if incorrect/undefined // enum is used or not. // in Qt user/developer can literally type GuiActions.abcdefg and qml will never complain and only if compared with the state will return false. // Treatment states - Rinse back // Rinseback states bool mRinseback = vData.mSubMode == GuiTreatmentStates ::TREATMENT_RINSEBACK_STATE ; if ( mRinseback ) { rbInit ( vData.mRinsebackState == GuiRinsebackStates ::RINSEBACK_STOP_INIT_STATE ); rbRun ( vData.mRinsebackState == GuiRinsebackStates ::RINSEBACK_RUN_STATE ); rbPaused ( vData.mRinsebackState == GuiRinsebackStates ::RINSEBACK_PAUSED_STATE ); rbStop ( vData.mRinsebackState == GuiRinsebackStates ::RINSEBACK_STOP_STATE ); rbAdditional ( vData.mRinsebackState == GuiRinsebackStates ::RINSEBACK_RUN_ADDITIONAL_STATE ); } txRinseback ( mRinseback ); // it's the main rinseback even so moved last to have all the sub-rinseback-states updated prior to. // Recirculate states bool mRecirculate = vData.mSubMode == GuiTreatmentStates ::TREATMENT_RECIRC_STATE ; if ( mRecirculate ) { rcStarted ( vData.mRecirculateState == GuiRecirculateStates ::TREATMENT_RECIRC_RECIRC_STATE ); rcStopped ( vData.mRecirculateState == GuiRecirculateStates ::TREATMENT_RECIRC_STOPPED_STATE ); } txRecirculate ( mRecirculate ); // it's the main recirculate even so moved last to have all the sub-recirculate-states updated prior to. // Blood Prime states bool mBloodPrime = vData.mSubMode == GuiTreatmentStates ::TREATMENT_BLOOD_PRIME_STATE ; if ( mBloodPrime ) { bpRamp ( vData.mBloodPrimeState == GuiBloodPrimeStates ::BLOOD_PRIME_RAMP_STATE ); } txBloodPrime ( mBloodPrime ); // Treatment End states bool mTreatmentEnd = vData.mSubMode == GuiTreatmentStates ::TREATMENT_END_STATE ; if ( mTreatmentEnd ) { teWaitRinseback ( vData.mTreatmentEndState == GuiTreatmentEndStates ::TREATMENT_END_WAIT_FOR_RINSEBACK_STATE ); tePaused ( vData.mTreatmentEndState == GuiTreatmentEndStates ::TREATMENT_END_PAUSED_STATE ); } txEnd ( mTreatmentEnd ); // Treatment Stop states bool mTreatmentStop = vData.mSubMode == GuiTreatmentStates ::TREATMENT_STOP_STATE ; if ( mTreatmentStop ) { tsRecirculate ( vData.mTreatmentStopState == GuiTreatmentStopStates ::TREATMENT_STOP_RECIRC_STATE ); tsRecirculateNo ( vData.mTreatmentStopState == GuiTreatmentStopStates ::TREATMENT_STOP_NO_RECIRC_STATE ); } txStop ( mTreatmentStop ); } /*! * \brief VHDTreatmentStates::onActionReceive * \details message handler for the message AdjustUltrafiltrationStateResponse data * \param vData - AdjustUltrafiltrationStateResponse data */ void VHDTreatmentStates::onActionReceive(const AdjustUltrafiltrationStateResponseData &vData) { // Ultrafiltration states ufStart ( vData.mState == GuiUFStates ::UF_START_STATE ); ufPaused ( vData.mState == GuiUFStates ::UF_PAUSED_STATE ); ufRunning ( vData.mState == GuiUFStates ::UF_RUNNING_STATE ); ufOff ( vData.mState == GuiUFStates ::UF_OFF_STATE ); ufCompleted ( vData.mState == GuiUFStates ::UF_COMPLETED_STATE ); } /*! * \brief VHDTreatmentStates::onActionReceive * \details message handler for the message AdjustSalineResponseData data * \param vData - AdjustSalineResponseData data */ void VHDTreatmentStates::onActionReceive(const AdjustSalineResponseData &vData) { // Saline Bolus states sbIdle ( vData.mState == GuiSalineStates ::SALINE_BOLUS_STATE_IDLE ); sbWaitPump ( vData.mState == GuiSalineStates ::SALINE_BOLUS_STATE_WAIT_FOR_PUMPS_STOP ); sbRunning ( vData.mState == GuiSalineStates ::SALINE_BOLUS_STATE_IN_PROGRESS ); sbMaxReached ( vData.mState == GuiSalineStates ::SALINE_BOLUS_STATE_MAX_DELIVERED ); } /*! * \brief VHDTreatmentStates::onActionReceive * \details message handler for the message AdjustHeparinResponseData data * \param vData - AdjustHeparinResponseData data */ void VHDTreatmentStates::onActionReceive(const AdjustHeparinResponseData &vData) { // Saline Bolus states hpOff ( vData.mState == GuiHeparinStates ::HEPARIN_STATE_OFF ); hpPaused ( vData.mState == GuiHeparinStates ::HEPARIN_STATE_PAUSED ); hpInitial_bolus ( vData.mState == GuiHeparinStates ::HEPARIN_STATE_INITIAL_BOLUS ); hpDispensing ( vData.mState == GuiHeparinStates ::HEPARIN_STATE_DISPENSING ); hpCompleted ( vData.mState == GuiHeparinStates ::HEPARIN_STATE_COMPLETED ); hpEmpty ( vData.mState == GuiHeparinStates ::HEPARIN_STATE_EMPTY ); }