Changeset 12639 for trunk/psModules/src/config/pmConfigCamera.c
- Timestamp:
- Mar 28, 2007, 10:59:53 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/config/pmConfigCamera.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/config/pmConfigCamera.c
r12597 r12639 49 49 removeConcept(source, "CELL.Y0"); 50 50 51 // For the sake of the defaults, include the .DEPEND 52 removeConcept(source, "CELL.XPARITY.DEPEND"); 53 removeConcept(source, "CELL.YPARITY.DEPEND"); 54 removeConcept(source, "CELL.X0.DEPEND"); 55 removeConcept(source, "CELL.Y0.DEPEND"); 56 51 57 return; 52 58 } … … 65 71 removeConcept(source, "CHIP.X0"); 66 72 removeConcept(source, "CHIP.Y0"); 73 74 // For the sake of the defaults, include the .DEPEND 75 removeConcept(source, "CHIP.XPARITY.DEPEND"); 76 removeConcept(source, "CHIP.YPARITY.DEPEND"); 77 removeConcept(source, "CHIP.X0.DEPEND"); 78 removeConcept(source, "CHIP.Y0.DEPEND"); 67 79 68 80 return; … … 85 97 psMetadata *camera = psMetadataLookupMetadata(NULL, oldCameras, name); // The camera configuration 86 98 if (!camera) { 87 // XXX is this an error?99 // XXX is this an error? 88 100 psError(PS_ERR_UNEXPECTED_NULL, false, "Can't find camera to be mosaicked in camera list."); 89 101 return false; … … 109 121 } 110 122 switch (mosaicLevel) { 111 // For CHIP mosaic, replace the contents of each chip with a single cell123 // For CHIP mosaic, replace the contents of each chip with a single cell 112 124 case PM_FPA_LEVEL_CHIP: { 113 125 psMetadataIterator *fpaIter = psMetadataIteratorAlloc(fpa, PS_LIST_HEAD, NULL); // Iterator … … 117 129 psError(PS_ERR_UNKNOWN, true, "Element %s within FPA in camera configuration is not of type STR.", 118 130 fpaItem->name); 119 psFree(new);120 return false;131 psFree(new); 132 return false; 121 133 } 122 134 … … 129 141 break; 130 142 } 131 // For FPA mosaic, replace the contents of the FPA with a single chip containing a single cell143 // For FPA mosaic, replace the contents of the FPA with a single chip containing a single cell 132 144 case PM_FPA_LEVEL_FPA: { 133 145 while (psListLength(fpa->list) > 0) { … … 156 168 157 169 // Add a new RULE which uniquely describes the mosaicked format. this is needed so 158 // that when a mosaic is written to a FITS file, it can be recognised again when read.170 // that when a mosaic is written to a FITS file, it can be recognised again when read. 159 171 psMetadata *rule = psMetadataLookupMetadata(NULL, format, "RULE"); // Way to identify format from PHU 160 172 if (!rule) { 161 // a camera format without a rule is not allowed.162 psError(PS_ERR_UNKNOWN, false, "Camera format %s has no RULE", formatsItem->name);163 return false;164 }165 166 // the new rule is supplemented by the mosaicLevel173 // a camera format without a rule is not allowed. 174 psError(PS_ERR_UNKNOWN, false, "Camera format %s has no RULE", formatsItem->name); 175 return false; 176 } 177 178 // the new rule is supplemented by the mosaicLevel 167 179 switch (mosaicLevel) { 168 180 case PM_FPA_LEVEL_CHIP: … … 177 189 178 190 // Fix the FILE information: need to fix the levels for the PHU and EXTENSIONS. 179 // both of these elements are required in the format; we raise an error if they are not found191 // both of these elements are required in the format; we raise an error if they are not found 180 192 // If EXTENSIONS is NONE, then we need to change the CONTENT specifier to point to the chip name. 181 193 psMetadata *file = psMetadataLookupMetadata(NULL, format, "FILE"); // File information 182 194 if (!file) { 183 195 psError(PS_ERR_UNKNOWN, false, "Camera format %s has no FILE", formatsItem->name); 184 return false;196 return false; 185 197 } 186 198 psMetadataItem *phuItem = psMetadataLookup(file, "PHU"); // PHU level 187 199 if (!phuItem || phuItem->type != PS_DATA_STRING) { 188 200 psError(PS_ERR_UNKNOWN, false, "Camera format %s is missing PHU in the FILE information", formatsItem->name); 189 return false;201 return false; 190 202 } 191 203 psMetadataItem *extensionsItem = psMetadataLookup(file, "EXTENSIONS"); // Extensions level … … 195 207 } 196 208 197 // mosaicLevel == CHIP:198 // Case PHU EXTENSIONS Modifications199 // ==== === ========== ===========200 // 1. FPA CHIP NONE201 // 2. FPA CELL EXT->CHIP202 // 3. FPA NONE NONE203 // 4. CHIP CELL EXT->NONE204 // 5. CHIP NONE NONE205 // 6. CELL NONE PHU->CHIP206 // possible outcomes:207 // FPA CHIP208 // FPA NONE209 // CHIP NONE210 211 // mosaicLevel == FPA:212 // Case PHU EXTENSIONS Modifications213 // ==== === ========== ===========214 // 1. FPA CHIP EXT->NONE215 // 2. FPA CELL EXT->NONE216 // 3. FPA NONE NONE217 // 4. CHIP CELL PHU->FPA, EXT->NONE218 // 5. CHIP NONE PHU->FPA219 // 6. CELL NONE PHU->FPA220 // possible outcomes:221 // FPA NONE222 223 // modify the values of phuItem and extensionsItem209 // mosaicLevel == CHIP: 210 // Case PHU EXTENSIONS Modifications 211 // ==== === ========== =========== 212 // 1. FPA CHIP NONE 213 // 2. FPA CELL EXT->CHIP 214 // 3. FPA NONE NONE 215 // 4. CHIP CELL EXT->NONE 216 // 5. CHIP NONE NONE 217 // 6. CELL NONE PHU->CHIP 218 // possible outcomes: 219 // FPA CHIP 220 // FPA NONE 221 // CHIP NONE 222 223 // mosaicLevel == FPA: 224 // Case PHU EXTENSIONS Modifications 225 // ==== === ========== =========== 226 // 1. FPA CHIP EXT->NONE 227 // 2. FPA CELL EXT->NONE 228 // 3. FPA NONE NONE 229 // 4. CHIP CELL PHU->FPA, EXT->NONE 230 // 5. CHIP NONE PHU->FPA 231 // 6. CELL NONE PHU->FPA 232 // possible outcomes: 233 // FPA NONE 234 235 // modify the values of phuItem and extensionsItem 224 236 switch (mosaicLevel) { 225 237 case PM_FPA_LEVEL_CHIP: 226 238 if (!strcasecmp(phuItem->data.str, "FPA") && !strcasecmp(extensionsItem->data.str, "CHIP")) { 227 break;228 } 239 break; 240 } 229 241 if (!strcasecmp(phuItem->data.str, "FPA") && !strcasecmp(extensionsItem->data.str, "CELL")) { 230 242 psFree(extensionsItem->data.str); 231 243 extensionsItem->data.str = psStringCopy("CHIP"); 232 break;233 } 244 break; 245 } 234 246 if (!strcasecmp(phuItem->data.str, "FPA") && !strcasecmp(extensionsItem->data.str, "NONE")) { 235 break;236 } 247 break; 248 } 237 249 if (!strcasecmp(phuItem->data.str, "CHIP") && !strcasecmp(extensionsItem->data.str, "CELL")) { 238 250 psFree(extensionsItem->data.str); 239 251 extensionsItem->data.str = psStringCopy("NONE"); 240 break;241 } 252 break; 253 } 242 254 if (!strcasecmp(phuItem->data.str, "CHIP") && !strcasecmp(extensionsItem->data.str, "NONE")) { 243 break;244 } 255 break; 256 } 245 257 if (!strcasecmp(phuItem->data.str, "CELL") && !strcasecmp(extensionsItem->data.str, "NONE")) { 246 psFree(phuItem->data.str);258 psFree(phuItem->data.str); 247 259 phuItem->data.str = psStringCopy("CHIP"); 248 break;249 } 250 psAbort ("should not reach here");260 break; 261 } 262 psAbort ("should not reach here"); 251 263 252 264 case PM_FPA_LEVEL_FPA: … … 254 266 psFree(extensionsItem->data.str); 255 267 extensionsItem->data.str = psStringCopy("NONE"); 256 break;257 } 268 break; 269 } 258 270 if (!strcasecmp(phuItem->data.str, "FPA") && !strcasecmp(extensionsItem->data.str, "CELL")) { 259 271 psFree(extensionsItem->data.str); 260 272 extensionsItem->data.str = psStringCopy("NONE"); 261 break;262 } 273 break; 274 } 263 275 if (!strcasecmp(phuItem->data.str, "FPA") && !strcasecmp(extensionsItem->data.str, "NONE")) { 264 break;265 } 276 break; 277 } 266 278 if (!strcasecmp(phuItem->data.str, "CHIP") && !strcasecmp(extensionsItem->data.str, "CELL")) { 267 psFree(phuItem->data.str);279 psFree(phuItem->data.str); 268 280 phuItem->data.str = psStringCopy("FPA"); 269 break;270 281 psFree(extensionsItem->data.str); 271 282 extensionsItem->data.str = psStringCopy("NONE"); 272 break;273 } 283 break; 284 } 274 285 if (!strcasecmp(phuItem->data.str, "CHIP") && !strcasecmp(extensionsItem->data.str, "NONE")) { 275 psFree(phuItem->data.str);286 psFree(phuItem->data.str); 276 287 phuItem->data.str = psStringCopy("FPA"); 277 break;278 } 288 break; 289 } 279 290 if (!strcasecmp(phuItem->data.str, "CELL") && !strcasecmp(extensionsItem->data.str, "NONE")) { 280 psFree(phuItem->data.str);291 psFree(phuItem->data.str); 281 292 phuItem->data.str = psStringCopy("FPA"); 282 break;283 } 284 psAbort ("should not reach here");285 286 default:293 break; 294 } 295 psAbort ("should not reach here"); 296 297 default: 287 298 psAbort("Should never get here.\n"); 288 299 } 289 300 290 301 #if 0 291 // XXXX when do I need to adjust the value of CONTENT, CELL.NAME, CHIP.NAME?292 293 // Don't need a "CONTENT" to identify the content!294 if (psMetadataLookup(file, "CONTENT")) {295 psMetadataRemoveKey(file, "CONTENT");296 }297 psMetadataAddStr(file, PS_LIST_TAIL, "CONTENT", PS_META_REPLACE, "Key to CONTENTS menu",298 "{CHIP.NAME}");299 // Don't need CELL.NAME for chip-mosaicked camera300 if (psMetadataLookup(file, "CELL.NAME")) {301 psMetadataRemoveKey(file, "CELL.NAME");302 }303 // Don't need CHIP.NAME or CELL.NAME for fpa-mosaicked camera304 if (psMetadataLookup(file, "CHIP.NAME")) {305 psMetadataRemoveKey(file, "CHIP.NAME");306 }307 if (psMetadataLookup(file, "CELL.NAME")) {308 psMetadataRemoveKey(file, "CELL.NAME");309 }302 // XXXX when do I need to adjust the value of CONTENT, CELL.NAME, CHIP.NAME? 303 304 // Don't need a "CONTENT" to identify the content! 305 if (psMetadataLookup(file, "CONTENT")) { 306 psMetadataRemoveKey(file, "CONTENT"); 307 } 308 psMetadataAddStr(file, PS_LIST_TAIL, "CONTENT", PS_META_REPLACE, "Key to CONTENTS menu", 309 "{CHIP.NAME}"); 310 // Don't need CELL.NAME for chip-mosaicked camera 311 if (psMetadataLookup(file, "CELL.NAME")) { 312 psMetadataRemoveKey(file, "CELL.NAME"); 313 } 314 // Don't need CHIP.NAME or CELL.NAME for fpa-mosaicked camera 315 if (psMetadataLookup(file, "CHIP.NAME")) { 316 psMetadataRemoveKey(file, "CHIP.NAME"); 317 } 318 if (psMetadataLookup(file, "CELL.NAME")) { 319 psMetadataRemoveKey(file, "CELL.NAME"); 320 } 310 321 #endif 311 322 … … 318 329 case PM_FPA_LEVEL_CHIP: 319 330 if (!strcasecmp(phuItem->data.str, "FPA") && !strcasecmp(extensionsItem->data.str, "CHIP")) { 320 // ensure the value of CONTENT in the FILE section has the right value321 psMetadataAddStr(file, PS_LIST_TAIL, "CONTENT", PS_META_REPLACE, "Key to CONTENTS menu", "{CHIP.NAME}");322 323 // List the chipName:chipType for each chip.324 psMetadata *contents = psMetadataAlloc(); // List of contents, with chipName:chipType325 326 psMetadataIterator *fpaIter = psMetadataIteratorAlloc(fpa, PS_LIST_HEAD, NULL); // Iteratr327 psMetadataItem *fpaItem; // Item from iteration328 while ((fpaItem = psMetadataGetAndIncrement(fpaIter))) {329 assert (fpaItem->type == PS_DATA_STRING); 330 psString content = NULL; // Content to add331 psStringAppend(&content, "%s:_mosaicChip ", fpaItem->name);332 psMetadataAddStr(contents, PS_LIST_TAIL, fpaItem->name, 0, NULL, content);333 psFree(content);334 }335 psFree(fpaIter);336 psMetadataAddMetadata(format, PS_LIST_TAIL, TABLE_OF_CONTENTS, PS_META_REPLACE,337 "List of contents", contents);338 psFree(contents);339 340 psMetadata *chips = psMetadataAlloc(); // List of chip types, with cellName:cellType341 psMetadataAddStr(chips, PS_LIST_TAIL, "_mosaicChip", 0, NULL,342 "MosaickedCell:_mosaic");343 psMetadataAddMetadata(format, PS_LIST_TAIL, CHIP_TYPES, PS_META_REPLACE,344 "List of chip types", chips);345 psFree(chips);346 break;347 } 348 if (!strcasecmp(phuItem->data.str, "FPA") && !strcasecmp(extensionsItem->data.str, "NONE")) {349 // List the contents on a single line350 psString contentsLine = NULL; // Contents of the PHU351 psMetadataIterator *fpaIter = psMetadataIteratorAlloc(fpa, PS_LIST_HEAD, NULL); // Iteratr352 psMetadataItem *fpaItem; // Item from iteration353 while ((fpaItem = psMetadataGetAndIncrement(fpaIter))) {354 assert (fpaItem->type == PS_DATA_STRING);355 psStringAppend(&contentsLine, "%s:MosaickedCell:_mosaic ", fpaItem->name);356 }357 psFree(fpaIter);358 psMetadataAddStr(format, PS_LIST_TAIL, TABLE_OF_CONTENTS, PS_META_REPLACE,359 NULL, contentsLine);360 psFree(contentsLine);361 break;362 }363 if (!strcasecmp(phuItem->data.str, "CHIP") && !strcasecmp(extensionsItem->data.str, "NONE")) {364 // XXX recode this to match the structure above (FPA/CHIP)?365 // select and remove the old contents366 psMetadata *contents = psMetadataLookupMetadata(NULL, format, TABLE_OF_CONTENTS); // File contents367 if (!contents) {368 psError(PS_ERR_UNKNOWN, false, "Couldn't find %s in the camera format %s.\n", 369 TABLE_OF_CONTENTS, formatsItem->name);370 return false;371 }372 while (psListLength(contents->list) > 0) {373 psMetadataRemoveIndex(contents, PS_LIST_TAIL);374 }375 376 // update with the new contents377 psMetadataIterator *fpaIter = psMetadataIteratorAlloc(fpa, PS_LIST_HEAD, NULL); // Iterator378 psMetadataItem *fpaItem; // Item from iteration379 while ((fpaItem = psMetadataGetAndIncrement(fpaIter))) {380 assert (fpaItem->type == PS_DATA_STRING);381 psMetadataAddStr(contents, PS_LIST_TAIL, fpaItem->name, 0, NULL, "_mosaicChip");382 }383 psFree(fpaIter);384 385 psMetadata *chips = psMetadataAlloc(); // List of chip types, with cellName:cellType386 psMetadataAddStr(chips, PS_LIST_TAIL, "_mosaicChip", 0, NULL,387 "MosaickedCell:_mosaic");388 psMetadataAddMetadata(format, PS_LIST_TAIL, CHIP_TYPES, PS_META_REPLACE,389 "List of chip types", chips);390 psFree(chips);391 break;392 }331 // ensure the value of CONTENT in the FILE section has the right value 332 psMetadataAddStr(file, PS_LIST_TAIL, "CONTENT", PS_META_REPLACE, "Key to CONTENTS menu", "{CHIP.NAME}"); 333 334 // List the chipName:chipType for each chip. 335 psMetadata *contents = psMetadataAlloc(); // List of contents, with chipName:chipType 336 337 psMetadataIterator *fpaIter = psMetadataIteratorAlloc(fpa, PS_LIST_HEAD, NULL); // Iteratr 338 psMetadataItem *fpaItem; // Item from iteration 339 while ((fpaItem = psMetadataGetAndIncrement(fpaIter))) { 340 assert (fpaItem->type == PS_DATA_STRING); 341 psString content = NULL; // Content to add 342 psStringAppend(&content, "%s:_mosaicChip ", fpaItem->name); 343 psMetadataAddStr(contents, PS_LIST_TAIL, fpaItem->name, 0, NULL, content); 344 psFree(content); 345 } 346 psFree(fpaIter); 347 psMetadataAddMetadata(format, PS_LIST_TAIL, TABLE_OF_CONTENTS, PS_META_REPLACE, 348 "List of contents", contents); 349 psFree(contents); 350 351 psMetadata *chips = psMetadataAlloc(); // List of chip types, with cellName:cellType 352 psMetadataAddStr(chips, PS_LIST_TAIL, "_mosaicChip", 0, NULL, 353 "MosaickedCell:_mosaic"); 354 psMetadataAddMetadata(format, PS_LIST_TAIL, CHIP_TYPES, PS_META_REPLACE, 355 "List of chip types", chips); 356 psFree(chips); 357 break; 358 } 359 if (!strcasecmp(phuItem->data.str, "FPA") && !strcasecmp(extensionsItem->data.str, "NONE")) { 360 // List the contents on a single line 361 psString contentsLine = NULL; // Contents of the PHU 362 psMetadataIterator *fpaIter = psMetadataIteratorAlloc(fpa, PS_LIST_HEAD, NULL); // Iteratr 363 psMetadataItem *fpaItem; // Item from iteration 364 while ((fpaItem = psMetadataGetAndIncrement(fpaIter))) { 365 assert (fpaItem->type == PS_DATA_STRING); 366 psStringAppend(&contentsLine, "%s:MosaickedCell:_mosaic ", fpaItem->name); 367 } 368 psFree(fpaIter); 369 psMetadataAddStr(format, PS_LIST_TAIL, TABLE_OF_CONTENTS, PS_META_REPLACE, 370 NULL, contentsLine); 371 psFree(contentsLine); 372 break; 373 } 374 if (!strcasecmp(phuItem->data.str, "CHIP") && !strcasecmp(extensionsItem->data.str, "NONE")) { 375 // XXX recode this to match the structure above (FPA/CHIP)? 376 // select and remove the old contents 377 psMetadata *contents = psMetadataLookupMetadata(NULL, format, TABLE_OF_CONTENTS); // File contents 378 if (!contents) { 379 psError(PS_ERR_UNKNOWN, false, "Couldn't find %s in the camera format %s.\n", 380 TABLE_OF_CONTENTS, formatsItem->name); 381 return false; 382 } 383 while (psListLength(contents->list) > 0) { 384 psMetadataRemoveIndex(contents, PS_LIST_TAIL); 385 } 386 387 // update with the new contents 388 psMetadataIterator *fpaIter = psMetadataIteratorAlloc(fpa, PS_LIST_HEAD, NULL); // Iterator 389 psMetadataItem *fpaItem; // Item from iteration 390 while ((fpaItem = psMetadataGetAndIncrement(fpaIter))) { 391 assert (fpaItem->type == PS_DATA_STRING); 392 psMetadataAddStr(contents, PS_LIST_TAIL, fpaItem->name, 0, NULL, "_mosaicChip"); 393 } 394 psFree(fpaIter); 395 396 psMetadata *chips = psMetadataAlloc(); // List of chip types, with cellName:cellType 397 psMetadataAddStr(chips, PS_LIST_TAIL, "_mosaicChip", 0, NULL, 398 "MosaickedCell:_mosaic"); 399 psMetadataAddMetadata(format, PS_LIST_TAIL, CHIP_TYPES, PS_META_REPLACE, 400 "List of chip types", chips); 401 psFree(chips); 402 break; 403 } 393 404 default: 394 405 psAbort("Should never get here.\n"); … … 399 410 if (!cells) { 400 411 psError(PS_ERR_UNKNOWN, false, "Couldn't find CELLS of type METADATA in the camera format %s.\n", formatsItem->name); 401 return false;412 return false; 402 413 } 403 414 psMetadata *cell = psMetadataAlloc(); // Cell information
Note:
See TracChangeset
for help on using the changeset viewer.
