slaclab / pysmurf

Other
2 stars 9 forks source link

New functions to get/set timing modes #738

Closed swh76 closed 1 year ago

swh76 commented 1 year ago

Description

This PR adds new functions to utils named get_timing_mode and set_timing_mode which allow you to check what timing mode a carrier is configured in (supported modes are our typical "ext_ref", "backplane", and "fiber" modes). This closes out issue pysmurf github https://github.com/slaclab/pysmurf/issues/734. No interface changes. Some implementation details:

I tested that I was able to setup in all three modes from power on, that the new get_timing_mode function recognized the timing configurations the way we used to set them (by changing pysmurf cfg and hammering) and that I was able to switch between modes and still see external timing info making it into streamed data headers. I also checked all of the warning conditions in both the new set_timing_mode and get_timing_mode functions (e.g. both throw a warning if configured in either "fiber" or "backplane" modes but no external timing data is being received).

Here's some commands and output for some typical usage cases for a slot 2 system in SLAC RF Lab1:

In [10]: S.get_timing_mode()
Out[10]: 'fiber'

In [11]: S.set_timing_mode('ext_ref')
[ 2022-10-27 07:42:09 ]  System configured for fiber timing.  Reconfiguring slot 2 for ext_ref timing.
[ 2022-10-27 07:42:09 ]  Select external reference for bay 0 or free running if there is no reference.
[ 2022-10-27 07:42:09 ]  Select external reference for bay 1 or free running if there is no reference.

In [12]: S.get_timing_mode()
Out[12]: 'ext_ref'

In [13]: S.set_timing_mode('backplane')
[ 2022-10-27 07:42:18 ]  System configured for ext_ref timing.  Reconfiguring slot 2 for backplane timing.
[ 2022-10-27 07:42:18 ]  System is in slot 2, which cannot be configured for backplane timing.  Will configure for fiber timing instead.

In [14]: S.get_timing_mode()
Out[14]: 'fiber'

In [15]: S.set_timing_mode('fiber')
[ 2022-10-27 07:42:46 ]  System already configured for fiber timing, doing nothing.

In [16]: S.set_timing_mode('ext_ref',write_log=True)
[ 2022-10-27 07:43:01 ]  System configured for fiber timing.  Reconfiguring slot 2 for ext_ref timing.
[ 2022-10-27 07:43:01 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AppTop:AppCore:MicrowaveMuxCore[0]:LMK:enable 1
[ 2022-10-27 07:43:01 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AppTop:AppCore:MicrowaveMuxCore[1]:LMK:enable 1
[ 2022-10-27 07:43:01 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AmcCarrierCore:AxiSy56040:OutputConfig[0] 0
[ 2022-10-27 07:43:01 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AmcCarrierCore:AxiSy56040:OutputConfig[1] 0
[ 2022-10-27 07:43:01 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AmcCarrierCore:AxiSy56040:OutputConfig[2] 1
[ 2022-10-27 07:43:01 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AmcCarrierCore:AxiSy56040:OutputConfig[3] 1
[ 2022-10-27 07:43:01 ]  Select external reference for bay 0 or free running if there is no reference.
[ 2022-10-27 07:43:01 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AppTop:AppCore:MicrowaveMuxCore[0]:LMK:LmkReg_0x0146 16
[ 2022-10-27 07:43:01 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AppTop:AppCore:MicrowaveMuxCore[0]:LMK:LmkReg_0x0147 26
[ 2022-10-27 07:43:01 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AppTop:AppCore:MicrowaveMuxCore[1]:LMK:LmkReg_0x0146 16
[ 2022-10-27 07:43:01 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AppTop:AppCore:MicrowaveMuxCore[1]:LMK:LmkReg_0x0147 26
[ 2022-10-27 07:43:01 ]  Select external reference for bay 1 or free running if there is no reference.
[ 2022-10-27 07:43:01 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AppTop:AppCore:MicrowaveMuxCore[0]:LMK:LmkReg_0x0146 16
[ 2022-10-27 07:43:01 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AppTop:AppCore:MicrowaveMuxCore[0]:LMK:LmkReg_0x0147 26
[ 2022-10-27 07:43:01 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AppTop:AppCore:MicrowaveMuxCore[1]:LMK:LmkReg_0x0146 16
[ 2022-10-27 07:43:01 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AppTop:AppCore:MicrowaveMuxCore[1]:LMK:LmkReg_0x0147 26
[ 2022-10-27 07:43:01 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AppTop:AppCore:RtmCryoDet:RampStartMode 0

In [17]: S.set_timing_mode('fiber',write_log=True)
[ 2022-10-27 07:44:07 ]  System configured for ext_ref timing.  Reconfiguring slot 2 for fiber timing.
[ 2022-10-27 07:44:07 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AppTop:AppCore:MicrowaveMuxCore[0]:LMK:enable 1
[ 2022-10-27 07:44:07 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AppTop:AppCore:MicrowaveMuxCore[1]:LMK:enable 1
[ 2022-10-27 07:44:07 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AmcCarrierCore:AxiSy56040:OutputConfig[0] 0
[ 2022-10-27 07:44:07 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AmcCarrierCore:AxiSy56040:OutputConfig[1] 0
[ 2022-10-27 07:44:07 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AmcCarrierCore:AxiSy56040:OutputConfig[2] 0
[ 2022-10-27 07:44:07 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AmcCarrierCore:AxiSy56040:OutputConfig[3] 0
[ 2022-10-27 07:44:07 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AmcCarrierCore:AmcCarrierTiming:EvrV2CoreTriggers:EvrV2ChannelReg[0]:EnableReg True
[ 2022-10-27 07:44:07 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AmcCarrierCore:AmcCarrierTiming:EvrV2CoreTriggers:EvrV2ChannelReg[0]:DestType 0
[ 2022-10-27 07:44:07 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AmcCarrierCore:AmcCarrierTiming:EvrV2CoreTriggers:EvrV2TriggerReg[0]:EnableTrig True
[ 2022-10-27 07:44:07 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AppTop:AppCore:RtmCryoDet:RampStartMode 1
[ 2022-10-27 07:44:07 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AppTop:AppCore:MicrowaveMuxCore[0]:LMK:LmkReg_0x0146 8
[ 2022-10-27 07:44:07 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AppTop:AppCore:MicrowaveMuxCore[0]:LMK:LmkReg_0x0147 10
[ 2022-10-27 07:44:07 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AppTop:AppCore:MicrowaveMuxCore[1]:LMK:LmkReg_0x0146 8
[ 2022-10-27 07:44:07 ]  caput smurf_server_s2:AMCc:FpgaTopLevel:AppTop:AppCore:MicrowaveMuxCore[1]:LMK:LmkReg_0x0147 10

# After deactivating timing carrier
In [18]: S.get_timing_mode()
[ 2022-10-27 07:45:18 ]  Configured for fiber timing but not receiving external timing data.
Out[18]: 'fiber'

In [19]: S.set_timing_mode('ext_ref')
[ 2022-10-27 07:45:25 ]  Configured for fiber timing but not receiving external timing data.
[ 2022-10-27 07:45:25 ]  System configured for fiber timing.  Reconfiguring slot 2 for ext_ref timing.
[ 2022-10-27 07:45:25 ]  Select external reference for bay 0 or free running if there is no reference.
[ 2022-10-27 07:45:25 ]  Select external reference for bay 1 or free running if there is no reference.

In [20]: S.set_timing_mode('fiber')
[ 2022-10-27 07:45:42 ]  System configured for ext_ref timing.  Reconfiguring slot 2 for fiber timing.
[ 2022-10-27 07:45:43 ]  Configured for fiber timing but not receiving external timing data after waiting 1 second.

Github Issue

https://github.com/slaclab/pysmurf/issues/734