IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 16, 2006, 2:33:57 PM (20 years ago)
Author:
Paul Price
Message:

Creating pmFPALevel.[ch] to hold pmFPALevel stuff. Creating pmFPAFlags.[ch] to hold status flag setting and checking functions. Both of these were pulled out of pmFPA.[ch]. Documenting pmFPA.h, pmFPALevel.h, pmFPAFlags.h. Adding additional includes of the new header files to files that needed them.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPA.c

    r8815 r9584  
    1212* XXX: Should we implement non-linear cell->chip transforms?
    1313*
    14 *  @version $Revision: 1.12 $ $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 $
    1616*
    1717*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    101101    psFree(chip->analysis);
    102102    psFree(chip->hdu);
    103     psFree(chip->mosaic);
    104103
    105104    # if FPA_ASTROM
     
    322321    tmpChip->toFPA = NULL;
    323322    tmpChip->fromFPA = NULL;
    324     # endif
     323    #endif
    325324
    326325    tmpChip->analysis = psMetadataAlloc();
     
    331330    }
    332331    tmpChip->hdu = NULL;
    333     tmpChip->mosaic = NULL;
    334332    tmpChip->process = true;            // Work on all chips, by default
    335333    tmpChip->file_exists = false;       // Not yet identified
     
    355353    tmpFPA->toTangentPlane = NULL;
    356354    tmpFPA->projection = NULL;
    357     # endif
     355    #endif
    358356
    359357    tmpFPA->analysis = NULL;
     
    369367}
    370368
    371 static bool cellCheckParents(pmCell *cell)
     369// Check a cell to ensure that all component readouts have the parent pointer set correctly
     370static bool cellCheckParents(pmCell *cell // Cell to check
     371                            )
    372372{
    373373    PS_ASSERT_PTR_NON_NULL(cell, true);
     
    387387}
    388388
    389 static bool chipCheckParents(pmChip *chip)
     389// Check a chip to ensure that all component cells have the parent pointer set correctly
     390static bool chipCheckParents(pmChip *chip // Chip to check
     391                            )
    390392{
    391393    PS_ASSERT_PTR_NON_NULL(chip, true);
     
    393395    bool flag = true;
    394396    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];
    396398        if (!tmpCell) {
    397399            continue;
     
    413415    bool flag = true;
    414416    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];
    416418        if (!tmpChip) {
    417419            continue;
     
    426428    return flag;
    427429}
    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 not
    550 static bool setCellsProcess(const pmChip *chip, // Chip of interest
    551                             bool process  // Process this chip?
    552                            )
    553 {
    554     PS_ASSERT_PTR_NON_NULL(chip, false);
    555 
    556     psArray *cells = chip->cells;       // Component cells
    557     if (! cells) {
    558         return false;
    559     }
    560     for (int i = 0; i < cells->n; i++) {
    561         pmCell *tmpCell = cells->data[i]; // Cell of interest
    562         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-selected
    572 XXX EAM : a negative value is valid and, in combinations with exclusive, de-selects all chips
    573  *****************************************************************************/
    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 chips
    579     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-selected
    605 XXX EAM : a negative value is valid and, in combinations with exclusive, de-selects all cells
    606 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 cells
    613     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 chip
    641  * number (chipNum). In the event that the specified chip number does not exist
    642  * 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 process
    644  * 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 chips
    654     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 processed
    664     for (int i = 0 ; i < chips->n ; i++) {
    665         pmChip *tmpChip = (pmChip *) chips->data[i]; // Chip of interest
    666         if (tmpChip != NULL) {
    667             if (i == chipNum) {
    668                 tmpChip->process = false;
    669                 setCellsProcess(tmpChip, false); // Wipe out the cell as well
    670             } else if (tmpChip->process) {
    671                 numChips++;
    672             }
    673         }
    674     }
    675 
    676     return(numChips);
    677 }
    678 
    679 int pmChipExcludeCell(pmChip *chip,
    680                       int cellNum
    681                      )
    682 {
    683     PS_ASSERT_PTR_NON_NULL(chip, -1);
    684 
    685     psArray *cells = chip->cells;       // The component cells
    686     if (!cells || cellNum > cells->n) {
    687         return 0;
    688     }
    689 
    690     int numCells = 0;                   // Number of cells to be processed
    691     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.