specify raw dset in py module
This commit is contained in:
@ -11,7 +11,6 @@
|
|||||||
#include <dbStaticLib.h>
|
#include <dbStaticLib.h>
|
||||||
#include <dbAccess.h>
|
#include <dbAccess.h>
|
||||||
#include <devSup.h>
|
#include <devSup.h>
|
||||||
#include <dbLink.h>
|
|
||||||
#include <recGbl.h>
|
#include <recGbl.h>
|
||||||
#include <alarm.h>
|
#include <alarm.h>
|
||||||
#include <ellLib.h>
|
#include <ellLib.h>
|
||||||
@ -33,6 +32,8 @@ typedef struct {
|
|||||||
PyObject *support;
|
PyObject *support;
|
||||||
PyObject *scanobj;
|
PyObject *scanobj;
|
||||||
|
|
||||||
|
int rawsupport;
|
||||||
|
|
||||||
IOSCANPVT scan;
|
IOSCANPVT scan;
|
||||||
|
|
||||||
PyObject *reason;
|
PyObject *reason;
|
||||||
@ -62,6 +63,15 @@ static long parse_link(dbCommon *prec, const char* src)
|
|||||||
Py_INCREF(priv->support);
|
Py_INCREF(priv->support);
|
||||||
Py_DECREF(ret);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +183,10 @@ static long init_record(dbCommon *prec)
|
|||||||
|
|
||||||
static long init_record2(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)
|
static long add_record(dbCommon *prec)
|
||||||
@ -331,8 +344,9 @@ static long process_record(dbCommon *prec)
|
|||||||
|
|
||||||
static long process_record2(dbCommon *prec)
|
static long process_record2(dbCommon *prec)
|
||||||
{
|
{
|
||||||
|
pyDevice *priv = prec->dpvt;
|
||||||
long ret = process_record(prec);
|
long ret = process_record(prec);
|
||||||
if(ret==0)
|
if(ret==0 && priv && priv->rawsupport)
|
||||||
ret = 2;
|
ret = 2;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -375,24 +389,24 @@ typedef struct {
|
|||||||
DEVSUPFUN linconv;
|
DEVSUPFUN linconv;
|
||||||
} dset6;
|
} dset6;
|
||||||
|
|
||||||
static dset6 pydevsupCom = {{6, (DEVSUPFUN)&report, (DEVSUPFUN)&init,
|
static dset6 pydevsupComSpec = {{6, (DEVSUPFUN)&report, (DEVSUPFUN)&init,
|
||||||
(DEVSUPFUN)&init_record,
|
(DEVSUPFUN)&init_record,
|
||||||
(DEVSUPFUN)&get_iointr_info},
|
(DEVSUPFUN)&get_iointr_info},
|
||||||
(DEVSUPFUN)&process_record};
|
(DEVSUPFUN)&process_record};
|
||||||
static dset6 pydevsupComOut2 = {{6, (DEVSUPFUN)&report, (DEVSUPFUN)&init,
|
static dset6 pydevsupComOut = {{6, (DEVSUPFUN)&report, (DEVSUPFUN)&init,
|
||||||
(DEVSUPFUN)&init_record2,
|
(DEVSUPFUN)&init_record2,
|
||||||
(DEVSUPFUN)&get_iointr_info},
|
(DEVSUPFUN)&get_iointr_info},
|
||||||
(DEVSUPFUN)&process_record};
|
(DEVSUPFUN)&process_record};
|
||||||
static dset6 pydevsupComIn2 = {{6, (DEVSUPFUN)&report, (DEVSUPFUN)&init,
|
static dset6 pydevsupComIn = {{6, (DEVSUPFUN)&report, (DEVSUPFUN)&init,
|
||||||
(DEVSUPFUN)&init_record,
|
(DEVSUPFUN)&init_record,
|
||||||
(DEVSUPFUN)&get_iointr_info},
|
(DEVSUPFUN)&get_iointr_info},
|
||||||
(DEVSUPFUN)&process_record2};
|
(DEVSUPFUN)&process_record2};
|
||||||
|
|
||||||
int isPyRecord(dbCommon *prec)
|
int isPyRecord(dbCommon *prec)
|
||||||
{
|
{
|
||||||
return prec->dset==(dset*)&pydevsupCom
|
return prec->dset==(dset*)&pydevsupComSpec
|
||||||
|| prec->dset==(dset*)&pydevsupComIn2
|
|| prec->dset==(dset*)&pydevsupComIn
|
||||||
|| prec->dset==(dset*)&pydevsupComOut2;
|
|| prec->dset==(dset*)&pydevsupComOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
int canIOScanRecord(dbCommon *prec)
|
int canIOScanRecord(dbCommon *prec)
|
||||||
@ -433,6 +447,6 @@ void pyDBD_cleanup(void)
|
|||||||
|
|
||||||
#include <epicsExport.h>
|
#include <epicsExport.h>
|
||||||
|
|
||||||
epicsExportAddress(dset, pydevsupCom);
|
epicsExportAddress(dset, pydevsupComSpec);
|
||||||
epicsExportAddress(dset, pydevsupComIn2);
|
epicsExportAddress(dset, pydevsupComIn);
|
||||||
epicsExportAddress(dset, pydevsupComOut2);
|
epicsExportAddress(dset, pydevsupComOut);
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
registrar(pySetupReg)
|
registrar(pySetupReg)
|
||||||
|
|
||||||
device(longin, INST_IO, pydevsupCom, "Python Device")
|
device(longin, INST_IO, pydevsupComIn, "Python Device")
|
||||||
device(longout, INST_IO, pydevsupCom, "Python Device")
|
device(longout, INST_IO, pydevsupComOut, "Python Device")
|
||||||
|
|
||||||
device(ai, INST_IO, pydevsupCom, "Python Device")
|
device(ai, INST_IO, pydevsupComIn, "Python Device")
|
||||||
device(ao, INST_IO, pydevsupCom, "Python Device")
|
device(ao, INST_IO, pydevsupComOut, "Python Device")
|
||||||
|
|
||||||
device(ai, INST_IO, pydevsupComIn2, "Raw Python Device")
|
device(waveform, INST_IO, pydevsupComIn, "Python Device")
|
||||||
device(ao, INST_IO, pydevsupComOut2, "Raw Python Device")
|
|
||||||
|
|
||||||
device(waveform, INST_IO, pydevsupCom, "Python Device")
|
|
||||||
|
@ -53,6 +53,15 @@ and the string "some other string".
|
|||||||
The module :mod:`devsup.interfaces` provides a Zope Interface
|
The module :mod:`devsup.interfaces` provides a Zope Interface
|
||||||
definition by this name which may be referenced.
|
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)
|
.. method:: process(record, reason)
|
||||||
|
|
||||||
:param record: :class:`Record <devsup.db.Record>` from which the request originated.
|
:param record: :class:`Record <devsup.db.Record>` from which the request originated.
|
||||||
@ -136,10 +145,6 @@ This support code can then be referenced from records. ::
|
|||||||
field(DTYP, "Python Device")
|
field(DTYP, "Python Device")
|
||||||
field(INP , "counter hello world")
|
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. ::
|
The following will fail to associate. ::
|
||||||
|
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
|
|
||||||
from zope.interface import Interface
|
from zope.interface import Interface, Attribute
|
||||||
|
|
||||||
class DeviceSupport(Interface):
|
class DeviceSupport(Interface):
|
||||||
|
|
||||||
|
raw = Attribute('True if this support modifies VAL instead of RVAL')
|
||||||
|
|
||||||
def detach(record):
|
def detach(record):
|
||||||
"""Disconnect from the record.
|
"""Disconnect from the record.
|
||||||
|
|
||||||
|
@ -33,16 +33,16 @@ record(longin, "$(P)async:cnt") {
|
|||||||
|
|
||||||
|
|
||||||
record(ao, "$(P):A-SP") {
|
record(ao, "$(P):A-SP") {
|
||||||
field(DTYP, "Raw Python Device")
|
field(DTYP, "Python Device")
|
||||||
field(OUT , "@test5 hello none")
|
field(OUT , "@test5 hello none")
|
||||||
}
|
}
|
||||||
|
|
||||||
record(ao, "$(P):B-SP") {
|
record(ao, "$(P):B-SP") {
|
||||||
field(DTYP, "Raw Python Device")
|
field(DTYP, "Python Device")
|
||||||
field(OUT , "@test5 hello half")
|
field(OUT , "@test5 hello half")
|
||||||
}
|
}
|
||||||
|
|
||||||
record(ai, "$(P):A-RB") {
|
record(ai, "$(P):A-RB") {
|
||||||
field(DTYP, "Raw Python Device")
|
field(DTYP, "Python Device")
|
||||||
field(INP , "@test5 hello none")
|
field(INP , "@test5 hello none")
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,9 @@ class UnitWorker(object):
|
|||||||
self.scan.interrupt(reason=values)
|
self.scan.interrupt(reason=values)
|
||||||
|
|
||||||
class UnitSupport(object):
|
class UnitSupport(object):
|
||||||
|
|
||||||
|
raw = True
|
||||||
|
|
||||||
def __init__(self, rec, args):
|
def __init__(self, rec, args):
|
||||||
worker, self.unit = args.split(None, 1)
|
worker, self.unit = args.split(None, 1)
|
||||||
try:
|
try:
|
||||||
|
Reference in New Issue
Block a user