# Configuration commands

Commands to configure the detector. these commands are often left to the configuration file.

- Data Structure: commands to configure detector data structure
- Status: commands to configure detector status
- Data Size: commands to configure detector data size
- Flags: commands to configure detector flags
- Chip: commands to configure chip of the detector
- Versions: commands to check version of each subsytem
- Speed: commands to configure speed of detector
- Detector Parameters: commands to configure/retrieve configuration of detector

## Data Structure

commands to configure detector data structure

- externalgui sets/gets external gui flag. 1 sets and enables the 0MQ data stream (0MQ threads created) from receiver to client, while 0 unsets and disables. `Returns` ``(int)

- free Free shared memory on the control PC

- add Adds a detector at the end of the multi-detector structure. `put` argument is the hostname or IP adress. Returns the chained list of detector hostnames.

- remove i Removes controller `i` from the multi-detector structure. Can be used for partial readout of the detector.

- type Sets/gets detector type. `Returns` ``(string). Normally not used. Using hostname is enough.

- hostname `put` adds the hostname (ot IP adress) at the end of the multi-detector structure. If used for a single controlled (i:) replaces the current hostname. Returns the list of the hostnames of the multi-detector structure. `Returns` ``(string)

- id[:i] Returns the id of the detector structure. i is the detector position in a multi detector system. If used a `put`, configures the id of the detector structure. i is the detector position in a multi detector system and l is the id of the detector to be added.

- master i `put` sets the position of the master of the acquisition (-1 if none). Returns the position of the master of the detector structure (-1 if none).

- sync Sets/gets the synchronization mode of the detectors in the multi-detector structure. Can be: `none`, `gating`, `trigger`, `complementary`. Mainly used by MYTHEN/GOTTHARD.

## Status

commands to configure detector status

- online [i] sets the detector in online (1) or offline (0) mode. `Returns` ``(int)

- checkonline returns the hostnames of all detectors without connecting to them. `Returns` (string) "All online" or "[list of offline hostnames] : Not online".

- activate Activates/Deactivates the detector. Deactivated detector does not send data. Used for EIGER only. `Returns` ``(int)

## Data Size

commands to configure detector data size

- nmod [i] sets/gets the number of modules of the detector. Used for MYTHEN only. `Returns` ``(int)

- maxmod Gets the maximum number of modules of the detector. Used for MYTHEN only. Cannot put! `Returns` ``(int)

- dr [i] sets/gets the dynamic range of detector. Mythen [4,8,16,24]. Eiger [4,8,16,32]. Others cannot put! `Returns` ``(int)

- roi [i] [xmin] [xmax] [ymin] [ymax] sets region of interest of the detector, where i is number of rois;i=0 to clear rois. Used for GOTTHARD only. `Returns` ``(int)

- detsizechan [xmax] [ymax] sets the maximum number of channels in each dimension for complete detector set; -1 is no limit. Use for multi-detector system as first command in config file. `Returns` ``("int int")

- roimask [i] ?? `Returns` ``(int) in hexadecimal

- flippeddatax [i] enables/disables data being flipped across x axis. 1 enables, 0 disables. Used for EIGER only. 1 for bottom half-module, 0 for top-half module. `Returns` ``(int)

- tengiga [i] enables/disables 10GbE in system (detector & receiver). 1 enabled 10GbE, 0 enables 1GbE. Used in EIGER only. `Returns` ``(int)

## Flags

commands to configure detector flags

- flags [flag] sets/gets the readout flags to mode. Options: none, storeinram, tot, continous, parallel, nonparallel, safe, digital, analog_digital, unknown. Used for MYTHEN and EIGER only. `Returns` ``(string). put takes one string and `returns` concatenation of all active flags separated by spaces.

- extsig:[i] [flag] sets/gets the mode of the external signal i. Options: `off`, `gate_in_active_high`, `gate_in_active_low`, `trigger_in_rising_edge`, `trigger_in_falling_edge`, `ro_trigger_in_rising_edge`, `ro_trigger_in_falling_edge`, `gate_out_active_high`, `gate_out_active_low`, `trigger_out_rising_edge`, `trigger_out_falling_edge`, `ro_trigger_out_rising_edge`, `ro_trigger_out_falling_edge`.
  Used in MYTHEN, GOTTHARD, PROPIX only. `Returns` ``(string)

- programfpga [file] programs the FPGA with file f (with .pof extension). Used for JUNGFRAU, MOENCH only. Only put! `Returns` ``("successful", "unsuccessful")

- resetfpga [f] resets FPGA, where f can be any value. Used for JUNGFRAU only. Only put! `Returns` ``("successful", "unsuccessful")

## Chip

commands to configure chip of the detector

- powerchip [i] Powers on/off the chip. 1 powers on, 0 powers off. Can also get the power status. Used for JUNGFRAU only. `Returns` ``(int)

- led [i] sets/gets the led status. 1 on, 0 off. Used for MOENCH only ?? `Returns` ``(int)

- pulse [n] [x] [y] pulses pixel at coordinates (x,y) n number of times. Used in EIGER only. Only put! `Returns` ``("successful", "unsuccessful")

- pulsenmove [n] [x] [y] pulses pixel n number of times and moves relatively by x value (x axis) and y value(y axis). Used in EIGER only. Only put! `Returns` ``("successful", "unsuccessful")

- pulsechip [n]pulses chip n number of times, while n=-1 will reset it to normal mode. Used in EIGER only. Only put! `Returns` ``("successful", "unsuccessful")

## Versions

Commands to check versions of each subsystem

- moduleversion:[i] Gets the firmware version of module i. Used for MYTHEN only. Only get! `Returns` ``(long int) in hexadecimal or "undefined module number"

- detectornumber Gets the serial number or MAC of detector. Only get! `Returns` ``(long int) in hexadecimal

- modulenumber:[i] Gets the serial number of module i. Used for MYTHEN only. Only get! `Returns` ``(long int) in hexadecimal or "undefined module number"

- detectorversion Gets the firmware version of detector. Only get! `Returns` ``(long int) in hexadecimal

- softwareversion Gets the software version of detector server. Only get! `Returns` ``(long int) in hexadecimal

- thisversion Gets the software version of this client software. Only get! `Returns` ``(long int) in hexadecimal

- receiverversion Gets the software version of receiver. Only get! `Returns` ``(long int) in hexadecimal

- framesl gets number of frames left. Used in MYTHEN, GOTTHARD only. Only get! `Returns` ``(double with 9 decimal digits)

## Speed

commands to configure speed of detector

- clkdivider [i] sets/gets the readout clock divider. EIGER, JUNGFRAU [0(fast speed), 1(half speed), 2(quarter speed)]. MYTHEN[???]. `Returns` ``(int)

- setlength [i] sets/gets length of set/reset signals (in clock cycles). Used in MYTHEN only. `Returns` ``(int)

- waitstates [i] sets/gets waitstates of the bus interface (in clock cycles). Used in MYTHEN only. `Returns` ``(int)

- totdivider [i] sets/gets clock divider in tot mode. Used in MYTHEN only. `Returns` ``(int)

- totdutycycle [i] sets/gets duty cycle of the tot clock. Used in MYTHEN only. `Returns` ``(int)

- phasestep [i] Only put for gotthard. Moves the phase of the ADC clock.`Returns` ``(int)

- oversampling [i] Sets/gets the number of adcsamples per clock. For the new chiptestboard.`Returns` ``(int)

- adcclk [i] sets/gets the ADC clock frequency in MHz. For the new chiptestboard!`Returns` ``(int)

- adcphase [i] Sets/gets the ADC clock frequency in MHz. For the new chiptestboard!`Returns` ``(int)

- adcpipeline [i] Sets/gets the pipeline of the ADC. For the new chiptestbaord!`Returns` ``(int)

- dbitclk [i] Sets/gets the clock frequency of the latching of the digital bits in MHz. For the new chiptestboard!`Returns` ``(int)

- dbitphase [i] Sets/gets the phase of the clock for latching of the digital bits. For the new chiptestboard!?`Returns` ``(int)

- dbitpipeline [i] Sets/gets the pipeline of the latching of the digital bits. For the new chiptestbaord!`Returns` ``(int)

## Detector Parameters

commands to configure/retrieve configuration of detector

- config [fname] sets/saves detector/receiver to configuration contained in fname. Same as executing sls_detector_put for every line. Normally a one time operation. `Returns` ``(string) fname

- rx_printconfig prints the receiver configuration. Only get! `Returns` ``(string)

- parameters [fname] sets/saves detector parameters contained in fname. Normally once per different measurement. `Returns` ``(string) fname

- setup [fname] sets/saves detector complete setup contained in fname (extensions automatically generated), including trimfiles, ff coefficients etc. `Returns` ``(string) fname