def main(): t = PulseWidthModulator() device = yield selectFromList(getDevices(), 'select device') channel = yield selectFromList( getPhysicalChannels(device)[CO], 'select physical channel') t.createChannel(channel) frequency = yield getType(float, 'enter frequency: ') t.setFrequency(frequency) dutyCycle = yield getType(float, 'enter duty cycle: ') t.setDutyCycle(dutyCycle) yield getUserInput('press enter to start: ') t.generatePulses() while True: FREQ, DUTY, QUIT = 'frequency', 'duty cycle', 'quit' options = (FREQ, DUTY, QUIT) option = yield selectFromList(options, 'select command') if option is QUIT: break else: value = yield getType( float, 'set new %s (%.2f): ' % (option, getattr(t, { FREQ: 'getFrequency', DUTY: 'getDutyCycle' }[option])())) getattr(t, { FREQ: 'setFrequency', DUTY: 'setDutyCycle' }[option])(value) t.stop() reactor.stop()
def main(): t = PulseWidthModulator() device = yield selectFromList( getDevices(), 'select device' ) channel = yield selectFromList( getPhysicalChannels(device)[CO], 'select physical channel' ) t.createChannel(channel) frequency = yield getType( float, 'enter frequency: ' ) t.setFrequency(frequency) dutyCycle = yield getType( float, 'enter duty cycle: ' ) t.setDutyCycle(dutyCycle) yield getUserInput('press enter to start: ') t.generatePulses() while True: FREQ, DUTY, QUIT = 'frequency', 'duty cycle', 'quit' options = (FREQ,DUTY,QUIT) option = yield selectFromList( options, 'select command' ) if option is QUIT: break else: value = yield getType( float, 'set new %s (%.2f): ' % ( option, getattr( t, { FREQ:'getFrequency', DUTY:'getDutyCycle' }[option] )() ) ) getattr( t, { FREQ:'setFrequency', DUTY:'setDutyCycle' }[option] )(value) t.stop() reactor.stop()
def main(): url = DELAY_GENERATOR_SERVER if not LOCAL else TEST_DELAY_GENERATOR_SERVER dgOptions = DG_CONFIG if not DEBUG else DEBUG_DG_CONFIG print '\n\n\n' printDict(dgOptions) configList = dgOptions.keys() if type(configList) is not list: configList = [configList] #if it is only 1 element, convert to list configList += ["Run All"] configList += ["Done"] while True: print '\n\n\n' if AUTORUN: dgToAdd = "Run All" else: dgToAdd = yield selectFromList(configList, "Which delay generator to add?") if dgToAdd == "Done" or len(configList) <= 0: break if dgToAdd == "Run All": configList.remove("Done") configList.remove("Run All") for thisDG in configList: try: if dgOptions[thisDG]['run_by_default']: dgDict.update( createDelayGenerator(thisDG, dgOptions[thisDG], dgDict)) except: print 'failed to create ' + thisDG break elif dgToAdd in configList: print dgToAdd print dgOptions[dgToAdd] dgDict.update( createDelayGenerator(dgToAdd, dgOptions[dgToAdd], dgDict)) configList.remove(dgToAdd) #confirm config doesn't have a conflict in the partnered delays. safety concern for lasers! for dg in dgDict.keys(): partnerName = dgOptions[dg]['partner'] if partnerName is None: continue partnerDefault = dgOptions[partnerName]['delay'] partnerRelative = dgOptions[dg]['delay'] + dgOptions[dg][ 'rel_part_delay'] if partnerDefault != partnerRelative: print 'your config file has a conflict in the default delay and relative delay for ' + str( dg) + ' and ' + str(partnerName) print str(partnerDefault) + ' ' + str(partnerRelative) print 'get yo shit together \n\n\n' sys.exit() runServer(WAMP=DelayGeneratorWAMP, URL=url, debug=True, outputToConsole=True)
def main(): from ab.abclient import getProtocol from ab.abbase import selectFromList, getFloat, getType from types import LongType from config.serverURLs import DELAY_GENERATOR_SERVER, TEST_DELAY_GENERATOR_SERVER from sitz import printDict from config.delaygenerator import DG_CONFIG, DEBUG_DG_CONFIG import sys print sys.argv DEBUG = len(sys.argv) > 1 and 'debug' in sys.argv LOCAL = len(sys.argv) > 1 and 'local' in sys.argv print 'debug: %s' % DEBUG print 'local: %s' % LOCAL protocol = yield getProtocol( TEST_DELAY_GENERATOR_SERVER if LOCAL else DELAY_GENERATOR_SERVER ) client = DelayGeneratorClient(protocol) delay = yield client.getDelays() dgNameList = delay.keys() activeDGs = {} for dg in dgNameList: if DEBUG: activeDGs[dg] = DEBUG_DG_CONFIG[dg] else: activeDGs[dg] = DG_CONFIG[dg] dgNameList.insert(0,'Refresh') dgNameList.append('Done') while True: delay = yield client.getDelays() print 'current settings:' for key,val in delay.items(): print '\t %s: %s' % (key,val) dgToMod = yield selectFromList(dgNameList,"Which delay generator to adjust?") if dgToMod == "Refresh": continue if dgToMod == "Done": break delayVal = yield getType(LongType,prompt="Enter a new delay (in ns):") if activeDGs[dgToMod]['partner'] is not None: print 'this delay has a partner. the partner will automatically adjust unless you override.' override = raw_input("override? (y/n)") if override == 'Y' or override == 'y': client.setDelay(dgToMod,delayVal) else: print 'setting partnered delay' client.setPartnerDelay(dgToMod,delayVal) if activeDGs[dgToMod]['partner'] is None: client.setDelay(dgToMod,delayVal) print 'shutting down' reactor.stop()
def onReady(): vm_prot = yield getProtocol(VOLTMETER_SERVER) sm_prot = yield getProtocol(STEPPER_MOTOR_SERVER) dg_prot = yield getProtocol(DELAY_GENERATOR_SERVER) vm = VoltMeterClient(vm_prot) sm = StepperMotorClient(sm_prot,POL) dg = DelayGeneratorClient(dg_prot) delays = yield dg.getDelays() pumpTime = delays[MAV_PUMP_QSW] times = np.arange(TIME_START+pumpTime,TIME_STOP+pumpTime+TIME_STEP,TIME_STEP) angles = np.arange(ANGLE_START,ANGLE_STOP+ANGLE_STEP,ANGLE_STEP) channels = yield vm.getChannels() channel = yield selectFromList(channels,'pick the mcp channel') trans = yield selectFromList(['Q3','S3','Q1'],'pick the transition you are at') bsang = yield selectFromList(['020','110'],'pick the angle of the beam splitter') for i in range(REPEAT): for angle in np.concatenate((angles,angles[::-1])): yield sm.setPosition(int(degrees_to_steps(angle))) angleStr = str(angle).zfill(3) relPath, fileName = filenameGen(path.join(trans,'TimeOfFlight','BS'+str(bsang),'HWP'+angleStr)) absPath = path.join(POOHDATAPATH,relPath) checkPath(absPath) logName = path.join(absPath,fileName+'.tsv') thisLog = LogFile(logName) for time in times[::-1]: yield dg.setPartnerDelay(MAV_PROBE_QSW, int(time)) voltage, std = yield vm.getNVoltages(channel,SHOTS) stdom = std/np.sqrt(SHOTS) print (angle,time-pumpTime,voltage,stdom) thisLog.update([time,voltage,stdom]) thisLog.close() print BELL if WAIT_FOR_TUNE: pause(None,None) reactor.stop()
def main(): from ab.abclient import getProtocol from ab.abbase import selectFromList, getFloat, getType from types import LongType from config.serverURLs import DELAY_GENERATOR_SERVER, TEST_DELAY_GENERATOR_SERVER from sitz import printDict from config.delaygenerator import DG_CONFIG, DEBUG_DG_CONFIG import sys print sys.argv DEBUG = len(sys.argv) > 1 and 'debug' in sys.argv LOCAL = len(sys.argv) > 1 and 'local' in sys.argv print 'debug: %s' % DEBUG print 'local: %s' % LOCAL protocol = yield getProtocol( TEST_DELAY_GENERATOR_SERVER if LOCAL else DELAY_GENERATOR_SERVER) client = DelayGeneratorClient(protocol) delay = yield client.getDelays() dgNameList = delay.keys() activeDGs = {} for dg in dgNameList: if DEBUG: activeDGs[dg] = DEBUG_DG_CONFIG[dg] else: activeDGs[dg] = DG_CONFIG[dg] dgNameList.insert(0, 'Refresh') dgNameList.append('Done') while True: delay = yield client.getDelays() print 'current settings:' for key, val in delay.items(): print '\t %s: %s' % (key, val) dgToMod = yield selectFromList(dgNameList, "Which delay generator to adjust?") if dgToMod == "Refresh": continue if dgToMod == "Done": break delayVal = yield getType(LongType, prompt="Enter a new delay (in ns):") if activeDGs[dgToMod]['partner'] is not None: print 'this delay has a partner. the partner will automatically adjust unless you override.' override = raw_input("override? (y/n)") if override == 'Y' or override == 'y': client.setDelay(dgToMod, delayVal) else: print 'setting partnered delay' client.setPartnerDelay(dgToMod, delayVal) if activeDGs[dgToMod]['partner'] is None: client.setDelay(dgToMod, delayVal) print 'shutting down' reactor.stop()
def main(): url = DELAY_GENERATOR_SERVER if not LOCAL else TEST_DELAY_GENERATOR_SERVER dgOptions = DG_CONFIG if not DEBUG else DEBUG_DG_CONFIG print '\n\n\n' printDict(dgOptions) configList = dgOptions.keys() if type(configList) is not list: configList = [configList] #if it is only 1 element, convert to list configList += ["Run All"] configList += ["Done"] while True: print '\n\n\n' if AUTORUN: dgToAdd = "Run All" else: dgToAdd = yield selectFromList(configList,"Which delay generator to add?") if dgToAdd == "Done" or len(configList) <= 0: break if dgToAdd == "Run All": configList.remove("Done") configList.remove("Run All") for thisDG in configList: try: if dgOptions[thisDG]['run_by_default']: dgDict.update(createDelayGenerator(thisDG,dgOptions[thisDG],dgDict)) except: print 'failed to create ' + thisDG break elif dgToAdd in configList: print dgToAdd print dgOptions[dgToAdd] dgDict.update(createDelayGenerator(dgToAdd,dgOptions[dgToAdd],dgDict)) configList.remove(dgToAdd) #confirm config doesn't have a conflict in the partnered delays. safety concern for lasers! for dg in dgDict.keys(): partnerName = dgOptions[dg]['partner'] if partnerName is None: continue partnerDefault = dgOptions[partnerName]['delay'] partnerRelative = dgOptions[dg]['delay'] + dgOptions[dg]['rel_part_delay'] if partnerDefault != partnerRelative: print 'your config file has a conflict in the default delay and relative delay for ' +str(dg)+' and '+str(partnerName) print str(partnerDefault) + ' ' + str(partnerRelative) print 'get yo shit together \n\n\n' sys.exit() runServer( WAMP = DelayGeneratorWAMP, URL = url, debug = True, outputToConsole=True )
def onReady(): vm_prot = yield getProtocol(VOLTMETER_SERVER) sm_prot = yield getProtocol(STEPPER_MOTOR_SERVER) vm = VoltMeterClient(vm_prot) sm = StepperMotorClient(sm_prot,POL) channels = yield vm.getChannels() channel = yield selectFromList(channels,'pick the mcp channel') trans = yield selectFromList(['Q3','S3','Q1'],'pick the transition you are at') bsang = yield selectFromList(['020','110'],'pick the angle of the beam splitter') # #suffix = yield selectFromList(['pump','unpump'],'are you pumping?') suffix = 'mBeamOff_diffZeroed' numPoints = (ANGLE_STOP-ANGLE_START+1)/ANGLE_STEP totalAcqTime = SWEEPS*2*(SHOTS/10.)*numPoints totalStepTime = ((ANGLE_STEP*SLOPE)/500.)*numPoints print 'ETA is: '+str((totalAcqTime + totalStepTime)/60.)+' minutes.' for sweep in range(SWEEPS): for direction in (FORWARDS,BACKWARDS): relPath, fileName = filenameGen(trans) absPath = path.join(POOHDATAPATH,relPath) checkPath(absPath) logName = path.join(absPath,fileName+'_pol_sweep_'+bsang+'_'+suffix+'.tsv') thisLog = LogFile(logName) for angle in { FORWARDS:forwards, BACKWARDS:backwards }[direction]: yield sm.setPosition(int(degrees_to_steps(angle))) voltage, std = yield vm.getNVoltages(channel,SHOTS) stdom = std/np.sqrt(SHOTS) print (sweep,angle,voltage, stdom) thisLog.update([angle,voltage,stdom]) thisLog.close() reactor.stop()
def configureVoltMeter(): device = yield selectFromList(daqmx.getDevices(), 'select device') channelDicts = [] while True: channelDict = {} aborted = False #HACK channelDict['minVal'] = 0.0 for optionKey, getOption in ( ('physicalChannel', partial(selectFromList, [None] + daqmx.getPhysicalChannels(device)[daqmx.AI], 'select channel')), ('name', partial(getUserInput, 'enter name: ')), ('maxVal', partial(getFloat, 'insert max voltage: ')), ('terminalConfig', partial(selectFromList, ('default', 'differential'), 'select terminal configuration'))): opt = yield getOption() if opt is None: aborted = True break channelDict[optionKey] = opt if aborted: if channelDicts: quit = yield selectFromList([True, False], 'end task configuration?') if quit: break continue channelDicts.append(channelDict) vm = VoltMeter(channelDicts) samplingRate = yield getFloat('enter sampling rate: ') vm.setSamplingRate(samplingRate) callbackRate = yield getFloat('enter callback rate: ') vm.setCallbackRate(callbackRate) returnValue(vm)
def getVoltMeter(): if os.path.isfile(CONFIG_FILEPATH): with open(CONFIG_FILEPATH,'r') as config_file: config_dict = pickle.loads(config_file.read()) returnValue( VoltMeter( config_dict.values() ) ) else: device = yield selectFromList(daqmx.getDevices(),'select a device') returnValue( VoltMeter( ( {VoltMeter.PHYSICAL_CHANNEL:channel,VoltMeter.VOLTAGE_RANGE:VoltMeter.V0_05} for channel in daqmx.getPhysicalChannels(device)[daqmx.AI] ) ) )
def configureVoltMeter(): device = yield selectFromList(daqmx.getDevices(),'select device') channelDicts = [] while True: channelDict = {} aborted = False #HACK channelDict['minVal'] = 0.0 for optionKey, getOption in ( ( 'physicalChannel', partial( selectFromList, [None] + daqmx.getPhysicalChannels(device)[daqmx.AI], 'select channel' ) ), ( 'name', partial( getUserInput, 'enter name: ' ) ), ( 'maxVal', partial( getFloat, 'insert max voltage: ' ) ), ( 'terminalConfig', partial( selectFromList, ( 'default', 'differential' ), 'select terminal configuration' ) ) ): opt = yield getOption() if opt is None: aborted = True break channelDict[optionKey] = opt if aborted: if channelDicts: quit = yield selectFromList([True,False],'end task configuration?') if quit: break continue channelDicts.append(channelDict) vm = VoltMeter(channelDicts) samplingRate = yield getFloat('enter sampling rate: ') vm.setSamplingRate(samplingRate) callbackRate = yield getFloat('enter callback rate: ') vm.setCallbackRate(callbackRate) returnValue(vm)
def selectChannel(self): channels = yield self.protocol.sendCommand('get-channels') channel = yield selectFromList(channels, 'select channel') returnValue(channel)
def selectChannel(self): channels = yield self.protocol.sendCommand("get-channels") channel = yield selectFromList(channels, "select channel") returnValue(channel)