本文整理汇总了C++中NDAttribute::getValue方法的典型用法代码示例。如果您正苦于以下问题:C++ NDAttribute::getValue方法的具体用法?C++ NDAttribute::getValue怎么用?C++ NDAttribute::getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NDAttribute
的用法示例。
在下文中一共展示了NDAttribute::getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calculateTrigger
asynStatus NDPluginCircularBuff::calculateTrigger(NDArray *pArray, int *trig)
{
NDAttribute *trigger;
char triggerString[256];
double triggerValue;
double calcResult;
int status;
int preTrigger, postTrigger, currentImage, triggered;
static const char *functionName="calculateTrigger";
*trig = 0;
getIntegerParam(NDCircBuffPreTrigger, &preTrigger);
getIntegerParam(NDCircBuffPostTrigger, &postTrigger);
getIntegerParam(NDCircBuffCurrentImage, ¤tImage);
getIntegerParam(NDCircBuffTriggered, &triggered);
triggerCalcArgs_[0] = epicsNAN;
triggerCalcArgs_[1] = epicsNAN;
triggerCalcArgs_[2] = preTrigger;
triggerCalcArgs_[3] = postTrigger;
triggerCalcArgs_[4] = currentImage;
triggerCalcArgs_[5] = triggered;
getStringParam(NDCircBuffTriggerA, sizeof(triggerString), triggerString);
trigger = pArray->pAttributeList->find(triggerString);
if (trigger != NULL) {
status = trigger->getValue(NDAttrFloat64, &triggerValue);
if (status == asynSuccess) {
triggerCalcArgs_[0] = triggerValue;
}
}
getStringParam(NDCircBuffTriggerB, sizeof(triggerString), triggerString);
trigger = pArray->pAttributeList->find(triggerString);
if (trigger != NULL) {
status = trigger->getValue(NDAttrFloat64, &triggerValue);
if (status == asynSuccess) {
triggerCalcArgs_[1] = triggerValue;
}
}
setDoubleParam(NDCircBuffTriggerAVal, triggerCalcArgs_[0]);
setDoubleParam(NDCircBuffTriggerBVal, triggerCalcArgs_[1]);
status = calcPerform(triggerCalcArgs_, &calcResult, triggerCalcPostfix_);
if (status) {
asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,
"%s::%s error evaluating expression=%s\n",
driverName, functionName, calcErrorStr(status));
return asynError;
}
if (!isnan(calcResult) && !isinf(calcResult) && (calcResult != 0)) *trig = 1;
setDoubleParam(NDCircBuffTriggerCalcVal, calcResult);
return asynSuccess;
}
示例2: attrFileNameSet
/** Look up filename related attributes in the NDArray.
* If file name or number is found in the NDArray, the values are replacing the existing ones
* in the parameter library. If not found the existing settings remain.
*/
asynStatus NDPluginFile::attrFileNameSet()
{
asynStatus status = asynSuccess;
NDAttribute *ndAttr;
char attrFileName[MAX_FILENAME_LEN];
epicsInt32 attrFileNumber;
size_t attrFileNameLen;
NDAttrDataType_t attrDataType;
NDArray *pArray = this->pArrays[0];
if (this->useAttrFilePrefix == false)
return status;
/* first check if the attribute contain a fileprefix to form part of the filename. */
ndAttr = pArray->pAttributeList->find(FILEPLUGIN_NAME);
if (ndAttr != NULL)
{
ndAttr->getValueInfo(&attrDataType, &attrFileNameLen);
if (attrDataType == NDAttrString)
{
if (attrFileNameLen > MAX_FILENAME_LEN) attrFileNameLen = MAX_FILENAME_LEN;
ndAttr->getValue(NDAttrString, attrFileName, attrFileNameLen);
setStringParam(NDFileName, attrFileName);
}
}
ndAttr = pArray->pAttributeList->find(FILEPLUGIN_NUMBER);
if (ndAttr != NULL)
{
ndAttr->getValueInfo(&attrDataType, &attrFileNameLen);
if (attrDataType == NDAttrInt32)
{
ndAttr->getValue(NDAttrInt32, &attrFileNumber, 0);
setIntegerParam(NDFileNumber, attrFileNumber);
// ensure auto increment is switched off when using attribute file numbers
setIntegerParam(NDAutoIncrement, 0);
}
}
return status;
}
示例3: attrIsProcessingRequired
/** Decide whether or not this frame is intended to be processed by this plugin.
* By default all frames are processed. The decision not to process a frame is
* made based on the string value of the FILEPLUGIN_DESTINATION: if the value does not equal
* either "all" or the ASYN port name of the current plugin the frame is not to be processed.
* \param[in] pAttrList A pointer to the current NDArray's attribute list.
* \returns true if the frame is to be processed. false if the frame is not to be processed.
*/
bool NDPluginFile::attrIsProcessingRequired(NDAttributeList* pAttrList)
{
char destPortName[MAX_FILENAME_LEN];
NDAttribute *ndAttr;
size_t destPortNameLen;
NDAttrDataType_t attrDataType;
ndAttr = pAttrList->find(FILEPLUGIN_DESTINATION);
if (ndAttr != NULL)
{
ndAttr->getValueInfo(&attrDataType, &destPortNameLen);
if (attrDataType == NDAttrString && destPortNameLen > 1)
{
if (destPortNameLen > MAX_FILENAME_LEN)
destPortNameLen = MAX_FILENAME_LEN;
ndAttr->getValue(NDAttrString, destPortName, destPortNameLen);
if (epicsStrnCaseCmp(destPortName, "all", destPortNameLen>3?3:destPortNameLen) != 0 &&
epicsStrnCaseCmp(destPortName, this->portName, destPortNameLen) != 0)
return false;
}
}
return true;
}
示例4: attrFileCloseCheck
/** Check whether an attribute asking the file to be closed has been set.
* if the value of FILEPLUGIN_CLOSE attribute is set to 1 then close the file.
*/
asynStatus NDPluginFile::attrFileCloseCheck()
{
asynStatus status = asynSuccess;
NDAttribute *NDattrFileClose;
int getStatus = 0;
int closeFile = 0;
NDattrFileClose = this->pArrays[0]->pAttributeList->find(FILEPLUGIN_CLOSE);
// Check for the existence of the parameter
if (NDattrFileClose != NULL) {
// Check NDAttribute value (0 = continue, anything else = close file)
getStatus = NDattrFileClose->getValue(NDAttrInt32, &closeFile);
if (getStatus == 0){
if (closeFile != 0){
// Force a file close
this->closeFileBase();
// We must also set the parameter to notify we have stopped capturing
setIntegerParam(NDFileCapture, 0);
}
} else {
status = asynError;
}
}
return status;
}
示例5: convert
//.........这里部分代码省略.........
/* Compute the dimensions of the output array */
dimsUnchanged = 1;
for (i=0; i<pIn->ndims; i++) {
dimsOutCopy[i].size = dimsOutCopy[i].size/dimsOutCopy[i].binning;
if (dimsOutCopy[i].size <= 0) {
printf("%s:%s: ERROR, invalid output dimension, size=%d, binning=%d\n",
driverName, functionName, (int)dimsOut[i].size, dimsOut[i].binning);
return(ND_ERROR);
}
dimSizeOut[i] = dimsOutCopy[i].size;
if ((pIn->dims[i].size != dimsOutCopy[i].size) ||
(dimsOutCopy[i].offset != 0) ||
(dimsOutCopy[i].binning != 1) ||
(dimsOutCopy[i].reverse != 0)) dimsUnchanged = 0;
}
/* We now know the datatype and dimensions of the output array.
* Allocate it */
pOut = alloc(pIn->ndims, dimSizeOut, dataTypeOut, 0, NULL);
*ppOut = pOut;
if (!pOut) {
printf("%s:%s: ERROR, cannot allocate output array\n",
driverName, functionName);
return(ND_ERROR);
}
/* Copy fields from input to output */
pOut->timeStamp = pIn->timeStamp;
pOut->epicsTS = pIn->epicsTS;
pOut->uniqueId = pIn->uniqueId;
/* Replace the dimensions with those passed to this function */
memcpy(pOut->dims, dimsOutCopy, pIn->ndims*sizeof(NDDimension_t));
pIn->pAttributeList->copy(pOut->pAttributeList);
pOut->getInfo(&arrayInfo);
if (dimsUnchanged) {
if (pIn->dataType == pOut->dataType) {
/* The dimensions are the same and the data type is the same,
* then just copy the input image to the output image */
memcpy(pOut->pData, pIn->pData, arrayInfo.totalBytes);
return ND_SUCCESS;
} else {
/* We need to convert data types */
switch(pOut->dataType) {
case NDInt8:
convertTypeSwitch <epicsInt8> (pIn, pOut);
break;
case NDUInt8:
convertTypeSwitch <epicsUInt8> (pIn, pOut);
break;
case NDInt16:
convertTypeSwitch <epicsInt16> (pIn, pOut);
break;
case NDUInt16:
convertTypeSwitch <epicsUInt16> (pIn, pOut);
break;
case NDInt32:
convertTypeSwitch <epicsInt32> (pIn, pOut);
break;
case NDUInt32:
convertTypeSwitch <epicsUInt32> (pIn, pOut);
break;
case NDFloat32:
convertTypeSwitch <epicsFloat32> (pIn, pOut);
break;
case NDFloat64:
convertTypeSwitch <epicsFloat64> (pIn, pOut);
break;
default:
//status = ND_ERROR;
break;
}
}
} else {
/* The input and output dimensions are not the same, so we are extracting a region
* and/or binning */
/* Clear entire output array */
memset(pOut->pData, 0, arrayInfo.totalBytes);
convertDimension(pIn, pOut, pIn->pData, pOut->pData, pIn->ndims-1);
}
/* Set fields in the output array */
for (i=0; i<pIn->ndims; i++) {
pOut->dims[i].offset = pIn->dims[i].offset + dimsOutCopy[i].offset;
pOut->dims[i].binning = pIn->dims[i].binning * dimsOutCopy[i].binning;
if (pIn->dims[i].reverse) pOut->dims[i].reverse = !pOut->dims[i].reverse;
}
/* If the frame is an RGBx frame and we have collapsed that dimension then change the colorMode */
pAttribute = pOut->pAttributeList->find("ColorMode");
if (pAttribute && pAttribute->getValue(NDAttrInt32, &colorMode)) {
if ((colorMode == NDColorModeRGB1) && (pOut->dims[0].size != 3))
pAttribute->setValue(&colorModeMono);
else if ((colorMode == NDColorModeRGB2) && (pOut->dims[1].size != 3))
pAttribute->setValue(&colorModeMono);
else if ((colorMode == NDColorModeRGB3) && (pOut->dims[2].size != 3))
pAttribute->setValue(&colorModeMono);
}
return ND_SUCCESS;
}
示例6: if
void* epics2hdf::getNDAttr(const char* attr_name, void* attr_val,
hid_t *datatype)
{
NDAttrDataType_t attrDataType;
NDAttribute *pAttr;
size_t attrDataSize;
hid_t nd_hdf_type;
if (strcmp(attr_name, "sysclock") == 0)
{
*datatype = H5T_NATIVE_DOUBLE;
double *x;
x = (double*) attr_val;
*x = clock() / CLOCKS_PER_SEC;
}
else if (strcmp(attr_name, "timestamp") == 0)
{
*datatype = H5T_NATIVE_DOUBLE;
double *x;
x = (double*) attr_val;
*x = pArray->timeStamp;
}
else if (strcmp(attr_name, "uniqueId") == 0)
{
*datatype = H5T_NATIVE_INT;
int *x;
x = (int*) attr_val;
*x = pArray->uniqueId;
}
else if (strcmp(attr_name, "datetime") == 0)
{
//2003-04-01T13:01:02 is ISO format.
time_t rawtime;
struct tm *today;
char tstr[128];
time(&rawtime);
today = localtime(&rawtime);
sprintf(tstr, "%04i-%02i-%02iT%02i:%02i:%02i", today->tm_year + 1900,
today->tm_mon + 1, today->tm_mday, today->tm_hour, today->tm_min,
today->tm_sec);
*datatype = H5T_STR_NULLTERM;
strcpy((char*) attr_val, tstr);
}
else
{
pAttr = pArray->pAttributeList->find(attr_name);
if (pAttr != NULL)
{
pAttr->getValueInfo(&attrDataType, &attrDataSize);
nd_hdf_type = type_ndatr2hdf(attrDataType);
*datatype = nd_hdf_type;
if (nd_hdf_type >= 0)
{
pAttr->getValue(attrDataType, (char *) attr_val, attrDataSize);
}
else
{
printf("epics2hdf::getNDAttr bad NDAttr datatype %s\n", attr_name);
*datatype = 0;
strcpy((char*) attr_val, "Error: Unknown Attribute Datatype");
}
} //pAttr
else
{
int attrCount;
printf("epics2hdf::getNDAttr Could not find NDAttr %s\n", attr_name);
*datatype = 0;
strcpy((char*) attr_val, "Error: Unknown Attribute");
// list the attributes
printf("List of attributes in image\n");
pAttr = pArray->pAttributeList->next(NULL);
for (attrCount = 0; attrCount < pArray->pAttributeList->count();
attrCount++)
{
printf("Attr: %s \n", pAttr->pName);
pAttr = pArray->pAttributeList->next(pAttr);
}
} //pAttr
}
return (attr_val);
}
示例7: formatArray
/** Format an NDArray as an AVFrame using the codec context c.
Use inPicture to wrap the data in pArray, use swscale to convert it to scPicture
using the output parameters stored in c. Special case for gray8 -> YUVx, can
use the data as is and add a neutral array for the colour info.
*/
int formatArray(NDArray *pArray, asynUser *pasynUser, AVFrame *inPicture,
struct SwsContext **pCtx, AVCodecContext *c, AVFrame *scPicture) {
static const char *functionName = "formatArray";
int colorMode = NDColorModeMono;
int width, height;
PixelFormat pix_fmt;
NDAttribute *pAttribute = NULL;
int Int16;
/* only support 8 and 16 bit data for now */
switch (pArray->dataType) {
case NDInt8:
case NDUInt8:
Int16 = 0;
break;
case NDInt16:
case NDUInt16:
Int16 = 1;
break;
default:
asynPrint(pasynUser, ASYN_TRACE_ERROR,
"%s: only 8 or 16-bit data is supported\n", functionName);
return(asynError);
}
/* Get the colormode of the array */
pAttribute = pArray->pAttributeList->find("ColorMode");
if (pAttribute) pAttribute->getValue(NDAttrInt32, &colorMode);
/* We do some special treatment based on colorMode */
if ((pArray->ndims == 2) && (colorMode == NDColorModeMono)) {
width = (int) pArray->dims[0].size;
height = (int) pArray->dims[1].size;
if (Int16) {
pix_fmt = PIX_FMT_GRAY16;
} else if (width != c->width || height != c->height) {
pix_fmt = PIX_FMT_GRAY8;
} else {
int stride;
pix_fmt = PIX_FMT_GRAY8;
/* special case for gray8, and planar outputs, don't need to scale,
can use a neutral array */
switch (c->pix_fmt) {
case PIX_FMT_YUV420P: //< planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
case PIX_FMT_YUV411P: //< planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
case PIX_FMT_YUVJ420P: //< planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_range
case PIX_FMT_NV12: //< planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V)
case PIX_FMT_NV21: //< as above, but U and V bytes are swapped
stride = 4;
break;
case PIX_FMT_YUV422P: //< planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
case PIX_FMT_YUVJ422P: //< planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_range
case PIX_FMT_YUV440P: //< planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
case PIX_FMT_YUVJ440P: //< planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range
stride = 2;
break;
case PIX_FMT_YUV444P: //< planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
case PIX_FMT_YUVJ444P: //< planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_range
stride = 1;
break;
default:
stride = 0;
break;
}
if (stride) {
scPicture->data[0] = (uint8_t*) pArray->pData;
scPicture->data[1] = (uint8_t*) neutral;
scPicture->data[2] = (uint8_t*) neutral;
scPicture->linesize[0] = width;
scPicture->linesize[1] = width / stride;
scPicture->linesize[2] = width / stride;
return(asynSuccess);
}
}
/* setup the input picture */
inPicture->data[0] = (uint8_t*) pArray->pData;
inPicture->linesize[0] = width * (Int16 + 1);
} else if ((pArray->ndims == 3) && (pArray->dims[0].size == 3) && (colorMode == NDColorModeRGB1)) {
width = (int) pArray->dims[1].size;
height = (int) pArray->dims[2].size;
if (Int16) {
pix_fmt = PIX_FMT_RGB48;
} else {
pix_fmt = PIX_FMT_RGB24;
}
/* setup the input picture */
inPicture->data[0] = (uint8_t*) pArray->pData;
inPicture->linesize[0] = width * (Int16 + 1) * 3;
} else {
asynPrint(pasynUser, ASYN_TRACE_ERROR,
"%s: unsupported array structure\n", functionName);
return(asynError);
}
/* setup the swscale ctx */
//.........这里部分代码省略.........
示例8: processCallbacks
/** Callback function that is called by the NDArray driver with new NDArray data.
* If the plugin is running then it attaches position data to the NDArray as NDAttributes
* and then passes the array on. If the plugin is not running then NDArrays are not
* passed through to the next plugin(s) in the chain.
* \param[in] pArray The NDArray from the callback.
*/
void NDPosPlugin::processCallbacks(NDArray *pArray)
{
int index = 0;
int running = NDPOS_IDLE;
int skip = 0;
int mode = 0;
int size = 0;
int duplicates = 0;
int dropped = 0;
int expectedID = 0;
int IDDifference = 0;
epicsInt32 IDValue = 0;
char IDName[MAX_STRING_SIZE];
static const char *functionName = "NDPosPlugin::processCallbacks";
// Call the base class method
NDPluginDriver::processCallbacks(pArray);
getIntegerParam(NDPos_Running, &running);
// We must maintain the size of the list ourselves, as calling
// size() on the list has a complexity of O(n) which causes a problem
// once we get into tens of thousands of items.
getIntegerParam(NDPos_CurrentQty, &size);
// Only attach the position data to the array if we are running
if (running == NDPOS_RUNNING){
getIntegerParam(NDPos_CurrentIndex, &index);
if (index >= size){
// We've reached the end of our positions, stop to make sure we don't overflow
setIntegerParam(NDPos_Running, NDPOS_IDLE);
running = NDPOS_IDLE;
} else {
// Read the ID parameter from the NDArray. If it cannot be found then abort
getStringParam(NDPos_IDName, MAX_STRING_SIZE, IDName);
// Check for IDName, if it is empty the we use the unique ID of the array
if (strcmp(IDName, "") == 0){
IDValue = pArray->uniqueId;
} else {
NDAttribute *IDAtt = pArray->pAttributeList->find(IDName);
if (IDAtt){
epicsInt32 IDValue;
if (IDAtt->getValue(NDAttrInt32, &IDValue, sizeof(epicsInt32)) == ND_ERROR){
// Error, unable to get the value from the ID attribute
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
"%s::%s ERROR: could not retrieve expected ID from attribute [%s]\n",
driverName, functionName, IDName);
setIntegerParam(NDPos_Running, NDPOS_IDLE);
running = NDPOS_IDLE;
}
} else {
// Error, unable to find the named ID attribute
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
"%s::%s ERROR: could not find attribute [%s]\n",
driverName, functionName, IDName);
setIntegerParam(NDPos_Running, NDPOS_IDLE);
running = NDPOS_IDLE;
}
}
if (running == NDPOS_RUNNING){
// Check the ID is the same as the expected index
getIntegerParam(NDPos_IDDifference, &IDDifference);
getIntegerParam(NDPos_ExpectedID, &expectedID);
if (expectedID < IDValue){
asynPrint(this->pasynUserSelf, ASYN_TRACE_WARNING,
"%s::%s WARNING: possible frame drop detected: expected ID [%d] received ID [%d]\n",
driverName, functionName, expectedID, IDValue);
// If expected is less than ID throw away positions and record dropped events
getIntegerParam(NDPos_MissingFrames, &dropped);
getIntegerParam(NDPos_Mode, &mode);
if (mode == MODE_DISCARD){
while ((expectedID < IDValue) && (size > 0)){
// The index will stay the same, and we need to pop the value out of the position array
positionArray.erase(positionArray.begin());
size--;
expectedID += IDDifference;
dropped++;
}
// If the size has dropped to zero then we've run out of positions, abort
if (size == 0){
setIntegerParam(NDPos_Running, NDPOS_IDLE);
running = NDPOS_IDLE;
}
setIntegerParam(NDPos_CurrentQty, size);
} else if (mode == MODE_KEEP){
while (expectedID < IDValue && (index < size)){
index++;
expectedID += IDDifference;
dropped++;
}
// If the index has reached the size of the array then we've run out of positions, abort
if (index == size){
setIntegerParam(NDPos_Running, NDPOS_IDLE);
running = NDPOS_IDLE;
}
setIntegerParam(NDPos_CurrentIndex, index);
}
//.........这里部分代码省略.........
示例9: openFile
/** Opens a TIFF file.
* \param[in] fileName The name of the file to open.
* \param[in] openMode Mask defining how the file should be opened; bits are
* NDFileModeRead, NDFileModeWrite, NDFileModeAppend, NDFileModeMultiple
* \param[in] pArray A pointer to an NDArray; this is used to determine the array and attribute properties.
*/
asynStatus NDFileTIFF::openFile(const char *fileName, NDFileOpenMode_t openMode, NDArray *pArray)
{
/* When we create TIFF variables and dimensions, we get back an
* ID for each one. */
static const char *functionName = "openFile";
size_t sizeX, sizeY, rowsPerStrip;
int bitsPerSample=8, sampleFormat=SAMPLEFORMAT_INT, samplesPerPixel, photoMetric, planarConfig;
int colorMode=NDColorModeMono;
NDAttribute *pAttribute = NULL;
char tagString[MAX_ATTRIBUTE_STRING_SIZE] = {0};
char attrString[MAX_ATTRIBUTE_STRING_SIZE] = {0};
/* We don't support reading yet */
if (openMode & NDFileModeRead) return(asynError);
/* We don't support opening an existing file for appending yet */
if (openMode & NDFileModeAppend) return(asynError);
/* Create the file. */
if ((this->output = TIFFOpen(fileName, "w")) == NULL ) {
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
"%s:%s error opening file %s\n",
driverName, functionName, fileName);
return(asynError);
}
/* We do some special treatment based on colorMode */
pAttribute = pArray->pAttributeList->find("ColorMode");
if (pAttribute) pAttribute->getValue(NDAttrInt32, &colorMode);
switch (pArray->dataType) {
case NDInt8:
sampleFormat = SAMPLEFORMAT_INT;
bitsPerSample = 8;
break;
case NDUInt8:
sampleFormat = SAMPLEFORMAT_UINT;
bitsPerSample = 8;
break;
case NDInt16:
sampleFormat = SAMPLEFORMAT_INT;
bitsPerSample = 16;
break;
case NDUInt16:
sampleFormat = SAMPLEFORMAT_UINT;
bitsPerSample = 16;
break;
case NDInt32:
sampleFormat = SAMPLEFORMAT_INT;
bitsPerSample = 32;
break;
case NDUInt32:
sampleFormat = SAMPLEFORMAT_UINT;
bitsPerSample = 32;
break;
case NDFloat32:
sampleFormat = SAMPLEFORMAT_IEEEFP;
bitsPerSample = 32;
break;
case NDFloat64:
sampleFormat = SAMPLEFORMAT_IEEEFP;
bitsPerSample = 64;
break;
}
if (pArray->ndims == 2) {
sizeX = pArray->dims[0].size;
sizeY = pArray->dims[1].size;
rowsPerStrip = sizeY;
samplesPerPixel = 1;
photoMetric = PHOTOMETRIC_MINISBLACK;
planarConfig = PLANARCONFIG_CONTIG;
this->colorMode = NDColorModeMono;
} else if ((pArray->ndims == 3) && (pArray->dims[0].size == 3) && (colorMode == NDColorModeRGB1)) {
sizeX = pArray->dims[1].size;
sizeY = pArray->dims[2].size;
rowsPerStrip = sizeY;
samplesPerPixel = 3;
photoMetric = PHOTOMETRIC_RGB;
planarConfig = PLANARCONFIG_CONTIG;
this->colorMode = NDColorModeRGB1;
} else if ((pArray->ndims == 3) && (pArray->dims[1].size == 3) && (colorMode == NDColorModeRGB2)) {
sizeX = pArray->dims[0].size;
sizeY = pArray->dims[2].size;
rowsPerStrip = 1;
samplesPerPixel = 3;
photoMetric = PHOTOMETRIC_RGB;
planarConfig = PLANARCONFIG_SEPARATE;
this->colorMode = NDColorModeRGB2;
} else if ((pArray->ndims == 3) && (pArray->dims[2].size == 3) && (colorMode == NDColorModeRGB3)) {
sizeX = pArray->dims[0].size;
sizeY = pArray->dims[1].size;
rowsPerStrip = sizeY;
samplesPerPixel = 3;
photoMetric = PHOTOMETRIC_RGB;
planarConfig = PLANARCONFIG_SEPARATE;
//.........这里部分代码省略.........
示例10: processCallbacks
/**
* \param[in] pArray The NDArray from the callback.
*/
void NDPluginAttribute::processCallbacks(NDArray *pArray)
{
/*
* This function is called with the mutex already locked. It unlocks it during long calculations when private
* structures don't need to be protected.
*/
int status = 0;
int currentTSPoint;
int numTSPoints;
int TSAcquiring;
double valueSum;
int i;
char attrName[MAX_ATTR_NAME_] = {0};
NDAttribute *pAttribute = NULL;
NDAttributeList *pAttrList = NULL;
epicsFloat64 attrValue = 0.0;
static const char *functionName = "NDPluginAttribute::processCallbacks";
/* Call the base class method */
NDPluginDriver::beginProcessCallbacks(pArray);
/* Get the attributes for this driver */
pAttrList = pArray->pAttributeList;
getIntegerParam(NDPluginAttributeTSCurrentPoint, ¤tTSPoint);
getIntegerParam(NDPluginAttributeTSNumPoints, &numTSPoints);
getIntegerParam(NDPluginAttributeTSAcquiring, &TSAcquiring);
for (i=0; i<maxAttributes_; i++) {
getStringParam(i, NDPluginAttributeAttrName, MAX_ATTR_NAME_, attrName);
asynPrint(this->pasynUserSelf, ASYN_TRACE_FLOW, "Finding the attribute %s\n", attrName);
if (strcmp(attrName, UNIQUE_ID_NAME_) == 0) {
attrValue = (epicsFloat64) pArray->uniqueId;
} else if (strcmp(attrName, TIMESTAMP_NAME_) == 0) {
attrValue = pArray->timeStamp;
} else if (strcmp(attrName, EPICS_TS_SEC_NAME_) == 0) {
attrValue = (epicsFloat64)pArray->epicsTS.secPastEpoch;
} else if (strcmp(attrName, EPICS_TS_NSEC_NAME_) == 0) {
attrValue = (epicsFloat64)pArray->epicsTS.nsec;
} else {
pAttribute = pAttrList->find(attrName);
if (pAttribute) {
status = pAttribute->getValue(NDAttrFloat64, &attrValue);
if (status != asynSuccess) {
asynPrint(this->pasynUserSelf, ASYN_TRACE_FLOW, "%s: Error reading value for NDAttribute %s. \n", functionName, attrName);
continue;
}
asynPrint(this->pasynUserSelf, ASYN_TRACE_FLOW, "Attribute %s value is %f\n", attrName, attrValue);
} else {
asynPrint(this->pasynUserSelf, ASYN_TRACE_FLOW, "%s: Error finding NDAttribute %s. \n", functionName, attrName);
continue;
}
}
setDoubleParam(i, NDPluginAttributeVal, attrValue);
getDoubleParam(i, NDPluginAttributeValSum, &valueSum);
valueSum += attrValue;
setDoubleParam(i, NDPluginAttributeValSum, valueSum);
if (TSAcquiring) {
pTSArray_[i][currentTSPoint] = attrValue;
}
callParamCallbacks(i);
}
if (TSAcquiring) {
currentTSPoint++;
setIntegerParam(NDPluginAttributeTSCurrentPoint, currentTSPoint);
if (currentTSPoint >= numTSPoints) {
doTimeSeriesCallbacks();
setIntegerParam(NDPluginAttributeTSAcquiring, 0);
}
}
}
示例11: writeFileBase
//.........这里部分代码省略.........
/* Write the file */
if (!this->pCapture) {
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
"%s:%s: ERROR, no capture buffer present\n",
driverName, functionName);
setIntegerParam(NDFileWriteStatus, NDFileWriteError);
setStringParam(NDFileWriteMessage, "ERROR, no capture buffer present");
break;
}
setIntegerParam(NDWriteFile, 1);
callParamCallbacks();
if (this->supportsMultipleArrays)
status = this->openFileBase(NDFileModeWrite | NDFileModeMultiple, this->pArrays[0]);
if (status == asynSuccess) {
for (i=0; i<numCaptured; i++) {
pArray = this->pCapture[i];
if (!this->supportsMultipleArrays)
status = this->openFileBase(NDFileModeWrite, pArray);
if (status == asynSuccess) {
this->unlock();
epicsMutexLock(this->fileMutexId);
status = this->writeFile(pArray);
epicsMutexUnlock(this->fileMutexId);
this->lock();
if (status) {
epicsSnprintf(errorMessage, sizeof(errorMessage)-1,
"Error writing file, status=%d", status);
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
"%s:%s %s\n",
driverName, functionName, errorMessage);
setIntegerParam(NDFileWriteStatus, NDFileWriteError);
setStringParam(NDFileWriteMessage, errorMessage);
} else {
if (!this->supportsMultipleArrays)
status = this->closeFileBase();
}
}
}
}
freeCaptureBuffer(numCapture);
if ((status == asynSuccess) && this->supportsMultipleArrays)
status = this->closeFileBase();
setIntegerParam(NDFileNumCaptured, 0);
setIntegerParam(NDWriteFile, 0);
callParamCallbacks();
break;
case NDFileModeStream:
if (!this->supportsMultipleArrays)
status = this->openFileBase(NDFileModeWrite | NDFileModeMultiple, this->pArrays[0]);
if (status == asynSuccess) {
this->unlock();
epicsMutexLock(this->fileMutexId);
status = this->writeFile(this->pArrays[0]);
epicsMutexUnlock(this->fileMutexId);
this->lock();
if (status) {
epicsSnprintf(errorMessage, sizeof(errorMessage)-1,
"Error writing file, status=%d", status);
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
"%s:%s %s\n",
driverName, functionName, errorMessage);
setIntegerParam(NDFileWriteStatus, NDFileWriteError);
setStringParam(NDFileWriteMessage, errorMessage);
} else {
if (!this->supportsMultipleArrays)
status = this->closeFileBase();
}
}
break;
default:
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
"%s:%s: ERROR, unknown fileWriteMode %d\n",
driverName, functionName, fileWriteMode);
break;
}
/* Check to see if we should delete the original file
* Only do this if all of the following conditions are met
* - DeleteOriginalFile is true
* - There were no errors above
* - The NDFullFileName attribute is present and contains a non-blank string
*/
getIntegerParam(NDFileDeleteDriverFile, &deleteDriverFile);
if ((status == asynSuccess) && deleteDriverFile) {
pAttribute = this->pArrays[0]->pAttributeList->find("DriverFileName");
if (pAttribute) {
status = pAttribute->getValue(NDAttrString, driverFileName, sizeof(driverFileName));
if ((status == asynSuccess) && (strlen(driverFileName) > 0)) {
status = remove(driverFileName);
if (status != 0) {
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
"%s:%s: error deleting file %s, error=%s\n",
driverName, functionName, driverFileName, strerror(errno));
}
}
}
}
return((asynStatus)status);
}
示例12: openFile
/** Opens a TIFF file.
* \param[in] fileName The name of the file to open.
* \param[in] openMode Mask defining how the file should be opened; bits are
* NDFileModeRead, NDFileModeWrite, NDFileModeAppend, NDFileModeMultiple
* \param[in] pArray A pointer to an NDArray; this is used to determine the array and attribute properties.
*/
asynStatus NDFileTIFF::openFile(const char *fileName, NDFileOpenMode_t openMode, NDArray *pArray)
{
/* When we create TIFF variables and dimensions, we get back an
* ID for each one. */
static const char *functionName = "openFile";
size_t sizeX, sizeY, rowsPerStrip;
int bitsPerSample=8, sampleFormat=SAMPLEFORMAT_INT, samplesPerPixel, photoMetric, planarConfig;
int colorMode=NDColorModeMono;
NDAttribute *pAttribute;
char ManufacturerString[MAX_ATTRIBUTE_STRING_SIZE] = "Unknown";
char ModelString[MAX_ATTRIBUTE_STRING_SIZE] = "Unknown";
/* We don't support reading yet */
if (openMode & NDFileModeRead) return(asynError);
/* We don't support opening an existing file for appending yet */
if (openMode & NDFileModeAppend) return(asynError);
/* Create the file. */
if ((this->output = TIFFOpen(fileName, "w")) == NULL ) {
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
"%s:%s error opening file %s\n",
driverName, functionName, fileName);
return(asynError);
}
/* We do some special treatment based on colorMode */
pAttribute = pArray->pAttributeList->find("ColorMode");
if (pAttribute) pAttribute->getValue(NDAttrInt32, &colorMode);
switch (pArray->dataType) {
case NDInt8:
sampleFormat = SAMPLEFORMAT_INT;
bitsPerSample = 8;
break;
case NDUInt8:
sampleFormat = SAMPLEFORMAT_UINT;
bitsPerSample = 8;
break;
case NDInt16:
sampleFormat = SAMPLEFORMAT_INT;
bitsPerSample = 16;
break;
case NDUInt16:
sampleFormat = SAMPLEFORMAT_UINT;
bitsPerSample = 16;
break;
case NDInt32:
sampleFormat = SAMPLEFORMAT_INT;
bitsPerSample = 32;
break;
case NDUInt32:
sampleFormat = SAMPLEFORMAT_UINT;
bitsPerSample = 32;
break;
case NDFloat32:
sampleFormat = SAMPLEFORMAT_IEEEFP;
bitsPerSample = 32;
break;
case NDFloat64:
sampleFormat = SAMPLEFORMAT_IEEEFP;
bitsPerSample = 64;
break;
}
if (pArray->ndims == 2) {
sizeX = pArray->dims[0].size;
sizeY = pArray->dims[1].size;
rowsPerStrip = sizeY;
samplesPerPixel = 1;
photoMetric = PHOTOMETRIC_MINISBLACK;
planarConfig = PLANARCONFIG_CONTIG;
this->colorMode = NDColorModeMono;
} else if ((pArray->ndims == 3) && (pArray->dims[0].size == 3) && (colorMode == NDColorModeRGB1)) {
sizeX = pArray->dims[1].size;
sizeY = pArray->dims[2].size;
rowsPerStrip = sizeY;
samplesPerPixel = 3;
photoMetric = PHOTOMETRIC_RGB;
planarConfig = PLANARCONFIG_CONTIG;
this->colorMode = NDColorModeRGB1;
} else if ((pArray->ndims == 3) && (pArray->dims[1].size == 3) && (colorMode == NDColorModeRGB2)) {
sizeX = pArray->dims[0].size;
sizeY = pArray->dims[2].size;
rowsPerStrip = 1;
samplesPerPixel = 3;
photoMetric = PHOTOMETRIC_RGB;
planarConfig = PLANARCONFIG_SEPARATE;
this->colorMode = NDColorModeRGB2;
} else if ((pArray->ndims == 3) && (pArray->dims[2].size == 3) && (colorMode == NDColorModeRGB3)) {
sizeX = pArray->dims[0].size;
sizeY = pArray->dims[1].size;
rowsPerStrip = sizeY;
samplesPerPixel = 3;
photoMetric = PHOTOMETRIC_RGB;
planarConfig = PLANARCONFIG_SEPARATE;
//.........这里部分代码省略.........
示例13: processNode
//.........这里部分代码省略.........
(strcmp (nodeValue, "NXsensor") ==0) ||
(strcmp (nodeValue, "NXcapillary") ==0) ||
(strcmp (nodeValue, "NXcollection") ==0) ||
(strcmp (nodeValue, "NXdetector_group") ==0) ||
(strcmp (nodeValue, "NXparameters") ==0) ||
(strcmp (nodeValue, "NXsubentry") ==0) ||
(strcmp (nodeValue, "NXxraylens") ==0) ||
(nodeType && strcmp (nodeType, "UserGroup") == 0) ) {
nodeName = curNode->ToElement()->Attribute("name");
if (nodeName == NULL) {
nodeName = nodeValue;
}
stat = NXmakegroup(this->nxFileHandle, (const char *)nodeName, (const char *)nodeValue);
stat |= NXopengroup(this->nxFileHandle, (const char *)nodeName, (const char *)nodeValue);
if (stat != NX_OK ) {
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
"%s:%s Error creating group %s %s\n",
driverName, functionName, nodeName, nodeValue);
}
this->iterateNodes(curNode, pArray);
stat = NXclosegroup(this->nxFileHandle);
if (stat != NX_OK ) {
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
"%s:%s Error closing group %s %s\n",
driverName, functionName, nodeName, nodeValue);
}
}
else if (strcmp (nodeValue, "Attr") ==0) {
nodeName = curNode->ToElement()->Attribute("name");
nodeSource = curNode->ToElement()->Attribute("source");
if (nodeType && strcmp(nodeType, "ND_ATTR") == 0 ) {
pAttr = this->pFileAttributes->find(nodeSource);
if (pAttr != NULL ){
pAttr->getValueInfo(&attrDataType, &attrDataSize);
this->getAttrTypeNSize(pAttr, &dataOutType, &wordSize);
if (dataOutType > 0) {
pValue = calloc( attrDataSize, wordSize );
pAttr->getValue(attrDataType, (char *)pValue, attrDataSize*wordSize);
NXputattr(this->nxFileHandle, nodeName, pValue, (int)(attrDataSize/wordSize), dataOutType);
free(pValue);
}
}
else {
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
"%s:%s Could not find attribute named %s\n",
driverName, functionName, nodeSource);
}
}
else if (nodeType && strcmp(nodeType, "CONST") == 0 ) {
this->findConstText( curNode, nodeText);
nodeOuttype = curNode->ToElement()->Attribute("outtype");
if (nodeOuttype == NULL){
nodeOuttype = "NX_CHAR";
}
dataOutType = this->typeStringToVal((const char *)nodeOuttype);
if ( dataOutType == NX_CHAR ) {
nodeTextLen = strlen(nodeText);
}
else {
nodeTextLen = 1;
}
pValue = allocConstValue( dataOutType, nodeTextLen);
constTextToDataType(nodeText, dataOutType, pValue);
示例14: getInfo
/** Convenience method returns information about an NDArray, including the total number of elements,
* the number of bytes per element, and the total number of bytes in the array.
\param[out] pInfo Pointer to an NDArrayInfo_t structure, must have been allocated by caller. */
int NDArray::getInfo(NDArrayInfo_t *pInfo)
{
int i;
NDAttribute *pAttribute;
switch(this->dataType) {
case NDInt8:
pInfo->bytesPerElement = sizeof(epicsInt8);
break;
case NDUInt8:
pInfo->bytesPerElement = sizeof(epicsUInt8);
break;
case NDInt16:
pInfo->bytesPerElement = sizeof(epicsInt16);
break;
case NDUInt16:
pInfo->bytesPerElement = sizeof(epicsUInt16);
break;
case NDInt32:
pInfo->bytesPerElement = sizeof(epicsInt32);
break;
case NDUInt32:
pInfo->bytesPerElement = sizeof(epicsUInt32);
break;
case NDFloat32:
pInfo->bytesPerElement = sizeof(epicsFloat32);
break;
case NDFloat64:
pInfo->bytesPerElement = sizeof(epicsFloat64);
break;
default:
return(ND_ERROR);
break;
}
pInfo->nElements = 1;
for (i=0; i<this->ndims; i++) pInfo->nElements *= this->dims[i].size;
pInfo->totalBytes = pInfo->nElements * pInfo->bytesPerElement;
pInfo->colorMode = NDColorModeMono;
pAttribute = this->pAttributeList->find("ColorMode");
if (pAttribute) pAttribute->getValue(NDAttrInt32, &pInfo->colorMode);
pInfo->xDim = 0;
pInfo->yDim = 0;
pInfo->colorDim = 0;
pInfo->xSize = 0;
pInfo->ySize = 0;
pInfo->colorSize = 0;
pInfo->xStride = 0;
pInfo->yStride = 0;
pInfo->colorStride = 0;
if (this->ndims > 0) {
pInfo->xStride = 1;
pInfo->xSize = this->dims[0].size;
}
if (this->ndims > 1) {
pInfo->yDim = 1;
pInfo->yStride = pInfo->xSize;
pInfo->ySize = this->dims[1].size;
}
if (this->ndims == 3) {
switch (pInfo->colorMode) {
case NDColorModeRGB1:
pInfo->xDim = 1;
pInfo->yDim = 2;
pInfo->colorDim = 0;
pInfo->xStride = this->dims[0].size;
pInfo->yStride = this->dims[0].size * this->dims[1].size;
pInfo->colorStride = 1;
break;
case NDColorModeRGB2:
pInfo->xDim = 0;
pInfo->yDim = 2;
pInfo->colorDim = 1;
pInfo->xStride = 1;
pInfo->yStride = this->dims[0].size * this->dims[1].size;
pInfo->colorStride = this->dims[0].size;
break;
case NDColorModeRGB3:
pInfo->xDim = 0;
pInfo->yDim = 1;
pInfo->colorDim = 2;
pInfo->xStride = 1;
pInfo->yStride = this->dims[0].size;
pInfo->colorStride = this->dims[0].size * this->dims[1].size;
break;
default:
break;
}
pInfo->xSize = this->dims[pInfo->xDim].size;
pInfo->ySize = this->dims[pInfo->yDim].size;
pInfo->colorSize = this->dims[pInfo->colorDim].size;
}
return(ND_SUCCESS);
}
示例15: openFile
/** Opens a Magick file.
* \param[in] fileName The name of the file to open.
* \param[in] openMode Mask defining how the file should be opened; bits are
* NDFileModeRead, NDFileModeWrite, NDFileModeAppend, NDFileModeMultiple
* \param[in] pArray A pointer to an NDArray; this is used to determine the array and attribute properties.
*/
asynStatus NDFileMagick::openFile(const char *fileName, NDFileOpenMode_t openMode, NDArray *pArray)
{
static const char *functionName = "openFile";
NDAttribute *pAttribute;
/* We don't support reading yet */
if (openMode & NDFileModeRead) return(asynError);
/* We don't support opening an existing file for appending yet */
if (openMode & NDFileModeAppend) return(asynError);
strncpy(this->fileName, fileName, sizeof(this->fileName));
this->colorMode = NDColorModeMono;
/* We do some special treatment based on colorMode */
pAttribute = pArray->pAttributeList->find("ColorMode");
if (pAttribute) pAttribute->getValue(NDAttrInt32, &this->colorMode);
switch (pArray->dataType) {
case NDInt8:
case NDUInt8:
this->storageType = CharPixel;
break;
case NDInt16:
case NDUInt16:
this->storageType = ShortPixel;
break;
case NDInt32:
case NDUInt32:
this->storageType = IntegerPixel;
break;
case NDFloat32:
this->storageType = FloatPixel;
break;
case NDFloat64:
this->storageType = DoublePixel;
break;
}
if (pArray->ndims == 2) {
sizeX = pArray->dims[0].size;
sizeY = pArray->dims[1].size;
this->colorMap = "R";
this->imageType = GrayscaleType;
} else if ((pArray->ndims == 3) && (pArray->dims[0].size == 3) && (this->colorMode == NDColorModeRGB1)) {
sizeX = pArray->dims[1].size;
sizeY = pArray->dims[2].size;
this->colorMap = "RGB";
this->imageType = TrueColorType;
} else if ((pArray->ndims == 3) && (pArray->dims[1].size == 3) && (this->colorMode == NDColorModeRGB2)) {
sizeX = pArray->dims[0].size;
sizeY = pArray->dims[2].size;
this->colorMap = "RGB";
this->imageType = TrueColorType;
} else if ((pArray->ndims == 3) && (pArray->dims[2].size == 3) && (this->colorMode == NDColorModeRGB3)) {
sizeX = pArray->dims[0].size;
sizeY = pArray->dims[1].size;
this->colorMap = "RGB";
this->imageType = TrueColorType;
} else {
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
"%s:%s: unsupported array structure\n",
driverName, functionName);
return(asynError);
}
return(asynSuccess);
}