Esempio n. 1
0
def set_gain_mask(gain_arr, trbit, dbpath, dbalias, src):
    """
    gain_arr: 3-d numpy array of the gain values
    dbpath: db path connection info file path
    dbalias: e.g. BEAM, NOBEAM, etc.
    src: XcsEndstation/0/Epix10ka2M/0
    """
    srcid = get_src_info(src)

    db = pycdb.Db(dbpath)
    xtc = db.get(alias=dbalias, src=srcid)[0]
    cfg = xtc.get()
    if 'elemCfg' in cfg:
        for i, elem in enumerate(cfg['elemCfg']):
            mask = elem['asicMask']
            elem['asicPixelConfigArray'] = gain_arr[i].tolist()
            for asicNum in range(4):
                if mask & (1 << asicNum):
                    elem['asics'][asicNum]['trbit'] = trbit
    else:
        mask = cfg['AsicMask']
        cfg['asicPixelConfigArray'] = gain_arr.tolist()
        for asicNum in range(4):
            if mask & (1 << asicNum):
                cfg['asics'][asicNum]['trbit'] = trbit
    xtc.set(cfg)
    db.set(xtc, dbalias)
    db.commit()
Esempio n. 2
0
 def create(self, daq=None):
     if self.dbpath is None and daq != None:
         self.dbpath = daq.dbpath()
     # try to append the file name if the path returns a dir
     if os.path.isdir(self.dbpath):
         self.dbpath = os.path.join(self.dbpath, '.configdbrc')
     self.db = pycdb.Db(self.dbpath)
Esempio n. 3
0
 def _connect(self):
     """Initializes the pycdb.Db object. If it does not exist."""
     if self._db is None:
         try:
             self._db = pycdb.Db(dbpath.format(self.hutch.lower()))
             return True
         except Exception as e:
             print "Failed to connect to daq config mysql database."
             print e
             return False
Esempio n. 4
0
  def configure(self):
    cdb = pycdb.Db(self.daq.dbpath())
    newkey = self.daq.dbkey()
    print "db path = %s  key = 0x%x" % (self.daq.dbpath(), self.daq.dbkey())

    print "daq configure...",
    sys.stdout.flush()
#    self.daq.configure(key=newkey)
    self.daq.configure(key=newkey,controls=self.controls)
    print " done."

    return 0
 def create(self):
     self.db = pycdb.Db(self.dbpath)
Esempio n. 6
0
def scan_parameter(device, configtype, parameter, values, enumkey=None):
    import sys

    parser = OptionParser()
    parser.add_option("-a",
                      "--address",
                      dest="host",
                      default='localhost',
                      help="connect to DAQ at HOST",
                      metavar="HOST")
    parser.add_option("-p",
                      "--platform",
                      dest="platform",
                      type="int",
                      default=3,
                      help="connect to DAQ at PLATFORM",
                      metavar="PLATFORM")
    parser.add_option("-D",
                      "--detector",
                      dest="detector",
                      type="string",
                      default='NoDetector',
                      help="detector to scan, default NoDetector",
                      metavar="DET")
    parser.add_option("-I",
                      "--detectorID",
                      dest="detectorID",
                      type="int",
                      default=0,
                      help="detector ID  to scan, default 0",
                      metavar="D_ID")
    parser.add_option("-i",
                      "--deviceID",
                      dest="deviceID",
                      type="int",
                      default=0,
                      help="device ID to scan, default 0",
                      metavar="DEV_ID")
    parser.add_option("-t",
                      "--typeIdVersion",
                      dest="typeIdVersion",
                      type="int",
                      default=1,
                      help="type ID Version in use, default 1",
                      metavar="typeIdVersion")
    parser.add_option("-A",
                      "--dbalias",
                      dest="dbalias",
                      type="string",
                      help="data base key in use",
                      metavar="DBALIAS")
    parser.add_option("-e",
                      "--events",
                      dest="events",
                      type="int",
                      default=1000,
                      help="record N events/cycle",
                      metavar="EVENTS")
    parser.add_option("-u",
                      "--user",
                      dest="userFlag",
                      type="int",
                      default=1,
                      help="Iff zero then no user, default=1",
                      metavar="DARKEVENTS")

    (options, args) = parser.parse_args()

    options.device = device
    options.typeId = configtype

    print 'host', options.host
    print 'platform', options.platform
    print 'dbalias', options.dbalias
    print 'detector', options.detector
    print 'detectorID', options.detectorID
    print 'device', options.device
    print 'deviceID', options.deviceID
    print 'events', options.events
    print 'userFlag', options.userFlag

    print 'device', device
    print 'configtype', configtype
    print 'parameter', parameter
    print 'values', values

    # Connect to the daq system
    daq = pydaq.Control(options.host, options.platform)
    daq.connect()
    print 'Partition is', daq.partition()
    detectors = daq.detectors()
    devices = daq.devices()
    types = daq.types()
    #    print 'types are :\n', types

    found = [False, False, False]
    index = 0
    for member in detectors:
        if member == options.detector:
            detectorValue = (index << 24) | ((options.detectorID & 0xff) << 16)
            found[0] = True
        index = index + 1
    index = 0
    for member in devices:
        if member == options.device:
            detectorValue = detectorValue | (index << 8) | (options.deviceID
                                                            & 0xff)
            found[1] = True
        index = index + 1
    index = 0
    for member in types:
        if member == options.typeId:
            typeIdValue = index | (options.typeIdVersion << 16)
            found[2] = True
        index = index + 1
    if found[0] and found[1] and found[2]:
        print "detector hex value", hex(detectorValue)
        print 'typeId', hex(typeIdValue)
    else:
        if not found[0]:
            print "Detector", options.detector, "not found!"
        if not found[1]:
            print "Device", options.device, "not found!"
        if not found[2]:
            print "Type", options.typeId, "not found!"
        print "Exiting"
        exit()
#
#  First, get the current configuration key in use and set the value to be used
#

    cdb = pycdb.Db(daq.dbpath())
    key = daq.dbkey()
    alias = daq.dbalias()
    print 'Retrieved key ' + hex(key) + ' alias ' + alias

    #
    #  Generate a new key with different epix and EVR configuration for each cycle
    #
    if options.dbalias == None:
        newkey = cdb.clone(alias)
    else:
        newkey = cdb.clone(options.dbalias)

    print 'Generated key ', hex(newkey)
    print 'key', hex(key)
    print 'detectorValue', hex(detectorValue)
    print 'typeIdValue', hex(typeIdValue)
    xtc = cdb.get(key=key, src=detectorValue, typeid=typeIdValue)[0]
    print 'xtc is', xtc
    config = xtc.get(0)
    if enumkey is not None:
        enums = xtc.get_enums()[enumkey]
    else:
        enums = None
    print 'Composing the sequence of configurations ...'
    cycle = 0  # cycle number excluding skipped
    for value in values:
        if parameter in config:
            if enums is not None:
                config[parameter] = enums[value]
            else:
                config[parameter] = value
        print config, cycle
        xtc.set(config, cycle)
        cycle += 1

    cdb.substitute(newkey, xtc)
    cdb.unlock()
    print '    done'

    #  Send the structure the first time to put the control variables
    #    in the file header
    #

    daq.configure(key=newkey, events=options.events)

    print "Configured."

    #
    #  Wait for the user to declare 'ready'
    #    Setting up monitoring displays for example
    #
    if options.userFlag > 0:
        ready = raw_input('--Hit Enter when Ready-->')

    for value in values:
        print 'parameter', parameter, 'value', value
        daq.begin(events=options.events)
        daq.end()

#
#  Wait for the user to declare 'done'
#    Saving monitoring displays for example
#
    if options.userFlag > 0:
        ready = raw_input('-- Finished, hit Enter to exit -->')
    print 'Restoring key', hex(key)
    daq.configure(key=key, events=1)
Esempio n. 7
0
def scan_offset(device, configtype):
    import sys

    parser = OptionParser()
    parser.add_option("-a",
                      "--address",
                      dest="host",
                      default='localhost',
                      help="connect to DAQ at HOST",
                      metavar="HOST")
    parser.add_option("-p",
                      "--platform",
                      dest="platform",
                      type="int",
                      default=0,
                      help="connect to DAQ at PLATFORM",
                      metavar="PLATFORM")
    parser.add_option("-D",
                      "--detector",
                      dest="detector",
                      type="string",
                      default='NoDetector',
                      help="detector to scan, default NoDetector",
                      metavar="DET")
    parser.add_option("-I",
                      "--detectorID",
                      dest="detectorID",
                      type="int",
                      default=0,
                      help="detector ID  to scan, default 0",
                      metavar="D_ID")
    #    parser.add_option("-d","--device",dest="device",type="string",default='Epix10ka',
    #                      help="device to scan, default Epix10ka",metavar="DEV")
    parser.add_option("-i",
                      "--deviceID",
                      dest="deviceID",
                      type="int",
                      default=0,
                      help="device ID to scan, default 0",
                      metavar="DEV_ID")
    parser.add_option("-t",
                      "--typeIdVersion",
                      dest="typeIdVersion",
                      type="int",
                      default=1,
                      help="type ID Version in use, default 1",
                      metavar="typeIdVersion")
    parser.add_option("-A",
                      "--dbalias",
                      dest="dbalias",
                      type="string",
                      help="data base key in use",
                      metavar="DBALIAS")
    parser.add_option("-s",
                      "--space",
                      dest="space",
                      type="int",
                      default=7,
                      help="space is the spacing in the array",
                      metavar="SPACE")
    parser.add_option("-e",
                      "--events",
                      dest="events",
                      type="int",
                      default=4608,
                      help="record N events/cycle",
                      metavar="EVENTS")
    parser.add_option("-v",
                      "--value0",
                      dest="Value0",
                      type="int",
                      default=0,
                      help="Value0 for most of the pixel array, default=0 ",
                      metavar="VALUE0")
    parser.add_option(
        "-V",
        "--value1",
        dest="Value1",
        type="int",
        default=1,
        help="Value1 for pixels under test in the pixel array, default=1",
        metavar="VALUE1")
    parser.add_option("-d",
                      "--darkEvents",
                      dest="darkEvents",
                      type="int",
                      default=1200,
                      help="Number of events in each Dark, default=1200 ",
                      metavar="DARKEVENTS")
    parser.add_option("-u",
                      "--user",
                      dest="userFlag",
                      type="int",
                      default=1,
                      help="Iff zero then no user, default=1",
                      metavar="USERFLAG")
    parser.add_option("-o",
                      "--cycleStart",
                      dest="cycleStart",
                      type="int",
                      default=0,
                      help="Starting at cycle number, default=0",
                      metavar="CYCLESTART")
    parser.add_option("-O",
                      "--cycleStop",
                      dest="cycleStop",
                      type="int",
                      default=105,
                      help="Stopping at cycle number, default=105",
                      metavar="CYCLESTOP")

    (options, args) = parser.parse_args()

    options.device = device
    options.typeId = configtype
    # currently only the Epix10kaQuads and Epix10ka2M support the ghost correction
    options.ghostCorrect = True if device in ['Epix10kaQuad', 'Epix10ka2M'
                                              ] else False

    print 'host', options.host
    print 'platform', options.platform
    print 'dbalias', options.dbalias
    print 'detector', options.detector
    print 'detectorID', options.detectorID
    print 'device', options.device
    print 'deviceID', options.deviceID
    if options.space > 7:
        print 'Space is too large, truncated to 7'
        options.space = 7
    print 'space', options.space
    print 'Values', options.Value0, ',', options.Value1
    print 'darkEvents', options.darkEvents
    print 'events', options.events
    print 'userFlag', options.userFlag
    print 'cycleStart', options.cycleStart
    print 'cycleStop', options.cycleStop
    print 'ghostCorrection', options.ghostCorrect

    #Fixed High Gain , pixel matrix to 0xc trbit 1
    #Fixed Medium Gain pixel matrix to 0xc trbit 0
    #Fixed Low Gain pixel matrix to to 0x8 trbit don't care
    #Auto High to Low pixel matrix to 0x0 trbit 1
    #Auto Medium to low pixel matrix to 0x0 trbit 0
    hasGhostCorrection = False
    numberOfDarks = 5
    darkValues = [0xc, 0xc, 0x8, 0, 0]
    trBitValues = [1, 0, 0, 1, 0]
    darkMessages = [
        'Fixed High Gain', 'Fixed Medium Gain', 'Fixed Low Gain',
        'Auto High to Low', 'Auto Medium to Low'
    ]

    # Connect to the daq system
    daq = pydaq.Control(options.host, options.platform)
    daq.connect()
    print 'Partition is', daq.partition()
    detectors = daq.detectors()
    devices = daq.devices()
    types = daq.types()
    #    print 'types are :\n', types

    found = [False, False, False]
    index = 0
    for member in detectors:
        if member == options.detector:
            detectorValue = (index << 24) | ((options.detectorID & 0xff) << 16)
            found[0] = True
        index = index + 1
    index = 0
    for member in devices:
        if member == options.device:
            detectorValue = detectorValue | (index << 8) | (options.deviceID
                                                            & 0xff)
            found[1] = True
        index = index + 1
    index = 0
    for member in types:
        if member == options.typeId:
            typeIdValue = index | (options.typeIdVersion << 16)
            found[2] = True
        index = index + 1
    if found[0] and found[1] and found[2]:
        print "detector hex value", hex(detectorValue)
        print 'typeId', hex(typeIdValue)
    else:
        if not found[0]:
            print "Detector", options.detector, "not found!"
        if not found[1]:
            print "Device", options.device, "not found!"
        if not found[2]:
            print "Type", options.typeId, "not found!"
        print "Exiting"
        exit()
#
#  First, get the current configuration key in use and set the value to be used
#

    cdb = pycdb.Db(daq.dbpath())
    key = daq.dbkey()
    alias = daq.dbalias()
    print 'Retrieved key ' + hex(key) + ' alias ' + alias

    #
    #  Generate a new key with different epix and EVR configuration for each cycle
    #
    if options.dbalias == None:
        newkey = cdb.clone(alias)
    else:
        newkey = cdb.clone(options.dbalias)

    print 'Generated key ', hex(newkey)
    print 'key', hex(key)
    print 'detectorValue', hex(detectorValue)
    print 'typeIdValue', hex(typeIdValue)
    xtc = cdb.get(key=key, src=detectorValue, typeid=typeIdValue)[0]
    print 'xtc is', xtc
    epix = xtc.get(0)
    print 'Composing the sequence of configurations ...'
    gcycle = 0  # cycle number if nothing skipped
    cycle = 0  # cycle number excluding skipped
    for dark in range(numberOfDarks):
        if gcycle >= options.cycleStart and gcycle < options.cycleStop:
            if 'elemCfg' in epix:
                for e in epix['elemCfg']:
                    mask = e['asicMask']
                    for rows in range(352):
                        for cols in range(384):
                            e['asicPixelConfigArray'][rows][cols] = darkValues[
                                dark]
                    for asicNum in range(4):
                        if mask & (1 << asicNum):
                            e['asics'][asicNum]['trbit'] = trBitValues[dark]
            else:
                mask = epix['AsicMask']
                for rows in range(352):
                    for cols in range(384):
                        epix['asicPixelConfigArray'][rows][cols] = darkValues[
                            dark]
                for asicNum in range(4):
                    if mask & (1 << asicNum):
                        epix['asics'][asicNum]['trbit'] = trBitValues[dark]
            xtc.set(epix, cycle)
            cycle += 1
        gcycle += 1

    for trbit in [0, 1]:
        for position in range(options.space**2):
            if gcycle >= options.cycleStart and gcycle < options.cycleStop:
                maskedpixels = pixel_mask(options.Value0, options.Value1,
                                          options.space, position)
                if 'elemCfg' in epix:
                    for e in epix['elemCfg']:
                        mask = e['asicMask']
                        for rows in range(352):
                            for cols in range(384):
                                e['asicPixelConfigArray'][rows][
                                    cols] = maskedpixels[rows][cols]
                        for asicNum in range(4):
                            if mask & (1 << asicNum):
                                e['asics'][asicNum]['atest'] = 1
                                e['asics'][asicNum]['test'] = 1
                                e['asics'][asicNum]['trbit'] = trbit
                                e['asics'][asicNum]['Pulser'] = 0
                                if options.ghostCorrect:
                                    e['asics'][asicNum]['PulserSync'] = 1
                else:
                    mask = epix['AsicMask']
                    for rows in range(352):
                        for cols in range(384):
                            epix['asicPixelConfigArray'][rows][
                                cols] = maskedpixels[rows][cols]
                    for asicNum in range(4):
                        if mask & (1 << asicNum):
                            epix['asics'][asicNum]['atest'] = 1
                            epix['asics'][asicNum]['test'] = 1
                            epix['asics'][asicNum]['trbit'] = trbit
                            epix['asics'][asicNum]['Pulser'] = 0
                            if options.ghostCorrect:
                                epix['asics'][asicNum]['PulserSync'] = 1
                if options.ghostCorrect:
                    if 'quads' in epix:
                        for q in epix['quads']:
                            q['asicAcqLToPPmatL'] = 1000
                    else:
                        epix['asicAcqLToPPmatL'] = 1000
                xtc.set(epix, cycle)
                cycle += 1
            gcycle += 1
#            print 'xtc.set(, epix', position + (trbit*(options.space**2)), ')'
    cdb.substitute(newkey, xtc)
    cdb.unlock()
    print '    done'

    #  Send the structure the first time to put the control variables
    #    in the file header
    #

    cycle_label = [
        ('%s offset scan' % device, ''),
    ]
    daq.configure(key=newkey, events=options.events, labels=cycle_label)

    print "Configured."

    #
    #  Wait for the user to declare 'ready'
    #    Setting up monitoring displays for example
    #
    if options.userFlag > 0:
        ready = raw_input('--Hit Enter when Ready-->')

    gcycle = 0
    for dark in range(numberOfDarks):
        if gcycle >= options.cycleStart and gcycle < options.cycleStop:
            print 'dark', darkMessages[dark]
            cycle_label = [
                ('%s offset scan' % device, 'dark %s' % darkMessages[dark]),
            ]
            daq.begin(events=options.darkEvents, labels=cycle_label)
            daq.end()
        gcycle += 1

    for trbit in [0, 1]:
        for position in range(((options.space**2))):
            if gcycle >= options.cycleStart and gcycle < options.cycleStop:
                print 'position', position, 'trbit', trbit
                cycle_label = [
                    ('%s offset scan' % device,
                     'position %d trbit %d' % (position, trbit)),
                ]
                daq.begin(events=options.events, labels=cycle_label)
                daq.end()
            gcycle += 1


#
#  Wait for the user to declare 'done'
#    Saving monitoring displays for example
#
    if options.userFlag > 0:
        ready = raw_input('-- Finished, hit Enter to exit -->')
    print 'Restoring key', hex(key)
    daq.configure(key=key, events=1)
Esempio n. 8
0
def scan_exponential(device, configtype):

    import sys

    parser = OptionParser()
    parser.add_option("-a",
                      "--address",
                      dest="host",
                      default='localhost',
                      help="connect to DAQ at HOST",
                      metavar="HOST")
    parser.add_option("-p",
                      "--platform",
                      dest="platform",
                      type="int",
                      default=3,
                      help="connect to DAQ at PLATFORM",
                      metavar="PLATFORM")
    parser.add_option("-D",
                      "--detector",
                      dest="detector",
                      type="string",
                      default='NoDetector',
                      help="detector to scan, default NoDetector",
                      metavar="DET")
    parser.add_option("-I",
                      "--detectorID",
                      dest="detectorID",
                      type="int",
                      default=0,
                      help="detector ID  to scan, default 0",
                      metavar="D_ID")
    parser.add_option("-i",
                      "--deviceID",
                      dest="deviceID",
                      type="int",
                      default=0,
                      help="device ID to scan, default 0",
                      metavar="DEV_ID")
    parser.add_option("-t",
                      "--typeIdVersion",
                      dest="typeIdVersion",
                      type="int",
                      default=1,
                      help="type ID Version in use, default 1",
                      metavar="typeIdVersion")
    parser.add_option("-P",
                      "--parameter",
                      dest="parameter",
                      type="string",
                      help="epix parameter to scan",
                      metavar="PARAMETER")
    parser.add_option("-A",
                      "--dbalias",
                      dest="dbalias",
                      type="string",
                      help="data base key in use",
                      metavar="DBALIAS")
    parser.add_option("-s",
                      "--start",
                      dest="start",
                      type="float",
                      default=200,
                      help="parameter start",
                      metavar="START")
    parser.add_option("-f",
                      "--finish",
                      dest="finish",
                      type="int",
                      nargs=1,
                      default=2000,
                      help="parameter finish",
                      metavar="FINISH")
    parser.add_option(
        "-m",
        "--multiplier",
        dest="multiplier",
        type="float",
        nargs=1,
        default=-1.0,
        help=
        "parameter multiplier in case you want to enter it directly, ignoring FINISH",
        metavar="MULTIPLIER")
    parser.add_option("-n",
                      "--steps",
                      dest="steps",
                      type="int",
                      default=20,
                      help="run N parameter steps",
                      metavar="N")
    parser.add_option("-e",
                      "--events",
                      dest="events",
                      type="int",
                      default=105,
                      help="record N events/cycle",
                      metavar="EVENTS")
    parser.add_option(
        "-L",
        "--linear",
        dest="linear",
        type="string",
        default="no",
        help="Set to yes for linear scanning instead of exponential",
        metavar="LINEAR")
    parser.add_option(
        "-l",
        "--limit",
        dest="limit",
        type="int",
        default=99,
        help="limit number of configs to less than number of steps",
        metavar="LIMIT")
    parser.add_option("-S",
                      "--shutter",
                      dest="shutter",
                      default="None",
                      help="path to shutter serial port",
                      metavar="SHUTTER")
    parser.add_option("-u",
                      "--use_l3t",
                      dest="use_l3t",
                      action="store_true",
                      default=False,
                      help="Use L3Trigger to filter events",
                      metavar="L3T")

    (options, args) = parser.parse_args()

    options.device = device
    options.typeId = configtype

    print 'host', options.host
    print 'platform', options.platform
    print 'dbalias', options.dbalias
    print 'parameter', options.parameter
    print 'start', options.start, options.start
    print 'steps', options.steps
    print 'finish', options.finish
    #    print 'multiplier', options.multiplier
    print 'events', options.events
    print 'detector', options.detector
    print 'detectorID', options.detectorID
    print 'device', options.device
    print 'deviceID', options.deviceID
    #    print 'linear', options.linear
    print 'shutter', options.shutter
    print 'use_l3t', options.use_l3t

    if options.steps < options.limit: options.limit = options.steps
    else:        print 'Warning, range will be covered in', options.limit, \
      'but will still do', options.steps, 'steps with wrapping'

    adder = 0.0
    if options.linear == "no":
        if (options.start == 0):
            options.start = 0.49
        if (options.multiplier < 0):
            options.multiplier = math.exp(
                (math.log(float(options.finish) / options.start)) /
                options.limit)
        print 'multiplier in use is', options.multiplier, 'and will scan from', options.start, 'to', options.finish
    else:
        adder = (float(options.finish) - options.start) / float(options.limit)
        print 'will do linear scanning from', options.start, 'to', options.finish, "in ", options.limit, "steps and with adder of ", adder

# Connect to the daq system
    daq = pydaq.Control(options.host, options.platform)
    daq.connect()
    print 'Partition is', daq.partition()
    detectors = daq.detectors()
    devices = daq.devices()
    types = daq.types()
    #    print 'types are :\n', types

    found = [False, False, False]
    index = 0
    for member in detectors:
        if member == options.detector:
            detectorValue = (index << 24) | ((options.detectorID & 0xff) << 16)
            found[0] = True
        index = index + 1
    index = 0
    for member in devices:
        if member == options.device:
            detectorValue = detectorValue | (index << 8) | (options.deviceID
                                                            & 0xff)
            found[1] = True
        index = index + 1
    index = 0
    for member in types:
        if member == options.typeId:
            typeIdValue = index | (options.typeIdVersion << 16)
            found[2] = True
        index = index + 1
    if found[0] and found[1] and found[2]:
        print "detector hex value", hex(detectorValue)
        print 'typeId', hex(typeIdValue)
    else:
        if not found[0]:
            print "Detector", options.detector, "not found!"
        if not found[1]:
            print "Device", options.device, "not found!"
        if not found[2]:
            print "Type", options.typeId, "not found!"
        print "Exiting"
        exit()
#
#  First, get the current configuration key in use and set the value to be used
#

    cdb = pycdb.Db(daq.dbpath())
    key = daq.dbkey()
    alias = daq.dbalias()
    print 'Retrieved key ' + hex(key) + ' alias ' + alias

    #
    #  Generate a new key with different epix and EVR configuration for each cycle
    #
    if options.dbalias == None:
        newkey = cdb.clone(alias)
    else:
        newkey = cdb.clone(options.dbalias)

    print 'Generated key ', hex(newkey)
    print 'key', hex(key)
    print 'detectorValue', hex(detectorValue)
    print 'typeIdValue', hex(typeIdValue)
    #    xtcSet = cdb.get(key=key)
    #    print 'xtcSet members :\n'
    #    for member in xtcSet :
    #        for attr in dir(member) :
    #            print getattr(member,attr)
    #    print 'Done printing xtcSet\n'
    #    print "cdb.get opened\n", cdb.get(key=key)
    xtc = cdb.get(key=key, src=detectorValue, typeid=typeIdValue)[0]
    print 'xtc is', xtc
    epix = xtc.get(0)

    if set_dict(epix, options.parameter, float(options.start)) == False:
        dump_dict(epix)
        sys.exit(1)

    else:
        print 'Composing the sequence of configurations ...'
        value = float(options.start)
        cycleLength = 1
        shutterActive = options.shutter != 'None'
        if shutterActive:
            cycleLength = 2
        denom = float(options.limit + 1)
        #        mask = epix['AsicMask']
        values = []
        for cycle in range(options.limit + 1):
            print cycle
            index = float(cycle % (options.limit + 1)) + 1.0
            set_dict(epix, options.parameter, value)
            xtc.set(epix, cycle)
            values.append(value)
            if options.linear == "no":
                #                print cycle, int(round(value))
                value = value * options.multiplier
            else:
                #                print cycle, int(round(value))
                value = value + adder
        cdb.substitute(newkey, xtc)
        cdb.unlock()
        for cycle in range(len(values)):
            print cycle, "value of", options.parameter, "is", values[cycle]
        print '    done'
        #
        #  Could scan EVR simultaneously
        #
        #    evr   = Evr  .ConfigV4().read(cdb.xtcpath(key.value,Evr  .DetInfo,Evr  .TypeId))
        #    newxtc = cdb.remove_xtc(newkey,Evr.DetInfo,Evr.TypeId)

        #
        #  Send the structure the first time to put the control variables
        #    in the file header
        #

        if options.use_l3t:
            print "Acquiring %s events passing L3Trigger" % (options.events)
            daq.configure(key=newkey,
                          l3t_events=options.events,
                          controls=[(options.parameter[0:29],
                                     int(round(options.start)))])
        else:
            daq.configure(key=newkey,
                          events=options.events,
                          controls=[(options.parameter[0:29],
                                     int(round(options.start)))])

        print "Configured."

        # set up shutter
        if shutterActive:
            ser = serial.Serial(options.shutter)
            ser.write(chr(129))  ## close shutter

#
#  Wait for the user to declare 'ready'
#    Setting up monitoring displays for example
#
        ready = raw_input('--Hit Enter when Ready-->')
        for cycle in range(options.steps + 1):
            if cycle % (options.limit + 1) == 0:
                index = 0.0
                subcycle = 0
            if shutterActive:
                ser.write(chr(129))  ## close shutter
                print "Cycle", cycle, " closed -", options.parameter, "=", values[
                    subcycle]
            else:
                print "Cycle", cycle, "-", options.parameter, "=", values[
                    subcycle]
            if options.use_l3t:
                daq.begin(l3t_events=options.events,
                          controls=[(options.parameter[0:29], values[subcycle])
                                    ])
            else:
                daq.begin(controls=[(options.parameter[0:29],
                                     values[subcycle])])
            # wait for enabled , then enable the EVR sequence
            # wait for disabled, then disable the EVR sequence
            daq.end()
            if shutterActive:
                print "        opened -", options.parameter, "=", values[
                    subcycle]
                ser.write(chr(128))  ## open shutter
                if options.use_l3t:
                    daq.begin(l3t_events=options.events,
                              controls=[(options.parameter[0:29],
                                         values[subcycle])])
                else:
                    daq.begin(controls=[(options.parameter[0:29],
                                         values[subcycle])])
                daq.end()
                ser.write(chr(129))  ## close shutter
            subcycle += 1


#
#  Wait for the user to declare 'done'
#    Saving monitoring displays for example
#
    ready = raw_input('-- Finished, hit Enter to exit -->')
    print 'Restoring key', hex(key)
    daq.configure(key=key, events=1)
Esempio n. 9
0
        print "detector hex value", hex(detectorValue)
        print 'typeId', hex(typeIdValue)
    else:
        if not found[0]:
            print "Detector", options.detector, "not found!"
        if not found[1]:
            print "Device", options.device, "not found!"
        if not found[2]:
            print "Type", options.typeId, "not found!"
        print "Exiting"
        exit()
#
#  First, get the current configuration key in use and set the value to be used
#

    cdb = pycdb.Db(daq.dbpath())
    key = daq.dbkey()
    print 'Retrieved key ', hex(key)

    #
    #  Generate a new key with different Cspad and EVR configuration for each cycle
    #
    newkey = cdb.clone(options.dbalias)
    print 'Generated key ', hex(newkey)
    print 'key', hex(key)
    print 'detectorValue', hex(detectorValue)
    print 'typeIdValue', hex(typeIdValue)
    #    xtcSet = cdb.get(key=key)
    #    print 'xtcSet members :\n'
    #    for member in xtcSet :
    #        for attr in dir(member) :
Esempio n. 10
0
    def configure(self, controls=None):
        cdb = pycdb.Db(self.daq.dbpath())
        newkey = cdb.get_key(self.alias)
        print "db path = %s  key = 0x%x" % (self.daq.dbpath(),
                                            self.daq.dbkey())

        partition = self.daq.partition()
        lAllocatedPrinceton = []
        lAllocatedFli = []
        lAllocatedAndor = []
        lAllocatedPimax = []
        for daqNode in partition['nodes']:
            # example of daqNode: {'record': True, 'phy': 256L, 'id': 'NoDetector-0|Evr-0', 'readout': True}
            phy = daqNode['phy']
            devId = ((phy & 0x0000FF00) >> 8)
            devNo = (phy & 0x000000FF)
            if devId == 6:  # Princeton
                lAllocatedPrinceton.append((phy, devNo))
            elif devId == 23:
                lAllocatedFli.append((phy, devNo))
            elif (devId == 25) or (devId == 38):
                lAllocatedAndor.append((phy, devNo))
            elif devId == 32:
                lAllocatedPimax.append((phy, devNo))

        fMaxReadoutTime = 0
        lSpeedTable = [0.1, 1, 0, 0, 1, 2]
        for cam_index, (phy, iCamera) in enumerate(lAllocatedPrinceton):
            lXtcPrinceton = cdb.get(key=newkey, src=phy)
            print "Princeton %d (detector id: 0x%x)" % (iCamera, phy)
            if len(lXtcPrinceton) != 1:
                print "!! Error: Princeton %d should only have one config, but found %d configs" % (
                    iCamera, len(lXtcPrinceton))
                continue
            xtc = lXtcPrinceton[0]
            configPrinceton = xtc.get()
            fOrgExposureTime = float(configPrinceton['exposureTime'])
            width = configPrinceton['width']
            height = configPrinceton['height']
            speed = configPrinceton['readoutSpeedIndex']
            code = configPrinceton['exposureEventCode']
            kineticHeight = configPrinceton['kineticHeight']

            configPrinceton['exposureEventCode'] = self.eventCameraOpan

            if speed < 0 or speed > len(
                    lSpeedTable) or lSpeedTable[speed] == 0:
                #print "*** Princeton %d configuation error: Unknown speed setting %d\n"\
                #  "Please check the readout speed index in the configuration window\n"\
                #  % (iCamera, speed)
                speed = 1
                #return 1

            #fReadoutTime = 4.7 * width * height / ( lSpeedTable[speed] * 2048 * 2048 )
            fReadoutTime = 4.7 / lSpeedTable[speed]
            if fReadoutTime > fMaxReadoutTime:
                fMaxReadoutTime = fReadoutTime

            print "  W %d H %d speed %d code %d readout %.3f" % (
                width, height, speed, configPrinceton['exposureEventCode'],
                fReadoutTime)

            if kineticHeight == 0:
                print "  Exposure time (Original) [%d]: %.3f s" % (
                    iCamera, fOrgExposureTime)
                configPrinceton['exposureTime'] = self.fExposureTime + (
                    cam_index * self.readout_time)
                print "  Exposure time (New)      [%d]: %.3f s" % (
                    iCamera, configPrinceton['exposureTime'])
            else:
                if height % kineticHeight != 0:
                    print "!!! Princeton %d Illegal kinetics height %d (Image height %d)" \
                     % (iCamera, kineticHeight, height)
                    return 2
                iNumKineticShot = height / kineticHeight
                print "  Kinetic mode: shots = %d" % (iNumKineticShot)
                if self.fBurstRate * fOrgExposureTime >= 1:
                    print "!!! Princeton %d exposure time %f slower than beam rate %f. Not okay for kinetics mode" \
                     % (iCamera, fOrgExposureTime, self.fBurstRate)
                    return 2
                    self.iNumShot = iNumKineticShot

            configPrinceton['numDelayShots'] = self.iNumShot
            print "  Number of Delayed Shots: [%d]: %d" % (
                iCamera, configPrinceton['numDelayShots'])

            xtc.set(configPrinceton)
            cdb.set(xtc=xtc, alias=self.alias)

        lSpeedTable = [0.2, 1]
        for cam_index, (phy, iCamera) in enumerate(lAllocatedFli):
            lXtcFli = cdb.get(key=newkey, src=phy)
            print "Fli %d (detector id: 0x%x)" % (iCamera, phy)
            if len(lXtcFli) != 1:
                print "!! Error: Fli %d should only have one config, but found %d configs" % (
                    iCamera, len(lXtcFli))
                continue
            xtc = lXtcFli[0]
            configFli = xtc.get()
            fOrgExposureTime = float(configFli['exposureTime'])
            width = configFli['width']
            height = configFli['height']
            speed = configFli['readoutSpeedIndex']
            code = configFli['exposureEventCode']

            configFli['exposureEventCode'] = self.eventCameraOpan

            if speed < 0 or speed > len(
                    lSpeedTable) or lSpeedTable[speed] == 0:
                print "*** Fli %d configuation error: Unknown speed setting %d\n"\
                  "Please check the readout speed index in the configuration window\n"\
                  % (iCamera, speed)
                return 1

            #fReadoutTime = 4.3 * width * height / (4096 * 4096)
            fReadoutTime = 4.3 / lSpeedTable[speed]
            if fReadoutTime > fMaxReadoutTime:
                fMaxReadoutTime = fReadoutTime

            print "  W %d H %d speed %d code %d readout %.3f" % (
                width, height, speed, configFli['exposureEventCode'],
                fReadoutTime)
            print "  Exposure time (Original) [%d]: %.3f s" % (
                iCamera, fOrgExposureTime)
            configFli['exposureTime'] = self.fExposureTime + (
                cam_index * self.readout_time)
            print "  Exposure time (New)      [%d]: %.3f s" % (
                iCamera, configFli['exposureTime'])

            configFli['numDelayShots'] = self.iNumShot
            print "  Number of Delayed Shots: [%d]: %d" % (
                iCamera, configFli['numDelayShots'])

            xtc.set(configFli)
            cdb.set(xtc=xtc, alias=self.alias)

        lSpeedTable = [1, 0.6, 0.2, 0.01]
        for cam_index, (phy, iCamera) in enumerate(lAllocatedAndor):
            lXtcAndor = cdb.get(key=newkey, src=phy)
            print "Andor %d (detector id: 0x%x)" % (iCamera, phy)
            if len(lXtcAndor) != 1:
                print "!! Error: Andor %d should only have one config, but found %d configs" % (
                    iCamera, len(lXtcAndor))
                continue
            xtc = lXtcAndor[0]
            configAndor = xtc.get()
            fOrgExposureTime = float(configAndor['exposureTime'])
            width = configAndor['width']
            height = configAndor['height']
            speed = configAndor['readoutSpeedIndex']
            code = configAndor['exposureEventCode']

            configAndor['exposureEventCode'] = self.eventCameraOpan

            if speed < 0 or speed > len(
                    lSpeedTable) or lSpeedTable[speed] == 0:
                print "*** Andor %d configuation error: Unknown speed setting %d\n"\
                  "Please check the readout speed index in the configuration window\n"\
                  % (iCamera, speed)
                return 1

            fReadoutTime = 1.1 / lSpeedTable[speed]
            if fReadoutTime > fMaxReadoutTime:
                fMaxReadoutTime = fReadoutTime

            print "  W %d H %d speed %d code %d readout %.3f" % (
                width, height, speed, configAndor['exposureEventCode'],
                fReadoutTime)
            print "  Exposure time (Original) [%d]: %.3f s" % (
                iCamera, fOrgExposureTime)
            configAndor['exposureTime'] = self.fExposureTime + (
                cam_index * self.readout_time)
            print "  Exposure time (New)      [%d]: %.3f s" % (
                iCamera, configAndor['exposureTime'])

            configAndor['numDelayShots'] = self.iNumShot
            print "  Number of Delayed Shots: [%d]: %d" % (
                iCamera, configAndor['numDelayShots'])

            xtc.set(configAndor)
            cdb.set(xtc=xtc, alias=self.alias)

        for cam_index, (phy, iCamera) in enumerate(lAllocatedPimax):
            lXtcPimax = cdb.get(key=newkey, src=phy)
            print "Pimax %d (detector id: 0x%x)" % (iCamera, phy)
            if len(lXtcPimax) != 1:
                print "!! Error: Pimax %d should only have one config, but found %d configs" % (
                    iCamera, len(lXtcPimax))
                continue
            xtc = lXtcPimax[0]
            configPimax = xtc.get()
            fOrgExposureTime = float(configPimax['exposureTime'])
            width = configPimax['width']
            height = configPimax['height']
            speed = configPimax['readoutSpeed']
            code = configPimax['exposureEventCode']

            configPimax['exposureEventCode'] = self.eventCameraOpan

            fReadoutTime = 1 / speed
            if fReadoutTime > fMaxReadoutTime:
                fMaxReadoutTime = fReadoutTime

            print "  W %d H %d speed %d code %d readout %.3f" % (
                width, height, speed, configPimax['exposureEventCode'],
                fReadoutTime)
            print "  Exposure time (Original) [%d]: %.3f s" % (
                iCamera, fOrgExposureTime)
            configPimax['exposureTime'] = self.fExposureTime + (
                cam_index * self.readout_time)
            print "  Exposure time (New)      [%d]: %.3f s" % (
                iCamera, configPimax['exposureTime'])

            configPimax['numIntegrationShots'] = self.iNumShot
            print "  Number of Integration Shots: [%d]: %d" % (
                iCamera, configPimax['numIntegrationShots'])

            xtc.set(configPimax)
            cdb.set(xtc=xtc, alias=self.alias)

        cdb.commit()
        newkey = cdb.get_key(self.alias)
        cdb.unlock()

        print "setting exposure time to %.2f s" % (self.fExposureTime)

        #
        #    self.daq.configure(events=options.events,
        #                  controls=[('EXAMPLEPV1',0),('EXAMPLEPV2',0)],
        #                  monitors=[('BEAM:LCLS:ELEC:Q',options.qbeam,1.)])
        #
        #    self.daq.configure(record=do_record,
        #                  events=options.events,
        #                  controls=[('EXAMPLEPV1',0),('EXAMPLEPV2',0)])
        print "CONTROLS LIST:", controls
        print "daq configure...",
        sys.stdout.flush()
        # cpo changed this line
        #print "()()()\n",controls
        if controls is None:
            self.daq.configure(key=newkey, events=0, controls=[])
        else:
            self.daq.configure(key=newkey, events=0, controls=controls)
        print " done."

        return 0
Esempio n. 11
0
 def __init__(self, dbpath="/reg/g/pcds/dist/pds/mec/configdb/current"):
     self.db = pycdb.Db(dbpath)
Esempio n. 12
0
    set_dict(d, name, n)
    v = get_dict(d, name)

    if v == o:
        print name + ' unchanged!'
    elif v == n:
        print name + ' correctly changed'
    else:
        print name + ' corrupted!'


if __name__ == "__main__":
    import sys

    #    cdb = pycdb.Db('/reg/neh/home/weaver/configdb/std')
    cdb = pycdb.Db('/reg/neh/home/tookey/configdb/lab2')
    detectorValue = 0x3200
    typeIdValue = 0x10078
    key = 0x164
    xtc = cdb.get(key=key, src=detectorValue, typeid=typeIdValue)[0]
    print xtc
    epix = xtc.get(0)
    #    print epix
    dump_dict(epix)

    test(epix, 9, 'evr.runDelay')
    test(epix, 3, 'elemCfg[3].asicMask')
    test(epix, 1, 'elemCfg[3].asics[3].RowStop')

    for i in range(3):
        xtc.set(epix, i)
Esempio n. 13
0
 def __init__(self, laser_config):
     self.laser_config = laser_config
     self.alias = "LASER_SIM"
     self._seq = Sequence()
     self._cdb = pycdb.Db(daq._control.dbpath())
     self.parent = None
Esempio n. 14
0
 def __init__(self, path, alias, sim=False):
     self.__db = None if sim else pycdb.Db(path)
     self.alias = alias
     self.__key = None
Esempio n. 15
0
  def configure(self):
    cdb = pycdb.Db(self.daq.dbpath())
    newkey = cdb.get_key(self.alias)
    print "db path = %s  key = 0x%x" % (self.daq.dbpath(), self.daq.dbkey())

    lXtcPrinceton = cdb.get(key=newkey,typeid=0x00050012) # PrincetonConfig, V5

    fMaxReadoutTime = 0
    lSpeedTable     = [ 0.1, 1, 0, 0, 1, 2 ]
    print "Found %d Princeton Configs" % (len(lXtcPrinceton))
    for iCamera in range(len(lXtcPrinceton)):
      print "Princeton %d:" %(iCamera)
      xtc              = lXtcPrinceton[iCamera]
      configPrinceton  = xtc.get()
      fOrgExposureTime = float(configPrinceton['exposureTime'])
      width            = configPrinceton['width']
      height           = configPrinceton['height']
      speed            = configPrinceton['readoutSpeedIndex']
      code             = configPrinceton['exposureEventCode']
      kineticHeight    = configPrinceton['kineticHeight']

      configPrinceton['exposureEventCode'] = self.codeCommand

      if speed < 0 or speed > len(lSpeedTable) or lSpeedTable[speed] == 0:
        #print "*** Princeton %d configuation error: Unknown speed setting %d\n"\
        #  "Please check the readout speed index in the configuration window\n"\
        #  % (iCamera, speed)
        speed = 1
        #return 1

      #fReadoutTime = 4.7 * width * height / ( lSpeedTable[speed] * 2048 * 2048 )
      fReadoutTime = 4.7 / lSpeedTable[speed]
      if fReadoutTime > fMaxReadoutTime:
        fMaxReadoutTime = fReadoutTime

      print "  W %d H %d speed %d code %d readout %.3f" % (width, height, speed, configPrinceton['exposureEventCode'], fReadoutTime)

      if kineticHeight == 0:
        print "  Exposure time (Original) [%d]: %.3f s" % (iCamera, fOrgExposureTime)
        configPrinceton['exposureTime']     = self.fExposureTime
        print "  Exposure time (New)      [%d]: %.3f s" % (iCamera, configPrinceton['exposureTime'])
      else:
        if height % kineticHeight != 0:
          print "!!! Princeton %d Illegal kinetics height %d (Image height %d)" \
           % (iCamera, kineticHeight, height)
          return 2
        iNumKineticShot = height / kineticHeight
        print "  Kinetic mode: shots = %d" % (iNumKineticShot)
        if self.fBurstRate * fOrgExposureTime >= 1:
          print "!!! Princeton %d exposure time %f slower than beam rate %f. Not okay for kinetics mode" \
           % (iCamera, fOrgExposureTime, self.fBurstRate)
          return 2
        if self.iNumShot != iNumKineticShot:
          self.iNumShot = iNumKineticShot
          if self.bSimMode:
            self.codeCommand = self.setPrincetonExposureSequence()
          else:
            self.mccBurst.mccBurstSetNumShot(self.iNumShot, self.dictBeamToBurstRate[self.fBurstRate])

      configPrinceton['numDelayShots'] = self.iNumShot
      print "  Number of Delayed Shots: [%d]: %d" % (iCamera, configPrinceton['numDelayShots'])

      xtc.set(configPrinceton)
      cdb.set(xtc = xtc, alias = self.alias)

    lSpeedTable     = [ 0.2, 1 ]
    lXtcFli = cdb.get(key=newkey,typeid=0x00010037) # FliConfig, V1
    print "Found %d Fli Configs" % (len(lXtcFli))
    for iCamera in range(len(lXtcFli)):
      print "Fli %d:" %(iCamera)
      xtc              = lXtcFli[iCamera]
      configFli        = xtc.get()
      fOrgExposureTime = float(configFli['exposureTime'])
      width            = configFli['width']
      height           = configFli['height']
      speed            = configFli['readoutSpeedIndex']
      code             = configFli['exposureEventCode']

      configFli['exposureEventCode'] = self.codeCommand

      if speed < 0 or speed > len(lSpeedTable) or lSpeedTable[speed] == 0:
        print "*** Fli %d configuation error: Unknown speed setting %d\n"\
          "Please check the readout speed index in the configuration window\n"\
          % (iCamera, speed)
        return 1

      #fReadoutTime = 4.3 * width * height / (4096 * 4096)
      fReadoutTime = 4.3 / lSpeedTable[speed]
      if fReadoutTime > fMaxReadoutTime:
        fMaxReadoutTime = fReadoutTime

      print "  W %d H %d speed %d code %d readout %.3f" % (width, height, speed, configFli['exposureEventCode'], fReadoutTime)
      print "  Exposure time (Original) [%d]: %.3f s" % (iCamera, fOrgExposureTime)
      configFli['exposureTime']     = self.fExposureTime
      print "  Exposure time (New)      [%d]: %.3f s" % (iCamera, configFli['exposureTime'])

      configFli['numDelayShots'] = self.iNumShot
      print "  Number of Delayed Shots: [%d]: %d" % (iCamera, configFli['numDelayShots'])

      xtc.set(configFli)
      cdb.set(xtc = xtc, alias = self.alias)

    lSpeedTable     = [ 1, 0.6, 0.2, 0.01 ]
    lXtcAndor = cdb.get(key=newkey,typeid=0x0001003C) # AndorConfig, V1
    print "Found %d Andor Configs" % (len(lXtcAndor))
    for iCamera in range(len(lXtcAndor)):
      print "Andor %d:" %(iCamera)
      xtc              = lXtcAndor[iCamera]
      configAndor      = xtc.get()
      fOrgExposureTime = float(configAndor['exposureTime'])
      width            = configAndor['width']
      height           = configAndor['height']
      speed            = configAndor['readoutSpeedIndex']
      code             = configAndor['exposureEventCode']

      configAndor['exposureEventCode'] = self.codeCommand

      if speed < 0 or speed > len(lSpeedTable) or lSpeedTable[speed] == 0:
        print "*** Andor %d configuation error: Unknown speed setting %d\n"\
          "Please check the readout speed index in the configuration window\n"\
          % (iCamera, speed)
        return 1

      fReadoutTime = 1.1 / lSpeedTable[speed]
      if fReadoutTime > fMaxReadoutTime:
        fMaxReadoutTime = fReadoutTime

      print "  W %d H %d speed %d code %d readout %.3f" % (width, height, speed, configAndor['exposureEventCode'], fReadoutTime)
      print "  Exposure time (Original) [%d]: %.3f s" % (iCamera, fOrgExposureTime)
      configAndor['exposureTime']     = self.fExposureTime
      print "  Exposure time (New)      [%d]: %.3f s" % (iCamera, configAndor['exposureTime'])

      configAndor['numDelayShots'] = self.iNumShot
      print "  Number of Delayed Shots: [%d]: %d" % (iCamera, configAndor['numDelayShots'])

      xtc.set(configAndor)
      cdb.set(xtc = xtc, alias = self.alias)

    cdb.commit()
    newkey = cdb.get_key(self.alias)

    # Image time =
    #  fSetupTime
    #  fExposureTime +
    #  camera readout time (4.7 second for 2048x2048 @ 1M, or fMaxReadoutTime) +
    #  Tolerance (0.3 second) +
    #  Min (
    #        Network data transfer delay (Number of shots / 100) ,
    #        Max limit (20 seconds) )
    #   + manual delay (overhead_delay)
    #   + delay for multiple princeton program (traffic shaping) (1 second for 3 programs)
    #
    if self.bDelayMode:
      fNetworkDelay = 0
    else:
      fNetworkDelay = self.iNumShot/100.0
    self.fImageTime = self.fSetupTime + self.fExposureTime + fMaxReadoutTime + 0.3 + fNetworkDelay + self.fPostDelay + 1
    if self.fImageTime < 0: self.fImageTime = 0

    # Post Sleep time =
    #  Image time -
    #    ( Delay between setting pvPlayCtrl and princeton open (0.5 second) +
    #      fExposureTime )
    #
    self.fPostSleep = self.fImageTime - 0.5 - self.fExposureTime

    print "setting exposure time to %.2f s. Expected image time %.2f s postSleep %.2f s" % (self.fExposureTime, self.fImageTime, self.fPostSleep)

    self.fImageTime_seconds = int(self.fImageTime)
    self.fImageTime_nanoseconds = int((self.fImageTime - float(self.fImageTime_seconds))*1.e9)

    #
    #    self.daq.configure(events=options.events,
    #                  controls=[('EXAMPLEPV1',0),('EXAMPLEPV2',0)],
    #                  monitors=[('BEAM:LCLS:ELEC:Q',options.qbeam,1.)])
    #
    #    self.daq.configure(record=do_record,
    #                  events=options.events,
    #                  controls=[('EXAMPLEPV1',0),('EXAMPLEPV2',0)])

    print "daq configure...",
    sys.stdout.flush()
    self.daq.configure(key=newkey,controls=self.controls)
    print " done."

    return 0
Esempio n. 16
0
import pycdb


def evr_evolve(db, fname):
    y = db.get(typeid=0x00050008, src=0x100, file=fname)[0]
    v = db.evolve(6, y)
    v.set(y.get())
    db.set(file=fname, xtc=v)


def cspad_evolve(db, fname):
    y = db.get(typeid=0x0003001d, src=0x14000a, file=fname)[0]
    print y
    v = db.evolve(4, y)
    v.set(y.get())
    print v.get()
    db.set(file=fname, xtc=v)


db = pycdb.Db("/reg/g/pcds/dist/pds/amo/configdb/devel")
#evr_evolve(db,'beam_shutter_v5.xtc')
#evr_evolve(db,'beam_v5.xtc')
#evr_evolve(db,'twoevr_nobeam_v5.xtc')

#db = pycdb.Db("/reg/g/pcds/dist/pds/xpp/configdb/current")
#cspad_evolve(db,"cspadV3_01.xtc")
#cspad_evolve(db,"test_V3_01.xtc")

db.get
Esempio n. 17
0
 def __init__(self):
     self.alias = "LASER_SIM"
     self._seq = Sequence()
     self._cdb = pycdb.Db(daq._control.dbpath())