Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplication of PV writes seen by camonitor #803

Open
cjtitus opened this issue Nov 4, 2022 · 6 comments
Open

Duplication of PV writes seen by camonitor #803

cjtitus opened this issue Nov 4, 2022 · 6 comments
Labels
server pvproperty, PVGroup, and related

Comments

@cjtitus
Copy link

cjtitus commented Nov 4, 2022

Short Description

I am building a caproto IOC that monitors an external PV, collects its values, and then outputs statistics, every 10 seconds. I have three pvproperty attributes that I am trying to write to -- mean, std, and npts.

When I do camonitor myioc:mean I see that the value is re-broadcast whenever any pvproperty in the caproto IOC is written to. In particular, it is tripled, as it is broadcast whenever std and npts are written, as well as when mean is written.

An example of monitor output is 
averager:mean                  2022-11-04 18:22:36.944039 1.1794e-12  
averager:mean                  2022-11-04 18:22:36.944039 1.1794e-12  
averager:mean                  2022-11-04 18:22:36.944039 1.1794e-12  
averager:mean                  2022-11-04 18:22:47.944145 1.18262e-12  
averager:mean                  2022-11-04 18:22:47.944145 1.18262e-12  
averager:mean                  2022-11-04 18:22:47.944145 1.18262e-12  

You can see that it gets tripled.

A complete version of this IOC is available https://gist.github.com/cjtitus/83235e4aa3441c7d417955ace1f37766
It's got my beamline's PV hardcoded into the __main__ method, but it should be trivial to run it to point at any PV you have access to in order to test this.

I am on caproto 0.8.1, but should be easy enough for someone to check if it happens on v1.0.0

@tacaswell
Copy link
Collaborator

Just to confirm, you commented out the other two stats and the behavior went away?

My concern is that because you are setting the value the alarm state I wonder if we are not correctly de-bouncing something and the 2 extra messages are from that (not the other two PVs)?

@cjtitus
Copy link
Author

cjtitus commented Nov 6, 2022 via email

@tacaswell
Copy link
Collaborator

Try passing a unique alarm_group='xyz' to each of the PVs

@tacaswell
Copy link
Collaborator

or filtering your monitor to value only (no alarm updates).

@klauer
Copy link
Member

klauer commented Nov 7, 2022

I think it's almost certainly as @tacaswell indicates - the alarm group is causing the other two to send updates.

caproto's handling of alarm updates could definitely be improved here. Something like only causing the linked alarm group to publish if the status/severity differ from the current setting:

caproto/caproto/_data.py

Lines 708 to 709 in 57e0c56

if 'status' in metadata or 'severity' in metadata:
await self.alarm.publish(flags, except_for=(self,))

@cjtitus
Copy link
Author

cjtitus commented Nov 7, 2022

Indeed, taking out the status kwarg from the write calls stops the duplication. Seems to be it.

@klauer klauer added the server pvproperty, PVGroup, and related label May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
server pvproperty, PVGroup, and related
Projects
None yet
Development

No branches or pull requests

3 participants