Ejemplo n.º 1
0
def get_chip_ids(**settings):
    '''
    Return a list of Chip objects representing the chips on the board.

    Checks if a chip is present by adjusting one channel's pixel trim
    threshold and checking to see that the correct configuration is read
    back in.
    '''
    logger = logging.getLogger(__name__)
    logger.info('Executing get_chip_ids')
    if 'controller' in settings:
        controller = settings['controller']
    else:
        controller = larpix.Controller(settings['port'])
    controller.use_all_chips = True
    stored_timeout = controller.timeout
    controller.timeout = 0.1
    chips = {}
    chip_regs = [(c.chip_key, 0) for c in controller.all_chips]
    controller.multi_read_configuration(chip_regs, timeout=0.1)
    for chip_key in controller.all_chips:
        chip = controller.get_chip(chip_key)
        if len(chip.reads) == 0:
            print('Chip ID %d: No packet recieved' % chip.chip_id)
            continue
        if len(chip.reads[0]) != 1:
            print('Cannot determine if chip %d exists because more'
                  'than 1 packet was received (expected 1)' % chip.chip_id)
            continue
        if chip.reads[0][0].register_data != 0:
            chips.append(chip)
            logger.info('Found chip %s' % chip)
    controller.timeout = stored_timeout
    controller.use_all_chips = False
    return chips
Ejemplo n.º 2
0
def quickcontroller(board='pcb-5',
                    interactive=False,
                    io=None,
                    logger=None,
                    log_filepath=None):
    '''Quick jump through all controller creation and config steps'''
    controller_config = 'controller/{}_chip_info.json'.format(board)
    if io is None:
        io_config = 'io/daq-srv1.json'
        io = ZMQ_IO(io_config)
    if logger is None:
        logger = HDF5Logger(filename=log_filepath)
        logger.open()
    controller = larpix.Controller()
    controller.io = io
    controller.logger = logger
    controller.load(controller_config)
    silence_chips(controller, interactive)
    set_config_physics(controller, interactive)
    return controller
Ejemplo n.º 3
0
def create_controller(timeout=0.01, io=None):
    '''Create a default controller'''
    c = larpix.Controller()
    c.io = io
    return c
Ejemplo n.º 4
0
if args.interactive:
    from subprocess import run
    command = [arg for arg in sys.argv if not arg in ['-i', '--interactive']]
    command = ['python', '-i'] + command
    run(command)
    sys.exit(0)

sl = ScriptLogger(start_time)
log = sl.script_log
log.info('arguments: %s' % str(args))

last_read = []
controller = None  # keep handle to some variables in case you want to enter an interactive session
board_info = None
try:
    controller = larpix.Controller(timeout=0.01)
    board_info = larpix_scripting.load_board(controller, args.board)
    controller.disable()
    config_ok, different_registers = larpix_scripting.load_chip_configurations(
        controller,
        board_info,
        args.config,
        threshold_correction=args.global_threshold_correction,
        trim_correction=args.trim_correction)

    for chip in controller.chips:
        chip.config.external_trigger_mask[7] = 0
        controller.write_configuration(chip, range(56, 60))

    for _ in range(args.subruns):
        specifier = time.strftime('%Y_%m_%d_%H_%M_%S')