IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10967


Ignore:
Timestamp:
Jan 8, 2007, 12:31:41 PM (19 years ago)
Author:
Paul Price
Message:

Fixed bugs with writing concepts to DEFAULTS --- code was all confused! Added function to return a list of concepts defined at a particular level, pmConceptsList.

Location:
trunk/psModules/src/concepts
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/concepts/pmConcepts.c

    r10644 r10967  
    3737    return spec;
    3838}
     39
     40psList *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
     75psList *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
    3986
    4087
     
    246293        for (long i = 0; i < chips->n; i++) {
    247294            pmChip *chip = chips->data[i]; // Chip of interest
    248             if (chip && !chip->hdu) {
     295            if (chip) {
    249296                success |= pmConceptsReadChip(chip, source, false, true, db);
    250297            }
     
    287334    bool success = conceptsRead(&conceptsChip, fpa, chip, NULL, &chip->conceptsRead, source, db,
    288335                                chip->concepts);
    289     if (propagateUp && !fpa->hdu) {
     336    if (propagateUp) {
    290337        success |= conceptsRead(&conceptsFPA, fpa, chip, NULL, &fpa->conceptsRead, source, db, fpa->concepts);
    291338    }
     
    294341        for (long i = 0; i < cells->n; i++) {
    295342            pmCell *cell = cells->data[i];  // Cell of interest
    296             if (cell && !cell->hdu) {
     343            if (cell) {
    297344                success |= pmConceptsReadCell(cell, source, false, db);
    298345            }
     
    341388                                cell->concepts);
    342389    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);
    351394    }
    352395
  • trunk/psModules/src/concepts/pmConcepts.h

    r9688 r10967  
    77/// @author Paul Price, IfA
    88///
    9 /// @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
    10 /// @date $Date: 2006-10-21 00:55:44 $
     9/// @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
     10/// @date $Date: 2007-01-08 22:31:41 $
    1111///
    1212/// Copyright 2005-2006 Institute for Astronomy, University of Hawaii
     
    8282    PM_CONCEPT_SOURCE_ALL      = 0xff   ///< All concepts
    8383} pmConceptSource;
     84
     85/// Get a list of defined concepts for a particular level.
     86psList *pmConceptsList(pmFPALevel level);
    8487
    8588/// Read the concepts for the given set of fpa, chip, cell
  • trunk/psModules/src/concepts/pmConceptsWrite.c

    r10487 r10967  
    119119        if (spec->format) {
    120120            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);
    121126        } else {
     127            // Can get away with merely incrementing the reference counter
    122128            formatted = psMemIncrRefCounter((const psPtr)concept);
    123129        }
     
    294300    PS_ASSERT_PTR_NON_NULL(concepts, false);
    295301
    296     pmHDU *hdu = pmHDUGetLowest(NULL, NULL, cell); // The HDU at the lowest level
     302    pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // The HDU at the lowest level
    297303    if (!hdu) {
    298304        return false;
     
    316322                // It's a menu --- need to look up the .DEPEND
    317323                psString dependName = NULL; // The concept name with ".DEPEND" on the end
    318                 psStringAppend(&dependName, ".DEPEND");
     324                psStringAppend(&dependName, "%s.DEPEND", defaultItem->name);
    319325                psString dependKey = psMetadataLookupStr(&mdok, defaults, dependName); // The keyword
    320                 psFree(dependName);
    321326                if (!mdok || !dependKey || strlen(dependKey) == 0) {
    322327                    psLogMsg(__func__, PS_LOG_WARN, "Can't find %s in the DEFAULTS for %s --- ignored.\n",
    323328                             dependName, name);
     329                    psFree(dependName);
    324330                    continue;
    325331                }
    326                 psString dependValue = psMetadataLookupStr(&mdok, concepts, dependName); // The value
    327                 if (!mdok || !dependKey || strlen(dependKey) == 0) {
     332                psString dependValue = psMetadataLookupStr(&mdok, concepts, dependKey); // The value
     333                if (!mdok || !dependValue || strlen(dependValue) == 0) {
    328334                    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);
    330337                    continue;
    331338                }
    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);
    333344            } 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
    336348            psMetadataItem *formatted = conceptFormat(spec, conceptItem, cameraFormat, fpa, chip, cell);
    337349            if (!formatted) {
     
    342354                         "format, but the values don't match.\n", name);
    343355            }
     356            psFree(defaultItem);
    344357            psFree(formatted);
    345358        }
     
    356369    PS_ASSERT_PTR_NON_NULL(concepts, false);
    357370
    358     pmHDU *hdu = pmHDUGetLowest(NULL, NULL, cell); // The HDU at the lowest level
     371    pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // The HDU at the lowest level
    359372    if (!hdu) {
    360373        return false;
     
    408421    #else
    409422
    410     pmHDU *hdu = pmHDUGetLowest(NULL, NULL, cell); // The HDU at the lowest level
     423    pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // The HDU at the lowest level
    411424    if (!hdu) {
    412425        return false;
Note: See TracChangeset for help on using the changeset viewer.