source: flair-src/trunk/lib/FlairSensorActuator/src/TargetEthController.h@ 9

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

sensoractuator

File size: 2.7 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: 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 and sends remote control
15// data to a distant target (this class) through Wifi
16//
17//
18/*********************************************************************/
19
20#ifndef TARGETETHCONTROLLER_H
21#define TARGETETHCONTROLLER_H
22
23#include "TargetController.h"
24
25namespace flair {
26 namespace core {
27 class FrameworkManager;
28 class cvmatrix;
29 class TcpSocket;
30 class Socket;
31 }
32 namespace gui {
33 class Tab;
34 class TabWidget;
35 class DataPlot1D;
36 }
37}
38
39namespace flair { namespace sensor {
40 /*! \class TargetController
41 *
42 * \brief Base Class for target side remote controls
43 *
44 */
45 class TargetEthController : public TargetController {
46 public:
47 TargetEthController(const core::FrameworkManager* parent,std::string name,uint16_t port,uint8_t priority=0);
48 ~TargetEthController();
49 //void DrawUserInterface();
50 protected:
51 bool IsConnected() const;
52 //axis stuff
53 std::string GetAxisName(unsigned int axisId) const;
54 //button stuff
55 std::string GetButtonName(unsigned int axisId) const;
56 //controller state stuff
57 bool ProcessMessage(core::Message *msg);
58 bool IsControllerActionSupported(ControllerAction action) const;
59
60 bool IsDataFrameReady();
61 void AcquireAxisData(core::cvmatrix &axis); //responsible for getting the axis data from the hardware
62 void AcquireButtonData(core::cvmatrix &button); //responsible for getting the button data from the hardware
63
64 bool ControllerInitialization();
65
66 private:
67 uint16_t readBits(uint8_t offsetInBits,uint8_t valueSizeInBits,char *buffer,size_t bufferSize);
68 uint8_t getByteOrNull(char *buffer,int byte,size_t bufferSize);
69 uint32_t charBufferToUint32(char *buffer, size_t bufferSize);
70 core::TcpSocket *listeningSocket;
71 int listeningPort;
72 core::TcpSocket *controlSocket=NULL;
73 core::Socket *dataSocket;
74 std::string *axisName=NULL;
75 std::string *buttonName=NULL;
76 size_t dataFrameSize;
77 char *dataFrameBuffer;
78 char *receiveFrameBuffer;
79 size_t receiveCurrentPosition;
80 uint8_t buttonOffset;
81 };
82
83}}
84
85#endif // TARGETCONTROLLER_H
Note: See TracBrowser for help on using the repository browser.