source: flair-src/trunk/lib/FlairIpc/src/IpcController.h@ 403

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

add ipc lib

  • Property svn:eol-style set to native
File size: 2.6 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: 2021/03/03
6// filename: IpcController.h
7//
8// author: Sébastien Ambroziak
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 IPCCONTROLLER_H
22#define IPCCONTROLLER_H
23
24#include "TargetController.h"
25
26namespace flair {
27namespace core {
28class FrameworkManager;
29class Matrix;
30class TcpSocket;
31class UdpSocket;
32}
33namespace gui {
34class Tab;
35class TabWidget;
36class DataPlot1D;
37}
38}
39
40namespace flair {
41namespace sensor {
42/*! \class TargetController
43*
44* \brief Base Class for target side remote controls
45*
46*/
47class IpcController : public TargetController {
48public:
49 IpcController(std::string name,
50 uint16_t port, uint8_t priority = 0);
51 ~IpcController();
52 // void DrawUserInterface();
53protected:
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::Matrix &axis); // responsible for getting the
65 // axis data from the hardware
66 void AcquireButtonData(core::Matrix &button); // responsible for getting the
67 // button data from the
68 // hardware
69
70 bool ControllerInitialization();
71
72private:
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 = nullptr;
80 core::UdpSocket *dataSocket;
81 std::string *axisName = nullptr;
82 std::string *buttonName = nullptr;
83 size_t dataFrameSize;
84 char *dataFrameBuffer;
85 char *receiveFrameBuffer;
86 size_t receiveCurrentPosition;
87 uint8_t buttonOffset;
88};
89}
90}
91
92#endif // IPCCONTROLLER_H
Note: See TracBrowser for help on using the repository browser.