Flair
Framework Libre Air
TargetController.h
1 // %flair:license{
2 // This file is part of the Flair framework distributed under the
3 // CECILL-C License, Version 1.0.
4 // %flair:license}
5 // created: 2015/04/14
6 // filename: TargetController.h
7 //
8 // author: Gildas Bayard
9 // Copyright Heudiasyc UMR UTC/CNRS 7253
10 //
11 // version: $Id: $
12 //
13 // purpose: Base class for target side remote controls
14 //
15 //
16 /*********************************************************************/
17 
18 #ifndef TARGETCONTROLLER_H
19 #define TARGETCONTROLLER_H
20 
21 #include <IODevice.h>
22 #include <Thread.h>
23 #include <stdint.h>
24 #include <queue>
25 
26 namespace flair {
27 namespace core {
28 class FrameworkManager;
29 class Matrix;
30 class Socket;
31 class io_data;
32 }
33 namespace gui {
34 class Tab;
35 class TabWidget;
36 class DataPlot1D;
37 }
38 }
39 
40 namespace flair {
41 namespace sensor {
42 enum class ControllerAction;
43 
50 public:
51  TargetController(std::string name,uint8_t priority = 0);
53  // void DrawUserInterface();
54  virtual bool IsConnected() const = 0;
55  virtual bool IsDataFrameReady() = 0;
56  // axis stuff
57  unsigned int GetAxisNumber() const;
58  virtual std::string GetAxisName(unsigned int axisId) const;
59  float
60  GetAxisValue(unsigned int axisId) const; // always in the range [-1.0,1.0]
61  // button stuff
62  unsigned int GetButtonNumber() const;
63  bool IsButtonPressed(unsigned int buttonId) const;
64  virtual std::string GetButtonName(unsigned int axisId) const;
65  // controller state stuff
66  virtual bool IsControllerActionSupported(ControllerAction action) const {
67  return false;
68  };
69  bool SetLedOn(unsigned int ledId);
70  bool SetLedOff(unsigned int ledId);
71  bool Rumble(unsigned int left_force, unsigned int left_timeout,
72  unsigned int right_force, unsigned int right_timeout);
73  bool FlashLed(unsigned int ledId, unsigned int on_timeout,
74  unsigned int off_timeout);
75  void UpdateFrom(const core::io_data *data){}; // TODO
76  gui::Tab *GetTab(void) const;
77 
78 protected:
79  virtual bool ProcessMessage(core::Message *msg) = 0;
80  void QueueMessage(core::Message msg);
81  virtual bool ControllerInitialization() = 0; // {return true;};
82  // axis stuff
83  unsigned int axisNumber;
84  core::Matrix *axis = nullptr;
85  virtual void AcquireAxisData(core::Matrix &axis) = 0; // responsible for
86  // getting the axis
87  // data from the
88  // hardware
89  uint16_t bitsPerAxis;
90  // button stuff
91  unsigned int buttonNumber;
92  core::Matrix *button = nullptr;
93  virtual void AcquireButtonData(core::Matrix &button) = 0; // responsible for
94  // getting the
95  // button data
96  // from the
97  // hardware
98  // controller state stuff
99  unsigned int ledNumber;
100 
101 private:
102  void Run();
103  std::queue<core::Message *> changeStateQueue;
104  flair::gui::Tab *main_tab;
105  flair::gui::Tab *setup_tab;
106 };
107 }
108 }
109 
110 #endif // TARGETCONTROLLER_H
Abstract class for data types.
Definition: io_data.h:94
Abstract class for input/ouput system.
Definition: IODevice.h:45
namespace of the flair Framework
Definition: Ahrs.h:19
Base Class for target side remote controls.
Definition: TargetController.h:49
Abstract class for input/ouput system.
void UpdateFrom(const core::io_data *data)
Update using provided datas.
Definition: TargetController.h:75
Abstract class for a thread.
Abstract class for a thread.
Definition: Thread.h:38
Definition: Object.h:41
Class defining a matrix.
Definition: Matrix.h:31
Class displaying a QTab on the ground station.
Definition: Tab.h:29