[4] | 1 | // %flair:license{
|
---|
[13] | 2 | // This file is part of the Flair framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
[4] | 4 | // %flair:license}
|
---|
| 5 | // created: 2015/04/14
|
---|
| 6 | // filename: TargetEthController.h
|
---|
| 7 | //
|
---|
| 8 | // author: Gildas Bayard
|
---|
| 9 | // Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
| 10 | //
|
---|
| 11 | // version: $Id: $
|
---|
| 12 | //
|
---|
| 13 | // purpose: class that gets remote controls through an ethernet connection.
|
---|
[13] | 14 | // Typical use case: a remote control is plugged in a workstation
|
---|
| 15 | // and sends remote control
|
---|
[4] | 16 | // data to a distant target (this class) through Wifi
|
---|
| 17 | //
|
---|
| 18 | //
|
---|
| 19 | /*********************************************************************/
|
---|
| 20 |
|
---|
| 21 | #ifndef TARGETETHCONTROLLER_H
|
---|
| 22 | #define TARGETETHCONTROLLER_H
|
---|
| 23 |
|
---|
| 24 | #include "TargetController.h"
|
---|
| 25 |
|
---|
| 26 | namespace flair {
|
---|
[13] | 27 | namespace core {
|
---|
| 28 | class FrameworkManager;
|
---|
| 29 | class cvmatrix;
|
---|
| 30 | class TcpSocket;
|
---|
[50] | 31 | class UdpSocket;
|
---|
[4] | 32 | }
|
---|
[13] | 33 | namespace gui {
|
---|
| 34 | class Tab;
|
---|
| 35 | class TabWidget;
|
---|
| 36 | class DataPlot1D;
|
---|
| 37 | }
|
---|
| 38 | }
|
---|
[4] | 39 |
|
---|
[13] | 40 | namespace flair {
|
---|
| 41 | namespace sensor {
|
---|
| 42 | /*! \class TargetController
|
---|
| 43 | *
|
---|
| 44 | * \brief Base Class for target side remote controls
|
---|
| 45 | *
|
---|
| 46 | */
|
---|
| 47 | class TargetEthController : public TargetController {
|
---|
| 48 | public:
|
---|
[50] | 49 | TargetEthController(std::string name,
|
---|
[13] | 50 | uint16_t port, uint8_t priority = 0);
|
---|
| 51 | ~TargetEthController();
|
---|
| 52 | // void DrawUserInterface();
|
---|
| 53 | protected:
|
---|
| 54 | bool IsConnected() const;
|
---|
| 55 | // axis stuff
|
---|
| 56 | std::string GetAxisName(unsigned int axisId) const;
|
---|
| 57 | // button stuff
|
---|
| 58 | std::string GetButtonName(unsigned int axisId) const;
|
---|
| 59 | // controller state stuff
|
---|
| 60 | bool ProcessMessage(core::Message *msg);
|
---|
| 61 | bool IsControllerActionSupported(ControllerAction action) const;
|
---|
[4] | 62 |
|
---|
[13] | 63 | bool IsDataFrameReady();
|
---|
[25] | 64 | void AcquireAxisData(core::cvmatrix &axis); // responsible for getting the
|
---|
| 65 | // axis data from the hardware
|
---|
[13] | 66 | void AcquireButtonData(core::cvmatrix &button); // responsible for getting the
|
---|
| 67 | // button data from the
|
---|
| 68 | // hardware
|
---|
[4] | 69 |
|
---|
[13] | 70 | bool ControllerInitialization();
|
---|
[4] | 71 |
|
---|
[13] | 72 | private:
|
---|
| 73 | uint16_t readBits(uint8_t offsetInBits, uint8_t valueSizeInBits, char *buffer,
|
---|
| 74 | size_t bufferSize);
|
---|
| 75 | uint8_t getByteOrNull(char *buffer, int byte, size_t bufferSize);
|
---|
| 76 | uint32_t charBufferToUint32(char *buffer, size_t bufferSize);
|
---|
| 77 | core::TcpSocket *listeningSocket;
|
---|
| 78 | int listeningPort;
|
---|
| 79 | core::TcpSocket *controlSocket = NULL;
|
---|
[50] | 80 | core::UdpSocket *dataSocket;
|
---|
[13] | 81 | std::string *axisName = NULL;
|
---|
| 82 | std::string *buttonName = NULL;
|
---|
| 83 | size_t dataFrameSize;
|
---|
| 84 | char *dataFrameBuffer;
|
---|
| 85 | char *receiveFrameBuffer;
|
---|
| 86 | size_t receiveCurrentPosition;
|
---|
| 87 | uint8_t buttonOffset;
|
---|
| 88 | };
|
---|
| 89 | }
|
---|
| 90 | }
|
---|
[4] | 91 |
|
---|
| 92 | #endif // TARGETCONTROLLER_H
|
---|