Changeset 7311 for trunk/psModules/src/concepts
- Timestamp:
- Jun 2, 2006, 3:02:08 PM (20 years ago)
- Location:
- trunk/psModules/src/concepts
- Files:
-
- 4 edited
-
pmConcepts.c (modified) (1 diff)
-
pmConcepts.h (modified) (1 diff)
-
pmConceptsRead.c (modified) (11 diffs)
-
pmConceptsStandard.c (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/concepts/pmConcepts.c
r7310 r7311 131 131 } 132 132 133 bool success = true; // Success in reading concepts? 133 134 if (source & PM_CONCEPT_SOURCE_CAMERA && !(*read & PM_CONCEPT_SOURCE_CAMERA)) { 134 pmConceptsReadFromCamera(*specs, cell, target); 135 *read |= PM_CONCEPT_SOURCE_CAMERA; 135 if (pmConceptsReadFromCamera(*specs, cell, target)) { 136 *read |= PM_CONCEPT_SOURCE_CAMERA; 137 } else { 138 psError(PS_ERR_UNKNOWN, false, "Error reading concepts from camera configuration.\n"); 139 success = false; 140 } 136 141 } 137 142 138 143 if (source & PM_CONCEPT_SOURCE_DEFAULTS && !(*read & PM_CONCEPT_SOURCE_DEFAULTS)) { 139 pmConceptsReadFromDefaults(*specs, fpa, chip, cell, target); 140 *read |= PM_CONCEPT_SOURCE_DEFAULTS; 144 if (pmConceptsReadFromDefaults(*specs, fpa, chip, cell, target)) { 145 *read |= PM_CONCEPT_SOURCE_DEFAULTS; 146 } else { 147 psError(PS_ERR_UNKNOWN, false, "Error reading concepts from defaults.\n"); 148 success = false; 149 } 141 150 } 142 151 143 152 if (source & PM_CONCEPT_SOURCE_HEADER && !(*read & PM_CONCEPT_SOURCE_HEADER)) { 144 pmConceptsReadFromHeader(*specs, fpa, chip, cell, target); 145 *read |= PM_CONCEPT_SOURCE_HEADER; 146 } 147 153 if (pmConceptsReadFromHeader(*specs, fpa, chip, cell, target)) { 154 *read |= PM_CONCEPT_SOURCE_HEADER; 155 } else { 156 psError(PS_ERR_UNKNOWN, false, "Error reading concepts from header.\n"); 157 success = false; 158 } 159 } 160 161 #ifndef OMIT_PSDB 148 162 if (source & PM_CONCEPT_SOURCE_DATABASE && !(*read & PM_CONCEPT_SOURCE_DATABASE)) { 149 pmConceptsReadFromDatabase(*specs, fpa, chip, cell, db, target); 150 *read |= PM_CONCEPT_SOURCE_DATABASE; 151 } 152 153 return true; 163 if (pmConceptsReadFromDatabase(*specs, fpa, chip, cell, db, target)) { 164 *read |= PM_CONCEPT_SOURCE_DATABASE; 165 } else { 166 psError(PS_ERR_UNKNOWN, false, "Error reading concepts from database.\n"); 167 success = false; 168 } 169 } 170 #endif 171 172 return success; 154 173 } 155 174 -
trunk/psModules/src/concepts/pmConcepts.h
r7017 r7311 6 6 7 7 // Function to call to parse a concept once it has been read 8 typedef psMetadataItem* (*pmConceptParseFunc)( psMetadataItem *concept, psMetadataItem *pattern, psMetadata *cameraFormat, pmFPA *fpa, pmChip *chip,pmCell *cell);8 typedef psMetadataItem* (*pmConceptParseFunc)(const psMetadataItem *concept, const psMetadataItem *pattern, const psMetadata *cameraFormat, const pmFPA *fpa, const pmChip *chip, const pmCell *cell); 9 9 // Function to call to format a concept for writing 10 typedef psMetadataItem* (*pmConceptFormatFunc)( psMetadataItem *concept, psMetadata *cameraFormat, pmFPA *fpa, pmChip *chip,pmCell *cell);10 typedef psMetadataItem* (*pmConceptFormatFunc)(const psMetadataItem *concept, const psMetadata *cameraFormat, const pmFPA *fpa, const pmChip *chip, const pmCell *cell); 11 11 12 12 // A "concept" specification -
trunk/psModules/src/concepts/pmConceptsRead.c
r7280 r7311 71 71 parsed = parsePlain(concept, spec->blank); 72 72 } 73 if (!parsed) 74 return false; 73 if (!parsed) { 74 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to parse concept %s\n", spec->blank->name); 75 return false; 76 } 75 77 76 78 // Plug the parsed concept into a new psMetadataItem, so each "concept" has its own version that can … … 117 119 118 120 pmHDU *hdu = pmHDUGetLowest(NULL, NULL, cell); // The HDU at the lowest level 119 if (! hdu) {121 if (!hdu) { 120 122 return false; 121 123 } … … 124 126 psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator 125 127 psMetadataItem *specItem = NULL; // Item from the specs metadata 128 bool status = true; // Status of reading concepts 126 129 while ((specItem = psMetadataGetAndIncrement(specsIter))) { 127 130 pmConceptSpec *spec = specItem->data.V; // The specification 128 131 psString name = specItem->name; // The concept name 129 132 psMetadataItem *conceptItem = psMetadataLookup(cellConfig, name); // The concept, or NULL 130 psMetadataItem *value = NULL; // The value of the concept131 133 if (conceptItem) { 132 134 if (conceptItem->type == PS_DATA_STRING) { … … 138 140 psFree(nameSource); 139 141 if (mdok && strlen(source) > 0 && strcasecmp(source, "VALUE") == 0) { 140 value = conceptItem; 141 conceptParse(spec, value, cameraFormat, target, NULL, NULL, cell); 142 if (!conceptParse(spec, conceptItem, cameraFormat, target, NULL, NULL, cell)) { 143 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to parse concept %s from camera " 144 "configuration\n", name); 145 status = false; 146 } 142 147 } else if (source && (strlen(source) == 0 || strcasecmp(source, "HEADER") != 0)) { 143 148 // We leave "HEADER" to pmConceptsReadFromHeader … … 148 153 } else { 149 154 // Another type --- should be OK 150 conceptParse(spec, conceptItem, cameraFormat, target, NULL, NULL, cell); 155 if (!conceptParse(spec, conceptItem, cameraFormat, target, NULL, NULL, cell)) { 156 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to parse concept %s from camera " 157 "configuration. It has a weird %s.SOURCE: %s\n", name, name); 158 status = false; 159 } 151 160 } 152 161 } 153 162 } 154 163 psFree(specsIter); 155 return true;164 return status; 156 165 } 157 166 … … 179 188 psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator 180 189 psMetadataItem *specItem = NULL; // Item from the specs metadata 190 bool status = true; // Status of reading concepts 181 191 while ((specItem = psMetadataGetAndIncrement(specsIter))) { 182 192 pmConceptSpec *spec = specItem->data.V; // The specification 183 193 psString name = specItem->name; // The concept name 184 194 psMetadataItem *conceptItem = psMetadataLookup(defaults, name); // The concept, or NULL 185 conceptParse(spec, conceptItem, cameraFormat, target, fpa, chip, cell); 195 if (conceptItem && !conceptParse(spec, conceptItem, cameraFormat, target, fpa, chip, cell)) { 196 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to parse concept %s from DEFAULTS.\n", name); 197 status = false; 198 } 186 199 } 187 200 psFree(specsIter); 188 return true;201 return status; 189 202 } 190 203 … … 213 226 psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator 214 227 psMetadataItem *specItem = NULL; // Item from the specs metadata 228 bool status = true; // Status of reading concepts 215 229 while ((specItem = psMetadataGetAndIncrement(specsIter))) { 216 230 pmConceptSpec *spec = specItem->data.V; // The specification … … 257 271 258 272 // This will also clean up the name 259 conceptParse(spec, headerItem, cameraFormat, target, fpa, chip, cell); 273 if (headerItem && !conceptParse(spec, headerItem, cameraFormat, target, fpa, chip, cell)) { 274 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to parse concept %s from header.\n", name); 275 status = false; 276 } 260 277 } 261 278 psFree(specsIter); 262 return true;279 return status; 263 280 } 264 281 … … 294 311 psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator 295 312 psMetadataItem *specItem = NULL; // Item from the specs metadata 313 bool status = true; // Status of reading concepts 296 314 while ((specItem = psMetadataGetAndIncrement(specsIter))) { 297 315 pmConceptSpec *spec = specItem->data.V; // The specification … … 374 392 375 393 // Now we have the result 376 conceptParse(spec, conceptItem, cameraFormat, target, fpa, chip, cell); 394 if (!conceptParse(spec, conceptItem, cameraFormat, target, fpa, chip, cell)) { 395 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to parse concept %s from database.\n", 396 name); 397 status = false; 398 } 377 399 378 400 } … … 385 407 psFree(specsIter); 386 408 387 return true;409 return status; 388 410 #endif 389 411 } -
trunk/psModules/src/concepts/pmConceptsStandard.c
r7281 r7311 69 69 sscanf(concept->data.V, "%d %d %f", &big, &medium, &small) != 3) 70 70 { 71 psError(PS_ERR_ IO, true, "Cannot interpret FPA.RA: %s\n", concept->data.V);71 psError(PS_ERR_UNKNOWN, true, "Cannot interpret FPA.RA: %s\n", concept->data.V); 72 72 break; 73 73 } … … 80 80 break; 81 81 default: 82 psError(PS_ERR_ IO, true, "%s concept is of an unexpected type: %x\n", pattern->name, concept->type);82 psError(PS_ERR_UNKNOWN, true, "%s concept is of an unexpected type: %x\n", pattern->name, concept->type); 83 83 return NULL; 84 84 } … … 171 171 assert(pattern); 172 172 173 psRegion *trimsec = ps Alloc(sizeof(psRegion)); // Make space for a psRegion (usually passed by value)173 psRegion *trimsec = psRegionAlloc(0, 0, 0, 0); 174 174 175 175 if (concept->type != PS_DATA_STRING) { 176 psError(PS_ERR_IO, true, "CELL.TRIMSEC after read is not of type STR (%x)\n", concept->type); 177 *trimsec = psRegionSet(0.0, 0.0, 0.0, 0.0); 176 psError(PS_ERR_UNKNOWN, true, "CELL.TRIMSEC after read is not of type STR (%x)\n", concept->type); 178 177 } else { 179 178 *trimsec = psRegionFromString(concept->data.V); … … 231 230 } 232 231 default: 233 psError(PS_ERR_ IO, true, "CELL.BIASSEC after read is not of type STRING or LIST --- assuming "232 psError(PS_ERR_UNKNOWN, true, "CELL.BIASSEC after read is not of type STRING or LIST --- assuming " 234 233 "blank.\n"); 235 234 } … … 259 258 (strcmp(pattern->name, "CELL.YBIN") == 0 && sscanf(binString, "%*d %d", &binning) != 1 && 260 259 sscanf(binString, "%*d,%d", &binning) != 1)) { 261 psError(PS_ERR_ IO, true, "Unable to parse string to get %s: %s\n", pattern->name, binString);260 psError(PS_ERR_UNKNOWN, true, "Unable to parse string to get %s: %s\n", pattern->name, binString); 262 261 } 263 262 } … … 269 268 TYPE_CASE(binning, concept, S32); 270 269 default: 271 psError(PS_ERR_ IO, true, "Note sure how to parse %s of type %x --- assuming 1.\n", pattern->name,270 psError(PS_ERR_UNKNOWN, true, "Note sure how to parse %s of type %x --- assuming 1.\n", pattern->name, 272 271 concept->type); 273 272 } … … 290 289 psString sys = concept->data.V; // The time system string 291 290 if (concept->type != PS_DATA_STRING || strlen(sys) <= 0) { 292 psError(PS_ERR_ IO, true, "Can't interpret CELL.TIMESYS --- assuming UTC.\n");291 psError(PS_ERR_UNKNOWN, true, "Can't interpret CELL.TIMESYS --- assuming UTC.\n"); 293 292 } else if (strcasecmp(sys, "TAI") == 0) { 294 293 timeSys = PS_TIME_TAI; … … 300 299 timeSys = PS_TIME_TT; 301 300 } else { 302 psError(PS_ERR_ IO, true, "Can't interpret CELL.TIMESYS --- assuming UTC.\n");301 psError(PS_ERR_UNKNOWN, true, "Can't interpret CELL.TIMESYS --- assuming UTC.\n"); 303 302 } 304 303 … … 334 333 // Get format 335 334 psMetadata *formats = psMetadataLookupMD(&mdok, cameraFormat, "FORMATS"); 336 if (!mdok || !formats) 335 if (!mdok || !formats) { 336 psError(PS_ERR_UNKNOWN, false, "Unable to find FORMATS in camera configuration.\n"); 337 337 return NULL; 338 } 338 339 339 340 psString timeFormat = psMetadataLookupStr(&mdok, formats, "CELL.TIME"); 340 if (!mdok || !timeFormat || !strlen(timeFormat)) 341 if (!mdok || !timeFormat || !strlen(timeFormat)) { 342 psError(PS_ERR_UNKNOWN, false, "Unable to find CELL.TIME in FORMATS.\n"); 341 343 return NULL; 344 } 342 345 343 346 // Parse the time format … … 385 388 psMetadataItem *timeItem = psListGet(dateTime, PS_LIST_HEAD + 1); // Item containing the time 386 389 if (dateItem->type != PS_DATA_STRING) { 387 psError(PS_ERR_ IO, true, "Date is not of type STR.\n");390 psError(PS_ERR_UNKNOWN, true, "Date is not of type STR.\n"); 388 391 return NULL; 389 392 } … … 392 395 if (sscanf(dateString, "%d-%d-%d", &year, &month, &day) != 3 && 393 396 sscanf(dateString, "%d/%d/%d", &year, &month, &day) != 3) { 394 psError(PS_ERR_ IO, true, "Unable to read date: %s\n", dateString);397 psError(PS_ERR_UNKNOWN, true, "Unable to read date: %s\n", dateString); 395 398 return NULL; 396 399 } … … 408 411 year = temp; 409 412 } 410 if (pre2000Time || year < 2000) { 411 year += 2000; 412 } 413 if (year < 100) { 414 if (pre2000Time) { 415 year += 1900; 416 } else { 417 year += 2000; 418 } 419 } 420 sprintf(dateString,"%04d-%02d-%02d", year, month, day); 421 413 422 psString timeString = NULL; // The string with the time 414 423 if (timeItem->type == PS_DATA_STRING) { … … 427 436 TYPE_CASE(seconds, timeItem, F64); 428 437 default: 429 psError(PS_ERR_ IO, true, "Time is not of an expected type: %x\n", timeItem->type);438 psError(PS_ERR_UNKNOWN, true, "Time is not of an expected type: %x\n", timeItem->type); 430 439 return NULL; 431 440 } … … 440 449 psStringAppend(&dateTimeString, "%sT%s", dateString, timeString); 441 450 time = psTimeFromISO(dateTimeString, timeSys); 451 psFree(dateTimeString); 442 452 break; 443 453 } … … 463 473 time = psTimeFromMJD(timeValue); 464 474 } else { 465 psError(PS_ERR_IO, true, "Not sure how to parse CELL.TIME (%f) --- trying JD\n", timeValue); 475 psError(PS_ERR_UNKNOWN, true, "Not sure how to parse CELL.TIME (%f) --- trying JD\n", 476 timeValue); 466 477 time = psTimeFromJD(timeValue); 467 478 } … … 475 486 time = psTimeFromMJD(timeValue); 476 487 } else { 477 psError(PS_ERR_IO, true, "Not sure how to parse CELL.TIME (%f) --- trying JD\n", timeValue); 488 psError(PS_ERR_UNKNOWN, true, "Not sure how to parse CELL.TIME (%f) --- trying JD\n", 489 timeValue); 478 490 time = psTimeFromJD(timeValue); 479 491 } … … 481 493 } 482 494 default: 483 psError(PS_ERR_ IO, true, "Unable to parse CELL.TIME.\n");495 psError(PS_ERR_UNKNOWN, true, "Unable to parse CELL.TIME.\n"); 484 496 return NULL; 485 497 } … … 526 538 TYPE_CASE(offset, concept, S32); 527 539 default: 528 psError(PS_ERR_ IO, true, "Concept %s is not of integer type, as expected.\n", pattern->name);540 psError(PS_ERR_UNKNOWN, true, "Concept %s is not of integer type, as expected.\n", pattern->name); 529 541 return NULL; 530 542 } … … 724 736 // XXX: Couldn't be bothered doing these right now 725 737 if (pre2000Time) { 726 psError(PS_ERR_ IO, true, "Don't you realise it's the twenty-first century?\n");738 psError(PS_ERR_UNKNOWN, true, "Don't you realise it's the twenty-first century?\n"); 727 739 return NULL; 728 740 } 729 741 if (backwardsTime) { 730 psError(PS_ERR_ IO, true, "You want it BACKWARDS? Not right now, thanks.\n");742 psError(PS_ERR_UNKNOWN, true, "You want it BACKWARDS? Not right now, thanks.\n"); 731 743 return NULL; 732 744 } 733 745 if (usaTime) { 734 psError(PS_ERR_ IO, true, "USA? No OK --- yet.\n");746 psError(PS_ERR_UNKNOWN, true, "USA? No OK.\n"); 735 747 return NULL; 736 748 } … … 778 790 779 791 if (concept->type != PS_TYPE_S32) { 780 psError(PS_ERR_ IO, true, "Concept %s is not of type S32, as expected.\n", concept->name);792 psError(PS_ERR_UNKNOWN, true, "Concept %s is not of type S32, as expected.\n", concept->name); 781 793 return NULL; 782 794 }
Note:
See TracChangeset
for help on using the changeset viewer.
