Changeset 4694 for trunk/archive/scripts/src/papFocalPlane.c
- Timestamp:
- Aug 1, 2005, 2:21:14 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/archive/scripts/src/papFocalPlane.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/archive/scripts/src/papFocalPlane.c
r4386 r4694 254 254 } 255 255 256 psMetadataItem *psCellGetValue(papFPA *fpa, // The FPA that contains the cell 257 const char *chipName, // The name of the chip 258 const char *cellName, // The name of the cell 256 psMetadataItem *psCellGetValue(papCell *cell, // The cell 259 257 const char *valueName // Name of value 260 258 ) 261 259 { 262 psTrace(__func__, 3, "Trying to retrieve %s for %s:%s...\n", valueName, chipName, cellName); 263 264 bool mdStatus = true; // Status of MD lookup 265 papChip *chip = psMetadataLookupChip(&mdStatus, fpa->chips, chipName); // The chip 266 if (!mdStatus) { 267 psError(PS_ERR_IO, false, "Unable to find chip named %s\n", chipName); 268 return NULL; 269 } 270 papCell *cell = psMetadataLookupCell(&mdStatus, chip->cells, cellName); // The cell 271 if (!mdStatus) { 272 psError(PS_ERR_IO, false, "Unable to find cell named %s in chip %s\n", cellName, chipName); 273 return NULL; 274 } 260 psTrace(__func__, 3, "Trying to retrieve %s...\n", valueName); 261 262 papChip *chip = cell->parent; // The chip 263 papFPA *fpa = chip->parent; // The FPA 275 264 276 265 // Try cache, headers, database, defaults in order … … 293 282 } 294 283 295 float psCellGetValueF32(papFPA *fpa, // The FPA that contains the cell 296 const char *chipName, // The name of the chip 297 const char *cellName, // The name of the cell 284 float psCellGetValueF32(papCell *cell, // The cell 298 285 const char *valueName // Name of value 299 286 ) 300 287 { 301 288 float value = NAN; // Result 302 psMetadataItem *item = psCellGetValue( fpa, chipName, cellName, valueName); // The item303 if (! item) { 304 psError(PS_ERR_IO, true, "Unable to find value %s in %s:%s.\n", valueName, chipName, cellName);289 psMetadataItem *item = psCellGetValue(cell, valueName); // The item 290 if (! item) { 291 psError(PS_ERR_IO, true, "Unable to find value %s in cell.\n", valueName); 305 292 } else if (item->type != PS_META_F32) { 306 psError(PS_ERR_IO, true, "Metadata item type for %s (%s:%s) is not F32.\n", valueName, chipName, 307 cellName); 293 psError(PS_ERR_IO, true, "Metadata item type for %s is not F32.\n", valueName); 308 294 } else { 309 295 value = item->data.F32; … … 313 299 } 314 300 315 int psCellGetValueS32(papFPA *fpa, // The FPA that contains the cell 316 const char *chipName, // The name of the chip 317 const char *cellName, // The name of the cell 301 int psCellGetValueS32(papCell *cell, // The cell 318 302 const char *valueName // Name of value 319 303 ) 320 304 { 321 305 int value = 0; // Result 322 psMetadataItem *item = psCellGetValue( fpa, chipName, cellName, valueName); // The item323 if (! item) { 324 psError(PS_ERR_IO, true, "Unable to find value %s in %s:%s.\n", valueName, chipName, cellName);306 psMetadataItem *item = psCellGetValue(cell, valueName); // The item 307 if (! item) { 308 psError(PS_ERR_IO, true, "Unable to find value %s.\n", valueName); 325 309 } else if (item->type != PS_META_S32) { 326 psError(PS_ERR_IO, true, "Metadata item type for %s (%s:%s) is not S32.\n", valueName, chipName, 327 cellName); 310 psError(PS_ERR_IO, true, "Metadata item type for %s is not S32.\n", valueName); 328 311 } else { 329 312 value = item->data.S32; … … 334 317 335 318 336 double psCellGetValueF64(papFPA *fpa, // The FPA that contains the cell 337 const char *chipName, // The name of the chip 338 const char *cellName, // The name of the cell 319 double psCellGetValueF64(papCell *cell, // The cell 339 320 const char *valueName // Name of value 340 321 ) 341 322 { 342 323 double value = NAN; // Result 343 psMetadataItem *item = psCellGetValue( fpa, chipName, cellName, valueName); // The item344 if (! item) { 345 psError(PS_ERR_IO, true, "Unable to find value %s in %s:%s.\n", valueName, chipName, cellName);324 psMetadataItem *item = psCellGetValue(cell, valueName); // The item 325 if (! item) { 326 psError(PS_ERR_IO, true, "Unable to find value %s.\n", valueName); 346 327 } else if (item->type != PS_META_F64) { 347 psError(PS_ERR_IO, true, "Metadata item type for %s (%s:%s) is not F64.\n", valueName, chipName, 348 cellName); 328 psError(PS_ERR_IO, true, "Metadata item type for %s is not F64.\n", valueName); 349 329 } else { 350 330 value = item->data.F64; … … 355 335 356 336 357 psString psCellGetValueString(papFPA *fpa, // The FPA that contains the cell 358 const char *chipName, // The name of the chip 359 const char *cellName, // The name of the cell 337 psString psCellGetValueString(papCell *cell, // The cell 360 338 const char *valueName // Name of value 361 339 ) 362 340 { 363 341 psString value = NULL; // Result 364 psMetadataItem *item = psCellGetValue( fpa, chipName, cellName, valueName); // The item365 if (! item) { 366 psError(PS_ERR_IO, true, "Unable to find value %s in %s:%s.\n", valueName, chipName, cellName);342 psMetadataItem *item = psCellGetValue(cell, valueName); // The item 343 if (! item) { 344 psError(PS_ERR_IO, true, "Unable to find value %s.\n", valueName); 367 345 } else if (item->type != PS_META_STR) { 368 psError(PS_ERR_IO, true, "Metadata item type for %s (%s:%s) is not STR.\n", valueName, chipName, 369 cellName); 346 psError(PS_ERR_IO, true, "Metadata item type for %s is not STR.\n", valueName); 370 347 } else { 371 348 value = item->data.V; … … 394 371 fpa->camera = psMemIncrRefCounter((psPtr)camera); 395 372 fpa->db = db; 396 fpa->chips = psMetadataAlloc(); 397 373 fpa->chips = psArrayAlloc(0); 374 375 fpa->extname = NULL; 398 376 fpa->pixels = NULL; 399 377 fpa->header = NULL; … … 418 396 419 397 papChip *papChipAlloc(papFPA *fpa, // FPA to which the chip belongs 420 const char *name // Name of the chip398 psString name // Chip name 421 399 ) 422 400 { … … 424 402 psMemSetDeallocator(chip, (psFreeFcn)p_papChipFree); 425 403 426 // Push onto the FPA427 psMetadataAdd(fpa->chips, PS_LIST_TAIL, name, PS_META_CHIP, "Chip added on allocation", chip);404 // Push onto the array of chips 405 fpa->chips = psArrayAdd(fpa->chips, 0, chip); 428 406 429 407 // Fill in the components … … 435 413 436 414 chip->values = psMetadataAlloc(); 437 chip->cells = psMetadataAlloc(); 438 415 chip->parent = psMemIncrRefCounter(fpa); 416 chip->cells = psArrayAlloc(0); 417 418 chip->extname = NULL; 439 419 chip->pixels = NULL; 440 420 chip->header = NULL; 441 421 442 psMetadataAdd(chip->values, PS_LIST_TAIL, "CHIP.NAME", PS_META_STR, "Name of the chip", 443 psStringCopy(name)); 422 psMetadataAddStr(chip->values, PS_LIST_HEAD, "CHIP.NAME", "Chip name added at papChipAlloc", name); 444 423 445 424 return chip; … … 453 432 psFree(chip->values); 454 433 psFree(chip->cells); 434 psFree(chip->parent); 455 435 456 436 psFree(chip->pixels); … … 459 439 460 440 papCell *papCellAlloc(papChip *chip, // Chip to which the cell belongs 461 const char *name, // Name of the cell 462 int nReadouts // Number of readouts contained 441 psString name // Name of cell 463 442 ) 464 443 { … … 466 445 psMemSetDeallocator(cell, (psFreeFcn)p_papCellFree); 467 446 468 // Push onto the chip469 psMetadataAdd(chip->cells, PS_LIST_TAIL, name, PS_META_CELL, "Cell added on allocation", cell);447 // Push onto the array of chips 448 chip->cells = psArrayAdd(chip->cells, 0, cell); 470 449 471 450 // Fill in components … … 480 459 481 460 cell->values = psMetadataAlloc(); 482 cell->readouts = psArrayAlloc(nReadouts); 483 461 cell->readouts = psArrayAlloc(0); 462 cell->parent = psMemIncrRefCounter(chip); 463 464 cell->extname = NULL; 484 465 cell->pixels = NULL; 485 466 cell->header = NULL; 486 467 487 psMetadataAdd(cell->values, PS_LIST_TAIL, "CELL.NAME", PS_META_STR, "Name of the cell", 488 psStringCopy(name)); 468 psMetadataAddStr(cell->values, PS_LIST_HEAD, "CELL.NAME", "Cell name added at papCellAlloc", name); 489 469 490 470 return cell; … … 501 481 psFree(cell->values); 502 482 psFree(cell->readouts); 483 psFree(cell->parent); 503 484 504 485 psFree(cell->pixels);
Note:
See TracChangeset
for help on using the changeset viewer.
