builder = dfmux.DfMuxBuilder( [int(board.serial) for board in hwm.query(pydfmux.IceBoard)]) # Get the local IP(s) to use to connect to the boards by opening test # connections. Using a set rather than a list deduplicates the results. local_ips = set() for board in hwm.query(pydfmux.core.dfmux.IceBoard): testsock = socket.create_connection( ('iceboard' + board.serial + '.local', 80)) local_ips.add(testsock.getsockname()[0]) testsock.close() print('Creating listeners for %d boards on interfaces: %s' % (hwm.query(pydfmux.core.dfmux.IceBoard).count(), ', '.join(local_ips))) # Set up listeners per network segment and point them at the event builder collectors = [dfmux.DfMuxCollector(ip, builder) for ip in local_ips] pipe.Add(builder) # Catch errors if samples have become misaligned. Don't even bother processing # data involving a significant (N-2) reduction from the boards we should have. nboards = hwm.query(pydfmux.IceBoard).count() n_badpkts = 0 n_goodpkts = 0 logtweaked = False def yellanddrop(fr): global n_badpkts global n_goodpkts global logtweaked
local_ips = {} for board in boards: testsock = socket.create_connection( ('iceboard' + board + '.local', 80)) local_ip = testsock.getsockname()[0] if local_ip not in local_ips: local_ips[local_ip] = set() local_ips[local_ip].add(int(board)) testsock.close() core.log_notice('Creating listeners for %d boards on interfaces: %s' % (len(boards), ', '.join(local_ips.keys())), unit='Data Acquisition') # Set up listeners per network segment and point them at the event builder collectors = [ dfmux.DfMuxCollector(ip, builder, list(local_boards)) for ip, local_boards in local_ips.items() ] else: iceboard_hosts = ['iceboard' + board + '.local' for board in boards] if args.daq_threads is None: args.daq_threads = len(iceboard_hosts) if args.daq_threads > len(iceboard_hosts): args.daq_threads = len(iceboard_hosts) collectors = [ dfmux.DfMuxCollector(builder, iceboard_hosts[i::args.daq_threads]) for i in range(args.daq_threads) ] pipe.Add(builder) # Catch errors if samples have become misaligned. Don't even bother processing
local_ips.add(testsock.getsockname()[0]) testsock.close() core.log_notice( 'Creating listeners for %d boards on interfaces: %s' % (hwm.query(pydfmux.core.dfmux.IceBoard).count(), ', '.join(local_ips)), unit='Ledgerman') # Build mapping dictionary for old (64x) firmware v2_mapping = { 'iceboard' + str(serial) + '.local': int(serial) for serial in serial_list } # Set up listeners per network segment and point them at the event builder collectors = [ dfmux.DfMuxCollector(ip, builder, v2_mapping) for ip in local_ips ] pipe.Add(builder) # Insert current hardware map into data stream. This is critical to get the # board ID -> IP mapping needed to do anything useful with the data pipe.Add(dfmux.PyDfMuxHardwareMapInjector, pydfmux_hwm=hwm, pathstring=args.pathstring, state=args.state) if args.physnames: from spt3g import calibration # Swap the normal bolometer names for their physical_name equivalents, # which can make laboratory tasks simpler -- we don't care about # long-term data archiving here.
local_ips.add(testsock.getsockname()[0]) testsock.close() core.log_notice( 'Creating listeners for %d boards on interfaces: %s' % (hwm.query(pydfmux.core.dfmux.IceBoard).count(), ', '.join(local_ips)), unit='Ledgerman') # Build mapping dictionary for old (64x) firmware v2_mapping = { 'iceboard' + str(serial) + '.local': int(serial) for serial in serial_list } # Set up listeners per network segment and point them at the event builder collectors = [ dfmux.DfMuxCollector(ip, builder, v2_mapping) for ip in local_ips ] else: hosts = ['iceboard' + str(serial) + '.local' for serial in serial_list] if args.threads is None: args.threads = len(hosts) if args.threads > len(hosts): args.threads = len(hosts) collectors = [ dfmux.DfMuxCollector(builder, hosts[i::args.threads]) for i in range(args.threads) ] pipe.Add(builder)
# Get the local IP(s) to use to connect to the boards by opening test # connections. Using a set rather than a list deduplicates the results. local_ips = {} for board in boards: testsock = socket.create_connection(('iceboard' + board + '.local', 80)) local_ip = testsock.getsockname()[0] if local_ip not in local_ips: local_ips[local_ip] = set() local_ips[local_ip].add(int(board)) testsock.close() core.log_notice('Creating listeners for %d boards on interfaces: %s' % (len(boards), ', '.join(local_ips.keys())), unit='Data Acquisition') # Set up listeners per network segment and point them at the event builder collectors = [dfmux.DfMuxCollector(ip, builder, list(local_boards)) for ip, local_boards in local_ips.items()] pipe.Add(builder) # Catch errors if samples have become misaligned. Don't even bother processing # data involving a significant (N-2) reduction from the boards we should have. nboards = len(boards) n_badpkts = 0 n_goodpkts = 0 logtweaked = False def yellanddrop(fr): global n_badpkts global n_goodpkts global logtweaked if fr.type != core.G3FrameType.Timepoint:
hwm.query(pydfmux.core.dfmux.IceBoard).align_sampling() print('Beginning data acquisition') # Set up DfMux consumer pipe = core.G3Pipeline() builder = dfmux.DfMuxBuilder( [int(board.serial) for board in hwm.query(pydfmux.IceBoard)]) # Get the local IP to connect to the boards by opening a test connection. testsock = socket.create_connection( ('iceboard' + str(hwm.query(pydfmux.core.dfmux.IceBoard).first().serial) + '.local', 80)) local_ip = testsock.getsockname()[0] testsock.close() collector = dfmux.DfMuxCollector(local_ip, builder) pipe.Add(builder) # Insert current hardware map into data stream. This is critical to get the # board ID -> IP mapping needed to do anything useful with the data pipe.Add(dfmux.PyDfMuxHardwareMapInjector, pydfmux_hwm=hwm) if args.system_time: def sub_system_time(frame): if frame.type != core.G3FrameType.Timepoint: return del frame['EventHeader'] frame['EventHeader'] = core.G3Time.Now() pipe.Add(sub_system_time)
import numpy from spt3g import core, dfmux pipe = core.G3Pipeline() builder = dfmux.DfMuxBuilder(1) collector = dfmux.DfMuxCollector("192.168.1.4", builder) pipe.Add(builder) startpoint = {} nframes = 0 def dump(frame): global nframes #print('Frame: %s' % str(frame['EventHeader'])) nframes += 1 for i in frame['DfMux']: ip = i.key() data = i.data() for module in data: if module.key() not in startpoint: startpoint[module.key()] = {} samps = numpy.abs(module.data()) for chan in range(0, 16): if chan not in startpoint[module.key()]: startpoint[module.key()][chan] = 0 if nframes < 200: startpoint[module.key()][chan] = max( startpoint[module.key()][chan], max(samps[chan * 2], samps[chan * 2 + 1]))