IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 11, 2008, 4:51:20 PM (18 years ago)
Author:
Paul Price
Message:

The operation of pmReadoutReadChunk was broken by the recent changes to support threading. Those changes assumed that the user would keep track of the 'this' and 'last' scan values. While that is the case for ppMerge in its new threaded incarnation, that's not the case for ppStack (yet), and the user shouldn't be forced to do something so mundane and important. Added a new readout variable, forceScan, which is supposed to tell the code to obey what the user says for the 'this' and 'last' scan values. When forceScan isn't set, then the reading reverts to the old way (progressively reading up the readout).

File:
1 edited

Legend:

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

    r19011 r19013  
    4444//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    4545
    46 // Return pointer to appropriate value for tracking scans
     46// Get the "thisXXXScan" value in the readout for the appropriate image type
    4747static int readoutGetThisScan(pmReadout *readout, // Readout of interest
    4848                              fpaReadType type // Type of image
     
    6161}
    6262
    63 // Return pointer to appropriate value for tracking scans
    64 static int readoutSetLastScan(pmReadout *readout, // Readout of interest
    65                               fpaReadType type,   // Type of image
    66                               int numScans        // requested number of scans
     63// Set the "thisXXXScan" value in the readout for the appropriate image type
     64static int readoutSetThisScan(pmReadout *readout, // Readout of interest
     65                              fpaReadType type, // Type of image
     66                              int thisScan // Starting scan number
    6767    )
    6868{
    6969    switch (type) {
    7070      case FPA_READ_TYPE_IMAGE:
    71         readout->lastImageScan = readout->thisImageScan + numScans;
     71        readout->thisImageScan = thisScan;
    7272        return readout->lastImageScan;
    7373      case FPA_READ_TYPE_MASK:
    74         readout->lastMaskScan = readout->thisMaskScan + numScans;
     74        readout->thisMaskScan = thisScan;
    7575        return readout->lastMaskScan;
    7676      case FPA_READ_TYPE_WEIGHT:
    77         readout->lastWeightScan = readout->thisWeightScan + numScans;
     77        readout->thisWeightScan = thisScan;
     78        return readout->lastWeightScan;
     79      default:
     80        psAbort("Unknown read type: %x\n", type);
     81    }
     82    return false;
     83}
     84
     85// Get the "lastXXXScan" value in the readout for the appropriate image type
     86static int readoutGetLastScan(pmReadout *readout, // Readout of interest
     87                              fpaReadType type // Type of image
     88    )
     89{
     90    switch (type) {
     91      case FPA_READ_TYPE_IMAGE:
     92        return readout->lastImageScan;
     93      case FPA_READ_TYPE_MASK:
     94        return readout->lastMaskScan;
     95      case FPA_READ_TYPE_WEIGHT:
     96        return readout->lastWeightScan;
     97      default:
     98        psAbort("Unknown read type: %x\n", type);
     99    }
     100}
     101
     102// Set the "lastXXXScan" value in the readout for the appropriate image type
     103static int readoutSetLastScan(pmReadout *readout, // Readout of interest
     104                              fpaReadType type, // Type of image
     105                              int lastScan // Last scan number
     106    )
     107{
     108    switch (type) {
     109      case FPA_READ_TYPE_IMAGE:
     110        readout->lastImageScan = lastScan;
     111        return readout->lastImageScan;
     112      case FPA_READ_TYPE_MASK:
     113        readout->lastMaskScan = lastScan;
     114        return readout->lastMaskScan;
     115      case FPA_READ_TYPE_WEIGHT:
     116        readout->lastWeightScan = lastScan;
    78117        return readout->lastWeightScan;
    79118      default:
     
    156195}
    157196
    158 // Does the current readout, with scans set for a new read, represent any real data, or is it
    159 // beyond the end?  Requires that cellNumReadouts() has been called before (for header and
    160 // concepts to have been read) In the process, adjusts the TRIMSEC
    161 static bool readoutHaveMoreScans(bool *result,   // true : more data to read
     197// Does the current readout, with scans set for a new read, represent any real data, or is it beyond the end?
     198// Requires that cellNumReadouts() has been called before (for header and concepts to have been read)
     199// In the process, adjusts the TRIMSEC
     200static bool readoutHaveMoreScans(int *start, // Start of scan
     201                                 int *last, // Last possible scan (defined by TRIMSEC)
    162202                                 pmReadout *readout, // Readout of interest
    163203                                 int numScans, // Number of scans to read at a time
     
    166206                                 )
    167207{
    168     assert(result);
     208    assert(start);
     209    assert(last);
    169210    assert(readout);
    170 
    171     *result = false;
    172211
    173212    if (!pmConceptsReadCell(readout->parent, PM_CONCEPT_SOURCE_DEFAULTS | PM_CONCEPT_SOURCE_DATABASE,
     
    213252    }
    214253
     254    *last = (readdir == 1) ? trimsec->y1 : trimsec->x1; // Maximum possible scan number
     255
    215256    // Calculate the segment offset and upper limit
    216257    if (numScans == 0) {
    217         // in the case of numScans == 0, we never call this funtion unless the data has not yet
    218         // been read.  thus, only if the delta is  should we return false (ie, trimsec defines an empty region)
    219         int thisScan = (readdir == 1) ? trimsec->y0 : trimsec->x0;
    220         int lastScan = (readdir == 1) ? trimsec->y1 : trimsec->x1;
    221         *result = (lastScan > thisScan);
    222         return true;
    223     }
    224 
    225     // allow multiple threads to read different segments into different readouts
    226     // this thread may not have read a segment yet; but others have.  trust readout->imageScan
    227 
    228     // is the start scan of the read less than the last possible scan?
    229     int thisScan = readoutGetThisScan(readout, type);
    230     int lastScan = (readdir == 1) ? trimsec->y1 : trimsec->x1;
    231 
    232     *result = (lastScan > thisScan);
     258        // Read entire image.  In that case, we never call this funtion unless the data has not yet been read.
     259        // thus, only if the delta is should we return false (ie, trimsec defines an empty region)
     260        *start = (readdir == 1) ? trimsec->y0 : trimsec->x0;
     261    } else if (readout->forceScan) {
     262        // We're forced to read what we're told
     263        *start = readoutGetThisScan(readout, type);
     264    } else {
     265        // Progressive scans
     266        psImage *image = *readoutImageByType(readout, type); // Appropriate image from readout
     267        *start = image ? readoutGetLastScan(readout, type) + numScans : 0;
     268    }
     269
    233270    return true;
    234     // XXX fold this and the above case together
    235271}
    236272
     
    271307    }
    272308
    273     bool haveData;
    274     if (!readoutHaveMoreScans(&haveData, readout, numScans, type, config)) {
     309    int start, last;                    // Start and last scans
     310    if (!readoutHaveMoreScans(&start, &last, readout, numScans, type, config)) {
    275311        psError(PS_ERR_UNKNOWN, false, "Unable to determine readout properties.");
    276312        return false;
    277313    }
    278314
    279     return haveData;
     315    return start < last;
    280316}
    281317
     
    458494    }
    459495
    460     bool haveData;
    461     if (!readoutHaveMoreScans(&haveData, readout, numScans, type, config)) {
     496    int thisScan;                       // Starting scan for this read
     497    int maxScan;                        // Maximum scan number
     498    if (!readoutHaveMoreScans(&thisScan, &maxScan, readout, numScans, type, config)) {
    462499        psError(PS_ERR_UNKNOWN, false, "Unable to determine readout properties.");
    463500        return false;
    464501    }
    465     if (!haveData) {
     502    if (thisScan >= maxScan) {
    466503        psError(PS_ERR_IO, true, "No more of the readout to read.");
    467504        return false;
    468505    }
    469 
    470506
    471507    pmHDU *hdu = pmHDUFromCell(cell);   // The HDU
     
    511547    }
    512548
    513     // Determine the numbe of scans to read
    514     int thisScan = readoutGetThisScan(readout, type);
    515     int lastScan = readoutSetLastScan (readout, type, numScans);
     549    // Determine the number of scans to read
     550    int lastScan = readoutSetLastScan(readout, type, thisScan + numScans);
    516551    if (thisScan == 0) {
    517552        overlap = 0;
    518553    }
    519554    thisScan -= overlap;
     555    readoutSetThisScan(readout, type, thisScan);
    520556
    521557    // Calculate limits, adjust readout->row0,col0
    522558    // XXX Should row0,col0 be adjusted, since they are used for astrometry???
    523     // Just moved to using the "scansTracker" for tracking position in chunk reads, so row0,col0 not required
    524559    if (readdir == 1) {
    525560        // Reading rows
Note: See TracChangeset for help on using the changeset viewer.