def auto_run(): run_action(act_s2) run_action(act1) run_action(act2) ic = confirm('Please confirm a1 peak at ' + str(peak_pos.value) +'. Click on \'OK\' to ' + 'accept the peak. Or click on \'Cancel\' to pause here.') if not ic: aname = 'a1' try: if DEBUGGING : aname = 'dummy_motor' except: pass slog('drive ' + aname + ' ' + str(a1.value)) sics.drive(aname, a1.value) print 'Calibration paused.' return run_action(offset) run_action(act3) ic = confirm('Please confirm a2 peak at ' + str(peak_pos.value) +'. Click on \'OK\' to ' + 'accept the peak. Or click on \'Cancel\' to pause here.') if not ic: aname = 'a2' try: if DEBUGGING : aname = 'dummy_motor' except: pass slog('drive ' + aname + ' ' + str(a2.value)) sics.drive(aname, a2.value) print 'Calibration paused.' return run_action(offset) run_action(nact)
def driveDet(position, offset): # Tolerance: 5mm and 1mm precision = 5 offsetPrecision = 1 shouldDrive = (position > getDetPosition() + precision) or ( position < getDetPosition() - precision) shouldDrive = (shouldDrive) or ( (offset > getDetOffsetValue() + offsetPrecision) or (offset < getDetOffsetValue() - offsetPrecision)) # Drive det only if we needed to if shouldDrive: driveDhv1(action.down) log('Driving detector to ' + str(position) + ' mm ...') while not sics.getSicsController().getServerStatus().equals( ServerStatus.EAGER_TO_EXECUTE): time.sleep(0.1) sics.drive('det', position) while not sics.getSicsController().getServerStatus().equals( ServerStatus.EAGER_TO_EXECUTE): time.sleep(0.1) log('Driving detector offset to ' + str(position) + ' mm ...') driveDetOffset(offset) while not sics.getSicsController().getServerStatus().equals( ServerStatus.EAGER_TO_EXECUTE): time.sleep(0.1) # Always set voltage up regardless if it is in position or not driveDhv1(action.up) log('Detector is now at ' + str(getDetPosition()) + 'mm with offset ' + str(getDetOffsetValue()) + 'mm')
def run_transmission_scan(mode, preset): slog('drive beam stop out, att=330') driveAtt(330) sics.run('bsz', 10) slog('drive polariser in') driveGuide(guideConfig.p1) sics.drive('bsz', 10) driveAtt(60) # slog('trans ++ att=60 det=20m count=' + str(preset)) setFlip(1) slog('counting...') quokka.scan(mode, dataType.HISTOGRAM_XY, preset) # slog('trans +- att=60 det=20m count=' + str(preset)) setFlip(0) slog('counting...') quokka.scan(mode, dataType.HISTOGRAM_XY, preset) # slog('tran unpolarised att=75 det=20m count=' + str(preset)) driveAtt(330) slog('polariser out') driveGuide(guideConfig.ga) driveAtt(75) slog('counting...') quokka.scan(mode, dataType.HISTOGRAM_XY, preset) #Drive beam stop back in slog('drive beam stop back in, att=330') driveAtt(330) sics.drive('bsz', 245)
def multi_run(): # sics.drive('att', 300) # sics.drive('nvs_lambda', 10) # sleep(0.1) # scan_att_katy(120, 30, 5, [1200 , 1200, 1800, 3600, 7200]) # sics.drive('att', 330) # sics.drive('nvs_lambda', 10) # sleep(0.1) # sleep(0.1) # scan_att_katy(210, 30, 5, [1200 , 600, 1200, 1800, 3600]) # sics.drive('att', 330) # sics.drive('att', 330) # sics.drive('nvs_lambda', 11) # sleep(0.1) # sleep(0.1) # sleep(0.1) # scan_att_katy(180, 30, 6, [1200 , 600, 1200, 1800, 3600, 3600]) # sics.drive('att', 330) # sics.drive('nvs_lambda', 4.55) sleep(0.1) #sics.drive('apx', -23) sleep(0.1) scan_att_katy(240, 30, 4, [30, 60, 1200, 2400]) sics.drive('att', 300)
def driveToLoadPosition(): log('Driving sample holder to load position') # Find soft upper limit upperlimit = sics.getValue('/sample/sample_x/softupperlim').getFloatData() # Use the soft lower limit as the load position loadPosition = math.floor(upperlimit) sics.drive('samx', loadPosition)
def scan_temp_field(fieldList, mode, preset, tempSettleTime = 1, fieldSettleTime = 1): global TRANS_PRESET # for wavelength in wavelengthList: for i in xrange(len(fieldList)): pack = fieldList[i] # driveAtt(attList[i]) log('driving tc1_driveable=' + str(pack[0])) sics.drive('tc1_driveable', pack[0]) log('waiting for temperature to settle') sleep(tempSettleTime) fields = pack[1] for j in xrange(len(fields)): driveAtt(330) field = fields[j] log('driving magnet1_driveable=' + str(field)) sics.drive('ma1_magnet_setpoint', field) log('waiting for field to settle') sleep(fieldSettleTime) log('start transmission') driveBsx(47, 100) driveAtt(210) quokka.scan(mode, dataType.HISTOGRAM_XY, TRANS_PRESET) log('start scattering') driveBsx(47, 0) driveAtt(0) quokka.scan(mode, dataType.HISTOGRAM_XY, preset) driveAtt(330)
def scan_temp_field_FW(fieldList, mode, preset, tempSettleTime = 1, fieldSettleTime = 1): # for wavelength in wavelengthList: for i in xrange(len(fieldList)): pack = fieldList[i] # driveAtt(attList[i]) value = str(pack[0]) log('driving magnet1_driveable=' + str(0)) sics.drive('ma1_setpoint', 0) log('driving tc1_driveable=' + str(50)) sics.drive('tc1_driveable', 50) log(value) sics.drive('ma1_setpoint', value) log('waiting for field to settle') log('driving tc1_driveable=' + str(55)) sics.drive('tc1_driveable', 55) sleep(300) fields = pack[1] for j in xrange(len(fields)): field = fields[j] log('driving tc1_driveable=' + str(field)) sics.drive('tc1_driveable', field) log('waiting for temperature to settle') log('start counting') quokka.scan(mode, dataType.HISTOGRAM_XY, preset)
def drive(self): try: if self.det is None and \ self.curtaindet is None and \ self.curtainl is None and \ self.curtainr is None and \ self.curtainu is None and \ self.curtaind is None: raise Exception, 'please set up Detector first.' else : dhv('DOWN') if self.det is None or self.curtaindet is None : self.multiDrive(self.det, self.curtaindet, self.curtainl, \ self.curtainr, self.curtainu, self.curtaind) else: cur_det = det() cur_curtaindet = curtaindet() if self.curtaindet <= cur_curtaindet and self.det >= cur_det : self.multiDrive(self.det, self.curtaindet, self.curtainl, \ self.curtainr, self.curtainu, self.curtaind) elif self.curtaindet > cur_curtaindet: sics.drive('det', self.det) self.multiDrive(None, self.curtaindet, self.curtainl, \ self.curtainr, self.curtainu, self.curtaind) else : self.multiDrive(None, self.curtaindet, self.curtainl, \ self.curtainr, self.curtainu, self.curtaind) sics.drive('det', self.det) dhv('UP') finally: self.clear()
def scan_temp_theta(fieldList, mode, preset, tempSettleTime = 1, thetaSettleTime = 1): # for wavelength in wavelengthList: # log('driving magnet1_driveable=' + str(0)) # sics.drive('ma1_setpoint', 0) # log('driving tc1_driveable=' + str(60)) # sics.drive('tc1_driveable', 60) # log('driving magnet1_driveable=' + str(170)) # sics.drive('ma1_setpoint', 170) # log(str(57.5)) # sics.drive('tc1_driveable', 57.5) # log('waiting for temperature to settle') # sleep(900) for i in xrange(len(fieldList)): pack = fieldList[i] # driveAtt(attList[i]) log('driving tc1_driveable=' + str(pack[0])) sics.drive('tc1_driveable', pack[0]) log('waiting for temperature to settle') sleep(tempSettleTime) thetas = pack[1] for j in xrange(len(thetas)): theta = thetas[j] log('driving rotation=' + str(theta)) sics.drive('samthet', theta) #slog('waiting for field to settle') sleep(thetaSettleTime) log('start counting') quokka.scan(mode, dataType.HISTOGRAM_XY, preset)
def scan_temp_field_ZFC(measurementList, mode, preset, tempSettleTime = 1, fieldSettleTime = 1): for temp,fieldList in measurementList: log('driving magnet1_driveable=' + str(0)) sics.drive('ma1_magnet_setpoint', 0) log('waiting for field to settle') sleep(fieldSettleTime) log('driving tc1_driveable=' + str(highTemp)) sics.drive('tc1_driveable', highTemp) log('waiting for temperature to settle') sleep(highTempSettleTime) log('driving tc1_driveable=' + str(temp)) sics.drive('tc1_driveable', temp) log('waiting for temperature to settle') sleep(firstTempSettleTime) for i,field in enumerate(fieldList): log(str(field)) log('driving magnet1_driveable=' + str(field)) sics.drive('ma1_magnet_setpoint', field) log('waiting for field to settle') sleep(fieldSettleTime) for theta in [-2.,0.,2.,4.,6.,8.]: log('driving rotation=' + str(theta)) sics.drive('samthet', theta) sleep(thetaSettleTime) log('start counting') quokka.scan(mode, preset)
def scan_theta(thetaList, mode, preset): for theta in thetaList: log('driving rotation=' + str(theta)) sics.drive('samthet', theta) sleep(thetaSettleTime) log('start counting') quokka.scan(mode, preset)
def runSampleEnvironmentScan(sampleEvnGroup): # Gets the sample environment settings evnSetting = sampleEnvironments[sampleEvnGroup['target']] controller = evnSetting['controller'] preset = evnSetting[sampleEvnGroup['setting']]['preset'] waitTime = evnSetting[sampleEvnGroup['setting']]['wait'] # Drive drivable controller deviceController = sics.getDeviceController(controller) if (deviceController == None): log('Driving controller ' + controller + ' to set point ' + str(preset)) driverPath = WorkspaceUtils.getFolder(PYTHON_DRIVERS_PATH).getFullPath().toString() driverPath = driverPath.replace('/', '.')[1:] exec('from ' + driverPath + ' import ' + controller) exec(controller + '.drive(preset)') else: log('Driving controller ' + controller + ' to set point ' + str(preset)) sics.drive(controller, preset) # Stabilisation log('Stabilising the controller for ' + str(waitTime) + ' sec') sleep(waitTime) # Recurrsively run (for effectiveness we reverse the configuration on every second run) if sampleEvnGroup['setting'] % 2 == 1: runQuokkaScan(sampleEvnGroup['contents'], True, controller + '=' + str(preset)) else: runQuokkaScan(sampleEvnGroup['contents'], False, controller + '=' + str(preset))
def checkedDrive(motor, value, useController=False): waitUntilSicsIs(ServerStatus.EAGER_TO_EXECUTE) if useController: controller = sics.getSicsController().findComponentController(motor) controller.drive(value) else: sics.drive(motor, value)
def zero_offset(): dev = device_name.value if dev != None and dev != '': slog('set zero offset for ' + dev) cur_value = sics.getValue(dev).getFloatData() sics.setpos(dev, cur_value, visual_value.value) slog('drive ' + dev + ' ' + str(cur_value)) sics.drive(dev, cur_value)
def curtaind(val=None): if not val is None: if not _is_within_precision_('curtaind', val, .1): dhv('DOWN') sics.drive('curtaind', val) dhv('UP') else: log('curtaind is already at ' + str(val) + ', skipped') return sics.get_raw_value('curtaind')
def curtaind(val = None): if not val is None : if not _is_within_precision_('curtaind', val, .1): dhv('DOWN') sics.drive('curtaind', val) dhv('UP') else: log('curtaind is already at ' + str(val) + ', skipped') return sics.get_raw_value('curtaind')
def scan_temp_field_FW(fieldList, mode, preset, tempSettleTime = 1, fieldSettleTime = 1): # for wavelength in wavelengthList: sics.execute('setvolt ' + str(10)) sleep(15) for i in xrange(len(fieldList)): pack = fieldList[i] # driveAtt(attList[i]) # log('driving tc1_driveable=' + str(pack[0])) value = str(pack[0]) log(value) # sics.drive('tc1_driveable', value) # log('waiting for temperature to settle') # sleep(tempSettleTime) fields = pack[1] for j in xrange(len(fields)): log('driving magnet1_driveable=' + str(0)) sics.drive('ma1_setpoint', 0) sics.drive('tc1_driveable', 50) log('waiting for temperature to settle') log('driving magnet1_driveable=' + str(225)) sics.drive('ma1_setpoint', 225) sics.drive('tc1_driveable', value) log(value) log('waiting for temperature to settle') sleep(900) field = fields[j][0] log('driving magnet1_driveable=' + str(field)) sics.drive('ma1_setpoint', field) log('waiting for field to settle') sleep(fieldSettleTime) e_fields = fields[j][1] for k in xrange(len(e_fields)): e_field = e_fields[k] log('drive electronic field to ' + str(e_field)) # sics.execute('setvolt ' + str(500)) # sleep(15) # sics.execute('setvolt ' + str(1000)) # sleep(15) # sics.execute('setvolt ' + str(1500)) # sleep(10) # sics.execute('setvolt ' + str(2000)) # sleep(10) # sics.execute('setvolt ' + str(2500)) # sleep(1) sics.execute('setvolt ' + str(e_field)) # prep_transmission() # quokka.scan(scanMode.time, dataType.HISTOGRAM_XY, 120) # # prep_scattering() log('start counting') quokka.scan(mode, dataType.HISTOGRAM_XY, preset)
def driveConfig(L2,bsx,bsz): slog('start driving detector...') slog('L2=' + str(L2) + ' bsx=' + str(bsx) + ' bsz=' + str(bsz) + ' att=330') driveAtt(330) sics.run('bsx', bsx) sics.run('bsz', bsz) driveDet(L2, 0) sics.drive('bsx', bsx) sics.drive('bsz', bsz) slog('drive completed')
def driveAtt(value): """ Do something very hard """ while not sics.getSicsController().getServerStatus().equals(ServerStatus.EAGER_TO_EXECUTE): time.sleep(0.2) log("Driving attenuator to " + str(value) + " degree ...") time.sleep(0.2) sics.drive("att", value) log("Attenuator is now at " + str(getAttValue()) + " degree")
def driveAtt(value): """ Do something very hard """ while not sics.getSicsController().getServerStatus().equals(ServerStatus.EAGER_TO_EXECUTE): time.sleep(0.2) log('Driving attenuator to ' + str(value) + ' degree ...') time.sleep(0.2) sics.drive('att', value) log('Attenuator is now at ' + str(getAttValue()) + ' degree')
def line_up(): slog('drive m2 ' + str(m2.value)\ + ' s2 ' + str(s2.value)\ + ' a1 ' + str(a1.value)\ + ' a2 ' + str(a2.value)\ + ' atrans ' + str(atrans.value)) sics.multiDrive({'m2':m2.value, 's2':s2.value, \ 'a1':a1.value, 'a2':a2.value}) sics.drive('atrans', atrans.value) print 'done'
def scan_wavelength(wavelengthList, mode, preset): for wavelength in wavelengthList: sics.drive('nvs_lambda', wavelength) sleep(0.1) # for att in attListTrans: # driveAtt(att) # sleep(0.1) log('starting run, wavelength=') log(str(wavelength)) quokka.scan(mode, dataType.HISTOGRAM_XY, preset)
def bs5(val = None): if not val is None: if val.upper() == 'IN': sics.drive('bs5', 65) elif val.upper() == 'OUT': sics.drive('bs5', 0) cur = sics.get_raw_value('bs5') if cur >= 63 and cur <= 67: return 'IN' else : return 'OUT'
def setTemperature(setpoint, heaterRange, waitForTemperature, tempSettleTime): slog('set tc1 heater range=' + str(heaterRange)) sics.set('/sample/tc1/heater/heaterRange',heaterRange) if waitForTemperature==0: slog('set sample T=' + str(setpoint) + ' & not wait for it') sics.run('tc1_driveable', setpoint) else: slog('set sample T=' + str(setpoint) + ' & wait till it is reached') sics.drive('tc1_driveable', setpoint) sleep(tempSettleTime) slog('waiting '+ str(tempSettleTime) +'sec for temperature to settle')
def offset_m2m1(): if offset_done.value : print 'You have already set the zero offset' else: slog('setpos m1 ' + str(m1_old.value) + ' ' + str(m1_new.value)) sics.setpos('m1', m1_old.value, m1_new.value) sics.drive('m1', m1_old.value) slog('setpos m2 ' + str(m2_old.value) + ' ' + str(m2_new.value)) sics.setpos('m2', m2_old.value, m2_new.value) sics.drive('m2', m2_old.value) offset_done.value = True
def driveToLoadPosition(): log("Driving sample holder to load position") # Find soft upper limit upperlimit = sics.getValue("/sample/sample_x/softupperlim").getFloatData() hardlimit = sics.getValue("/sample/sample_x/hardupperlim").getFloatData() softzero = sics.getValue("/sample/sample_x/softzero").getFloatData() if upperlimit > hardlimit - softzero: upperlimit = hardlimit - softzero # Use the soft lower limit as the load position loadPosition = math.floor(upperlimit) sics.drive("samx", loadPosition)
def scan_device(): np1 = int(scan1_np.value) if np1 <= 0: raise Exception, 'invalid number of points for dimension 1' np2 = int(scan2_np.value) if np2 <= 0: raise Exception, 'invalid number of points for dimension 2' motor1 = device1_name.value motor2 = device2_name.value start1 = scan1_start.value stop1 = scan1_stop.value start2 = scan2_start.value stop2 = scan2_stop.value if np1 == 1: step1 = 0. else: step1 = (stop1 - start1) * 1.0 / (np1 - 1) if np2 == 1: step2 = 0. else: step2 = (stop2 - start2) * 1.0 / (np2 - 1) mode = scan_mode.value preset = scan_preset.value slog('*********** scan started ***********') rev = False for i in xrange(np1): pos1 = start1 + i * step1 slog('drive ' + motor1 + ' ' + str(pos1)) sics.drive(motor1, pos1) for j in xrange(np2): if rev: pos2 = stop2 - j * step2 else: pos2 = start2 + j * step2 slog('drive ' + motor2 + ' ' + str(pos2)) sics.drive(motor2, pos2) slog('collect data with ' + motor1 + '=' + str(pos1) + ' and ' + motor2 + '=' + str(pos2) + ' on "' + mode + '" for preset of ' + str(preset)) sicsext.runscan('dummy_motor', 0, 0, 1, mode, preset, None, True, \ 'HISTOGRAM_XY') rev = not rev slog('*********** scan finished ***********')
def scan_temp_field(fieldList, mode, preset, tempSettleTime = 1, fieldSettleTime = 1): # for wavelength in wavelengthList: log('driving magnet1_driveable=' + str(0)) sics.drive('ma1_setpoint', 0) sics.drive('tc1_driveable', 60) log('driving tc1_driveable=' + str(60)) sics.drive('tc1_driveable', 57.125) log('driving tc1_driveable=' + str(57.125)) quokka.scan(mode, dataType.HISTOGRAM_XY, preset) quokka.scan(mode, dataType.HISTOGRAM_XY, preset) quokka.scan(mode, dataType.HISTOGRAM_XY, preset) quokka.scan(mode, dataType.HISTOGRAM_XY, preset) quokka.scan(mode, dataType.HISTOGRAM_XY, preset) quokka.scan(mode, dataType.HISTOGRAM_XY, preset) quokka.scan(mode, dataType.HISTOGRAM_XY, preset) quokka.scan(mode, dataType.HISTOGRAM_XY, preset) quokka.scan(mode, dataType.HISTOGRAM_XY, preset) quokka.scan(mode, dataType.HISTOGRAM_XY, preset) quokka.scan(mode, dataType.HISTOGRAM_XY, preset) quokka.scan(mode, dataType.HISTOGRAM_XY, preset) log('driving magnet1_driveable=' + str(200)) sics.drive('ma1_setpoint', 200) log('waiting for field to settle') sleep(0) log('start counting') quokka.scan(mode, dataType.HISTOGRAM_XY, preset)
def scan_temp_field(filedList, mode, preset): # for wavelength in wavelengthList: for i in xrange(len(filedList)): pack = filedList[i] # driveAtt(attList[i]) log('starting run, tc1_driveable=', pack[0]) sics.drive('tc1_driveable', pack[0]) sleep(0.1) fields = pack[1] for j in xrange(len(fields)): field = fields[j] log('starting run, magnet1_driveable=', field) sics.drive('magnet1_setpoint', field) quokka.scan(mode, dataType.HISTOGRAM_XY, preset)
def scan_temp_field_FW(measurementList, mode, preset, tempSettleTime = 1, fieldSettleTime = 1): for field,tempList in measurementList: log('driving magnet1_driveable=' + str(0)) sics.drive('ma1_magnet_setpoint', 0) log('waiting for field to settle') sleep(fieldSettleTime) log('driving tc1_driveable=' + str(lowTemp)) sics.drive('tc1_driveable', lowTemp) log('waiting for temperature to settle') sleep(lowTempSettleTime) log('driving magnet1_driveable=' + str(field)) sics.drive('ma1_magnet_setpoint', field) log('waiting for field to settle') sleep(fieldSettleTime) for i,temp in enumerate(tempList): log(str(temp)) sics.drive('tc1_driveable', temp) log('waiting for temperature to settle') if i ==0: sleep(firstTempSettleTime) else: sleep(tempSettleTime) log('start counting') quokka.scan(mode, preset)
def scan_temp_helical_FW(tempList, mode, preset, tempSettleTime = 1, fieldSettleTime = 1): log('driving magnet1_driveable=' + str(0)) sics.drive('ma1_magnet_setpoint', 0) log('waiting for field to settle') sleep(fieldSettleTime) log('driving tc1_driveable=' + str(lowTemp)) sics.drive('tc1_driveable', lowTemp) log('waiting for temperature to settle') sleep(lowTempSettleTime) for i,temp in enumerate(tempList): log(str(temp)) sics.drive('tc1_driveable', temp) log('waiting for temperature to settle') if i ==0: sleep(firstTempSettleTime) else: sleep(tempSettleTime) for theta in [0.,6.]: log('driving rotation=' + str(theta)) sics.drive('samthet', theta) sleep(thetaSettleTime) log('start counting') quokka.scan(mode, preset)
def drive_a1a2_0(): if ei_old != Ei.value : slog('drive Ei ' + str(Ei.value)) sics.execute('tasub update') time.sleep(1) try: sics.drive('ei', Ei.value) except: pass time.sleep(1) while str(sics.getDeviceController('ei').getStatus()) == 'RUNNING': time.sleep(0.5) slog('drive a1 0 a2 0') sics.multiDrive({'a1' : 0, 'a2' : 0})
def offset_s2(): aname = 's2' try: if DEBUGGING: aname = 'dummy_motor' except: pass if offset_done.value: print 'You have already set the zero offset of ' + aname else: slog('drive ' + aname + ' ' + str(peak_pos.value)) sics.drive(aname, peak_pos.value) slog('set peak position to ' + str(s2.value)) sics.setpos(aname, peak_pos.value, s2.value) offset_done.value = True print 'done'
def sample(val=None): global __sampleMap__, __sampleNum__ if not val is None: if not type(val) is int or not type(val) is float: val = float(str(val)) if val <= 0 or val >= 11: raise Exception, 'sample number not supported, must be within 1 to 10, got ' + str( val) else: # sics.drive('samx', __sampleMap__[round(val)]) sics.drive('samx', __cal_samx__(val)) raw = sics.get_raw_value('samx') samNum = -1 for i in xrange(len(__sampleMap__[__sampleNum__])): if raw > __sampleMap__[__sampleNum__][i]: if i > 0: samNum = i - (raw - __sampleMap__[__sampleNum__][i]) / ( __sampleMap__[__sampleNum__][i - 1] - __sampleMap__[__sampleNum__][i]) break if samNum < 0.05 or samNum > len(__sampleMap__[__sampleNum__]) - 1.05: samNum = -1 return round(samNum, 1)
def __bs__(id, val=None): bs_name = 'bs' + str(id) if not val is None: if type(val) is int or type(val) is float or str(val).isdigit(): sics.drive(bs_name, val) elif str(val).upper() == 'IN': sics.drive(bs_name, 65) elif str(val).upper() == 'OUT': sics.drive(bs_name, 0) cur = sics.get_raw_value(bs_name) if cur >= 63 and cur <= 67: return 'IN' else: return 'OUT'
def samz(val=None): if not val is None: sics.drive('samz', val) return sics.get_raw_value('samz')
def som(val=None): if not val is None: sics.drive('som', val) return sics.get_raw_value('som')
def driveDetOffset(value): log('Driving detector offset to ' + str(value) + ' ...') sics.drive('detoff', value) log('Detector offset is now at ' + str(getDetOffsetValue()))
def driveBsx(baseValue, offset): log('Driving beamstop x to ' + str(baseValue + offset) + 'mm ...') sics.drive('bsx', baseValue + offset) log('Beamstop x is now at ' + str(getBsxValue()) + 'mm')
def drive(self): try: if self.det is None and \ self.curtaindet is None and \ self.curtainl is None and \ self.curtainr is None and \ self.curtainu is None and \ self.curtaind is None: raise Exception, 'please set up Detector first.' else: need_drive = False if self.det != None and not _is_within_precision_( 'det', self.det, .1): need_drive = True else: if self.det != None: log('det is already at ' + str(self.det) + ', skipped') if self.curtaindet != None and not _is_within_precision_( 'curtaindet', self.curtaindet, .1): need_drive = True else: if self.curtaindet != None: log('curtaindet is already at ' + str(self.curtaindet) + ', skipped') if self.curtainl != None and not _is_within_precision_( 'curtainl', self.curtainl, .1): need_drive = True else: if self.curtainl != None: log('curtainl is already at ' + str(self.curtainl) + ', skipped') if self.curtainr != None and not _is_within_precision_( 'curtainr', self.curtainr, .1): need_drive = True else: if self.curtainr != None: log('curtainr is already at ' + str(self.curtainr) + ', skipped') if self.curtainu != None and not _is_within_precision_( 'curtainu', self.curtainu, .1): need_drive = True else: if self.curtainu != None: log('curtainu is already at ' + str(self.curtainu) + ', skipped') if self.curtaind != None and not _is_within_precision_( 'curtaind', self.curtaind, .1): need_drive = True else: if self.curtaind != None: log('curtaind is already at ' + str(self.curtaind) + ', skipped') if need_drive: dhv('DOWN') if self.det is None or self.curtaindet is None: self.multiDrive(self.det, self.curtaindet, self.curtainl, \ self.curtainr, self.curtainu, self.curtaind) else: cur_det = det() cur_curtaindet = curtaindet() if self.curtaindet <= cur_curtaindet and self.det >= cur_det: self.multiDrive(self.det, self.curtaindet, self.curtainl, \ self.curtainr, self.curtainu, self.curtaind) elif self.curtaindet > cur_curtaindet: sics.drive('det', self.det) self.multiDrive(None, self.curtaindet, self.curtainl, \ self.curtainr, self.curtainu, self.curtaind) else: self.multiDrive(None, self.curtaindet, self.curtainl, \ self.curtainr, self.curtainu, self.curtaind) sics.drive('det', self.det) dhv('UP') else: log('no need to drive the detectors, pass') return finally: self.clear()
def driveBsRailOut(): value = -64 + 100 log('Driving beamstop rail out to ' + str(value) + ' ...') sics.drive('bsx', value) log('Beamstop rail is now at ' + str(getBsRailPosition()))
def att(val=None): if not val is None: sics.drive('att', val) return sics.get_raw_value('att')
def driveEntRotAp(value): log('Driving entrance aperture to ' + str(value) + ' degree ...') sics.drive('srce', value) log('Entrance aperture is now at ' + str(getEntRotApValue()) + ' degree')
def bs_att(bs_num, bs_angle, att_num): if type(bs_num) is str or type(bs_num) is unicode: bs_num = int(bs_num) if bs_num < 3 or bs_num > 5: raise Exception, 'beam stop number ' + str( bs_num) + ' is not supported' if type(att_num) is str or type(att_num) is unicode: att_num = int(att_num) if att_num < 0 or att_num > 5: raise Exception, 'att position number ' + str( att_num) + ' is not supported' if type(bs_angle) is str or type(bs_angle) is unicode: bs_angle = float(bs_angle) cur_bs3 = bs3() cur_bs4 = bs4() cur_bs5 = bs5() cur_att = att_pos() # Check if the current configuration has all beamstops out of position and the # empty attenuator position selected. If this is the case, put an attenuator # in (which will engage the fast shutter while doing so). # Should not ever happen, but best to check. if (cur_bs3 < 63.0 or cur_bs3 > 67.0) and (cur_bs4 < 63.0 or cur_bs4 > 67.0) \ and (cur_bs5 < 63.0 or cur_bs5 > 67.0) and cur_att == 3: log('put attenuator to 5 first') att_pos(5) # This is nominally the BS in position for all beamstops # Inserts a given beamstop and then remove all others. Then moves the attenuator. if bs_angle >= 63.0 and bs_angle <= 67.0: log('put bs' + str(bs_num) + ' in') if bs_num == 3: sics.drive('bs3', bs_angle) sics.drive('bs4', 0) sics.drive('bs5', 0) elif bs_num == 4: sics.drive('bs4', bs_angle) sics.drive('bs3', 0) sics.drive('bs5', 0) elif bs_num == 5: sics.drive('bs5', bs_angle) sics.drive('bs3', 0) sics.drive('bs4', 0) log('put attenuator to ' + str(att_num)) att_pos(att_num) # If you are driving an attenuator in, do this first, then move the beam stop elif (bs_angle < 63.0 or bs_angle > 67.0) and att_num != 3: log('put attenuator to ' + str(att_num)) att_pos(att_num) log('put bs' + str(bs_num) + ' in') if bs_num == 3: sics.drive('bs3', bs_angle) sics.drive('bs4', 0) sics.drive('bs5', 0) elif bs_num == 4: sics.drive('bs4', bs_angle) sics.drive('bs3', 0) sics.drive('bs5', 0) elif bs_num == 5: sics.drive('bs5', bs_angle) sics.drive('bs3', 0) sics.drive('bs4', 0) else: # Do not let the BS_Att command drive to an unsafe configuration raise Exception, 'No valid beamstop or attenuator has been selected no movement of beamstop or attempted'
def driveBsz(value): log('Driving beamstop z to ' + str(value) + 'mm ...') sics.drive('bsz', value) log('Beamstop z is now at ' + str(getBszValue()) + 'mm')