diff --git a/script/HystScan.py b/script/HystScan.py index 7dac2ae..a8f3cd5 100644 --- a/script/HystScan.py +++ b/script/HystScan.py @@ -1,5 +1,9 @@ #Script imported from: Fe_hyst_plus.xml +#Parameters +START_FIELD = 6.8 +ENERGIES = (707.90, 703.90) + #Pre-actions #cawait('ACOAU-ACCU:OP-MODE', 'Light Available', type = 's') #caput('X07MA-ID:MODE', 'CIRC +') @@ -12,12 +16,15 @@ caputq('X07MA-PC-PS2:SET:DMD:RAMPRATE:TPM', '2.0') sleep(15.0) #TODO: Set the diplay names of positioners and detectors -scan = ManualScan(['field', 'Energy'], ['TEY', 'I0', 'trans', 'polarization', 'polAngle', 'temperature', 'RingCurrent', 'fieldAnalogX', 'tey_norm', 'trans_norm'] , [0.0, 703.9], [80.0, 707.9], [80, 1]) +scan = ManualScan(['index', 'Energy'], ['FieldRbk', 'TEY', 'I0', 'trans', 'polarization', 'polAngle', 'temperature', 'RingCurrent', 'fieldAnalogX', 'tey_norm', 'trans_norm'] , [0.0, 703.9], [80.0, 707.9], [80, 1]) scan.start() +#Stop condition +ramp_done = Channel('X07MA-PC-MAG:X:RAMP:DONE, type = 'i') + #Creating channels: dimension 1 #RegionPositioner field -field = Channel('X07MA-PC:GO', type = 'd') +#field = Channel('X07MA-PC:GO', type = 'd') fieldReadback = Channel('X07MA-PC-PS2:STS:PMCURRENT', type = 'd') #Creating channels: dimension 2 #ArrayPositioner Energy @@ -42,22 +49,23 @@ fieldAnalogX = Channel('X07MA-ES1-AI:SIGNAL4', type = 'd') #Dimension 1 #RegionPositioner field -for setpoint1 in frange(0.0, 80.0, 1.0, True): - #Region 1 pre-actions - if setpoint1 == 0.0: - caputq('X07MA-PC-PS2:M:GO.A', '6.8') - field.put(setpoint1, timeout=None) # TODO: Set appropriate timeout - readback1 = fieldReadback.get() - if abs(readback1 - setpoint1) > 0.5 : # TODO: Check accuracy - raise Exception('Actor field could not be set to the value ' + str(setpoint1)) +#Region 1 pre-actions +caputq('X07MA-PC-PS2:M:GO.A', START_FIELD) + +index = 0 +while(True): #Dimension 2 #ArrayPositioner Energy - for setpoint2 in (707.90, 703.90): + for setpoint2 in ENERGIES: Energy.put(setpoint2, timeout=None) # TODO: Set appropriate timeout readback2 = EnergyReadback.get() if abs(readback2 - setpoint2) > 0.1 : # TODO: Check accuracy raise Exception('Actor Energy could not be set to the value ' + str(setpoint2)) sleep( 0.5 ) # Settling time + + #Detector field readback + field_readback = fieldReadback.get() + #Detector TEY detector1 = TEY.get() #Detector I0 @@ -74,6 +82,8 @@ for setpoint1 in frange(0.0, 80.0, 1.0, True): detector7 = RingCurrent.get() #Detector fieldAnalogX detector8 = fieldAnalogX.get() + + #Manipulation tey_norm #Variable Mappings @@ -86,7 +96,12 @@ for setpoint1 in frange(0.0, 80.0, 1.0, True): #TODO: Move, if needed, this import to the file header: import math trans_norm = detector3/detector2 - scan.append ([setpoint1, setpoint2], [readback1, readback2], [detector1, detector2, detector3, detector4, detector5, detector6, detector7, detector8, tey_norm, trans_norm]) + scan.append ([index, setpoint2], [index, readback2], [field_readback, detector1, detector2, detector3, detector4, detector5, detector6, detector7, detector8, tey_norm, trans_norm]) + + if ramp_done.get() == 1: #If not ramping + print "Not ramping, breaking execution" + break + index = index+1 #Closing channels Energy.close() @@ -101,5 +116,6 @@ RingCurrent.close() fieldAnalogX.close() field.close() fieldReadback.close() +ramp_done.close() scan.end() diff --git a/script/local.py b/script/local.py index b15e038..f60a812 100644 --- a/script/local.py +++ b/script/local.py @@ -18,4 +18,6 @@ class SimulatedEnergyReadback(Readable): sim_energy = SimulatedEnergy() -sim_energy_readback = SimulatedEnergyReadback() \ No newline at end of file +sim_energy_readback = SimulatedEnergyReadback() + +