Index: sources/view/hd/data/VHDOperationModeData.cpp =================================================================== diff -u -rf688ed9f1c64a2603a6d10fbb090b257a43e1f6f -r1da89b0452b8ef9448847618e75c118f3f58bd0c --- sources/view/hd/data/VHDOperationModeData.cpp (.../VHDOperationModeData.cpp) (revision f688ed9f1c64a2603a6d10fbb090b257a43e1f6f) +++ sources/view/hd/data/VHDOperationModeData.cpp (.../VHDOperationModeData.cpp) (revision 1da89b0452b8ef9448847618e75c118f3f58bd0c) @@ -1,15 +1,15 @@ /*! * - * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. + * Copyright (c) 2020-2023 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 VHDOperationModeData.cpp - * \author (last) Behrouz NematiPour - * \date (last) 08-Sep-2020 - * \author (original) Behrouz NematiPour - * \date (original) 13-Aug-2020 + * \file VHDOperationModeData.cpp + * \author (last) Behrouz NematiPour + * \date (last) 28-Sep-2022 + * \author (original) Behrouz NematiPour + * \date (original) 13-Aug-2020 * */ #include "VHDOperationModeData.h" @@ -21,17 +21,52 @@ void VHDOperationMode::onActionReceive(const HDOperationModeData &vData) { - opMode ( vData.mOpMode ); + opMode ( vData.mOpMode ); + subMode( vData.mSubMode ); - fault ( vData.mOpMode == GuiHDOpModes::MODE_FAUL ); - service ( vData.mOpMode == GuiHDOpModes::MODE_SERV ); - init ( vData.mOpMode == GuiHDOpModes::MODE_INIT ); - standby ( vData.mOpMode == GuiHDOpModes::MODE_STAN ); - validateParameters ( vData.mOpMode == GuiHDOpModes::MODE_TPAR ); - preTreatment ( vData.mOpMode == GuiHDOpModes::MODE_PRET ); - inTreatment ( vData.mOpMode == GuiHDOpModes::MODE_TREA ); - postTreatment ( vData.mOpMode == GuiHDOpModes::MODE_POST ); - invalidMode ( vData.mOpMode == GuiHDOpModes::MODE_NLEG ); + fault ( vData.mOpMode == GuiHDOpModes ::MODE_FAUL ); + service ( vData.mOpMode == GuiHDOpModes ::MODE_SERV ); + init ( vData.mOpMode == GuiHDOpModes ::MODE_INIT ); + standby ( vData.mOpMode == GuiHDOpModes ::MODE_STAN ); + validateParameters ( vData.mOpMode == GuiHDOpModes ::MODE_TPAR ); + preTreatment ( vData.mOpMode == GuiHDOpModes ::MODE_PRET ); + inTreatment ( vData.mOpMode == GuiHDOpModes ::MODE_TREA ); + postTreatment ( vData.mOpMode == GuiHDOpModes ::MODE_POST ); + invalidMode ( vData.mOpMode == GuiHDOpModes ::MODE_NLEG ); + + if ( _standby ) { + standbyStart ( vData.mSubMode == GuiHDStandbyStates ::STANDBY_START_STATE ); + standbyWaitTreatment ( vData.mSubMode == GuiHDStandbyStates ::STANDBY_WAIT_FOR_TREATMENT_STATE ); + standbyWaitDisinfect ( vData.mSubMode == GuiHDStandbyStates ::STANDBY_WAIT_FOR_DISINFECT_STATE ); + } + + // isTreatment ( ! _service ); // if enabled goes to home, fault from service, which shouldn't since the service is dead end. Maybe later investigate more when fault enabled. + isSettings ( _service ); + // isManager ( false ); // Always false, not used/implemented for now. + + // Go to home is kind of tricky and needs to be managed here in the backend. + // It seems we need more states. + // It can be handled in the QML but two things will happen that none of which are good. + // Problem : The issue is for example FW may change the opMode state to TPAR <=> STAN but during that, subMode is not changing. + // and when it comes back to the opMode STAN again only opMode is changing which is not enough, + // because we still need to know when we are in STAN what subMode of STAN we need to be in + // and because that does not change QML, since FW change opMode STAN <=> TPAR then UI is doing nothing. + // The solutions on QML side are: + // 1 - On each standby change STAN <=> TPAR which is not good because if in STAN we need to go to anything other than Start/waitTreatment. + // Issue : But then the home screen would jump. + // 2 - And we can also check that if subMode is Start/WaitTreatment go to home in QML. + // 3 - Make the sub PROPERTY as TRIGGER and if standby is true trigger them. + // Issue : None of the two later ideas are good either, because FW is sending the HDOpMode message each second(maybe on higher freq later) + // and then QML is updating itself on a high frequency, which is absolutely incorrect on UI side, + // Final Solution: # - The solution though is to have a special state in backend C++ that checks if opMode is standby and subMode is state/waitTreatment + // and if these conditions changed since the last time then signal emits. + // Brief : *** So actually we have a mixed condition property *** + home ( _standby && + ( // op_mode of standby is a must for the home screen + ( _standbyStart || _standbyWaitTreatment ) // actual standby and ready to start a treatment + // disinfection state but getting to home screen to do what allowed in disinfection + ) + ); } QString View::VHDOperationMode::text()