source: flair-dev/trunk/include/FlairSensorActuator/TargetController.h@ 28

Last change on this file since 28 was 13, checked in by Bayard Gildas, 9 years ago

formatting script + include reformatted

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 cvmatrix;
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(const core::FrameworkManager *parent, std::string name,
52 uint8_t priority = 0);
53 ~TargetController();
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
79protected:
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
102private:
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
Note: See TracBrowser for help on using the repository browser.