Hi Janko,
I hope this is a right place to ask a question about pyepics.
I think it is.
I wrote a simple program to monitor their value:
import sys
import time
from epics import PV
def callback_function(pvname=None, value=None, char_value=None,
type=None,units=None, enum_strs=None, **kw):
print "------Printout from callback ------"
fmt = ' pvname \t = %s \n value \t\t = %s \n\
char_value \t = %s \n type \t\t = %s \n\
units \t\t = %s \n enum_strs \t = %s \n'
print fmt % (pvname, value, char_value, type, units, enum_strs)
print "----------------------------------\n"
pll = PV('LUCA:ENV:ENV_SC_PLL_MONITOR')
vent = PV('LUCA:ENV:ENV_FRONT_VENT_ACT_MONITOR')
pll.add_callback(callback_function)
pll.run_callbacks()
vent.add_callback(callback_function)
vent.run_callbacks()
while True:
time.sleep(0.001)
Sorry for the trouble.
The issue is that not all of the "extra control fields" (including the
names of the enumeration states, units, and precision) have been
determined when you do PV.run_callbacks(). That is only the "native
form" of the PV
The easiest fix is to explicitly make the control fields be looked up,
either with PV.get_ctrlvars() or PV.get(as_string=True) which also
makes sure that the "char_value" is well formed. That is, I think you
want
pll.add_callback(callback_function)
pll.get(as_string=True)
pll.run_callbacks()
vent.add_callback(callback_function)
vent.get(as_string=True)
vent.run_callbacks()
while True:
time.sleep(0.001)
Perhaps an option should be added to PV.add_callback() to make sure
the control fields are initialized. Either that, or this should be
better documented.
--Matt Newville <newville at cars.uchicago.edu> 630-252-0431