IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 26, 2009, 2:45:31 PM (17 years ago)
Author:
Paul Price
Message:

Reorganised the concepts files, moving the Write functions into pmConceptsWrite, and the Read functions into pmConceptsRead, which sort of makes sense. Added new type of concept property: copy. Most concepts use the default copy method (which is to simply copy the item), but for the TIMESYS concepts, we want to ensure that the target is of the correct type --- if it's already set (e.g., via the DEFAULTS), then we don't copy it. This will allow us to set the target TIMESYS using the DEFAULTS in the camera format, and have the output time be adjusted appropriately. Without this, the TIMESYS is simply copied, and specifying the TIMESYS in the DEFAULTS results in a warning ('values don't match'). Removed pmFPACopyConcepts, since it is pretty much the same as pmConceptsCopyFPA.

File:
1 edited

Legend:

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

    r20868 r22699  
    1515#include "pmHDUUtils.h"
    1616#include "pmConcepts.h"
     17#include "pmConceptsUpdate.h"
     18
    1719#include "pmConceptsRead.h"
    1820
     
    483485}
    484486
     487
     488
     489// Read all registered concepts for the specified level
     490static bool conceptsRead(psMetadata **specs, // One of the concepts specifications
     491                         pmFPA *fpa,    // The FPA
     492                         pmChip *chip,  // The chip
     493                         pmCell *cell, // The cell
     494                         unsigned int *read,     // What's already been read
     495                         pmConceptSource source, // The source of the concepts to read
     496                         pmConfig *config, // Configuration
     497                         psMetadata *target // Place into which to read the concepts
     498                        )
     499{
     500    assert(specs);
     501    assert(read);
     502    assert(target);
     503
     504    pmConceptsInit();
     505
     506    // At least one HDU is required for the reading functions
     507    pmHDU *hduLow = pmHDUGetLowest(fpa, chip, cell); // Lowest HDU.
     508    if (!hduLow) {
     509        // Can't do anything --- don't record any success, but don't return an error either
     510        return true;
     511    }
     512    pmHDU *hduHigh = pmHDUGetHighest(fpa, chip, cell); // Highest HDU
     513
     514    if (cell && (cell->conceptsRead == PM_CONCEPT_SOURCE_NONE)) {
     515        pmConceptsBlankCell(cell);
     516        cell->conceptsRead = PM_CONCEPT_SOURCE_BLANK;
     517    }
     518    if (chip && (chip->conceptsRead == PM_CONCEPT_SOURCE_NONE)) {
     519        pmConceptsBlankChip(chip);
     520        chip->conceptsRead = PM_CONCEPT_SOURCE_BLANK;
     521    }
     522    if (fpa && (fpa->conceptsRead == PM_CONCEPT_SOURCE_NONE)) {
     523        pmConceptsBlankFPA(fpa);
     524        fpa->conceptsRead = PM_CONCEPT_SOURCE_BLANK;
     525    }
     526
     527    bool success = true;                // Success in reading concepts?
     528    if (source & PM_CONCEPT_SOURCE_CELLS && !(*read & PM_CONCEPT_SOURCE_CELLS) && cell) {
     529        if (p_pmConceptsReadFromCells(target, *specs, cell)) {
     530            *read |= PM_CONCEPT_SOURCE_CELLS;
     531        } else {
     532            psError(PS_ERR_UNKNOWN, false, "Error reading concepts from camera configuration.\n");
     533            success = false;
     534        }
     535    }
     536
     537    if (source & PM_CONCEPT_SOURCE_DEFAULTS && !(*read & PM_CONCEPT_SOURCE_DEFAULTS)) {
     538        if (p_pmConceptsReadFromDefaults(target, *specs, fpa, chip, cell)) {
     539            *read |= PM_CONCEPT_SOURCE_DEFAULTS;
     540        } else {
     541            psError(PS_ERR_UNKNOWN, false, "Error reading concepts from defaults.\n");
     542            success = false;
     543        }
     544    }
     545
     546    if (source & PM_CONCEPT_SOURCE_PHU && !(*read & PM_CONCEPT_SOURCE_PHU) && hduHigh->header) {
     547        if (p_pmConceptsReadFromHeader(target, *specs, fpa, chip, cell)) {
     548            *read |= PM_CONCEPT_SOURCE_PHU;
     549        } else {
     550            psError(PS_ERR_UNKNOWN, false, "Error reading concepts from PHU.\n");
     551            success = false;
     552        }
     553    }
     554
     555    // If there are multiple HDUs, then it may be that one of them hasn't been read yet (hdu->header not set)
     556    if (source & PM_CONCEPT_SOURCE_HEADER && !(*read & PM_CONCEPT_SOURCE_HEADER) &&
     557        hduLow != hduHigh && hduLow->header) {
     558        if (p_pmConceptsReadFromHeader(target, *specs, fpa, chip, cell)) {
     559            *read |= PM_CONCEPT_SOURCE_HEADER;
     560        } else {
     561            psError(PS_ERR_UNKNOWN, false, "Error reading concepts from header.\n");
     562            success = false;
     563        }
     564    }
     565
     566#ifdef HAVE_PSDB
     567    if (source & PM_CONCEPT_SOURCE_DATABASE && !(*read & PM_CONCEPT_SOURCE_DATABASE)) {
     568        if (p_pmConceptsReadFromDatabase(target, *specs, fpa, chip, cell, config)) {
     569            *read |= PM_CONCEPT_SOURCE_DATABASE;
     570        } else {
     571            psError(PS_ERR_UNKNOWN, false, "Error reading concepts from database.\n");
     572            success = false;
     573        }
     574    }
     575#endif
     576
     577    pmConceptsUpdate(fpa, chip, cell);
     578
     579    return success;
     580}
     581
     582
     583
     584
     585bool pmConceptsRead(pmFPA *fpa, pmChip *chip, pmCell *cell, pmConceptSource source, pmConfig *config)
     586{
     587    PS_ASSERT_PTR_NON_NULL(fpa, false);
     588    psMetadata *conceptsFPA = pmConceptsSpecs(PM_FPA_LEVEL_FPA); // Concept specifications
     589    bool success = conceptsRead(&conceptsFPA, fpa, chip, cell, &fpa->conceptsRead, source,
     590                                config, fpa->concepts);
     591    if (chip) {
     592        psMetadata *conceptsChip = pmConceptsSpecs(PM_FPA_LEVEL_CHIP); // Concept specifications
     593        success &= conceptsRead(&conceptsChip, fpa, chip, cell, &chip->conceptsRead, source,
     594                                config, chip->concepts);
     595    }
     596    if (cell) {
     597        psMetadata *conceptsCell = pmConceptsSpecs(PM_FPA_LEVEL_CELL); // Concept specifications
     598        success &= conceptsRead(&conceptsCell, fpa, chip, cell, &cell->conceptsRead, source,
     599                                config, cell->concepts);
     600    }
     601
     602    return success;
     603}
     604
     605
     606
     607bool pmConceptsReadFPA(pmFPA *fpa, pmConceptSource source, bool propagateDown, pmConfig *config)
     608{
     609    PS_ASSERT_PTR_NON_NULL(fpa, false);
     610    psMetadata *conceptsFPA = pmConceptsSpecs(PM_FPA_LEVEL_FPA); // Concept specifications
     611    psTrace("psModules.concepts", 5, "Reading FPA concepts: %p %p\n", conceptsFPA, fpa->concepts);
     612    bool success = conceptsRead(&conceptsFPA, fpa, NULL, NULL, &fpa->conceptsRead, source,
     613                                config, fpa->concepts);
     614    if (propagateDown) {
     615        psArray *chips = fpa->chips;    // Array of chips
     616        for (long i = 0; i < chips->n; i++) {
     617            pmChip *chip = chips->data[i]; // Chip of interest
     618            if (chip) {
     619                success &= pmConceptsReadChip(chip, source, false, true, config);
     620            }
     621        }
     622    }
     623
     624    return success;
     625}
     626
     627
     628
     629bool pmConceptsReadChip(pmChip *chip, pmConceptSource source, bool propagateUp,
     630                        bool propagateDown, pmConfig *config)
     631{
     632    PS_ASSERT_PTR_NON_NULL(chip, false);
     633    psMetadata *conceptsChip = pmConceptsSpecs(PM_FPA_LEVEL_CHIP); // Concept specifications
     634    psTrace("psModules.concepts", 5, "Reading chip concepts: %p %p\n", conceptsChip, chip->concepts);
     635    pmFPA *fpa = chip->parent;          // FPA to which the chip belongs
     636    bool success = conceptsRead(&conceptsChip, fpa, chip, NULL, &chip->conceptsRead, source, config,
     637                                chip->concepts);
     638    if (propagateUp) {
     639        psMetadata *conceptsFPA = pmConceptsSpecs(PM_FPA_LEVEL_FPA); // Concept specifications
     640        success &= conceptsRead(&conceptsFPA, fpa, chip, NULL, &fpa->conceptsRead, source,
     641                                config, fpa->concepts);
     642    }
     643    if (propagateDown) {
     644        psArray *cells = chip->cells;        // Array of cells
     645        for (long i = 0; i < cells->n; i++) {
     646            pmCell *cell = cells->data[i];  // Cell of interest
     647            if (cell) {
     648                success &= pmConceptsReadCell(cell, source, false, config);
     649            }
     650        }
     651    }
     652    return success;
     653}
     654
     655
     656bool pmConceptsReadCell(pmCell *cell, pmConceptSource source, bool propagateUp, pmConfig *config)
     657{
     658    PS_ASSERT_PTR_NON_NULL(cell, false);
     659    psMetadata *conceptsCell = pmConceptsSpecs(PM_FPA_LEVEL_CELL); // Concept specifications
     660    psTrace("psModules.concepts", 5, "Reading cell concepts: %p %p\n", conceptsCell, cell->concepts);
     661    pmChip *chip = cell->parent;        // Chip to which the cell belongs
     662    pmFPA *fpa = chip->parent;          // FPA to which the chip belongs
     663
     664    bool success = conceptsRead(&conceptsCell, fpa, chip, cell, &cell->conceptsRead, source, config,
     665                                cell->concepts);
     666    if (propagateUp) {
     667        psMetadata *conceptsChip = pmConceptsSpecs(PM_FPA_LEVEL_CHIP); // Concept specifications
     668        success &= conceptsRead(&conceptsChip, fpa, chip, cell, &chip->conceptsRead, source, config,
     669                                chip->concepts);
     670        psMetadata *conceptsFPA = pmConceptsSpecs(PM_FPA_LEVEL_FPA); // Concept specifications
     671
     672        success &= conceptsRead(&conceptsFPA, fpa, chip, cell, &fpa->conceptsRead, source, config,
     673                                fpa->concepts);
     674    }
     675
     676    return success;
     677}
Note: See TracChangeset for help on using the changeset viewer.