1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643 | //
//
//
#define SCHEDULER_TIMER_PLOOP 5
#define SCHEDULER_TIMER_PPATIENT 20
#define SCHEDULER_TIMER_FLOWIN 20
#define SCHEDULER_TIMER_PVENTURI 20
#define SCHEDULER_TIMER_ADC 1000
#define SCHEDULER_TIMER_SUPERVISOR 1000
#include "HAL.h"
#include <functional>
void HAL::Init()
{
hwi.Init();
dbg.Init(DBG_WARNING, &hwi);
_dc.hwi = &hwi;
_dc.dbg = &dbg;
drv_FlowIn.Init(IIC_FLOW1, &_dc);
drv_PLoop.Init(IIC_PS_0, PLOOP_MODEL, OVS_2048, &_dc);
drv_PPatient.Init(IIC_PS_1, PPATIENT_MODEL, OVS_1024, &_dc);
drv_PVenturi.Init(IIC_PS_2, PVENTURI, OVS_1024, &_dc);
drv_FlowVenturi.Init(VENTURI_CUSTOM);
PressureLoop.Init(5, 2, &_dc);
drv_ADC0.Init(IIC_ADC_0, &_dc);
drv_OxygenSensor.Init(OxygenSensorA, &_dc);
drv_ADC0.setGain(GAIN_ONE);
MEM_PLoop = new CircularBuffer(4);
MEM_PPatient = new CircularBuffer(16);
MEM_FlowIn = new CircularBuffer(4);
MEM_FlowVenturi = new CircularBuffer(4);
MEM_PVenturi = new CircularBuffer(8);
cycle_PLoop_LT = hwi.GetMillis();
cycle_PPatient_LT = hwi.GetMillis();
cycle_FlowIn_LT = hwi.GetMillis();
cycle_PVenturi_LT = hwi.GetMillis();
cycle_ADC_LT = hwi.GetMillis();
cycle_Supervisor_LT = hwi.GetMillis();
cycle_LT = hwi.GetMillis();
_adc_channel = 0;
Tloop = 0;
Ploop = 0;
Tpatient = 0;
Ppatient = 0;
FlowIn = 0;
TFlowIn = 0;
Tventuri = 0;
Pventuri = 0;
FlowVenturi = 0;
Oxygen = 0;
VoltageReference = 2.5;
VoltageProbe12V = 12;
VoltageProbe5V = 5;
_InputValveValue = 0;
_OutputValveValue = 0;
GasTemperature = 0;
Pin = 0;
BoardTemperature = 0;
SupervisorAlarms = 0;
i2c_scheduler = 0;
flush_pipe_mode = false;
//hwi->addHandler(std::bind(&HAL::Callback, this, 1));
}
/*
void HAL::Callback(int x)
{
dbg->DbgPrint(DBG_CODE, DBG_CRITICAL, String((int32_t)hwi->GetMillis()) + " - CALLBACK CALLED " + String(x));
}*/
void HAL::Tick()
{
uint32_t ADC_LastResult;
if (flush_pipe_mode == false)
{
PressureLoop.Tick();
hwi.PWMSet(PWM_PV1, PressureLoop.GetValveControl());
}
else
{
hwi.PWMSet(PWM_PV1, flush_pipe_open);
SetOutputValve(true);
}
if (hwi.Get_dT_millis(cycle_LT) >= 3)
{
if (drv_PLoop.asyncGetResult(&ploop_raw, &Tloop))
{
if (fabs(ploop_raw) < 150)
{
Ploop = Ploop * 0.2 + ploop_raw * 0.8;
MEM_PLoop->PushData(Ploop);
PressureLoop.SetPressure(PRESSURE_VALVE, Ploop);
dbg.DbgPrint(DBG_CODE, DBG_VALUE, String((int32_t)hwi.GetMillis()) + " - Ploop: " + String(Ploop));
if (callback_ploop)
callback_ploop();
}
}
else if (drv_PPatient.asyncGetResult(&ppatient_row, &Tpatient))
{
if (fabs(ppatient_row) < 150)
{
Ppatient = Ppatient * 0.1 + ppatient_row * 0.9;
MEM_PPatient->PushData(Ppatient);
PressureLoop.SetPressure(PRESSURE_PATIENT, Ppatient);
dbg.DbgPrint(DBG_CODE, DBG_VALUE, String((int32_t)hwi.GetMillis()) + " - PPatient: " + String(Ppatient));
if (callback_ppatient)
callback_ppatient();
}
}
else if (drv_PVenturi.asyncGetResult(&Pventuri, &Tventuri))
{
if (fabs(Pventuri) < 10)
{
FlowVenturi = drv_FlowVenturi.GetFlow(Pventuri, Tventuri);
MEM_FlowVenturi->PushData(FlowVenturi);
MEM_PVenturi->PushData(Pventuri);
dbg.DbgPrint(DBG_CODE, DBG_VALUE, String((int32_t)hwi.GetMillis()) + " - PVenturi: " + String(Pventuri) + " - FlowVenturi: " + String(FlowVenturi));
if (callback_venturi)
callback_venturi();
}
}
else if (drv_ADC0.asyncGetResult(&ADC_LastResult))
{
ADC_Results[_adc_channel] = ADC_LastResult;
#ifdef HARDWARE_TARGET_PLATFORM_V4
if (_adc_channel == 0)
{
drv_OxygenSensor.setData(ADC_Results[_adc_channel], Tloop);
Oxygen = drv_OxygenSensor.GetConcentration();
}
if (_adc_channel == 1)
{
VoltageReference = ADC_Results[_adc_channel];
//TODO: Check value for alarm
}
if (_adc_channel == 2)
{
VoltageProbe12V = ((float)ADC_Results[_adc_channel]) / VoltageReference * 2.5 * 5;
if ((VoltageProbe12V < 10) || (VoltageProbe12V > 15))
TriggerAlarm(ALARM_OVER_UNDER_VOLTAGE);
}
if (_adc_channel == 3)
{
VoltageProbe5V = ((float)ADC_Results[_adc_channel]) / VoltageReference * 2.5 * 2;
if ((VoltageProbe5V < 4.7) || (VoltageProbe5V > 5.3))
TriggerAlarm(ALARM_OVER_UNDER_VOLTAGE);
}
_adc_channel++;
if (_adc_channel > 3) _adc_channel = 0;
#endif
}
else
{
switch (i2c_scheduler)
{
case 0:
if (hwi.Get_dT_millis(cycle_PLoop_LT) > SCHEDULER_TIMER_PLOOP)
{
cycle_PLoop_LT = hwi.GetMillis();
if (!drv_PLoop.asyncMeasure())
TriggerAlarm(UNABLE_TO_READ_SENSOR_PRESSURE);
}
i2c_scheduler = 1;
break;
case 1:
if (hwi.Get_dT_millis(cycle_PPatient_LT) > SCHEDULER_TIMER_PPATIENT)
{
cycle_PPatient_LT = hwi.GetMillis();
if (!drv_PPatient.asyncMeasure())
TriggerAlarm(UNABLE_TO_READ_SENSOR_PRESSURE);
}
i2c_scheduler = 2;
break;
case 2:
if (hwi.Get_dT_millis(cycle_PVenturi_LT) > SCHEDULER_TIMER_PVENTURI)
{
cycle_PVenturi_LT = hwi.GetMillis();
if (!drv_PVenturi.asyncMeasure())
TriggerAlarm(UNABLE_TO_READ_SENSOR_VENTURI);
}
i2c_scheduler = 3;
break;
case 3:
if (hwi.Get_dT_millis(cycle_ADC_LT) > SCHEDULER_TIMER_ADC)
{
cycle_ADC_LT = hwi.GetMillis();
drv_ADC0.asyncMeasure(_adc_channel);
}
i2c_scheduler = 4;
break;
case 4:
if (hwi.Get_dT_millis(cycle_Supervisor_LT) > SCHEDULER_TIMER_SUPERVISOR)
{
cycle_Supervisor_LT = hwi.GetMillis();
Pin = hwi.GetPIN();
BoardTemperature = hwi.GetBoardTemperature();
SupervisorAlarms = hwi.GetSupervisorAlarms();
//Check supervisors alarms
if (SupervisorAlarms != 0)
{
TriggerAlarm(ALARM_SUPERVISOR);
}
//Pressure Alarms
if (Pin > MAX_PIN)
{
TriggerAlarm(ALARM_PRESSURE_INPUT_TOO_HIGH);
}
if ((_InputValveValue > 0) && (Pin < MIN_PIN))
{
TriggerAlarm(ALARM_PRESSURE_INPUT_TOO_LOW);
}
//Check board temperature
if (BoardTemperature > 75)
{
TriggerAlarm(ALARM_OVERTEMPERATURE);
}
}
i2c_scheduler = 5;
break;
case 5:
if (hwi.Get_dT_millis(cycle_FlowIn_LT) > SCHEDULER_TIMER_FLOWIN)
{
cycle_FlowIn_LT = hwi.GetMillis();
if (!drv_FlowIn.doMeasure(&FlowIn, &TFlowIn))
TriggerAlarm(UNABLE_TO_READ_SENSOR_FLUX);
MEM_FlowIn->PushData(FlowIn);
GasTemperature = TFlowIn;
dbg.DbgPrint(DBG_CODE, DBG_VALUE, String((int32_t)hwi.GetMillis()) + " - Flow: " + String(FlowIn));
if (callback_flowsens)
callback_flowsens();
}
i2c_scheduler = 6;
break;
case 6:
hwi.Tick();
i2c_scheduler = 0;
break;
}
}
cycle_LT = hwi.GetMillis();
}
}
float HAL::GetPressureValve(int32_t Delay)
{
return MEM_PLoop->GetData(Delay);
}
float HAL::GetPressurePatient(int32_t Delay)
{
return MEM_PPatient->GetData(Delay);
}
float HAL::GetFlowInspire(int32_t Delay)
{
return MEM_FlowIn->GetData(Delay);
}
float HAL::GetFlowVenturi(int32_t Delay)
{
return MEM_FlowVenturi->GetData(Delay);
}
float HAL::GetPVenturi(int32_t Delay)
{
return MEM_PVenturi->GetData(Delay);
}
void HAL::SetInputValve(float value)
{
_InputValveValue = value;
PressureLoop.SetTargetPressure(value);
}
float HAL::GetInputValve()
{
return _InputValveValue;
}
void HAL::SetOutputValve(bool value)
{
_OutputValveValue = value ? 1 : 0;
hwi.IOSet(GPIO_PV2, !value);
}
float HAL::GetOutputValve()
{
return _OutputValveValue;
}
void HAL::SetBuzzer(bool value)
{
hwi.IOSet(GPIO_BUZZER, value);
}
void HAL::SetAlarmLed(bool value)
{
hwi.IOSet(GPIO_LED, value);
}
void HAL::SetAlarmRele(bool value)
{
hwi.IOSet(GPIO_RELEALLARM, value);
}
float HAL::GetVolumeVenturi()<--- The function 'GetVolumeVenturi' is never used.
{
return drv_FlowVenturi.GetIntegral();
}
float HAL::GetVolumeInput()<--- The function 'GetVolumeInput' is never used.
{
return drv_FlowIn.GetIntegral();
}
void HAL::ResetVolumeVenturi()<--- The function 'ResetVolumeVenturi' is never used.
{
drv_FlowVenturi.ResetIntegral();
}
void HAL::ResetVolumeInput()<--- The function 'ResetVolumeInput' is never used.
{
drv_FlowIn.ResetIntegral();
}
bool HAL::DataAvailableOnUART0()
{
return hwi.DataAvailableOnUART0();
}
String HAL::ReadUART0UntilEOL()
{
return hwi.ReadUART0UntilEOL();
}
bool HAL::WriteUART0(String s)
{
return hwi.WriteUART0(s);
}
void HAL::GetInputValvePID(float* pid_slow, float* pid_fast)
{
PressureLoop.GetPidMonitor(pid_slow, pid_fast);
}
uint32_t HAL::GetSupervisorAlarms()
{
return SupervisorAlarms;
}
float HAL::GetBoardTemp()
{
return BoardTemperature;
}
float HAL::GetPin()
{
return Pin;
}
uint64_t HAL::GetMillis()
{
return hwi.GetMillis();
}
int64_t HAL::Get_dT_millis(uint64_t ms)
{
return hwi.Get_dT_millis(ms);
}
float HAL::ZeroPressureSensor(t_pressure_sensor ps)
{
switch (ps)
{
case PS_LOOP:
return drv_PLoop.doZero();
break;
case PS_PATIENT:
return drv_PPatient.doZero();
break;
case PS_VENTURI:
return drv_PVenturi.doZero();
break;
default:
return 0;
break;
}
}
void HAL::SetZeroPressureSensor(t_pressure_sensor ps, float value)<--- The function 'SetZeroPressureSensor' is never used.
{
switch (ps)
{
case PS_LOOP:
drv_PLoop.setZero(value);
break;
case PS_PATIENT:
drv_PPatient.setZero(value);
break;
case PS_VENTURI:
drv_PVenturi.setZero(value);
break;
default:
break;
}
}
void HAL::CorrectZeroPressureSensor(t_pressure_sensor ps, float value)
{
switch (ps)
{
case PS_LOOP:
drv_PLoop.correctZero(value);
break;
case PS_PATIENT:
drv_PPatient.correctZero(value);
break;
case PS_VENTURI:
drv_PVenturi.correctZero(value);
break;
default:
break;
}
}
void HAL::ConfigureInputValvePID(float P, float I, float D, float P2, float I2, float D2, float pid_limit)
{
PressureLoop.ConfigurePidSlow(P2, I2, D2, pid_limit);
PressureLoop.ConfigurePidFast(P, I, D);
}
void HAL::delay_ms(float ms)
{
hwi.__delay_blocking_ms((uint32_t)ms);
}
float HAL::GetOxygen()
{
return Oxygen;
}
void HAL::CalibrateOxygenSensorInAir()
{
drv_OxygenSensor.CalibrateAir();
}
void HAL::CalibrateOxygenSensorInPureOxygen()<--- The function 'CalibrateOxygenSensorInPureOxygen' is never used.
{
drv_OxygenSensor.CalibratePureOxygen();
}
void HAL::TriggerAlarm(t_ALARM alarm_code)
{
if (callback_alarm)
callback_alarm(alarm_code);
}
float HAL::GetGasTemperature()
{
return GasTemperature;
}
void HAL::GetPowerStatus(bool* batteryPowered, float* charge)
{
hwi.GetPowerStatus(batteryPowered, charge);
}
void HAL::FlushPipes(bool run, float valve)
{
flush_pipe_mode = run;
flush_pipe_open = valve;
}
void HAL::DOVenturiMeterScan()
{
float fref, tref;
float pmeas, tmeas;
float fref_m, pmeas_m, cnt;<--- The scope of the variable 'fref_m' can be reduced. [+]The scope of the variable 'fref_m' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:<--- Unused variable: cnt
void f(int x)<--- Unused variable: cnt
{<--- Unused variable: cnt
int i = 0;<--- Unused variable: cnt
if (x) {<--- Unused variable: cnt
// it's safe to move 'int i = 0;' here<--- Unused variable: cnt
for (int n = 0; n < 10; ++n) {<--- Unused variable: cnt
// it is possible but not safe to move 'int i = 0;' here<--- Unused variable: cnt
do_something(&i);<--- Unused variable: cnt
}<--- Unused variable: cnt
}<--- Unused variable: cnt
}<--- Unused variable: cnt
When you see this message it is always safe to reduce the variable scope 1 level. <--- The scope of the variable 'pmeas_m' can be reduced. [+]The scope of the variable 'pmeas_m' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:<--- Unused variable: cnt
void f(int x)<--- Unused variable: cnt
{<--- Unused variable: cnt
int i = 0;<--- Unused variable: cnt
if (x) {<--- Unused variable: cnt
// it's safe to move 'int i = 0;' here<--- Unused variable: cnt
for (int n = 0; n < 10; ++n) {<--- Unused variable: cnt
// it is possible but not safe to move 'int i = 0;' here<--- Unused variable: cnt
do_something(&i);<--- Unused variable: cnt
}<--- Unused variable: cnt
}<--- Unused variable: cnt
}<--- Unused variable: cnt
When you see this message it is always safe to reduce the variable scope 1 level. <--- Unused variable: cnt
if (flush_pipe_mode)
{
SetOutputValve(false);
for (int i = 30; i < 100; i++)
{
hwi.PWMSet(PWM_PV1, i);
uint64_t start_time = hwi.GetMillis();
while (hwi.Get_dT_millis(start_time) < 500)
hwi.Tick();
fref_m = 0;
pmeas_m = 0;
for (int j = 0; j < 30; j++)
{
drv_FlowIn.doMeasure(&fref, &tref);
drv_PVenturi.doMeasure(&pmeas, &tmeas);
fref_m += fref;
pmeas_m += pmeas;
}
fref_m = fref_m / 30;
pmeas_m = pmeas_m / 30;
hwi.WriteUART0(String(i) + "," + String(fref_m, 5) + "," + String(pmeas_m, 5));
}
}
else
{
hwi.WriteUART0("valore=ERROR:Missing flush_pipe mode");
}
}
void HAL::DOValveScan()
{
float fref, tref;
float pmeas, tmeas;<--- The scope of the variable 'pmeas' can be reduced. [+]The scope of the variable 'pmeas' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:<--- Unused variable: tmeas
void f(int x)<--- Unused variable: tmeas
{<--- Unused variable: tmeas
int i = 0;<--- Unused variable: tmeas
if (x) {<--- Unused variable: tmeas
// it's safe to move 'int i = 0;' here<--- Unused variable: tmeas
for (int n = 0; n < 10; ++n) {<--- Unused variable: tmeas
// it is possible but not safe to move 'int i = 0;' here<--- Unused variable: tmeas
do_something(&i);<--- Unused variable: tmeas
}<--- Unused variable: tmeas
}<--- Unused variable: tmeas
}<--- Unused variable: tmeas
When you see this message it is always safe to reduce the variable scope 1 level. <--- Unused variable: tmeas
float fref_m, pmeas_m, cnt;<--- The scope of the variable 'fref_m' can be reduced. [+]The scope of the variable 'fref_m' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:<--- Unused variable: cnt
void f(int x)<--- Unused variable: cnt
{<--- Unused variable: cnt
int i = 0;<--- Unused variable: cnt
if (x) {<--- Unused variable: cnt
// it's safe to move 'int i = 0;' here<--- Unused variable: cnt
for (int n = 0; n < 10; ++n) {<--- Unused variable: cnt
// it is possible but not safe to move 'int i = 0;' here<--- Unused variable: cnt
do_something(&i);<--- Unused variable: cnt
}<--- Unused variable: cnt
}<--- Unused variable: cnt
}<--- Unused variable: cnt
When you see this message it is always safe to reduce the variable scope 1 level. <--- The scope of the variable 'pmeas_m' can be reduced. [+]The scope of the variable 'pmeas_m' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:<--- Unused variable: cnt
void f(int x)<--- Unused variable: cnt
{<--- Unused variable: cnt
int i = 0;<--- Unused variable: cnt
if (x) {<--- Unused variable: cnt
// it's safe to move 'int i = 0;' here<--- Unused variable: cnt
for (int n = 0; n < 10; ++n) {<--- Unused variable: cnt
// it is possible but not safe to move 'int i = 0;' here<--- Unused variable: cnt
do_something(&i);<--- Unused variable: cnt
}<--- Unused variable: cnt
}<--- Unused variable: cnt
}<--- Unused variable: cnt
When you see this message it is always safe to reduce the variable scope 1 level. <--- Unused variable: cnt
if (flush_pipe_mode)
{
SetOutputValve(false);
for (int i = 0; i < 100; i++)
{
hwi.PWMSet(PWM_PV1, i);
hwi.__delay_blocking_ms(250);
fref_m = 0;
pmeas_m = 0;<--- Variable 'pmeas_m' is assigned a value that is never used.
for (int j = 0; j < 30; j++)
{
drv_FlowIn.doMeasure(&fref, &tref);
fref_m += fref;
pmeas_m += pmeas;<--- Uninitialized variable: pmeas<--- Variable 'pmeas_m' is assigned a value that is never used.
}
fref_m = fref_m / 30;
hwi.WriteUART0(String(i) + "," + String(fref_m, 5));
}
for (int i = 100; i > 0; i--)
{
hwi.PWMSet(PWM_PV1, i);
hwi.__delay_blocking_ms(250);
fref_m = 0;
pmeas_m = 0;<--- Variable 'pmeas_m' is assigned a value that is never used.
for (int j = 0; j < 30; j++)
{
drv_FlowIn.doMeasure(&fref, &tref);
fref_m += fref;
pmeas_m += pmeas;<--- Uninitialized variable: pmeas<--- Variable 'pmeas_m' is assigned a value that is never used.
}
fref_m = fref_m / 30;
hwi.WriteUART0(String(i) + "," + String(fref_m, 5));
}
}
else
{
hwi.WriteUART0("valore=ERROR:Missing flush_pipe mode");
}
}
bool HAL::VenturiSetCoefficient(int index, float value)
{
return drv_FlowVenturi.VenturiSetCoefficient(index, value);
}
void HAL::LEAKAGETest()
{
SetOutputValve(false);
SetInputValve(30);
for (int i = 0; i < 12; i++)
{
float pLmeas, tLmeas;
float pPmeas, tPmeas;
drv_PLoop.doMeasure(&pLmeas, &tLmeas);
drv_PPatient.doMeasure(&pPmeas, &tPmeas);
hwi.WriteUART0(String(i * 50 / 12) + "," + String(pLmeas, 5) + "," + String(pPmeas, 5));
uint64_t start_time = hwi.GetMillis();
while (hwi.Get_dT_millis(start_time) < 250)
Tick();
}
SetInputValve(0);
for (int i = 0; i < 36; i++)
{
float pLmeas, tLmeas;
float pPmeas, tPmeas;
drv_PLoop.doMeasure(&pLmeas, &tLmeas);
drv_PPatient.doMeasure(&pPmeas, &tPmeas);
hwi.WriteUART0(String(50 + (i * 50 / 35)) + "," + String(pLmeas, 5) + "," + String(pPmeas, 5));
uint64_t start_time = hwi.GetMillis();
while (hwi.Get_dT_millis(start_time) < 250)
Tick();
}
SetOutputValve(false);
}
// # # ###
// ## # #
// # # # #
// # # # #
// # # # #
// # ## #
// # # ###
//
// Nuclear Instruments 2020 - All rights reserved
// Any commercial use of this code is forbidden
// Contact info@nuclearinstruments.eu
|