Example #1
0
def driveSample(position):
    log('Driving sample holder to position ' + str(position) + ' ...')
    cur = sics.getValue('sampleNum').getFloatData()
    if abs(cur - position) < 0.01:
        log('sampleNum is already at ' + str(position))
        return

    sicsController = sics.getSicsController()
    controller = sicsController.findComponentController(devices['sampleNum'])
    #    controller.drive(position)
    cnt = 0
    while cnt < 20:
        try:
            controller.drive(position)
            break
        except SicsExecutionException, e:
            em = str(e.getMessage())
            if em.__contains__('Interrupted'):
                raise e
            time.sleep(0.6)

            log(str(e))
            log('retry driving sampleNum')

            time.sleep(1)
            while not sicsController.getServerStatus().equals(ServerStatus.EAGER_TO_EXECUTE):
                time.sleep(0.3)
            cnt += 1
            sics.handleInterrupt()

            cur = sics.getValue('sampleNum').getFloatData()
            if abs(cur - position) < 0.01:
                log('sampleNum is already at ' + str(position))
                return
Example #2
0
def printQuokkaSettings():
    datafile = sics.getValue('datafilename').getStringData()
    if ((datafile.find('QKK') != -1) and (datafile.find('.nx.hdf') != -1)):
        runNumber = (datafile.split('QKK')[1].split('.nx.hdf'))[0]
    else:
        runNumber = datafile
    print
    print "*****  Quokka Instrument Settings  *****"
    print
    print "    Last Run Number: " + runNumber
    print "        Sample Name: " + sics.getValue('samplename').getStringData()
    print
    print "         Attenuator: %.2f degree" % getAttValue()
    print " Entrance Aperature: %.2f" % getEntRotApValue()
    print "Guide Configuration: " + getGuideConfig()
    print "    Sample Position: " + str(getSamplePosition())
#    print "        Beam Stop 1: " + getBsPosition(1)
#    print "        Beam Stop 2: " + getBsPosition(2)
#    print "        Beam Stop 3: " + getBsPosition(3)
#    print "        Beam Stop 4: " + getBsPosition(4)
#    print "        Beam Stop 5: " + getBsPosition(5)
    print "        Beam Stop X: %.2f" % getBsxValue()
    print "        Beam Stop Z: %.2f" % getBszValue()
    print "  Detector Position: %.2f" %getDetPosition()
    print "    Detector Offset: %.2f" % getDetOffsetValue()
    print
    print "****************************************"
Example #3
0
def driveSample(position):
    log('Driving sample holder to position ' + str(position) + ' ...')
    cur = sics.getValue('sampleNum').getFloatData()
    if abs(cur - position) < 0.01:
        log('sampleNum is already at ' + str(position))
        return

    sicsController = sics.getSicsController()
    controller = sicsController.findComponentController(devices['sampleNum'])
    #    controller.drive(position)
    cnt = 0
    while cnt < 20:
        try:
            controller.drive(position)
            break
        except SicsExecutionException, e:
            em = str(e.getMessage())
            if em.__contains__('Interrupted'):
                raise e
            time.sleep(0.6)

            log(str(e))
            log('retry driving sampleNum')

            time.sleep(1)
            while not sicsController.getServerStatus().equals(ServerStatus.EAGER_TO_EXECUTE):
                time.sleep(0.3)
            cnt += 1
            sics.handleInterrupt()

            cur = sics.getValue('sampleNum').getFloatData()
            if abs(cur - position) < 0.01:
                log('sampleNum is already at ' + str(position))
                return
Example #4
0
def getLambdaValue():
    try:
        # For SICS after 2011-05
        return sics.getValue('/instrument/velocity_selector/wavelength_nominal').getFloatData()
    except sics.SicsError:
        # For SICS prior to 2011-05
        return sics.getValue('/instrument/velocity_selector/Lambda').getFloatData()
def drive_s2():
    slog('drive s2 away to -50 and atrans to 0')
    sics.multiDrive({'s2': -50, 'atrans':0})
    s2.value = sics.getValue('s2').getFloatData()
    atrans.value = sics.getValue('atrans').getFloatData()
    sics.execute('s2 fixed 1')
    print 'Please check if s2 is fixed!'
Example #6
0
def printQuokkaSettings():
    datafile = sics.getValue("datafilename").getStringData()
    if (datafile.find("QKK") != -1) and (datafile.find(".nx.hdf") != -1):
        runNumber = (datafile.split("QKK")[1].split(".nx.hdf"))[0]
    else:
        runNumber = datafile
    msg = "\n"
    msg += "*****  Quokka Instrument Settings  *****\n"
    msg += "\n"
    msg += "    Last Run Number: " + runNumber + "\n"
    msg += "        Sample Name: " + sics.getValue("samplename").getStringData() + "\n"
    msg += "\n"
    msg += "         Attenuator: %.2f degree" % getAttValue() + "\n"
    msg += " Entrance Aperature: %.2f" % getEntRotApValue() + "\n"
    msg += "Guide Configuration: " + getGuideConfig() + "\n"
    try:
        msg += "    Sample Position: " + str(getSamplePosition()) + "\n"
    except:
        msg += "    Sample Position: ???\n"

    #    print "        Beam Stop 1: " + getBsPosition(1)
    #    print "        Beam Stop 2: " + getBsPosition(2)
    #    print "        Beam Stop 3: " + getBsPosition(3)
    #    print "        Beam Stop 4: " + getBsPosition(4)
    #    print "        Beam Stop 5: " + getBsPosition(5)
    msg += "        Beam Stop X: %.2f" % getBsxValue() + "\n"
    msg += "        Beam Stop Z: %.2f" % getBszValue() + "\n"
    msg += "  Detector Position: %.2f" % getDetPosition() + "\n"
    msg += "    Detector Offset: %.2f" % getDetOffsetValue() + "\n"
    msg += "\n"
    msg += "****************************************\n"
    log(msg)
Example #7
0
def printQuokkaSettings():
    datafile = sics.getValue('datafilename').getStringData()
    if ((datafile.find('QKK') != -1) and (datafile.find('.nx.hdf') != -1)):
        runNumber = (datafile.split('QKK')[1].split('.nx.hdf'))[0]
    else:
        runNumber = datafile
    msg = '\n'
    msg += "*****  Quokka Instrument Settings  *****\n"
    msg += '\n'
    msg +=  "    Last Run Number: " + runNumber + '\n'
    msg +=  "        Sample Name: " + sics.getValue('samplename').getStringData() + '\n'
    msg += '\n'
    msg +=  "         Attenuator: %.2f degree" % getAttValue() + '\n'
    msg +=  " Entrance Aperature: %.2f" % getEntRotApValue() + '\n'
    msg +=  "Guide Configuration: " + getGuideConfig() + '\n'
    try:
        msg +=  "    Sample Position: " + str(getSamplePosition()) + '\n'
    except:
        msg +=  "    Sample Position: ???\n"

#    print "        Beam Stop 1: " + getBsPosition(1)
#    print "        Beam Stop 2: " + getBsPosition(2)
#    print "        Beam Stop 3: " + getBsPosition(3)
#    print "        Beam Stop 4: " + getBsPosition(4)
#    print "        Beam Stop 5: " + getBsPosition(5)
    msg +=  "        Beam Stop X: %.2f" % getBsxValue() + '\n'
    msg +=  "        Beam Stop Z: %.2f" % getBszValue() + '\n'
    msg +=  "  Detector Position: %.2f" %getDetPosition() + '\n'
    msg +=  "    Detector Offset: %.2f" % getDetOffsetValue() + '\n'
    msg += '\n'
    msg +=  "****************************************\n"
    log(msg)
Example #8
0
def getLambdaValue():
    try:
        # For SICS after 2011-05
        return sics.getValue('/instrument/velocity_selector/wavelength_nominal').getFloatData()
    except sics.SicsError:
        # For SICS prior to 2011-05
        return sics.getValue('/instrument/velocity_selector/Lambda').getFloatData()
def drive_a1_a2():
    slog('drive a2 ' + str(m2.value))
    slog('drive a1 ' + str(m1.value))
    sics.multiDrive({'a1':m1.value, 'a2':m2.value})
    a1.value = sics.getValue('a1').getFloatData()
    a2.value = sics.getValue('a2').getFloatData()
    scan_a1.value = str(math.ceil((a1.value - 1) * 1000) / 1000) + ', 0.2, 11, \'timer\', 1'
    scan_a2.value = str(math.ceil((a2.value - 2.5) * 1000) / 1000) + ', 0.5, 11, \'timer\', 1'
Example #10
0
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)
Example #11
0
def getSlitGapAndOffset(aPath, a0, bPath, b0):
    try:
        a = sics.getValue(aPath).getFloatData()
        b = sics.getValue(bPath).getFloatData()

        gap = (a - a0 - (b - b0)) / 1.0
        offset = (a - a0 + (b - b0)) / 2.0

        return (gap, offset)
    except:
        return (float('nan'), float('nan'))
Example #12
0
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)
Example #13
0
def driveFlipper(value):
    # Clear interrupt flag
    sics.getSicsController().clearInterrupt()
    # Set timeout to 120 sec
    timeout = 120
    counter = 0
    # Set flipper
    sics.set('/instrument/flipper/set_flip_on', value)
    log('Driving flipper to ' + str(value) + "...")
    while True:
        flipperValue = sics.getValue('/instrument/flipper/flip_on').getIntData()
        # Test if value is set 
        if flipperValue == value:
            log('Flipper is set to ' + str(flipperValue))
            return
        else:
            # Check timeout
            if counter >= timeout:
                raise Exception('Failed to set flipper to ' + str(value))
            # Check interrupt
            if sics.getSicsController().isInterrupted() == 1:
                raise Exception('SICS has been interrupted')
            # Otherwise sleep for 1 sec
            counter += 1
            time.sleep(1)
Example #14
0
def selBs(beamstop):
    # Get command controller
    sicsController = sics.getSicsController()
    commandController = sicsController.findComponentController('/commands/beamstops/selbsn')
    
    # Configuring command properties
    timeout = 10
    count = 0
    sics.hset(commandController, '/bs', beamstop)
    while sics.getValue('/commands/beamstops/selbsn/bs').getIntData() != beamstop:
        time.sleep(0.1)
        count += 0.1
        if count > timeout:
            raise Exception("Time out on receiving feedback on beam stop selection")
    
    cnt = 0
    while cnt < 20:
        try:
            commandController.syncExecute();
            break
        except SicsExecutionException, e:
            em = str(e.getMessage())
            if em.__contains__('Interrupted'):
                raise e
            log('retry selecting beam stop ' + str(beamstop))
            time.sleep(1)
            while not sicsController.getServerStatus().equals(ServerStatus.EAGER_TO_EXECUTE):
                time.sleep(0.3)
            cnt += 1
Example #15
0
def selBs(beamstop):
    # Get command controller
    sicsController = sics.getSicsController()
    commandController = sicsController.findComponentController('/commands/beamstops/selbsn')
    
    # Configuring command properties
    timeout = 10
    count = 0
    sics.hset(commandController, '/bs', beamstop)
    while sics.getValue('/commands/beamstops/selbsn/bs').getIntData() != beamstop:
        time.sleep(0.1)
        count += 0.1
        if count > timeout:
            raise Exception("Time out on receiving feedback on beam stop selection")
    
    cnt = 0
    while cnt < 20:
        try:
            commandController.syncExecute();
            break
        except SicsExecutionException, e:
            em = str(e.getMessage())
            if em.__contains__('Interrupted'):
                raise e
            log('retry selecting beam stop ' + str(beamstop))
            time.sleep(1)
            while not sicsController.getServerStatus().equals(ServerStatus.EAGER_TO_EXECUTE):
                time.sleep(0.3)
            cnt += 1
Example #16
0
def driveFlipper(value):
    # Clear interrupt flag
    sics.getSicsController().clearInterrupt()
    # Set timeout to 120 sec
    timeout = 120
    counter = 0
    # Set flipper
    sics.set('/instrument/flipper/set_flip_on', value)
    log('Driving flipper to ' + str(value) + "...")
    while True:
        flipperValue = sics.getValue('/instrument/flipper/flip_on').getIntData()
        # Test if value is set 
        if flipperValue == value:
            log('Flipper is set to ' + str(flipperValue))
            return
        else:
            # Check timeout
            if counter >= timeout:
                raise Exception('Failed to set flipper to ' + str(value))
            # Check interrupt
            if sics.getSicsController().isInterrupted() == 1:
                raise Exception('SICS has been interrupted')
            # Otherwise sleep for 1 sec
            counter += 1
            time.sleep(1)
Example #17
0
 def getter():
     if useController:
         controller = sics.getSicsController().findComponentController(path)
         return controller.getValue().getStringData()
     elif useRaw:
         return str(sics.get_raw_value(path))
     else:
         return sics.getValue(path).getStringData()
Example #18
0
 def getter():
     if useController:
         controller = sics.getSicsController().findComponentController(path)
         return controller.getValue().getIntData()
     elif useRaw:
         return int(sics.get_raw_value(path))
     else:
         return sics.getValue(path).getIntData()
Example #19
0
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)
Example #20
0
 def getter():
     if useController:
         controller = sics.getSicsController().findComponentController(path)
         if refresh:
             controller.getValue(True)
         return controller.getValue().getFloatData()
     elif useRaw:
         return float(sics.get_raw_value(path))
     else:
         return sics.getValue(path, refresh).getFloatData()
Example #21
0
def selBs(beamstop):
    # Get command controller
    sicsController = sics.getSicsController()
    commandController = sicsController.findComponentController('/commands/beamstops/selbsn')
    
    # Configuring command properties
    timeout = 10
    count = 0
    sics.hset(commandController, '/bs', beamstop)
    while sics.getValue('/commands/beamstops/selbsn/bs').getIntData() != beamstop:
        time.sleep(0.1)
        count += 0.1
        if count > timeout:
            raise Exception("Time out on receiving feedback on beam stop selection")
    # Synchronously run command
    commandController.syncExecute()
Example #22
0
def selBs(beamstop):
    # Get command controller
    sicsController = sics.getSicsController()
    commandController = sicsController.findComponentController(
        '/commands/beamstops/selbsn')

    # Configuring command properties
    timeout = 10
    count = 0
    sics.hset(commandController, '/bs', beamstop)
    while sics.getValue(
            '/commands/beamstops/selbsn/bs').getIntData() != beamstop:
        time.sleep(0.1)
        count += 0.1
        if count > timeout:
            raise Exception(
                "Time out on receiving feedback on beam stop selection")
    # Synchronously run command
    commandController.syncExecute()
Example #23
0
def getBsxValue():
    return sics.getValue('bsx').getFloatData()
Example #24
0
sample_name.title = 'Name'

sample_description = Par('string', 'UNKNOWN')
sample_description.title = 'Description'

sample_thickness = Par('string', '1', options=['0.01', '0.1', '1.0', '10.0'])
sample_thickness.title = 'Thickness (mm)'

Group('Sample').add(sample_name, sample_description, sample_thickness)

## Crystal
crystal_name = Par('string', 'UNKNOWN')
crystal_name.title = 'Name'
crystal_name.enabled = False
try:
    m2om = sics.getValue('/instrument/crystal/m2om').getFloatData()
    if m2om > 90:
        crystal_name.value = 'Si111 (4.74 Angstroms)'
    else:
        crystal_name.value = 'Si311 (2.37 Angstroms)'
except:
    pass

crystal_change = Act('switchCrystal()', 'switch to other crystal')

g0 = Group('Crystal')
g0.numColumns = 2
g0.add(crystal_name, crystal_change)

## Pre/Post-Sample Slit
Example #25
0
def startScan(configModel):
    ''' setup '''

    scanVariable = configModel.scanVariable
    crystal = configModel.crystal
    mode = configModel.mode

    MainDeadTime = 1.08E-6
    TransDeadTime = 1.08E-6

    if 'Si111' in crystal:
        empLevel = 0.3
        bkgLevel = 0.277
        dOmega = 2.3E-6
        gDQv = 0.0586
        gDQh = 0

        wavelength = 4.74
        TransmissionTube = 10
        TransBackground = 0  # counts per second

    elif 'Si311' in crystal:
        empLevel = 0.34
        bkgLevel = 0.333
        dOmega = 4.6E-7
        gDQv = 0.117
        gDQh = 0

        wavelength = 2.37
        TransmissionTube = 9
        TransBackground = 0  # counts per second

    else:
        print 'selected crystal is invalid'
        return
    ''' angles '''

    scan = configModel.scan

    scan_angleMin = builtin_min(scan['angles'])
    scan_angleMax = builtin_max(scan['angles'])

    if ('m1om' in scanVariable) or ('m2om' in scanVariable):
        tolerance = 2

        approved = False
        if 'Si111' in crystal:
            if (180 - tolerance <= scan_angleMin) and (scan_angleMax <=
                                                       180 + tolerance):
                approved = True

        elif 'Si311' in crystal:
            if (0 - tolerance <= scan_angleMin) and (scan_angleMax <=
                                                     0 + tolerance):
                approved = True

        if not approved:
            print 'angle out of range'
            return
    ''' execution '''

    sics.execute('hset user/name ' + configModel.user_name)
    sics.execute('hset user/email ' + configModel.user_email)

    sics.execute('hset sample/name ' + configModel.sample_name)
    sics.execute('hset sample/description ' + configModel.sample_description)
    sics.execute('hset sample/thickness %g' % configModel.sample_thickness)

    sics.execute('hset experiment/bkgLevel %g' % bkgLevel)
    sics.execute('hset experiment/empLevel %g' % empLevel)

    sics.execute('hset instrument/detector/MainDeadTime %g' % MainDeadTime)
    sics.execute('hset instrument/detector/TransDeadTime %g' % TransDeadTime)
    sics.execute('hset instrument/detector/TransBackground %g' %
                 TransBackground)
    sics.execute('hset instrument/detector/TransmissionTube %i' %
                 TransmissionTube)

    sics.execute('hset instrument/crystal/dOmega %g' % dOmega)
    sics.execute('hset instrument/crystal/gDQv %g' % gDQv)
    sics.execute('hset instrument/crystal/gDQh %g' % gDQh)
    sics.execute('hset instrument/crystal/wavelength %g' % wavelength)
    sics.execute('hset instrument/crystal/scan_variable ' + scanVariable)

    sicsController = sics.getSicsController()

    # slits
    def getSlitValues(gap, offset, a0, b0, aOpen, bOpen):

        if gap == 'fully opened':
            return (aOpen, bOpen)

        if gap == 'fully closed':
            gap = -5.0
            offset = 0.0

        a = a0 + 0.5 * float(gap) + float(offset)
        b = b0 - 0.5 * float(gap) + float(offset)

        return (a, b)

    ss1vg = configModel.ss1vg
    ss1vo = configModel.ss1vo
    ss1hg = configModel.ss1hg
    ss1ho = configModel.ss1ho

    ss2vg = configModel.ss2vg
    ss2vo = configModel.ss2vo
    ss2hg = configModel.ss2hg
    ss2ho = configModel.ss2ho

    (ss1u, ss1d) = getSlitValues(ss1vg, ss1vo, ss1u0, ss1d0, 35.8, -38.8)
    (ss1r, ss1l) = getSlitValues(ss1hg, ss1ho, ss1r0, ss1l0, 57.0, -58.0)

    (ss2u, ss2d) = getSlitValues(ss2vg, ss2vo, ss2u0, ss2d0, 37.0, -39.5)
    (ss2r, ss2l) = getSlitValues(ss2hg, ss2ho, ss2r0, ss2l0, 35.0, -35.0)

    # apply slits
    run = {}
    run['ss1u'] = ss1u
    run['ss1d'] = ss1d
    run['ss1r'] = ss1r
    run['ss1l'] = ss1l

    run['ss2u'] = ss2u
    run['ss2d'] = ss2d
    run['ss2r'] = ss2r
    run['ss2l'] = ss2l

    sics.multiDrive(run)

    time.sleep(2)
    while not sicsController.getServerStatus().equals(
            ServerStatus.EAGER_TO_EXECUTE):
        time.sleep(0.1)
    '''
    sics.execute('run ss1u %.2f' % ss1u)
    sics.execute('run ss1d %.2f' % ss1d)
    sics.execute('run ss1r %.2f' % ss1r)
    sics.execute('run ss1l %.2f' % ss1l)
    
    sics.execute('run ss2u %.2f' % ss2u)
    sics.execute('run ss2d %.2f' % ss2d)
    sics.execute('run ss2r %.2f' % ss2r)
    sics.execute('run ss2l %.2f' % ss2l)
    '''

    # load sample positions
    sam_positions = str(configModel.sam_position)

    if (len(sam_positions) == 0) or (sam_positions == 'fixed'):
        samz_list = [None]
    else:
        samz_list = []

        pos2samz = {}
        pos2samz['1'] = 33.5
        pos2samz['2'] = 178.5
        pos2samz['3'] = 323.5
        pos2samz['4'] = 468.5
        pos2samz['5'] = 613.5

        pos2samz['1 top'] = 17.4
        pos2samz['1 bottom'] = 77.7
        pos2samz['2 top'] = 163.5
        pos2samz['2 bottom'] = 223.1
        pos2samz['3 top'] = 308.0
        pos2samz['3 bottom'] = 368.1
        pos2samz['4 top'] = 454.1
        pos2samz['4 bottom'] = 513.6
        pos2samz['5 top'] = 598.2
        pos2samz['5 bottom'] = 658.0

        samz_list.append(pos2samz[sam_positions])
        '''
        for range in filter(None, sam_positions.split(',')):
            rangeItems = range.split('-')
            if ('' in rangeItems) or (len(rangeItems) < 1) or (len(rangeItems) > 2):
                raise Exception('format in "Sample Position" is incorrect')
            
            if len(rangeItems) == 1:
                samz_list.append(pos2samz[int(rangeItems[0])])
            else:
                for i in xrange(int(rangeItems[0]), int(rangeItems[1])+1):
                    samz_list.append(pos2samz[i])
                    
        if len(samz_list) == 0:
            samz_list = [0.0]
            
        '''

    for samz in samz_list:

        sics.execute('histmem stop')
        time.sleep(3)
        sics.execute('histmem mode time')

        if samz is not None:
            print 'run samz %.2f' % samz
            sics.execute('run samz %.2f' % samz)
            # sics.execute('prun samz 2' % samz) !!!
            time.sleep(1)
            while not sicsController.getServerStatus().equals(
                    ServerStatus.EAGER_TO_EXECUTE):
                time.sleep(0.1)

        sics.execute('newfile HISTOGRAM_XYT')
        #sics.execute('autosave 60') # 60 seconds
        time.sleep(1)

        # start/stop hmm
        if mode == 'count_roi':
            sics.execute('histmem preset %i' % 1)
            time.sleep(1)
            sics.execute('histmem start')
            time.sleep(5)
            while not sicsController.getServerStatus().equals(
                    ServerStatus.EAGER_TO_EXECUTE):
                time.sleep(0.1)
            sics.execute('histmem stop')

        print 'frames:', len(scan['angles'])
        for frame_index in xrange(len(scan['angles'])):
            angle = scan['angles'][frame_index]
            preset = scan['presets'][frame_index]
            maxTime = scan['maxTimes'][frame_index]

            print 'run %s %.6f' % (scanVariable, angle)
            sics.execute('run %s %.6f' % (scanVariable, angle))
            time.sleep(10)
            while not sicsController.getServerStatus().equals(
                    ServerStatus.EAGER_TO_EXECUTE):
                time.sleep(0.1)
            print 'run done'

            time.sleep(1)
            print 'histmem start'
            while True:
                if mode == 'count_roi':
                    sics.execute('histmem preset %i' % maxTime)
                else:
                    sics.execute('histmem preset %i' % preset)

                time.sleep(5)
                sics.execute('histmem start')
                time.sleep(5)

                if mode == 'count_roi':
                    print 'count_roi'

                    time.sleep(configModel.min_time)

                    count_roi = 0
                    while not sicsController.getServerStatus().equals(
                            ServerStatus.EAGER_TO_EXECUTE):
                        try:
                            count_roi = int(
                                sicsext.runCommand(
                                    'hmm configure num_events_filled_to_count_roi'
                                ))
                            print count_roi

                            if count_roi > preset:
                                print count_roi
                                print 'reached desired count_roi'
                                sics.execute('histmem pause')
                                time.sleep(1)
                                break
                        except:
                            pass

                        time.sleep(0.5)

                    break

                else:
                    while not sicsController.getServerStatus().equals(
                            ServerStatus.EAGER_TO_EXECUTE):
                        time.sleep(0.1)

                    valid = False
                    for i in xrange(10):
                        time.sleep(1)
                        detector_time = sics.getValue(
                            '/instrument/detector/time').getFloatData()

                        valid = (detector_time >= preset - 1) or (
                            detector_time >= preset * 0.90)
                        if valid:
                            break

                    print 'detector_time:', detector_time

                    if valid:
                        break
                    else:
                        print 'scan was invalid and needs to be repeated'

            #sics.execute('histmem stop')
            sics.execute('save %i' % frame_index)
            frame_index += 1
            print 'histmem done'

        sics.execute('newfile clear')
        #sics.execute('autosave 0') # disable autosave

        # Get output filename
        filenameController = sicsController.findDeviceController(
            'datafilename')
        savedFilename = filenameController.getValue().getStringData()
        print 'saved:', savedFilename

    print 'done'
    print
Example #26
0
def getDetPosition():
    return sics.getValue('det').getIntData()
Example #27
0
def getGlobalMapRate():
    return sics.getValue('/instrument/detector/total_maprate').getFloatData()
Example #28
0
def getBsRailPosition():
    return sics.getValue('bsx').getIntData()
Example #29
0
def getEntRotApValue():
    return sics.getValue('srce').getIntData()
Example #30
0
def getBszValue():
    return sics.getValue('bsz').getFloatData()
Example #31
0
def getBsxValue():
    return sics.getValue('bsx').getFloatData()
    m2_new.value = 2 * m1_new.value
    slog('Chi2 = ' + str(fit_quality.value))
    slog('lambda = ' + str(lambda_fit.value))
    slog('meV = ' + str((h * pl / lambda_fit.value / m) ** 2 * m * 500 / eV))
    slog('two-theta_offset = ' + str(two_theta_off.value * 180 / math.pi))
    
def offset_s2():
    ic = confirm('Please confirm the s2 and m2 offset')
    if ic :
        slog('setpos s2 ' + str(-two_theta_off.value) + ' 0')
        sics.setpos('s2', -two_theta_off.value, 0)
    else:
        raise Exception, 'S2 offset not accepted'
    
G3 = Group('m1 and m2 Zero Offsets')
m1_old = Par('float', sics.getValue('m1').getFloatData())
m1_new = Par('float', 0)
m2_old = Par('float', sics.getValue('m2').getFloatData())
m2_new = Par('float', 0)
offset_done = Par('bool', False)
act4 = Act('offset_m2m1()', 'Set m1, m2 Zero Offset')
G3.add(m1_old, m1_new, m2_old, m2_new, offset_done, act4)
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)
Example #33
0
def getJulaboValue():
    return sics.getValue('/sample/tc1').getFloatData()
Example #34
0
def getEntRotApValue():
    return sics.getValue('srce').getIntData()
Example #35
0
def getGuideConfig():
    return sics.getValue('/commands/optics/guide/configuration').getStringData()
Example #36
0
def getBsRailPosition():
    return sics.getValue('bsx').getIntData()
Example #37
0
def getBszValue():
    return sics.getValue('bsz').getFloatData()
Example #38
0
def getL1Value():
    return sics.getValue('l1').getFloatData()
Example #39
0
def getGuideConfig():
    return sics.getValue('/commands/optics/guide/configuration').getStringData()
Example #40
0
def getAttValue():
    """ Do something hard
    """
    return sics.getValue('att').getIntData()
Example #41
0
def getJulaboValue():
    return sics.getValue('/sample/tc1').getFloatData()
Example #42
0
def getDetPosition():
    return sics.getValue('det').getIntData()
Example #43
0
def getMaxBinRate():
    return sics.getValue('/instrument/detector/max_binrate').getFloatData()
Example #44
0
def getDetOffsetValue():
    return sics.getValue('detoff').getFloatData()
Example #45
0
def getAttValue():
    """ Do something hard
    """
    return sics.getValue('att').getIntData()
Example #46
0
def getL1Value():
    return sics.getValue('l1').getFloatData()
Example #47
0
def getL2Value():
    return sics.getValue('l2').getFloatData()
Example #48
0
def getDetOffsetValue():
    return sics.getValue('detoff').getFloatData()
Example #49
0
    global peak_res
    if Ei.value < 30:
        npeak = 6
    elif Ei.value < 50:
        npeak = 5
    else:
        npeak = 6
    twod = array.instance([npeak])
    peaks = array.instance([npeak])
    peak_res = array.instance([npeak], init = float('nan'))
    

pact = Act('previous_step()', '<- Previous Step')

sics.getDeviceController('ei').getValue(True)
ei_val = sics.getValue('ei').getFloatData()
Ei = Par('float', ei_val, command = 'calc_peaks()')
ei_old = Ei.value
lmd = Par('float', 0)
act_all = Act('run_all()', 'Scan All 6 Peaks Automatically')

G1 = Group('Peak 1')
peak_1 = Par('float', 0)
scan_1 = Par('string', '')
act1 = Act('scan_peak(0)', 'Scan Peak 1')
found_1 = Par('bool', False)
G1.add(peak_1, scan_1, act1, found_1)

G2 = Group('Peak 2')
peak_2 = Par('float', 0)
scan_2 = Par('string', '')
Example #50
0
def getL2Value():
    return sics.getValue('l2').getFloatData()
Example #51
0
# script info
__script__.title = 'Alignment Finished'
__script__.version = ''

previous_file = 'auto_8_scan_en.py'

# Use below example to create parameters.
# The type can be string, int, float, bool, file.
cact = Act('', 'The alignment is finished.')

G1 = Group('Devices Status')
sics.execute('tasub update')
sics.getDeviceController('ei').getValue(True)
sics.getDeviceController('ef').getValue(True)
sics.getDeviceController('en').getValue(True)
m1 = Par('float', sics.getValue('m1').getFloatData())
m2 = Par('float', sics.getValue('m2').getFloatData())
s1 = Par('float', sics.getValue('s1').getFloatData())
s2 = Par('float', sics.getValue('s2').getFloatData())
a1 = Par('float', sics.getValue('a1').getFloatData())
a2 = Par('float', sics.getValue('a2').getFloatData())
Ei = Par('float', sics.getValue('ei').getFloatData())
Ef = Par('float', sics.getValue('ef').getFloatData())
En = Par('float', sics.getValue('en').getFloatData())

G1.add(m1, m2, s1, s2, a1, a2, Ei, Ef, En)
sics.execute('s2 fixed -1')
    
pact = Act('previous_step()', '<- Previous Step')

def fit_curve():
Example #52
0
def getMaxBinRate():
    return sics.getValue('/instrument/detector/max_binrate').getFloatData()
Example #53
0
# Script control setup area
# script info
__script__.title = 'Run En Scan'
__script__.version = ''

previous_file = 'auto_7_align_a1a2.py'
next_file = 'auto_9_finished.py'

# Use below example to create parameters.
# The type can be string, int, float, bool, file.
pact = Act('', 'Calibration Finished')
    
G1 = Group('Scan En')
sics.getDeviceController('ei').getValue(True)
sics.getDeviceController('en').getValue(True)
ei = Par('float', sics.getValue('ei').getFloatData())
en = Par('float', sics.getValue('en').getFloatData())
scan = Par('string', '0, 0.25, 17, \'timer\', 1')
act2 = Act('scan_en()', 'Scan on en') 
def scan_en():
    aname = 'en'
    try:
        if DEBUGGING :
            aname = 'dummy_motor'
    except:
        pass
    axis_name.value = aname
    sicsext.call_back = __load_experiment_data__
    slog('s2 fixed 1')
    sics.execute('s2 fixed 1')
    slog('bmonscan ' + aname + ' ' + scan.value)
Example #54
0
def getGlobalMapRate():
    return sics.getValue('/instrument/detector/total_maprate').getFloatData()