IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7469


Ignore:
Timestamp:
Jun 9, 2006, 3:55:20 PM (20 years ago)
Author:
Paul Price
Message:

Was having trouble reading and writing concepts at different levels. Added 'propagateUp' and 'propagateDown' flags to the pmConceptsRead and pmConceptsWrite functions so we can read up and down the hierarchy. For example, when you read a header at the chip level, it may be a PHU so that you want the FPA to also read concepts from it if it doesn't have its own HDU, and you want the cell to read concepts from it if it doesn't have its own HDU. But if I add a PHU, I only want to propagate upwards, because the downwards propagation will occur when I read the header lower down.

Location:
trunk/psModules/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPAConstruct.c

    r7449 r7469  
    138138    fpa->hdu = psMemIncrRefCounter(hdu);
    139139    bool success = true;                // Success of reading concepts
    140     if (hdu->header && !pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_HEADER, NULL)) {
     140    if (hdu->header && !pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_HEADER, false, NULL)) {
    141141        psError(PS_ERR_UNKNOWN, false, "Unable to read concepts from header.\n");
    142142        success = false;
     
    164164    chip->hdu = psMemIncrRefCounter(hdu);
    165165    bool success = true;                // Success of reading concepts
    166     if (hdu->header && !pmConceptsReadChip(chip, PM_CONCEPT_SOURCE_HEADER, true, NULL)) {
     166    if (hdu->header && !pmConceptsReadChip(chip, PM_CONCEPT_SOURCE_HEADER, true, false, NULL)) {
    167167        psError(PS_ERR_UNKNOWN, false, "Unable to read concepts from header.\n");
    168168        success = false;
     
    299299        }
    300300
    301         if (!pmConceptsReadChip(newChip, PM_CONCEPT_SOURCE_DEFAULTS, false, NULL)) {
     301        if (!pmConceptsReadChip(newChip, PM_CONCEPT_SOURCE_DEFAULTS, false, false, NULL)) {
    302302            psError(PS_ERR_UNKNOWN, false, "Unable to read concepts from camera and defaults for chip %s\n",
    303303                    chipName);
     
    751751    psFree(contentsIter);
    752752
    753     if (!pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_DEFAULTS, NULL)) {
     753    if (!pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_DEFAULTS, true, NULL)) {
    754754        psError(PS_ERR_UNKNOWN, false, "Unable to read concepts from defaults for FPA %s.  Attempting to "
    755755                "proceed anyway.\n", currentFPAname);
  • trunk/psModules/src/camera/pmFPAHeader.c

    r7314 r7469  
    66#include "pmConcepts.h"
    77#include "pmFPAHeader.h"
    8 
    9 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
    10 // File-static (private) functions
    11 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
    12 
    13 // Read concepts for all cells in a chip
    14 static bool chipConcepts(pmChip *chip   // The chip for which to read the concepts
    15                         )
    16 {
    17     assert(chip);
    18 
    19     bool status = true;                 // Status of concept reading
    20     status |= pmConceptsReadChip(chip, PM_CONCEPT_SOURCE_HEADER, false, NULL);
    21     psArray *cells = chip->cells;       // The cells
    22     for (int i = 0; i < cells->n; i++) {
    23         pmCell *cell = cells->data[i];  // The cell of interest
    24         if (!cell) {
    25             continue;
    26         }
    27         status |= pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER, false, NULL);
    28     }
    29 
    30     return status;
    31 }
    32 
    33 // Read concepts for all chips in an FPA
    34 static bool fpaConcepts(pmFPA *fpa   // The FPA for which to read the concepts
    35                        )
    36 {
    37     assert(fpa);
    38 
    39     bool status = true;                 // Status of concept reading
    40     status |= pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_HEADER, NULL);
    41     psArray *chips = fpa->chips;        // The chips
    42     for (int i = 0; i < chips->n; i++) {
    43         pmChip *chip = chips->data[i];  // The chip of interest
    44         if (!chip) {
    45             continue;
    46         }
    47         status |= chipConcepts(chip);
    48     }
    49 
    50     return status;
    51 }
    52 
    538
    549//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    9045    }
    9146
    92     if (!chipConcepts(chip)) {
     47    if (!pmConceptsReadChip(chip, PM_CONCEPT_SOURCE_HEADER, true, true, NULL)) {
    9348        psError(PS_ERR_UNKNOWN, false, "Unable to read concepts for chip.\n");
    9449        return false;
     
    11469    }
    11570
    116     if (!fpaConcepts(fpa)) {
     71    if (!pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_HEADER, true, NULL)) {
    11772        psError(PS_ERR_UNKNOWN, false, "Unable to read concepts for FPA.\n");
    11873        return false;
  • trunk/psModules/src/camera/pmFPARead.c

    r7407 r7469  
    183183
    184184    // Make sure we have the information we need
    185     pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CAMERA | PM_CONCEPT_SOURCE_DEFAULTS,
    186                        false, NULL);
     185    if (!pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CAMERA |
     186                            PM_CONCEPT_SOURCE_DEFAULTS, true, NULL)) {
     187        psError(PS_ERR_IO, false, "Failed to read concepts for cell.\n");
     188        return false;
     189    }
    187190
    188191    // Get the trim and bias sections
     
    322325    }
    323326
    324     if (!pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER, false, NULL)) {
     327    if (!pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER, true, NULL)) {
    325328        psError(PS_ERR_UNKNOWN, false, "Failed to read concepts for cell");
    326329        return false;
     
    354357    }
    355358
    356     pmCellSetDataStatus (cell, true);
     359    pmCellSetDataStatus(cell, true);
    357360    return true;
    358361}
     
    374377    }
    375378    if (success) {
    376         pmConceptsReadChip(chip, PM_CONCEPT_SOURCE_HEADER, false, NULL);
     379        if (!pmConceptsReadChip(chip, PM_CONCEPT_SOURCE_HEADER, true, true, NULL)) {
     380            psError(PS_ERR_IO, false, "Failed to read concepts for FPA.\n");
     381            return false;
     382        }
    377383        // XXX probably could just use chip->data_exists
    378         pmChipSetDataStatus (chip, true);
     384        pmChipSetDataStatus(chip, true);
    379385    }
    380386
     
    398404    }
    399405    if (success) {
    400         pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_HEADER, NULL);
     406        if (!pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_HEADER, true, NULL)) {
     407            psError(PS_ERR_IO, false, "Failed to read concepts for FPA.\n");
     408            return false;
     409        }
    401410    } else {
    402411        psError(PS_ERR_UNKNOWN, false, "Unable to read any chips in FPA");
  • trunk/psModules/src/camera/pmFPAWrite.c

    r7278 r7469  
    136136            (pixels && (hdu->images || (!hdu->images && pmHDUGenerateForChip(chip) && hdu->images)))) { // Data
    137137        success &= pmConceptsWriteChip(chip, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CAMERA |
    138                                        PM_CONCEPT_SOURCE_DEFAULTS, false, NULL);
     138                                       PM_CONCEPT_SOURCE_DEFAULTS, false, true, NULL);
    139139        success &= pmHDUWrite(hdu, fits);
    140140    }
     
    177177            (pixels && (hdu->images || (!hdu->images && pmHDUGenerateForFPA(fpa) && hdu->images)))) { // Data
    178178        success &= pmConceptsWriteFPA(fpa, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CAMERA |
    179                                       PM_CONCEPT_SOURCE_DEFAULTS, NULL);
     179                                      PM_CONCEPT_SOURCE_DEFAULTS, true, NULL);
    180180        success &= pmHDUWrite(hdu, fits);
    181181    }
  • trunk/psModules/src/concepts/pmConcepts.c

    r7447 r7469  
    189189    }
    190190
     191    psTrace(__func__, 3, "Writing concepts (%x %x %x): %x\n", fpa, chip, cell, source);
     192
    191193    if (source & PM_CONCEPT_SOURCE_CAMERA) {
    192194        pmConceptsWriteToCamera(*specs, cell, concepts);
     
    218220bool pmConceptsReadFPA(pmFPA *fpa,      // FPA for which to read concepts
    219221                       pmConceptSource source, // The source of the concepts to read
    220                        psDB *db         // Database handle
     222                       bool propagateDown, // Propagate to lower levels?
     223                       psDB *db        // Database handle
    221224                      )
    222225{
    223226    PS_ASSERT_PTR_NON_NULL(fpa, false);
    224227    psTrace("psModule.concepts", 5, "Reading FPA concepts: %x %x\n", conceptsFPA, fpa->concepts);
    225     return conceptsRead(&conceptsFPA, fpa, NULL, NULL, &fpa->conceptsRead, source, db, fpa->concepts);
     228    bool success = conceptsRead(&conceptsFPA, fpa, NULL, NULL, &fpa->conceptsRead, source, db, fpa->concepts);
     229    if (propagateDown) {
     230        psArray *chips = fpa->chips;    // Array of chips
     231        for (long i = 0; i < chips->n; i++) {
     232            pmChip *chip = chips->data[i]; // Chip of interest
     233            if (chip && !chip->hdu) {
     234                success |= pmConceptsReadChip(chip, source, false, true, db);
     235            }
     236        }
     237    }
     238
     239    return success;
    226240}
    227241
     
    229243bool pmConceptsWriteFPA(pmFPA *fpa,     // FPA for which to write concepts
    230244                        pmConceptSource source, // The source of the concepts to read
     245                        bool propagateDown, // Propagate to lower levels?
    231246                        psDB *db        // Database handle
    232247                       )
     
    234249    PS_ASSERT_PTR_NON_NULL(fpa, false);
    235250    psTrace("psModule.concepts", 5, "Writing FPA concepts: %x %x\n", conceptsFPA, fpa->concepts);
    236     return conceptsWrite(&conceptsFPA, fpa, NULL, NULL, source, db, fpa->concepts);
     251    bool success = conceptsWrite(&conceptsFPA, fpa, NULL, NULL, source, db, fpa->concepts);
     252    if (propagateDown) {
     253        psArray *chips = fpa->chips;        // Array of chips
     254        for (long i = 0; i < chips->n; i++) {
     255            pmChip *chip = chips->data[i];  // Chip of interest
     256            if (chip && !chip->hdu) {
     257                success |= pmConceptsWriteChip(chip, source, false, true, db);
     258            }
     259        }
     260    }
     261    return success;
    237262}
    238263
     
    249274bool pmConceptsReadChip(pmChip *chip,   // Chip for which to read concepts
    250275                        pmConceptSource source, // The source of the concepts to read
    251                         bool propagate, // Propagate to higher levels as well?
     276                        bool propagateUp, // Propagate to higher levels?
     277                        bool propagateDown, // Propagate to lower levels?
    252278                        psDB *db        // Database handle
    253279                       )
     
    256282    psTrace("psModule.concepts", 5, "Reading chip concepts: %x %x\n", conceptsChip, chip->concepts);
    257283    pmFPA *fpa = chip->parent;          // FPA to which the chip belongs
    258     return conceptsRead(&conceptsChip, fpa, chip, NULL, &chip->conceptsRead, source, db, chip->concepts) &&
    259            ((propagate && conceptsRead(&conceptsFPA, fpa, chip, NULL, &fpa->conceptsRead, source, db,
    260                                        fpa->concepts)) ||
    261             !propagate);
     284    bool success = conceptsRead(&conceptsChip, fpa, chip, NULL, &chip->conceptsRead, source, db,
     285                                chip->concepts);
     286    if (propagateUp && !fpa->hdu) {
     287        success |= conceptsRead(&conceptsFPA, fpa, chip, NULL, &fpa->conceptsRead, source, db, fpa->concepts);
     288    }
     289    if (propagateDown) {
     290        psArray *cells = chip->cells;        // Array of cells
     291        for (long i = 0; i < cells->n; i++) {
     292            pmCell *cell = cells->data[i];  // Cell of interest
     293            if (cell && !cell->hdu) {
     294                success |= pmConceptsReadCell(cell, source, false, db);
     295            }
     296        }
     297    }
     298    return success;
    262299}
    263300
     
    265302bool pmConceptsWriteChip(pmChip *chip,  // Chip for which to write concepts
    266303                         pmConceptSource source, // The source of the concepts to read
    267                          bool propagate,// Propagate to higher levels as well?
     304                         bool propagateUp, // Propagate to higher levels?
     305                         bool propagateDown, // Propagate to lower levels?
    268306                         psDB *db        // Database handle
    269307                        )
     
    272310    psTrace("psModule.concepts", 5, "Writing chip concepts: %x %x\n", conceptsChip, chip->concepts);
    273311    pmFPA *fpa = chip->parent;          // FPA to which the chip belongs
    274     return conceptsWrite(&conceptsChip, fpa, chip, NULL, source, db, chip->concepts) &&
    275            ((propagate && conceptsWrite(&conceptsFPA, fpa, chip, NULL, source, db, fpa->concepts)) ||
    276             !propagate);
     312    bool success = conceptsWrite(&conceptsChip, fpa, chip, NULL, source, db, chip->concepts);
     313    if (propagateUp && !fpa->hdu) {
     314        success |= conceptsWrite(&conceptsFPA, fpa, chip, NULL, source, db, fpa->concepts);
     315    }
     316    if (propagateDown) {
     317        psArray *cells = chip->cells;        // Array of cells
     318        for (long i = 0; i < cells->n; i++) {
     319            pmCell *cell = cells->data[i];  // Cell of interest
     320            if (cell && !cell->hdu) {
     321                success |= pmConceptsWriteCell(cell, source, false, db);
     322            }
     323        }
     324    }
     325    return success;
    277326}
    278327
     
    289338bool pmConceptsReadCell(pmCell *cell,   // Cell for which to read concepts
    290339                        pmConceptSource source, // The source of the concepts to read
    291                         bool propagate,// Propagate to higher levels as well?
     340                        bool propagateUp, // Propagate to higher levels?
    292341                        psDB *db        // Database handle
    293342                       )
     
    298347    pmFPA *fpa = chip->parent;          // FPA to which the chip belongs
    299348
    300     bool cellSuccess = conceptsRead(&conceptsCell, fpa, chip, cell, &cell->conceptsRead, source, db, cell->concepts);
    301 
    302     bool chipSuccess = true;
    303     if (propagate) {
    304         chipSuccess = conceptsRead(&conceptsChip, fpa, chip, cell, &chip->conceptsRead, source, db, chip->concepts);
    305     }
    306 
    307     bool fpaSuccess = true;
    308     if (propagate) {
    309         fpaSuccess = conceptsRead(&conceptsFPA, fpa, chip, cell, &fpa->conceptsRead, source, db, fpa->concepts);
    310     }
    311 
    312     return (cellSuccess && chipSuccess && fpaSuccess);
     349    bool success = conceptsRead(&conceptsCell, fpa, chip, cell, &cell->conceptsRead, source, db,
     350                                cell->concepts);
     351    if (propagateUp) {
     352        if (!chip->hdu) {
     353            success |= conceptsRead(&conceptsChip, fpa, chip, cell, &chip->conceptsRead, source, db,
     354                                    chip->concepts);
     355            if (!fpa->hdu) {
     356                success |= conceptsRead(&conceptsFPA, fpa, chip, cell, &fpa->conceptsRead, source, db,
     357                                        fpa->concepts);
     358            }
     359        }
     360    }
     361
     362    return success;
    313363}
    314364
     
    316366bool pmConceptsWriteCell(pmCell *cell,  // FPA for which to write concepts
    317367                         pmConceptSource source, // The source of the concepts to read
    318                          bool propagate,// Propagate to higher levels as well?
     368                         bool propagateUp, // Propagate to higher levels?
    319369                         psDB *db       // Database handle
    320370                        )
     
    324374    pmChip *chip = cell->parent;        // Chip to which the cell belongs
    325375    pmFPA *fpa = chip->parent;          // FPA to which the chip belongs
    326     return conceptsWrite(&conceptsCell, fpa, chip, cell, source, db, cell->concepts) &&
    327            ((propagate && conceptsWrite(&conceptsChip, fpa, chip, cell, source, db, chip->concepts) &&
    328              conceptsWrite(&conceptsFPA, fpa, chip, cell, source, db, fpa->concepts)) || !propagate);
     376
     377    bool success = conceptsWrite(&conceptsCell, fpa, chip, cell, source, db, cell->concepts);
     378    if (propagateUp) {
     379        if (!chip->hdu) {
     380            success |= conceptsWrite(&conceptsChip, fpa, chip, cell, source, db, chip->concepts);
     381            if (!fpa->hdu) {
     382                success |= conceptsWrite(&conceptsFPA, fpa, chip, cell, source, db, fpa->concepts);
     383            }
     384        }
     385    }
     386
     387    return success;
    329388}
    330389
  • trunk/psModules/src/concepts/pmConcepts.h

    r7311 r7469  
    4747bool pmConceptsReadFPA(pmFPA *fpa,      // FPA for which to read concepts
    4848                       pmConceptSource source, // Source for concepts
     49                       bool propagateDown, // Propagate to lower levels?
    4950                       psDB *db         // Database handle
    5051                      );
    5152bool pmConceptsWriteFPA(pmFPA *fpa,     // FPA for which to write concepts
    5253                        pmConceptSource source, // Source for concepts
     54                        bool propagateDown, // Propagate to lower levels?
    5355                        psDB *db        // Database handle
    5456                       );
     
    5759bool pmConceptsReadChip(pmChip *chip,   // Chip for which to read concepts
    5860                        pmConceptSource source, // Source for concepts
    59                         bool propagate, // Propagate to higher levels as well?
     61                        bool propagateUp, // Propagate to higher levels?
     62                        bool propagateDown, // Propagate to lower levels?
    6063                        psDB *db        // Database handle
    6164                       );
    6265bool pmConceptsWriteChip(pmChip *chip,  // Chip for which to write concepts
    6366                         pmConceptSource source, // Source for concepts
    64                          bool propagate,// Propagate to higher levels as well?
     67                         bool propagateUp,// Propagate to higher levels?
     68                         bool propagateDown, // Propagate to lower levels?
    6569                         psDB *db       // Database handle
    6670                        );
     
    6973bool pmConceptsReadCell(pmCell *cell,   // Cell for which to read concepts
    7074                        pmConceptSource source, // Source for concepts
    71                         bool propagate, // Propagate to higher levels as well?
     75                        bool propagateUp, // Propagate to higher levels?
    7276                        psDB *db        // Database handle
    7377                       );
    7478bool pmConceptsWriteCell(pmCell *cell,  // FPA for which to write concepts
    7579                         pmConceptSource source, // Source for concepts
    76                          bool propagate,// Propagate to higher levels as well?
     80                         bool propagateUp, // Propagate to higher levels?
    7781                         psDB *db       // Database handle
    7882                        );
  • trunk/psModules/src/concepts/pmConceptsWrite.c

    r7382 r7469  
    141141    switch (item->type) {
    142142    case PS_DATA_STRING:
     143        psTrace(__func__, 9, "Writing header %s: %s\n", keyword, item->data.V);
    143144        return psMetadataAddStr(hdu->header, PS_LIST_TAIL, keyword, PS_META_REPLACE, item->comment,
    144145                                item->data.V);
    145146    case PS_DATA_S32:
     147        psTrace(__func__, 9, "Writing header %s: %d\n", keyword, item->data.S32);
    146148        return psMetadataAddS32(hdu->header, PS_LIST_TAIL, keyword, PS_META_REPLACE, item->comment,
    147149                                item->data.S32);
    148150    case PS_DATA_F32:
     151        psTrace(__func__, 9, "Writing header %s: %f\n", keyword, item->data.F32);
    149152        return psMetadataAddF32(hdu->header, PS_LIST_TAIL, keyword, PS_META_REPLACE, item->comment,
    150153                                item->data.F32);
    151154    case PS_DATA_F64:
     155        psTrace(__func__, 9, "Writing header %s: %f\n", keyword, item->data.F64);
    152156        return psMetadataAddF64(hdu->header, PS_LIST_TAIL, keyword, PS_META_REPLACE, item->comment,
    153157                                item->data.F64);
    154158    case PS_DATA_REGION: {
    155159            psString region = psRegionToString(*(psRegion*)item->data.V);
     160            psTrace(__func__, 9, "Writing header %s: %s\n", keyword, region);
    156161            bool result = psMetadataAddStr(hdu->header, PS_LIST_TAIL, keyword, PS_META_REPLACE, item->comment,
    157162                                           region);
     
    378383                continue;
    379384            }
     385            psTrace(__func__, 3, "Writing %s to header %s\n", name, headerItem->data.V);
    380386            psMetadataItem *conceptItem = psMetadataLookup(concepts, name); // The item from the concepts
    381387            psMetadataItem *formatted = conceptFormat(spec, conceptItem, cameraFormat, fpa, chip, cell);
Note: See TracChangeset for help on using the changeset viewer.