Changeset 23432
- Timestamp:
- Mar 19, 2009, 12:08:52 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/concepts/pmConceptsStandard.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/concepts/pmConceptsStandard.c
r23428 r23432 606 606 } 607 607 608 // Get the current value of a concept 609 static 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 633 static 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(×ysName, "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 654 static 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(×ysName, "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 } 608 682 609 683 psMetadataItem *p_pmConceptParse_TIMESYS(const psMetadataItem *concept, … … 622 696 if (concept->type != PS_DATA_STRING || strlen(sys) <= 0) { 623 697 // XXX is this too low verbosity? 624 ps LogMsg ("psModules.concepts", PS_LOG_DETAIL, "Can't interpret %s --- assuming UTC.\n", pattern->name);698 psWarning("Can't interpret %s --- assuming UTC.", pattern->name); 625 699 } else if (strcasecmp(sys, "TAI") == 0) { 626 700 timeSys = PS_TIME_TAI; … … 633 707 } else { 634 708 // 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); 636 716 } 637 717 … … 639 719 } 640 720 641 // Determine the corresponding TIMESYS for one of the TIME concepts642 static psTimeType conceptGetTimesysForTime(const char *name, // Concept name ("CELL.TIME" or "FPA.TIME")643 const pmFPA *fpa, // FPA of interest644 const pmChip *chip, // Chip of interest, or NULL645 const pmCell *cell // Cell of interest, or NULL646 )647 {648 assert(name);649 650 psString timesysName = psStringCopy(name); // e.g., "CELL.TIME" --> "CELL.TIMESYS"651 psStringSubstitute(×ysName, "TIMESYS", "TIME");652 bool mdok = false; // Result of MD lookup653 psTimeType timeSys = 0xFFFFFFFF; // The time system654 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 concepts674 static bool conceptSetTimesysForTime(const char *name, // Concept name ("CELL.TIME" or "FPA.TIME")675 const pmFPA *fpa, // FPA of interest676 const pmChip *chip, // Chip of interest, or NULL677 const pmCell *cell, // Cell of interest, or NULL678 psTimeType timeSys // The time system value679 )680 {681 assert(name);682 683 psString timesysName = psStringCopy(name); // e.g., "CELL.TIME" --> "CELL.TIMESYS"684 psStringSubstitute(×ysName, "TIMESYS", "TIME");685 psMetadataItem *item = NULL; // Item with time system686 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 written705 return pmConceptWriteSingle(fpa, chip, cell, NULL, item);706 }707 721 708 722
Note:
See TracChangeset
for help on using the changeset viewer.
