Ejemplo n.º 1
0
    public ExerciceTest( InputController_I inputController)
    {
        //Transition from low to high
        breathings = new List<Breathing> (1);
        breathings.Add(new Breathing(1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 10.0f,BreathingState.HOLDING_BREATH, inputController));

        indexActualBreathing = 0;
    }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Breathing"/> class starting at the given state.
 /// A breathing is composed of three state. The first is "inspiration", the second in "holding breath" and the last one is "expiration".
 /// </summary>
 /// <param name="startVolume">The volume at which we start the breathing (before inspiration). As all volume, 0 is for empty lungs and 1 for full ones (which in this case: before inspiration; is irrelevant).</param>
 /// <param name="maxVolume">The volume at which we end the inspiration and start the holding breath. As all volume, 0 is for empty (which in this case: after inspiration; is irrelevant) lungs and 1 for full ones.</param>
 /// <param name="endVolume">The volume at which we end the breathing (the end of the expiration). As all volume, 0 is for empty lungs and 1 for full ones (which in this case: after expiration; is irrelevant).</param>
 /// <param name="holdingBreathTime">The time (is seconds) the patient should hold his breath after an inspiration.</param>
 /// <param name="inspirationTime">The time (is seconds) the patient should inspiring (from <see cref="startVolume"/> to <see cref="maxVolume"/>).</param>
 /// <param name="expirationTime">The time (is seconds) the patient should expiring (from <see cref="maxVolume"/> to <see cref="endVolume"/>).</param>
 /// <param name="startState">The state at which this breathing starts.</param>
 public Breathing(float startVolume, float maxVolume, float endVolume, float inspirationTime, float holdingBreathTime, float expirationTime, BreathingState startState, InputController_I inputController)
 {
     this.startVolume = startVolume;
     this.maxVolume = maxVolume;
     this.endVolume = endVolume;
     this.inspirationTime = inspirationTime;
     this.holdingBreathTime = holdingBreathTime;
     this.expirationTime=expirationTime;
     this.inputController = inputController;
     ResetTo (startState);
 }
    /// <summary>
    /// Initializes a new instance of the <see cref="DecreasingAutogenicDrainage"/> class.
    /// </summary>
    /// <param name="nbBreathingsHigh">Number of breathing done at high pulmonary volume.</param>
    /// <param name="nbBreathingsMedium">Number of breathing done at medium pulmonary volume.</param>
    /// <param name="nbBreathingsLow">Number of breathing done at low pulmonary volume.</param>
    /// <param name="inspirationTime">The time in seconds the patient should be inpiring in each breathing.</param>
    /// <param name="holdingBreathTime">The time in seconds when the player has to hold his breath (between inspiration and expiration).</param>
    /// <param name="expirationMinTime">The minimum number of seconds the patient should be expiring in each breathing.</param>
    /// <param name="volumeRange">
    /// The volume range in which the patient should do a breathing.
    /// The high breathings will start from full lungs and deacrease of this value.
    /// The medium breathings will start at 0.5 + (this value)/2 and deacrease of this value.
    /// The low breathings will start from this value and deacrease until empty lungs.
    /// </param>
    public DecreasingAutogenicDrainage(int nbBreathingsHigh, int nbBreathingsMedium, int nbBreathingsLow, float inspirationTime, float holdingBreathTime, float expirationMinTime, float volumeRange, InputController_I inputController)
    {
        int nbBreahthings = nbBreathingsHigh + nbBreathingsMedium + nbBreathingsLow;

        //Transition from low to high
        breathings = new List<Breathing> (nbBreahthings);
        float volumeMax = 1.0f;
        float lastVolume = 0.0f;
        float transitionInspirationTime = (volumeMax - lastVolume) / (volumeRange / inspirationTime);
        float endVolume=1.0f-volumeRange;
        breathings.Add(new Breathing(lastVolume, volumeMax, endVolume, transitionInspirationTime, holdingBreathTime, expirationMinTime, BreathingState.HOLDING_BREATH, inputController));
        lastVolume = endVolume;
        //High volume
        for (int i=1; i<nbBreathingsHigh-1; i++) {
            breathings.Add(new Breathing(lastVolume, volumeMax, endVolume, inspirationTime, holdingBreathTime, expirationMinTime, inputController));
            lastVolume=endVolume;
        }
        //Transition from high to medium volume
        endVolume = 0.5f - volumeRange / 2.0f;
        float transitionExpirationMinTime = (volumeMax - endVolume) / (volumeRange / expirationMinTime);
        breathings.Add (new Breathing (lastVolume, volumeMax, endVolume, inspirationTime, holdingBreathTime, transitionExpirationMinTime, inputController));
        lastVolume = endVolume;
        //Medium volume
        volumeMax = 0.5f + volumeRange / 2.0f;
        for (int i=0; i<nbBreathingsMedium-1; i++) {
            breathings.Add(new Breathing(lastVolume, volumeMax, endVolume, inspirationTime, holdingBreathTime, expirationMinTime, inputController));
            lastVolume=endVolume;
        }
        //Transition from medium to low volume
        endVolume = 0.0f;
        transitionExpirationMinTime = (volumeMax - endVolume) / (volumeRange / expirationMinTime);
        breathings.Add (new Breathing (lastVolume, volumeMax, endVolume, inspirationTime, holdingBreathTime, transitionExpirationMinTime, inputController));
        lastVolume = endVolume;
        //Low volume
        for (int i=0; i<nbBreathingsLow; i++) {
            breathings.Add(new Breathing(lastVolume, 0.5f, endVolume, inspirationTime, holdingBreathTime, expirationMinTime, inputController));
            lastVolume=endVolume;
        }

        indexActualBreathing = 0;
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Using the input contoller, this methods update the computed volume the pation should have in his lungs.
    /// If the patient reach correctly the end volume, we go to the nexte breathing.
    /// </summary>
    /// <param name="inputController">Input controller.</param>
    /// <param name="deltaTime">The time in seconds elapsed since the last call.</param>
    public void CheckProgress(InputController_I inputController, float deltaTime)
    {
        volume=ActualBreathing.CheckProgress (inputController.GetInputState(), inputController.GetStrength(), volume, volumeMaxCalibrated, deltaTime);
        //The breathing has ended (already back to expiration) and the volume value isn't up to date.
        //We have to do a new "CheckProgress" on a non-ended breathing.
        if (ActualBreathing.IsEnded){

            //TODO: Save the breathings data here.

            if(ActualBreathing.ExpirationPercentage >= factorMinExpirationForValidation) {
                ActualBreathing.ResetTo(BreathingState.INSPIRATION);
                indexActualBreathing++;
                indexActualBreathing%=breathings.Count;
            }
            else{
                ActualBreathing.ResetTo(BreathingState.EXPIRATION);
            }
            volume=ActualBreathing.CheckProgress (inputController.GetInputState(), inputController.GetStrength(), volume, volumeMaxCalibrated, deltaTime);
        }
    }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Breathing"/> class. A breathing is composed of three state. The first is "inpiration", the second in "holding breath" and the last one is "expiration".
 /// The instantiated breathing start at "INSPIRATION" state
 /// </summary>
 /// <param name="startVolume">The volume at which we start the breathing (before inspiration). As all volume, 0 is for empty lungs and 1 for full ones (which in this case: before inspiration; is irrelevant).</param>
 /// <param name="maxVolume">The volume at which we end the inspiration and start the holding breath. As all volume, 0 is for empty (which in this case: after inspiration; is irrelevant) lungs and 1 for full ones.</param>
 /// <param name="endVolume">The volume at which we end the breathing (the end of the expiration). As all volume, 0 is for empty lungs and 1 for full ones (which in this case: after expiration; is irrelevant).</param>
 /// <param name="holdingBreathTime">The time (is seconds) the patient should hold his breath after an inspiration.</param>
 /// <param name="inspirationTime">The time (is seconds) the patient should inspiring (from <see cref="startVolume"/> to <see cref="maxVolume"/>).</param>
 /// <param name="expirationTime">The time (is seconds) the patient should expiring (from <see cref="maxVolume"/> to <see cref="endVolume"/>).</param>
 public Breathing(float startVolume, float maxVolume, float endVolume, float inspirationTime, float holdingBreathTime, float expirationTime, InputController_I inputController)
     : this(startVolume, maxVolume, endVolume, inspirationTime, holdingBreathTime, expirationTime, BreathingState.INSPIRATION, inputController)
 {
 }
 // Use this for initialization
 void Start()
 {
     inputcontroller = new KeyboardInputController(3.0f);
 }