Experimental Physics and
Since there are many fields in the Motor record, many of which aren't needed for most use cases, a Motor object does not try to connect to all fields at initialization but instead trie to connect to a particular field only when necessary (ie, as late as possible). Currently this means that __getattr__() and __setattr__() will treat any unknown attribute as a potential PV, so that
>>> print m1.RBV
>>> m1.VAL = 2.0 # puts to VAL field
>>> print m1.VAL # gets VAL field
__getattr__() and __setattr__() for getting/setting instance attributes that are internally mapped to fields of the appropriate device. That is, one can do
Hi Terry,Sorry for the trouble. The Device classes in pyepics, including the Motor class, are a little unusual in that they override
>>> from epics import Motor
>>> m1 = Motor('XXX:m1')
>>> print m1.FOO
will hang for a while, trying to connect to 'XXX:m1.FOO', eventually returning None.
Right now, the list of "attributes to not convert to PVs" is hardwired into the Motor class (and other Devices too), and I don't think it can be easily altered by a subclass. At least, I don't see an easy way to do that.
It would certainly be reasonable to change this behavior. I think it might be preferable to have an explicit list of attributes that will be converted to PVs rather than trying to convert every unknown attribute to a PV. That would better allow subclassing, and avoid silent hanging on typos. This might take a little effort, but is probably worth it.
On Wed, May 28, 2014 at 7:33 PM, Terry Cornall <Terry.Cornall@synchrotron.org.au> wrote:
--Matt Newville <newville at cars.uchicago.edu> 630-252-0431
|ANJ, 17 Dec 2015||
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·