EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  <20182019  2020  2021  2022  2023  2024  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  <20182019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Problem concerning callback function on multiple channels by using Cachannel
From: lzf neu <[email protected]>
To: "[email protected]" <[email protected]>, "[email protected]" <[email protected]>
Date: Thu, 19 Jul 2018 14:45:50 +0000

Dear Dr. Wang and all, 


I have a problem concerning Cachannel to consult you please.


The manual says:

CaChannel.add_masked_array_event(...) can specify a callback function to be executed whenever changes occur to a PV.


For example, I have two PVs, one is 'caLab:okok_left', another one is 'caLab:okok_right', their values change continuously, I try to write the following codes to monitor them:


from CaChannel import ca, CaChannel

class myDriver(Driver):

    def __init__(self):
        Driver.__init__(self)
        self.chan_left = CaChannel('caLab:okok_left')  
        self.chan_left.searchw()
        self.chan_left.add_masked_array_event(None, None, None, self.value_callback_left)
        self.chan_right = CaChannel('caLab:okok_right')  
        self.chan_right.searchw()
        self.chan_right.add_masked_array_event(None, None, None, self.value_callback_right)

    def value_callback_left(self, epics_args_left, user_args_left):
        value_left=epics_args_left['pv_value']
        print "monitor caLab:okok_left"


    def value_callback_right(self, epics_args_right, user_args_right):
        value_right=epics_args_right['pv_value']

        print "monitor caLab:okok_right"


if __name__ == '__main__':
    server = SimpleServer()
    server.createPV(prefix, pvdb)
    driver = myDriver()
    while True:
        server.process(0.1)

However, It seems only the first PV('caLab:okok_left') is running and value_callback_left function works, the second one is blocked.

I looked up the manual and know the following codes can perform the search request at once, but I have no idea how to write the callback function for each PVs at once.:


from CaChannel import ca, CaChannel
chans = {pvname: CaChannel(pvname) for pvname in ['pv1', 'pv2', 'pv3', ...]}
for chan in chans.values():
chan.search()

Therefore, if I have two PVs or multiple PVs, how to specify callback function on two or multiple PVs at once.

Any help will be appreciated and could you please show me an example, thank you very much.


Zhefu




Replies:
Re: Problem concerning callback function on multiple channels by using Cachannel Matt Newville
Re: Problem concerning callback function on multiple channels by using Cachannel Wang Xiaoqiang (PSI)
Re: Problem concerning callback function on multiple channels by using Cachannel Wang Xiaoqiang (PSI)

Navigate by Date:
Prev: Re: Delta Tau Power Brick LV-IMS driver [email protected]
Next: Re: Problem concerning callback function on multiple channels by using Cachannel Matt Newville
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  <20182019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Rotating Image in NDPluginPva plugin Michael Davidsaver
Next: Re: Problem concerning callback function on multiple channels by using Cachannel Matt Newville
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  <20182019  2020  2021  2022  2023  2024 
ANJ, 19 Jul 2018 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·