2017-02-07 15:43:01 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AP_Param/AP_Param.h>
|
|
|
|
|
|
|
|
#define LEAKDETECTOR_MAX_INSTANCES 3
|
|
|
|
|
|
|
|
#define LEAKDETECTOR_COOLDOWN_MS 3000 // Status will return true for this long after last time leak was detected
|
|
|
|
|
|
|
|
class AP_LeakDetector_Backend;
|
|
|
|
|
|
|
|
class AP_LeakDetector {
|
|
|
|
|
|
|
|
friend class AP_LeakDetector_Analog;
|
|
|
|
friend class AP_LeakDetector_Digital;
|
|
|
|
|
|
|
|
public:
|
2017-12-12 21:06:12 -04:00
|
|
|
AP_LeakDetector();
|
2017-08-23 11:59:52 -03:00
|
|
|
|
|
|
|
/* Do not allow copies */
|
2022-09-30 06:50:43 -03:00
|
|
|
CLASS_NO_COPY(AP_LeakDetector);
|
2017-02-07 15:43:01 -04:00
|
|
|
|
|
|
|
struct LeakDetector_State {
|
|
|
|
uint8_t instance;
|
|
|
|
bool status; // leaking?
|
|
|
|
};
|
|
|
|
|
|
|
|
// Return current status
|
|
|
|
bool get_status(void) const { return _status; }
|
|
|
|
|
|
|
|
// Set status externally, ie via mavlink message from subsystems
|
|
|
|
void set_detect(void);
|
|
|
|
|
|
|
|
// Initialize all drivers
|
|
|
|
void init(void);
|
|
|
|
|
|
|
|
// Update all drivers
|
|
|
|
bool update(void);
|
|
|
|
|
|
|
|
static const struct AP_Param::GroupInfo var_info[];
|
|
|
|
|
|
|
|
private:
|
|
|
|
AP_LeakDetector_Backend *_drivers[LEAKDETECTOR_MAX_INSTANCES];
|
|
|
|
LeakDetector_State _state[LEAKDETECTOR_MAX_INSTANCES];
|
|
|
|
|
|
|
|
bool _status; // Current status, true if leak detected, false if all sensors dry
|
|
|
|
uint32_t _last_detect_ms;
|
|
|
|
|
2022-10-20 12:09:07 -03:00
|
|
|
enum _signal_types {
|
|
|
|
DISABLED=-1,
|
|
|
|
ANALOG=0,
|
|
|
|
DIGITAL=1
|
|
|
|
};
|
|
|
|
AP_Int8 _type[LEAKDETECTOR_MAX_INSTANCES]; // Signal type configured at the input pin (analog, digital, disabled)
|
2017-02-07 15:43:01 -04:00
|
|
|
AP_Int8 _pin[LEAKDETECTOR_MAX_INSTANCES]; // Pin that detector is connected to
|
|
|
|
AP_Int8 _default_reading[LEAKDETECTOR_MAX_INSTANCES]; // Default reading when leak detector is dry
|
|
|
|
};
|