acq400

acq400.py interface to one acq400 appliance instance

  • enumerates all site services, available as uut.sX.knob

  • monitors transient status on uut, provides blocking events

  • read_channels() reads all data from channel data service.

  • simple property interface allows natural “script-like” usage

  • eg:

    uut1.s0.set_arm = 1
    
  • equivalent to running this on a logged in shell session on the UUT:

    set.site1 set_arm=1
    
exception DataNotAvailableError[source]

Bases: Exception

class AcqPorts[source]

Bases: object

uut server port constants

TSTAT = 2235
STREAM = 4210
SITE0 = 4220
SEGSW = 4250
SEGSR = 4251
DPGSTL = 4521
GPGSTL = 4541
GPGDUMP = 4543
WRPG = 4606
DIO482_PG_STL = 45001
DIO482_PG_DUMP = 45003
BOLO8_CAL = 45072
DATA0 = 53000
DATAT = 53333
MULTI_EVENT_TMP = 53555
MULTI_EVENT_DISK = 53556
DATA_SPY = 53667
LIVETOP = 53998
ONESHOT = 53999
AWG_ONCE = 54201
AWG_AUTOREARM = 54202
AWG_CONTINUOUS = 54205
AWG_STREAM = 54207
MGTDRAM = 53993
MGTDRAM_PULL_DATA = 53991
SLOWMON = 53666
class AcqSites[source]

Bases: object

uut site constants

SITE0 = 0
SITE1 = 1
SITE2 = 2
SITE3 = 3
SITE4 = 4
SITE5 = 5
SITE6 = 6
SITE_CA = 13
SITE_CB = 12
SITE_CC = 11
SITE_DSP = 14
SITE_HUDP = 10
class SF[source]

Bases: object

uut system state constants

STATE = 0
PRE = 1
POST = 2
ELAPSED = 3
DEMUX = 5
class STATE[source]

Bases: object

transient state constants

IDLE = 0
ARM = 1
RUNPRE = 2
RUNPOST = 3
POPROCESS = 4
CLEANUP = 5
static str(st)[source]
class Signals[source]

Bases: object

EXT_TRG_DX = 'd0'
INT_TRG_DX = 'd1'
MB_CLK_DX = 'd1'
class StreamClient[source]

Bases: Netclient

handles live streaming data

__init__(addr)[source]
class RawClient[source]

Bases: Netclient

handles raw data from any service port

__init__(addr, port)[source]

init RawClient

Parameters:
  • addr (str) – ip or hostname

  • port (int) – service port see AcqPorts

read(nelems, data_size=2)[source]

read data from channel data server

Parameters:
  • nelems (int) – data elements

  • data_size (int, optional) – data size in bytes 2|4 short or int. Defaults to 2.

Returns:

channel data

Return type:

ndarray

get_blocks(nelems, data_size=2)[source]
class MgtDramPullClient[source]

Bases: RawClient

__init__(addr)[source]
class ChannelClient[source]

Bases: RawClient

handles post shot data for one channel.

Parameters:
  • addr (str) – ip address or hostname

  • ch (int) – channel number 1..N

__init__(addr, ch)[source]
exception ExitCommand[source]

Bases: Exception

signal_handler(signal, frame)[source]
class Statusmonitor[source]

Bases: object

monitors the status channel

Efficient event-driven monitoring in a separate thread

st_re = re.compile('([0-9]) ([0-9]+) ([0-9]+) ([0-9]+) ([0-9])+')
st_shot_re = re.compile('SHOT=([0-9]),([0-9]+),([0-9]+),([0-9]+)')
st_failed_to_find_event_re = re.compile('ERROR EVENT NOT FOUND')
st_timer_re = re.compile('Timer::report\\(([0-9]+)\\) ([A-Z]{3}) ([0-9]+) msec')
st_monitor()[source]
get_state()[source]
get_pre()[source]
get_post()[source]
get_total()[source]
get_elapsed()[source]
wait_event(ev, descr='')[source]
wait_armed()[source]

blocks until uut is ARMED

wait_stopped()[source]

blocks until uut is STOPPED

wait_state_changed()[source]

blocks until state has changed

__init__(_uut, _status)[source]
trace = 0
class NullFilter[source]

Bases: object

class ProcessMonitor[source]

Bases: object

st_rex = (re.compile('^END'), re.compile('^real'))
st_monitor()[source]
__init__(_uut, _monport, _filter, set_arm)[source]

init ProcessMonitor

Parameters:
  • _uut (acq400) – uut instance

  • _monport (int) – monitor port

  • _filter (func) – filtering function

  • set_arm (bool) – set arm

class Acq400[source]

Bases: object

Host-side proxy for Acq400 uut.

acq400 discovers and maintains all site servers, maintains a monitor and handles multiple channel post shot upload

init_site_client(site)[source]
classmethod create_uuts(uut_names)[source]

create_uuts(): factory .. create them in parallel

* Experimental Do Not Use *

uuts_methods = {}
uuts = {}
__init__(_uut, monitor=True, s0_client=None)[source]

init acq400

Parameters:
  • _uut (srt) – uut hostname or ip-address

  • monitor (bool, optional) – start statusmonitor. Defaults to True.

  • s0_client (netclient.Siteclient, optional) – existing siteclient. Defaults to None.

close()[source]

Closes uut connection gracefully

state()[source]
post_samples()[source]
pre_samples()[source]
elapsed_samples()[source]
demux_status()[source]
samples()[source]
get_aggregator_sites()[source]
fetch_all_calibration()[source]

Gets uut calibration and stores in instance

scale_raw(raw, volts=False)[source]
chan2volts(chan, raw)[source]

returns calibrated volts for channel

Parameters:
  • chan (int) – channel index

  • raw (ndarray) – uncalibrated data array

Returns:

calibrated data array

Return type:

ndarray

read_chan(chan, nsam=0, data_size=None)[source]

Reads a channels data

Parameters:
  • chan (int) – channel number

  • nsam (int, optional) – Number of samples. Defaults to 0.

  • data_size (int, optional) – data size in bytes. Defaults to None.

Returns:

ndarray

read_decims(nsam=0)[source]
nchan()[source]

gets total number of channels

can include scratchpad

Returns:

number of channels

Return type:

int

data_size()[source]

gets data size

Returns:

data size in bytes

Return type:

int

uut_demux_enabled()[source]

returns demux status

read_channels(channels=(), nsam=0, localdemux=False)[source]

read selected channels post shot data.

uut_demux_enabled() == False: UUT did NOT demux the data, data order [sample][channel] uut_demux_enabled() == True: UUT did demux the data, data order [channel][sample]

DEMUX is a synonym for uut_demux_enabled()..

channels=(0) : return all (bulk) data, likely in raw[sample][channel] format. channels=(0) localdemux=True: return all (bulk) in demux[channel][sample] format.

channels=N or channels=(N,N1,N2 ..) # N >= 1 && N <= NCHAN

There are 4 cases: channels=(1,2…nchan) and (remote) DEMUX=1: SIMPLE, pull each channel at a time from the UUT. channels=(0) and DEMUX=0 : SIMPLE: return the raw data.

channels=(1,2..) and DEMUX=1 : demux locally.

channels=(0) and DEMUX=0 and localdemux : demux locally, return bulk data [channels][samnples]

Parameters:
  • channels (tuple, optional) – tuple contining channels to read . Defaults to all.

  • nsam (int, optional) – Number of samples. Defaults to 0.

  • localdemux (bool, optional) – demux data. Defaults to False.

Returns:

channel data

Return type:

ndarray

read_transient_timebase(nsamples, pre=0)[source]
load_segments(segs)[source]
show_segments()[source]
clear_counters()[source]
set_sync_routing_master(clk_dx='d1', trg_dx='d0')[source]
set_sync_routing_slave()[source]
set_sync_routing(role)[source]
set_mb_clk(hz=4000000, src='zclk', fin=1000000)[source]
load_stl(stl, port, trace=False, wait_eof=True, wait_eol=True)[source]

Send a STL file to the specified port

Parameters:
  • stl (str) – stl string each line seperated by newlines

  • port (int) – port num see AcqPorts

  • trace (bool, optional) – print each line sent. Defaults to False.

  • wait_eof (bool, optional) – wait for end of file. Defaults to True.

  • wait_eol (bool, optional) – wait for end of line. Defaults to True.

load_gpg(stl, trace=False)[source]

Send stl to GPG port

Parameters:
  • stl (str) – stl string each line seperated by newlines

  • trace (bool, optional) – print each line sent. Defaults to False.

load_dpg(stl, trace=False)[source]

Send stl to DPG port

Parameters:
  • stl (str) – stl string each line seperated by newlines

  • trace (bool, optional) – print each line sent. Defaults to False.

load_wrpg(stl, trace=False)[source]
load_dio482pg(site, stl, trace=False)[source]
set_DO(site, dox, value='P')[source]
exception AwgBusyError[source]

Bases: Exception

__init__(value)[source]
load_awg(data, autorearm=False, continuous=False, repeats=1, port=None)[source]

Load and config a AWG pattern

Parameters:
  • data (str) – AWG pattern

  • autorearm (bool, optional) – Rearm and wait after run. Defaults to False.

  • continuous (bool, optional) – Run pattern continuously. Defaults to False.

  • repeats (int, optional) – Number of pattern repetitions. Defaults to 1.

run_service(port, eof='EOF', prompt='>')[source]

Run a service on the uut

Parameters:
  • port (int) – service port see AcqPorts

  • eof (str, optional) – end connection on character. Defaults to “EOF”.

  • prompt (str, optional) – prompt character. Defaults to ‘>’.

Returns:

service transcript

Return type:

str

run_oneshot()[source]
run_livetop()[source]
disable_trigger()[source]
enable_trigger(trg_0='EXT', trg_1='STRIG')[source]
configure_post(role, trigger=[1, 1, 1], post=100000)[source]

Configure UUT for a regular transient capture

Parameters:
  • role (str) – uut role master or slave

  • trigger (list, optional) – Trigger trinary. Defaults to [1,1,1].

  • post (int, optional) – post samples. Defaults to 100k.

configure_pre_post(role, trigger=[1, 1, 1], event=[1, 1, 1], pre=50000, post=100000)[source]

Configure UUT for pre/post mode.

Default setup: soft trigger starts the data flow and trigger the event on a hard external trigger.

Parameters:
  • role (str) – uut role master or slave

  • trigger (list, optional) – Trigger trinary. Defaults to [1,1,1].

  • event (list, optional) – Event trinary. Defaults to [1,1,1].

  • pre (int, optional) – pre samples. Defaults to 50k.

  • post (int, optional) – post samples. Defaults to 100k.

configure_rtm(role, trigger=[1, 1, 1], event=[1, 1, 1], post=50000, rtm_translen=5000, gpg=0)[source]

Configure UUT for rtm mode.

Default setup: external trigger starts the capture and takes 5000 samples, each subsequent trigger gives us another 5000 samples.

GPG can be used in RTM mode as the Event. If you are using the GPG then this function can put the GPG output onto the event bus (to use as an Event for RTM).

Parameters:
  • role (str) – uut role master or slave

  • trigger (list, optional) – Trigger trinary. Defaults to [1,1,1].

  • event (list, optional) – Event trinary. Defaults to [1,1,1].

  • post (int, optional) – post samples. Defaults to 100k.

  • rtm_translen (int, optional) – translen. Defaults to 5000.

  • gpg (int, optional) – _description_. Defaults to 0.

configure_transient(pre=0, post=100000, sig_DX='d0', auto_soft_trigger=0, demux=1, edge='rising')[source]

Configure uut for transient capture.

Parameters:
  • pre (int, optional) – pre samples. Defaults to 0.

  • post (int, optional) – post samples. Defaults to 100k.

  • sig_DX (str, optional) – signal line responsible for trigger or event. Defaults to ‘d0’.

  • auto_soft_trigger (int, optional) – automatically soft trigger. Defaults to 0.

  • demux (int, optional) – demux data on/off. Defaults to 1.

  • edge (str, optional) – trigger edge. Defaults to ‘rising’.

configure_rgm(role, trigger=[1, 0, 1], event=[1, 1, 1], post='100000', gpg=0)[source]

Configure UUT for RGM mode

Parameters:
  • role (str) – uut role master or slave

  • trigger (list, optional) – Trigger trinary. Defaults to [1,0,1].

  • event (list, optional) – Event trinary. Defaults to [1,1,1].

  • post (int, optional) – post samples. Defaults to 100k.

  • gpg (int, optional) – Put GPG output onto the event bus (to use as an Event for RGM). Defaults to 0.

get_demux_state()[source]

Returns the current state of demux

Beware: if demux is set after the shot then this function will return the new state. There is no way to determine what the state was during the previous shot.

pull_plot(channels=(), demux=-1)[source]

This function returns an array of the specified channels and plots the data.

Pulls data from 53000 or 5300X and will return the corresponding data from each 5300X port (if demux is on) or will return the corresponding data filtered from 53000 if demux is off.

Parameters:
  • channels (tuple, optional) – tuple containing channel indexes. Defaults to ().

  • demux (int, optional) – 1 demux on 0 demux off -1 autodetect. Defaults to -1.

read_muxed_data()[source]

returns data from port 53000.

Only use if demux is turned off.

pull_data()[source]

Gets data from all AI channels

Returns:

channel data

Return type:

ndarray

get_ai_channels()[source]

Gets total number of AI channels

nchan can sometimes include scratchpad

Returns:

total AI channels

Return type:

int

get_site_types()[source]

gets all sites grouped by site type

Returns:

AISITES, AOSITES, and DIOSITES

Return type:

dict

get_es_indices(file_path='default', nchan='default', human_readable=0, return_hex_string=0)[source]

Returns the location of event samples.

Parameters:
  • file_path (str, optional) – data source. Can load from file. Defaults to from uut.

  • nchan (int, optional) – total chans use when loading from file. Defaults to from uut.

  • human_readable (int, optional) – returns hex interpretations of the event sample data. Defaults to 0.

  • return_hex_string (int, optional) – if 1 and human_readable 1 returns single string containing all of the event samples. Defaults to 0.

Returns:

[ [Event sample indices], [Event sample data] ]

Return type:

list

stream(recvlen=131072, port=4210, data_size=2)[source]

Runs stream and yields data buffers

Parameters:
  • recvlen (_type_, optional) – buffer size. Defaults to 4096*32.

  • port (_type_, optional) – uut port. Defaults to AcqPorts.STREAM value.

  • data_size (int, optional) – data size in bytes. Defaults to 2.

Yields:

ndarray – data buffer

stream_close()[source]
stream_slowmon(nspad=None)[source]
slowmon_close()[source]
freqpv(sig)[source]
floatpv(_pv)[source]
activepv(_pv)[source]
class Acq2106[source]

Bases: Acq400

Acq2106 specialization of Acq400

Defines features specific to ACQ2106

__init__(_uut, monitor=True, s0_client=None, has_dsp=False, has_comms=True, has_wr=False, has_hudp=False)[source]

init acq2106

Parameters:
  • _uut (srt) – uut hostname or ip-address

  • monitor (bool, optional) – start statusmonitor. Defaults to True.

  • s0_client (netclient.Siteclient, optional) – existing siteclient. Defaults to None.

  • has_dsp (bool, optional) – if uut has dsp. Defaults to False.

  • has_comms (bool, optional) – if uut has comms. Defaults to True.

  • has_wr (bool, optional) – if uut has white rabbit. Defaults to False.

  • has_hudp (bool, optional) – if uut has hudp. Defaults to False.

get_mgt_site(mgt)[source]

gets mgt site str from num

Parameters:

mgt (int) – mgt site num

Returns:

(site string, site num)

Return type:

tuple

set_mb_clk(hz=4000000, src='zclk', fin=1000000)[source]
set_sync_routing_slave()[source]
set_master_trg(trg, edge='rising', enabled=True)[source]
set_MR(enable, evsel0=4, evsel1=5, MR10DEC=8)[source]
wr_PPS_active()[source]
get_sys_info()[source]

Gets uut system information

Returns:

system info

Return type:

str

class Acq2106_Mgtdram8[source]

Bases: Acq2106

Mgtdram8 specialization of Acq2106

Defines features specific to Acq2106_Mgtdram8

MGT_BLOCK_BYTES = 4194304
MGT_BLOCK_MULTIPLE = 16
__init__(uut, monitor=True, s0_client=None)[source]

init Acq2106_Mgtdram8

Parameters:
  • _uut (srt) – uut hostname or ip-address

  • monitor (bool, optional) – start statusmonitor. Defaults to True.

  • s0_client (netclient.Siteclient, optional) – existing siteclient. Defaults to None.

run_mgt(filter=<acq400_hapi.acq400.NullFilter object>, set_arm=True)[source]
create_mgtdram_pull_client()[source]
class Acq2106_TIGA[source]

Bases: Acq2106

TIGA specialization of Acq2106

Defines features specific to Acq2106_TIGA

__init__(uut, monitor=True, s0_client=None)[source]

init Acq2106_TIGA

Parameters:
  • _uut (srt) – uut hostname or ip-address

  • monitor (bool, optional) – start statusmonitor. Defaults to True.

  • s0_client (netclient.Siteclient, optional) – existing siteclient. Defaults to None.

load_dio482pg(site, stl, trace=False)[source]
set_DO(site, dox, value='P')[source]
run_unit_test()[source]
sigsel(enable=1, dx=1, site=None, edge=1)[source]
factory(_uut)[source]

deduce what sort of uut this is and invoke the appropriate class

Preferred to init hapi instance

Parameters:

_uut (str) – uut hostname or ip-address

Returns:

uut hapi instance

Return type:

acq400

get_hapi()[source]

find instance of hapi

freq(sig)[source]
intpv(pv)[source]
pv(pv)[source]