# Default SCPI configuration

# General device settings
DEVIce:SYNC INTernal;RESolution LOWRES;LEDS ON

# link output loop to internal clock
OUTLoop:LINK INT

# configure inputs and start channel
STAR:ENAB ON;COUP DC;EDGE RISING;THRE -0.400V;SELE UNSHAPED;COUNter:INTEgrationtime 1000;MODE CYCLE
INPU1:ENAB OFF;COUP DC;EDGE RISING;THRE -0.400V;SELE UNSHAPED;RESY AUTO;COUNter:INTEgrationtime 1000;MODE CYCLE
INPU2:ENAB OFF;COUP DC;EDGE RISING;THRE -0.400V;SELE UNSHAPED;RESY AUTO;COUNter:INTEgrationtime 1000;MODE CYCLE
INPU3:ENAB OFF;COUP DC;EDGE RISING;THRE -0.400V;SELE UNSHAPED;RESY AUTO;COUNter:INTEgrationtime 1000;MODE CYCLE
INPU4:ENAB OFF;COUP DC;EDGE RISING;THRE -0.400V;SELE UNSHAPED;RESY AUTO;COUNter:INTEgrationtime 1000;MODE CYCLE

# configure delays
STAR:DELAy 0
DELA1:VALUe 0;LINK INPU1
DELA2:VALUe 0;LINK INPU2
DELA3:VALUe 0;LINK INPU3
DELA4:VALUe 0;LINK INPU4
DELA5:VALUe 0;LINK INPU1
DELA6:VALUe 0;LINK INPU2
DELA7:VALUe 0;LINK INPU3
DELA8:VALUe 0;LINK INPU4

# disable outputs, use NIM mode, no delay, not output pulse
OUTP1:ENAB OFF;MODE NIM;PULSe OFF;DELAy 0;PULSE:WIDTH 100
OUTP2:ENAB OFF;MODE NIM;PULSe OFF;DELAy 0;PULSE:WIDTH 100
OUTP3:ENAB OFF;MODE NIM;PULSe OFF;DELAy 0;PULSE:WIDTH 100
OUTP4:ENAB OFF;MODE NIM;PULSe OFF;DELAy 0;PULSE:WIDTH 100

# map each output# to tsco# (n to n mapping)
OUTP1:LINK TSCO1
OUTP2:LINK TSCO2
OUTP3:LINK TSCO3
OUTP4:LINK TSCO4

# level 2 combiners

# first 4 combiners forward the first 4 generators signals

TSCO1:FIR:LINK GEN1
TSCO1:SEC:LINK NONE
TSCO1:OPIN ONLYFIR;OPOUt ONLYFIR
TSCO1:COUNter:INTEgrationtime 1000;MODE CYCLE
TSCO1:WIND:ENAB OFF
TSCO1:WIND:BEGIn:DELAY 0;EDGE RISING;LINK NONE
TSCO1:WIND:END:DELAY 0;EDGE FALLing;LINK NONE

TSCO2:FIR:LINK GEN2
TSCO2:SEC:LINK NONE
TSCO2:OPIN ONLYFIR;OPOUt ONLYFIR
TSCO2:COUNter:INTEgrationtime 1000;MODE CYCLE
TSCO2:WIND:ENAB OFF
TSCO2:WIND:BEGIn:DELAY 0;EDGE RISING;LINK NONE
TSCO2:WIND:END:DELAY 0;EDGE FALLing;LINK NONE

TSCO3:FIR:LINK GEN3
TSCO3:SEC:LINK NONE
TSCO3:OPIN ONLYFIR;OPOUt ONLYFIR
TSCO3:COUNter:INTEgrationtime 1000;MODE CYCLE
TSCO3:WIND:ENAB OFF
TSCO3:WIND:BEGIn:DELAY 0;EDGE RISING;LINK NONE
TSCO3:WIND:END:DELAY 0;EDGE FALLing;LINK NONE

TSCO4:FIR:LINK GEN4
TSCO4:SEC:LINK NONE
TSCO4:OPIN ONLYFIR;OPOUt ONLYFIR
TSCO4:COUNter:INTEgrationtime 1000;MODE CYCLE
TSCO4:WIND:ENAB OFF
TSCO4:WIND:BEGIn:DELAY 0;EDGE RISING;LINK NONE
TSCO4:WIND:END:DELAY 0;EDGE FALLing;LINK NONE

# next 4 combiners forward inputs signals (from first 4 DELA# blocks)

TSCO5:FIR:LINK DELA1
TSCO5:SEC:LINK NONE
TSCO5:OPIN ONLYFIR;OPOUt ONLYFIR
TSCO5:COUNter:INTEgrationtime 1000;MODE CYCLE
TSCO5:WIND:ENAB OFF
TSCO5:WIND:BEGIn:DELAY 0;EDGE RISING;LINK NONE
TSCO5:WIND:END:DELAY 0;EDGE FALLing;LINK NONE

TSCO6:FIR:LINK DELA2
TSCO6:SEC:LINK NONE
TSCO6:OPIN ONLYFIR;OPOUt ONLYFIR
TSCO6:COUNter:INTEgrationtime 1000;MODE CYCLE
TSCO6:WIND:ENAB OFF
TSCO6:WIND:BEGIn:DELAY 0;EDGE RISING;LINK NONE
TSCO6:WIND:END:DELAY 0;EDGE FALLing;LINK NONE

TSCO7:FIR:LINK DELA3
TSCO7:SEC:LINK NONE
TSCO7:OPIN ONLYFIR;OPOUt ONLYFIR
TSCO7:COUNter:INTEgrationtime 1000;MODE CYCLE
TSCO7:WIND:ENAB OFF
TSCO7:WIND:BEGIn:DELAY 0;EDGE RISING;LINK NONE
TSCO7:WIND:END:DELAY 0;EDGE FALLing;LINK NONE

TSCO8:FIR:LINK DELA4
TSCO8:SEC:LINK NONE
TSCO8:OPIN ONLYFIR;OPOUt ONLYFIR
TSCO8:COUNter:INTEgrationtime 1000;MODE CYCLE
TSCO8:WIND:ENAB OFF
TSCO8:WIND:BEGIn:DELAY 0;EDGE RISING;LINK NONE
TSCO8:WIND:END:DELAY 0;EDGE FALLing;LINK NONE

#coincidence level 2

TSCO9:FIR:LINK GEN1
TSCO9:SEC:LINK NONE
TSCO9:OPIN ONLYFIR;OPOUt ONLYFIR
TSCO9:COUNter:INTEgrationtime 1000;MODE CYCLE
TSCO9:WIND:ENAB OFF
TSCO9:WIND:BEGIn:DELAY 0;EDGE RISING;LINK NONE
TSCO9:WIND:END:DELAY 0;EDGE FALLing;LINK NONE

TSCO10:FIR:LINK GEN2
TSCO10:SEC:LINK NONE
TSCO10:OPIN ONLYFIR;OPOUt ONLYFIR
TSCO10:COUNter:INTEgrationtime 1000;MODE CYCLE
TSCO10:WIND:ENAB OFF
TSCO10:WIND:BEGIn:DELAY 0;EDGE RISING;LINK NONE
TSCO10:WIND:END:DELAY 0;EDGE FALLing;LINK NONE

TSCO11:FIR:LINK GEN3
TSCO11:SEC:LINK NONE
TSCO11:OPIN ONLYFIR;OPOUt ONLYFIR
TSCO11:COUNter:INTEgrationtime 1000;MODE CYCLE
TSCO11:WIND:ENAB OFF
TSCO11:WIND:BEGIn:DELAY 0;EDGE RISING;LINK NONE
TSCO11:WIND:END:DELAY 0;EDGE FALLing;LINK NONE

TSCO12:FIR:LINK GEN4
TSCO12:SEC:LINK NONE
TSCO12:OPIN ONLYFIR;OPOUt ONLYFIR
TSCO12:COUNter:INTEgrationtime 1000;MODE CYCLE
TSCO12:WIND:ENAB OFF
TSCO12:WIND:BEGIn:DELAY 0;EDGE RISING;LINK NONE
TSCO12:WIND:END:DELAY 0;EDGE FALLing;LINK NONE

TSCO13:FIR:LINK NONE
TSCO13:SEC:LINK NONE
TSCO13:OPIN ONLYFIR;OPOUt ONLYFIR
TSCO13:COUNter:INTEgrationtime 1000;MODE CYCLE
TSCO13:WIND:ENAB OFF
TSCO13:WIND:BEGIn:DELAY 0;EDGE RISING;LINK NONE
TSCO13:WIND:END:DELAY 0;EDGE FALLing;LINK NONE

TSCO14:FIR:LINK NONE
TSCO14:SEC:LINK NONE
TSCO14:OPIN ONLYFIR;OPOUt ONLYFIR
TSCO14:COUNter:INTEgrationtime 1000;MODE CYCLE
TSCO14:WIND:ENAB OFF
TSCO14:WIND:BEGIn:DELAY 0;EDGE RISING;LINK NONE
TSCO14:WIND:END:DELAY 0;EDGE FALLing;LINK NONE

TSCO15:FIR:LINK NONE
TSCO15:SEC:LINK NONE
TSCO15:OPIN ONLYFIR;OPOUt ONLYFIR
TSCO15:COUNter:INTEgrationtime 1000;MODE CYCLE
TSCO15:WIND:ENAB OFF
TSCO15:WIND:BEGIn:DELAY 0;EDGE RISING;LINK NONE
TSCO15:WIND:END:DELAY 0;EDGE FALLing;LINK NONE

TSCO16:FIR:LINK NONE
TSCO16:SEC:LINK NONE
TSCO16:OPIN ONLYFIR;OPOUt ONLYFIR
TSCO16:COUNter:INTEgrationtime 1000;MODE CYCLE
TSCO16:WIND:ENAB OFF
TSCO16:WIND:BEGIn:DELAY 0;EDGE RISING;LINK NONE
TSCO16:WIND:END:DELAY 0;EDGE FALLing;LINK NONE

#coincidence level 3

TSCO17:FIR:LINK NONE
TSCO17:SEC:LINK NONE
TSCO17:OPIN ONLYFIR;OPOUt ONLYFIR
TSCO17:COUNter:INTEgrationtime 1000;MODE CYCLE
TSCO17:WIND:ENAB OFF
TSCO17:WIND:BEGIn:DELAY 0;EDGE RISING;LINK NONE
TSCO17:WIND:END:DELAY 0;EDGE FALLing;LINK NONE

TSCO18:FIR:LINK NONE
TSCO18:SEC:LINK NONE
TSCO18:OPIN ONLYFIR;OPOUt ONLYFIR
TSCO18:COUNter:INTEgrationtime 1000;MODE CYCLE
TSCO18:WIND:ENAB OFF
TSCO18:WIND:BEGIn:DELAY 0;EDGE RISING;LINK NONE
TSCO18:WIND:END:DELAY 0;EDGE FALLing;LINK NONE

TSCO19:FIR:LINK NONE
TSCO19:SEC:LINK NONE
TSCO19:OPIN ONLYFIR;OPOUt ONLYFIR
TSCO19:COUNter:INTEgrationtime 1000;MODE CYCLE
TSCO19:WIND:ENAB OFF
TSCO19:WIND:BEGIn:DELAY 0;EDGE RISING;LINK NONE
TSCO19:WIND:END:DELAY 0;EDGE FALLing;LINK NONE

TSCO20:FIR:LINK NONE
TSCO20:SEC:LINK NONE
TSCO20:OPIN ONLYFIR;OPOUt ONLYFIR
TSCO20:COUNter:INTEgrationtime 1000;MODE CYCLE
TSCO20:WIND:ENAB OFF
TSCO20:WIND:BEGIn:DELAY 0;EDGE RISING;LINK NONE
TSCO20:WIND:END:DELAY 0;EDGE FALLing;LINK NONE

TSCO21:FIR:LINK NONE
TSCO21:SEC:LINK NONE
TSCO21:OPIN ONLYFIR;OPOUt ONLYFIR
TSCO21:COUNter:INTEgrationtime 1000;MODE CYCLE
TSCO21:WIND:ENAB OFF
TSCO21:WIND:BEGIn:DELAY 0;EDGE RISING;LINK NONE
TSCO21:WIND:END:DELAY 0;EDGE FALLing;LINK NONE

TSCO22:FIR:LINK NONE
TSCO22:SEC:LINK NONE
TSCO22:OPIN ONLYFIR;OPOUt ONLYFIR
TSCO22:COUNter:INTEgrationtime 1000;MODE CYCLE
TSCO22:WIND:ENAB OFF
TSCO22:WIND:BEGIn:DELAY 0;EDGE RISING;LINK NONE
TSCO22:WIND:END:DELAY 0;EDGE FALLing;LINK NONE

TSCO23:FIR:LINK NONE
TSCO23:SEC:LINK NONE
TSCO23:OPIN ONLYFIR;OPOUt ONLYFIR
TSCO23:COUNter:INTEgrationtime 1000;MODE CYCLE
TSCO23:WIND:ENAB OFF
TSCO23:WIND:BEGIn:DELAY 0;EDGE RISING;LINK NONE
TSCO23:WIND:END:DELAY 0;EDGE FALLing;LINK NONE

TSCO24:FIR:LINK NONE
TSCO24:SEC:LINK NONE
TSCO24:OPIN ONLYFIR;OPOUt ONLYFIR
TSCO24:COUNter:INTEgrationtime 1000;MODE CYCLE
TSCO24:WIND:ENAB OFF
TSCO24:WIND:BEGIn:DELAY 0;EDGE RISING;LINK NONE
TSCO24:WIND:END:DELAY 0;EDGE FALLing;LINK NONE

# Configure generators
REC:ENAB OFF;NUM 1;DUR 1000000000000;TRIG:DELA 0;LINK DELA4;ARM:MODE MANU
GEN1:ENAB OFF;PNUM INF;PWID 500000;PPER 1000000;TRIG:DELA 0;LINK DELA1;ARM:MODE MANU
GEN2:ENAB OFF;PNUM INF;PWID 500000;PPER 1000000;TRIG:DELA 0;LINK DELA2;ARM:MODE MANU
GEN3:ENAB OFF;PNUM INF;PWID 500000;PPER 1000000;TRIG:DELA 0;LINK DELA3;ARM:MODE MANU
GEN4:ENAB OFF;PNUM INF;PWID 500000;PPER 1000000;TRIG:DELA 0;LINK DELA4;ARM:MODE MANU
GEN5:ENAB OFF;PNUM INF;PWID 500000;PPER 1000000;TRIG:DELA 0;LINK DELA1;ARM:MODE MANU
GEN6:ENAB OFF;PNUM INF;PWID 500000;PPER 1000000;TRIG:DELA 0;LINK DELA2;ARM:MODE MANU
GEN7:ENAB OFF;PNUM INF;PWID 500000;PPER 1000000;TRIG:DELA 0;LINK DELA3;ARM:MODE MANU
GEN8:ENAB OFF;PNUM INF;PWID 500000;PPER 1000000;TRIG:DELA 0;LINK DELA4;ARM:MODE MANU

# Configure histograms to use combiners 5..8 (gated internally in the HISTO with TSGE8)
# Configure histogram start channels
# Configure histogram stop channels to be routed via combiners n+4, to account for gating (synch acq.)
# Configure Raw data and histogram start channels on the start

HIST1:STOP:LINK TSCO5
HIST1:REF:LINK STAR
HIST1:STOP:FILT RISI
HIST1:REF:FILT RISI
HIST1:ENAB:LINK REC
HIST1:MIN 0;BWID 100;BCOUNT 10

HIST2:STOP:LINK TSCO6
HIST2:REF:LINK STAR
HIST2:STOP:FILT RISI
HIST2:REF:FILT RISI
HIST2:ENAB:LINK REC
HIST2:MIN 0;BWID 100;BCOUNT 10

HIST3:STOP:LINK TSCO7
HIST3:REF:LINK STAR
HIST3:STOP:FILT RISI
HIST3:REF:FILT RISI
HIST3:ENAB:LINK REC
HIST3:MIN 0;BWID 100;BCOUNT 10

HIST4:STOP:LINK TSCO8
HIST4:REF:LINK STAR
HIST4:STOP:FILT RISI
HIST4:REF:FILT RISI
HIST4:ENAB:LINK REC
HIST4:MIN 0;BWID 100;BCOUNT 10

# flush histograms
HIST1:FLUSh
HIST2:FLUSh
HIST3:FLUSh
HIST4:FLUSh

RAW1:SEND OFF
RAW1:REF:LINK STAR
RAW1:STOP:LINK TSCO5
RAW1:ENAB:LINK REC
RAW1:NUMErator 1;DENOminator 1

RAW2:SEND OFF
RAW2:REF:LINK STAR
RAW2:STOP:LINK TSCO6
RAW2:ENAB:LINK REC
RAW2:NUMErator 1;DENOminator 1

RAW3:SEND OFF
RAW3:REF:LINK STAR
RAW3:STOP:LINK TSCO7
RAW3:ENAB:LINK REC
RAW3:NUMErator 1;DENOminator 1

RAW4:SEND OFF
RAW4:REF:LINK STAR
RAW4:STOP:LINK TSCO8
RAW4:ENAB:LINK REC
RAW4:NUMErator 1;DENOminator 1
