# ****************************************************************
# ZLE Configuration File
# ****************************************************************

# NOTE:
# The setting modes can be [COMMON] (all boards-related), "[BOARD] #" (single board-related) or "[CHANNEL] #" (single channel-related)
# The setting mode is specified by a C,B and G in the setting description
# If a setting is CHANNEL-related, it can also be BOARD-related or COMMON (i.e. the setting refers to all the channels in all the boards of the system) 
# However not all options that are COMMON can also be BOARD- or CHANNEL-related.  The "[BOARD] #" or "[CHANNEL] #" directives have no effect on such settings
# The "[BOARD] #" and "[CHANNEL] #" modes are alternative to [COMMON] but do not exclude each other. This means that one can issue a command to a 
# specific channel of a specific board, to all channels of a specific board or to a specific channel of all boards. 
# When the "[BOARD] #" mode is set, the following settings apply to all channels (even if a specific channel was previously selected)  
# The board index follows the board initialization order using the OPEN command (see below).
# The lines between the commands @OFF and @ON will be skipped. This can be used to exclude parts of the config file.

# ----------------------------------------------------------------
# Settings common to the whole acquisition system.
# ----------------------------------------------------------------
[COMMON] 

# OPEN: open the digitizer
# NOTE: when using the USB or CONET, the BA must be set to 0
# The base address (if required) must be in the form "0xXXXXXXXX"
# options: 
# USB [LINKNUM] 0                   Desktop/NIM digitizer through USB
# USB [LINKNUM] [BA]                VME digitizer through USB V1718/V3718 (BA = BaseAddress of the VME board, 32 bit hex)
# PCI [LINKNUM] [CONET NODE] 0      Desktop/NIM/VME through CONET (optical link) with A2818/A3818/A5818
# PCI [LINKNUM] [CONET NODE] [BA]   VME digitizer through CONET (optical link) with A2818/A3818/A5818 and V2718/V3718/V4718 (BA = BaseAddress of the VME board, 32 bit hex)
# USB_A4818 [PID] [CONET NODE] 0    Desktop/NIM/VME through CONET (optical link) with A4818
# USB_A4818 [PID] [CONET NODE] [BA] VME digitizer through CONET (optical link) with A4818 and V2718/V3718/V4718 (BA = BaseAddress of the VME board, 32 bit hex)
# USB_V4718 [PID] [BA]              VME digitizer through USB V4718 (BA = BaseAddress of the VME board, 32 bit hex)
# ETH_V4718 [HOSTNAME] [BA]         VME digitizer through ETH V4718 (BA = BaseAddress of the VME board, 32 bit hex)

OPEN USB 0 0x32100000
#OPEN USB 0 0
#OPEN PCI 0 0 0x32110000
#OPEN PCI 0 0 0

# START ACQUISITION(SW,S_IN,FIRST_TRG,LVDS): board start acquisition signal source
#start acquisition settings only apply when not in synchronization mode (see below) 
#START_ACQ SW

# ENABLE SYNC(YES/NO): sets all the registers required for the synchronization procedure
# board delays might need a further tuning according to the experimental setup used
SYNC_ENABLE YES

# Statistics Refresh period (msec)(C), including event plotting if enabled.
STAT_REFRESH 1000

# PERIODIC_PLOT(YES/NO)(C): if set to YES a spectrum will be plotted periodically, the period being set by the STAT_REFRESH variable
# On slower PCs, disabling this feature might improve the demo sw's performances. Single events can be plotted by pressing the "p" key during acquisition 
PERIODIC_PLOT YES

# PLOT TYPE (C): plot all the channels of a single board (BOARDPLOT) or  0-channels of each board (SYNCPLOT,useful to verify the synchronization)
PLOT_TYPE BOARDPLOT

# GNUPLOT_PATH (C): path to gnuplot executable file
# remember: \ for windows, / for linux
# included gnuplot execs might not work on all win/linux systems. Installing gnuplot and adding it to your path on the used system is advised
# if the pre-installed, path-added gnuplot is used, set GNUPLOT_PATH to ""
#GNUPLOT_PATH "./gnuplot_exec/linux/"
#GNUPLOT_PATH  "..\gnuplot_exec\win\"

# Enable output file: RAW,WAVE (YES/NO)(C)
# The RAW mode allows to save the board dump (.bin)
# The WAVE mode allows to save the last wave of each active channel (.txt)

OUTFILE_RAW NO
OUTFILE_WAVE NO

# OUTPUT BINARY FILES PATH AND NAME
# The default output directory in windows is "UserDir"\ZLE_DEMO\ZLE_output\ (created by the program)
# The default output directory in linux is "UserDir"\ZLE_output\ (created by the program) 
# The default file name is run0
# b,c,seg identify the board, channel and output segment (segmented according to OUTFILE_MAXSIZE):
# "file_name"_raw_b#_seg#.bin for the raw
# "file_name"_wave_b#_c#.txt for the wave
# the following lines must be uncommented to change the default output directory and filename
# if they are commented, "ZLE_output" and "run0" will be the default output directory and name
#OUTFILE_PATH ZLE_output\
#OUTFILE_NAME run0

# SIZE OF A SINGLE OUTPUT BINARY FILE(MBytes)(C). After this size has been reached by raw files, a new file with a _(#+1) segment value will be opened.
OUTFILE_MAXSIZE 100

# SOFTWARE TRIGGER: software trigger input settings. When enabled, the software trigger can be either 
# propagated (ACQUISITION_AND_TRGOUT, TRGOUT_ONLY) or not (ACQUISITION_ONLY) through the TRGOUT connector
#options: DISABLED, ACQUISITION_ONLY, TRGOUT_ONLY, ACQUISITION_AND_TRGOUT
SW_TRIGGER  ACQUISITION_ONLY

# CONTINUOUS SW TRIGGER (YES/NO)
CONT_SWTRIGGER NO

# ----------------------------------------------------------------
# Board-specific (B) or channel-specific (CH) Settings.
# The CH-settings can be applied on a channel basis
# if the related channel section ([CHANNEL] #) is specified; 
# if written in the [COMMON] section, the settings are applied to all channels.
# Remember: What is channel-specific ([CHANNEL] #) can be also board-specific ([BOARD] #) and both can be [COMMON]
# ----------------------------------------------------------------
[COMMON]

# EXTERNAL_TRIGGER(B): external trigger (TRGIN connector) input settings. When enabled, the external trigger can be either 
# propagated (ACQUISITION_AND_TRGOUT, TRGOUT_ONLY) or not (ACQUISITION_ONLY) through the TRGOUT connector
# options: DISABLED, ACQUISITION_ONLY, ACQUISITION_AND_TRGOUT
EXTERNAL_TRIGGER  ACQUISITION_ONLY

# FPIO_LEVEL(B): signal type (NIM or TTL) of the front panel I/O LEMO connectors 
FPIO_LEVEL TTL

# RECORD_LENGTH (0/1048576)(B): the record length is the same for all channels. Each unit is equal to 4 samples.
RECORD_LENGTH 512

# TRIGGER COUPLE MASK (0x00/0xff)(B): mask of the trigger couples involved in the trigger generation  
TRIGCOUPLE_MASK 0x00

# TRIGGER COUPLE LOGIC (OR, AND, FIRSTONLY, SECONDONLY)(B): logic of each couple of channels involved in the trigger generation

TRIGLOGIC_COUPLE 0 OR
TRIGLOGIC_COUPLE 1 OR
TRIGLOGIC_COUPLE 2 OR
TRIGLOGIC_COUPLE 3 OR
TRIGLOGIC_COUPLE 4 OR
TRIGLOGIC_COUPLE 5 OR
TRIGLOGIC_COUPLE 6 OR
TRIGLOGIC_COUPLE 7 OR

# GAIN (0/1)(B): sets the input dynamic range (0->2Vpp, 1->0.5Vpp)
GAIN_FACTOR 0

# PRETRIGGER (0/240)(CH): it sets how long before the trigger the record length window should be opened. Each unit corresponds to 4 samples
# if PRE_TRIGGER=N_LBK=0 and trigger generated by over-threshold channels, the triggering samples are at about 16 ns from the start of the collected window
# if PRE_TRIGGER=N_LBK=0 and external trigger, samples sinchronous with the external trigger are at about 186(132) ns from the start of the collected window for the V1725(V1730)
PRE_TRIGGER 2

#LOOK-BACK AND LOOK-FORWARD WINDOW (0/255)(CH): samples collected before and after the over-threshold signal. Each unit corresponds to 2 samples
N_LBK	6
N_LFW	6

#USE DEFAULT BASELINE VALUE (YES/NO)(CH): If set to YES, the baseline is given a fixed value (see below)
BLINE_DEFMODE NO

#DEFAULT BASELINE VALUE(0/16383)(CH): Default value of the baseline (only used if BLINE_DEFMODE=YES)
BLINE_DEFVALUE 15900

#BASELINE NOISE IN LSBs (0/255)(CH): This value is needed by the baseline algorithm and should be ideally equal to the noise sigma
BLINE_NOISE 6 

#PULSE POLARITY (POSITIVE/NEGATIVE)(CH): signal polarity 
PULSE_POLARITY POSITIVE

#NO THRESHOLD (YES/NO)(CH): collect all samples in the record length window, disregarding polarity and threshold
NO_THRESHOLD NO

#ENABLE TEST PULSE (YES/NO)(CH): Allows to replace the input channels with an internally-generated, exponentially-decaying pulse
TEST_PULSE NO

#TEST PULSE RATE (0/7)(CH): (0->1Hz,1->10Hz,...,6->1MHz,7->10MHz on XX30, half the rates on XX25)
TP_RATE 3

#TEST PULSE SIGNAL HEIGHT (0/3)(CH): (0:x1,...,3:x4)
TP_SCALE 1

#TEST PULSE POLARITY (POSITIVE/NEGATIVE;CH)
TP_POLARITY POSITIVE

#DATA THRESHOLD (0/16385)(CH): data threshold 
ZLE_THRESHOLD   400

# example: set the threshold to a different value for all channels of the first board and then switch back to [COMMON]
#[BOARD] 0
#ZLE_THRESHOLD 200
#[COMMON]

#TRIGGER TRESHOLD (0/16385)(CH): trigger threshold
TRG_THRESHOLD   200

# ENABLE_INPUT (YES,NO)(CH): enable/disable the channel
# options: YES, NO

# ENABLE_GRAPH (YES,NO)(CH): enable/disable the graph of that channel
# the plotted channels can be enabled/disabled by using the 1-8 keys 
# 1-8 corresponds to channels 0-7 or 8-15; the group selection can be toggled by pressing 'g' 
# the plotted board (in case of multiple boards) can be toggled by pressing the +/- keys
# This parameter is meaningless if the channel is not enabled (ENABLE_INPUT = YES)

# DC_OFFSET (-50./50.)(CH): DC offset adjust (DAC channel setting) in percent of the Full Scale.
# -50: analog input dynamic range = -Vpp to 0 (negative signals)
# +50: analog input dynamic range = 0 to +Vpp (positive signals)
# 0:   analog input dynamic range = -Vpp/2 to +Vpp/2 (bipolar signals)
# options: -50.0 to 50.0  (floating point)

[CHANNEL] 0

ENABLE_INPUT           YES
ENABLE_GRAPH           YES
DC_OFFSET              0

[CHANNEL] 1
ENABLE_INPUT           YES
ENABLE_GRAPH           YES
DC_OFFSET              0

[CHANNEL] 2
ENABLE_INPUT           YES
ENABLE_GRAPH           YES
DC_OFFSET              0

[CHANNEL] 3
ENABLE_INPUT           YES
ENABLE_GRAPH           YES
DC_OFFSET              0

[CHANNEL] 4
ENABLE_INPUT           YES
ENABLE_GRAPH           YES
DC_OFFSET              0

[CHANNEL] 5
ENABLE_INPUT           YES
ENABLE_GRAPH           YES
DC_OFFSET              0

[CHANNEL] 6
ENABLE_INPUT           YES
ENABLE_GRAPH           YES
DC_OFFSET              0

[CHANNEL] 7
ENABLE_INPUT           YES
ENABLE_GRAPH           YES
DC_OFFSET              0

[CHANNEL] 8
ENABLE_INPUT           YES
ENABLE_GRAPH           YES
DC_OFFSET              0

[CHANNEL] 9
ENABLE_INPUT           YES
ENABLE_GRAPH           YES
DC_OFFSET              0

[CHANNEL] 10
ENABLE_INPUT           YES
ENABLE_GRAPH           YES
DC_OFFSET              0

[CHANNEL] 11
ENABLE_INPUT           YES
ENABLE_GRAPH           YES
DC_OFFSET              0

[CHANNEL] 12
ENABLE_INPUT           YES
ENABLE_GRAPH           YES
DC_OFFSET              0

[CHANNEL] 13
ENABLE_INPUT           YES
ENABLE_GRAPH           YES
DC_OFFSET              0

[CHANNEL] 14
ENABLE_INPUT           YES
ENABLE_GRAPH           YES
DC_OFFSET              0

[CHANNEL] 15
ENABLE_INPUT           YES
ENABLE_GRAPH           YES
DC_OFFSET              0