A roach bank manager class.
add_switching_state(duration, blank, cal, sig):
Add a description of one switching phase (backend dependent).
Example to set up a 8 phase signal (4-phase if blanking is not considered) with blanking, cal, and sig/ref, total of 400 mS:
be = Backend(None) # no real backend needed for example
be.clear_switching_states()
be.add_switching_state(0.01, blank = True, cal = True, sig = True)
be.add_switching_state(0.09, cal = True, sig = True)
be.add_switching_state(0.01, blank = True, cal = True)
be.add_switching_state(0.09, cal = True)
be.add_switching_state(0.01, blank = True, sig = True)
be.add_switching_state(0.09, sig = True)
be.add_switching_state(0.01, blank = True)
be.add_switching_state(0.09)
arm_roach(self):
Sends a sequence of commands to arm the ROACH. This is mode dependent and mode should have been specified in advance, as the sequence of commands is obtained from the ‘MODEX’ section of the configuration file.
This method creates the status shared memory segment if necessary. If the segment exists, the state of the status memory is not modified.
This method clears the status shared memory segment if necessary.
disarm_roach(self):
Sends a sequence of commands to disarm the ROACH. This is mode dependent and mode should have been specified in advance, as the sequence of commands is obtained from the ‘MODEX’ section of the configuration file.
Dive into the config file and fetch the bank name based on the current host running this bank.
A pass-thru method which gets the values of a backend specific parameter.
Example usage:
get_param(exposure)
Returns the specified key’s value, or the values of several keys, or the entire contents of the shared memory status buffer.
‘keys’ == None: The entire buffer is returned, as a dictionary containing the key/value pairs.
‘keys’ is a list of keys, which are strings: returns a dictionary containing the requested subset of key/value pairs.
‘keys’ is a single string: a single value will be looked up and returned using ‘keys’ as the single key.
A pass-thru method which conveys a backend specific parameter to the modes parameter engine.
Example usage:
help_param(exposure)
monitor() requests that the DAQ program go into monitor mode. This is handy for troubleshooting issues like no data. In monitor mode the DAQ’s net thread starts receiving data but does not do anything with that data. However the thread’s status may be read in the status memory: NETSTAT will say ‘receiving’ if packets are arriving, ‘waiting’ if not.
Reads the config file ‘filename’ and loads the values into data structures in memory. ‘filename’ should be a fully qualified filename. The config file contains a ‘bank’ section of interest to this bank; in addition, it contains any number of ‘MODEX’ sections, where ‘X’ is a mode name/number.
Since the vegas and guppi HPC programs require different data buffer layouts, remove and re-create the databuffers as appropriate for the HPC program in use.
reset_roach(self):
Sends a sequence of commands to reset the ROACH. This is mode dependent and mode should have been specified in advance, as the sequence of commands is obtained from the ‘MODEX’ section of the configuration file.
scan_status(self):
Returns the state of currently running scan. The return type is a tuple, backend dependent.
set_gbt_ss(period, ss_list):
adds a complete GBT style switching signal description.
Example:
b.set_gbt_ss(period = 0.1,
ss_list = ((0.0, SWbits.SIG, SWbits.CALON, 0.025),
(0.25, SWbits.SIG, SWbits.CALOFF, 0.025),
(0.5, SWbits.REF, SWbits.CALON, 0.025),
(0.75, SWbits.REF, SWbits.CALOFF, 0.025))
)
Sets the operating mode for the roach. Does this by programming the roach.
Returns a tuple consisting of (status, ‘msg’) where ‘status’ is a boolean, ‘True’ if the mode was loaded, ‘False’ otherwise; and ‘msg’ explains the error if any.
Example:
s, msg = f.set_mode('MODE1') s, msg =
f.set_mode(mode='MODE1', force=True)
A pass-thru method which conveys a backend specific parameter to the modes parameter engine.
Example usage: set_param(exposure=x,switch_period=1.0, ...)
Updates the values for the keys specified in the parameter list as keyword value pairs. So:
set_status(PROJID=’JUNK’, OBS_MODE=’HBW’)
would set those two parameters.
starttime: a datetime object representing a start time, in UTC
–OR–
starttime: a tuple or list(for ease of JSON serialization) of datetime compatible values: (year, month, day, hour, minute, second, microsecond), UTC.
Sets up the system for a measurement and kicks it off at the appropriate time, based on ‘starttime’. If ‘starttime’ is not on a PPS boundary it is bumped up to the next PPS boundary. If ‘starttime’ is not given, the earliest possible start time is used.
start() may require a needed arm delay time, which is specified in every mode section of the configuration file as ‘needed_arm_delay’. During this delay it tells the HPC program to start its net, accum and disk threads, and waits for the HPC program to report that it is receiving data. It then calculates the time it needs to sleep until just after the penultimate PPS signal. At that time it wakes up and arms the ROACH. The ROACH should then send the initial packet at that time.
If a start time is specified that cannot be met an Exception is thrown with a message stating the problem.