Commit 78452ed2 authored by Matthieu Cattin's avatar Matthieu Cattin

Raise exception at the end of the tests, this allow to continue test (eg. of the other channels).

parent c6140a34
......@@ -48,7 +48,7 @@ def main (default_directory='.'):
sys.stdin = sys.__stdin__;
# Initialize error variable, disable triggers and make sure no acquisition is running
errors = [0, 0]
error = 0
fmc.set_trig_config(1, 0, 0, 0, 0, 0, 0)
fmc.stop_acq()
......@@ -67,7 +67,8 @@ def main (default_directory='.'):
if (ask == "N"):
# LED ON fail
errors[0] = 1
print("One or both LEDs not switching ON. Check for soldering or connection problem, grounded control line.")
errors += 1
############################################################################
# Test LEDs OFF
......@@ -84,19 +85,16 @@ def main (default_directory='.'):
if (ask == "N"):
# LED OFF fail
errors[1] = 1
print("One or both LEDs not switching OFF. Check for short-cut.")
error += 1
# Standard in/out redirection
sys.stdout = tmp_stdout;
sys.stdin = tmp_stdin;
# Check for errors in LED tests
if (errors != ([0] * 2)):
if(errors[0] == 1):
print("One or both LEDs not switching ON. Check for soldering or connection problem, grounded control line.")
if(errors[1] == 1):
print("One or both LEDs not switching OFF. Check for short-cut.")
raise PtsError("There is a problem with the LEDs");
# Check if an error occured during LED test
if (error != 0):
raise PtsError('An error occured during LEDs test, check log for details.')
if __name__ == '__main__' :
......
......@@ -76,7 +76,7 @@ def main (default_directory='.'):
# Start acquisition
fmc.stop_acq()
print('Acquisition FSM state : %s') % fmc.get_acq_fsm_state()
print('Acquisition FSM state : %s (should be IDLE)') % fmc.get_acq_fsm_state()
fmc.start_acq()
time.sleep(TIMEOUT)
......@@ -89,5 +89,6 @@ def main (default_directory='.'):
print('Acquisition FSM state : %s') % fmc.get_acq_fsm_state()
raise PtsError('External trigger input is not working')
if __name__ == '__main__' :
main()
......@@ -45,6 +45,8 @@ def main (default_directory='.'):
spec = rr.Gennum() # bind to the SPEC board
fmc = fmc_adc.CFmcAdc100Ms(spec)
error = 0
# All inputs in calibration mode
for i in range(1, NB_CHANNELS+1):
fmc.set_input_range(i, "CAL")
......@@ -63,7 +65,9 @@ def main (default_directory='.'):
adc_value = fmc.get_current_adc_value(i)
print('ADC channel %d value:0x%.4X') % (i, adc_value)
if(ADC_POS != adc_value):
raise PtsError('Channel %d offset circuit is malfunctioning'%i)
print('Channel %d offset circuit is malfunctioning')%(i)
error += 1
#raise PtsError('Channel %d offset circuit is malfunctioning'%i)
# Reset offset DACs
print('Reset offset')
......@@ -75,7 +79,9 @@ def main (default_directory='.'):
adc_value = fmc.get_current_adc_value(i)
print('ADC channel %d value:0x%.4X tolerance:0x%.4X') % (i, adc_value, ADC_TOL)
if((ADC_MID-ADC_TOL > adc_value) | (ADC_MID+ADC_TOL < adc_value)):
raise PtsError('Channel %d offset circuit is malfunctioning'%i)
print('Channel %d offset circuit is malfunctioning')%(i)
error += 1
#raise PtsError('Channel %d offset circuit is malfunctioning'%i)
# Set a negative offset on all channels
print('Set negative offset: %.4X' % OFFSET_NEG)
......@@ -88,11 +94,17 @@ def main (default_directory='.'):
adc_value = fmc.get_current_adc_value(i)
print('ADC channel %d value:0x%.4X') % (i, adc_value)
if(ADC_NEG != adc_value):
raise PtsError('Channel %d offset circuit is malfunctioning'%i)
print('Channel %d offset circuit is malfunctioning')%(i)
error += 1
#raise PtsError('Channel %d offset circuit is malfunctioning'%i)
# Reset offset DACs
fmc.dc_offset_reset()
# Check if an error occured during offset DAC test
if(error != 0):
raise PtsError('An error occured during offset DAC test, check log for details.')
if __name__ == '__main__' :
main()
......@@ -53,7 +53,6 @@ SW5_THRESHOLD = 5
SW6_THRESHOLD = 10
SW7_THRESHOLD = 10
def set_awg_offset(gen, sine, offset):
sine.dc = offset
gen.play(sine)
......@@ -93,7 +92,9 @@ def sw_test(gen, sine, awg_offset, fmc, sw, ssr_1, ssr_2, diff_tol, retry_nb=0,
print('#####################################')
print('SW%d of channel %d is malfunctioning') % (sw, i)
print('#####################################')
raise PtsError('SW%d of channel %d is malfunctioning' % (sw, i))
#raise PtsError('SW%d of channel %d is malfunctioning' % (sw, i))
return 1
return 0
def adc_mid_test(gen, sine, awg_offset, fmc, tol, retry_nb=0, threshold=0):
print('\nTesting ADC middle scale\n-------------------------')
......@@ -116,7 +117,9 @@ def adc_mid_test(gen, sine, awg_offset, fmc, tol, retry_nb=0, threshold=0):
print('############################################')
print('One of channel %d switches is malfunctioning') % i
print('############################################')
raise PtsError('One of channel %d switches is malfunctioning' % i)
#raise PtsError('One of channel %d switches is malfunctioning' % i)
return 1
return 0
def main (default_directory='.'):
......@@ -224,15 +227,17 @@ def main (default_directory='.'):
sys.exit()
"""
adc_mid_test(gen, sine, 0.25, fmc, ADC_MID_TOL, RETRY_NB, ADC_MID_THRESHOLD)
error = 0
error += adc_mid_test(gen, sine, 0.25, fmc, ADC_MID_TOL, RETRY_NB, ADC_MID_THRESHOLD)
sw_test(gen, sine, 0.25, fmc, 1, 0x00, 0x01, SW1_TOL, RETRY_NB, SW1_THRESHOLD)
sw_test(gen, sine, 0.25, fmc, 4, 0x01, 0x09, SW4_TOL, RETRY_NB, SW4_THRESHOLD)
sw_test(gen, sine, 0.25, fmc, 5, 0x41, 0x51, SW5_TOL, RETRY_NB, SW5_THRESHOLD)
sw_test(gen, sine, 0.25, fmc, 6, 0x00, 0x60, SW5_TOL, RETRY_NB, SW6_THRESHOLD)
sw_test(gen, sine, 0.25, fmc, 7, 0x01, 0x41, SW6_TOL, RETRY_NB, SW7_THRESHOLD)
sw_test(gen, sine, 0.01, fmc, 2, 0x20, 0x22, SW2_TOL, RETRY_NB, SW2_THRESHOLD)
sw_test(gen, sine, 0.01, fmc, 3, 0x22, 0x26, SW3_TOL, RETRY_NB, SW3_THRESHOLD)
error += sw_test(gen, sine, 0.25, fmc, 1, 0x00, 0x01, SW1_TOL, RETRY_NB, SW1_THRESHOLD)
error += sw_test(gen, sine, 0.25, fmc, 4, 0x01, 0x09, SW4_TOL, RETRY_NB, SW4_THRESHOLD)
error += sw_test(gen, sine, 0.25, fmc, 5, 0x41, 0x51, SW5_TOL, RETRY_NB, SW5_THRESHOLD)
error += sw_test(gen, sine, 0.25, fmc, 6, 0x00, 0x60, SW5_TOL, RETRY_NB, SW6_THRESHOLD)
error += sw_test(gen, sine, 0.25, fmc, 7, 0x01, 0x41, SW6_TOL, RETRY_NB, SW7_THRESHOLD)
error += sw_test(gen, sine, 0.01, fmc, 2, 0x20, 0x22, SW2_TOL, RETRY_NB, SW2_THRESHOLD)
error += sw_test(gen, sine, 0.01, fmc, 3, 0x22, 0x26, SW3_TOL, RETRY_NB, SW3_THRESHOLD)
# Following commented code is for testing the tests
"""
......@@ -253,6 +258,10 @@ def main (default_directory='.'):
gen.output = False
gen.close()
# Check if an error occured during switches test
if(error != 0):
raise PtsError('An error occured during switches test, check log for details.')
if __name__ == '__main__' :
main()
......@@ -145,7 +145,9 @@ def acquisition(gnum, pages, fmc, channel_nb, channel_data):
time.sleep(.1)
timeout += 1
if(ACQ_TIMEOUT < timeout):
raise PtsError('Acquisition timeout. Check that the AWG is switched ON and properly connected.')
print('Acquisition timeout. Check that the AWG is switched ON and properly connected.')
return 1
#raise PtsError('Acquisition timeout. Check that the AWG is switched ON and properly connected.')
# Retrieve data trough DMA
page1_data_before_dma = gnum.get_memory_page(1)
......@@ -161,7 +163,7 @@ def acquisition(gnum, pages, fmc, channel_nb, channel_data):
print page1_data[0:20]
print('### Acquisition or DMA error. ###')
#raise PtsWarning('Acquisition or DMA error.')
return -1
return 1
for i in range(len(page1_data)):
channel_data.append(page1_data[i] & 0xFFFF)
channel_data.append(page1_data[i]>>16)
......@@ -227,7 +229,8 @@ def main (default_directory='.'):
# Test frequency response of all channels
ch_diff = []
j = 0
error_cnt = 0
retry_cnt = 0
error = 0
while(j < len(points)):
#print('begin loop j=%d')%(j)
set_awg_freq(gen, sine, points[j][0])
......@@ -235,12 +238,15 @@ def main (default_directory='.'):
fmc.set_input_range(i, '1V')
time.sleep(SSR_SET_SLEEP)
channel_data = []
error = acquisition(gnum, pages, fmc, i, channel_data)
if(error != 0):
error_cnt += 1
print('RETRY: %d')%(error_cnt)
if(MAX_FIRMWARE_RELOAD < error_cnt):
raise PtsError('Maximium of %d retry exceeded (channel:%d, freq:%2.3fMHz)'%(MAX_FIRMWARE_RELOAD, i, points[j][0]/1E6))
retry = acquisition(gnum, pages, fmc, i, channel_data)
if(retry != 0):
retry_cnt += 1
print('RETRY: %d')%(retry_cnt)
if(MAX_FIRMWARE_RELOAD < retry_cnt):
print('Maximium of %d retry exceeded (channel:%d, freq:%2.3fMHz)')%(MAX_FIRMWARE_RELOAD, i, points[j][0]/1E6))
error += 1
break
#raise PtsError('Maximium of %d retry exceeded (channel:%d, freq:%2.3fMHz)'%(MAX_FIRMWARE_RELOAD, i, points[j][0]/1E6))
load_firmware(default_directory)
fmc_adc_init(spec, fmc)
#time.sleep(2)
......@@ -252,10 +258,11 @@ def main (default_directory='.'):
if((diff < points[j][1]-points[j][2]) | (diff > points[j][1]+points[j][2])):
print('Channel %d frequency response is out of range at freq:%2.3fMHz')%(i, points[j][0]/1E6)
print('Current amplitude:%d, expected:%d +/-%d')%(diff, points[j][1], points[j][2])
raise PtsError('Channel %d frequency response is out of range at freq:%2.3fMHz'%(i, points[j][0]/1E6))
if(error == 0):
error += 1
#raise PtsError('Channel %d frequency response is out of range at freq:%2.3fMHz'%(i, points[j][0]/1E6))
if(retry == 0):
j += 1
error_cnt = 0
retry_cnt = 0
#print('j++')
#print('end loop j=%d')%(j)
......@@ -289,6 +296,10 @@ def main (default_directory='.'):
gen.output = False
gen.close()
# Check if an error occured during frequency response test
if(error != 0):
raise PtsError('An error occured during frequency response test, check log for details.')
if __name__ == '__main__' :
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment