Changeset 18939
- Timestamp:
- Aug 5, 2008, 5:40:45 PM (18 years ago)
- Location:
- trunk/psModules/src/config
- Files:
-
- 3 edited
-
pmConfigCamera.c (modified) (1 diff)
-
pmConfigCamera.h (modified) (2 diffs)
-
pmConfigDump.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/config/pmConfigCamera.c
r17993 r18939 23 23 static void removeChipConceptsSources(psMetadata *source); 24 24 25 // Generate the skycell version of a named camera configuration 26 bool pmConfigCameraSkycellVersion(psMetadata *system, // The system configuration 27 const char *name // Name of the un-mosaicked camera 28 ) 29 { 30 PS_ASSERT_METADATA_NON_NULL(system, false); 31 PS_ASSERT_STRING_NON_EMPTY(name, false); 32 33 bool mdok; // Status of MD lookup 34 psMetadata *cameras = psMetadataLookupMetadata(&mdok, system, "CAMERAS"); // List of cameras 35 if (!mdok || !cameras) { 36 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the system configuration.\n"); 37 return false; 38 } 39 if (!pmConfigGenerateSkycellVersion(cameras, cameras, name, system)) { 40 psError(PS_ERR_UNKNOWN, true, "Failed to build skycell camera description for %s\n", name); 41 return false; 42 } 43 return true; 25 psString pmConfigCameraRootName(const char *name) 26 { 27 PS_ASSERT_STRING_NON_EMPTY(name, NULL); 28 29 if (name[0] != '_') { 30 // It's an original 31 return psStringCopy(name); 32 } 33 34 psString root = psStringCopy(name + 1); // Camera name 35 int length = strlen(name); // Length of camera name 36 if (strcmp(root + length - 9, "-SKYCELL") == 0) { 37 length -= 9; 38 } else if (strcmp(root + length - 6, "-CHIP") == 0) { 39 length -= 6; 40 } else if (strcmp(root + length - 5, "-FPA") == 0) { 41 length -= 5; 42 } else { 43 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unrecognised derivative camera: %s", name); 44 psFree(root); 45 return NULL; 46 } 47 48 // Truncate the string 49 root[length] = '\0'; 50 51 return root; 52 } 53 54 psString pmConfigCameraSkycellName(const char *name) 55 { 56 PS_ASSERT_STRING_NON_EMPTY(name, NULL); 57 58 psString root = pmConfigCameraRootName(name); // Root name of camera 59 if (!root) { 60 return NULL; 61 } 62 63 psStringAppend(&root, "-SKYCELL"); 64 psStringPrepend(&root, "_"); 65 66 return root; 67 } 68 69 psString pmConfigCameraChipName(const char *name) 70 { 71 PS_ASSERT_STRING_NON_EMPTY(name, NULL); 72 73 psString root = pmConfigCameraRootName(name); // Root name of camera 74 if (!root) { 75 return NULL; 76 } 77 78 psStringAppend(&root, "-CHIP"); 79 psStringPrepend(&root, "_"); 80 81 return root; 82 } 83 84 psString pmConfigCameraFPAName(const char *name) 85 { 86 PS_ASSERT_STRING_NON_EMPTY(name, NULL); 87 88 psString root = pmConfigCameraRootName(name); // Root name of camera 89 if (!root) { 90 return NULL; 91 } 92 93 psStringAppend(&root, "-FPA"); 94 psStringPrepend(&root, "_"); 95 96 return root; 44 97 } 45 98 -
trunk/psModules/src/config/pmConfigCamera.h
r14475 r18939 5 5 * @author Eugene Magnier, IfA 6 6 * 7 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $8 * @date $Date: 200 7-08-14 00:17:40$7 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2008-08-06 03:40:45 $ 9 9 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii 10 10 */ … … 15 15 /// @addtogroup Config Configuration System 16 16 /// @{ 17 18 // Return the name of the original ("root") camera 19 // 20 // The root name is the name of the camera before it was made into a derivative (e.g., skycell, chip, fpa). 21 psString pmConfigCameraRootName(const char *name // Name of camera 22 ); 23 24 // Return the name of the Skycell derivative camera 25 psString pmConfigCameraSkycellName(const char *name // Name of camera 26 ); 27 28 // Return the name of the Chip derivative camera 29 psString pmConfigCameraChipName(const char *name // Name of camera 30 ); 31 32 // Return the name of the FPA derivative camera 33 psString pmConfigCameraFPAName(const char *name // Name of camera 34 ); 17 35 18 36 // Generate a skycell version of a camera configuration -
trunk/psModules/src/config/pmConfigDump.c
r18908 r18939 13 13 #include "pmFPAview.h" 14 14 #include "pmFPAfile.h" 15 #include "pmConfigCamera.h" 15 16 16 17 #include "pmConfigDump.h" … … 18 19 // Cull entries in the metadata, ignoring the ones listed. 19 20 static bool configCull(psMetadata *md, // Configuration metadata from which to cull 20 const char*list // List of items NOT to cull21 const psArray *list // List of items NOT to cull 21 22 ) 22 23 { 23 24 PS_ASSERT_METADATA_NON_NULL(md, false); 25 PS_ASSERT_ARRAY_NON_NULL(list, false); 24 26 25 if (!list || strlen(list) == 0) {26 // Save everything if nothing is listed27 return true;27 psHash *keep = psHashAlloc(list->n); // Hash with strings to keep 28 for (int i = 0; i < keep->n; i++) { 29 psHashAdd(keep, list->data[i], list->data[i]); 28 30 } 29 30 psArray *keepList = psStringSplitArray(list, " ,;", false); // List of items to keep31 psHash *keep = psHashAlloc(keepList->n); // Hash with strings to keep32 for (int i = 0; i < keep->n; i++) {33 psHashAdd(keep, keepList->data[i], keepList->data[i]);34 }35 psFree(keepList);36 31 37 32 psMetadataIterator *iter = psMetadataIteratorAlloc(md, PS_LIST_HEAD, NULL); // Iterator … … 57 52 } 58 53 59 return configCull(config->recipes, save); 54 psArray *keep = psStringSplitArray(save, " ,;", false); // List of items to keep 55 56 bool result = configCull(config->recipes, keep); // Result of culling 57 psFree(keep); 58 59 return result; 60 60 } 61 61 … … 70 70 } 71 71 72 return configCull(cameras, config->cameraName); 72 // Get names of the root camera and its derivatives 73 psArray *keep = psArrayAlloc(4); 74 keep->data[0] = pmConfigCameraRootName(config->cameraName); 75 keep->data[1] = pmConfigCameraChipName(config->cameraName); 76 keep->data[2] = pmConfigCameraFPAName(config->cameraName); 77 keep->data[3] = pmConfigCameraSkycellName(config->cameraName); 78 79 bool result = configCull(cameras, keep); // Result of culling 80 psFree(keep); 81 82 return result; 73 83 } 74 84
Note:
See TracChangeset
for help on using the changeset viewer.
