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/pmConceptsWrite.c

    r18163 r22699  
    1616#include "pmConcepts.h"
    1717#include "pmConceptsRead.h"
     18
     19#include "pmConceptsWrite.h"
    1820
    1921//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    320322
    321323bool p_pmConceptsWriteToDefaults(const psMetadata *specs, const pmFPA *fpa, const pmChip *chip,
    322                                  const pmCell *cell, psMetadata *concepts)
     324                                 const pmCell *cell, const psMetadata *concepts)
    323325{
    324326    PS_ASSERT_PTR_NON_NULL(specs, false);
     
    486488    #endif
    487489}
     490
     491
     492
     493
     494
     495// Write all registered concepts for the specified level
     496static bool conceptsWrite(psMetadata **specs, // One of the concepts specifications
     497                          const pmFPA *fpa,   // The FPA
     498                          const pmChip *chip, // The chip
     499                          const pmCell *cell, // The cell
     500                          pmConceptSource source, // The source of the concepts to write
     501                          pmConfig *config, // Configuration
     502                          psMetadata *concepts // The concepts to write out
     503                         )
     504{
     505    assert(specs);
     506    assert(concepts);
     507
     508    pmConceptsInit();
     509
     510    psTrace("psModules.concepts", 3, "Writing concepts (%p %p %p): %d\n", fpa, chip, cell, source);
     511
     512    if (source & PM_CONCEPT_SOURCE_CELLS) {
     513        p_pmConceptsWriteToCells(*specs, cell, concepts);
     514    }
     515    if (source & PM_CONCEPT_SOURCE_DEFAULTS) {
     516        p_pmConceptsWriteToDefaults(*specs, fpa, chip, cell, concepts);
     517    }
     518    if (source & (PM_CONCEPT_SOURCE_PHU | PM_CONCEPT_SOURCE_HEADER)) {
     519        p_pmConceptsWriteToHeader(*specs, fpa, chip, cell, concepts);
     520    }
     521    if (source & PM_CONCEPT_SOURCE_DATABASE) {
     522        p_pmConceptsWriteToDatabase(*specs, fpa, chip, cell, config, concepts);
     523    }
     524
     525    return true;
     526}
     527
     528
     529bool pmConceptsWriteFPA(const pmFPA *fpa, pmConceptSource source, bool propagateDown, pmConfig *config)
     530{
     531    PS_ASSERT_PTR_NON_NULL(fpa, false);
     532    psMetadata *conceptsFPA = pmConceptsSpecs(PM_FPA_LEVEL_FPA); // Concept specifications
     533    psTrace("psModules.concepts", 5, "Writing FPA concepts: %p %p\n", conceptsFPA, fpa->concepts);
     534    bool success = conceptsWrite(&conceptsFPA, fpa, NULL, NULL, source, config, fpa->concepts);
     535    if (propagateDown) {
     536        psArray *chips = fpa->chips;        // Array of chips
     537        for (long i = 0; i < chips->n; i++) {
     538            pmChip *chip = chips->data[i];  // Chip of interest
     539            if (chip && !chip->hdu) {
     540                success &= pmConceptsWriteChip(chip, source, false, true, config);
     541            }
     542        }
     543    }
     544    return success;
     545}
     546
     547
     548bool pmConceptsWriteChip(const pmChip *chip, pmConceptSource source, bool propagateUp,
     549                         bool propagateDown, pmConfig *config)
     550{
     551    PS_ASSERT_PTR_NON_NULL(chip, false);
     552    psMetadata *conceptsChip = pmConceptsSpecs(PM_FPA_LEVEL_CHIP); // Concept specifications
     553    psTrace("psModules.concepts", 5, "Writing chip concepts: %p %p\n", conceptsChip, chip->concepts);
     554    pmFPA *fpa = chip->parent;          // FPA to which the chip belongs
     555    bool success = conceptsWrite(&conceptsChip, fpa, chip, NULL, source, config, chip->concepts);
     556    if (propagateUp && !fpa->hdu) {
     557        psMetadata *conceptsFPA = pmConceptsSpecs(PM_FPA_LEVEL_FPA); // Concept specifications
     558        success &= conceptsWrite(&conceptsFPA, fpa, chip, NULL, source, config, fpa->concepts);
     559    }
     560    if (propagateDown) {
     561        psArray *cells = chip->cells;        // Array of cells
     562        for (long i = 0; i < cells->n; i++) {
     563            pmCell *cell = cells->data[i];  // Cell of interest
     564            if (cell && !cell->hdu) {
     565                success &= pmConceptsWriteCell(cell, source, false, config);
     566            }
     567        }
     568    }
     569    return success;
     570}
     571
     572
     573bool pmConceptsWriteCell(const pmCell *cell, pmConceptSource source, bool propagateUp, pmConfig *config)
     574{
     575    PS_ASSERT_PTR_NON_NULL(cell, false);
     576    psMetadata *conceptsCell = pmConceptsSpecs(PM_FPA_LEVEL_CELL); // Concept specifications
     577    psTrace("psModules.concepts", 5, "Writing cell concepts: %p %p\n", conceptsCell, cell->concepts);
     578    pmChip *chip = cell->parent;        // Chip to which the cell belongs
     579    pmFPA *fpa = chip->parent;          // FPA to which the chip belongs
     580
     581    bool success = conceptsWrite(&conceptsCell, fpa, chip, cell, source, config, cell->concepts);
     582    if (propagateUp) {
     583        if (!chip->hdu) {
     584            psMetadata *conceptsChip = pmConceptsSpecs(PM_FPA_LEVEL_CHIP); // Concept specifications
     585            success &= conceptsWrite(&conceptsChip, fpa, chip, cell, source, config, chip->concepts);
     586            if (!fpa->hdu) {
     587                psMetadata *conceptsFPA = pmConceptsSpecs(PM_FPA_LEVEL_FPA); // Concept specifications
     588                success &= conceptsWrite(&conceptsFPA, fpa, chip, cell, source, config, fpa->concepts);
     589            }
     590        }
     591    }
     592
     593    return success;
     594}
Note: See TracChangeset for help on using the changeset viewer.