IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 23, 2004, 1:16:36 PM (22 years ago)
Author:
gusciora
Message:

Added tests for input parameters.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/pmReadoutCombine.c

    r2810 r2812  
    55 *  @author GLG, MHPCC
    66 *
    7  *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-12-23 20:27:51 $
     7 *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-12-23 23:16:36 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2727psCombineParams;
    2828
    29 
    30 int p_psDetermineNumBits(unsigned int data)
     29/******************************************************************************
     30p_psDetermineNumBits(data): This routine takes an enum psStatsOptions as an
     31argument and returns the number of non-zero bits.
     32 *****************************************************************************/
     33psStatsOptions p_psDetermineNumBits(psStatsOptions data)
    3134{
    32     int i;
    33     unsigned int tmpData = data;
    34     int numBits = 0;
    35 
    36     for (i=0;i<sizeof(unsigned int);i++) {
    37         if (0x0001 && tmpData) {
     35    psS32 i;
     36    psU64 tmpData = data;
     37    psS32 numBits = 0;
     38
     39    for (i=0;i<4 * sizeof(psStatsOptions);i++) {
     40        if (0x0001 & tmpData) {
    3841            numBits++;
    3942        }
     
    4346}
    4447
     48// XXX: Whats this?
    4549#define MAX_INT 10000
    4650psImage *pmReadoutCombine(psImage *output,
     
    5559    PS_PTR_CHECK_NULL(inputs, NULL);
    5660    PS_PTR_CHECK_NULL(params, NULL);
     61    PS_PTR_CHECK_NULL(params->stats, NULL);
     62    if (zero != NULL) {
     63        PS_VECTOR_CHECK_TYPE(zero, PS_TYPE_F32, NULL);
     64    }
     65    if (scale != NULL) {
     66        PS_VECTOR_CHECK_TYPE(scale, PS_TYPE_F32, NULL);
     67    }
     68    if ((zero != NULL) && (scale != NULL)) {
     69        PS_VECTOR_CHECK_TYPE_EQUAL(zero, scale, NULL);
     70        // XXX: Currently only type F32 is implemented.
     71        // PS_VECTOR_CHECK_TYPE_S16_S32_F32(scale, NULL);
     72    }
     73
    5774    psStats *stats = params->stats;
    5875    int i;
     
    6683    int numInputs = 0;
    6784    int tmpI;
     85    psElemType outputType = PS_TYPE_F32;
     86
     87    if (1 < p_psDetermineNumBits(params->stats->options)) {
     88        psError(PS_ERR_UNKNOWN, true,
     89                "Multiple statistical options have been requested.\n");
     90        return(NULL);
     91    }
    6892
    6993    //
     
    86110        PS_READOUT_CHECK_EMPTY(tmpReadout, output);
    87111        PS_READOUT_CHECK_TYPE(tmpReadout, PS_TYPE_F32, output);
     112        outputType = tmpReadout->image->type.type;
    88113
    89114        minInputRows = PS_MIN(minInputRows,
     
    105130
    106131    // We ensure that the zero vector is of the proper size.
     132
    107133    if (zero != NULL) {
    108134        PS_VECTOR_CHECK_TYPE(zero, PS_TYPE_F32, NULL);
    109135        if (numInputs > zero->n) {
    110             // XXX: ERROR: the zero vector does not have enough elements.
     136            psError(PS_ERR_UNKNOWN, true, "zero vector has incorrect size (%d)\n", zero->n);
    111137            return(NULL);
    112138        } else if (numInputs < zero->n) {
    113             // XXX: WARNING: the zero vector too many elements.
     139            psLogMsg(__func__, PS_LOG_WARN,
     140                     "WARNING: the zero vector too many elements (%d)\n", zero->n);
    114141        }
    115142    }
     
    119146        PS_VECTOR_CHECK_TYPE(scale, PS_TYPE_F32, NULL);
    120147        if (numInputs > scale->n) {
    121             // XXX: ERROR: the scale vector does not have enough elements.
     148            psError(PS_ERR_UNKNOWN, true, "scale vector has incorrect size (%d)\n", scale->n);
    122149            return(NULL);
    123150        } else if (numInputs < scale->n) {
    124             // XXX: WARNING: the scale vector too many elements.
     151            psLogMsg(__func__, PS_LOG_WARN,
     152                     "WARNING: the scale vector too many elements (%d)\n", scale->n);
    125153        }
    126154    }
     
    134162    if (output == NULL) {
    135163        output = psImageAlloc(maxInputCols-minInputCols,
    136                               maxInputRows-minInputRows, PS_TYPE_F32);
     164                              maxInputRows-minInputRows, outputType);
    137165        *(int *) &(output->col0) = minInputCols;
    138166        *(int *) &(output->row0) = minInputRows;
     
    140168        if (((output->col0 + output->numCols) < maxInputCols) ||
    141169                ((output->row0 + output->numRows) < maxInputRows)) {
    142             //XXX ERROR: "Output image (%d, %d) is too small to hold combined images.\n",
    143             //                    output->row0 + output->numRows,
    144             //                    output->col0 + output->numCols);
     170            psError(PS_ERR_UNKNOWN, true,
     171                    "Output image (%d, %d) is too small to hold combined images.\n",
     172                    output->row0 + output->numRows,
     173                    output->col0 + output->numCols);
    145174            return(NULL);
    146175        }
     
    150179            return(NULL);
    151180        }
    152     }
    153 
    154     if (1 < p_psDetermineNumBits(params->stats->options)) {
    155         //XXX        psError(PS_ERR_UNKNOWN,true, "Multiple statistical options have been requested.\n");
    156         return(NULL);
    157181    }
    158182
     
    254278            // XXX: Is this correct?
    255279            // We add the zero vector, if non-NULL.
     280
    256281            if (zero != NULL) {
    257282                for (int r = 0; r < numInputs ; r++) {
Note: See TracChangeset for help on using the changeset viewer.