Changeset 9510
- Timestamp:
- Oct 12, 2006, 11:38:28 AM (20 years ago)
- Location:
- trunk/psModules/src/concepts
- Files:
-
- 4 edited
-
pmConcepts.c (modified) (6 diffs)
-
pmConcepts.h (modified) (1 diff)
-
pmConceptsStandard.c (modified) (13 diffs)
-
pmConceptsStandard.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/concepts/pmConcepts.c
r9216 r9510 153 153 } 154 154 155 if (source & PM_CONCEPT_SOURCE_PHU && !(*read & PM_CONCEPT_SOURCE_PHU)) { 156 if (!pmConceptsReadFromHeader(*specs, fpa, chip, cell, target)) { 157 psError(PS_ERR_UNKNOWN, false, "Error reading concepts from header.\n"); 158 success = false; 159 } 160 } 161 155 162 if (source & PM_CONCEPT_SOURCE_HEADER && !(*read & PM_CONCEPT_SOURCE_HEADER)) { 156 163 if (pmConceptsReadFromHeader(*specs, fpa, chip, cell, target)) { … … 201 208 pmConceptsWriteToDefaults(*specs, fpa, chip, cell, concepts); 202 209 } 203 if (source & PM_CONCEPT_SOURCE_HEADER) {210 if (source & (PM_CONCEPT_SOURCE_PHU | PM_CONCEPT_SOURCE_HEADER)) { 204 211 pmConceptsWriteToHeader(*specs, fpa, chip, cell, concepts); 205 212 } … … 218 225 psTrace("psModules.concepts", 5, "Blanking FPA concepts: %p %p\n", conceptsFPA, fpa->concepts); 219 226 return conceptsBlank(&conceptsFPA, fpa->concepts); 227 } 228 229 // Read the concepts for the given set of fpa, chip, cell 230 bool pmConceptsRead(pmFPA *fpa, // FPA for which to read concepts 231 pmChip *chip, // Chip for which to read concepts, or NULL 232 pmCell *cell, // Cell for which to read concepts, or NULL 233 pmConceptSource source, // The source of the concepts to read 234 psDB *db // Database handle 235 ) 236 { 237 PS_ASSERT_PTR_NON_NULL(fpa, false); 238 bool success = conceptsRead(&conceptsFPA, fpa, chip, cell, &fpa->conceptsRead, source, db, fpa->concepts); 239 if (chip) { 240 success |= conceptsRead(&conceptsChip, fpa, chip, cell, &chip->conceptsRead, source, db, chip->concepts); 241 } 242 if (cell) { 243 success |= conceptsRead(&conceptsCell, fpa, chip, cell, &cell->conceptsRead, source, db, cell->concepts); 244 } 245 246 return success; 220 247 } 221 248 … … 501 528 } 502 529 530 // FPA.TIMESYS 531 { 532 psMetadataItem *fpaTimesys = psMetadataItemAllocS32("FPA.TIMESYS", "Time system", -1); 533 pmConceptRegister(fpaTimesys, (pmConceptParseFunc)p_pmConceptParse_TIMESYS, 534 (pmConceptFormatFunc)p_pmConceptFormat_TIMESYS, PM_FPA_LEVEL_FPA); 535 psFree(fpaTimesys); 536 } 537 538 // FPA.TIME 539 { 540 psTime *time = psTimeAlloc(PS_TIME_TAI); // Blank time 541 // Not particularly distinguishing, but should be good enough 542 time->sec = 0; 543 time->nsec = 0; 544 psMetadataItem *fpaTime = psMetadataItemAlloc("FPA.TIME", PS_DATA_TIME, 545 "Time of exposure", time); 546 psFree(time); 547 pmConceptRegister(fpaTime, (pmConceptParseFunc)p_pmConceptParse_TIME, 548 (pmConceptFormatFunc)p_pmConceptFormat_TIME, PM_FPA_LEVEL_FPA); 549 psFree(fpaTime); 550 } 551 503 552 // Done with FPA level concepts 504 553 } … … 675 724 { 676 725 psMetadataItem *cellTimesys = psMetadataItemAllocS32("CELL.TIMESYS", "Time system", -1); 677 pmConceptRegister(cellTimesys, (pmConceptParseFunc)p_pmConceptParse_ CELL_TIMESYS,678 (pmConceptFormatFunc)p_pmConceptFormat_ CELL_TIMESYS, PM_FPA_LEVEL_CELL);726 pmConceptRegister(cellTimesys, (pmConceptParseFunc)p_pmConceptParse_TIMESYS, 727 (pmConceptFormatFunc)p_pmConceptFormat_TIMESYS, PM_FPA_LEVEL_CELL); 679 728 psFree(cellTimesys); 680 729 } … … 689 738 "Time of exposure", time); 690 739 psFree(time); 691 pmConceptRegister(cellTime, (pmConceptParseFunc)p_pmConceptParse_ CELL_TIME,692 (pmConceptFormatFunc)p_pmConceptFormat_ CELL_TIME, PM_FPA_LEVEL_CELL);740 pmConceptRegister(cellTime, (pmConceptParseFunc)p_pmConceptParse_TIME, 741 (pmConceptFormatFunc)p_pmConceptFormat_TIME, PM_FPA_LEVEL_CELL); 693 742 psFree(cellTime); 694 743 } -
trunk/psModules/src/concepts/pmConcepts.h
r7469 r9510 37 37 PM_CONCEPT_SOURCE_CAMERA = 0x01, // Concept comes from the camera information 38 38 PM_CONCEPT_SOURCE_DEFAULTS = 0x02, // Concept comes from defaults 39 PM_CONCEPT_SOURCE_HEADER = 0x04, // Concept comes from FITS header 40 PM_CONCEPT_SOURCE_DATABASE = 0x08, // Concept comes from database 41 PM_CONCEPT_SOURCE_ALL = 0x0e // All concepts 39 PM_CONCEPT_SOURCE_PHU = 0x04, // Concept comes from PHU 40 PM_CONCEPT_SOURCE_HEADER = 0x08, // Concept comes from FITS header 41 PM_CONCEPT_SOURCE_DATABASE = 0x10, // Concept comes from database 42 PM_CONCEPT_SOURCE_ALL = 0xff // All concepts 42 43 } pmConceptSource; 44 45 // Read the concepts for the given set of fpa, chip, cell 46 bool pmConceptsRead(pmFPA *fpa, // FPA for which to read concepts 47 pmChip *chip, // Chip for which to read concepts, or NULL 48 pmCell *cell, // Cell for which to read concepts, or NULL 49 pmConceptSource source, // The source of the concepts to read 50 psDB *db // Database handle 51 ); 43 52 44 53 // Set blanks, read or write concepts at the appropriate level -
trunk/psModules/src/concepts/pmConceptsStandard.c
r8848 r9510 282 282 283 283 284 psMetadataItem *p_pmConceptParse_ CELL_TIMESYS(psMetadataItem *concept,284 psMetadataItem *p_pmConceptParse_TIMESYS(psMetadataItem *concept, 285 285 psMetadataItem *pattern, 286 286 psMetadata *cameraFormat, … … 295 295 psString sys = concept->data.V; // The time system string 296 296 if (concept->type != PS_DATA_STRING || strlen(sys) <= 0) { 297 psError(PS_ERR_UNKNOWN, true, "Can't interpret CELL.TIMESYS --- assuming UTC.\n");297 psError(PS_ERR_UNKNOWN, true, "Can't interpret %s --- assuming UTC.\n", pattern->name); 298 298 } else if (strcasecmp(sys, "TAI") == 0) { 299 299 timeSys = PS_TIME_TAI; … … 305 305 timeSys = PS_TIME_TT; 306 306 } else { 307 psError(PS_ERR_UNKNOWN, true, "Can't interpret CELL.TIMESYS --- assuming UTC.\n");307 psError(PS_ERR_UNKNOWN, true, "Can't interpret %s --- assuming UTC.\n", pattern->name); 308 308 } 309 309 … … 311 311 } 312 312 313 psMetadataItem *p_pmConceptParse_ CELL_TIME(psMetadataItem *concept,314 psMetadataItem *pattern,315 psMetadata *cameraFormat,316 pmFPA *fpa,317 pmChip *chip,318 pmCell *cell)313 psMetadataItem *p_pmConceptParse_TIME(psMetadataItem *concept, 314 psMetadataItem *pattern, 315 psMetadata *cameraFormat, 316 pmFPA *fpa, 317 pmChip *chip, 318 pmCell *cell) 319 319 { 320 320 assert(concept); 321 321 assert(cameraFormat); 322 assert(cell); 323 324 // Need CELL.TIMESYS first 325 bool mdok = true; // Result of MD lookup 326 psTimeType timeSys = psMetadataLookupS32(&mdok, cell->concepts, "CELL.TIMESYS"); // The time system 322 323 // Need TIMESYS first 324 psString timesysName = psStringCopy(pattern->name); // e.g., "CELL.TIME" --> "CELL.TIMESYS" 325 timesysName = psStringSubstitute(timesysName, "TIMESYS", "TIME"); 326 bool mdok = false; // Result of MD lookup 327 psTimeType timeSys; // The time system 328 if (cell) { 329 timeSys = psMetadataLookupS32(&mdok, cell->concepts, timesysName); 330 } 331 if (!mdok && chip) { 332 timeSys = psMetadataLookupS32(&mdok, chip->concepts, timesysName); 333 } 334 if (!mdok && fpa) { 335 timeSys = psMetadataLookupS32(&mdok, fpa->concepts, timesysName); 336 } 327 337 if (!mdok) { 328 psLogMsg(__func__, PS_LOG_WARN, "Unable to find CELL.TIMESYS in concepts --- assuming UTC.\n"); 338 psLogMsg(__func__, PS_LOG_WARN, "Unable to find %s in concepts when parsing %s --- assuming UTC.\n", 339 timesysName, pattern->name); 329 340 timeSys = PS_TIME_UTC; 330 341 } 342 psFree(timesysName); 331 343 332 344 // Work out how the time is represented … … 344 356 } 345 357 346 psString timeFormat = psMetadataLookupStr(&mdok, formats, "CELL.TIME");358 psString timeFormat = psMetadataLookupStr(&mdok, formats, pattern->name); 347 359 if (!mdok || strlen(timeFormat) == 0) { 348 psError(PS_ERR_UNKNOWN, true, "Unable to find CELL.TIME in FORMATS.\n");360 psError(PS_ERR_UNKNOWN, true, "Unable to find %s in FORMATS.\n", pattern->name); 349 361 return NULL; 350 362 } … … 377 389 usaTime = false; 378 390 } else { 379 psError(PS_ERR_UNKNOWN, true, "Unrecognised FORMATS option for CELL.TIME: %s --- "380 "ignored.\n", timeFormat);391 psError(PS_ERR_UNKNOWN, true, "Unrecognised FORMATS option for %s: %s --- " 392 "ignored.\n", pattern->name, timeFormat); 381 393 psFree(timeFormatsIter); 382 394 psFree(timeFormats); … … 481 493 time = psTimeFromMJD(timeValue); 482 494 } else { 483 psError(PS_ERR_UNKNOWN, true, "Not sure how to parse CELL.TIME(%f) --- trying JD\n",484 timeValue);495 psError(PS_ERR_UNKNOWN, true, "Not sure how to parse %s (%f) --- trying JD\n", 496 pattern->name, timeValue); 485 497 time = psTimeFromJD(timeValue); 486 498 } … … 494 506 time = psTimeFromMJD(timeValue); 495 507 } else { 496 psError(PS_ERR_UNKNOWN, true, "Not sure how to parse CELL.TIME(%f) --- trying JD\n",497 timeValue);508 psError(PS_ERR_UNKNOWN, true, "Not sure how to parse %s (%f) --- trying JD\n", 509 pattern->name, timeValue); 498 510 time = psTimeFromJD(timeValue); 499 511 } … … 501 513 } 502 514 default: 503 psError(PS_ERR_UNKNOWN, true, "Unable to parse CELL.TIME.\n");515 psError(PS_ERR_UNKNOWN, true, "Unable to parse %s.\n", pattern->name); 504 516 return NULL; 505 517 } … … 652 664 653 665 654 psMetadataItem *p_pmConceptFormat_ CELL_TIMESYS(psMetadataItem *concept,666 psMetadataItem *p_pmConceptFormat_TIMESYS(psMetadataItem *concept, 655 667 psMetadata *cameraFormat, 656 668 pmFPA *fpa, … … 681 693 } 682 694 683 psMetadataItem *p_pmConceptFormat_ CELL_TIME(psMetadataItem *concept,684 psMetadata *cameraFormat,685 pmFPA *fpa,686 pmChip *chip,687 pmCell *cell)695 psMetadataItem *p_pmConceptFormat_TIME(psMetadataItem *concept, 696 psMetadata *cameraFormat, 697 pmFPA *fpa, 698 pmChip *chip, 699 pmCell *cell) 688 700 { 689 701 psTime *time = concept->data.V; // The time … … 700 712 psMetadata *formats = psMetadataLookupMD(&mdok, cameraFormat, "FORMATS"); // The formats 701 713 if (mdok && formats) { 702 psString format = psMetadataLookupStr(&mdok, formats, "CELL.TIME"); // The formats forCELL.TIME714 psString format = psMetadataLookupStr(&mdok, formats, concept->name); // The formats for eg, CELL.TIME 703 715 if (mdok && format && strlen(format) > 0) { 704 716 psList *formatList = psStringSplit(format, " ,;", false); // List of formats specified … … 732 744 separateTime = false; 733 745 } else { 734 psLogMsg(__func__, PS_LOG_WARN, "Unrecognised FORMATS option for CELL.TIME: %s --- "735 "ignored.\n", format);746 psLogMsg(__func__, PS_LOG_WARN, "Unrecognised FORMATS option for %s: %s --- " 747 "ignored.\n", concept->name, format); 736 748 } 737 749 } -
trunk/psModules/src/concepts/pmConceptsStandard.h
r7441 r9510 36 36 pmChip *chip, 37 37 pmCell *cell); 38 psMetadataItem *p_pmConceptParse_ CELL_TIMESYS(psMetadataItem *concept,38 psMetadataItem *p_pmConceptParse_TIMESYS(psMetadataItem *concept, 39 39 psMetadataItem *pattern, 40 40 psMetadata *cameraFormat, … … 42 42 pmChip *chip, 43 43 pmCell *cell); 44 psMetadataItem *p_pmConceptParse_ CELL_TIME(psMetadataItem *concept,45 psMetadataItem *pattern,46 psMetadata *cameraFormat,47 pmFPA *fpa,48 pmChip *chip,49 pmCell *cell);44 psMetadataItem *p_pmConceptParse_TIME(psMetadataItem *concept, 45 psMetadataItem *pattern, 46 psMetadata *cameraFormat, 47 pmFPA *fpa, 48 pmChip *chip, 49 pmCell *cell); 50 50 psMetadataItem *p_pmConceptParse_Positions(psMetadataItem *concept, 51 51 psMetadataItem *pattern, … … 74 74 pmChip *chip, 75 75 pmCell *cell); 76 psMetadataItem *p_pmConceptFormat_ CELL_TIMESYS(psMetadataItem *concept,76 psMetadataItem *p_pmConceptFormat_TIMESYS(psMetadataItem *concept, 77 77 psMetadata *cameraFormat, 78 78 pmFPA *fpa, 79 79 pmChip *chip, 80 80 pmCell *cell); 81 psMetadataItem *p_pmConceptFormat_ CELL_TIME(psMetadataItem *concept,82 psMetadata *cameraFormat,83 pmFPA *fpa,84 pmChip *chip,85 pmCell *cell);81 psMetadataItem *p_pmConceptFormat_TIME(psMetadataItem *concept, 82 psMetadata *cameraFormat, 83 pmFPA *fpa, 84 pmChip *chip, 85 pmCell *cell); 86 86 psMetadataItem *p_pmConceptFormat_Positions(psMetadataItem *concept, 87 87 psMetadata *cameraFormat,
Note:
See TracChangeset
for help on using the changeset viewer.
