-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.h
More file actions
62 lines (51 loc) · 2.16 KB
/
database.h
File metadata and controls
62 lines (51 loc) · 2.16 KB
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
#ifndef DATABASE_H
#define DATABASE_H
#include <QDir>
#include <QSqlDatabase>
#include <QSqlDriver>
#include <QSqlQuery>
#include <QSqlError>
#include <QSqlTableModel>
#include <QSqlQuery>
#include <QSqlRecord>
#include <QSqlField>
#include <QDebug>
#include <QStringLiteral>
#include <QMessageBox>
#include "globals.h"
#include "libBrakeCooling/include/libBrakeCooling.h"
class Database {
private:
const static inline char* DRIVER = "QSQLITE";
const static inline char* DB_FILE = "database.db";
const static inline char* CHECK_QUERY = "SELECT name FROM sqlite_master";
inline static double executeQuery(QSqlQuery &query);
static void error(const QString &error_msg, QWidget* parent = nullptr);
public:
/*!
* \brief Establish the database connection
*/
static bool connect(QWidget* parent = nullptr);
static std::vector<double> getTableValues(const QString &table_name, Global::Parameter parameter);
static std::array<double, 16> getReferenceBrakingEnergyValues(
const QString &table_name,
const BrakeCooling::Params &speed,
const BrakeCooling::Params &weight,
const BrakeCooling::Params &temp,
const BrakeCooling::Params &alt );
static double getCautionValue(const QString &table_name, Global::BrakeCategory brake_category);
static double getWarningValue(const QString &table_name, Global::BrakeCategory brake_category);
/*!
* \brief retreive reference braking energy for a given speed, weight, temperature and altitude values.
*/
static double getRefBe(const QString &table_name, int speed, int weight, int temp, int alt);
/*!
* \brief retreive adjusted brake energy for a given reference brake energy, braking event and reverse thrust usage
*/
static double getAdjustedBe(const QString &table_name, int reference_braking_energy, Global::BrakingEvent braking_event, bool rev_t);
/*!
* \brief retreive cooling time (in minutes) for a given adjusted brake energy and brake category
*/
static double getCoolingTime(const QString &table_name, Global::BrakeCategory brake_category, const double &adjusted_be);
};
#endif // DATABASE_H