IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 29, 2009, 6:15:31 PM (17 years ago)
Author:
beaumont
Message:

merged with head

Location:
branches/cnb_branches/cnb_branch_20090301
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/cnb_branches/cnb_branch_20090301

  • branches/cnb_branches/cnb_branch_20090301/psModules

  • branches/cnb_branches/cnb_branch_20090301/psModules/src/concepts/pmConceptsStandard.c

    r23351 r23594  
    606606}
    607607
     608// Get the current value of a concept
     609static psMetadataItem *conceptGet(const pmFPA *fpa, // FPA of interest
     610                                  const pmChip *chip, // Chip of interest, or NULL
     611                                  const pmCell *cell, // Cell of interest, or NULL
     612                                  const char *name // Concept name
     613    )
     614{
     615    psMetadataItem *item = NULL;        // Item with time system
     616    if (cell) {
     617        item = psMetadataLookup(cell->concepts, name);
     618    }
     619    if (!item && chip) {
     620        item = psMetadataLookup(chip->concepts, name);
     621    }
     622    if (!item && fpa) {
     623        item = psMetadataLookup(fpa->concepts, name);
     624    }
     625    if (!item) {
     626        psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find %s in concepts", name);
     627        return NULL;
     628    }
     629    return item;
     630}
     631
     632// Determine the corresponding TIMESYS for one of the TIME concepts
     633static psTimeType conceptGetTimesysForTime(const char *name, // Concept name ("CELL.TIME" or "FPA.TIME")
     634                                           const pmFPA *fpa, // FPA of interest
     635                                           const pmChip *chip, // Chip of interest, or NULL
     636                                           const pmCell *cell // Cell of interest, or NULL
     637                                           )
     638{
     639    assert(name);
     640
     641    psString timesysName = psStringCopy(name); // e.g., "CELL.TIME" --> "CELL.TIMESYS"
     642    psStringSubstitute(&timesysName, "TIMESYS", "TIME");
     643    psMetadataItem *item = conceptGet(fpa, chip, cell, timesysName); // Time system
     644    psFree(timesysName);
     645
     646    if (!item || item->type != PS_TYPE_S32) {
     647        psWarning("Unable to find %s --- assuming UTC", timesysName);
     648        return PS_TIME_UTC;
     649    }
     650    return item->data.S32;
     651}
     652
     653// Set the corresponding TIMESYS for one of the TIME concepts
     654static bool conceptSetTimesysForTime(const char *name, // Concept name ("CELL.TIME" or "FPA.TIME")
     655                                     const pmFPA *fpa, // FPA of interest
     656                                     const pmChip *chip, // Chip of interest, or NULL
     657                                     const pmCell *cell, // Cell of interest, or NULL
     658                                     psTimeType timeSys // The time system value
     659                                     )
     660{
     661    assert(name);
     662
     663    psString timesysName = psStringCopy(name); // e.g., "CELL.TIME" --> "CELL.TIMESYS"
     664    psStringSubstitute(&timesysName, "TIMESYS", "TIME");
     665    psMetadataItem *item = conceptGet(fpa, chip, cell, timesysName); // Time system
     666    psFree(timesysName);
     667
     668    if (!item) {
     669        psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find %s in concepts when setting %s\n",
     670                timesysName, name);
     671        return false;
     672    }
     673
     674    if (item->data.S32 != -1 && item->data.S32 != timeSys) {
     675        psWarning("Time system is set to %x; but should be %x", item->data.S32, timeSys);
     676    }
     677
     678    item->data.S32 = timeSys;
     679
     680    return true;
     681}
    608682
    609683psMetadataItem *p_pmConceptParse_TIMESYS(const psMetadataItem *concept,
     
    622696    if (concept->type != PS_DATA_STRING || strlen(sys) <= 0) {
    623697        // XXX is this too low verbosity?
    624         psLogMsg ("psModules.concepts", PS_LOG_DETAIL, "Can't interpret %s --- assuming UTC.\n", pattern->name);
     698        psWarning("Can't interpret %s --- assuming UTC.", pattern->name);
    625699    } else if (strcasecmp(sys, "TAI") == 0) {
    626700        timeSys = PS_TIME_TAI;
     
    633707    } else {
    634708        // XXX is this too low verbosity?
    635         psLogMsg ("psModules.concepts", PS_LOG_DETAIL, "Can't interpret %s --- assuming UTC.\n", pattern->name);
     709        psWarning("Can't interpret %s --- assuming UTC.", pattern->name);
     710    }
     711
     712    psMetadataItem *old = conceptGet(fpa, chip, cell, pattern->name); // Old value
     713    if (old && old->data.S32 != -1 && old->data.S32 != timeSys) {
     714        psWarning("%s is already set (%x) and not consistent with new value (%x)",
     715                  pattern->name, old->data.S32, timeSys);
    636716    }
    637717
     
    639719}
    640720
    641 // Determine the corresponding TIMESYS for one of the TIME concepts
    642 static psTimeType conceptGetTimesysForTime(const char *name, // Concept name ("CELL.TIME" or "FPA.TIME")
    643                                            const pmFPA *fpa, // FPA of interest
    644                                            const pmChip *chip, // Chip of interest, or NULL
    645                                            const pmCell *cell // Cell of interest, or NULL
    646                                            )
    647 {
    648     assert(name);
    649 
    650     psString timesysName = psStringCopy(name); // e.g., "CELL.TIME" --> "CELL.TIMESYS"
    651     psStringSubstitute(&timesysName, "TIMESYS", "TIME");
    652     bool mdok = false;                  // Result of MD lookup
    653     psTimeType timeSys = 0xFFFFFFFF;    // The time system
    654     if (cell) {
    655         timeSys = psMetadataLookupS32(&mdok, cell->concepts, timesysName);
    656     }
    657     if (!mdok && chip) {
    658         timeSys = psMetadataLookupS32(&mdok, chip->concepts, timesysName);
    659     }
    660     if (!mdok && fpa) {
    661         timeSys = psMetadataLookupS32(&mdok, fpa->concepts, timesysName);
    662     }
    663     if (!mdok || (timeSys == 0xFFFFFFFF)) {
    664         psWarning("Unable to find %s in concepts when parsing %s --- assuming UTC.\n",
    665                   timesysName, name);
    666         timeSys = PS_TIME_UTC;
    667     }
    668     psFree(timesysName);
    669 
    670     return timeSys;
    671 }
     721
    672722
    673723psMetadataItem *p_pmConceptParse_TIME(const psMetadataItem *concept,
     
    896946    }
    897947
    898     time->type = timeSys;
     948    if (jdTime || mjdTime) {
     949        conceptSetTimesysForTime(pattern->name, fpa, chip, cell, PS_TIME_TAI);
     950    } else {
     951        time->type = timeSys;
     952    }
    899953
    900954    psMetadataItem *item = psMetadataItemAllocPtr(pattern->name, PS_DATA_TIME, pattern->comment, time);
Note: See TracChangeset for help on using the changeset viewer.