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:
Stripped all the timing stuff out of setup ; it now just uses the new set_timing_mode function.
I tried to make the functions smart enough to catch some common errors like asking for an external timing mode (currently either "backplane" or "fiber") but no external timing data is coming in or e.g. trying to configure a slot 2 carrier for "backplane" timing or a slot 3-7 carrier for "fiber" timing.
I added a lot more documentation for all the EvrV2 regs (that configure trigger pulse generation from external timing) and get functions for the regs that need to be set to configure for fiber and backplane timing modes. The new get functions get_evr_channel_reg_enable, get_evr_trigger_dest_type, and get_trigger_enable are needed by the get_timing_mode function to figure out what timing mode a system is configured in.
Eliminated the get_timing_fiber_status function which is now superceded by the get_timing_mode function.
Improved docstrings for most of the functions used to get/set timing modes.
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.
Description
This PR adds new functions to utils named
get_timing_mode
andset_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:setup
; it now just uses the newset_timing_mode
function.get_evr_channel_reg_enable
,get_evr_trigger_dest_type
, andget_trigger_enable
are needed by theget_timing_mode
function to figure out what timing mode a system is configured in.get_timing_fiber_status
function which is now superceded by theget_timing_mode
function.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 newset_timing_mode
andget_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:
Github Issue
https://github.com/slaclab/pysmurf/issues/734