Line data Source code
1 : /* 2 : This program is free software: you can redistribute it and/or modify 3 : it under the terms of the GNU General Public License as published by 4 : the Free Software Foundation, either version 3 of the License, or 5 : (at your option) any later version. 6 : 7 : This program is distributed in the hope that it will be useful, 8 : but WITHOUT ANY WARRANTY; without even the implied warranty of 9 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 : GNU General Public License for more details. 11 : 12 : You should have received a copy of the GNU General Public License 13 : along with this program. If not, see <http://www.gnu.org/licenses/>. 14 : */ 15 : #pragma once 16 : 17 : #include "AP_EFI.h" 18 : #include "AP_EFI_State.h" 19 : #include <AP_HAL/Semaphores.h> 20 : #include <AP_Scripting/AP_Scripting_config.h> 21 : #include <GCS_MAVLink/GCS_MAVLink.h> 22 : 23 : class AP_EFI; //forward declaration 24 : 25 : class AP_EFI_Backend { 26 : public: 27 : // Constructor with initialization 28 : AP_EFI_Backend(AP_EFI &_frontend); 29 : 30 : // Virtual destructor that efi backends can override 31 0 : virtual ~AP_EFI_Backend(void) {} 32 : 33 : // Update the state structure 34 : virtual void update() = 0; 35 : 36 0 : virtual void handle_EFI_message(const mavlink_message_t &msg) {}; 37 : 38 : #if AP_SCRIPTING_ENABLED 39 0 : virtual bool handle_scripting(const EFI_State &efi_state) { return false; } 40 : #endif 41 : 42 : virtual bool healthy() const; 43 : 44 : protected: 45 : // Copies internal state to the frontend state 46 : void copy_to_frontend(); 47 : 48 : // Internal state for this driver (before copying to frontend) 49 : EFI_State internal_state; 50 : 51 : int8_t get_dronecan_node_id(void) const; 52 : float get_coef1(void) const; 53 : float get_coef2(void) const; 54 : 55 : void set_default_coef1(float coef1); 56 : 57 : float get_ecu_fuel_density(void) const; 58 : 59 : /* 60 : linearise throttle if enabled 61 : */ 62 : float linearise_throttle(float throttle_percent); 63 : 64 : HAL_Semaphore &get_sem(void); 65 : 66 : private: 67 : AP_EFI &frontend; 68 : };