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 data_ts = (interface_data_ts_t *)data_ptr;
00050 memset(data_ptr, 0, data_size);
00051 add_fieldinfo(IFT_FLOAT, "track_x_positions", 30, &data->track_x_positions);
00052 add_fieldinfo(IFT_FLOAT, "track_y_positions", 30, &data->track_y_positions);
00053 add_fieldinfo(IFT_INT32, "track_timestamps", 30, &data->track_timestamps);
00054 add_fieldinfo(IFT_BOOL, "valid", 1, &data->valid);
00055 add_fieldinfo(IFT_UINT32, "length", 1, &data->length);
00056 add_fieldinfo(IFT_UINT32, "track_id", 1, &data->track_id);
00057 unsigned char tmp_hash[] = {0xcd, 0xb8, 0x68, 0x14, 0xff, 0x3, 0xe4, 0xc4, 0x20, 0x43, 0x44, 0xb8, 0x86, 0x87, 0xa3, 0x4c};
00058 set_hash(tmp_hash);
00059 }
00060
00061
00062 Position2DTrackInterface::~Position2DTrackInterface()
00063 {
00064 free(data_ptr);
00065 }
00066
00067
00068
00069
00070
00071
00072
00073
00074 float *
00075 Position2DTrackInterface::track_x_positions() const
00076 {
00077 return data->track_x_positions;
00078 }
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 float
00090 Position2DTrackInterface::track_x_positions(unsigned int index) const
00091 {
00092 if (index > 30) {
00093 throw Exception("Index value %u out of bounds (0..30)", index);
00094 }
00095 return data->track_x_positions[index];
00096 }
00097
00098
00099
00100
00101
00102 size_t
00103 Position2DTrackInterface::maxlenof_track_x_positions() const
00104 {
00105 return 30;
00106 }
00107
00108
00109
00110
00111
00112
00113
00114
00115 void
00116 Position2DTrackInterface::set_track_x_positions(const float * new_track_x_positions)
00117 {
00118 memcpy(data->track_x_positions, new_track_x_positions, sizeof(float) * 30);
00119 data_changed = true;
00120 }
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 void
00131 Position2DTrackInterface::set_track_x_positions(unsigned int index, const float new_track_x_positions)
00132 {
00133 if (index > 30) {
00134 throw Exception("Index value %u out of bounds (0..30)", index);
00135 }
00136 data->track_x_positions[index] = new_track_x_positions;
00137 }
00138
00139
00140
00141
00142
00143
00144
00145 float *
00146 Position2DTrackInterface::track_y_positions() const
00147 {
00148 return data->track_y_positions;
00149 }
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160 float
00161 Position2DTrackInterface::track_y_positions(unsigned int index) const
00162 {
00163 if (index > 30) {
00164 throw Exception("Index value %u out of bounds (0..30)", index);
00165 }
00166 return data->track_y_positions[index];
00167 }
00168
00169
00170
00171
00172
00173 size_t
00174 Position2DTrackInterface::maxlenof_track_y_positions() const
00175 {
00176 return 30;
00177 }
00178
00179
00180
00181
00182
00183
00184
00185
00186 void
00187 Position2DTrackInterface::set_track_y_positions(const float * new_track_y_positions)
00188 {
00189 memcpy(data->track_y_positions, new_track_y_positions, sizeof(float) * 30);
00190 data_changed = true;
00191 }
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201 void
00202 Position2DTrackInterface::set_track_y_positions(unsigned int index, const float new_track_y_positions)
00203 {
00204 if (index > 30) {
00205 throw Exception("Index value %u out of bounds (0..30)", index);
00206 }
00207 data->track_y_positions[index] = new_track_y_positions;
00208 }
00209
00210
00211
00212
00213
00214
00215
00216 int32_t *
00217 Position2DTrackInterface::track_timestamps() const
00218 {
00219 return data->track_timestamps;
00220 }
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231 int32_t
00232 Position2DTrackInterface::track_timestamps(unsigned int index) const
00233 {
00234 if (index > 30) {
00235 throw Exception("Index value %u out of bounds (0..30)", index);
00236 }
00237 return data->track_timestamps[index];
00238 }
00239
00240
00241
00242
00243
00244 size_t
00245 Position2DTrackInterface::maxlenof_track_timestamps() const
00246 {
00247 return 30;
00248 }
00249
00250
00251
00252
00253
00254
00255
00256
00257 void
00258 Position2DTrackInterface::set_track_timestamps(const int32_t * new_track_timestamps)
00259 {
00260 memcpy(data->track_timestamps, new_track_timestamps, sizeof(int32_t) * 30);
00261 data_changed = true;
00262 }
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272 void
00273 Position2DTrackInterface::set_track_timestamps(unsigned int index, const int32_t new_track_timestamps)
00274 {
00275 if (index > 30) {
00276 throw Exception("Index value %u out of bounds (0..30)", index);
00277 }
00278 data->track_timestamps[index] = new_track_timestamps;
00279 }
00280
00281
00282
00283
00284 bool
00285 Position2DTrackInterface::is_valid() const
00286 {
00287 return data->valid;
00288 }
00289
00290
00291
00292
00293
00294 size_t
00295 Position2DTrackInterface::maxlenof_valid() const
00296 {
00297 return 1;
00298 }
00299
00300
00301
00302
00303
00304 void
00305 Position2DTrackInterface::set_valid(const bool new_valid)
00306 {
00307 data->valid = new_valid;
00308 data_changed = true;
00309 }
00310
00311
00312
00313
00314
00315 uint32_t
00316 Position2DTrackInterface::length() const
00317 {
00318 return data->length;
00319 }
00320
00321
00322
00323
00324
00325 size_t
00326 Position2DTrackInterface::maxlenof_length() const
00327 {
00328 return 1;
00329 }
00330
00331
00332
00333
00334
00335 void
00336 Position2DTrackInterface::set_length(const uint32_t new_length)
00337 {
00338 data->length = new_length;
00339 data_changed = true;
00340 }
00341
00342
00343
00344
00345
00346 uint32_t
00347 Position2DTrackInterface::track_id() const
00348 {
00349 return data->track_id;
00350 }
00351
00352
00353
00354
00355
00356 size_t
00357 Position2DTrackInterface::maxlenof_track_id() const
00358 {
00359 return 1;
00360 }
00361
00362
00363
00364
00365
00366 void
00367 Position2DTrackInterface::set_track_id(const uint32_t new_track_id)
00368 {
00369 data->track_id = new_track_id;
00370 data_changed = true;
00371 }
00372
00373
00374 Message *
00375 Position2DTrackInterface::create_message(const char *type) const
00376 {
00377 throw UnknownTypeException("The given type '%s' does not match any known "
00378 "message type for this interface type.", type);
00379 }
00380
00381
00382
00383
00384
00385 void
00386 Position2DTrackInterface::copy_values(const Interface *other)
00387 {
00388 const Position2DTrackInterface *oi = dynamic_cast<const Position2DTrackInterface *>(other);
00389 if (oi == NULL) {
00390 throw TypeMismatchException("Can only copy values from interface of same type (%s vs. %s)",
00391 type(), other->type());
00392 }
00393 memcpy(data, oi->data, sizeof(Position2DTrackInterface_data_t));
00394 }
00395
00396 const char *
00397 Position2DTrackInterface::enum_tostring(const char *enumtype, int val) const
00398 {
00399 throw UnknownTypeException("Unknown enum type %s", enumtype);
00400 }
00401
00402
00403
00404
00405
00406
00407 bool
00408 Position2DTrackInterface::message_valid(const Message *message) const
00409 {
00410 return false;
00411 }
00412
00413
00414 EXPORT_INTERFACE(Position2DTrackInterface)
00415
00416
00417
00418 }