Changeset 27084
- Timestamp:
- Feb 25, 2010, 12:09:45 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/camera/pmFPAfileDefine.c (modified) (49 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPAfileDefine.c
r27000 r27084 91 91 psMetadata *data = pmConfigFileRule(config, camera, name); // File rule 92 92 if (!data) { 93 psError( PS_ERR_IO, true, "Can't find file rule %s!", name);93 psError(psErrorCodeLast(), false, "Can't find file rule %s!", name); 94 94 return NULL; 95 95 } … … 105 105 file->type = pmFPAfileTypeFromString(type); 106 106 if (file->type == PM_FPA_FILE_NONE) { 107 psError(P S_ERR_IO, true, "FILE.TYPE is not defined for %s\n", name);107 psError(PM_ERR_CONFIG, true, "FILE.TYPE is not defined for %s\n", name); 108 108 psFree(file); 109 109 return NULL; … … 115 115 file->dataLevel = pmFPALevelFromName(psMetadataLookupStr (&status, data, "DATA.LEVEL")); 116 116 if (file->dataLevel == PM_FPA_LEVEL_NONE) { 117 psError(P S_ERR_IO, true, "DATA.LEVEL is not set for %s\n", name);117 psError(PM_ERR_CONFIG, true, "DATA.LEVEL is not set for %s\n", name); 118 118 psFree(file); 119 119 return NULL; … … 137 137 if (!psMetadataAddPtr(config->files, PS_LIST_TAIL, name, 138 138 PS_DATA_UNKNOWN | PS_META_DUPLICATE_OK, "", file)) { 139 psError(P S_ERR_IO, false, "could not add %s to config files", name);139 psError(PM_ERR_CONFIG, false, "could not add %s to config files", name); 140 140 return NULL; 141 141 } … … 167 167 psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->system, "CAMERAS"); // Known cameras 168 168 if (!mdok || !cameras) { 169 psError(P S_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the system configuration.\n");169 psError(PM_ERR_CONFIG, true, "Unable to find CAMERAS in the system configuration.\n"); 170 170 return NULL; 171 171 } 172 172 camera = psMetadataLookupMetadata(&mdok, cameras, cameraName); // Camera configuration of interest 173 173 if (!mdok || !camera) { 174 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find automatically generated " 175 "camera configuration %s in system configuration.\n", cameraName); 174 psError(PM_ERR_CONFIG, true, 175 "Unable to find automatically generated camera configuration %s in system configuration.", 176 cameraName); 176 177 return NULL; 177 178 } … … 184 185 psMetadata *filerule = pmConfigFileRule(config, camera, name); // File rule 185 186 if (!filerule) { 186 psError( PS_ERR_IO, true, "Can't find file rule %s!", name);187 psError(psErrorCodeLast(), false, "Can't find file rule %s!", name); 187 188 return NULL; 188 189 } … … 199 200 file->type = pmFPAfileTypeFromString(type); 200 201 if (file->type == PM_FPA_FILE_NONE) { 201 psError(P S_ERR_IO, true, "FILE.TYPE is not defined for %s\n", name);202 psError(PM_ERR_CONFIG, true, "FILE.TYPE is not defined for %s\n", name); 202 203 psFree(file); 203 204 return NULL; … … 230 231 psMetadata *format = psMetadataLookupMetadata(&status, formats, formatName); // Camera format to use 231 232 if (!format) { 232 psError(P S_ERR_BAD_PARAMETER_VALUE, true, "Unable to find format %s for file %s.\n",233 psError(PM_ERR_CONFIG, true, "Unable to find format %s for file %s.\n", 233 234 formatName, file->name); 234 235 psFree(file); … … 287 288 options->stdevNum = parseOptionFloat(scheme, "STDEV.NUM", source); // Padding to edge 288 289 if (!isfinite(options->stdevNum)) { 289 psError(P S_ERR_BAD_PARAMETER_VALUE, false, "Bad value for STDEV.NUM for %s", source);290 psError(PM_ERR_CONFIG, true, "Bad value for STDEV.NUM for %s", source); 290 291 psFree(source); 291 292 psFree(file); … … 296 297 options->stdevBits = parseOptionInt(scheme, "STDEV.BITS", source, 0); // Bits for stdev 297 298 if (options->stdevBits <= 0) { 298 psError(P S_ERR_BAD_PARAMETER_VALUE, false, "Bad value for STDEV.BITS (%d) for %s",299 psError(PM_ERR_CONFIG, true, "Bad value for STDEV.BITS (%d) for %s", 299 300 options->stdevBits, source); 300 301 psFree(source); … … 337 338 file->fileLevel = pmFPAPHULevel(format); 338 339 if (file->fileLevel == PM_FPA_LEVEL_NONE) { 339 psError(P S_ERR_IO, true, "Unable to determine file level for %s\n", name);340 psError(PM_ERR_CONFIG, true, "Unable to determine file level for %s\n", name); 340 341 psFree(file); 341 342 return NULL; … … 344 345 file->dataLevel = pmFPALevelFromName(psMetadataLookupStr(&status, filerule, "DATA.LEVEL")); 345 346 if (file->dataLevel == PM_FPA_LEVEL_NONE) { 346 psError(P S_ERR_IO, true, "DATA.LEVEL is not set for %s\n", name);347 psError(PM_ERR_CONFIG, true, "DATA.LEVEL is not set for %s\n", name); 347 348 psFree(file); 348 349 return NULL; … … 443 444 psString realName = pmConfigConvertFilename(filenames->data[0], config, false, false); 444 445 if (!realName) { 445 psError( PS_ERR_IO, false, "Failed to convert file name %s", (char *)filenames->data[0]);446 psError(psErrorCodeLast(), false, "Failed to convert file name %s", (char *)filenames->data[0]); 446 447 return NULL; 447 448 } … … 451 452 psFits *fits = psFitsOpen(realName, "r"); // FITS file 452 453 if (!fits) { 453 psError( PS_ERR_IO, false, "Failed to open file %s", realName);454 psError(psErrorCodeLast(), false, "Failed to open file %s", realName); 454 455 psFree(realName); 455 456 return NULL; … … 457 458 phu = psFitsReadHeader (NULL, fits); // Primary header 458 459 if (!phu) { 459 psError( PS_ERR_IO, false, "Failed to read file header %s", realName);460 psError(psErrorCodeLast(), false, "Failed to read file header %s", realName); 460 461 psFree(realName); 461 462 return NULL; … … 471 472 format = pmConfigCameraFormatFromHeader(&camera, &cameraName, &formatName, config, phu, true); 472 473 if (!format) { 473 psError( PS_ERR_IO, false, "Failed to determine camera format for %s", realName);474 psError(psErrorCodeLast(), false, "Failed to determine camera format for %s", realName); 474 475 psFree(camera); 475 476 psFree(formatName); … … 481 482 fileLevel = pmFPAPHULevel(format); 482 483 if (fileLevel == PM_FPA_LEVEL_NONE) { 483 psError(P S_ERR_IO, true, "Unable to determine file level for %s", realName);484 psError(PM_ERR_CONFIG, true, "Unable to determine file level for %s", realName); 484 485 psFree(camera); 485 486 psFree(formatName); … … 494 495 psFree(camera); 495 496 if (!fpa) { 496 psError( PS_ERR_IO, false, "Failed to construct FPA from %s", realName);497 psError(psErrorCodeLast(), false, "Failed to construct FPA from %s", realName); 497 498 psFree(formatName); 498 499 psFree(realName); … … 508 509 pmFPAfile *file = pmFPAfileDefineInput(config, fpa, cameraName, name); // File, to return 509 510 if (!file) { 510 psError( PS_ERR_IO, false, "File %s not defined", name);511 psError(psErrorCodeLast(), false, "File %s not defined", name); 511 512 psFree(formatName); 512 513 psFree(format); … … 535 536 psString realName = pmConfigConvertFilename(filenames->data[i], config, false, false); 536 537 if (!realName) { 537 psError( PS_ERR_IO, false, "Failed to convert file name %s", (char*)filenames->data[i]);538 psError(psErrorCodeLast(), false, "Failed to convert file name %s", (char*)filenames->data[i]); 538 539 return NULL; 539 540 } 540 541 psFits *fits = psFitsOpen(realName, "r"); // FITS file 541 542 if (!fits) { 542 psError( PS_ERR_IO, false, "Failed to open file %s", realName);543 psError(psErrorCodeLast(), false, "Failed to open file %s", realName); 543 544 psFree(realName); 544 545 return NULL; … … 551 552 } 552 553 if (!phu) { 553 psError( PS_ERR_IO, false, "Failed to read file header %s", realName);554 psError(psErrorCodeLast(), false, "Failed to read file header %s", realName); 554 555 psFree(realName); 555 556 return NULL; … … 560 561 if (i == 0 && file->type == PM_FPA_FILE_MASK) { 561 562 if (!pmConfigMaskReadHeader(config, phu)) { 562 psError( PS_ERR_IO, false, "Error reading mask bits");563 psError(psErrorCodeLast(), false, "Error reading mask bits"); 563 564 psFree(phu); 564 565 return NULL; … … 570 571 bool valid = false; 571 572 if (!pmConfigValidateCameraFormat(&valid, format, phu)) { 572 psError( PS_ERR_UNKNOWN, false, "Error in config scripts\n");573 psError(psErrorCodeLast(), false, "Error in config scripts\n"); 573 574 psFree(phu); 574 575 return NULL; 575 576 } 576 577 if (!valid) { 577 psError( PS_ERR_IO, false, "File %s is not from the required camera",578 psError(psErrorCodeLast(), false, "File %s is not from the required camera", 578 579 (char*)filenames->data[i]); 579 580 psFree(phu); … … 583 584 format = pmConfigCameraFormatFromHeader(NULL, NULL, NULL, config, phu, true); 584 585 if (!format) { 585 psError( PS_ERR_IO, false, "Failed to determine camera format from %s",586 psError(psErrorCodeLast(), false, "Failed to determine camera format from %s", 586 587 (char*)filenames->data[i]); 587 588 psFree(phu); … … 609 610 phu = NULL; 610 611 if (!view) { 611 psError(P S_ERR_IO, false, "Unable to determine source for %s", name);612 psError(PM_ERR_CONFIG, true, "Unable to determine source for %s", name); 612 613 return NULL; 613 614 } … … 641 642 } 642 643 if (filenames->n == 0) { 643 psError(P S_ERR_IO, false, "No files in array in %s in arguments", argname);644 psError(PM_ERR_CONFIG, true, "No files in array in %s in arguments", argname); 644 645 if (success) { 645 646 *success = false; … … 675 676 } 676 677 if (filenames->n == 0) { 677 psError(P S_ERR_IO, false, "No files in array in %s in arguments", argname);678 psError(PM_ERR_CONFIG, true, "No files in array in %s in arguments", argname); 678 679 if (success) { 679 680 *success = false; … … 708 709 } 709 710 if (filenames->n <= entry) { 710 psError(P S_ERR_IO, false, "Insufficient files (%ld) in array in %s in arguments",711 psError(PM_ERR_CONFIG, true, "Insufficient files (%ld) in array in %s in arguments", 711 712 filenames->n, argname); 712 713 if (success) { … … 768 769 } 769 770 if (bind && files->n != bind->n) { 770 psError(P S_ERR_BAD_PARAMETER_VALUE, true,771 psError(PM_ERR_CONFIG, true, 771 772 "Length of filenames (%ld) and bind files (%ld) does not match.", 772 773 files->n, bind->n); … … 782 783 files->data[i] = psMemIncrRefCounter(fpaFileDefineFromArray(config, bindFile, filename, dummy)); 783 784 if (!files->data[i]) { 784 psError( PS_ERR_UNKNOWN, false, "Unable to define file %s %d", filename, i);785 psError(psErrorCodeLast(), false, "Unable to define file %s %d", filename, i); 785 786 psFree(dummy); 786 787 psFree(files); … … 810 811 // a camera config is needed (as source of file rule) 811 812 if (config->camera == NULL) { 812 psError(P S_ERR_IO, true, "camera is not defined");813 psError(PM_ERR_PROG, true, "camera is not defined"); 813 814 return NULL; 814 815 } … … 817 818 pmFPA *fpa = pmFPAConstruct(config->camera, config->cameraName); 818 819 if (!fpa) { 819 psError( PS_ERR_IO, false, "Failed to construct FPA for %s", filename);820 psError(psErrorCodeLast(), false, "Failed to construct FPA for %s", filename); 820 821 return NULL; 821 822 } … … 826 827 psFree (fpa); 827 828 if (!file) { 828 psError( PS_ERR_IO, false, "file %s not defined\n", filename);829 psError(psErrorCodeLast(), false, "file %s not defined\n", filename); 829 830 return NULL; 830 831 } … … 832 833 // image names may not come from file->names 833 834 if (!strcasecmp(file->filerule, "@FILES")) { 834 psError(P S_ERR_IO, true, "supplied filerule uses illegal value @FILES");835 psError(PM_ERR_CONFIG, true, "supplied filerule uses illegal value @FILES"); 835 836 // XXX remove the file from config->files 836 837 return NULL; … … 889 890 // a camera config is needed (as source of file rule) 890 891 if (config->camera == NULL) { 891 psError(PS_ERR_ IO, true, "camera is not defined");892 psError(PS_ERR_PROG, true, "camera is not defined"); 892 893 return NULL; 893 894 } … … 903 904 fpa = pmFPAConstruct(config->camera, config->cameraName); 904 905 if (!fpa) { 905 psError( PS_ERR_IO, false, "Failed to construct FPA for %s", filename);906 psError(psErrorCodeLast(), false, "Failed to construct FPA for %s", filename); 906 907 return NULL; 907 908 } … … 910 911 file = pmFPAfileDefineInput (config, fpa, NULL, filename); 911 912 if (!file) { 912 psError( PS_ERR_IO, false, "file %s not defined\n", filename);913 psError(psErrorCodeLast(), false, "file %s not defined\n", filename); 913 914 psFree(fpa); 914 915 return NULL; … … 942 943 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, "PPIMAGE"); 943 944 if (!status) { 944 psError(P S_ERR_UNEXPECTED_NULL, true, "PPIMAGE recipe not found.");945 psError(PM_ERR_CONFIG, true, "PPIMAGE recipe not found."); 945 946 psFree(options); 946 947 psFree(fpa); … … 1020 1021 pmDetrendSelectResults *results = pmDetrendSelect (options, config); 1021 1022 if (!results) { 1022 psError ( PS_ERR_IO, false, "no matching detrend data");1023 psError (psErrorCodeLast(), false, "no matching detrend data"); 1023 1024 return NULL; 1024 1025 } … … 1026 1027 file->fileLevel = pmFPALevelFromName(results->level); 1027 1028 if (file->fileLevel == PM_FPA_LEVEL_NONE) { 1028 psError (P S_ERR_IO, false, "invalid file level for selected detrend data");1029 psError (PM_ERR_CONFIG, false, "invalid file level for selected detrend data"); 1029 1030 return NULL; 1030 1031 } … … 1051 1052 pmFPAfile *file = pmFPAfileDefineOutput (config, fpa, filename); 1052 1053 if (!file) { 1053 psError( PS_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);1054 psError(psErrorCodeLast(), false, "file %s not defined\n", filename); 1054 1055 return NULL; 1055 1056 } … … 1070 1071 pmFPAfile *file = pmFPAfileDefineOutputForFormat(config, NULL, filename, src->cameraName, src->formatName); 1071 1072 if (!file) { 1072 psError( PS_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);1073 psError(psErrorCodeLast(), false, "file %s not defined\n", filename); 1073 1074 return NULL; 1074 1075 } … … 1092 1093 pmFPAfile *file = pmFPAfileDefineOutput (config, NULL, filename); 1093 1094 if (!file) { 1094 psError( PS_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);1095 psError(psErrorCodeLast(), false, "file %s not defined\n", filename); 1095 1096 return NULL; 1096 1097 } 1097 1098 if (!file->camera) { 1098 psError(P S_ERR_UNEXPECTED_NULL, false, "file %s does not define a new camera\n", filename);1099 psError(PM_ERR_CONFIG, false, "file %s does not define a new camera\n", filename); 1099 1100 return NULL; 1100 1101 } … … 1135 1136 } 1136 1137 if (!file) { 1137 psError(P S_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);1138 psError(PM_ERR_CONFIG, true, "file %s not defined\n", filename); 1138 1139 return NULL; 1139 1140 } … … 1178 1179 } 1179 1180 if (!file) { 1180 psError(P S_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);1181 psError(PM_ERR_CONFIG, true, "file %s not defined\n", filename); 1181 1182 return NULL; 1182 1183 } … … 1185 1186 if (src) { 1186 1187 if (!pmConceptsCopyFPA(file->fpa, src, true, false)) { 1187 psError( PS_ERR_UNKNOWN, false, "Unable to copy concepts from source to new FPA");1188 psError(psErrorCodeLast(), false, "Unable to copy concepts from source to new FPA"); 1188 1189 return NULL; 1189 1190 } … … 1229 1230 } 1230 1231 if (!file) { 1231 psError(P S_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);1232 psError(PM_ERR_CONFIG, true, "file %s not defined\n", filename); 1232 1233 return NULL; 1233 1234 } … … 1236 1237 if (src) { 1237 1238 if (!pmConceptsCopyFPA(file->fpa, src, false, false)) { 1238 psError( PS_ERR_UNKNOWN, false, "Unable to copy concepts from source to new FPA");1239 psError(psErrorCodeLast(), false, "Unable to copy concepts from source to new FPA"); 1239 1240 return NULL; 1240 1241 } … … 1282 1283 } 1283 1284 if (file == NULL) { 1284 psError(P S_ERR_IO, true, "file %s is NULL", name);1285 psError(PM_ERR_CONFIG, true, "file %s is NULL", name); 1285 1286 return false; 1286 1287 }
Note:
See TracChangeset
for help on using the changeset viewer.
