CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_EFI/AP_EFI_Backend.h
Views: 1798
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
virtual ~AP_EFI_Backend(void) {}
32
33
// Update the state structure
34
virtual void update() = 0;
35
36
virtual void handle_EFI_message(const mavlink_message_t &msg) {};
37
38
#if AP_SCRIPTING_ENABLED
39
virtual bool handle_scripting(const EFI_State &efi_state) { return false; }
40
#endif
41
42
protected:
43
// Copies internal state to the frontend state
44
void copy_to_frontend();
45
46
// Internal state for this driver (before copying to frontend)
47
EFI_State internal_state;
48
49
int8_t get_dronecan_node_id(void) const;
50
float get_coef1(void) const;
51
float get_coef2(void) const;
52
53
void set_default_coef1(float coef1);
54
55
float get_ecu_fuel_density(void) const;
56
57
/*
58
linearise throttle if enabled
59
*/
60
float linearise_throttle(float throttle_percent);
61
62
HAL_Semaphore &get_sem(void);
63
64
private:
65
AP_EFI &frontend;
66
};
67
68