Changeset 5104 for trunk/archive/scripts/src/phase2/pmFPAConstruct.c
- Timestamp:
- Sep 22, 2005, 4:54:52 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/archive/scripts/src/phase2/pmFPAConstruct.c
r4820 r5104 30 30 psError(PS_ERR_IO, false, "Unable to find specs for cell %s: ignored\n", cellName); 31 31 } 32 33 #if 0 34 // Need to create a new instance, so that each cell can work with its own 35 psMetadata *copy = psMetadataAlloc(); 36 psMetadataIterator *iter = psMetadataIteratorAlloc(cellData, PS_LIST_HEAD, NULL); // Iterator 37 psMetadataItem *item = NULL; // Item from iteration 38 while (item = psMetadataGetAndIncrement(iter)) { 39 if (item->type == PS_META_MULTI || item->type == PS_META_META) { 40 psLogMsg(__func__, PS_LOG_WARN, "PS_META_MULTI and PS_META_META are not supported in a cell " 41 "definition --- %s ignored.\n", item->name); 42 continue; 43 } 44 if (! psMetadataAdd(copy, PS_LIST_TAIL, item->name, item->type, item->comment, item->data.V)) { 45 psAbort(__func__, "Should never reach here!\n"); 46 } 47 } 48 psFree(iter); 49 50 return copy; 51 #else 32 52 return cellData; 53 #endif 54 33 55 } 34 56 … … 38 60 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 39 61 40 pmFPA *pmFPAConstruct(const psMetadata *camera, // The camera configuration 41 psDB *db // Database handle 62 pmFPA *pmFPAConstruct(const psMetadata *camera // The camera configuration 42 63 ) 43 64 { 44 pmFPA *fpa = pmFPAAlloc(camera , db); // The FPA to fill out65 pmFPA *fpa = pmFPAAlloc(camera); // The FPA to fill out 45 66 bool mdStatus = true; // Status from metadata lookups 46 67 const char *phuType = psMetadataLookupString(&mdStatus, camera, "PHU"); // What is the PHU? … … 67 88 psString extName = contentItem->name; // The name of the extension 68 89 pmChip *chip = pmChipAlloc(fpa, extName); // The chip 69 chip-> extname = extName;// Markchip to receive FITS data90 chip->private = p_pmHDUAlloc(extName); // Prepare chip to receive FITS data 70 91 if (contentItem->type != PS_META_STR) { 71 92 psLogMsg(__func__, PS_LOG_WARN, "Type of content item (%x) is not string: ignored\n", … … 83 104 psMetadata *cellData = getCellData(camera, cellName); 84 105 pmCell *cell = pmCellAlloc(chip, cellData, cellName); // The cell 106 // psFree(cellData); 85 107 } 86 108 psFree(cellNamesIter); … … 102 124 const char *content = contentItem->data.V; // The content of the extension 103 125 psList *contents = papSplit(content, ": "); // Split the name from the type 104 if (contents-> size!= 2) {126 if (contents->n != 2) { 105 127 psLogMsg(__func__, PS_LOG_WARN, "Unable to read contents of %s: ignored.\n", extName); 106 128 } else { … … 123 145 psMetadata *cellData = getCellData(camera, cellType); 124 146 pmCell *cell = pmCellAlloc(chip, cellData, extName); // The cell 125 cell->extname = extName; // Mark cell to receive FITS data 147 // psFree(cellData); 148 cell->private = p_pmHDUAlloc(extName); // Prepare cell to receive FITS data 126 149 127 150 psFree(chip); 128 151 psFree(cell); 129 psFree(chipName);130 psFree(cellType);131 152 } 132 153 psFree(contents); … … 136 157 } else if (strcasecmp(extType, "NONE") == 0) { 137 158 // No extensions; Content contains metadata, each entry is a chip with its component cells 138 fpa-> extname = "PHU";159 fpa->private = p_pmHDUAlloc("PHU"); // Prepare FPA to receive FITS data 139 160 while (contentItem = psMetadataGetAndIncrement(contentsIter)) { 140 161 psString chipName = contentItem->name; // The name of the chip … … 155 176 psMetadata *cellData = getCellData(camera, cellName); 156 177 pmCell *cell = pmCellAlloc(chip, cellData, cellName); // The cell 178 // psFree(cellData); 157 179 } 158 180 psFree(cellNamesIter); … … 174 196 if (strcasecmp(extType, "NONE") == 0) { 175 197 // There are no extensions --- only the PHU 176 chip-> extname = "PHU";198 chip->private = p_pmHDUAlloc("PHU"); 177 199 178 200 const char *contents = psMetadataLookupString(&mdStatus, camera, "CONTENTS"); … … 188 210 psMetadata *cellData = getCellData(camera, cellName); 189 211 pmCell *cell = pmCellAlloc(chip, cellData, cellName); // The cell 212 // psFree(cellData); 190 213 } 191 214 psFree(cellIter); … … 223 246 psMetadata *cellData = getCellData(camera, cellType); 224 247 pmCell *cell = pmCellAlloc(chip, cellData, extName); // The cell 225 cell->extname = extName; // Mark cell to receive FITS data 248 // psFree(cellData); 249 cell->private = p_pmHDUAlloc(extName); // Prepare cell to receive FITS data 226 250 } // Iterating through contents 227 251 psFree(contentsIter); … … 249 273 { 250 274 psTrace(__func__, 0, "FPA:\n"); 251 if (fpa-> extname) {252 psTrace(__func__, 1, "---> FPA is extension %s.\n", fpa-> extname);253 if (! fpa->p ixels) {254 psTrace(__func__, 1, "---> NO PIXELS for extension %s\n", fpa-> extname);275 if (fpa->private) { 276 psTrace(__func__, 1, "---> FPA is extension %s.\n", fpa->private->extname); 277 if (! fpa->private->pixels) { 278 psTrace(__func__, 1, "---> NO PIXELS for extension %s\n", fpa->private->extname); 255 279 } 256 280 } … … 261 285 psTrace(__func__, 1, "Chip: %d\n", i); 262 286 pmChip *chip = chips->data[i]; // The chip 263 if (chip-> extname) {264 psTrace(__func__, 2, "---> Chip is extension %s.\n", chip-> extname);265 if (! chip->p ixels) {266 psTrace(__func__, 2, "---> NO PIXELS for extension %s\n", chip-> extname);287 if (chip->private) { 288 psTrace(__func__, 2, "---> Chip is extension %s.\n", chip->private->extname); 289 if (! chip->private->pixels) { 290 psTrace(__func__, 2, "---> NO PIXELS for extension %s\n", chip->private->extname); 267 291 } 268 292 } … … 272 296 psTrace(__func__, 2, "Cell: %d\n", j); 273 297 pmCell *cell = cells->data[j]; // The cell 274 if (cell-> extname) {275 psTrace(__func__, 3, "---> Cell is extension %s.\n", cell-> extname);276 if (! cell->p ixels) {277 psTrace(__func__, 3, "---> NO PIXELS for extension %s\n", cell-> extname);278 } 279 } 280 psMetadataPrint(cell-> values, 3);298 if (cell->private) { 299 psTrace(__func__, 3, "---> Cell is extension %s.\n", cell->private->extname); 300 if (! cell->private->pixels) { 301 psTrace(__func__, 3, "---> NO PIXELS for extension %s\n", cell->private->extname); 302 } 303 } 304 psMetadataPrint(cell->concepts, 3); 281 305 psTrace(__func__, 3, "Readouts:\n"); 282 306 psArray *readouts = cell->readouts; // Array of readouts
Note:
See TracChangeset
for help on using the changeset viewer.
