Commit 3d38dfc4 authored by Éric Thiébaut's avatar Éric Thiébaut
Browse files

Test pre-processing level and pixel type

parent ae1dbb0e
......@@ -1246,8 +1246,37 @@ static tao_status check_configuration(
}
}
if (idx == -1) {
tao_store_error(func, TAO_BAD_ENCODING);
return TAO_ERROR;
goto bad_encoding;
}
// Check pre-processing level and pixel type.
int nbits = 0;
if (cfg->bufferencoding == TAO_ENCODING_MONO(8)) {
nbits = 8;
} else if (cfg->bufferencoding == TAO_ENCODING_MONO_PKT(12, 24)) {
nbits = 12;
} else if (cfg->bufferencoding == TAO_ENCODING_MONO(16)) {
nbits = 16;
} else if (cfg->bufferencoding == TAO_ENCODING_MONO(32)) {
nbits = 32;
} else {
goto bad_encoding;
}
if (cfg->preprocessing == TAO_PREPROCESSING_NONE) {
if ((cfg->pixeltype != TAO_UINT8 || nbits > 8) &&
(cfg->pixeltype != TAO_UINT16 || nbits > 16) &&
(cfg->pixeltype != TAO_UINT32 || nbits > 32) &&
(cfg->pixeltype != TAO_FLOAT ) &&
(cfg->pixeltype != TAO_DOUBLE )) {
goto bad_pixeltype;
}
} else if (cfg->preprocessing == TAO_PREPROCESSING_AFFINE ||
cfg->preprocessing == TAO_PREPROCESSING_FULL) {
if (cfg->pixeltype != TAO_FLOAT && cfg->pixeltype != TAO_DOUBLE) {
goto bad_pixeltype;
}
} else {
goto bad_preprocessing;
}
// Check number of number of acquisition buffers.
......@@ -1256,4 +1285,15 @@ static tao_status check_configuration(
return TAO_ERROR;
}
return TAO_OK;
// Errors branch here.
bad_encoding:
tao_store_error(func, TAO_BAD_ENCODING);
return TAO_ERROR;
bad_pixeltype:
tao_store_error(func, TAO_BAD_TYPE);
return TAO_ERROR;
bad_preprocessing:
tao_store_error(func, TAO_BAD_PREPROCESSING);
return TAO_ERROR;
}
......@@ -369,6 +369,7 @@ const char* FUNC(
CASE(TAO_BAD_SERIAL, "Invalid serial number");
CASE(TAO_BAD_ROI, "Invalid region of interest");
CASE(TAO_BAD_RANK, "Invalid number of dimensions");
CASE(TAO_BAD_PREPROCESSING, "Bad pre-processing setting");
CASE(TAO_BAD_NAME, "Bad parameter name");
CASE(TAO_BAD_MAGIC, "Invalid magic number");
CASE(TAO_BAD_GAIN, "Invalid detector gain");
......
......@@ -96,37 +96,38 @@ typedef enum tao_error_code_ {
TAO_BAD_GAIN = -20, ///< Invalid detector gain
TAO_BAD_MAGIC = -21, ///< Invalid magic number
TAO_BAD_NAME = -22, ///< Bad parameter name
TAO_BAD_RANK = -23, ///< Invalid number of dimensions
TAO_BAD_ROI = -24, ///< Invalid region of interest
TAO_BAD_SERIAL = -25, ///< Invalid serial number
TAO_BAD_SIZE = -26, ///< Invalid size
TAO_BAD_SPEED = -27, ///< Invalid connection speed
TAO_BAD_STAGE = -28, ///< Invalid or unexpected stage
TAO_BAD_TYPE = -29, ///< Invalid type
TAO_BAD_VALUE = -30, ///< Invalid parameter value
TAO_BROKEN_CYCLE = -31, ///< Broken cycle or unordered operations
TAO_CANT_TRACK_ERROR = -32, ///< Insufficient memory to track errors
TAO_CORRUPTED = -33, ///< Corrupted structure
TAO_DESTROYED = -34, ///< Resource has been destroyed
TAO_EXHAUSTED = -35, ///< Resource exhausted
TAO_MISSING_SEPARATOR = -36, ///< Separator missing
TAO_MUST_RESET = -37, ///< Device must be reset
TAO_NOT_ACQUIRING = -38, ///< Acquisition not started
TAO_NOT_FOUND = -39, ///< Item not found
TAO_NOT_LOCKED = -40, ///< Resource not locked by caller
TAO_NOT_READY = -41, ///< Device not ready
TAO_NOT_RUNNING = -42, ///< Server is not running
TAO_NOT_YET_IMPLEMENTED = -43, ///< Not yet implemented
TAO_NO_DATA = -44, ///< No data available
TAO_NO_FITS_SUPPORT = -45, ///< Compiled with no FITS support
TAO_OUT_OF_RANGE = -46, ///< Out of range argument
TAO_OVERWRITTEN = -47, ///< Contents has been overwritten
TAO_SYSTEM_ERROR = -48, ///< Unknown system error
TAO_UNCLOSED_STRING = -49, ///< Unclosed string
TAO_UNREADABLE = -50, ///< Not readable
TAO_UNRECOVERABLE = -51, ///< Unrecoverable error
TAO_UNSUPPORTED = -52, ///< Unsupported feature
TAO_UNWRITABLE = -53, ///< Not writable
TAO_BAD_PREPROCESSING = -23, ///< Bad pre-processing setting
TAO_BAD_RANK = -24, ///< Invalid number of dimensions
TAO_BAD_ROI = -25, ///< Invalid region of interest
TAO_BAD_SERIAL = -26, ///< Invalid serial number
TAO_BAD_SIZE = -27, ///< Invalid size
TAO_BAD_SPEED = -28, ///< Invalid connection speed
TAO_BAD_STAGE = -29, ///< Invalid or unexpected stage
TAO_BAD_TYPE = -30, ///< Invalid type
TAO_BAD_VALUE = -31, ///< Invalid parameter value
TAO_BROKEN_CYCLE = -32, ///< Broken cycle or unordered operations
TAO_CANT_TRACK_ERROR = -33, ///< Insufficient memory to track errors
TAO_CORRUPTED = -34, ///< Corrupted structure
TAO_DESTROYED = -35, ///< Resource has been destroyed
TAO_EXHAUSTED = -36, ///< Resource exhausted
TAO_MISSING_SEPARATOR = -37, ///< Separator missing
TAO_MUST_RESET = -38, ///< Device must be reset
TAO_NOT_ACQUIRING = -39, ///< Acquisition not started
TAO_NOT_FOUND = -40, ///< Item not found
TAO_NOT_LOCKED = -41, ///< Resource not locked by caller
TAO_NOT_READY = -42, ///< Device not ready
TAO_NOT_RUNNING = -43, ///< Server is not running
TAO_NOT_YET_IMPLEMENTED = -44, ///< Not yet implemented
TAO_NO_DATA = -45, ///< No data available
TAO_NO_FITS_SUPPORT = -46, ///< Compiled with no FITS support
TAO_OUT_OF_RANGE = -47, ///< Out of range argument
TAO_OVERWRITTEN = -48, ///< Contents has been overwritten
TAO_SYSTEM_ERROR = -49, ///< Unknown system error
TAO_UNCLOSED_STRING = -50, ///< Unclosed string
TAO_UNREADABLE = -51, ///< Not readable
TAO_UNRECOVERABLE = -52, ///< Unrecoverable error
TAO_UNSUPPORTED = -53, ///< Unsupported feature
TAO_UNWRITABLE = -54, ///< Not writable
} tao_error_code;
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment