Skip to content

Commit

Permalink
Configurable CA priority of PVAttribute (areaDetector#491)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoqiangwang committed May 24, 2023
1 parent 49f9cce commit 954e57f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
5 changes: 3 additions & 2 deletions ADApp/ADSrc/PVAttribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ static asynUser *pasynUserSelf = NULL;
* \param[in] dbrType The EPICS DBR_XXX type to be used (DBR_STRING, DBR_DOUBLE, etc).
* In addition to the normal DBR types a special type, DBR_NATIVE, may be used,
* which means to use the native data type returned by Channel Access for this PV.
* \param[in] priority The priority level of the CA channel, 0 the lowest and 99 the highest.
*/
PVAttribute::PVAttribute(const char *pName, const char *pDescription,
const char *pSource, chtype dbrType)
const char *pSource, chtype dbrType, int priority)
: NDAttribute(pName, pDescription, NDAttrSourceEPICSPV, pSource, NDAttrUndefined, 0),
dbrType(dbrType), callbackString(0), connectedOnce(false)
{
Expand Down Expand Up @@ -63,7 +64,7 @@ PVAttribute::PVAttribute(const char *pName, const char *pDescription,
return;
}
/* Set connection callback on this PV */
SEVCHK(ca_create_channel(pSource, connectCallbackC, this, 10 ,&this->chanId),
SEVCHK(ca_create_channel(pSource, connectCallbackC, this, priority, &this->chanId),
"ca_create_channel");
}

Expand Down
2 changes: 1 addition & 1 deletion ADApp/ADSrc/PVAttribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
class ADCORE_API PVAttribute : public NDAttribute {
public:
PVAttribute(const char *pName, const char *pDescription, const char *pSource, chtype dbrType);
PVAttribute(const char *pName, const char *pDescription, const char *pSource, chtype dbrType, int priority);
PVAttribute(PVAttribute& attribute);
~PVAttribute();
PVAttribute* copy(NDAttribute *pAttribute);
Expand Down
8 changes: 7 additions & 1 deletion ADApp/ADSrc/asynNDArrayDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <libxml/parser.h>

#include <epicsAlgorithm.h>
#include <epicsString.h>
#include <epicsThread.h>
#include <macLib.h>
Expand Down Expand Up @@ -429,11 +430,16 @@ asynStatus asynNDArrayDriver::readNDAttributesFile()
return asynError;
}
}
// CA priority level
const char *pPriority = (const char *)xmlGetProp(Attr, (const xmlChar *)"priority");
int priority = 10;
if (pPriority) priority = epicsMin(99L, epicsMax(0L, strtol(pPriority, NULL, 0)));

asynPrint(pasynUserSelf, ASYN_TRACEIO_DRIVER,
"%s:%s: Name=%s, PVName=%s, pDBRType=%s, dbrType=%d, pDescription=%s\n",
driverName, functionName, pName, pSource, pDBRType, dbrType, pDescription);
#ifndef EPICS_LIBCOM_ONLY
PVAttribute *pPVAttribute = new PVAttribute(pName, pDescription, pSource, dbrType);
PVAttribute *pPVAttribute = new PVAttribute(pName, pDescription, pSource, dbrType, priority);
this->pAttributeList->add(pPVAttribute);
#endif
} else if (strcmp(pAttrType, NDAttribute::attrSourceString(NDAttrSourceParam)) == 0) {
Expand Down
9 changes: 9 additions & 0 deletions XML_schema/NDAttributes.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="priority" type="xs:int" default="10">
<!-- only for type="EPICS_PV" -->
<xs:annotation>
<xs:documentation>
Declares the dispatch priority within the server for an
EPICS Process Variable.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="param" type="xs:string" default="">
<!-- only for type="FUNCTION" -->
<xs:annotation>
Expand Down

0 comments on commit 954e57f

Please sign in to comment.