Changeset 7249 for trunk/psModules/src/camera/pmFPAWrite.c
- Timestamp:
- May 30, 2006, 7:18:05 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/camera/pmFPAWrite.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPAWrite.c
r7168 r7249 84 84 psFits *fits, // FITS file to which to write 85 85 psDB *db, // Database handle for "concepts" update 86 bool pixels // Write the pixels ?86 bool pixels // Write the pixels, or only the PHU header? 87 87 ) 88 88 { 89 89 pmHDU *hdu = cell->hdu; // The HDU 90 if (hdu && ((!pixels && hdu->phu) || pixels)) { 91 if (pixels && !hdu->images && !pmHDUGenerateForCell(cell)) { 92 psError(PS_ERR_IO, false, "Unable to generate HDU for cell.\n"); 93 return false; 94 } 95 bool status = pmConceptsWriteCell(cell, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CAMERA | 96 PM_CONCEPT_SOURCE_DEFAULTS, false, NULL); 97 status &= pmHDUWrite(hdu, fits); 98 if (!status) { 99 psError(PS_ERR_IO, false, "Unable to write HDU for Chip.\n"); 100 return false; 101 } 90 if (!hdu) { 91 return true; // We wrote every HDU that exists 102 92 } 103 93 104 return true; 94 bool success = true; // Success of writing 95 if ((!pixels && hdu->phu && !hdu->images) || // Data-less PHU 96 (pixels && (hdu->images || (!hdu->images && pmHDUGenerateForCell(cell) && hdu->images)))) { // Data 97 success &= pmConceptsWriteCell(cell, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CAMERA | 98 PM_CONCEPT_SOURCE_DEFAULTS, false, NULL); 99 success &= pmHDUWrite(hdu, fits); 100 } 101 102 if (!success) { 103 psError(PS_ERR_IO, false, "Unable to write HDU for Chip.\n"); 104 return false; 105 } 106 107 // No lower levels to which to recurse 108 109 return success; 105 110 } 106 111 … … 109 114 psFits *fits, // FITS file to which to write 110 115 psDB *db, // Database handle for "concepts" update 111 bool pixels // Write the pixels? 116 bool pixels, // Write the pixels, or only the PHU header? 117 bool recurse // Recurse to lower levels? 112 118 ) 113 119 { 114 120 pmHDU *hdu = chip->hdu; // The HDU 115 if (hdu && ((!pixels && hdu->phu) || pixels)) { 116 if (pixels && !hdu->images && !pmHDUGenerateForChip(chip)) { 117 psError(PS_ERR_IO, false, "Unable to generate HDU for chip.\n"); 118 return false; 119 } 120 bool status = pmConceptsWriteChip(chip, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CAMERA | 121 PM_CONCEPT_SOURCE_DEFAULTS, false, NULL); 122 status &= pmHDUWrite(hdu, fits); 123 if (!status) { 124 psError(PS_ERR_IO, false, "Unable to write HDU for Chip.\n"); 125 return false; 126 } 121 if (!hdu) { 122 return true; // We wrote every HDU that exists 127 123 } 128 124 129 125 bool success = true; // Success of writing 130 if (pixels) { 126 if ((!pixels && hdu->phu && !hdu->images) || // Data-less PHU 127 (pixels && (hdu->images || (!hdu->images && pmHDUGenerateForChip(chip) && hdu->images)))) { // Data 128 success &= pmConceptsWriteChip(chip, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CAMERA | 129 PM_CONCEPT_SOURCE_DEFAULTS, false, NULL); 130 success &= pmHDUWrite(hdu, fits); 131 } 132 133 if (!success) { 134 psError(PS_ERR_IO, false, "Unable to write HDU for Chip.\n"); 135 return false; 136 } 137 138 if (recurse) { 131 139 psArray *cells = chip->cells; // Array of cells 132 140 for (int i = 0; i < cells->n; i++) { 133 141 pmCell *cell = cells->data[i]; // The cell of interest 134 success |= pmCellWrite(cell, fits, db, true);142 success &= pmCellWrite(cell, fits, db, pixels); 135 143 } 136 144 } … … 144 152 psFits *fits, // FITS file to which to write 145 153 psDB *db, // Database handle for "concepts" update 146 bool pixels // Write the pixels? 154 bool pixels, // Write the pixels, or only the PHU header? 155 bool recurse // Recurse to lower levels? 147 156 ) 148 157 { 149 158 pmHDU *hdu = fpa->hdu; // The HDU 150 if (hdu && ((!pixels && hdu->phu) || pixels)) { 151 if (pixels && !hdu->images && !pmHDUGenerateForFPA(fpa)) { 152 psError(PS_ERR_IO, false, "Unable to generate HDU for FPA.\n"); 153 return false; 154 } 155 bool status = pmConceptsWriteFPA(fpa, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CAMERA | 156 PM_CONCEPT_SOURCE_DEFAULTS, NULL); 157 status &= pmHDUWrite(hdu, fits); 158 if (!status) { 159 psError(PS_ERR_IO, false, "Unable to write HDU for FPA.\n"); 160 return false; 161 } 159 if (!hdu) { 160 return true; // We wrote every HDU that exists 162 161 } 163 162 164 163 bool success = true; // Success of writing 165 if (pixels) { 164 if ((!pixels && hdu->phu && !hdu->images) || // Data-less PHU 165 (pixels && (hdu->images || (!hdu->images && pmHDUGenerateForFPA(fpa) && hdu->images)))) { // Data 166 success &= pmConceptsWriteFPA(fpa, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CAMERA | 167 PM_CONCEPT_SOURCE_DEFAULTS, NULL); 168 success &= pmHDUWrite(hdu, fits); 169 } 170 171 if (!success) { 172 psError(PS_ERR_IO, false, "Unable to write HDU for FPA.\n"); 173 return false; 174 } 175 176 if (recurse) { 166 177 psArray *chips = fpa->chips; // Array of chips 167 178 for (int i = 0; i < chips->n; i++) { 168 179 pmChip *chip = chips->data[i]; // The chip of interest 169 success |= pmChipWrite(chip, fits, db, true);180 success &= pmChipWrite(chip, fits, db, pixels, true); 170 181 } 171 182 }
Note:
See TracChangeset
for help on using the changeset viewer.
