Hi,
Here is the running demo adapted from your post. It runs the ping command every 5 seconds.
$ caget TEST:PING
TEST:PING Ok
#!/usr/bin/env python
import os
import threading
import time
from pcaspy import Driver, SimpleServer
prefix = 'TEST:'
pvdb = {
'PING' : {
'type': 'enum',
'enums': ['Unreachable', '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):
while True:
a=os.system("ping -c 1 -w 1 127.0.0.1")
if (a==0):
self.setParam('PING', True)
else:
self.setParam('PING', False)
time.sleep(5)
if __name__ == '__main__':
server = SimpleServer()
server.createPV(prefix, pvdb)
driver = myDriver()
# process CA transactions
while True:
server.process(0.1)
> On 06 Sep 2016, at 10:37, lzf neu <[email protected]> wrote:
>
> Hi all,
>
> i want to display the TEST:PING value in camonitor, which is the return value by ping 127.0.0.1.
> i know pcaspy can implement this, but i am newer in it.
> below is the pcaspy program i wrote and there is an error.
> Could you give me some advice and thanks in advance.
>
> #!/usr/bin/env python
> import os
> from pcaspy import Driver, SimpleServer
> prefix = 'TEST:'
> pvdb = {
> 'PING' : {
> a,
> },
> }
>
> class myDriver(Driver):
> def __init__(self):
> super(myDriver, self).__init__()
> def determine():
> a=os.system("ping -c 1 -w 1 127.0.0.1")
> if (a==0):
> print "communication established !"
>
> if __name__ == '__main__':
> server = SimpleServer()
> server.createPV(prefix, pvdb)
> driver = myDriver()
>
> # process CA transactions
> while True:
> server.process(0.1)
- References:
- Question about return ping value by using pcaspy in camonitor lzf neu
- Navigate by Date:
- Prev:
RE: ProcServ suggestion - add Date/Time to startup lines Mark Rivers
- Next:
Re: Support for CAEN SY4527 Jiro Fujita
- 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 return ping value by using pcaspy in camonitor lzf neu
- Next:
Question about display history data in the form of data reports table in CSS boy opi ? lzf neu
- 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
|