Changeset 12564 for trunk/psModules/src/config/pmConfigCamera.c
- Timestamp:
- Mar 22, 2007, 5:09:53 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/config/pmConfigCamera.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/config/pmConfigCamera.c
r11754 r12564 11 11 12 12 #include "pmConfigCamera.h" 13 14 15 #define TABLE_OF_CONTENTS "CONTENTS" // Name for camera format metadata containing the contents 16 #define CHIP_TYPES "CHIPS" // Name for camera format metadata containing the chip types 17 #define CELL_TYPES "CELLS" // Name for camera format metadata containing the cell types 13 18 14 19 … … 68 73 psMetadata *newCameras, // New list of camera configurations 69 74 const char *name, // Name of original camera configuration 70 pmFPALevel level // Level75 pmFPALevel mosaicLevel // Level to which we are mosaicking 71 76 ) 72 77 { … … 74 79 assert(newCameras); 75 80 assert(name); 76 assert( level == PM_FPA_LEVEL_CHIP || level == PM_FPA_LEVEL_FPA);81 assert(mosaicLevel == PM_FPA_LEVEL_CHIP || mosaicLevel == PM_FPA_LEVEL_FPA); 77 82 78 83 // See if the old one is there … … 84 89 // See if the new one is already there 85 90 psString newName = NULL; // Name of mosaicked camera 86 psStringAppend(&newName, "_%s-%s", name, level == PM_FPA_LEVEL_CHIP ? "CHIP" : "FPA");91 psStringAppend(&newName, "_%s-%s", name, mosaicLevel == PM_FPA_LEVEL_CHIP ? "CHIP" : "FPA"); 87 92 if (psMetadataLookup(oldCameras, newName)) { 88 93 return true; … … 99 104 return NULL; 100 105 } 101 switch (level) { 102 case PM_FPA_LEVEL_CHIP: { 103 // Replace the contents of each chip with a single cell 104 psMetadataIterator *fpaIter = psMetadataIteratorAlloc(fpa, PS_LIST_HEAD, NULL); // Iterator 105 psMetadataItem *fpaItem = NULL; // Item from iteration 106 while ((fpaItem = psMetadataGetAndIncrement(fpaIter))) { 107 if (fpaItem->type != PS_DATA_STRING) { 108 psWarning("Element %s within FPA in camera configuration is not of type STR.", 109 fpaItem->name); 110 continue; 111 } 112 113 psFree(fpaItem->data.str); 114 fpaItem->data.str = psStringCopy("MosaickedCell"); 115 psFree(fpaItem->comment); 116 fpaItem->comment = psStringCopy("Mosaicked cell; automatically generated"); 117 } 118 psFree(fpaIter); 119 } 120 break; 121 case PM_FPA_LEVEL_FPA: { 122 while (psListLength(fpa->list) > 0) { 123 psMetadataRemoveIndex(fpa, PS_LIST_TAIL); 124 } 125 126 psMetadataAddStr(fpa, PS_LIST_HEAD, "MosaickedChip", 0, 127 "Mosaicked chip with mosaicked cell; automatically generated", 128 "MosaickedCell"); 129 } 130 break; 106 switch (mosaicLevel) { 107 case PM_FPA_LEVEL_CHIP: { 108 // Replace the contents of each chip with a single cell 109 psMetadataIterator *fpaIter = psMetadataIteratorAlloc(fpa, PS_LIST_HEAD, NULL); // Iterator 110 psMetadataItem *fpaItem = NULL; // Item from iteration 111 while ((fpaItem = psMetadataGetAndIncrement(fpaIter))) { 112 if (fpaItem->type != PS_DATA_STRING) { 113 psWarning("Element %s within FPA in camera configuration is not of type STR.", 114 fpaItem->name); 115 continue; 116 } 117 118 psFree(fpaItem->data.str); 119 fpaItem->data.str = psStringCopy("MosaickedCell"); 120 psFree(fpaItem->comment); 121 fpaItem->comment = psStringCopy("Mosaicked cell; automatically generated"); 122 } 123 psFree(fpaIter); 124 break; 125 } 126 case PM_FPA_LEVEL_FPA: { 127 // Replace the contents of the FPA with a single chip containing a single cell 128 while (psListLength(fpa->list) > 0) { 129 psMetadataRemoveIndex(fpa, PS_LIST_TAIL); 130 } 131 132 psMetadataAddStr(fpa, PS_LIST_HEAD, "MosaickedChip", 0, 133 "Mosaicked chip with mosaicked cell; automatically generated", 134 "MosaickedCell"); 135 break; 136 } 131 137 default: 132 138 psAbort("Should never get here.\n"); … … 142 148 psMetadata *format = formatsItem->data.V; // The camera format 143 149 144 // Add a RULE 150 // Add a RULE, so that when a mosaic is written to a FITS file, it can be recognised again when read. 145 151 psMetadata *rule = psMetadataLookupMetadata(&mdok, format, "RULE"); // Way to identify format from PHU 146 152 if (!mdok || !rule) { … … 148 154 continue; 149 155 } 150 switch ( level) {156 switch (mosaicLevel) { 151 157 case PM_FPA_LEVEL_CHIP: 152 158 psMetadataAddStr(rule, PS_LIST_TAIL, "PSMOSAIC", 0, "Mosaicked level", "CHIP"); … … 173 179 } 174 180 if (strcasecmp(phuItem->data.str, "CELL") == 0 || 175 ( level == PM_FPA_LEVEL_FPA && (strcasecmp(phuItem->data.str, "CHIP") == 0))) {181 (mosaicLevel == PM_FPA_LEVEL_FPA && (strcasecmp(phuItem->data.str, "CHIP") == 0))) { 176 182 psFree(phuItem->data.str); 177 if ( level == PM_FPA_LEVEL_CHIP) {183 if (mosaicLevel == PM_FPA_LEVEL_CHIP) { 178 184 phuItem->data.str = psStringCopy("CHIP"); 179 185 } else { … … 187 193 continue; 188 194 } 189 switch (level) { 190 case PM_FPA_LEVEL_CHIP: 191 if (strcasecmp(extensionsItem->data.str, "NONE") == 0) { 192 if (strcasecmp(phuItem->data.str, "FPA") == 0) { 193 break; // Don't need a "CONTENT" to identify the content! 194 } 195 psMetadataItem *contentItem = psMetadataLookup(file, "CONTENT"); // Key to CONTENTS menu 196 if (!contentItem || contentItem->type != PS_DATA_STRING) { 197 psWarning("Couldn't find CONTENT of type STR in the FILE information " 198 "in the camera format %s.\n", formatsItem->name); 199 continue; 200 } 201 psFree(contentItem->data.str); 202 contentItem->data.str = psStringCopy("{CHIP.NAME}"); 203 } else if (strcasecmp(extensionsItem->data.str, "CELL") == 0) { 195 switch (mosaicLevel) { 196 case PM_FPA_LEVEL_CHIP: 197 if (strcasecmp(phuItem->data.str, "FPA") == 0 && 198 strcasecmp(extensionsItem->data.str, "CELL") == 0) { 204 199 psFree(extensionsItem->data.str); 205 200 extensionsItem->data.str = psStringCopy("CHIP"); 206 } 207 break; 208 case PM_FPA_LEVEL_FPA: 201 } else { 202 psFree(extensionsItem->data.str); 203 extensionsItem->data.str = psStringCopy("NONE"); 204 205 if (strcasecmp(phuItem->data.str, "FPA") == 0) { 206 // Don't need a "CONTENT" to identify the content! 207 if (psMetadataLookup(file, "CONTENT")) { 208 psMetadataRemoveKey(file, "CONTENT"); 209 } 210 break; 211 } 212 psMetadataAddStr(file, PS_LIST_TAIL, "CONTENT", PS_META_REPLACE, "Key to CONTENTS menu", 213 "{CHIP.NAME}"); 214 } 215 216 #if 0 217 // Don't need CELL.NAME for chip-mosaicked camera 218 if (psMetadataLookup(file, "CELL.NAME")) { 219 psMetadataRemoveKey(file, "CELL.NAME"); 220 } 221 #endif 222 break; 223 case PM_FPA_LEVEL_FPA: 209 224 psFree(extensionsItem->data.str); 210 225 extensionsItem->data.str = psStringCopy("NONE"); 226 #if 0 227 // Don't need CHIP.NAME or CELL.NAME for fpa-mosaicked camera 228 if (psMetadataLookup(file, "CHIP.NAME")) { 229 psMetadataRemoveKey(file, "CHIP.NAME"); 230 } 231 if (psMetadataLookup(file, "CELL.NAME")) { 232 psMetadataRemoveKey(file, "CELL.NAME"); 233 } 234 #endif 211 235 break; 212 236 default: … … 215 239 216 240 // Fix up the CONTENTS to contain only the mosaicked cell for each chip 217 switch (level) { 218 case PM_FPA_LEVEL_CHIP: 219 if (strcasecmp(phuItem->data.str, "FPA") == 0 && 220 strcasecmp(extensionsItem->data.str, "NONE") == 0) { 221 // List the contents on a single line 222 psString contentsLine = NULL; // Contents of the PHU 223 psMetadataIterator *fpaIter = psMetadataIteratorAlloc(fpa, PS_LIST_HEAD, NULL); // Iterator 224 psMetadataItem *fpaItem; // Item from iteration 225 while ((fpaItem = psMetadataGetAndIncrement(fpaIter))) { 226 if (fpaItem->type != PS_DATA_STRING) { 227 // We've already thrown a warning on this, above. 228 continue; 241 switch (mosaicLevel) { 242 case PM_FPA_LEVEL_FPA: 243 psMetadataAddStr(format, PS_LIST_TAIL, TABLE_OF_CONTENTS, PS_META_REPLACE, NULL, 244 "MosaickedChip:MosaickedCell:_mosaic"); 245 break; 246 case PM_FPA_LEVEL_CHIP: 247 if (strcasecmp(phuItem->data.str, "FPA") == 0) { 248 if (strcasecmp(extensionsItem->data.str, "CHIP") == 0) { 249 // List the chipName:chipType for each chip. 250 251 psMetadata *contents = psMetadataAlloc(); // List of contents, with chipName:chipType 252 253 psMetadataIterator *fpaIter = psMetadataIteratorAlloc(fpa, PS_LIST_HEAD, NULL); // Iteratr 254 psMetadataItem *fpaItem; // Item from iteration 255 while ((fpaItem = psMetadataGetAndIncrement(fpaIter))) { 256 if (fpaItem->type != PS_DATA_STRING) { 257 // We've already thrown a warning on this, above. 258 continue; 259 } 260 psString content = NULL; // Content to add 261 psStringAppend(&content, "%s:_mosaicChip ", fpaItem->name); 262 psMetadataAddStr(contents, PS_LIST_TAIL, fpaItem->name, 0, NULL, content); 263 psFree(content); 229 264 } 230 psStringAppend(&contentsLine, "%s:MosaickedCell:_mosaic ", fpaItem->name); 265 psFree(fpaIter); 266 psMetadataAddMetadata(format, PS_LIST_TAIL, TABLE_OF_CONTENTS, PS_META_REPLACE, 267 "List of contents", contents); 268 psFree(contents); 269 270 psMetadata *chips = psMetadataAlloc(); // List of chip types, with cellName:cellType 271 psMetadataAddStr(chips, PS_LIST_TAIL, "_mosaicChip", 0, NULL, 272 "MosaickedCell:_mosaic"); 273 psMetadataAddMetadata(format, PS_LIST_TAIL, CHIP_TYPES, PS_META_REPLACE, 274 "List of chip types", chips); 275 psFree(chips); 276 break; 277 } else if (strcasecmp(extensionsItem->data.str, "NONE") == 0) { 278 // List the contents on a single line 279 psString contentsLine = NULL; // Contents of the PHU 280 psMetadataIterator *fpaIter = psMetadataIteratorAlloc(fpa, PS_LIST_HEAD, NULL); // Iteratr 281 psMetadataItem *fpaItem; // Item from iteration 282 while ((fpaItem = psMetadataGetAndIncrement(fpaIter))) { 283 if (fpaItem->type != PS_DATA_STRING) { 284 // We've already thrown a warning on this, above. 285 continue; 286 } 287 psStringAppend(&contentsLine, "%s:MosaickedCell:_mosaic ", fpaItem->name); 288 } 289 psFree(fpaIter); 290 psMetadataAddStr(format, PS_LIST_TAIL, TABLE_OF_CONTENTS, PS_META_REPLACE, 291 NULL, contentsLine); 292 psFree(contentsLine); 293 break; 231 294 } 232 psFree(fpaIter); 233 psMetadataAddStr(format, PS_LIST_TAIL, "CONTENTS", PS_META_REPLACE, NULL, contentsLine); 234 psFree(contentsLine); 235 break; 236 } 237 238 psMetadata *contents = psMetadataLookupMetadata(&mdok, format, "CONTENTS"); // Contents of file 295 } 296 // PHU level is CHIP, EXTENSIONS is NONE. 297 298 psMetadata *contents = psMetadataLookupMetadata(&mdok, format, 299 TABLE_OF_CONTENTS); // File contents 239 300 if (!mdok || !contents) { 240 psWarning("Couldn't find CONTENTS in the camera format %s.\n", formatsItem->name); 301 psWarning("Couldn't find %s in the camera format %s.\n", TABLE_OF_CONTENTS, 302 formatsItem->name); 241 303 continue; 242 304 } … … 244 306 psMetadataRemoveIndex(contents, PS_LIST_TAIL); 245 307 } 308 246 309 psMetadataIterator *fpaIter = psMetadataIteratorAlloc(fpa, PS_LIST_HEAD, NULL); // Iterator 247 310 psMetadataItem *fpaItem; // Item from iteration … … 252 315 } 253 316 254 psString content = NULL; // Content of the chip 255 psStringAppend(&content, "%s:MosaickedCell:_mosaic", fpaItem->name); 256 psMetadataAddStr(contents, PS_LIST_TAIL, fpaItem->name, 0, NULL, content); 257 psFree(content); // Drop reference 317 psMetadataAddStr(contents, PS_LIST_TAIL, fpaItem->name, 0, NULL, "_mosaicChip"); 258 318 } 259 319 psFree(fpaIter); 260 break; 261 case PM_FPA_LEVEL_FPA: 262 psMetadataAddStr(format, PS_LIST_TAIL, "CONTENTS", PS_META_REPLACE, NULL, 263 "MosaickedChip:MosaickedCell:_mosaic"); 320 321 psMetadata *chips = psMetadataAlloc(); // List of chip types, with cellName:cellType 322 psMetadataAddStr(chips, PS_LIST_TAIL, "_mosaicChip", 0, NULL, 323 "MosaickedCell:_mosaic"); 324 psMetadataAddMetadata(format, PS_LIST_TAIL, CHIP_TYPES, PS_META_REPLACE, 325 "List of chip types", chips); 326 psFree(chips); 264 327 break; 265 328 default: … … 268 331 269 332 // Fix the cell type 270 psMetadata *cells = psMetadataLookupMetadata(&mdok, format, "CELLS"); // CELLS information333 psMetadata *cells = psMetadataLookupMetadata(&mdok, format, CELL_TYPES); // CELLS information 271 334 if (!mdok || !cells) { 272 335 psWarning("Couldn't find CELLS of type METADATA in the camera format %s.\n", formatsItem->name); … … 316 379 } 317 380 318 if ( level == PM_FPA_LEVEL_FPA) {381 if (mosaicLevel == PM_FPA_LEVEL_FPA) { 319 382 removeChipConceptsSources(translation); 320 383 removeChipConceptsSources(database); … … 347 410 } 348 411 349 350 412 // Generate the chip mosaicked version of a camera configuration 351 413 bool pmConfigCameraMosaickedVersions(psMetadata *site, // The site configuration
Note:
See TracChangeset
for help on using the changeset viewer.
