/*!
 *
 * Copyright (c) 2021-2024 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    PreTreatmentPrime.qml
 * \author  (last)      Behrouz NematiPour
 * \date    (last)      31-Aug-2023
 * \author  (original)  Behrouz NematiPour
 * \date    (original)  01-Mar-2021
 *
 */

// Qt
import QtQuick 2.12

// Project
//  Qml imports
import "qrc:/globals"
import "qrc:/components"
import "qrc:/pages/pretreatment"

/*!
 * \brief   The Pre Tretreatment Prime Screen
 */
PreTreatmentBase { id: _root
    objectName: "_PreTreatmentPrime"
    isComplete              : timeCircleProgressValue >= timeCircleMaximum  // TODO Update later
    completeText            : qsTr("Priming Complete!")

    // time circle
    hasTimeCircle           : true
    timeCircleMinimum       : 0
    timeCircleMaximum       : 3 * 60                        // vPreTreatmentDisposablesPrime.total          // TODO implement in later story
    timeCircleProgressValue : 0                             // vPreTreatmentDisposablesPrime.elapsed
    timeCircleTimeTextValue : timeCircleProgressValue * 60  // vPreTreatmentDisposablesPrime.remaining * 60

    // chcek list
    hasCheckList            : true
    checkListStepNames      : [
        qsTr("Blood Tubing Circuit Priming" ),
        qsTr("Dialysate Circuit Priming"    ),
    ]

    // TODO implement in later story
//    Connections { target: vPreTreatmentStates
//        function onSelfTestDryChanged                               ( vValue ) { page( _preTreatmentDrySelfTest                         , vValue       )}
//        function onSelfTestDry_startChanged                         ( vValue ) { _preTreatmentDrySelfTest        .checkList.setItemExt(0, true         )}
//        function onSelfTestDry_waitDoorCloseChanged                 ( vValue ) { _preTreatmentDrySelfTest        .checkList.setItemExt(0, vValue       )}
//        function onSelfTestDry_usedCartridgeEntered                 ( vValue ) { _preTreatmentDrySelfTest        .checkList.setItemExt(1, true         )}
//        function onSelfTestDry_cartridgeLoadedEntered               ( vValue ) { _preTreatmentDrySelfTest        .checkList.setItemExt(1, vValue       )}
//        function onSelfTestDry_pressureSensorsNormalSetupEntered    ( vValue ) { _preTreatmentDrySelfTest        .checkList.setItemExt(2, true         )}
//        function onSelfTestDry_pressureSensorsVenousSetupEntered    ( vValue ) {}
//        function onSelfTestDry_pressureSensorsVenousEntered         ( vValue ) {}
//        function onSelfTestDry_pressureSensorsArterialSetupEntered  ( vValue ) {}
//        function onSelfTestDry_pressureSensorsArterialEntered       ( vValue ) {}
//        function onSelfTestDry_pressureSensorsDecayEntered          ( vValue ) {}
//        function onSelfTestDry_pressureSensorsStabilityEntered      ( vValue ) {}
//        function onSelfTestDry_pressureSensorsNormalEntered         ( vValue ) { _preTreatmentDrySelfTest        .checkList.setItemExt(2, vValue       )}
//        function onSelfTestDry_syringePumpEntered                   ( vValue ) { _preTreatmentDrySelfTest        .checkList.setItemExt(3, vValue       )}
//        function onSelfTestDry_syringePumpOcclusionDetectionEntered ( vValue ) { _preTreatmentDrySelfTest        .checkList.setItemExt(4, vValue       )}
//        function onSelfTestDry_stoppedEntered                       ( vValue ) {}
//        function onSelfTestDry_completeEntered                      ( vValue ) {}
//    }

//    Connections { target: vPreTreatmentStates
//        function onPrimeChanged                                     ( vValue ) { page( _preTreatmentDisposablesPrime                 , vValue       )}
//        function onPrime_waitUserStartEntered                       ( vValue ) {}
//        function onPrime_salineSetupEntered                         ( vValue ) {}
//        function onPrime_salinePurgeAirEntered                      ( vValue ) {}
//        function onPrime_salineCirculateBloodCircuitEntered         ( vValue ) {}
//        function onPrime_reservoirOneFillCompleteEntered            ( vValue ) {}
//        function onPrime_dialysateDialyzerEntered                   ( vValue ) {}
//        function onPrime_salineDialyzerSetupEntered                 ( vValue ) {}
//        function onPrime_salineDialyzerEntered                      ( vValue ) {}
//        function onPrime_reservoirTwoFillCompleteEntered            ( vValue ) {}
//        function onPrime_dialysateBypassEntered                     ( vValue ) {}
//        function onPrime_wetSelfTestsEntered                        ( vValue ) {}
//        function onPrime_pauseEntered                               ( vValue ) {}
//        function onPrime_completeEntered                            ( vValue ) {}

//        //TODO  this way of handling the states are new for states which can reset to the previous states
//        // if it is successfull I may use everywhere.
//        // 1 - it uses new setItemExt
//        // 2 - bundles the states of FW in UI states
//        // setitem differences.
//        // old:
//        // 1 - the start FW state of the UI state set to true
//        // 2 - the end FW state fo the UI state set with vValue
//        // 3 - nothing for the FW in-states of the UI states
//        // new:
//        // - all set with vValue and use the  setItemExt
//        // Unkown missbehavior:
//        // - the only misbehavior is if the FW changes the FW state in the middle (in one of in-states),
//        //   since UI budles the FW states, it assumes it is done and checks the state which may not be ideal.
//        //   as an example if during the Dyalysate FW changes th state to the pause, UI may not show the Dialysaate done (probably!).
//        function onPrime__BloodCircuitEntered                       ( vValue ) { _preTreatmentDisposablesPrime   .checkList.setItemExt(0, vValue    )}
//        function onPrime__DialysateCircuitEntered                   ( vValue ) { _preTreatmentDisposablesPrime   .checkList.setItemExt(1, vValue    )}
//        function onPrime__WetSelfTestsEntered                       ( vValue ) { _preTreatmentDisposablesPrime   .checkList.setItemExt(2, vValue    )}
//    }




}
