IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23746


Ignore:
Timestamp:
Apr 8, 2009, 12:16:56 PM (17 years ago)
Author:
Paul Price
Message:

Adding default values for some concept interpolations. This is intended to get rid of the annoying '{CHIP.NAME}' in filenames.

Location:
trunk/psModules/src
Files:
2 edited

Legend:

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

    r23487 r23746  
    205205    }
    206206    if (strstr(newName, "{CHIP.NAME}")) {
     207        const char *name = NULL;        // Name of chip
    207208        pmChip *chip = pmFPAviewThisChip(view, fpa);
    208209        if (chip) {
    209             char *name = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME");
    210             if (name) {
    211                 psStringSubstitute(&newName, name, "{CHIP.NAME}");
    212             }
    213         }
     210            name = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME");
     211            psAssert(name, "All chips should have a name");
     212        } else {
     213            name = "fpa";
     214        }
     215        psStringSubstitute(&newName, name, "{CHIP.NAME}");
     216
    214217    }
    215218    if (strstr(newName, "{CHIP.ID}")) {
     
    255258    }
    256259    if (strstr(newName, "{CELL.NAME}")) {
     260        const char *name = NULL;        // Name of cell
    257261        pmCell *cell = pmFPAviewThisCell(view, fpa);
    258262        if (cell) {
    259             char *name = psMetadataLookupStr(NULL, cell->concepts, "CELL.NAME");
    260             if (name) {
    261                 psStringSubstitute(&newName, name, "{CELL.NAME}");
    262             }
    263         }
     263            name = psMetadataLookupStr(NULL, cell->concepts, "CELL.NAME");
     264            psAssert(name, "All cells should have a name");
     265        } else {
     266            name = "chip";
     267        }
     268        psStringSubstitute(&newName, name, "{CELL.NAME}");
    264269    }
    265270    if (strstr(newName, "{CELL.N}")) {
  • trunk/psModules/src/concepts/pmConcepts.c

    r22699 r23746  
    421421
    422422// Interpolate the concept.  Generalises the FPA/Chip/Cell
    423 #define CONCEPT_INTERPOLATE(SOURCE, NAME) \
     423#define CONCEPT_INTERPOLATE(SOURCE, NAME, DEFAULT) \
    424424    if (strncmp(concept, NAME, strlen(NAME)) == 0) { \
    425         if (!(SOURCE)) { \
    426             psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Cannot interpolate %s because %s not provided", \
    427                     concept, NAME); \
    428             psFree(string); \
    429             return NULL; \
    430         } \
    431         psMetadataItem *item = psMetadataLookup((SOURCE)->concepts, concept); /* Item with concept */ \
    432         if (!item) { \
    433             psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Can't find concept %s in %s", concept, NAME); \
    434             psFree(string); \
    435             return NULL; \
    436         } \
    437         \
    438         psString value = psMetadataItemParseString(item); /* Value of concept */ \
    439         if (!value) { \
    440             psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to parse concept %s", concept); \
    441             psFree(string); \
    442             return NULL; \
     425        psString value = NULL; /* Value of concept */ \
     426        if (SOURCE) { \
     427            psMetadataItem *item = psMetadataLookup((SOURCE)->concepts, concept); /* Item with concept */ \
     428            if (!item) { \
     429                psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Can't find concept %s in %s", concept, NAME); \
     430                psFree(string); \
     431                return NULL; \
     432            } \
     433            \
     434            psString value = psMetadataItemParseString(item); /* Value of concept */ \
     435            if (!value) { \
     436                psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to parse concept %s", concept); \
     437                psFree(string); \
     438                return NULL; \
     439            } \
     440        } else { \
     441            if (!(DEFAULT)) { \
     442                psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to determine concept %s", concept); \
     443                psFree(string); \
     444                return NULL; \
     445            } \
     446            value = psStringCopy(DEFAULT); \
    443447        } \
    444448        \
     
    483487        psTrace("psModules.concepts", 7, "Interpolating concept %s", concept);
    484488
    485         CONCEPT_INTERPOLATE(fpa,  "FPA");
    486         CONCEPT_INTERPOLATE(chip, "CHIP");
    487         CONCEPT_INTERPOLATE(cell, "CELL");
     489        CONCEPT_INTERPOLATE(fpa,  "FPA", NULL);
     490        CONCEPT_INTERPOLATE(chip, "CHIP", "fpa");
     491        CONCEPT_INTERPOLATE(cell, "CELL", "chip");
    488492
    489493        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unrecognised concept: %s", concept);
Note: See TracChangeset for help on using the changeset viewer.