-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnvirons.Sensors.h
320 lines (259 loc) · 10.5 KB
/
Environs.Sensors.h
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
/**
* Environs Sensor Handling
* ------------------------------------------------------------------
* Copyright (c) Chi-Tai Dang
*
* @author Chi-Tai Dang
* @version 1.0
* @remarks
*
* This file is part of the Environs framework developed at the
* Lab for Human Centered Multimedia of the University of Augsburg.
* http://hcm-lab.de/environs
*
* Environ is free software; you can redistribute it and/or modify
* it under the terms of the Eclipse Public License v1.0.
* A copy of the license may be obtained at:
* http://www.eclipse.org/org/documents/epl-v10.html
* --------------------------------------------------------------------
*/
#ifndef INCLUDE_HCM_ENVIRONS_SENSORS_H
#define INCLUDE_HCM_ENVIRONS_SENSORS_H
#include "Environs.Lib.Inc.h"
#include "Interop/Threads.h"
#ifndef CLI_CPP
#include "Device/Device.Base.h"
#else
#endif
/** Place declarations to global namespace for plain C */
#ifdef __cplusplus
namespace environs
{
#endif
#ifndef CLI_CPP
extern pthread_mutex_t sensorsMutex;
#endif
/**
* Objects for handling sensor services
*/
extern unsigned int sensorRegistered;
extern int sensorSender [ ENVIRONS_SENSOR_TYPE_MAX ];
extern int sensorsEventRate [ ENVIRONS_SENSOR_TYPE_MAX ];
/** Place declarations to global namespace for plain C */
#ifdef __cplusplus
namespace API
{
#endif
#ifdef __cplusplus
extern "C"
{
#endif
void DetermineSensorSupport ();
#ifdef ANDROID
void InitSensorMainThreaded ();
void DisposeSensorImpl ();
#else
# define InitSensorMainThreaded()
# define DisposeSensorImpl()
#endif
/**
* Determine whether the given sensorType is available.
*
* @param ENVIRONS_SENSOR_TYPE_ A value of type ENVIRONS_SENSOR_TYPE_*.
*
* @return success true = enabled, false = failed.
*/
CLI_INC
LIBEXPORT int IsSensorAvailableN ( int hInst, int ENVIRONS_SENSOR_TYPE_ );
/**
* Enable sending of sensor events to this DeviceInstance.
* Events are send if the device is connected and stopped if the device is disconnected.
*
* @param nativeID Destination native id
* @param objID Destination object id
* @param ENVIRONS_SENSOR_TYPE_ A value of type ENVIRONS_SENSOR_TYPE_*.
* @param enable true = enable, false = disable.
*
* @return success true = enabled, false = failed.
*/
CLI_INC
LIBEXPORT EBOOL CallConv SetSensorEventSenderN ( int hInst, int nativeID, int objID, int ENVIRONS_SENSOR_TYPE_, EBOOL enable );
/**
* Enable sending of sensor events to this DeviceInstance.
* Events are send if the device is connected and stopped if the device is disconnected.
*
* @param hInst The Environs instance identifier.
* @param nativeID Destination native device id
* @param objID Destination object device id
* @param flags A bitfield with values of type SensorType
* @param enable true = enable, false = disable.
*
* @return success 1 = enabled, 0 = failed.
*/
CLI_INC
LIBEXPORT int CallConv SetSensorEventSenderFlagsN ( int hInst, int nativeID, int objID, int flags, int enable );
/**
* Get registered DeviceInstance objects for sending of sensor events.
*
* @param ENVIRONS_SENSOR_TYPE_ A value of type ENVIRONS_SENSOR_TYPE_*.
*
* @return success true = enabled, false = failed.
*/
CLI_INC
LIBEXPORT int CallConv GetSensorEventSenderCountN ( int hInst, int ENVIRONS_SENSOR_TYPE_ );
CLI_INC
LIBEXPORT void CallConv PushSensorDataN ( int ENVIRONS_SENSOR_TYPE_, float x, float y, float z );
CLI_INC
LIBEXPORT void CallConv PushSensorDataDoublesN ( int ENVIRONS_SENSOR_TYPE_, double x, double y, double z );
CLI_INC
LIBEXPORT void CallConv PushSensorDataExtN ( int ENVIRONS_SENSOR_TYPE_, double x, double y, double z, float m, float n, float o );
/**
* Set use of Tcp transport channel of the given sensorType.
*
* @param hInst The Environs instance identifier.
* @param sensorType A value of type environs::SensorType_t.
* @param enable true = TCP, false = UDP.
*
*/
CLI_INC
LIBEXPORT void CallConv SetUseSensorChannelTcpN ( int hInst, int sensorType, bool enable );
/**
* Get use of Tcp transport channel of the given sensorType.
*
* @param hInst The Environs instance identifier.
* @param sensorType A value of type environs::SensorType_t.
*
* @return success 1 = TCP, 0 = UDP, -1 = error.
*/
CLI_INC
LIBEXPORT int CallConv GetUseSensorChannelTcpN ( int hInst, int sensorType );
/**
* Set sample rate of the given sensorType in microseconds.
*
* @param hInst The Environs instance identifier.
* @param sensorType A value of type environs::SensorType_t.
* @param microseconds The sensor sample rate in microseconds.
*
*/
CLI_INC
LIBEXPORT void CallConv SetUseSensorRateN ( int hInst, int sensorType, int microseconds );
/**
* Get sample rate of the given sensorType in microseconds.
*
* @param hInst The Environs instance identifier.
* @param sensorType A value of type environs::SensorType_t.
*
* @return microseconds The sensor sample rate in microseconds. -1 means error.
*/
CLI_INC
LIBEXPORT int CallConv GetUseSensorRateN ( int hInst, int sensorType );
/**
* Stop all sensors that the given Environs instance have subscribed to.
*
* @param hInst The Environs instance identifier.
*
*/
CLI_INC
LIBEXPORT void CallConv StopSensorListeningAllN ( int hInst );
/**
* Start all sensors that the given Environs instance have subscribed to.
*
* @param hInst The Environs instance identifier.
*
*/
CLI_INC
LIBEXPORT void CallConv StartSensorListeningAllN ( int hInst );
/**
* Register to sensor events and listen to sensor data events.
* This implementation is platform specific and needs to be implemented
* in the particular platform layer.
*
* @param sensorType A value of type environs::SensorType.
*
*/
CLI_INC
LIBEXPORT int CallConv StartSensorListeningN ( int hInst, int sensorType );
/**
* Deregister to sensor events and stop listen to sensor data events.
* This implementation is platform specific and needs to be implemented
* in the particular platform layer.
*
* @param sensorType A value of type environs::SensorType.
*
*/
CLI_INC
LIBEXPORT int CallConv StopSensorListeningN ( int hInst, int sensorType );
#ifdef __cplusplus
}
#endif
#ifndef CLI_CPP
bool EnvironsSensors_GlobalsInit ();
bool EnvironsSensors_GlobalsDispose ();
#ifdef __cplusplus
void DisposeSensorSender ( int hInst, DeviceBase * device );
/**
* Get registered DeviceInstance objects for sending of sensor events.
*
* @param sensorType A value of type environs::SensorType.
*
* @return success true = enabled, false = failed.
*/
int GetSensorEventSenderCount ( int hInst, environs::SensorType_t sensorType );
#endif
#endif
#ifdef __cplusplus
/**
* Determine whether the given sensorType is available.
*
* @param sensorType A value of type environs::SensorType_t.
*
* @return success true = enabled, false = failed.
*/
bool IsSensorAvailable ( int hInst, environs::SensorType_t sensorType, const char * sensorName );
bool IsSensorAvailableImpl ( int hInst, environs::SensorType_t sensorType );
/**
* Register to sensor events and listen to sensor data events.
* This implementation is platform specific and needs to be implemented
* in the particular platform layer.
*
* @param sensorType A value of type environs::SensorType.
*
*/
//void StartSensorListening ( int hInst, environs::SensorType_t sensorType );
bool StartSensorListeningImpl ( int hInst, environs::SensorType_t sensorType, const char * sensorName );
/**
* Deregister to sensor events and stop listen to sensor data events.
* This implementation is platform specific and needs to be implemented
* in the particular platform layer.
*
* @param sensorType A value of type environs::SensorType.
*
*/
//void StopSensorListening ( int hInst, environs::SensorType_t sensorType );
void StopSensorListeningImpl ( int hInst, environs::SensorType_t sensorType, const char * sensorName );
/**
* Register to sensor events and listen to sensor data events.
* This implementation is platform specific and needs to be implemented
* in the particular platform layer.
*
* @param hInst The Environs instance identifier.
*
*/
void StopSensorListeningAll ( int hInst );
/**
* Register to sensor events and listen to sensor data events.
* This implementation is platform specific and needs to be implemented
* in the particular platform layer.
*
* @param hInst The Environs instance identifier.
*
*/
void StartSensorListeningAll ( int hInst );
#endif
#ifdef __cplusplus
} /** namespace API */
#endif
#ifdef __cplusplus
} /* namespace environs */
#endif
#endif