@@ -44,7 +44,7 @@ int startInspiration_afterOneInspiration_openInspiratoryValve() {
4444
4545 //initialize the function get_current_time
4646 int breath_cycle_duration = 60000 /RR [0 ];
47- int times [1 ] = {breath_cycle_duration + 1 };
47+ int times [1 ] = {breath_cycle_duration };
4848 set_current_time (times );
4949
5050 //initialize the function to get circuit pressure
@@ -63,6 +63,35 @@ int startInspiration_afterOneInspiration_openInspiratoryValve() {
6363 assertTrue (inspiratory_valve_status == VALVE_OPEN );
6464}
6565
66+ int startExpiration_afterOneInspiration_closeInspiratoryValve () {
67+ //initialize the function get_respiratory_rate
68+ uint32_t RR [1 ] = {20 };
69+ status_t status [1 ] = {STATUS_OK };
70+ set_respiratory_rate (RR , status );
71+
72+ int breath_cycle_duration = 60000 /RR [0 ];
73+
74+ //initialize the selected inspiratory time
75+ uint32_t insp_time [1 ] = {breath_cycle_duration /2 };
76+ set_selected_inspiratory_time (insp_time , status );
77+
78+ //initialize the function get_current_time
79+ int times [1 ] = {breath_cycle_duration + insp_time [0 ]};
80+ set_current_time (times );
81+
82+ //initialize the function to get circuit pressure
83+ uint32_t inspiratory [1 ] = {40 };
84+ uint32_t expiratory [1 ] = {41 };
85+ set_inspiratory_pressure (inspiratory , status );
86+ set_expiratory_pressure (expiratory , status );
87+
88+ //reinitialize the system to be sure that the valve wasn't previously open
89+ start_expiration ();
90+
91+ int inspiratory_valve_status = get_inspiratory_valve_status ();
92+ assertTrue (inspiratory_valve_status == VALVE_CLOSE );
93+ }
94+
6695int startInspiration_afterOneInspiration_setsVentilationPhaseToInspiration () {
6796 //initialize the function get_respiratory_rate
6897 uint32_t RR [1 ] = {20 };
@@ -71,7 +100,7 @@ int startInspiration_afterOneInspiration_setsVentilationPhaseToInspiration() {
71100
72101 //initialize the function get_current_time
73102 int breath_cycle_duration = 60000 /RR [0 ];
74- int times [1 ] = {(breath_cycle_duration + 1 ) * 2 };
103+ int times [1 ] = {(breath_cycle_duration ) * 2 };
75104 set_current_time (times );
76105
77106 //initialize the function to get circuit pressure
@@ -88,6 +117,35 @@ int startInspiration_afterOneInspiration_setsVentilationPhaseToInspiration() {
88117 assertTrue (ventilation_phase == 1 );
89118}
90119
120+ int startExpiration_afterOneInspiration_opensExpiratoryValve () {
121+ //initialize the function get_respiratory_rate
122+ uint32_t RR [1 ] = {20 };
123+ status_t status [1 ] = {STATUS_OK };
124+ set_respiratory_rate (RR , status );
125+
126+ int breath_cycle_duration = 60000 /RR [0 ];
127+
128+ //initialize the selected inspiratory time
129+ uint32_t insp_time [1 ] = {breath_cycle_duration /2 };
130+ set_selected_inspiratory_time (insp_time , status );
131+
132+ //initialize the function get_current_time
133+ int times [1 ] = {breath_cycle_duration * 2 + insp_time [0 ]};
134+ set_current_time (times );
135+
136+ //initialize the function to get circuit pressure
137+ uint32_t inspiratory [1 ] = {40 };
138+ uint32_t expiratory [1 ] = {41 };
139+ set_inspiratory_pressure (inspiratory , status );
140+ set_expiratory_pressure (expiratory , status );
141+
142+ //reinitialize the system to be sure that the valve wasn't previously open
143+ start_expiration ();
144+
145+ int expiratory_valve_status = get_expiratory_valve_status ();
146+ assertTrue (expiratory_valve_status == VALVE_OPEN );
147+ }
148+
91149int startInspiration_afterTwoInspirations_updatesStartCurrentBreathCycle () {
92150 //initialize the function get_respiratory_rate
93151 uint32_t RR [1 ] = {20 };
@@ -96,7 +154,7 @@ int startInspiration_afterTwoInspirations_updatesStartCurrentBreathCycle() {
96154
97155 //initialize the function get_current_time
98156 int breath_cycle_duration = 60000 /RR [0 ];
99- int time = (breath_cycle_duration + 1 ) * 3 ;
157+ int time = (breath_cycle_duration ) * 3 ;
100158 int times [1 ] = {time };
101159 set_current_time (times );
102160
@@ -114,6 +172,35 @@ int startInspiration_afterTwoInspirations_updatesStartCurrentBreathCycle() {
114172 assertTrue (time_of_start_current_breath_cycle == time );
115173}
116174
175+ int startExpiration_afterThreeInspiration_updatesVentilationPhase () {
176+ //initialize the function get_respiratory_rate
177+ uint32_t RR [1 ] = {20 };
178+ status_t status [1 ] = {STATUS_OK };
179+ set_respiratory_rate (RR , status );
180+
181+ int breath_cycle_duration = 60000 /RR [0 ];
182+
183+ //initialize the selected inspiratory time
184+ uint32_t insp_time [1 ] = {breath_cycle_duration /2 };
185+ set_selected_inspiratory_time (insp_time , status );
186+
187+ //initialize the function get_current_time
188+ int times [1 ] = {breath_cycle_duration * 3 + insp_time [0 ]};
189+ set_current_time (times );
190+
191+ //initialize the function to get circuit pressure
192+ uint32_t inspiratory [1 ] = {40 };
193+ uint32_t expiratory [1 ] = {41 };
194+ set_inspiratory_pressure (inspiratory , status );
195+ set_expiratory_pressure (expiratory , status );
196+
197+ //reinitialize the system to be sure that the valve wasn't previously open
198+ start_expiration ();
199+
200+ int ventilation_phase = get_ventilation_phase ();
201+ assertTrue (ventilation_phase == 2 );
202+ }
203+
117204int startInspiration_duringInspiration_doesNotopenInspiratoryValve () {
118205 int times [1 ] = {0 };
119206 set_current_time (times );
@@ -158,7 +245,7 @@ int startInspiration_duringInspiration_doesNotChangeVentilationPhase() {
158245 start_inspiration ();
159246
160247 int ventilation_phase = get_ventilation_phase ();
161- assertTrue (ventilation_phase == 4 );
248+ assertTrue (ventilation_phase == 2 );
162249}
163250
164251int startInspiration_duringInspiration_doesNotUpdateStartOfcurrentBreathCycle () {
0 commit comments