- Timestamp:
- May 3, 2010, 8:50:52 AM (16 years ago)
- Location:
- branches/simtest_nebulous_branches
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches
- Property svn:mergeinfo changed
-
branches/simtest_nebulous_branches/psModules
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/psModules merged eligible /branches/eam_branches/stackphot.20100406/psModules 27623-27653 /branches/pap_delete/psModules 27530-27595
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/simtest_nebulous_branches/psModules/src/concepts/pmConceptsStandard.c
r24419 r27840 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> … … 160 161 assert(concept); 161 162 assert(pattern); 162 163 163 double value = NAN; 164 164 switch (concept->type) { … … 318 318 "Unable to find %s in FILTER.ID in camera configuration.\n", key); 319 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); 320 423 } 321 424 … … 429 532 } 430 533 431 psString ra = psMetadataLookupStr(&mdok, formats, "FPA.RA"); // Format for RA 432 psString dec = psMetadataLookupStr(&mdok, formats, "FPA.DEC"); // Format for Dec 433 if (ra && strcasecmp(ra, "HOURS") == 0 && dec && strcasecmp(dec, "DEGREES") == 0) { 434 sexagesimal = true; 534 if (strcmp(concept->name, "FPA.RA") == 0 || strcmp(concept->name, "FPA.DEC") == 0) { 535 psString ra = psMetadataLookupStr(&mdok, formats, "FPA.RA"); // Format for RA 536 psString dec = psMetadataLookupStr(&mdok, formats, "FPA.DEC"); // Format for Dec 537 if (ra && strcasecmp(ra, "HOURS") == 0 && dec && strcasecmp(dec, "DEGREES") == 0) { 538 sexagesimal = true; 539 } 435 540 } 436 541 } else { … … 450 555 small = 3600.0 * coords; 451 556 small = (float)((int)(small * 1000.0)) / 1000.0; 452 if (negative) {453 big *= -1;454 }455 557 psString coordString = NULL; // String with the coordinates in sexagesimal format 456 psStringAppend(&coordString, "%d:%02d:%06.3f", big, medium, small); 558 psStringAppend(&coordString, "%s%02d:%02d:%06.3f", 559 negative ? "-" : (strcmp(concept->name, "FPA.DEC") == 0 ? "+" : ""), 560 big, medium, small); 457 561 coordItem = psMetadataItemAllocStr(concept->name, concept->comment, coordString); 458 562 psFree(coordString); … … 631 735 return psMetadataItemAllocS32(pattern->name, pattern->comment, binning); 632 736 } 737 738 // BTOOLAPP 739 psMetadataItem *p_pmConceptParse_BTOOLAPP(const psMetadataItem *concept, 740 const psMetadataItem *pattern, 741 pmConceptSource source, 742 const psMetadata *cameraFormat, 743 const pmFPA *fpa, 744 const pmChip *chip, 745 const pmCell *cell) 746 { 747 assert(concept); 748 assert(pattern); 749 750 int bt_status = 0; 751 752 if (concept->type != PS_DATA_BOOL) { 753 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Type for %s (%x) is not BOOL\n", 754 concept->name, concept->type); 755 if (concept->type != PS_DATA_S32) { 756 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Wasn't the type I'd guessed either.\n"); 757 return NULL; 758 } 759 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Looks like an S32 value? (%d)\n", 760 concept->data.S32); 761 762 if (concept->data.S32 == 0) { 763 bt_status = 1; 764 } 765 else if (concept->data.S32 == 1) { 766 bt_status = -2; 767 } 768 } 769 770 if (concept->data.B == true) { 771 bt_status = -2; 772 } 773 else if (concept->data.B == false) { 774 bt_status = 1 ; 775 } 776 777 return psMetadataItemAllocS32(concept->name, concept->comment, bt_status); 778 } 779 psMetadataItem *p_pmConceptFormat_BTOOLAPP(const psMetadataItem *concept, 780 pmConceptSource source, 781 const psMetadata *cameraFormat, 782 const pmFPA *fpa, 783 const pmChip *chip, 784 const pmCell *cell) 785 { 786 assert(concept); 787 788 if (concept->type != PS_DATA_S32) { 789 return NULL; 790 } 791 792 if (concept->data.S32 == 0) { 793 return NULL; 794 } 795 else if (concept->data.S32 == -2) { 796 return psMetadataItemAllocBool(concept->name,concept->comment,true); 797 } 798 else if (concept->data.S32 == 1) { 799 return psMetadataItemAllocBool(concept->name,concept->comment,false); 800 } 801 else { 802 return NULL; 803 } 804 805 } 806 633 807 634 808 // Get the current value of a concept
Note:
See TracChangeset
for help on using the changeset viewer.
