Changeset 12696 for trunk/psModules/src/config/pmConfigCamera.c
- Timestamp:
- Mar 30, 2007, 11:12:56 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/config/pmConfigCamera.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/config/pmConfigCamera.c
r12639 r12696 1 1 #ifdef HAVE_CONFIG_H 2 # include "config.h"2 #include <config.h> 3 3 #endif 4 4 … … 7 7 #include <pslib.h> 8 8 9 #include "pmHDU.h" 10 #include "pmFPA.h" 9 11 #include "pmFPALevel.h" 10 12 #include "pmConcepts.h" 11 12 13 #include "pmConfigCamera.h" 13 14 14 15 15 #define TABLE_OF_CONTENTS "CONTENTS" // Name for camera format metadata containing the contents … … 17 17 #define CELL_TYPES "CELLS" // Name for camera format metadata containing the cell types 18 18 19 20 // Remove a concept from the list of sources. Need to check to see if it exists first, to avoid a warning. 21 static void removeConcept(psMetadata *source, // Source from which to remove concept 22 const char *concept // Concept name to remove 23 ) 19 // local helper functions defined below 20 static void removeCellConceptsSources(psMetadata *source); 21 static void removeChipConceptsSources(psMetadata *source); 22 23 // Generate the Chip and FPA mosaicked version of a named camera configuration 24 bool pmConfigCameraMosaickedVersions(psMetadata *site, // The site configuration 25 const char *name // Name of the un-mosaicked camera 26 ) 24 27 { 25 assert(source); 26 assert(concept && strlen(concept) > 0); 27 28 if (psMetadataLookup(source, concept)) { 29 psMetadataRemoveKey(source, concept); 30 } 31 32 return; 28 PS_ASSERT_METADATA_NON_NULL(site, false); 29 PS_ASSERT_STRING_NON_EMPTY(name, false); 30 31 bool mdok; // Status of MD lookup 32 psMetadata *cameras = psMetadataLookupMetadata(&mdok, site, "CAMERAS"); // List of cameras 33 if (!mdok || !cameras) { 34 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the site configuration.\n"); 35 return false; 36 } 37 if (!pmConfigGenerateMosaickedVersion(cameras, cameras, name, PM_FPA_LEVEL_CHIP)) { 38 psError(PS_ERR_UNKNOWN, true, "Failed to build Chip mosaic camera description for %s\n", name); 39 return false; 40 } 41 if (!pmConfigGenerateMosaickedVersion(cameras, cameras, name, PM_FPA_LEVEL_FPA)) { 42 psError(PS_ERR_UNKNOWN, true, "Failed to build FPA mosaic camera description for %s\n", name); 43 return false; 44 } 45 return true; 33 46 } 34 47 35 // Remove certain concepts from the list of sources. These concepts are important in the mosaicking process, 36 // and are added explicitly to the defaults (elsewhere) so that the user can't get them wrong. 37 static void removeCellConceptsSources(psMetadata *source // Source for concepts 48 // the operation putting the new entries first is now implemented in pmConfigGenerateMosaickedVersion 49 // Generate the Chip and FPA mosaicked version of a named camera configuration 50 bool pmConfigCameraMosaickedVersionsAll(psMetadata *site) 51 { 52 PS_ASSERT_METADATA_NON_NULL(site, false); 53 54 bool mdok; // Status of MD lookup 55 psMetadata *cameras = psMetadataLookupMetadata(&mdok, site, "CAMERAS"); // List of cameras 56 if (!mdok || !cameras) { 57 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the site configuration.\n"); 58 return false; 59 } 60 61 psMetadataIterator *camerasIter = psMetadataIteratorAlloc(cameras, PS_LIST_HEAD, NULL); // Iterator 62 psMetadataItem *camerasItem = NULL; // Item from iteration 63 psMetadata *new = psMetadataAlloc();// New cameras to add 64 while ((camerasItem = psMetadataGetAndIncrement(camerasIter))) { 65 assert(camerasItem->type == PS_DATA_METADATA); // Only metadata are allowed here! 66 if (!pmConfigGenerateMosaickedVersion(cameras, new, camerasItem->name, PM_FPA_LEVEL_CHIP)) { 67 psError(PS_ERR_UNKNOWN, true, "Failed to build Chip mosaic camera description for %s\n", camerasItem->name); 68 return false; 69 } 70 if (!pmConfigGenerateMosaickedVersion(cameras, new, camerasItem->name, PM_FPA_LEVEL_FPA)) { 71 psError(PS_ERR_UNKNOWN, true, "Failed to build FPA mosaic camera description for %s\n", camerasItem->name); 72 return false; 73 } 74 } 75 psFree(camerasIter); 76 77 // Now put the new cameras at the top of the list of cameras, so they get recognised first 78 // Note: going from the top, and putting everything to the top as we get there, so that the last one on 79 // goes to the top. This preserves the original order of the cameras, putting the mosaicked versions 80 // before the originals. 81 camerasIter = psMetadataIteratorAlloc(new, PS_LIST_HEAD, NULL); // Iterator 82 while ((camerasItem = psMetadataGetAndIncrement(camerasIter))) { 83 psMetadataAddItem(cameras, camerasItem, PS_LIST_HEAD, 0); 84 } 85 psFree(camerasIter); 86 psFree(new); 87 88 return true; 89 } 90 91 // Generate a mosaicked version of a camera configuration 92 bool pmConfigGenerateMosaickedVersion(psMetadata *oldCameras, // Old list of camera configurations 93 psMetadata *newCameras, // New list of camera configurations 94 const char *name, // Name of original camera configuration 95 pmFPALevel mosaicLevel // Level to which we are mosaicking 38 96 ) 39 {40 if (!source) {41 return;42 }43 44 removeConcept(source, "CELL.BIASSEC");45 removeConcept(source, "CELL.TRIMSEC");46 removeConcept(source, "CELL.XPARITY");47 removeConcept(source, "CELL.YPARITY");48 removeConcept(source, "CELL.X0");49 removeConcept(source, "CELL.Y0");50 51 // For the sake of the defaults, include the .DEPEND52 removeConcept(source, "CELL.XPARITY.DEPEND");53 removeConcept(source, "CELL.YPARITY.DEPEND");54 removeConcept(source, "CELL.X0.DEPEND");55 removeConcept(source, "CELL.Y0.DEPEND");56 57 return;58 }59 60 // Remove certain concepts from the list of sources. These concepts are important in the mosaicking process,61 // and are added explicitly to the defaults (elsewhere) so that the user can't get them wrong.62 static void removeChipConceptsSources(psMetadata *source // Source for concepts63 )64 {65 if (!source) {66 return;67 }68 69 removeConcept(source, "CHIP.XPARITY");70 removeConcept(source, "CHIP.YPARITY");71 removeConcept(source, "CHIP.X0");72 removeConcept(source, "CHIP.Y0");73 74 // For the sake of the defaults, include the .DEPEND75 removeConcept(source, "CHIP.XPARITY.DEPEND");76 removeConcept(source, "CHIP.YPARITY.DEPEND");77 removeConcept(source, "CHIP.X0.DEPEND");78 removeConcept(source, "CHIP.Y0.DEPEND");79 80 return;81 }82 83 // Generate a mosaicked version of a camera configuration84 // XXX EAM : the error states of this function need to be more carefully considered85 static bool mosaickedVersion(psMetadata *oldCameras, // Old list of camera configurations86 psMetadata *newCameras, // New list of camera configurations87 const char *name, // Name of original camera configuration88 pmFPALevel mosaicLevel // Level to which we are mosaicking89 )90 97 { 91 98 assert(oldCameras); … … 97 104 psMetadata *camera = psMetadataLookupMetadata(NULL, oldCameras, name); // The camera configuration 98 105 if (!camera) { 99 // XXX is this an error?100 106 psError(PS_ERR_UNEXPECTED_NULL, false, "Can't find camera to be mosaicked in camera list."); 101 107 return false; … … 485 491 } 486 492 487 // Generate the chip mosaicked version of a camera configuration 488 bool pmConfigCameraMosaickedVersions(psMetadata *site, // The site configuration 489 const char *name // Name of the un-mosaicked camera 490 ) 493 /*** Helper Functions ***/ 494 495 // Remove a concept from the list of sources. Need to check to see if it exists first, to avoid a warning. 496 static void removeConcept(psMetadata *source, // Source from which to remove concept 497 const char *concept // Concept name to remove 498 ) 491 499 { 492 PS_ASSERT_METADATA_NON_NULL(site, false); 493 PS_ASSERT_STRING_NON_EMPTY(name, false); 494 495 bool mdok; // Status of MD lookup 496 psMetadata *cameras = psMetadataLookupMetadata(&mdok, site, "CAMERAS"); // List of cameras 497 if (!mdok || !cameras) { 498 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the site configuration.\n"); 499 return false; 500 } 501 return mosaickedVersion(cameras, cameras, name, PM_FPA_LEVEL_CHIP) && 502 mosaickedVersion(cameras, cameras, name, PM_FPA_LEVEL_FPA); 500 assert(source); 501 assert(concept && strlen(concept) > 0); 502 503 if (psMetadataLookup(source, concept)) { 504 psMetadataRemoveKey(source, concept); 505 } 506 507 return; 503 508 } 504 509 505 // XXX EAM : shouldn't this loop over the unmosaicked camera names, calling the above function? 506 // the operation putting the new entries first is now implemented in mosaickedVersion 507 bool pmConfigCameraMosaickedVersionsAll(psMetadata *site) 510 // Remove certain concepts from the list of sources. These concepts are important in the mosaicking process, 511 // and are added explicitly to the defaults (elsewhere) so that the user can't get them wrong. 512 static void removeCellConceptsSources(psMetadata *source // Source for concepts 513 ) 508 514 { 509 PS_ASSERT_METADATA_NON_NULL(site, false); 510 511 bool mdok; // Status of MD lookup 512 psMetadata *cameras = psMetadataLookupMetadata(&mdok, site, "CAMERAS"); // List of cameras 513 if (!mdok || !cameras) { 514 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the site configuration.\n"); 515 return false; 516 } 517 518 psMetadataIterator *camerasIter = psMetadataIteratorAlloc(cameras, PS_LIST_HEAD, NULL); // Iterator 519 psMetadataItem *camerasItem = NULL; // Item from iteration 520 psMetadata *new = psMetadataAlloc();// New cameras to add 521 while ((camerasItem = psMetadataGetAndIncrement(camerasIter))) { 522 assert(camerasItem->type == PS_DATA_METADATA); // Only metadata are allowed here! 523 mosaickedVersion(cameras, new, camerasItem->name, PM_FPA_LEVEL_CHIP); 524 mosaickedVersion(cameras, new, camerasItem->name, PM_FPA_LEVEL_FPA); 525 } 526 psFree(camerasIter); 527 528 // Now put the new cameras at the top of the list of cameras, so they get recognised first 529 // Note: going from the top, and putting everything to the top as we get there, so that the last one on 530 // goes to the top. This preserves the original order of the cameras, putting the mosaicked versions 531 // before the originals. 532 camerasIter = psMetadataIteratorAlloc(new, PS_LIST_HEAD, NULL); // Iterator 533 while ((camerasItem = psMetadataGetAndIncrement(camerasIter))) { 534 psMetadataAddItem(cameras, camerasItem, PS_LIST_HEAD, 0); 535 } 536 psFree(camerasIter); 537 psFree(new); 538 539 return true; 515 if (!source) { 516 return; 517 } 518 519 removeConcept(source, "CELL.BIASSEC"); 520 removeConcept(source, "CELL.TRIMSEC"); 521 removeConcept(source, "CELL.XPARITY"); 522 removeConcept(source, "CELL.YPARITY"); 523 removeConcept(source, "CELL.X0"); 524 removeConcept(source, "CELL.Y0"); 525 526 // For the sake of the defaults, include the .DEPEND 527 removeConcept(source, "CELL.XPARITY.DEPEND"); 528 removeConcept(source, "CELL.YPARITY.DEPEND"); 529 removeConcept(source, "CELL.X0.DEPEND"); 530 removeConcept(source, "CELL.Y0.DEPEND"); 531 532 return; 540 533 } 541 534 535 // Remove certain concepts from the list of sources. These concepts are important in the mosaicking process, 536 // and are added explicitly to the defaults (elsewhere) so that the user can't get them wrong. 537 static void removeChipConceptsSources(psMetadata *source // Source for concepts 538 ) 539 { 540 if (!source) { 541 return; 542 } 543 544 removeConcept(source, "CHIP.XPARITY"); 545 removeConcept(source, "CHIP.YPARITY"); 546 removeConcept(source, "CHIP.X0"); 547 removeConcept(source, "CHIP.Y0"); 548 549 // For the sake of the defaults, include the .DEPEND 550 removeConcept(source, "CHIP.XPARITY.DEPEND"); 551 removeConcept(source, "CHIP.YPARITY.DEPEND"); 552 removeConcept(source, "CHIP.X0.DEPEND"); 553 removeConcept(source, "CHIP.Y0.DEPEND"); 554 555 return; 556 }
Note:
See TracChangeset
for help on using the changeset viewer.
