Here is a simple example. It monitors a PV ‘catest’ and synchronise its value to `MTEST:PROXY’
######
from pcaspy import Driver, SimpleServer
from CaChannel import ca, CaChannel
prefix = 'MTEST:'
pvdb = {
'PROXY': {
}
}
class myDriver(Driver):
def __init__(self):
Driver.__init__(self)
self.chan = CaChannel('catest')
self.chan.searchw()
self.chan.add_masked_array_event(None, None, None, self.value_callback)
def value_callback(self, epics_args, user_args):
self.setParam('PROXY', epics_args['pv_value'])
self.updatePVs()
if __name__ == '__main__':
server = SimpleServer()
server.createPV(prefix, pvdb)
driver = myDriver()
while True:
# process CA transactions
server.process(0.1)
#######
> On 30 Mar 2017, at 17:45, lzf neu <[email protected]> wrote:
>
> Thank you!
>
> I have a new question to consult you:
>
> I want to get the return value of caget('some PV name') by writing Pcaspy script. I have no idear what command to use in the script.
> Any suggestions will be appreciated !
> 发件人: Kasemir, Kay <[email protected]>
> 发送时间: 2017年3月29日 12:46:30
> 收件人: lzf neu
> 抄送: [email protected]
> 主题: Re: Question about PV name by using pcaspy
>
>
>> On Mar 29, 2017, at 3:37 AM, lzf neu <[email protected]> wrote:
>>
>> Hi,
>>
>> I want to fulfill a goal that when running camonitor command, PV name TEST:PING in the terminal window print "Disconnect!" or "OK!" alternatively.
>>
>> However, I failed, "self.setParam('PING',a)" seems only run once in the code and in terminal window only print one result.
>>
>> I have posted the code in the following lines.
>>
>> Could you give me some suggestions and any help will be appreciated.
>
>
> You’re missing a call to
> self.updatePVs()
>
> -Kay
>
>
>>
>> Zhefu
>>
>> #===============================
>> #!/usr/bin/env python
>> import os
>> import threading
>> import time
>>
>> from pcaspy import Driver, SimpleServer
>> prefix = 'TEST:'
>> pvdb = {
>> 'PING' : {
>> 'type':'enum',
>> 'enums':['Disconnect!','OK!']
>> },
>> }
>>
>> class myDriver(Driver):
>> def __init__(self):
>> super(myDriver, self).__init__()
>> tid=threading.Thread(target=self.determine)
>> tid.setDaemon(True)
>> tid.start()
>>
>> def determine(self):
>> a=os.system("ping -c 1 -w 1 127.0.0.1")
>> if (a==0):
>> while True:
>> self.setParam('PING',a)
>> a=not a
>> time.sleep(5)
>>
>> if __name__ == '__main__':
>> server = SimpleServer()
>> server.createPV(prefix, pvdb)
>> driver = myDriver()
>>
>> # process CA transactions
>> while True:
>> server.process(0.1)
>
- References:
- Question about PV name by using pcaspy lzf neu
- Re: Question about PV name by using pcaspy Kasemir, Kay
- 答复: Question about PV name by using pcaspy lzf neu
- Navigate by Date:
- Prev:
PCAS (using pcaspy) in docker ""server isnt attached to a network" Sparger, John E.
- Next:
Re: PCAS (using pcaspy) in docker ""server isnt attached to a network" Andrew Johnson
- 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:
答复: Question about PV name by using pcaspy lzf neu
- Next:
PCAS (using pcaspy) in docker ""server isnt attached to a network" Sparger, John E.
- 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
|