Comments (9)
@ikunwang Hm, sorry for the trouble, but I'm not entirely sure why that would not work.
But also, what is 'distboard'? What happens if you take that out?
After you create status_PV
and add the callback, what does
print(status_PV.info)
and
print(status_PV.callbacks)
show?
from pyepics.
the 'distboard' is one data structure to store the information of my hardware board.
when the status of hardware changes, the hardware will change the pv value,
and I hope the python script in the remote computer can monitor this change.
I have tesed by your suggestion and it shows as below:
E:>python pvcb.py
pvname:S001:C06:B01:Status _conn_started = True
[设备管理22] 配线盘下线[变更]
== S001:C06:B01:Status (time_long) ==
value = 0
char_value = '0'
count = 1
nelm = 1
type = time_long
units =
host = 192.168.159.201:5064
access = read/write
status = 17
char_status= UDF
severity = 0
char_severity = NO_ALARM
timestamp = 631152000.000 (1990-01-01 08:00:00.00000)
posixseconds = 631152000.0
nanoseconds= 0
upper_ctrl_limit = 0
lower_ctrl_limit = 0
upper_disp_limit = 0
lower_disp_limit = 0
upper_alarm_limit = 0
lower_alarm_limit = 0
upper_warning_limit = 0
lower_warning_limit = 0
PV is internally monitored, with 1 user-defined callbacks:
on_status_change in file pvcb.py
{1: (<function on_status_change at 0x00000188BB6B61F0>, {'distboard': None})}
you can see:
[设备管理22] 配线盘下线[变更]
it seems that the callback was called only once to show the initial value,
but when I changed the pv value by caput, it never called again...
the pv value change as below:
C:\Users\001>caget S001:C06:B01:Status
S001:C06:B01:Status 0
C:\Users\001>caget S001:C06:B01:Status
S001:C06:B01:Status 1
when I test, the pv value is changed by the caput commond on the hardware board.
Thank you.
from pyepics.
@newville , I am sorry, I didn't orgnize the text format well. I'm not good at it...
from pyepics.
@ikunwang
For distboard
, do you expect the callback function will receive some information about that from the CA event manager? I think it will not. Did you try without using that? If not, I will repeat my suggestion to try with removing that from the Python functions.
Do you see the same behavior with a different PV?
Do you see in your Python program that the PV has changed?
from pyepics.
@newville
I think the disboard is ok...
when I register the callback, I can input the disboard info into the CA event manager, and when the callback is called, the disboard is input for me to do something. In my code, it works ok.
the code you see the first time is just a test code, I tried another PV in test code and it also has the same problem.
but in the code of product, it seems that another PV works OK, when PV value changes in the network (changed by another machine), the callback can be called. And I have compared the two PV, but no differance was found...
"Do you see in your Python program that the PV has changed?"
-->I am not sure I understand your question... I changed the PV in the network, for example, using the caput command to change the value in another machine or the same machine of Python programe.
from pyepics.
I think the disboard is ok...
I don't see how the event manager could possibly fill in that value for a callback on a PV. And, just in general, if you ask for help, and then ignore or dismiss my suggestions, I become much less interested in helping you.
when I register the callback, I can input the disboard info into the CA event manager, and when the callback is called, the
disboard is input for me to do something. In my code, it works ok.
Huh? In what code does "it work ok"? You are saying here that it doesn't work, aren't you? It works now?
It seems to me like you are not telling me the whole story. Frankly, most conversations I've had in recent years that go in this direction involve someone using a home-built CA server or running with an Epics IOC process.
the code you see the first time is just a test code, I tried another PV in test code and it also has the same problem.
but in the code of product, it seems that another PV works OK, when PV value changes in the network (changed by
another machine), the callback can be called. And I have compared the two PV, but no differance was found...
Why would it work for one PV and not another? That makes no sense to me unless you are doing something to try to break CA.
"Do you see in your Python program that the PV has changed?"
-->I am not sure I understand your question... I changed the PV in the network, for example, using the caput command to
change the value in another machine or the same machine of Python program.
Well, if you simply print the PV value in your while True
loop, does that printed value change? If not, then the event was not seen. If so, the event was seen, but the callback was not called.
Just to be clear, placing callbacks on PVs works for lots of people, in production, thousands of times per hour. Like, seriously, for me it works all day, every day, with hundreds of PVs. I don't know what is not working for you. I suspect you have misconfigured PVs.
from pyepics.
@newville
I am sorry...and I really appreciate you.
I think there is some misunderstanding... Really thanks : )
I have tried your sugestion and there is something strange...
After I change the pv value in the hardware board, the caget commond can get the right value (both on the hardware board itself or on my computer).
But...the caget function in my python programe can not get the right value (it does not know the value changed....)
the PV definiation is as below,:
record(longout, "S$(station_id):C$(cluster_id):B$(board_id):Status")
{
field(DESC, "DBorad Status")
field(DTYP, "asynInt32")
field(INP, "@ASYN(
field(TSE, "$(TSE)")
field(SCAN, "$(SCAN)")
}
Is there some misconfiguration for it? ...
and the latest test code is as below:
#!/bin/python
-- coding: utf-8 --
import sys
import logging
import time
from epics import *
#配线盘在线状态发生变化
def on_status_change(pvname=None, value=None, char_value=None, **kws):
if value == 1:
print("board become online")
else:
print("board become offline")
status_PV = PV('S001:C06:B01:Status')
status_PV.add_callback(on_status_change)
print(status_PV.info)
print(status_PV.callbacks)
while(True):
print(caget('S001:C06:B01:Status'))
time.sleep(1)
from pyepics.
@ikunwang I don't know.
That seems very hard to explain, especially if it works for some variables.
There are all sorts of networking issues that could happen, but those are impossible for me to diagnose. I assume you've made sure that your Python program is running in the same environment as the command-line functions....
from pyepics.
@newville
yes, the python programe run the same environment as the command-line functions.
I think I should check the problem why python program not know the pv value change...
Really thanks. You helped me find the direct cause.
When I found something new or solved it, I will discuss with you :)
from pyepics.
Related Issues (20)
- Problem with control limit attribute HOT 3
- Control limit attribute shows 0 for ao (analog out) PV
- pyepics crashes process on shutdown randomly HOT 11
- How to set DBR type for ca.put()? HOT 5
- Add missing DBR types DBR_STSACK_STRING and DBR_CLASS_NAME HOT 3
- CAC: Unable to connect because "Invalid argument" when using pcaspy with pyepics HOT 8
- pyc files not removed properly from distributions
- Segmentation fault in epics.get_pv for pyepics 3.5.1 HOT 3
- ca.get('image) timed out after 1.00 seconds HOT 1
- libca.so cannot be found on RPi 64bit HOT 3
- The issue of installed pyepics HOT 1
- Review performance testing HOT 10
- launch new multiprocessing task from pv / camonitor callback HOT 5
- text encoding fallback HOT 9
- libca.so: cannot open shared object file HOT 23
- Missing updates from pv monitor when going in/out of an invalid severity HOT 2
- Callback function gets NoneType return value HOT 6
- Application using pyepics may crash after epics.ca.clear_cache() HOT 4
- GitHub worflow tests do no execute on pull-requests
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyepics.