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: 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.
|
---|
14 | // Typical use case: a remote control is plugged in a workstation
|
---|
15 | // and sends remote control
|
---|
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 {
|
---|
27 | namespace core {
|
---|
28 | class FrameworkManager;
|
---|
29 | class cvmatrix;
|
---|
30 | class TcpSocket;
|
---|
31 | class Socket;
|
---|
32 | }
|
---|
33 | namespace gui {
|
---|
34 | class Tab;
|
---|
35 | class TabWidget;
|
---|
36 | class DataPlot1D;
|
---|
37 | }
|
---|
38 | }
|
---|
39 |
|
---|
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:
|
---|
49 | TargetEthController(const core::FrameworkManager *parent, std::string name,
|
---|
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;
|
---|
62 |
|
---|
63 | bool IsDataFrameReady();
|
---|
64 | void AcquireAxisData(core::cvmatrix &axis); // responsible for getting the
|
---|
65 | // axis data from the hardware
|
---|
66 | void AcquireButtonData(core::cvmatrix &button); // responsible for getting the
|
---|
67 | // button data from the
|
---|
68 | // hardware
|
---|
69 |
|
---|
70 | bool ControllerInitialization();
|
---|
71 |
|
---|
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;
|
---|
80 | core::Socket *dataSocket;
|
---|
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 | }
|
---|
91 |
|
---|
92 | #endif // TARGETCONTROLLER_H
|
---|