Changeset 25882 for trunk/psModules/src/concepts/pmConceptsStandard.c
- Timestamp:
- Oct 18, 2009, 10:52:02 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/concepts/pmConceptsStandard.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/concepts/pmConceptsStandard.c
r25425 r25882 4 4 5 5 #include <stdio.h> 6 #include <ctype.h> // for tolower() 6 7 #include <string.h> 7 #include <strings.h> /* for strn?casecmp */8 #include <strings.h> // for strn?casecmp 8 9 #include <assert.h> 9 10 #include <pslib.h> … … 317 318 "Unable to find %s in FILTER.ID in camera configuration.\n", key); 318 319 return NULL; 320 } 321 322 // FPA.OBSTYPE 323 // convert concept->data.str to new value 324 psMetadataItem *p_pmConceptParse_FPA_OBSTYPE(const psMetadataItem *concept, 325 const psMetadataItem *pattern, 326 pmConceptSource source, 327 const psMetadata *cameraFormat, 328 const pmFPA *fpa, 329 const pmChip *chip, 330 const pmCell *cell) 331 { 332 assert(concept); 333 assert(pattern); 334 assert(fpa); 335 assert(fpa->camera); 336 337 if (concept->type != PS_DATA_STRING) { 338 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Type for %s (%x) is not STR\n", 339 pattern->name, concept->type); 340 return NULL; 341 } 342 if (!concept->data.str || strlen(concept->data.str) == 0) { 343 return psMetadataItemAllocStr(pattern->name, pattern->comment, ""); 344 } 345 346 bool mdok; // Status of MD lookup 347 psMetadata *table = psMetadataLookupMetadata(&mdok, fpa->camera, "OBSTYPE.TABLE"); 348 if (!mdok || !table) { 349 // if the table is not defined, pass the supplied value unmodified 350 return psMetadataItemAllocStr(pattern->name, pattern->comment, concept->data.str); 351 } 352 353 // the metadata is in the format (external) STR (internal) 354 // do a lookup to get the internal name 355 char *extname = psStringCopy (concept->data.str); 356 for (int i = 0; i < strlen(extname); i++) { 357 extname[i] = tolower(extname[i]); 358 } 359 char *name = psMetadataLookupStr (&mdok, table, extname); 360 psFree(extname); 361 if (!name) { 362 // if the entry is not defined, pass the supplied value unmodified 363 return psMetadataItemAllocStr(pattern->name, pattern->comment, concept->data.str); 364 } 365 366 return psMetadataItemAllocStr(pattern->name, pattern->comment, name); 367 } 368 369 // convert concept->data.str to new value 370 psMetadataItem *p_pmConceptFormat_FPA_OBSTYPE(const psMetadataItem *concept, 371 pmConceptSource source, 372 const psMetadata *cameraFormat, 373 const pmFPA *fpa, 374 const pmChip *chip, 375 const pmCell *cell) 376 { 377 assert(concept); 378 assert(fpa); 379 assert(fpa->camera); 380 381 if (concept->type != PS_DATA_STRING) { 382 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Type for %s (%x) is not STR\n", 383 concept->name, concept->type); 384 return NULL; 385 } 386 if (!concept->data.str || strlen(concept->data.str) == 0) { 387 return psMetadataItemAllocStr(concept->name, concept->comment, ""); 388 } 389 390 bool mdok; // Status of MD lookup 391 psMetadata *table = psMetadataLookupMetadata(&mdok, fpa->camera, "OBSTYPE.TABLE"); 392 if (!mdok || !table) { 393 // if the table is not defined, pass the supplied value unmodified 394 return psMetadataItemAllocStr(concept->name, concept->comment, concept->data.str); 395 } 396 397 const char *key = concept->data.str; // The name to look up 398 if (!key || strlen(key) == 0) { 399 return psMetadataItemAllocStr(concept->name, concept->comment, NULL); 400 } 401 402 // the metadata is in the format (internal) STR (external) 403 // do a reverse lookup to get the internal name 404 psMetadataIterator *iter = psMetadataIteratorAlloc(table, PS_LIST_HEAD, NULL); // Iterator for filters 405 psMetadataItem *item; // Item from iteration 406 char *name = NULL; // The winning name 407 while ((item = psMetadataGetAndIncrement(iter))) { 408 if (item->type != PS_DATA_STRING) { 409 psWarning("Type for %s (%x) in OBSTYPE.TABLE in camera configuration is not STR\n", item->name, item->type); 410 continue; 411 } 412 if (strcmp(item->data.str, key) == 0) { 413 name = item->name; 414 break; 415 } 416 } 417 psFree(iter); 418 419 if (!name) { 420 return psMetadataItemAllocStr(concept->name, concept->comment, key); 421 } 422 return psMetadataItemAllocStr(concept->name, concept->comment, name); 319 423 } 320 424
Note:
See TracChangeset
for help on using the changeset viewer.
