Changeset 10967
- Timestamp:
- Jan 8, 2007, 12:31:41 PM (19 years ago)
- Location:
- trunk/psModules/src/concepts
- Files:
-
- 3 edited
-
pmConcepts.c (modified) (5 diffs)
-
pmConcepts.h (modified) (2 diffs)
-
pmConceptsWrite.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/concepts/pmConcepts.c
r10644 r10967 37 37 return spec; 38 38 } 39 40 psList *pmConceptsList(pmFPALevel level) 41 { 42 if (!conceptsInitialised) { 43 pmConceptsInit(); 44 } 45 46 // Get the appropriate concepts 47 psMetadata *concepts = NULL; // Metadata of concepts specs 48 switch (level) { 49 case PM_FPA_LEVEL_FPA: 50 concepts = conceptsFPA; 51 break; 52 case PM_FPA_LEVEL_CHIP: 53 concepts = conceptsChip; 54 break; 55 case PM_FPA_LEVEL_CELL: 56 concepts = conceptsCell; 57 break; 58 default: 59 psError(PS_ERR_IO, true, "Invalid concept level provided: %d\n", level); 60 return NULL; 61 } 62 63 // Pull out the names 64 psList *list = psListAlloc(NULL); // List of concepts' names 65 psMetadataIterator *iter = psMetadataIteratorAlloc(concepts, PS_LIST_HEAD, NULL); // Iterator 66 psMetadataItem *item; // Item from iteration 67 while ((item = psMetadataGetAndIncrement(iter))) { 68 psListAdd(list, PS_LIST_TAIL, item->name); 69 } 70 psFree(iter); 71 return list; 72 } 73 74 75 psList *psMetadataKeys(psMetadata *md) 76 { 77 psList *list = psListAlloc(NULL); // List with the keys 78 psMetadataIterator *iter = psMetadataIteratorAlloc(md, PS_LIST_HEAD, false); 79 psMetadataItem *item; // Item from iteration 80 while ((item = psMetadataGetAndIncrement(iter))) { 81 psListAdd(list, PS_LIST_TAIL, item->name); 82 } 83 return list; 84 } 85 39 86 40 87 … … 246 293 for (long i = 0; i < chips->n; i++) { 247 294 pmChip *chip = chips->data[i]; // Chip of interest 248 if (chip && !chip->hdu) {295 if (chip) { 249 296 success |= pmConceptsReadChip(chip, source, false, true, db); 250 297 } … … 287 334 bool success = conceptsRead(&conceptsChip, fpa, chip, NULL, &chip->conceptsRead, source, db, 288 335 chip->concepts); 289 if (propagateUp && !fpa->hdu) {336 if (propagateUp) { 290 337 success |= conceptsRead(&conceptsFPA, fpa, chip, NULL, &fpa->conceptsRead, source, db, fpa->concepts); 291 338 } … … 294 341 for (long i = 0; i < cells->n; i++) { 295 342 pmCell *cell = cells->data[i]; // Cell of interest 296 if (cell && !cell->hdu) {343 if (cell) { 297 344 success |= pmConceptsReadCell(cell, source, false, db); 298 345 } … … 341 388 cell->concepts); 342 389 if (propagateUp) { 343 if (!chip->hdu) { 344 success |= conceptsRead(&conceptsChip, fpa, chip, cell, &chip->conceptsRead, source, db, 345 chip->concepts); 346 if (!fpa->hdu) { 347 success |= conceptsRead(&conceptsFPA, fpa, chip, cell, &fpa->conceptsRead, source, db, 348 fpa->concepts); 349 } 350 } 390 success |= conceptsRead(&conceptsChip, fpa, chip, cell, &chip->conceptsRead, source, db, 391 chip->concepts); 392 success |= conceptsRead(&conceptsFPA, fpa, chip, cell, &fpa->conceptsRead, source, db, 393 fpa->concepts); 351 394 } 352 395 -
trunk/psModules/src/concepts/pmConcepts.h
r9688 r10967 7 7 /// @author Paul Price, IfA 8 8 /// 9 /// @version $Revision: 1. 9$ $Name: not supported by cvs2svn $10 /// @date $Date: 200 6-10-21 00:55:44$9 /// @version $Revision: 1.10 $ $Name: not supported by cvs2svn $ 10 /// @date $Date: 2007-01-08 22:31:41 $ 11 11 /// 12 12 /// Copyright 2005-2006 Institute for Astronomy, University of Hawaii … … 82 82 PM_CONCEPT_SOURCE_ALL = 0xff ///< All concepts 83 83 } pmConceptSource; 84 85 /// Get a list of defined concepts for a particular level. 86 psList *pmConceptsList(pmFPALevel level); 84 87 85 88 /// Read the concepts for the given set of fpa, chip, cell -
trunk/psModules/src/concepts/pmConceptsWrite.c
r10487 r10967 119 119 if (spec->format) { 120 120 formatted = spec->format(concept, cameraFormat, fpa, chip, cell); 121 } else if (strcmp(concept->name, spec->blank->name) != 0) { 122 // Adjust so that the name is correct 123 formatted = psMetadataItemCopy(concept); 124 psFree(formatted->name); 125 formatted->name = psStringCopy(spec->blank->name); 121 126 } else { 127 // Can get away with merely incrementing the reference counter 122 128 formatted = psMemIncrRefCounter((const psPtr)concept); 123 129 } … … 294 300 PS_ASSERT_PTR_NON_NULL(concepts, false); 295 301 296 pmHDU *hdu = pmHDUGetLowest( NULL, NULL, cell); // The HDU at the lowest level302 pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // The HDU at the lowest level 297 303 if (!hdu) { 298 304 return false; … … 316 322 // It's a menu --- need to look up the .DEPEND 317 323 psString dependName = NULL; // The concept name with ".DEPEND" on the end 318 psStringAppend(&dependName, " .DEPEND");324 psStringAppend(&dependName, "%s.DEPEND", defaultItem->name); 319 325 psString dependKey = psMetadataLookupStr(&mdok, defaults, dependName); // The keyword 320 psFree(dependName);321 326 if (!mdok || !dependKey || strlen(dependKey) == 0) { 322 327 psLogMsg(__func__, PS_LOG_WARN, "Can't find %s in the DEFAULTS for %s --- ignored.\n", 323 328 dependName, name); 329 psFree(dependName); 324 330 continue; 325 331 } 326 psString dependValue = psMetadataLookupStr(&mdok, concepts, depend Name); // The value327 if (!mdok || !depend Key || strlen(dependKey) == 0) {332 psString dependValue = psMetadataLookupStr(&mdok, concepts, dependKey); // The value 333 if (!mdok || !dependValue || strlen(dependValue) == 0) { 328 334 psLogMsg(__func__, PS_LOG_WARN, "Concept %s specified by %s isn't of type STR -- " 329 "ignored.\n", name, dependName); 335 "ignored.\n", dependKey, dependName); 336 psFree(dependName); 330 337 continue; 331 338 } 332 conceptItem = psMetadataLookup(defaultItem->data.V, dependValue); 339 psFree(dependName); 340 // Get the actual item of interest, and correct the name to match the concept name 341 defaultItem = psMetadataItemCopy(psMetadataLookup(defaultItem->data.md, dependValue)); 342 psFree(defaultItem->name); 343 defaultItem->name = psStringCopy(name); 333 344 } else { 334 conceptItem = psMetadataLookup(concepts, name); // The item from the concepts 335 } 345 psMemIncrRefCounter(defaultItem); 346 } 347 conceptItem = psMetadataLookup(concepts, name); // The item from the concepts 336 348 psMetadataItem *formatted = conceptFormat(spec, conceptItem, cameraFormat, fpa, chip, cell); 337 349 if (!formatted) { … … 342 354 "format, but the values don't match.\n", name); 343 355 } 356 psFree(defaultItem); 344 357 psFree(formatted); 345 358 } … … 356 369 PS_ASSERT_PTR_NON_NULL(concepts, false); 357 370 358 pmHDU *hdu = pmHDUGetLowest( NULL, NULL, cell); // The HDU at the lowest level371 pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // The HDU at the lowest level 359 372 if (!hdu) { 360 373 return false; … … 408 421 #else 409 422 410 pmHDU *hdu = pmHDUGetLowest( NULL, NULL, cell); // The HDU at the lowest level423 pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // The HDU at the lowest level 411 424 if (!hdu) { 412 425 return false;
Note:
See TracChangeset
for help on using the changeset viewer.
