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 | // HAL.h
#ifndef _HAL_h
#define _HAL_h
#if defined(ARDUINO) && ARDUINO >= 100
#include "arduino.h"
#else
#include "WProgram.h"
#endif
#include "generic_definitions.h"
#ifdef HARDWARE_TARGET_PLATFORM_V3
#include "fw_board_razzeto_v3.h"
#endif
#ifdef HARDWARE_TARGET_PLATFORM_V4
#include "fw_board_ni_v4.h"
#endif
#include "DebugIface.h"
#include "driver_5525DSO.h"
#include "driver_SFM3019.h"
#include "driver_SFM3000.h"
#include "driver_ADS1115.h"
#include "driver_VenturiFlowMeter.h"
#include "driver_OxygenSensor.h"
#include "PressureLoop.h"
#include "CircularBuffer.h"
class HAL<--- The class 'HAL' does not have a constructor although it has private member variables. [+]The class 'HAL' does not have a constructor although it has private member variables. Member variables of builtin types are left uninitialized when the class is instantiated. That may cause bugs or undefined behavior. <--- The class 'HAL' does not have a constructor although it has private member variables. [+]The class 'HAL' does not have a constructor although it has private member variables. Member variables of builtin types are left uninitialized when the class is instantiated. That may cause bugs or undefined behavior. <--- The class 'HAL' does not have a constructor although it has private member variables. [+]The class 'HAL' does not have a constructor although it has private member variables. Member variables of builtin types are left uninitialized when the class is instantiated. That may cause bugs or undefined behavior. <--- The class 'HAL' does not have a constructor although it has private member variables. [+]The class 'HAL' does not have a constructor although it has private member variables. Member variables of builtin types are left uninitialized when the class is instantiated. That may cause bugs or undefined behavior. <--- The class 'HAL' does not have a constructor although it has private member variables. [+]The class 'HAL' does not have a constructor although it has private member variables. Member variables of builtin types are left uninitialized when the class is instantiated. That may cause bugs or undefined behavior. <--- The class 'HAL' does not have a constructor although it has private member variables. [+]The class 'HAL' does not have a constructor although it has private member variables. Member variables of builtin types are left uninitialized when the class is instantiated. That may cause bugs or undefined behavior.
{
private:
#ifdef HARDWARE_TARGET_PLATFORM_V3
HW_V3 hwi;
#endif
#ifdef HARDWARE_TARGET_PLATFORM_V4
HW_V4 hwi;
#endif
Sensor5525DSO drv_PLoop;
Sensor5525DSO drv_PPatient;
Sensor5525DSO drv_PVenturi;
#ifdef USE_SPIROMETER_SFM3019
SensorSFM3019 drv_FlowIn;
#endif
#ifdef USE_SPIROMETER_SFM3000
SensorSFM3000 drv_FlowIn;
#endif
ADC_ADS1115 drv_ADC0;
VenturiFlowMeter drv_FlowVenturi;
OxygenSensor drv_OxygenSensor;
PressureLoopClass PressureLoop;
DriverContext _dc;
CircularBuffer *MEM_PLoop;
CircularBuffer *MEM_PPatient;
CircularBuffer *MEM_FlowIn;
CircularBuffer *MEM_FlowVenturi;
CircularBuffer* MEM_PVenturi;
uint64_t cycle_PLoop_LT;
uint64_t cycle_PPatient_LT;
uint64_t cycle_PVenturi_LT;
uint64_t cycle_FlowIn_LT;
uint64_t cycle_ADC_LT;
uint64_t cycle_Supervisor_LT;
uint64_t cycle_LT;
float Tloop, Ploop;
float Tpatient, Ppatient;
float FlowIn, TFlowIn;
float Tventuri, Pventuri;
float FlowVenturi;
float Oxygen;
float VoltageReference;
float VoltageProbe12V;
float VoltageProbe5V;
float _InputValveValue;
float _OutputValveValue;
float GasTemperature;
float Pin;
float BoardTemperature;
uint16_t SupervisorAlarms;
bool flush_pipe_mode = false;
float flush_pipe_open = 0;
float ploop_raw = 0;
float ppatient_row = 0;
public:
DebugIfaceClass dbg;
void Init();
float GetPressureValve(int32_t Delay);
float GetPressurePatient(int32_t Delay);
float GetFlowInspire(int32_t Delay);
float GetFlowVenturi(int32_t Delay);
float GetPVenturi(int32_t Delay);
void SetInputValve(float value);
float GetInputValve();
void SetOutputValve(bool value);
float GetOutputValve();
void GetInputValvePID(float *pid_slow, float *pid_fast);
void ConfigureInputValvePID(float P, float I, float D, float P2, float I2, float D2, float pid_limit);
void SetBuzzer(bool value);
void SetAlarmLed(bool value);
void SetAlarmRele(bool value);
float GetVolumeVenturi();
float GetVolumeInput();
void ResetVolumeVenturi();
void ResetVolumeInput();
bool DataAvailableOnUART0();
String ReadUART0UntilEOL();
bool WriteUART0(String s);
uint64_t GetMillis();
int64_t Get_dT_millis(uint64_t ms);
float ZeroPressureSensor(t_pressure_sensor ps);
void SetZeroPressureSensor(t_pressure_sensor ps, float value);
void CorrectZeroPressureSensor(t_pressure_sensor ps, float value);
void delay_ms(float ms);
float GetOxygen();
void CalibrateOxygenSensorInAir();
void CalibrateOxygenSensorInPureOxygen();
void TriggerAlarm(t_ALARM alarm_code);
float GetGasTemperature();
void GetPowerStatus(bool* batteryPowered, float* charge);
void FlushPipes(bool run, float valve);
void DOVenturiMeterScan();
void DOValveScan();
bool VenturiSetCoefficient(int index, float value);
void LEAKAGETest();
uint32_t GetSupervisorAlarms();
float GetBoardTemp();
float GetPin();
uint8_t i2c_scheduler;
uint8_t _adc_channel;
float ADC_Results[4];
std::function<void()> callback_ploop = NULL;
std::function<void()> callback_ppatient = NULL;
std::function<void()> callback_flowsens = NULL;
std::function<void()> callback_venturi = NULL;
std::function<void(t_ALARM alarm_code)> callback_alarm = NULL;
void addHandler_PLoop(std::function<void()> callback)
{
callback_ploop = callback;
}
void addHandler_PPatient(std::function<void()> callback)
{
callback_ppatient = callback;
}
void addHandler_FlowSens(std::function<void()> callback)
{
callback_flowsens = callback;
}
void addHandler_FlowVenturi(std::function<void()> callback)
{
callback_venturi = callback;
}
void addHandler_HardwareAlarm(std::function<void(t_ALARM alarm_code)> callback)
{
callback_alarm = callback;
}
void Tick();
};
#endif
// # # ###
// ## # #
// # # # #
// # # # #
// # # # #
// # ## #
// # # ###
//
// Nuclear Instruments 2020 - All rights reserved
// Any commercial use of this code is forbidden
// Contact info@nuclearinstruments.eu
|