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

Last change on this file since 4 was 3, checked in by Sanahuja Guillaume, 6 years ago

sensoractuator

File size: 3.1 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 {
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
40namespace flair { namespace sensor {
41    enum class ControllerAction;
42
43    /*! \class TargetController
44    *
45    * \brief Base Class for target side remote controls
46    *
47    */
48    class TargetController : public core::Thread, public core::IODevice {
49    public:
50        TargetController(const core::FrameworkManager* parent,std::string name,uint8_t priority=0);
51        ~TargetController();
52        //void DrawUserInterface();
53        virtual bool IsConnected() const=0;
54        virtual bool IsDataFrameReady()=0;
55        //axis stuff
56        unsigned int GetAxisNumber() const;
57        virtual std::string GetAxisName(unsigned int axisId) const;
58        float GetAxisValue(unsigned int axisId) const;// always in the range [-1.0,1.0]
59        //button stuff
60        unsigned int GetButtonNumber() const;
61        bool IsButtonPressed(unsigned int buttonId) const;
62        virtual std::string GetButtonName(unsigned int axisId) const;
63        //controller state stuff
64        virtual bool IsControllerActionSupported(ControllerAction action) const {return false;};
65        bool SetLedOn(unsigned int ledId);
66        bool SetLedOff(unsigned int ledId);
67        bool Rumble(unsigned int left_force,unsigned int left_timeout,unsigned int right_force,unsigned int right_timeout);
68        bool FlashLed(unsigned int ledId,unsigned int on_timeout,unsigned int off_timeout);
69        void UpdateFrom(const core::io_data *data){}; //TODO
70        gui::Tab* GetTab(void) const;
71
72    protected:
73        virtual bool ProcessMessage(core::Message *msg)=0;
74        void QueueMessage(core::Message msg);
75        virtual bool ControllerInitialization()=0;// {return true;};
76        //axis stuff
77        unsigned int axisNumber;
78        core::cvmatrix* axis=NULL;
79        virtual void AcquireAxisData(core::cvmatrix &axis)=0; //responsible for getting the axis data from the hardware
80        uint16_t bitsPerAxis;
81        //button stuff
82        unsigned int buttonNumber;
83        core::cvmatrix* button=NULL;
84        virtual void AcquireButtonData(core::cvmatrix &button)=0; //responsible for getting the button data from the hardware
85        //controller state stuff
86        unsigned int ledNumber;
87    private:
88        void Run();
89        std::queue<core::Message *> changeStateQueue;
90        flair::gui::Tab* main_tab;
91        flair::gui::Tab* setup_tab;
92    };
93
94}}
95
96#endif // TARGETCONTROLLER_H
Note: See TracBrowser for help on using the repository browser.