コード例 #1
0
 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()
コード例 #2
0
ファイル: co.py プロジェクト: creilly/sitzlabexpcontrol
 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()        
コード例 #3
0
 def initializeWAMP(self):
     protocol = yield getProtocol(
         TEST_STEPPER_MOTOR_SERVER if DEBUG else STEPPER_MOTOR_SERVER)
     self.polSM = ChunkedStepperMotorClient(protocol, POL)
     angle = yield getType(float, 'enter polarizer angle: ')
     self.offset = {}
     BaseWAMP.initializeWAMP(self)
     yield self.calibrateAngle(angle)
コード例 #4
0
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()
コード例 #5
0
 def initializeWAMP(self):        
     protocol = yield getProtocol(
         TEST_STEPPER_MOTOR_SERVER
         if DEBUG else
         STEPPER_MOTOR_SERVER
     )
     self.polSM = ChunkedStepperMotorClient(protocol,POL)
     angle = yield getType(float,'enter polarizer angle: ')
     self.offset = {}
     BaseWAMP.initializeWAMP(self)        
     yield self.calibrateAngle(angle)       
コード例 #6
0
 def initializeWAMP(self):
     self.tracking = False
     protocol = yield getProtocol(TEST_STEPPER_MOTOR_SERVER if DEBUG else STEPPER_MOTOR_SERVER)
     stepperMotors = self.stepperMotors = {id: ChunkedStepperMotorClient(protocol, id) for id in STEPPER_MOTOR_KEYS}
     calibrators = self.calibrators = {
         id: Calibrator() for id, Calibrator in ((KDP, KDPCrystalCalibrator), (BBO, BBOCrystalCalibrator))
     }
     self.offsets = {}
     wavelength = yield getType(float, "enter surf wavelength: ")
     BaseWAMP.initializeWAMP(self)
     yield self.calibrateWavelength(wavelength)
コード例 #7
0
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()
コード例 #8
0
 def setChannelParameter(self):
     channel, parameter = yield self.selectChannelParameter()
     if parameter is AI.PHYSICAL_CHANNEL:
         returnValue("not yet supported")
     if parameter in (AI.MIN, AI.MAX):
         value = yield getType(float, "enter voltage: ")
     if parameter is AI.TERMINAL_CONFIG:
         trmCfgIndex = yield getListIndex(zip(*AI.TERMINAL_CONFIGS)[2], "select configuration")
         value = zip(*self.TERMINAL_CONFIGS)[0][trmCfgIndex]
     if parameter is AI.DESCRIPTION:
         value = yield getUserInput("enter description: ")
     yield self.protocol.sendCommand("set-channel-parameter", channel, parameter, value)
コード例 #9
0
 def setChannelParameter(self):
     channel, parameter = yield self.selectChannelParameter()
     if parameter is AI.PHYSICAL_CHANNEL:
         returnValue('not yet supported')
     if parameter in (AI.MIN, AI.MAX):
         value = yield getType(float, 'enter voltage: ')
     if parameter is AI.TERMINAL_CONFIG:
         trmCfgIndex = yield getListIndex(
             zip(*AI.TERMINAL_CONFIGS)[2], 'select configuration')
         value = zip(*self.TERMINAL_CONFIGS)[0][trmCfgIndex]
     if parameter is AI.DESCRIPTION:
         value = yield getUserInput('enter description: ')
     yield self.protocol.sendCommand('set-channel-parameter', channel,
                                     parameter, value)
コード例 #10
0
 def initializeWAMP(self):
     self.tracking = False
     protocol = yield getProtocol(
         TEST_STEPPER_MOTOR_SERVER if DEBUG else STEPPER_MOTOR_SERVER)
     stepperMotors = self.stepperMotors = {
         id: ChunkedStepperMotorClient(protocol, id)
         for id in STEPPER_MOTOR_KEYS
     }
     calibrators = self.calibrators = {
         id: Calibrator()
         for id, Calibrator in ((KDP, KDPCrystalCalibrator),
                                (BBO, BBOCrystalCalibrator))
     }
     self.offsets = {}
     wavelength = yield getType(float, 'enter surf wavelength: ')
     BaseWAMP.initializeWAMP(self)
     yield self.calibrateWavelength(wavelength)
コード例 #11
0
 def calibrateWavelength(self):
     wavelength = yield getType(float, 'enter current surf dial reading: ')
     yield self.protocol.sendCommand('calibrate-wavelength', wavelength)
コード例 #12
0
 def calibrateWavelength(self):
     wavelength = yield getType(float,'enter current surf dial reading: ')
     yield self.protocol.sendCommand('calibrate-wavelength',wavelength)