Changeset 15987 for trunk/psModules/test/camera/tap_pmFPAHeader.c
- Timestamp:
- Jan 2, 2008, 10:53:30 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/test/camera/tap_pmFPAHeader.c (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/test/camera/tap_pmFPAHeader.c
r14882 r15987 5 5 #include "tap.h" 6 6 #include "pstap.h" 7 // XXX: Use better name for the temporary FITS file 8 // XXX: The code to generate and free the FPA hierarchy was copied from 9 // tap-pmFPA.c. EIther include it directly, or library, or something. 10 // Also, get rid of the manual free functions and use psFree() once 11 // it correctly frees child members 12 // XXX: For the genSimpleFPA() code, add IDs to each function so that 13 // the values set in each chip-?cell-?hdu-?image are unique 14 // XXX: For the genSimpleFPA() code, write masks and weights as well 7 /* STATUS: 8 All functions are tested. 9 */ 15 10 16 11 #define CHIP_ALLOC_NAME "ChipName" … … 84 79 cell->hdu = pmHDUAlloc(extname); 85 80 for (int i = 0 ; i < NUM_READOUTS ; i++) { 86 cell->readouts->data[i] = generateSimpleReadout(cell); 87 } 88 89 bool rc = pmConfigFileRead(&cell->hdu->format, "data/camera0/format0.config", "Camera format 0"); 81 cell->readouts->data[i] = psMemDecrRefCounter((psPtr) generateSimpleReadout(cell)); 82 } 83 84 // First try to read data from ../dataFiles, then try dataFiles. 85 bool rc = pmConfigFileRead(&cell->hdu->format, "../dataFiles/camera0/format0.config", "Camera format 0"); 90 86 if (!rc) { 91 diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())"); 87 rc = pmConfigFileRead(&cell->hdu->format, "dataFiles/camera0/format0.config", "Camera format 0"); 88 if (!rc) { 89 diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())"); 90 } 92 91 } 93 92 … … 104 103 } 105 104 106 //XXX: Should the region be set some other way? Like through the various config files?107 // psRegion *region = psRegionAlloc(0.0, TEST_NUM_COLS-1, 0.0, TEST_NUM_ROWS-1);108 105 psRegion *region = psRegionAlloc(0.0, 0.0, 0.0, 0.0); 109 // You shouldn't have to remove the key from the metadata. Find out how to simply change the key value.106 // You shouldn't have to remove the key from the metadata. 110 107 psMetadataRemoveKey(cell->concepts, "CELL.TRIMSEC"); 111 108 psMetadataAddPtr(cell->concepts, PS_LIST_TAIL|PS_META_REPLACE, "CELL.TRIMSEC", PS_DATA_REGION, "I am a region", region); … … 134 131 psArrayRealloc(chip->cells, NUM_CELLS); 135 132 for (int i = 0 ; i < NUM_CELLS ; i++) { 136 chip->cells->data[i] = generateSimpleCell(chip, i); 137 } 138 139 // XXX: Add code to initialize chip pmConcepts 140 141 133 chip->cells->data[i] = psMemDecrRefCounter((psPtr) generateSimpleCell(chip, i)); 134 } 142 135 return(chip); 143 136 } … … 156 149 psMetadataAddS32((psMetadata *) fpa->camera, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM); 157 150 psMetadataAddS32(fpa->concepts, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM); 158 // fpa->hdu = pmHDUAlloc("fpaExtName");159 //160 // bool rc = pmConfigFileRead(&fpa->hdu->format, "data/camera0/format0.config", "Camera format 0");161 // if (!rc) {162 // diag("pmConfigFileRead() was unsuccessful (from generateSimpleFPA())");163 // }164 151 165 152 psArrayRealloc(fpa->chips, NUM_CHIPS); 166 153 for (int i = 0 ; i < NUM_CHIPS ; i++) { 167 fpa->chips->data[i] = generateSimpleChip(fpa, i); 168 } 169 170 // XXX: Eventually, when you finish the pmConcepts tests, add full concept 171 // reading code from wherever. 154 fpa->chips->data[i] = psMemDecrRefCounter((psPtr) generateSimpleChip(fpa, i)); 155 } 172 156 pmConceptsBlankFPA(fpa); 173 // bool mdok;174 // psMetadata *fileData = psMetadataLookupMetadata(&mdok, fpa->hdu->format, "FILE");175 // char *fpaNameHdr = psMetadataLookupStr(&mdok, fileData, "FPA.NAME");176 // psMetadataAddStr(fpa->concepts, PS_LIST_TAIL, "FPA.NAME", PS_META_REPLACE, NULL, fpaNameHdr);177 178 157 return(fpa); 179 158 } 180 159 181 // XXX: This should only be necessary until the psFree() functions for182 // FPA/chip/cell/readout correctly free all child chips/cells/readouts183 void myFreeCell(pmCell *cell)184 {185 for (int k = 0 ; k < cell->readouts->n ; k++) {186 psFree(cell->readouts->data[k]);187 }188 psFree(cell);189 }190 191 void myFreeChip(pmChip *chip) {192 for (int j = 0 ; j < chip->cells->n ; j++) {193 myFreeCell(chip->cells->data[j]);194 }195 psFree(chip);196 }197 198 void myFreeFPA(pmFPA *fpa)199 {200 for (int i = 0 ; i < fpa->chips->n ; i++) {201 myFreeChip(fpa->chips->data[i]);202 }203 psFree(fpa);204 }205 160 206 161 … … 210 165 psLogSetLevel(PS_LOG_INFO); 211 166 psTraceSetLevel("err", ERR_TRACE_LEVEL); 212 plan_tests( 25);167 plan_tests(75); 213 168 214 169 … … 225 180 ok(cell != NULL, "Allocated a pmCell successfully"); 226 181 ok(!pmCellReadHeader(cell, NULL), "pmCellReadHeader(cell, NULL) returned FALSE"); 227 myFreeFPA(fpa);182 psFree(fpa); 228 183 psFree(camera); 229 184 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 245 200 { 246 201 psMemId id = psMemGetId(); 247 248 202 // Create a FITS file for this test 249 203 psFits* fitsFileW = psFitsOpen(fitsFilename, "w"); … … 264 218 psMetadataAdd(hdu->header, PS_LIST_TAIL, "MYSTR", PS_DATA_STRING, 265 219 "String Item", extname); 266 bool rc = pmConfigFileRead(&hdu->format, "data/camera0/format0.config", "Camera 0 Config Format"); 220 bool rc = pmConfigFileRead(&hdu->format, "../dataFiles/camera0/format0.config", "Camera 0 Config Format"); 221 if (!rc) { 222 rc = pmConfigFileRead(&hdu->format, "dataFiles/camera0/format0.config", "Camera 0 Config Format"); 223 } 267 224 ok(rc == true, "pmConfigFileRead() was successful"); 268 225 rc = pmHDUWrite(hdu, fitsFileW); … … 289 246 // elsewhere. However, if we should test it, test it here. 290 247 291 myFreeFPA(fpa);248 psFree(fpa); 292 249 psFree(camera); 293 250 psFree(fitsFileR); … … 308 265 ok(cell != NULL, "Allocated a pmCell successfully"); 309 266 ok(!pmChipReadHeader(chip, NULL), "pmChipReadHeader(chip, NULL) returned FALSE"); 310 myFreeFPA(fpa);267 psFree(fpa); 311 268 psFree(camera); 312 269 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 347 304 psMetadataAdd(hdu->header, PS_LIST_TAIL, "MYSTR", PS_DATA_STRING, 348 305 "String Item", extname); 349 bool rc = pmConfigFileRead(&hdu->format, "data/camera0/format0.config", "Camera 0 Config Format"); 306 bool rc = pmConfigFileRead(&hdu->format, "../dataFiles/camera0/format0.config", "Camera 0 Config Format"); 307 if (!rc) { 308 rc = pmConfigFileRead(&hdu->format, "dataFiles/camera0/format0.config", "Camera 0 Config Format"); 309 } 350 310 ok(rc == true, "pmConfigFileRead() was successful"); 351 311 rc = pmHDUWrite(hdu, fitsFileW); … … 382 342 // elsewhere. However, if we should test it, test it here. 383 343 384 myFreeFPA(fpa);344 psFree(fpa); 385 345 psFree(camera); 386 346 psFree(fitsFileR); … … 401 361 ok(cell != NULL, "Allocated a pmCell successfully"); 402 362 ok(!pmFPAReadHeader(fpa, NULL), "pmFPAReadHeader(fpa, NULL) returned FALSE"); 403 myFreeFPA(fpa);363 psFree(fpa); 404 364 psFree(camera); 405 365 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 440 400 psMetadataAdd(hdu->header, PS_LIST_TAIL, "MYSTR", PS_DATA_STRING, 441 401 "String Item", extname); 442 bool rc = pmConfigFileRead(&hdu->format, "data/camera0/format0.config", "Camera 0 Config Format"); 402 bool rc = pmConfigFileRead(&hdu->format, "../dataFiles/camera0/format0.config", "Camera 0 Config Format"); 403 if (!rc) { 404 rc = pmConfigFileRead(&hdu->format, "dataFiles/camera0/format0.config", "Camera 0 Config Format"); 405 } 443 406 ok(rc == true, "pmConfigFileRead() was successful"); 444 407 rc = pmHDUWrite(hdu, fitsFileW); … … 476 439 // elsewhere. However, if we should test it, test it here. 477 440 478 myFreeFPA(fpa);441 psFree(fpa); 479 442 psFree(camera); 480 443 psFree(fitsFileR); 481 444 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 482 445 } 483 484 485 486 487 } 488 446 } 447
Note:
See TracChangeset
for help on using the changeset viewer.
