Skip to content

Commit

Permalink
refactoring device register
Browse files Browse the repository at this point in the history
- reduced cpu overhead
- reduced code dependencies
  • Loading branch information
brunotl committed Sep 3, 2021
1 parent eba543a commit 9d2f9e0
Show file tree
Hide file tree
Showing 99 changed files with 1,187 additions and 1,362 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ add_library( LK8000 SHARED
Common/Source/Devices/devFlarm.cpp
Common/Source/Devices/devLX_EOS_ERA.cpp
Common/Source/Devices/devFanet.cpp
Common/Source/Devices/DeviceRegister.cpp

Common/Source/Dialogs/dlgSelectObject.cpp
Common/Source/Dialogs/dlgSelectAirspace.cpp
Expand Down
1 change: 1 addition & 0 deletions Common/Header/ComPort.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define COMPORT_H

#include "Sizes.h"
#include "Enums.h"
#include "Util/tstring.hpp"
#include "Poco/Event.h"
#include "Poco/Thread.h"
Expand Down
2 changes: 2 additions & 0 deletions Common/Header/Flarm.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#ifndef _FLARM_H
#define _FLARM_H

#include <cstdint>

// Max number of local ids in file
#define MAXFLARMLOCALS 50

Expand Down
1 change: 1 addition & 0 deletions Common/Header/MapWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "Time/PeriodClock.hpp"
#include <array>
#include "RGB.h"
#include "Thread/Mutex.hpp"

#ifndef ENABLE_OPENGL
#include "Poco/ThreadTarget.h"
Expand Down
1 change: 1 addition & 0 deletions Common/Header/WindowControls.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <tchar.h>
#include <string.h>
#include <functional>
#include <list>

#define IsEmptyString(x) ((x==NULL) || (x[0]=='\0'))

Expand Down
30 changes: 17 additions & 13 deletions Common/Header/devAR620x.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
/*
* LK8000 Tactical Flight Computer - WWW.LK8000.IT
* Released under GNU/GPL License v.2 or later
* See CREDITS.TXT file for authors and copyrights
*
* File: devAR620x.h
*/

#ifndef DEV_AR620x_H
#define DEV_AR620x_H

#include "Devices/DeviceRegister.h"

BOOL AR620xRegister(void);

int AR620xNMEAddCheckSumStrg( TCHAR szStrg[] );
BOOL AR620xIsRadio(PDeviceDescriptor_t d);
BOOL AR620xPutVolume(PDeviceDescriptor_t d, int Volume) ;
BOOL AR620xPutSquelch(PDeviceDescriptor_t d, int Squelch) ;
BOOL AR620xPutFreqActive(PDeviceDescriptor_t d, double Freq, const TCHAR* StationName) ;
BOOL AR620xPutFreqStandby(PDeviceDescriptor_t d, double Freq, const TCHAR* StationName) ;
BOOL AR620xStationSwap(PDeviceDescriptor_t d);
BOOL AR620xParseString(PDeviceDescriptor_t d, char *String, int len, NMEA_INFO *info);
BOOL AR620xInstall(PDeviceDescriptor_t d);
BOOL AR620xRadioMode(PDeviceDescriptor_t d, int mode);

void AR620xInstall(DeviceDescriptor_t* d);

inline constexpr
DeviceRegister_t AR620xRegister() {
return devRegister(
TEXT("Becker AR620x"),
(1l << dfRadio),
AR620xInstall);
}

#endif
31 changes: 17 additions & 14 deletions Common/Header/devATR833.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
/*
* LK8000 Tactical Flight Computer - WWW.LK8000.IT
* Released under GNU/GPL License v.2 or later
* See CREDITS.TXT file for authors and copyrights
*
* File: devATR833.h
*/

#ifndef DEV_ATR833_H
#define DEV_ATR833_H

#include "Devices/DeviceRegister.h"

BOOL ATR833Register(void);

int ATR833NMEAddCheckSumStrg( TCHAR szStrg[] );
BOOL ATR833IsRadio(PDeviceDescriptor_t d);
BOOL ATR833PutVolume(PDeviceDescriptor_t d, int Volume) ;
BOOL ATR833PutSquelch(PDeviceDescriptor_t d, int Squelch) ;
BOOL ATR833PutFreqActive(PDeviceDescriptor_t d, double Freq, const TCHAR* StationName) ;
BOOL ATR833PutFreqStandby(PDeviceDescriptor_t d, double Freq, const TCHAR* StationName) ;
BOOL ATR833StationSwap(PDeviceDescriptor_t d);
BOOL ATR833RequestAllData(PDeviceDescriptor_t d) ;
BOOL ATR833ParseString(PDeviceDescriptor_t d, char *String, int len, NMEA_INFO *info);
BOOL ATR833Install(PDeviceDescriptor_t d);
BOOL ATR833RadioMode(PDeviceDescriptor_t d, int mode);

void ATR833Install(PDeviceDescriptor_t d);

inline constexpr
DeviceRegister_t ATR833Register(void){
return devRegister(
TEXT("f.u.n.k.e. ATR833"),
(1l << dfRadio),
ATR833Install);
}

#endif
12 changes: 11 additions & 1 deletion Common/Header/devBlueFlyVario.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@
#ifndef DEVBLUEFLYVARIO_H
#define DEVBLUEFLYVARIO_H

BOOL BlueFlyRegister(void);
#include "Devices/DeviceRegister.h"

void BlueFlyInstall(PDeviceDescriptor_t d);

inline constexpr
DeviceRegister_t BlueFlyRegister(void) {
return devRegister(
TEXT("BlueFlyVario"),
(1l << dfBaroAlt) | (1l << dfVario),
BlueFlyInstall);
}

#endif /* DEVBLUEFLYVARIO_H */
17 changes: 14 additions & 3 deletions Common/Header/devBorgeltB50.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
/*
* LK8000 Tactical Flight Computer - WWW.LK8000.IT
* Released under GNU/GPL License v.2 or later
* See CREDITS.TXT file for authors and copyrights
*
* File: devBorgeltB50.h
*/

#ifndef DEVB50_H
#define DEVB50_H

#include "Devices/DeviceRegister.h"

void b50Install(PDeviceDescriptor_t d);

BOOL b50Install(PDeviceDescriptor_t d);

BOOL b50Register(void);
inline constexpr
DeviceRegister_t b50Register() {
return devRegister(_T("Borgelt B50"), (1l << dfGPS), b50Install );
}

#endif
21 changes: 17 additions & 4 deletions Common/Header/devCAI302.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
/*
* LK8000 Tactical Flight Computer - WWW.LK8000.IT
* Released under GNU/GPL License v.2 or later
* See CREDITS.TXT file for authors and copyrights
*
* File: devCAI302.h
*/

#ifndef DEVCAI302_H
#define DEVCAI302_H

#include "Devices/DeviceRegister.h"

void cai302Install(PDeviceDescriptor_t d);

inline constexpr
DeviceRegister_t cai302Register() {
constexpr unsigned flags = (1l << dfGPS) | (1l << dfLogger) | (1l << dfSpeed)
| (1l << dfVario) | (1l << dfBaroAlt) | (1l << dfWind);

return devRegister(_T("CAI 302"), flags, cai302Install);
}

BOOL cai302Register(void);
BOOL cai302PutBugs(PDeviceDescriptor_t d, double Bugs);
BOOL cai302PutMacCready(PDeviceDescriptor_t d, double MacCready);
BOOL cai302PutBallast(PDeviceDescriptor_t d, double Ballast);
#endif
21 changes: 17 additions & 4 deletions Common/Header/devCProbe.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
#ifndef devCProbe_h__
#define devCProbe_h__
#include "devBase.h"

#include "Util/tstring.hpp"
#include "nmeaistream.h"
#include "dlgTools.h"
#include "Devices/DeviceRegister.h"

struct DeviceDescriptor_t;

class WindowControl;
class WndButton;
Expand All @@ -28,18 +32,27 @@ class CDevCProbe : public DevBase

//Init
public:
static bool Register();
static const TCHAR* GetName() { return TEXT("C-Probe"); }
static constexpr
DeviceRegister_t Register() {
return devRegister(GetName(), cap_baro_alt|cap_vario, &Install);
}


static constexpr
const TCHAR* GetName() {
return TEXT("C-Probe");
}

static BOOL Open(PDeviceDescriptor_t d);
static BOOL Close (PDeviceDescriptor_t d);


private:
static BOOL Install(PDeviceDescriptor_t d);
static void Install(PDeviceDescriptor_t d);

// Receive data
private:
static BOOL ParseNMEA(DeviceDescriptor_t *d, TCHAR *String, NMEA_INFO *pINFO);
static BOOL ParseNMEA(PDeviceDescriptor_t d, TCHAR *String, NMEA_INFO *pINFO);

static BOOL ParseData(tnmeastring& wiss, NMEA_INFO *pINFO );
static BOOL ParseGyro(tnmeastring& wiss, NMEA_INFO *pINFO );
Expand Down
17 changes: 13 additions & 4 deletions Common/Header/devCaiGpsNav.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define DEVCAIGPSNAV_H

#include "devBase.h"

#include "Devices/DeviceRegister.h"

/**
* @brief CAI GPS-Nav device class
Expand All @@ -20,13 +20,22 @@
class CDevCAIGpsNav : public DevBase
{
// LK interface
static const TCHAR *GetName();
static constexpr
const TCHAR *GetName() {
return _T("CAI GPS-NAV");
}

static BOOL Init(DeviceDescriptor_t *d);
static BOOL DeclareTask(PDeviceDescriptor_t d, Declaration_t *decl, unsigned errBufSize, TCHAR errBuf[]);
static BOOL Install(PDeviceDescriptor_t d);
static void Install(PDeviceDescriptor_t d);

public:
static bool Register();

static constexpr
DeviceRegister_t Register() {
return devRegister(GetName(), cap_gps | cap_baro_alt | cap_logger, Install);
}

};

#endif /* DEVCAIGPSNAV_H */
17 changes: 15 additions & 2 deletions Common/Header/devCompeo.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
/*
* LK8000 Tactical Flight Computer - WWW.LK8000.IT
* Released under GNU/GPL License v.2 or later
* See CREDITS.TXT file for authors and copyrights
*
* File: devCompeo.h
*/

#ifndef DEVCOMPEO_H
#define DEVCOMPEO_H

#include "Devices/DeviceRegister.h"

void CompeoInstall(PDeviceDescriptor_t d);


BOOL CompeoRegister(void);
inline constexpr
DeviceRegister_t CompeoRegister() {
constexpr unsigned flags = (1l << dfGPS) | (1l << dfBaroAlt) | (1l << dfSpeed) | (1l << dfVario);
return devRegister( _T("Brauniger/Compeo 5030"), flags, CompeoInstall );
}

#endif
19 changes: 17 additions & 2 deletions Common/Header/devCondor.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
/*
* LK8000 Tactical Flight Computer - WWW.LK8000.IT
* Released under GNU/GPL License v.2 or later
* See CREDITS.TXT file for authors and copyrights
*
* File: devCondor.h
*/

#ifndef DEVCONDOR_H
#define DEVCONDOR_H

#include "Devices/DeviceRegister.h"

void condorInstall(PDeviceDescriptor_t d);


BOOL condorRegister(void);
inline constexpr
DeviceRegister_t condorRegister() {
return devRegister(
_T("Condor"),
(1l << dfGPS) | (1l << dfBaroAlt) | (1l << dfSpeed) | (1l << dfVario),
condorInstall );
}

#endif
16 changes: 15 additions & 1 deletion Common/Header/devDigifly.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
/*
* LK8000 Tactical Flight Computer - WWW.LK8000.IT
* Released under GNU/GPL License v.2 or later
* See CREDITS.TXT file for authors and copyrights
*
* File: devDigifly.h
*/

#ifndef DEVDIGIFLY_H
#define DEVDIGIFLY_H

#include "Devices/DeviceRegister.h"

void DigiflyInstall(PDeviceDescriptor_t d);

BOOL DigiflyRegister(void);
inline constexpr
DeviceRegister_t DigiflyRegister(void) {
constexpr unsigned flags = (1l << dfGPS) | (1l << dfBaroAlt) | (1l << dfSpeed) | (1l << dfVario);
return devRegister(_T("Digifly"), flags, DigiflyInstall);
}

#endif
16 changes: 14 additions & 2 deletions Common/Header/devDisabled.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
/*
* LK8000 Tactical Flight Computer - WWW.LK8000.IT
* Released under GNU/GPL License v.2 or later
* See CREDITS.TXT file for authors and copyrights
*
* File: devDisabled.h
*/

#ifndef DEVDISABLED_H
#define DEVDISABLED_H

#include "Devices/DeviceRegister.h"

BOOL disInstall(PDeviceDescriptor_t d);
BOOL disRegister(void);
void disInstall(PDeviceDescriptor_t d);

inline constexpr
DeviceRegister_t disRegister() {
return devRegister(_T(DEV_DISABLED_NAME), (1l << dfGPS), disInstall);
}

#endif
16 changes: 13 additions & 3 deletions Common/Header/devEW.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
/*
* LK8000 Tactical Flight Computer - WWW.LK8000.IT
* Released under GNU/GPL License v.2 or later
* See CREDITS.TXT file for authors and copyrights
*
* File: devEW.h
*/

#ifndef DEVEW_H
#define DEVEW_H

#include "Devices/DeviceRegister.h"

BOOL ewInstall(PDeviceDescriptor_t d);
BOOL ewRegister(void);

void ewInstall(PDeviceDescriptor_t d);

inline constexpr
DeviceRegister_t ewRegister() {
return devRegister(_T("EW Logger"), 1l << dfGPS | 1l << dfLogger, ewInstall);
}

#endif
Loading

0 comments on commit 9d2f9e0

Please sign in to comment.