Changeset 6970
- Timestamp:
- Apr 24, 2006, 2:22:25 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/astrom/pmFPA.c (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/astrom/pmFPA.c
r6930 r6970 12 12 * XXX: Should we implement non-linear cell->chip transforms? 13 13 * 14 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $15 * @date $Date: 2006-04-2 0 22:30:33$14 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2006-04-25 00:22:25 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 33 33 /****************************************************************************** 34 34 *****************************************************************************/ 35 #define PS_FREE_HIERARCHY 136 #define PARENT_LINKS 037 35 38 36 static void readoutFree(pmReadout *readout) 39 37 { 40 psTrace(__func__, 9, "Removing readout %lx from cell %lx...\n", (size_t) readout, (size_t)readout->parent);38 psTrace(__func__, 9, "Removing readout %lx from cell %lx...\n", (size_t)readout, (size_t)readout->parent); 41 39 if (readout->parent) { 42 40 psArray *readouts = readout->parent->readouts; 43 41 for (int i = 0; i < readouts->n; i++) { 44 42 if (readouts->data[i] == readout) { 45 // pmReadout *tmpReadout = readouts->data[i];46 43 readouts->data[i] = NULL; 47 #if PARENT_LINKS48 49 psFree(tmpReadout);50 #endif51 52 break;53 44 } 54 45 } 55 46 } 56 47 psTrace(__func__, 9, "Freeing readout %lx\n", (size_t) readout); 57 58 #if PARENT_LINKS59 60 psFree(readout->parent);61 #endif62 63 48 psFree(readout->image); 64 49 psFree(readout->mask); … … 75 60 for (int i = 0; i < cells->n; i++) { 76 61 if (cells->data[i] == cell) { 77 // pmCell *tmpCell = cells->data[i];78 62 cells->data[i] = NULL; 79 #if PARENT_LINKS80 81 psFree(tmpCell);82 #endif83 84 break;85 63 } 86 64 } 87 65 } 88 66 psTrace(__func__, 9, "Freeing cell %lx\n", (size_t)cell); 89 90 67 pmCellFreeReadouts(cell); 91 68 psFree(cell->readouts); 92 #if PARENT_LINKS93 94 psFree(cell->parent);95 #endif96 69 97 70 psFree(cell->concepts); … … 108 81 for (int i = 0; i < chips->n; i++) { 109 82 if (chips->data[i] == chip) { 110 // pmChip *tmpChip = chips->data[i];111 83 chips->data[i] = NULL; 112 #if PARENT_LINKS113 114 psFree(tmpChip);115 #endif116 117 break;118 84 } 119 85 } 120 86 } 121 87 psTrace(__func__, 9, "Freeing chip %lx\n", (size_t)chip); 122 123 88 pmChipFreeCells(chip); 124 89 psFree(chip->cells); 125 #if PARENT_LINKS126 127 psFree(chip->parent);128 #endif129 130 #if 0131 132 psFree(chip->toFPA);133 psFree(chip->fromFPA);134 #endif135 90 136 91 psFree(chip->concepts); 137 92 psFree(chip->analysis); 138 93 psFree(chip->hdu); 94 psFree(chip->mosaic); 139 95 } 140 96 … … 143 99 { 144 100 psTrace(__func__, 9, "Freeing fpa %lx\n", (size_t)fpa); 145 #if 0146 147 psFree(fpa->fromTangentPlane);148 psFree(fpa->toTangentPlane);149 psFree(fpa->projection);150 #endif151 152 psFree(fpa->concepts);153 psFree(fpa->analysis);154 psFree(fpa->camera);155 //156 // Set the parent to NULL in all fpa->chips before psFree(fpa->chips)157 // in order to avoid memory reference counter problems.158 //159 101 psArray *chips = fpa->chips; 160 102 for (psS32 i = 0 ; i < chips->n ; i++) { … … 165 107 chips->data[i] = NULL; 166 108 tmpChip->parent = NULL; 167 if (PS_FREE_HIERARCHY == 1) {168 psFree(tmpChip);169 }170 109 } 171 110 psFree(fpa->chips); 111 psFree(fpa->concepts); 112 psFree(fpa->analysis); 113 psFree(fpa->camera); 172 114 psFree(fpa->hdu); 173 115 } … … 189 131 psTrace(__func__, 9, "Will now free readout %lx...\n", (size_t)tmpReadout); 190 132 psFree(tmpReadout); // Drop the readout 191 #if PARENT_LINKS192 193 psFree(cell); // Decrement reference counter on cell, since readout->parent isn't held any more194 #endif195 196 133 } 197 134 cell->readouts = psArrayRealloc(cell->readouts, 0); … … 216 153 pmCellFreeReadouts(tmpCell);// Drop all readouts the cell holds 217 154 psFree(tmpCell); // Drop the cell 218 #if PARENT_LINKS219 220 psFree(chip); // Decrement reference counter on chip, since cell->parent isn't held any more221 #endif222 223 155 } 224 156 chip->cells = psArrayRealloc(chip->cells, 0); … … 230 162 { 231 163 pmReadout *tmpReadout = (pmReadout *) psAlloc(sizeof(pmReadout)); 232 tmpReadout->row0 = 0; 233 tmpReadout->col0 = 0; 164 psMemSetDeallocator(tmpReadout, (psFreeFunc) readoutFree); 234 165 235 166 tmpReadout->image = NULL; … … 238 169 tmpReadout->bias = psListAlloc(NULL); 239 170 tmpReadout->analysis = psMetadataAlloc(); 240 #if PARENT_LINKS241 242 tmpReadout->parent = psMemIncrRefCounter(cell);243 #else244 245 171 tmpReadout->parent = cell; 246 #endif247 248 172 if (cell != NULL) { 249 173 cell->readouts = psArrayAdd(cell->readouts, 1, (psPtr) tmpReadout); … … 254 178 tmpReadout->data_exists = false; // data yet read in 255 179 256 psMemSetDeallocator(tmpReadout, (psFreeFunc) readoutFree); 180 tmpReadout->row0 = 0; 181 tmpReadout->col0 = 0; 182 257 183 return(tmpReadout); 258 184 } 259 185 260 // XXX: Verify these default values for row0, col0.261 // PAP: These values may disappear in the future in favour of values in the "concepts"?262 186 pmCell *pmCellAlloc( 263 187 pmChip *chip, 264 const char *name) 188 const char *name 189 ) 265 190 { 266 191 pmCell *tmpCell = (pmCell *) psAlloc(sizeof(pmCell)); 267 268 tmpCell->concepts = psMetadataAlloc(); 269 tmpCell->conceptsRead = PM_CONCEPT_SOURCE_NONE; 270 psBool rc = psMetadataAddStr(tmpCell->concepts, PS_LIST_HEAD, "CELL.NAME", 0, NULL, name); 271 if (rc == false) { 272 psLogMsg(__func__, PS_LOG_WARN, "WARNING: Could not add CELL.NAME to metadata.\n"); 273 } 192 psMemSetDeallocator(tmpCell, (psFreeFunc) cellFree); 193 274 194 tmpCell->config = NULL; 275 195 tmpCell->analysis = psMetadataAlloc(); 276 196 tmpCell->readouts = psArrayAlloc(0); 277 #if PARENT_LINKS278 279 tmpCell->parent = psMemIncrRefCounter(chip);280 #else281 282 197 tmpCell->parent = chip; 283 #endif284 285 198 if (chip != NULL) { 286 199 chip->cells = psArrayAdd(chip->cells, 1, (psPtr) tmpCell); 287 200 } 201 tmpCell->hdu = NULL; 288 202 tmpCell->process = true; // All cells are processed by default 289 203 tmpCell->file_exists = false; // Not yet identified 290 204 tmpCell->data_exists = false; // Not yet read in 291 tmpCell->hdu = NULL; 292 205 206 tmpCell->concepts = psMetadataAlloc(); 207 tmpCell->conceptsRead = PM_CONCEPT_SOURCE_NONE; 208 if (!psMetadataAddStr(tmpCell->concepts, PS_LIST_HEAD, "CELL.NAME", 0, NULL, name)) { 209 psLogMsg(__func__, PS_LOG_WARN, "WARNING: Could not add CELL.NAME to metadata.\n"); 210 } 293 211 pmConceptsBlankCell(tmpCell); 294 212 295 psMemSetDeallocator(tmpCell, (psFreeFunc) cellFree);296 213 return(tmpCell); 297 214 } 298 215 299 // XXX: Verify these default values for row0, col0.300 // PAP: row0, col0 may disappear in the future in favour of storing values in the "concepts".301 216 pmChip *pmChipAlloc( 302 217 pmFPA *fpa, … … 304 219 { 305 220 pmChip *tmpChip = (pmChip *) psAlloc(sizeof(pmChip)); 306 307 #if 0 308 309 tmpChip->col0 = 0; 310 tmpChip->row0 = 0; 311 tmpChip->toFPA = NULL; 312 tmpChip->fromFPA = NULL; 313 #endif 314 315 tmpChip->concepts = psMetadataAlloc(); 316 tmpChip->conceptsRead = PM_CONCEPT_SOURCE_NONE; 317 psBool rc = psMetadataAddStr(tmpChip->concepts, PS_LIST_HEAD, "CHIP.NAME", 0, NULL, name); 318 if (rc == false) { 319 psLogMsg(__func__, PS_LOG_WARN, "WARNING: Could not add CHIP.NAME to metadata.\n"); 320 } 221 psMemSetDeallocator(tmpChip, (psFreeFunc) chipFree); 222 321 223 tmpChip->analysis = psMetadataAlloc(); 322 224 tmpChip->cells = psArrayAlloc(0); 323 #if PARENT_LINKS324 325 tmpChip->parent = psMemIncrRefCounter(fpa);326 #else327 328 225 tmpChip->parent = fpa; 329 #endif330 331 226 if (fpa != NULL) { 332 227 fpa->chips = psArrayAdd(fpa->chips, 1, (psPtr) tmpChip); 333 228 } 229 tmpChip->hdu = NULL; 230 tmpChip->mosaic = NULL; 334 231 tmpChip->process = true; // Work on all chips, by default 335 232 tmpChip->file_exists = false; // Not yet identified 336 233 tmpChip->data_exists = false; // Not yet read in 337 tmpChip->hdu = NULL; 338 234 235 if (!psMetadataAddStr(tmpChip->concepts, PS_LIST_HEAD, "CHIP.NAME", 0, NULL, name)) { 236 psLogMsg(__func__, PS_LOG_WARN, "WARNING: Could not add CHIP.NAME %s to concepts.\n", name); 237 } 238 tmpChip->concepts = psMetadataAlloc(); 239 tmpChip->conceptsRead = PM_CONCEPT_SOURCE_NONE; 339 240 pmConceptsBlankChip(tmpChip); 340 241 341 psMemSetDeallocator(tmpChip, (psFreeFunc) chipFree);342 242 return(tmpChip); 343 243 } … … 346 246 { 347 247 pmFPA *tmpFPA = (pmFPA *) psAlloc(sizeof(pmFPA)); 348 349 #if 0 350 351 tmpFPA->fromTangentPlane = NULL; 352 tmpFPA->toTangentPlane = NULL; 353 tmpFPA->projection = NULL; 354 #endif 355 356 tmpFPA->concepts = psMetadataAlloc(); 357 tmpFPA->conceptsRead = PM_CONCEPT_SOURCE_NONE; 248 psMemSetDeallocator(tmpFPA, (psFreeFunc) FPAFree); 249 358 250 tmpFPA->analysis = NULL; 359 251 tmpFPA->camera = psMemIncrRefCounter((psPtr)camera); … … 361 253 tmpFPA->hdu = NULL; 362 254 255 tmpFPA->concepts = psMetadataAlloc(); 256 tmpFPA->conceptsRead = PM_CONCEPT_SOURCE_NONE; 363 257 pmConceptsBlankFPA(tmpFPA); 364 258 365 psMemSetDeallocator(tmpFPA, (psFreeFunc) FPAFree);366 259 return(tmpFPA); 367 260 } … … 369 262 static psBool cellCheckParents(pmCell *cell) 370 263 { 371 if ( cell == NULL) {264 if (!cell) { 372 265 return(true); 373 266 } … … 387 280 static psBool chipCheckParents(pmChip *chip) 388 281 { 389 if ( chip == NULL) {282 if (!chip) { 390 283 return(true); 391 284 } … … 407 300 psBool pmFPACheckParents(pmFPA *fpa) 408 301 { 409 if ( fpa == NULL) {302 if (!fpa) { 410 303 return(true); 411 304 }
Note:
See TracChangeset
for help on using the changeset viewer.
