Flair
Framework Libre Air
EmulatedController.h
1 // created: 2015/04/14
2 // filename: EmulatedController.h
3 //
4 // author: Gildas Bayard
5 // Copyright Heudiasyc UMR UTC/CNRS 7253
6 //
7 // version: $Id: $
8 //
9 // purpose: class that emulate a remote control.
10 // Typical use case: run a demo without any reliable communication channel
11 //
12 //
13 /*********************************************************************/
14 
15 #ifndef EMULATEDCONTROLLER_H
16 #define EMULATEDCONTROLLER_H
17 
18 #include <TargetController.h>
19 #include <list>
20 
21 namespace flair {
22  namespace core {
23  class Matrix;
24  }
25  namespace gui {
26  class Tab;
27  class TabWidget;
28  class DataPlot1D;
29  }
30 }
31 
32 namespace flair { namespace sensor {
39  public:
40  EmulatedController(std::string name,uint8_t priority=0);
42  enum class ButtonType : uint16_t {
43  start=0x0001,select=0x0002,square=0x0004,triangle=0x0008,
44  circle=0x0010,cross=0x0020,left1=0x0040,left2=0x0080,
45  left3=0x0100,right1=0x0200,right2=0x0400,right3=0x0800,
46  up=0x1000,down=0x2000,left=0x4000,right=0x8000
47  };
48  void AddStep(unsigned int durationMs,std::string description,uint16_t buttonPressed, float leftAxisX, float leftAxisY, float rightAxisX, float rightAxisY);
49  protected :
50  bool IsConnected() const;
51  //controller state stuff
52  bool ProcessMessage(core::Message *msg);
53  bool IsDataFrameReady();
54  void AcquireAxisData(core::Matrix &axis); //responsible for getting the axis data from the hardware
55  void AcquireButtonData(core::Matrix &button); //responsible for getting the button data from the hardware
56  bool ControllerInitialization();
57 
58  private:
59  enum class DataType { axis,button };
60  void ComputeControllerData(DataType dataType, core::Matrix &data);
61  template<typename T> void fillVectorNoMutex(core::Matrix &vector,T data[],unsigned int size);
62  void fillVectorNoMutex(core::Matrix &destination,core::Matrix &source,unsigned int size);
63  struct StepData {
64  unsigned int durationMs; //milliseconds
65  core::Matrix *axisData;
66  core::Matrix *buttonData;
67  std::string description;
68  void Print();
69  };
70  std::list<StepData> steps;
71  };
72 
73 }}
74 
75 #endif // EMULATEDCONTROLLER_H
namespace of the flair Framework
Definition: Ahrs.h:19
Base Class for target side remote controls.
Definition: TargetController.h:49
Emulated remote control.
Definition: EmulatedController.h:38
Definition: Object.h:41
Class defining a matrix.
Definition: Matrix.h:31