Line data Source code
1 : #pragma once 2 : 3 : #include <AP_Logger/LogStructure.h> 4 : 5 : #include <AP_Airspeed/AP_Airspeed.h> 6 : 7 : class AP_DAL_Airspeed { 8 : public: 9 : 10 : // Airspeed-like methods: 11 : 12 : // return health status of sensor 13 12760030 : bool healthy(uint8_t i) const { 14 12760030 : return _RASI[i].healthy; 15 : } 16 : // return health status of primary sensor 17 2815766 : bool healthy() const { 18 2815766 : return healthy(get_primary()); 19 : } 20 : 21 : // return true if airspeed is enabled, and airspeed use is set 22 12912606 : bool use(uint8_t i) const { 23 12912606 : return _RASI[i].use; 24 : } 25 2968482 : bool use() const { 26 2968482 : return use(get_primary()); 27 : } 28 : 29 : // return the current airspeed in m/s 30 13140548 : float get_airspeed(uint8_t i) const { 31 13140548 : return _RASI[i].airspeed; 32 : } 33 3384300 : float get_airspeed() const { 34 3384300 : return get_airspeed(get_primary()); 35 : } 36 : 37 : // return time in ms of last update 38 9938261 : uint32_t last_update_ms(uint8_t i) const { return _RASI[i].last_update_ms; } 39 3372106 : uint32_t last_update_ms() const { return last_update_ms(get_primary()); } 40 : 41 : // get number of sensors 42 7080319 : uint8_t get_num_sensors(void) const { return _RASH.num_sensors; } 43 : 44 : // get current primary sensor 45 28718142 : uint8_t get_primary(void) const { return _RASH.primary; } 46 : 47 : // AP_DAL methods: 48 : AP_DAL_Airspeed(); 49 : 50 : void start_frame(); 51 : 52 : void handle_message(const log_RASH &msg) { 53 : _RASH = msg; 54 : } 55 : void handle_message(const log_RASI &msg) { 56 : _RASI[msg.instance] = msg; 57 : } 58 : 59 : private: 60 : 61 : struct log_RASH _RASH; 62 : struct log_RASI _RASI[AIRSPEED_MAX_SENSORS]; 63 : };