IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 18, 2006, 2:54:44 PM (20 years ago)
Author:
Paul Price
Message:

Removing pmConceptLevel in favour of pmFPALevel

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/astrom/pmConceptsStandard.c

    r6872 r6895  
    1414                               (a)->y0 == (b)->y0 && \
    1515                               (a)->y1 == (b)->y1) ? true : false)
     16
     17#define TYPE_CASE(assign, item, TYPE) \
     18case PS_TYPE_##TYPE: \
     19assign = item->data.TYPE; \
     20break;
     21
    1622
    1723
     
    218224
    219225    int binning = 1;                    // Binning factor in x
    220     if (concept->type == PS_DATA_STRING) {
    221         psString binString = concept->data.V; // The string containing the binning
    222         if ((strcmp(pattern->name, "CELL.XBIN") == 0 && sscanf(binString, "%d %*d", &binning) != 1 &&
    223                 sscanf(binString, "%d,%*d", &binning) != 1) ||
    224                 (strcmp(pattern->name, "CELL.YBIN") == 0 && sscanf(binString, "%*d %d", &binning) != 1 &&
    225                  sscanf(binString, "%*d,%d", &binning) != 1)) {
    226             psError(PS_ERR_IO, true, "Unable to parse string to get %s: %s\n", pattern->name, binString);
    227         }
    228     } else if (concept->type == PS_TYPE_S32) {
    229         binning = concept->data.S32;
    230     } else {
     226    switch (concept->type) {
     227    case PS_DATA_STRING: {
     228            psString binString = concept->data.V; // The string containing the binning
     229            if ((strcmp(pattern->name, "CELL.XBIN") == 0 && sscanf(binString, "%d %*d", &binning) != 1 &&
     230                    sscanf(binString, "%d,%*d", &binning) != 1) ||
     231                    (strcmp(pattern->name, "CELL.YBIN") == 0 && sscanf(binString, "%*d %d", &binning) != 1 &&
     232                     sscanf(binString, "%*d,%d", &binning) != 1)) {
     233                psError(PS_ERR_IO, true, "Unable to parse string to get %s: %s\n", pattern->name, binString);
     234            }
     235        }
     236        TYPE_CASE(binning, concept, U8);
     237        TYPE_CASE(binning, concept, U16);
     238        TYPE_CASE(binning, concept, U32);
     239        TYPE_CASE(binning, concept, S8);
     240        TYPE_CASE(binning, concept, S16);
     241        TYPE_CASE(binning, concept, S32);
     242    default:
    231243        psError(PS_ERR_IO, true, "Note sure how to parse %s of type %x --- assuming 1.\n", pattern->name,
    232244                concept->type);
     
    324336                double seconds = NAN;
    325337                switch (timeItem->type) {
    326                 case PS_TYPE_S32:
    327                     seconds = timeItem->data.S32;
    328                     break;
    329                 case PS_TYPE_F32:
    330                     seconds = timeItem->data.F32;
    331                     break;
    332                 case PS_TYPE_F64:
    333                     seconds = timeItem->data.F64;
    334                     break;
     338                    TYPE_CASE(seconds, timeItem, U8);
     339                    TYPE_CASE(seconds, timeItem, U16);
     340                    TYPE_CASE(seconds, timeItem, U32);
     341                    TYPE_CASE(seconds, timeItem, S8);
     342                    TYPE_CASE(seconds, timeItem, S16);
     343                    TYPE_CASE(seconds, timeItem, S32);
     344                    TYPE_CASE(seconds, timeItem, F32);
     345                    TYPE_CASE(seconds, timeItem, F64);
    335346                default:
    336347                    psError(PS_ERR_IO, true, "Time is not of an expected type: %x\n", timeItem->type);
     
    424435    assert(cameraFormat);
    425436
    426     if (concept->type != PS_TYPE_S32) {
    427         psError(PS_ERR_IO, true, "Concept %s is not of type S32, as expected.\n", pattern->name);
     437    int offset = 0;                     // Offset of cell (0,0) corner from the chip (0,0) corner
     438
     439    switch (concept->type) {
     440        TYPE_CASE(offset, concept, U8);
     441        TYPE_CASE(offset, concept, U16);
     442        TYPE_CASE(offset, concept, U32);
     443        TYPE_CASE(offset, concept, S8);
     444        TYPE_CASE(offset, concept, S16);
     445        TYPE_CASE(offset, concept, S32);
     446    default:
     447        psError(PS_ERR_IO, true, "Concept %s is not of integer type, as expected.\n", pattern->name);
    428448        return NULL;
    429449    }
    430     int offset = concept->data.S32;
    431450    offset -= fortranCorr(cameraFormat, pattern->name);
    432451    return psMetadataItemAllocS32(pattern->name, pattern->comment, offset);
Note: See TracChangeset for help on using the changeset viewer.