-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConsoleDataProcessor.h
More file actions
196 lines (177 loc) · 9.85 KB
/
ConsoleDataProcessor.h
File metadata and controls
196 lines (177 loc) · 9.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/*
* ConsoleDataProcessor.h
* Console2
*
* Created by Xun Wang on 14/05/10.
* Copyright 2010 GalaxyNetwork. All rights reserved.
*
*/
#ifndef ConsoleDataProcessor_h_DEFINED
#define ConsoleDataProcessor_h_DEFINED
#include "PyRideNetComm.h"
#ifdef __cplusplus
using namespace pyride;
extern "C" {
void initConsoleDataProcessor();
void finiConsoleDataProcessor();
void processingData();
void setRobotCallbacks( void (* addRobotFn)( const char, const int, const RobotInfo *,
const VideoSettings * vsettings, const AudioSettings * asettings,
const unsigned char * optLabel, const int optLabelLength ),
void (* removeRobotFn)( const char ),
void (* telemetryFn)( const char, const RobotPose *, const FieldObject *, const int ),
void (* isTelemetryStreamStartedFn)( bool ),
void (* isImageStreamStartedFn)( bool, const char ),
void (* onCameraModeUpdateFn)( const char, ImageFormat ),
void (* onCameraSwitchFn)( const char, const VideoSettings * ),
void (* operationalDataFn)( const char, const int, const unsigned char *, const int ),
void (* extCommandRespFn)( const char, const PyRideExtendedCommand,
const unsigned char *, const int ) );
bool logonToRobot( const char * host, const unsigned char * authCode );
void discoverRobots();
void disconnectRobots();
void startTelemetryStream( const char cID );
void stopTelemetryStream();
void startCameraImageStream( const char cID );
void stopCameraImageStream( const char cID );
void cancelCurrentOperation( const char cID );
void setImageFormat( const char cID, ImageFormat format );
void switchCamera( const char cID, const char vID );
void issueHeartBeat( const char cID );
void issueExtendedCommand( const char cID, const PyRideExtendedCommand command,
const unsigned char * optionalData, const int optionalDataLength );
bool findClientAddress( const char cID, struct sockaddr_in * cAddr );
};
//using namespace std;
class PyRideConsoleCommandHandler
{
protected:
virtual void onRobotCreated( const char cID, const int ipAddr, const RobotInfo * rinfo,
const VideoSettings * vsettings, const AudioSettings * asettings,
const unsigned char * optLabel,
const int optLabelLength ) = 0;
virtual void onRobotDestroyed( const char cID ) = 0;
virtual void onTelemetryData( const char cID, const RobotPose * pose, const FieldObject * objects = NULL,
const int nofObjs = 0 ) {}
virtual void onTelemetryStreamControl( bool isStart ) {}
virtual void onVideoStreamControl( bool isStart, const char cID ) {}
virtual void onVideoStreamSwitch( const char cID, const VideoSettings * vsettings ) {}
virtual void onOperationalData( const char cID, const int status,
const unsigned char * optionalData = NULL,
const int optionalDataLength = 0 ) {}
virtual void onExtendedCommandResponse( const char cID, const PyRideExtendedCommand command,
const unsigned char * optionalData = NULL,
const int optionalDataLength = 0 ) {}
virtual void onTimer( const long timerID ) {}
virtual void onTimerLapsed( const long timerID ) {}
friend class ConsoleDataProcessor;
};
class ConsoleDataProcessor : public RobotDataHandler
{
public:
static ConsoleDataProcessor * instance();
~ConsoleDataProcessor();
void init( PyRideConsoleCommandHandler * cmdHandler = NULL );
void fini();
void processingData();
bool logonToRobot( const char * host, const unsigned char * authCode );
void discoverRobots();
void disconnectRobots();
void startTelemetryStream( const char cID = 0 );
void stopTelemetryStream();
void startCameraImageStream( const char cID );
void stopCameraImageStream( const char cID );
void cancelCurrentOperation( const char cID );
void issueHeartBeat( const char cID );
void issueExtendedCommand( const char cID, const PyRideExtendedCommand command,
const unsigned char * optionalData = NULL, const int optionalDataLength = 0 );
void setRobotDataCallbacks( void (* addRobotFn)( const char, const int, const RobotInfo *, const VideoSettings *, const AudioSettings *,
const unsigned char *, const int ),
void (* removeRobotFn)( const char ),
void (* telemetryFn)( const char, const RobotPose *, const FieldObject *, const int ),
void (* isTelemetryStreamStartedFn)( bool ),
void (* isImageStreamStartedFn)( bool, const char ),
void (* onCameraModeUpdateFn)( const char, ImageFormat ),
void (* onCameraSwitchFn)( const char, const VideoSettings * ),
void (* operationalDataFn)( const char, const int, const unsigned char *, const int ),
void (* extCommandRespFn)( const char, const PyRideExtendedCommand,
const unsigned char *, const int ) );
void setImageFormat( const char cID, ImageFormat format );
void switchCamera( const char cID, const char vID );
bool findClientAddress( const char cID, struct sockaddr_in & cAddr );
long addTimer( float initialTime, long repeats = 0, float interval = 1.0 );
void delTimer( long tID );
void delAllTimers();
long totalTimers();
bool isTimerRunning( long tID );
bool isTimerExecuting( long tID );
private:
PyRideNetComm * pNetComm_;
PyRideConsoleCommandHandler * cmdHandler_;
int telemetryRobot_;
//unsigned char * pConvImageData_;
//int convImageDataSize_;
ConsoleDataProcessor();
void (* addRobotFn_)( const char, const int, const RobotInfo *, const VideoSettings *,
const AudioSettings *, const unsigned char *, const int );
void (* removeRobotFn_)( const char );
void (* telemetryFn_)( const char, const RobotPose *, const FieldObject *, const int );
void (* isTelemetryStreamStartedFn_)( bool );
void (* isImageStreamStartedFn_)( bool, const char );
void (* onCameraModeUpdateFn_)( const char, ImageFormat );
void (* onCameraSwitchFn_)( const char, const VideoSettings * );
void (* operationalDataFn_)( const char, const int, const unsigned char *, const int );
void (* extCommandRespFn_)( const char, const PyRideExtendedCommand, const unsigned char *, const int );
static ConsoleDataProcessor * s_pConsoleDataProcessor;
void onRobotCreated( const char cID, const int ipAddr, const RobotInfo * rinfo, const VideoSettings * vsettings, const AudioSettings * assetings,
const unsigned char * optLabel,
const int optLabelLength );
void onRobotDestroyed( const char cID );
void onRobotTelemetryData( const char cID, const RobotPose * pose, const FieldObject * objects = NULL,
const int nofObjs = 0 );
void onTelemetryStreamStart( const char cID );
void onTelemetryStreamStop( const char cID );
void onImageStreamStart( const char cID );
void onImageStreamStop( const char cID );
void onImageFormatChange( const char cID, ImageFormat format );
void onVideoSwitchChange( const char cID, const VideoSettings * vsettings );
void onExtendedCommandResponse( const char cID, const PyRideExtendedCommand command,
const unsigned char * optionalData = NULL,
const int optionalDataLength = 0 );
void onOperationalData( const char cID, const int status,
const unsigned char * optionalData = NULL,
const int optionalDataLength = 0 );
void onTimer( const long timerID );
void onTimerLapsed( const long timerID );
};
#else
void initConsoleDataProcessor(void);
void finiConsoleDataProcessor(void);
void processingData(void);
void setRobotCallbacks( void (* addRobotFn)( const char, const int, const RobotInfo *, const VideoSettings *, const AudioSettings *,
const unsigned char *, const int ),
void (* removeRobotFn)( const char ),
void (* telemetryFn)( const char, const RobotPose *, const FieldObject *, const int ),
void (* isTelemetryStreamStartedFn)( bool ),
void (* isImageStreamStartedFn)( bool, const char ),
void (* onCameraModeUpdateFn)( const char, ImageFormat ),
void (* onCameraSwitchFn)( const char, const VideoSettings * ),
void (* operationalDataFn)( const char, const int, const unsigned char *, const int ),
void (* extCommandRespFn)( const char, const PyRideExtendedCommand,
const unsigned char *, const int ) );
bool logonToRobot( const char * host, const unsigned char * authCode );
void discoverRobots(void);
void disconnectRobots(void);
void startTelemetryStream( const char cID );
void stopTelemetryStream(void);
void startCameraImageStream( const char cID );
void stopCameraImageStream( const char cID );
void cancelCurrentOperation( const char cID );
void setImageFormat( const char cID, ImageFormat format );
void switchCamera( const char cID, const char vID );
void issueHeartBeat( const char cID );
void issueExtendedCommand( const char cID, const PyRideExtendedCommand command,
const unsigned char * optionalData, const int optionalDataLength );
bool findClientAddress( const char cID, struct sockaddr_in * cAddr );
#endif // __cplusplus
#endif // ConsoleDataProcessor_h_DEFINED