source: flair-src/trunk/lib/FlairSensorActuator/src/TargetController.h@ 269

Last change on this file since 269 was 251, checked in by Bayard Gildas, 7 years ago

nullptr instead of NULL

File size: 3.3 KB
Line 
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
26namespace flair {
27namespace core {
28class FrameworkManager;
29class Matrix;
30class Socket;
31class io_data;
32}
33namespace gui {
34class Tab;
35class TabWidget;
36class DataPlot1D;
37}
38}
39
40namespace flair {
41namespace sensor {
42enum class ControllerAction;
43
44/*! \class TargetController
45*
46* \brief Base Class for target side remote controls
47*
48*/
49class TargetController : public core::Thread, public core::IODevice {
50public:
51 TargetController(std::string name,uint8_t priority = 0);
52 ~TargetController();
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
78protected:
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
101private:
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
Note: See TracBrowser for help on using the repository browser.