Test mass change

parent ac8b5473
Pipeline #950 canceled with stage
...@@ -51,6 +51,10 @@ BreathingLoop::BreathingLoop() ...@@ -51,6 +51,10 @@ BreathingLoop::BreathingLoop()
initCalib(); initCalib();
resetReadingSums(); resetReadingSums();
_Pstartbuffer = 0;
_Pendbuffer = 0;
_Pstartbuffer = 0;
_flow = 0; _flow = 0;
_volume = 0; _volume = 0;
_airway_pressure = 0; _airway_pressure = 0;
...@@ -301,7 +305,8 @@ void BreathingLoop::updateCycleReadings() ...@@ -301,7 +305,8 @@ void BreathingLoop::updateCycleReadings()
_cycle_index = (_cycle_index == CYCLE_AVG_READINGS-1 ) ? 0 : _cycle_index+1; _cycle_index = (_cycle_index == CYCLE_AVG_READINGS-1 ) ? 0 : _cycle_index+1;
_cycle_readings.timestamp = tnow; _cycle_readings.timestamp = tnow;
_cycle_readings.fiO2_percent = _cycle_readings.lung_compliance; //_readings_avgs.o2_percent;// FIXME _cycle_readings.fiO2_percent = _cycle_readings.static_compliance;
//_cycle_readings.fiO2_percent = _cycle_readings.lung_compliance; //_readings_avgs.o2_percent;// FIXME
_running_inhale_minute_volume[_cycle_index] = _volume_inhale ; _running_inhale_minute_volume[_cycle_index] = _volume_inhale ;
_running_exhale_minute_volume[_cycle_index] = _volume_exhale ; _running_exhale_minute_volume[_cycle_index] = _volume_exhale ;
//logMsg(" I, E "+String(_volume_inhale)+ " "+String(_volume_exhale)); //logMsg(" I, E "+String(_volume_inhale)+ " "+String(_volume_exhale));
...@@ -334,7 +339,8 @@ void BreathingLoop::updateCycleReadings() ...@@ -334,7 +339,8 @@ void BreathingLoop::updateCycleReadings()
_cycle_readings.inhaled_tidal_volume = mvi_sum/CYCLE_AVG_READINGS; _cycle_readings.inhaled_tidal_volume = mvi_sum/CYCLE_AVG_READINGS;
_cycle_readings.exhaled_tidal_volume = mve_sum/CYCLE_AVG_READINGS; _cycle_readings.exhaled_tidal_volume = mve_sum/CYCLE_AVG_READINGS;
_cycle_readings.lung_compliance = _cycle_readings.inhaled_tidal_volume / (_cycle_readings.peak_inspiratory_pressure -_peep); _cycle_readings.lung_compliance = _cycle_readings.inhaled_tidal_volume / (_cycle_readings.peak_inspiratory_pressure -_peep);
_cycle_readings.static_compliance = _cycle_readings.tidal_volume / (_cycle_readings.plateau_pressure - _peep); _cycle_readings.static_compliance = (_volumeStandard * 0.082*293)/790;
//_cycle_readings.static_compliance = _cycle_readings.tidal_volume / (_cycle_readings.plateau_pressure - _peep);
_cycle_readings.mean_airway_pressure = _airway_pressure; _cycle_readings.mean_airway_pressure = _airway_pressure;
_cycle_readings.inhalation_pressure = _airway_pressure; _cycle_readings.inhalation_pressure = _airway_pressure;
_cycle_readings.apnea_index += (_apnea_event == true) ? 1 : 0; _cycle_readings.apnea_index += (_apnea_event == true) ? 1 : 0;
...@@ -640,7 +646,7 @@ void BreathingLoop::FSM_breathCycle() ...@@ -640,7 +646,7 @@ void BreathingLoop::FSM_breathCycle()
_pid.istep = 0; _pid.istep = 0;
_peep = _running_avg_peep; _peep = _running_avg_peep;
break; break;
case BL_STATES::INHALE: case BL_STATES::INHALE:
//_valves_controller.setValves(VALVE_STATE::CLOSED, VALVE_STATE::CLOSED, VALVE_STATE::OPEN, VALVE_STATE::CLOSED, VALVE_STATE::CLOSED);//Comment this line for the PID control during inhale //_valves_controller.setValves(VALVE_STATE::CLOSED, VALVE_STATE::CLOSED, VALVE_STATE::OPEN, VALVE_STATE::CLOSED, VALVE_STATE::CLOSED);//Comment this line for the PID control during inhale
...@@ -654,6 +660,7 @@ void BreathingLoop::FSM_breathCycle() ...@@ -654,6 +660,7 @@ void BreathingLoop::FSM_breathCycle()
// mand_vol = volumeTrigger(); // disable for now // mand_vol = volumeTrigger(); // disable for now
_mandatory_exhale = mand_ex ; // & mand_vol; _mandatory_exhale = mand_ex ; // & mand_vol;
//logMsg("inhale "+String(_valley_flow_time)+" "+_measured_durations.inhale+ " "+_measured_durations.exhale+" " +_fsm_timeout); //logMsg("inhale "+String(_valley_flow_time)+" "+_measured_durations.inhale+ " "+_measured_durations.exhale+" " +_fsm_timeout);
break; break;
case BL_STATES::PAUSE: case BL_STATES::PAUSE:
_valves_controller.setValves(VALVE_STATE::CLOSED, VALVE_STATE::CLOSED, VALVE_STATE::CLOSED, VALVE_STATE::CLOSED, VALVE_STATE::CLOSED); _valves_controller.setValves(VALVE_STATE::CLOSED, VALVE_STATE::CLOSED, VALVE_STATE::CLOSED, VALVE_STATE::CLOSED, VALVE_STATE::CLOSED);
...@@ -1279,10 +1286,15 @@ void BreathingLoop::runningAvgs() ...@@ -1279,10 +1286,15 @@ void BreathingLoop::runningAvgs()
_flow_fitter.resetCalculation(tnow); _flow_fitter.resetCalculation(tnow);
} }
if(_bl_state == BL_STATES::BUFF_PRE_INHALE ){
_Pstartbuffer = _readings_avgs.pressure_buffer; //P1
}
if(_bl_state == BL_STATES::PAUSE ){ if(_bl_state == BL_STATES::PAUSE ){
// even if pause duration is 0, this should execute once // even if pause duration is 0, this should execute once
_cycle_readings.plateau_pressure = _readings_avgs.pressure_patient; //_running_avg_plateau_pressure; _cycle_readings.plateau_pressure = _readings_avgs.pressure_patient; //_running_avg_plateau_pressure;
_cycle_readings.peak_inspiratory_pressure = _readings_avgs.pressure_inhale; _cycle_readings.peak_inspiratory_pressure = _readings_avgs.pressure_inhale;
_Pendbuffer = _readings_avgs.pressure_buffer; //P1'
} }
if ((_readings_avgs.pressure_patient > _cycle_readings.peak_inspiratory_pressure) && (_bl_state == BL_STATES::INHALE)){ if ((_readings_avgs.pressure_patient > _cycle_readings.peak_inspiratory_pressure) && (_bl_state == BL_STATES::INHALE)){
...@@ -1294,7 +1306,7 @@ void BreathingLoop::runningAvgs() ...@@ -1294,7 +1306,7 @@ void BreathingLoop::runningAvgs()
_volume_inhale = _volume; //getVolume(); _volume_inhale = _volume; //getVolume();
//logMsg("INHALE "+String(_volume_inhale)); //logMsg("INHALE "+String(_volume_inhale));
} else if (_bl_state == BL_STATES::EXHALE){ } else if (_bl_state == BL_STATES::EXHALE){
_volume_exhale = _volume_inhale - _volume; //getVolume(); _volume_exhale = _volume_inhale - _volume; //getVolume();
//if(fabs(_flow) < 0.02){ //if(fabs(_flow) < 0.02){
// _peep = _readings_avgs.pressure_patient; // _peep = _readings_avgs.pressure_patient;
//} //}
...@@ -1302,6 +1314,10 @@ void BreathingLoop::runningAvgs() ...@@ -1302,6 +1314,10 @@ void BreathingLoop::runningAvgs()
_flow_fitter.appendPoints(millis(), _flow); _flow_fitter.appendPoints(millis(), _flow);
} }
if(_bl_state == BL_STATES::EXHALE ){
_volumeStandard = ((_Pstartbuffer - _Pendbuffer) * (10/(0.0082*293)) + (_cycle_readings.plateau_pressure*(1+(0.1*(_cycle_readings.plateau_pressure -_peep)-(_peep*1))/(0.0082*293);
}
_sum_airway_pressure += _readings_avgs.pressure_patient; _sum_airway_pressure += _readings_avgs.pressure_patient;
_ap_readings_N++; _ap_readings_N++;
......
...@@ -185,6 +185,9 @@ private: ...@@ -185,6 +185,9 @@ private:
uint16_t _inhale_cycle_duration[CYCLE_AVG_READINGS]; uint16_t _inhale_cycle_duration[CYCLE_AVG_READINGS];
uint16_t _exhale_cycle_duration[CYCLE_AVG_READINGS]; uint16_t _exhale_cycle_duration[CYCLE_AVG_READINGS];
float _Pstartbuffer;
float _Pendbuffer;
float _volumeStandard;
float _flow; float _flow;
float _volume; float _volume;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment