diff --git a/devsupApp/src/dbdset.c b/devsupApp/src/dbdset.c index 7d47308..37fd667 100644 --- a/devsupApp/src/dbdset.c +++ b/devsupApp/src/dbdset.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -33,6 +32,8 @@ typedef struct { PyObject *support; PyObject *scanobj; + int rawsupport; + IOSCANPVT scan; PyObject *reason; @@ -62,6 +63,15 @@ static long parse_link(dbCommon *prec, const char* src) Py_INCREF(priv->support); Py_DECREF(ret); + ret = PyObject_GetAttrString(priv->support, "raw"); + if(!ret) + PyErr_Clear(); + else if(ret && PyObject_IsTrue(ret)==1) + priv->rawsupport = 1; + Py_XDECREF(ret); + if(PyErr_Occurred()) + return -1; + return 0; } @@ -173,7 +183,10 @@ static long init_record(dbCommon *prec) static long init_record2(dbCommon *prec) { - return 2; + pyDevice *priv = prec->dpvt; + if(priv && priv->rawsupport) + return 2; + return 0; } static long add_record(dbCommon *prec) @@ -331,8 +344,9 @@ static long process_record(dbCommon *prec) static long process_record2(dbCommon *prec) { + pyDevice *priv = prec->dpvt; long ret = process_record(prec); - if(ret==0) + if(ret==0 && priv && priv->rawsupport) ret = 2; return ret; } @@ -375,24 +389,24 @@ typedef struct { DEVSUPFUN linconv; } dset6; -static dset6 pydevsupCom = {{6, (DEVSUPFUN)&report, (DEVSUPFUN)&init, +static dset6 pydevsupComSpec = {{6, (DEVSUPFUN)&report, (DEVSUPFUN)&init, (DEVSUPFUN)&init_record, (DEVSUPFUN)&get_iointr_info}, (DEVSUPFUN)&process_record}; -static dset6 pydevsupComOut2 = {{6, (DEVSUPFUN)&report, (DEVSUPFUN)&init, +static dset6 pydevsupComOut = {{6, (DEVSUPFUN)&report, (DEVSUPFUN)&init, (DEVSUPFUN)&init_record2, (DEVSUPFUN)&get_iointr_info}, (DEVSUPFUN)&process_record}; -static dset6 pydevsupComIn2 = {{6, (DEVSUPFUN)&report, (DEVSUPFUN)&init, +static dset6 pydevsupComIn = {{6, (DEVSUPFUN)&report, (DEVSUPFUN)&init, (DEVSUPFUN)&init_record, (DEVSUPFUN)&get_iointr_info}, (DEVSUPFUN)&process_record2}; int isPyRecord(dbCommon *prec) { - return prec->dset==(dset*)&pydevsupCom - || prec->dset==(dset*)&pydevsupComIn2 - || prec->dset==(dset*)&pydevsupComOut2; + return prec->dset==(dset*)&pydevsupComSpec + || prec->dset==(dset*)&pydevsupComIn + || prec->dset==(dset*)&pydevsupComOut; } int canIOScanRecord(dbCommon *prec) @@ -433,6 +447,6 @@ void pyDBD_cleanup(void) #include -epicsExportAddress(dset, pydevsupCom); -epicsExportAddress(dset, pydevsupComIn2); -epicsExportAddress(dset, pydevsupComOut2); +epicsExportAddress(dset, pydevsupComSpec); +epicsExportAddress(dset, pydevsupComIn); +epicsExportAddress(dset, pydevsupComOut); diff --git a/devsupApp/src/pyDevSup.dbd b/devsupApp/src/pyDevSup.dbd index f3d4f5c..d404e67 100644 --- a/devsupApp/src/pyDevSup.dbd +++ b/devsupApp/src/pyDevSup.dbd @@ -1,12 +1,9 @@ registrar(pySetupReg) -device(longin, INST_IO, pydevsupCom, "Python Device") -device(longout, INST_IO, pydevsupCom, "Python Device") +device(longin, INST_IO, pydevsupComIn, "Python Device") +device(longout, INST_IO, pydevsupComOut, "Python Device") -device(ai, INST_IO, pydevsupCom, "Python Device") -device(ao, INST_IO, pydevsupCom, "Python Device") +device(ai, INST_IO, pydevsupComIn, "Python Device") +device(ao, INST_IO, pydevsupComOut, "Python Device") -device(ai, INST_IO, pydevsupComIn2, "Raw Python Device") -device(ao, INST_IO, pydevsupComOut2, "Raw Python Device") - -device(waveform, INST_IO, pydevsupCom, "Python Device") +device(waveform, INST_IO, pydevsupComIn, "Python Device") diff --git a/documentation/interfaces.rst b/documentation/interfaces.rst index a7b7fc0..44186c7 100644 --- a/documentation/interfaces.rst +++ b/documentation/interfaces.rst @@ -53,6 +53,15 @@ and the string "some other string". The module :mod:`devsup.interfaces` provides a Zope Interface definition by this name which may be referenced. + .. attribute:: raw + + A boolean value indicating whether this device support + uses "raw" access. A Raw support module will update + the VAL field even if the recordtype has an RVAL field + (eg. ai/ao, mbbi/mbbo). + + Omitting this attribute is the same as False. + .. method:: process(record, reason) :param record: :class:`Record ` from which the request originated. @@ -136,10 +145,6 @@ This support code can then be referenced from records. :: field(DTYP, "Python Device") field(INP , "counter hello world") } - record(ai, "my:float:counter") { - field(DTYP, "Raw Python Device") - field(INP , "counter hello there") - } The following will fail to associate. :: diff --git a/python/devsup/interfaces.py b/python/devsup/interfaces.py index ec5c8c9..8c4ef7c 100644 --- a/python/devsup/interfaces.py +++ b/python/devsup/interfaces.py @@ -1,7 +1,10 @@ -from zope.interface import Interface +from zope.interface import Interface, Attribute class DeviceSupport(Interface): + + raw = Attribute('True if this support modifies VAL instead of RVAL') + def detach(record): """Disconnect from the record. diff --git a/testApp/test.db b/testApp/test.db index 86c4f91..a9123d1 100644 --- a/testApp/test.db +++ b/testApp/test.db @@ -33,16 +33,16 @@ record(longin, "$(P)async:cnt") { record(ao, "$(P):A-SP") { - field(DTYP, "Raw Python Device") + field(DTYP, "Python Device") field(OUT , "@test5 hello none") } record(ao, "$(P):B-SP") { - field(DTYP, "Raw Python Device") + field(DTYP, "Python Device") field(OUT , "@test5 hello half") } record(ai, "$(P):A-RB") { - field(DTYP, "Raw Python Device") + field(DTYP, "Python Device") field(INP , "@test5 hello none") } diff --git a/testApp/test5.py b/testApp/test5.py index cc0ede6..ab2dc53 100644 --- a/testApp/test5.py +++ b/testApp/test5.py @@ -41,6 +41,9 @@ class UnitWorker(object): self.scan.interrupt(reason=values) class UnitSupport(object): + + raw = True + def __init__(self, rec, args): worker, self.unit = args.split(None, 1) try: