00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <interfaces/Position2DTrackInterface.h>
00025
00026 #include <core/exceptions/software.h>
00027
00028 #include <cstring>
00029 #include <cstdlib>
00030
00031 namespace fawkes {
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 Position2DTrackInterface::Position2DTrackInterface() : Interface()
00045 {
00046 data_size = sizeof(Position2DTrackInterface_data_t);
00047 data_ptr = malloc(data_size);
00048 data = (Position2DTrackInterface_data_t *)data_ptr;
00049 memset(data_ptr, 0, data_size);
00050 add_fieldinfo(IFT_FLOAT, "track_x_positions", 30, &data->track_x_positions);
00051 add_fieldinfo(IFT_FLOAT, "track_y_positions", 30, &data->track_y_positions);
00052 add_fieldinfo(IFT_INT, "track_timestamps", 30, &data->track_timestamps);
00053 add_fieldinfo(IFT_BOOL, "valid", 1, &data->valid);
00054 add_fieldinfo(IFT_UINT, "length", 1, &data->length);
00055 add_fieldinfo(IFT_UINT, "track_id", 1, &data->track_id);
00056 unsigned char tmp_hash[] = {0xda, 0x9e, 0x3f, 0x1e, 0x79, 0x8e, 0x9f, 0xd6, 0xec, 0xa6, 0x1f, 0xd2, 0x53, 0x7, 0x41, 0x2d};
00057 set_hash(tmp_hash);
00058 }
00059
00060
00061 Position2DTrackInterface::~Position2DTrackInterface()
00062 {
00063 free(data_ptr);
00064 }
00065
00066
00067
00068
00069
00070
00071
00072
00073 float *
00074 Position2DTrackInterface::track_x_positions() const
00075 {
00076 return data->track_x_positions;
00077 }
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088 float
00089 Position2DTrackInterface::track_x_positions(unsigned int index) const
00090 {
00091 if (index > 30) {
00092 throw Exception("Index value %u out of bounds (0..30)", index);
00093 }
00094 return data->track_x_positions[index];
00095 }
00096
00097
00098
00099
00100
00101 size_t
00102 Position2DTrackInterface::maxlenof_track_x_positions() const
00103 {
00104 return 30;
00105 }
00106
00107
00108
00109
00110
00111
00112
00113
00114 void
00115 Position2DTrackInterface::set_track_x_positions(const float * new_track_x_positions)
00116 {
00117 memcpy(data->track_x_positions, new_track_x_positions, sizeof(float) * 30);
00118 }
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128 void
00129 Position2DTrackInterface::set_track_x_positions(unsigned int index, const float new_track_x_positions)
00130 {
00131 if (index > 30) {
00132 throw Exception("Index value %u out of bounds (0..30)", index);
00133 }
00134 data->track_x_positions[index] = new_track_x_positions;
00135 }
00136
00137
00138
00139
00140
00141
00142
00143 float *
00144 Position2DTrackInterface::track_y_positions() const
00145 {
00146 return data->track_y_positions;
00147 }
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158 float
00159 Position2DTrackInterface::track_y_positions(unsigned int index) const
00160 {
00161 if (index > 30) {
00162 throw Exception("Index value %u out of bounds (0..30)", index);
00163 }
00164 return data->track_y_positions[index];
00165 }
00166
00167
00168
00169
00170
00171 size_t
00172 Position2DTrackInterface::maxlenof_track_y_positions() const
00173 {
00174 return 30;
00175 }
00176
00177
00178
00179
00180
00181
00182
00183
00184 void
00185 Position2DTrackInterface::set_track_y_positions(const float * new_track_y_positions)
00186 {
00187 memcpy(data->track_y_positions, new_track_y_positions, sizeof(float) * 30);
00188 }
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198 void
00199 Position2DTrackInterface::set_track_y_positions(unsigned int index, const float new_track_y_positions)
00200 {
00201 if (index > 30) {
00202 throw Exception("Index value %u out of bounds (0..30)", index);
00203 }
00204 data->track_y_positions[index] = new_track_y_positions;
00205 }
00206
00207
00208
00209
00210
00211
00212
00213 int *
00214 Position2DTrackInterface::track_timestamps() const
00215 {
00216 return data->track_timestamps;
00217 }
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228 int
00229 Position2DTrackInterface::track_timestamps(unsigned int index) const
00230 {
00231 if (index > 30) {
00232 throw Exception("Index value %u out of bounds (0..30)", index);
00233 }
00234 return data->track_timestamps[index];
00235 }
00236
00237
00238
00239
00240
00241 size_t
00242 Position2DTrackInterface::maxlenof_track_timestamps() const
00243 {
00244 return 30;
00245 }
00246
00247
00248
00249
00250
00251
00252
00253
00254 void
00255 Position2DTrackInterface::set_track_timestamps(const int * new_track_timestamps)
00256 {
00257 memcpy(data->track_timestamps, new_track_timestamps, sizeof(int) * 30);
00258 }
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268 void
00269 Position2DTrackInterface::set_track_timestamps(unsigned int index, const int new_track_timestamps)
00270 {
00271 if (index > 30) {
00272 throw Exception("Index value %u out of bounds (0..30)", index);
00273 }
00274 data->track_timestamps[index] = new_track_timestamps;
00275 }
00276
00277
00278
00279
00280 bool
00281 Position2DTrackInterface::is_valid() const
00282 {
00283 return data->valid;
00284 }
00285
00286
00287
00288
00289
00290 size_t
00291 Position2DTrackInterface::maxlenof_valid() const
00292 {
00293 return 1;
00294 }
00295
00296
00297
00298
00299
00300 void
00301 Position2DTrackInterface::set_valid(const bool new_valid)
00302 {
00303 data->valid = new_valid;
00304 }
00305
00306
00307
00308
00309
00310 unsigned int
00311 Position2DTrackInterface::length() const
00312 {
00313 return data->length;
00314 }
00315
00316
00317
00318
00319
00320 size_t
00321 Position2DTrackInterface::maxlenof_length() const
00322 {
00323 return 1;
00324 }
00325
00326
00327
00328
00329
00330 void
00331 Position2DTrackInterface::set_length(const unsigned int new_length)
00332 {
00333 data->length = new_length;
00334 }
00335
00336
00337
00338
00339
00340 unsigned int
00341 Position2DTrackInterface::track_id() const
00342 {
00343 return data->track_id;
00344 }
00345
00346
00347
00348
00349
00350 size_t
00351 Position2DTrackInterface::maxlenof_track_id() const
00352 {
00353 return 1;
00354 }
00355
00356
00357
00358
00359
00360 void
00361 Position2DTrackInterface::set_track_id(const unsigned int new_track_id)
00362 {
00363 data->track_id = new_track_id;
00364 }
00365
00366
00367 Message *
00368 Position2DTrackInterface::create_message(const char *type) const
00369 {
00370 throw UnknownTypeException("The given type '%s' does not match any known "
00371 "message type for this interface type.", type);
00372 }
00373
00374
00375
00376
00377
00378 void
00379 Position2DTrackInterface::copy_values(const Interface *other)
00380 {
00381 const Position2DTrackInterface *oi = dynamic_cast<const Position2DTrackInterface *>(other);
00382 if (oi == NULL) {
00383 throw TypeMismatchException("Can only copy values from interface of same type (%s vs. %s)",
00384 type(), other->type());
00385 }
00386 memcpy(data, oi->data, sizeof(Position2DTrackInterface_data_t));
00387 }
00388
00389
00390
00391
00392
00393 bool
00394 Position2DTrackInterface::message_valid(const Message *message) const
00395 {
00396 return false;
00397 }
00398
00399
00400 EXPORT_INTERFACE(Position2DTrackInterface)
00401
00402
00403
00404 }