I found the best thing for PyEpics devices was to only have attributes that are associated with PV's. All other non-PV attributes are handled using explicit getters and setters, e.g., 'motor.getXxx()' instead of 'motor.xxx'. That way I don't have to worry about anybody treating a non-PV attribute as though it were a PV attribute, e.g., trying to add a callback on it.
Mark
-----------------------------------------------
On Wed, May 28, 2014 at 7:33 PM, Terry Cornall <[email protected]> wrote:
Hi All.
I’ve been trying to subclass the Motor class in Pyepics, so I can add my own variables and methods to it, and I’ve run into problems.
Adding new methods seems to work just fine, but I find a strange problem when I try to add new ‘instance variables’ to my subclass.
They all end up having value ‘None’ if I add them after doing the __init__ of the base Motor class. Worse, if I try to define
them before I call the epics.Motor.__init__(), I get an exception from motor.py. This is not normal Python behaviour, as far as I know, and I’ve added code to test that I can subclass this way with a ‘simple’ python class, as shown below.
Any ideas what I am doing wrong, or why epics.Motor can’t be subclassed in this way?
Any suggestions as to how I can subclass it and add my own variables, or why I shouldn’t?
I suppose an alternative would be to make a class that contains an epics.Motor object rather than subclass it.
Thanks,
Terry
- Navigate by Date:
- Prev:
Re: subclassing Pyepics epics.motor doesn't work as expected Matt Newville
- Next:
caQtDM drag-and-drop workaround Mooney, Tim M.
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
<2014>
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
RE: subclassing Pyepics epics.motor doesn't work as expected Terry Cornall
- Next:
caQtDM drag-and-drop workaround Mooney, Tim M.
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
<2014>
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|