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 cvmatrix;
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(const core::FrameworkManager *parent, std::string name,
52  uint8_t priority = 0);
54  // void DrawUserInterface();
55  virtual bool IsConnected() const = 0;
56  virtual bool IsDataFrameReady() = 0;
57  // axis stuff
58  unsigned int GetAxisNumber() const;
59  virtual std::string GetAxisName(unsigned int axisId) const;
60  float
61  GetAxisValue(unsigned int axisId) const; // always in the range [-1.0,1.0]
62  // button stuff
63  unsigned int GetButtonNumber() const;
64  bool IsButtonPressed(unsigned int buttonId) const;
65  virtual std::string GetButtonName(unsigned int axisId) const;
66  // controller state stuff
67  virtual bool IsControllerActionSupported(ControllerAction action) const {
68  return false;
69  };
70  bool SetLedOn(unsigned int ledId);
71  bool SetLedOff(unsigned int ledId);
72  bool Rumble(unsigned int left_force, unsigned int left_timeout,
73  unsigned int right_force, unsigned int right_timeout);
74  bool FlashLed(unsigned int ledId, unsigned int on_timeout,
75  unsigned int off_timeout);
76  void UpdateFrom(const core::io_data *data){}; // TODO
77  gui::Tab *GetTab(void) const;
78 
79 protected:
80  virtual bool ProcessMessage(core::Message *msg) = 0;
81  void QueueMessage(core::Message msg);
82  virtual bool ControllerInitialization() = 0; // {return true;};
83  // axis stuff
84  unsigned int axisNumber;
85  core::cvmatrix *axis = NULL;
86  virtual void AcquireAxisData(core::cvmatrix &axis) = 0; // responsible for
87  // getting the axis
88  // data from the
89  // hardware
90  uint16_t bitsPerAxis;
91  // button stuff
92  unsigned int buttonNumber;
93  core::cvmatrix *button = NULL;
94  virtual void AcquireButtonData(core::cvmatrix &button) = 0; // responsible for
95  // getting the
96  // button data
97  // from the
98  // hardware
99  // controller state stuff
100  unsigned int ledNumber;
101 
102 private:
103  void Run();
104  std::queue<core::Message *> changeStateQueue;
105  flair::gui::Tab *main_tab;
106  flair::gui::Tab *setup_tab;
107 };
108 }
109 }
110 
111 #endif // TARGETCONTROLLER_H
Abstract class for data types.
Definition: io_data.h:94
Abstract class for input/ouput system.
Definition: IODevice.h:44
namespace of the flair Framework
Definition: Ahrs.h:19
Class defining a matrix of kind CvMat.
Definition: cvmatrix.h:33
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:76
Main class of the Framework library.
Definition: FrameworkManager.h:45
Abstract class for a thread.
Abstract class for a thread.
Definition: Thread.h:38
Definition: Object.h:35
Class displaying a QTab on the ground station.
Definition: Tab.h:29