IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23432


Ignore:
Timestamp:
Mar 19, 2009, 12:08:52 PM (17 years ago)
Author:
Paul Price
Message:

Just realised that conceptSetTimesysForTime was being called in the
parsing (read) function, as opposed to the formatting (write)
function, so it's not right to force the concept write there.
Instead, look for different value when parsing the timesys and throw a
warning.

File:
1 edited

Legend:

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

    r23428 r23432  
    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 }
    672 
    673 // Set the corresponding TIMESYS for one of the TIME concepts
    674 static bool conceptSetTimesysForTime(const char *name, // Concept name ("CELL.TIME" or "FPA.TIME")
    675                                      const pmFPA *fpa, // FPA of interest
    676                                      const pmChip *chip, // Chip of interest, or NULL
    677                                      const pmCell *cell, // Cell of interest, or NULL
    678                                      psTimeType timeSys // The time system value
    679                                      )
    680 {
    681     assert(name);
    682 
    683     psString timesysName = psStringCopy(name); // e.g., "CELL.TIME" --> "CELL.TIMESYS"
    684     psStringSubstitute(&timesysName, "TIMESYS", "TIME");
    685     psMetadataItem *item = NULL;        // Item with time system
    686     if (cell) {
    687         item = psMetadataLookup(cell->concepts, timesysName);
    688     }
    689     if (!item && chip) {
    690         item = psMetadataLookup(chip->concepts, timesysName);
    691     }
    692     if (!item && fpa) {
    693         item = psMetadataLookup(fpa->concepts, timesysName);
    694     }
    695     psFree(timesysName);
    696     if (!item) {
    697         psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find %s in concepts when setting %s\n",
    698                 timesysName, name);
    699         return false;
    700     }
    701 
    702     item->data.S32 = timeSys;
    703 
    704     // Ensure the updated TIMESYS is written
    705     return pmConceptWriteSingle(fpa, chip, cell, NULL, item);
    706 }
    707721
    708722
Note: See TracChangeset for help on using the changeset viewer.