From 446005e788d6d713b771be4571bb5297f19cd47b Mon Sep 17 00:00:00 2001 From: boccioli_m Date: Fri, 29 May 2015 14:25:31 +0200 Subject: [PATCH] Closedown --- config/plugins.properties | 4 +- script/power-supply2.py | 78 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 script/power-supply2.py diff --git a/config/plugins.properties b/config/plugins.properties index 9846821..9135732 100644 --- a/config/plugins.properties +++ b/config/plugins.properties @@ -1,2 +1,2 @@ -#Fri May 29 11:50:05 CEST 2015 -.\\home\\plugins\\NetbeansPlugin.java=disabled +#Fri May 29 14:25:26 CEST 2015 +.\\home\\plugins\\NetbeansPlugin.java=enabled diff --git a/script/power-supply2.py b/script/power-supply2.py new file mode 100644 index 0000000..01bedc5 --- /dev/null +++ b/script/power-supply2.py @@ -0,0 +1,78 @@ +#Script imported from: PO2DV-NCS-HW_ps.xml +from mathutils import estimate_peak_indexes, fit_gaussians, create_fit_point_list + +#Pre-actions +caput('PO2DV-NCS-VHQ1:Set-RampA', '10') +sleep(0.1) + +#TODO: Set the diplay names of positioners and detectors +#ManualScan(writables, readables, start = None, end = None, steps = None, relative = False) +scan = ManualScan(['time'], ['SetVA', 'ActualVA', 'ActualIA'] , [0.0], [20.0], [10]) #????????????????????? what does this do? what is writeables? what is readables? +scan.start() + +#Creating channels: dimension 1 +#LinearPositioner SetVA +SetVA = Channel('PO2DV-NCS-VHQ1:Set-VA', type = 'd') +#Timestamp time +#ScalarDetector ActualVA +ActualVA = Channel('PO2DV-NCS-VHQ1:Actual-VA', type = 'd') +#ScalarDetector ActualIA +ActualIA = Channel('PO2DV-NCS-VHQ1:Actual-IA', type = 'd') + +#set voltage to 0 +print 'Ramping down power supply to 0V' +SetVA.put(0.0, timeout=None) + +#wait up to 2 minutes for voltage to be ~0 +for setpoint1 in frange(0.0, 120.0, 1.0, True): + detector2 = ActualVA.get() + if detector2 <= 1.0: + break + sleep(0.5) + +#Dimension 1 +#LinearPositioner SetVA +print 'Ramping up power supply' +for setpoint1 in frange(0.0, 20.0, 10.0, True): #?????????????????? What is the relationship between this FOR loop and the ManualScan? + if setpoint1 > 50.0 or setpoint1 < 0.0: + break + SetVA.put(setpoint1, timeout=None) # TODO: Set appropriate timeout + readback1 = SetVA.get() + if abs(readback1 - setpoint1) > 0.5 : # TODO: Check accuracy + raise Exception('Actor SetVA could not be set to the value ' + str(setpoint1)) + #scan quickly the output during some seconds + for setpoint2 in range(0, 20): + #Detector time + detector1 = float(java.lang.System.currentTimeMillis()) + #Detector ActualVA + detector2 = ActualVA.get() + detector3 = ActualIA.get() + #scan.append ([setpoint1], [readback1], [detector1, detector2]) + + #append(setpoints, positions, values) + scan.append ([detector1], [detector1], [readback1, detector2, detector3]) #?????????????????????? what is setpoint? is position = X-axis? + sleep( 0.1 ) # Settling time + +#reset output to 0V +SetVA.put(0.0, timeout=None) +#Closing channels +SetVA.close() +ActualVA.close() +ActualIA.close() + +readable = scan.readables[0] +positions = scan.writables + +threshold = (min(readable) + max(readable))/2 +min_peak_distance = 5.0 + +peaks = estimate_peak_indexes(readable, positions, threshold, min_peak_distance) +print "Peak indexes: " + str(peaks) +print "Peak x: " + str(map(lambda x:positions[x], peaks)) +print "Peak y: " + str(map(lambda x:readable[x], peaks)) + + +scan.end() + + +#??????????????????????????? Device modeling: how can I modelise a Power Supply, for example?