本文整理汇总了C++中NDAttribute::setValue方法的典型用法代码示例。如果您正苦于以下问题:C++ NDAttribute::setValue方法的具体用法?C++ NDAttribute::setValue怎么用?C++ NDAttribute::setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NDAttribute
的用法示例。
在下文中一共展示了NDAttribute::setValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: add
/** Adds an attribute to the list.
* This is a convenience function for adding attributes to a list.
* It first searches the list to see if there is an existing attribute
* with the same name. If there is it just changes the properties of the
* existing attribute. If not, it creates a new attribute with the
* specified properties.
* IMPORTANT: This method is only capable of creating attributes
* of the NDAttribute base class type, not derived class attributes.
* To add attributes of a derived class to a list the NDAttributeList::add(NDAttribute*)
* method must be used.
* \param[in] pName The name of the attribute to be added.
* \param[in] pDescription The description of the attribute.
* \param[in] dataType The data type of the attribute.
* \param[in] pValue A pointer to the value for this attribute.
*
*/
NDAttribute* NDAttributeList::add(const char *pName, const char *pDescription, NDAttrDataType_t dataType, void *pValue)
{
//const char *functionName = "NDAttributeList::add";
NDAttribute *pAttribute;
epicsMutexLock(this->lock);
pAttribute = this->find(pName);
if (pAttribute) {
pAttribute->setDescription(pDescription);
pAttribute->setValue(dataType, pValue);
} else {
pAttribute = new NDAttribute(pName, pDescription, dataType, pValue);
ellAdd(&this->list, &pAttribute->listNode.node);
}
epicsMutexUnlock(this->lock);
return(pAttribute);
}
示例2: 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;
}