epics-modules / mrfioc2

EPICS driver for Micro Research Finland event timing system devices
http://epics-modules.github.io/mrfioc2/
Other
8 stars 30 forks source link

Include a mechanism to avoid PpsInp-Sel and PpsInp1-Sel to be set at the same time #160

Open gabrielfedel opened 3 months ago

gabrielfedel commented 3 months ago

Currently is possible to set the PpsInp-Sel and PpsInp1-Sel records to different of None, and this way have 2 sources of PPS. It would be good to have a mechanism on DB layer to avoid this. A simple idea would be to set the other Sel to None if the current one is != None (e.g. if PpsInp1 is UnivInp11, PpsInp is set to None automatically)

hongran commented 3 months ago

Currently the source selection for triggered events also has the same issue. I just made another PR for database support of the VME-300 cards. For the VME cards, I need 3 selection records for dBus, trigEvt and Pps. I implemented a mechanism to avoid double or triple selection. I think my method is expandable.

Question to Insomnia: does your solution work if we have 3 selection records (for example, PpsInp-Sel, PpsInp1-Sel and PpsInp2-Sel)?

Insomnia1437 commented 3 months ago

@hongran if there are 3 PpsInp sources, then my PR doesn't work. I am checking your PR now

Insomnia1437 commented 3 months ago

@hongran I add a dfanout record in my PR, now it works with 3 or more selection records

gabrielfedel commented 3 months ago

@hongran could you take a look on that PR to check if looks fine ? https://github.com/epics-modules/mrfioc2/pull/161

hongran commented 3 months ago

@gabrielfedel @Insomnia1437 I just tested the code in PR#161 and it does not work. This issue is that after the old selection is set to 0, the corresponding mbbi record is not processed, so the old selection remains active.

I have tested my solution in PR#164 and it doesn't have this issue. @Insomnia1437 is concerning about the transient period in my solution. It can be avoided in a small change. I will do this soon and update that PR.

Insomnia1437 commented 3 months ago

@hongran you are correct, I forget this logic

hongran commented 3 months ago

I updated PR#164. I tested that it works as expected. To ensure that the mbbi record is processed later than setting other selections, I need to introduce another seq record. The fanout record does not wait until entire chain out OUTA is done before processing OUTB.

I only implemented this to the Pps selection. Let me know if it is necessary to implement this transient prevention in the TrigEvent selection and DBus selection.