Changeset 9584 for trunk/psModules/src/camera/pmFPA.c
- Timestamp:
- Oct 16, 2006, 2:33:57 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/camera/pmFPA.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPA.c
r8815 r9584 12 12 * XXX: Should we implement non-linear cell->chip transforms? 13 13 * 14 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $15 * @date $Date: 2006- 09-15 09:49:01$14 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2006-10-17 00:33:56 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 101 101 psFree(chip->analysis); 102 102 psFree(chip->hdu); 103 psFree(chip->mosaic);104 103 105 104 # if FPA_ASTROM … … 322 321 tmpChip->toFPA = NULL; 323 322 tmpChip->fromFPA = NULL; 324 # endif323 #endif 325 324 326 325 tmpChip->analysis = psMetadataAlloc(); … … 331 330 } 332 331 tmpChip->hdu = NULL; 333 tmpChip->mosaic = NULL;334 332 tmpChip->process = true; // Work on all chips, by default 335 333 tmpChip->file_exists = false; // Not yet identified … … 355 353 tmpFPA->toTangentPlane = NULL; 356 354 tmpFPA->projection = NULL; 357 # endif355 #endif 358 356 359 357 tmpFPA->analysis = NULL; … … 369 367 } 370 368 371 static bool cellCheckParents(pmCell *cell) 369 // Check a cell to ensure that all component readouts have the parent pointer set correctly 370 static bool cellCheckParents(pmCell *cell // Cell to check 371 ) 372 372 { 373 373 PS_ASSERT_PTR_NON_NULL(cell, true); … … 387 387 } 388 388 389 static bool chipCheckParents(pmChip *chip) 389 // Check a chip to ensure that all component cells have the parent pointer set correctly 390 static bool chipCheckParents(pmChip *chip // Chip to check 391 ) 390 392 { 391 393 PS_ASSERT_PTR_NON_NULL(chip, true); … … 393 395 bool flag = true; 394 396 for (long i = 0; i < chip->cells->n ; i++) { 395 pmCell *tmpCell = (pmCell *)chip->cells->data[i];397 pmCell *tmpCell = (pmCell*)chip->cells->data[i]; 396 398 if (!tmpCell) { 397 399 continue; … … 413 415 bool flag = true; 414 416 for (long i = 0; i < fpa->chips->n ; i++) { 415 pmChip *tmpChip = (pmChip *)fpa->chips->data[i];417 pmChip *tmpChip = (pmChip*)fpa->chips->data[i]; 416 418 if (!tmpChip) { 417 419 continue; … … 426 428 return flag; 427 429 } 428 429 /** functions to turn on/off the file_exists flag **/430 bool pmFPASetFileStatus(pmFPA *fpa, bool status)431 {432 PS_ASSERT_PTR_NON_NULL(fpa, false);433 434 for (int i = 0; i < fpa->chips->n; i++) {435 pmChip *chip = fpa->chips->data[i];436 pmChipSetFileStatus (chip, status);437 }438 return true;439 }440 441 bool pmChipSetFileStatus(pmChip *chip, bool status)442 {443 PS_ASSERT_PTR_NON_NULL(chip, false);444 445 chip->file_exists = status;446 for (int i = 0; i < chip->cells->n; i++) {447 pmCell *cell = chip->cells->data[i];448 pmCellSetFileStatus (cell, status);449 }450 return true;451 }452 453 bool pmCellSetFileStatus(pmCell *cell, bool status)454 {455 PS_ASSERT_PTR_NON_NULL(cell, false);456 457 cell->file_exists = status;458 for (int i = 0; i < cell->readouts->n; i++) {459 pmReadout *readout = cell->readouts->data[i];460 readout->file_exists = status;461 }462 return true;463 }464 465 bool pmFPACheckFileStatus(const pmFPA *fpa)466 {467 PS_ASSERT_PTR_NON_NULL(fpa, false);468 469 for (int i = 0; i < fpa->chips->n; i++) {470 pmChip *chip = fpa->chips->data[i];471 if (!pmChipCheckFileStatus(chip)) {472 return false;473 }474 }475 return true;476 }477 478 bool pmChipCheckFileStatus(const pmChip *chip)479 {480 PS_ASSERT_PTR_NON_NULL(chip, false);481 if (!chip->file_exists) {482 return false;483 }484 485 for (int i = 0; i < chip->cells->n; i++) {486 pmCell *cell = chip->cells->data[i];487 if (!pmCellCheckFileStatus(cell)) {488 return false;489 }490 }491 return true;492 }493 494 bool pmCellCheckFileStatus(const pmCell *cell)495 {496 PS_ASSERT_PTR_NON_NULL(cell, false);497 if (!cell->file_exists) {498 return false;499 }500 501 for (int i = 0; i < cell->readouts->n; i++) {502 pmReadout *readout = cell->readouts->data[i];503 if (!readout->file_exists) {504 return false;505 }506 }507 return true;508 }509 510 /** functions to turn on/off the data_exists flag **/511 bool pmFPASetDataStatus(pmFPA *fpa, bool status)512 {513 PS_ASSERT_PTR_NON_NULL(fpa, false);514 515 for (int i = 0; i < fpa->chips->n; i++) {516 pmChip *chip = fpa->chips->data[i];517 pmChipSetDataStatus (chip, status);518 }519 return true;520 }521 522 bool pmChipSetDataStatus(pmChip *chip, bool status)523 {524 PS_ASSERT_PTR_NON_NULL(chip, false);525 526 chip->data_exists = status;527 for (int i = 0; i < chip->cells->n; i++) {528 pmCell *cell = chip->cells->data[i];529 pmCellSetDataStatus (cell, status);530 }531 return true;532 }533 534 bool pmCellSetDataStatus (pmCell *cell, bool status)535 {536 PS_ASSERT_PTR_NON_NULL(cell, false);537 538 cell->data_exists = status;539 for (int i = 0; i < cell->readouts->n; i++) {540 pmReadout *readout = cell->readouts->data[i];541 readout->data_exists = status;542 }543 return true;544 }545 546 /*****************************************************************************547 *****************************************************************************/548 549 // Set cells within a chip to be processed or not550 static bool setCellsProcess(const pmChip *chip, // Chip of interest551 bool process // Process this chip?552 )553 {554 PS_ASSERT_PTR_NON_NULL(chip, false);555 556 psArray *cells = chip->cells; // Component cells557 if (! cells) {558 return false;559 }560 for (int i = 0; i < cells->n; i++) {561 pmCell *tmpCell = cells->data[i]; // Cell of interest562 if (tmpCell) {563 tmpCell->process = process;564 }565 }566 567 return true;568 }569 570 /*****************************************************************************571 XXX EAM : I've added the 'exclusive' option. if true all other chips are de-selected572 XXX EAM : a negative value is valid and, in combinations with exclusive, de-selects all chips573 *****************************************************************************/574 bool pmFPASelectChip(pmFPA *fpa, int chipNum, bool exclusive)575 {576 PS_ASSERT_PTR_NON_NULL(fpa, false);577 578 psArray *chips = fpa->chips; // Component chips579 if ((chips == NULL) || (chipNum >= chips->n)) {580 return(false);581 }582 583 for (int i = 0 ; i < chips->n ; i++) {584 pmChip *tmpChip = (pmChip *) chips->data[i];585 if (tmpChip == NULL) {586 continue;587 }588 if (i == chipNum) {589 tmpChip->process = true;590 setCellsProcess(tmpChip, true);591 } else {592 if (exclusive) {593 tmpChip->process = false;594 setCellsProcess(tmpChip, false);595 }596 }597 598 }599 600 return true;601 }602 603 /*****************************************************************************604 XXX EAM : I've added the 'exclusive' option. if true all other chips are de-selected605 XXX EAM : a negative value is valid and, in combinations with exclusive, de-selects all cells606 XXX this function should probably be re-defined to merge with 'setCellsProcess'607 *****************************************************************************/608 bool pmChipSelectCell(pmChip *chip, int cellNum, bool exclusive)609 {610 PS_ASSERT_PTR_NON_NULL(chip, false);611 612 psArray *cells = chip->cells; // Component cells613 if (!cells || cellNum > cells->n) {614 return false;615 }616 617 for (int i = 0; i < cells->n; i++) {618 pmCell *cell = cells->data[i];619 if (!cell) {620 continue;621 }622 if (i == cellNum) {623 cell->process = true;624 } else {625 if (exclusive) {626 cell->process = false;627 }628 }629 }630 return true;631 }632 633 /*****************************************************************************634 XXX: The SDRS is ambiguous on a few things:635 Whether or not the other chips should be set process=true. [PAP: No]636 Should we return the number of chip process=true before or after they're set, [PAP: After]637 *****************************************************************************/638 /**639 *640 * pmFPAExcludeChip shall set process to false only for the specified chip641 * number (chipNum). In the event that the specified chip number does not exist642 * within the fpa, the function shall generate a warning, and perform no action.643 * The function shall return the number of chips within the fpa that have process644 * set to true.645 *646 */647 int pmFPAExcludeChip(648 pmFPA *fpa,649 int chipNum)650 {651 PS_ASSERT_PTR_NON_NULL(fpa, -1);652 653 psArray *chips = fpa->chips; // Component chips654 if (chips == NULL) {655 psLogMsg(__func__, PS_LOG_WARN, "WARNING: fpa->chips == NULL\n");656 return(0);657 }658 if ((chipNum >= chips->n) || (NULL == (pmChip *) chips->data[chipNum])) {659 psLogMsg(__func__, PS_LOG_WARN, "WARNING: the specified chip (%d) does not exist.\n", chipNum);660 return(0);661 }662 663 int numChips = 0; // Number of chips to be processed664 for (int i = 0 ; i < chips->n ; i++) {665 pmChip *tmpChip = (pmChip *) chips->data[i]; // Chip of interest666 if (tmpChip != NULL) {667 if (i == chipNum) {668 tmpChip->process = false;669 setCellsProcess(tmpChip, false); // Wipe out the cell as well670 } else if (tmpChip->process) {671 numChips++;672 }673 }674 }675 676 return(numChips);677 }678 679 int pmChipExcludeCell(pmChip *chip,680 int cellNum681 )682 {683 PS_ASSERT_PTR_NON_NULL(chip, -1);684 685 psArray *cells = chip->cells; // The component cells686 if (!cells || cellNum > cells->n) {687 return 0;688 }689 690 int numCells = 0; // Number of cells to be processed691 for (int i = 0; i < cells->n; i++) {692 pmCell *cell = cells->data[i];693 if (!cell) {694 continue;695 }696 if (i == cellNum) {697 cell->process = false;698 } else {699 numCells++;700 }701 }702 703 return numCells;704 }705 706 static char *NameNONE = "NONE";707 static char *NameFPA = "FPA";708 static char *NameCHIP = "CHIP";709 static char *NameCELL = "CELL";710 static char *NameREADOUT = "READOUT";711 712 char *pmFPALevelToName(pmFPALevel level)713 {714 715 switch (level) {716 case PM_FPA_LEVEL_NONE:717 return NameNONE;718 case PM_FPA_LEVEL_FPA:719 return NameFPA;720 case PM_FPA_LEVEL_CHIP:721 return NameCHIP;722 case PM_FPA_LEVEL_CELL:723 return NameCELL;724 case PM_FPA_LEVEL_READOUT:725 return NameREADOUT;726 default:727 psAbort(PS_FILE_LINE, "You can't get here; level = %d", level);728 }729 return NULL;730 }731 732 pmFPALevel pmFPALevelFromName(const char *name)733 {734 pmFPALevel val;735 736 if (name == NULL) {737 val = PM_FPA_LEVEL_NONE;738 } else if (!strcasecmp(name, "FPA")) {739 val = PM_FPA_LEVEL_FPA;740 } else if (!strcasecmp(name, "CHIP")) {741 val = PM_FPA_LEVEL_CHIP;742 } else if (!strcasecmp(name, "CELL")) {743 val = PM_FPA_LEVEL_CELL;744 } else if (!strcasecmp(name, "READOUT")) {745 val = PM_FPA_LEVEL_READOUT;746 } else {747 val = PM_FPA_LEVEL_NONE;748 }749 750 return val;751 }752
Note:
See TracChangeset
for help on using the changeset viewer.
