Merge pull request #73 from slsdetectorgroup/mythen3

mythen3: virtual server, connected timing mode, row and col in header…
This commit is contained in:
Dhanya Thattil 2020-01-23 12:35:43 +01:00 committed by GitHub
commit 688e4e84d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 479 additions and 400 deletions

View File

@ -10,7 +10,7 @@ pycmd = dir(Detector)+dir(Eiger)+dir(Ctb)
pycmd += ['vrf', 'vtr', 'vrs', 'vtgstv', 'vsvn', 'vtrim',
'vsvp', 'vth1', 'vth2', 'vth3', 'vshaper', 'vshaperneg', 'rxb_rb',
'rxb_lb', 'vref_prech', 'vref_restore', 'vref_cds',
'rxb_lb', 'vref_prech', 'vref_rstore', 'vref_cds',
'vpreamp', 'vref_comp', 'vref_comp_fe vref_ds', 'vref_h_adc',
'vref_l_adc', 'iodelay', 'list', 'vref_ds', 'vis', 'vpl',
'vref_comp_fe', 'vph', 'vout_cm', 'vcp', 'vcn', 'vcmp_ll', 'vcmp_lr'

View File

@ -9,19 +9,7 @@ enums.cpp
import re
import subprocess
# def remove_comments(text):
# def replacer(match):
# s = match.group(0)
# if s.startswith('/'):
# return " " # note: a space and not an empty string
# else:
# return s
# pattern = re.compile(
# r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"',
# re.DOTALL | re.MULTILINE
# )
# return re.sub(pattern, replacer, text)
from parse import remove_comments
def extract_enums(lines):
line_iter = iter(lines)

View File

@ -74,9 +74,12 @@ void init_det(py::module &m) {
py::arg() = Positions{})
.def("getNumberOfTriggersLeft", &Detector::getNumberOfTriggersLeft,
py::arg() = Positions{})
.def("getPeriodLeft", &Detector::getPeriodLeft, py::arg() = Positions{})
.def("getDelayAfterTriggerLeft", &Detector::getDelayAfterTriggerLeft,
py::arg() = Positions{})
.def("getPeriodLeft", &Detector::getPeriodLeft, py::arg() = Positions{})
.def("getTimingMode", &Detector::getTimingMode, py::arg() = Positions{})
.def("setTimingMode", &Detector::setTimingMode, py::arg(),
py::arg() = Positions{})
.def("getSpeed", &Detector::getSpeed, py::arg() = Positions{})
.def("setSpeed", &Detector::setSpeed, py::arg(),
py::arg() = Positions{})
@ -109,6 +112,9 @@ void init_det(py::module &m) {
py::arg(), py::arg() = Positions{})
.def("getHighVoltage", &Detector::getHighVoltage,
py::arg() = Positions{})
.def("getPowerChip", &Detector::getPowerChip, py::arg() = Positions{})
.def("setPowerChip", &Detector::setPowerChip, py::arg(),
py::arg() = Positions{})
.def("setHighVoltage", &Detector::setHighVoltage, py::arg(),
py::arg() = Positions{})
.def("getTemperature", &Detector::getTemperature, py::arg(),
@ -121,9 +127,6 @@ void init_det(py::module &m) {
py::arg() = Positions{})
.def("setOnChipDAC", &Detector::setOnChipDAC, py::arg(), py::arg(),
py::arg(), py::arg() = Positions{})
.def("getTimingMode", &Detector::getTimingMode, py::arg() = Positions{})
.def("setTimingMode", &Detector::setTimingMode, py::arg(),
py::arg() = Positions{})
.def("acquire", &Detector::acquire)
.def("clearAcquiringFlag", &Detector::clearAcquiringFlag)
.def("startReceiver", &Detector::startReceiver)
@ -395,9 +398,6 @@ void init_det(py::module &m) {
py::arg() = Positions{})
.def("resetTemperatureEvent", &Detector::resetTemperatureEvent,
py::arg() = Positions{})
.def("getPowerChip", &Detector::getPowerChip, py::arg() = Positions{})
.def("setPowerChip", &Detector::setPowerChip, py::arg(),
py::arg() = Positions{})
.def("getAutoCompDisable", &Detector::getAutoCompDisable,
py::arg() = Positions{})
.def("setAutoCompDisable", &Detector::setAutoCompDisable, py::arg(),
@ -438,9 +438,9 @@ void init_det(py::module &m) {
py::arg(), py::arg(), py::arg() = Positions{})
.def("setVetoReference", &Detector::setVetoReference, py::arg(),
py::arg(), py::arg() = Positions{})
.def("getBurstMode", &Detector::getBurstMode, py::arg() = Positions{})
.def("setBurstMode", &Detector::setBurstMode, py::arg(),
py::arg() = Positions{})
.def("getBurstMode", &Detector::getBurstMode, py::arg() = Positions{})
.def("getCounterMask", &Detector::getCounterMask,
py::arg() = Positions{})
.def("setCounterMask", &Detector::setCounterMask, py::arg(),

View File

@ -169,7 +169,7 @@ void init_enums(py::module &m) {
.value("VB_COMP_FE", slsDetectorDefs::dacIndex::VB_COMP_FE)
.value("VB_COMP_ADC", slsDetectorDefs::dacIndex::VB_COMP_ADC)
.value("VCOM_CDS", slsDetectorDefs::dacIndex::VCOM_CDS)
.value("VREF_RESTORE", slsDetectorDefs::dacIndex::VREF_RESTORE)
.value("VREF_RSTORE", slsDetectorDefs::dacIndex::VREF_RSTORE)
.value("VB_OPA_1ST", slsDetectorDefs::dacIndex::VB_OPA_1ST)
.value("VREF_COMP_FE", slsDetectorDefs::dacIndex::VREF_COMP_FE)
.value("VCOM_ADC1", slsDetectorDefs::dacIndex::VCOM_ADC1)
@ -278,4 +278,10 @@ void init_enums(py::module &m) {
slsDetectorDefs::detectorModeType::INTERPOLATING)
.value("ANALOG", slsDetectorDefs::detectorModeType::ANALOG)
.export_values();
py::enum_<slsDetectorDefs::burstMode>(Defs, "burstMode")
.value("BURST_OFF", slsDetectorDefs::burstMode::BURST_OFF)
.value("BURST_INTERNAL", slsDetectorDefs::burstMode::BURST_INTERNAL)
.value("BURST_EXTERNAL", slsDetectorDefs::burstMode::BURST_EXTERNAL)
.export_values();
}

View File

@ -1418,22 +1418,18 @@ int setHighVoltage(int val){
void setTiming( enum timingMode arg){
if(arg != GET_TIMING_MODE){
switch(arg){
case AUTO_TIMING:
FILE_LOG(logINFO, ("Set Timing: Auto\n"));
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) & ~EXT_SIGNAL_MSK);
break;
case TRIGGER_EXPOSURE:
FILE_LOG(logINFO, ("Set Timing: Trigger\n"));
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) | EXT_SIGNAL_MSK);
break;
default:
FILE_LOG(logERROR, ("Unknown timing mode %d\n", arg));
return;
}
}
switch(arg){
case AUTO_TIMING:
FILE_LOG(logINFO, ("Set Timing: Auto\n"));
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) & ~EXT_SIGNAL_MSK);
break;
case TRIGGER_EXPOSURE:
FILE_LOG(logINFO, ("Set Timing: Trigger\n"));
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) | EXT_SIGNAL_MSK);
break;
default:
FILE_LOG(logERROR, ("Unknown timing mode %d\n", arg));
}
}

View File

@ -1106,36 +1106,46 @@ int setHighVoltage(int val) {
/* parameters - timing, extsig */
void setTiming( enum timingMode arg) {
enum timingMode ret=GET_TIMING_MODE;
if (arg != GET_TIMING_MODE) {
switch(arg) {
case AUTO_TIMING: ret = 0; break;
case TRIGGER_EXPOSURE: ret = 2; break;
case BURST_TRIGGER: ret = 1; break;
case GATED: ret = 3; break;
}
FILE_LOG(logDEBUG1, ("Setting Triggering Mode: %d\n", (int)ret));
#ifndef VIRTUAL
if (Feb_Control_SetTriggerMode(ret,1))
#endif
eiger_triggermode = ret;
int ret = 0;
switch(arg) {
case AUTO_TIMING:
ret = 0;
break;
case TRIGGER_EXPOSURE:
ret = 2;
break;
case BURST_TRIGGER:
ret = 1;
break;
case GATED:
ret = 3;
break;
default:
FILE_LOG(logERROR, ("Unknown timing mode %d\n", arg));
return;
}
FILE_LOG(logDEBUG1, ("Setting Triggering Mode: %d\n", (int)ret));
#ifndef VIRTUAL
if (Feb_Control_SetTriggerMode(ret,1))
#endif
eiger_triggermode = ret;
}
enum timingMode getTiming() {
enum timingMode ret = GET_TIMING_MODE;
ret = eiger_triggermode;
switch((int)ret) {
case 0: ret = AUTO_TIMING; break;
case 2: ret = TRIGGER_EXPOSURE; break;
case 1: ret = BURST_TRIGGER; break;
case 3: ret = GATED; break;
switch(eiger_triggermode) {
case 0:
return AUTO_TIMING;
case 2:
return TRIGGER_EXPOSURE;
case 1:
return BURST_TRIGGER;
case 3:
return GATED;
default:
FILE_LOG(logERROR, ("Unknown trigger mode found %d\n", ret));
ret = 0;
FILE_LOG(logERROR, ("Unknown trigger mode found %d\n", eiger_triggermode));
return GET_TIMING_MODE;
}
return ret;
}

View File

@ -11,7 +11,7 @@ vref_h_adc 2099
vb_comp_fe 0
vb_comp_adc 0
vcom_cds 1400
vref_restore 640
vref_rstore 640
vb_opa_1st 0
vref_comp_fe 0
vcom_adc1 1400

View File

@ -46,8 +46,7 @@ int injectedChannelsOffset = 0;
int injectedChannelsIncrement = 0;
int vetoReference[NCHIP][NCHAN];
uint8_t adcConfiguration[NCHIP][NADC];
int burstMode = 0;
enum burstModeType burstType = INTERNAL;
int burstMode = BURST_INTERNAL;
int64_t exptime_ns = 0;
int64_t period_ns = 0;
int64_t nframes = 0;
@ -349,8 +348,7 @@ void setupDetector() {
highvoltage = 0;
injectedChannelsOffset = 0;
injectedChannelsIncrement = 0;
burstMode = 0;
burstType = INTERNAL;
burstMode = BURST_INTERNAL;
exptime_ns = 0;
period_ns = 0;
nframes = 0;
@ -431,8 +429,6 @@ void setupDetector() {
return;
}
#endif
// set burst mode will take in burstType and also set it
burstType = DEFAULT_BURST_TYPE;
setBurstMode(DEFAULT_BURST_MODE);
setSettings(DEFAULT_SETTINGS);
@ -626,8 +622,8 @@ int readConfigFile() {
idac = G2_VB_COMP_ADC;
} else if (!strcasecmp(command,"vcom_cds")) {
idac = G2_VCOM_CDS;
} else if (!strcasecmp(command,"vref_restore")) {
idac = G2_VREF_RESTORE;
} else if (!strcasecmp(command,"vref_rstore")) {
idac = G2_VREF_RSTORE;
} else if (!strcasecmp(command,"vb_opa_1st")) {
idac = G2_VB_OPA_1ST;
} else if (!strcasecmp(command,"vref_comp_fe")) {
@ -1091,21 +1087,18 @@ int setHighVoltage(int val){
/* parameters - timing */
void setTiming( enum timingMode arg){
if(arg != GET_TIMING_MODE){
switch(arg){
case AUTO_TIMING:
FILE_LOG(logINFO, ("Set Timing: Auto\n"));
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) & ~EXT_SIGNAL_MSK);
break;
case TRIGGER_EXPOSURE:
FILE_LOG(logINFO, ("Set Timing: Trigger\n"));
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) | EXT_SIGNAL_MSK);
break;
default:
FILE_LOG(logERROR, ("Unknown timing mode %d\n", arg));
return;
}
}
switch(arg){
case AUTO_TIMING:
FILE_LOG(logINFO, ("Set Timing: Auto\n"));
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) & ~EXT_SIGNAL_MSK);
break;
case TRIGGER_EXPOSURE:
FILE_LOG(logINFO, ("Set Timing: Trigger\n"));
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) | EXT_SIGNAL_MSK);
break;
default:
FILE_LOG(logERROR, ("Unknown timing mode %d\n", arg));
}
}
enum timingMode getTiming() {
@ -1670,10 +1663,10 @@ int configureSingleADCDriver(int chipIndex) {
{
int i = 0;
for (i = 0; i < NADC; ++i) {
if (!burstMode) {
if (burstMode == BURST_OFF) {
values[i] |= ASIC_CONTINUOUS_MODE_MSK;
}
FILE_LOG(logDEBUG1, ("Value %d: 0x%02hhx\n", i, values[i]));
FILE_LOG(logDEBUG2, ("Value %d: 0x%02hhx\n", i, values[i]));
}
}
@ -1749,14 +1742,39 @@ int configureADC() {
return OK;
}
int setBurstModeinFPGA(enum burstMode value) {
uint32_t addr = ASIC_CONFIG_REG;
uint32_t runmode = 0;
switch (value) {
case BURST_OFF:
runmode = ASIC_CONFIG_RUN_MODE_CONT_VAL;
break;
case BURST_INTERNAL:
runmode = ASIC_CONFIG_RUN_MODE_INT_BURST_VAL;
break;
case BURST_EXTERNAL:
runmode = ASIC_CONFIG_RUN_MODE_EXT_BURST_VAL;
break;
default:
FILE_LOG(logERROR, ("Unknown burst mode %d\n", value));
return FAIL;
}
FILE_LOG(logDEBUG1, ("Run mode (FPGA val): %d\n", runmode));
bus_w(addr, bus_r(addr) &~ ASIC_CONFIG_RUN_MODE_MSK);
bus_w(addr, bus_r(addr) | ((runmode << ASIC_CONFIG_RUN_MODE_OFST) & ASIC_CONFIG_RUN_MODE_MSK));
burstMode = value;
return OK;
}
int setBurstMode(int burst) {
FILE_LOG(logINFO, ("Setting %s Mode\n", burst == 1 ? "Burst" : "Continuous"));
burstMode = burst;
setBurstType(burstType);
int setBurstMode(enum burstMode burst) {
FILE_LOG(logINFO, ("Setting burst mode to %s\n", burst == BURST_OFF ? "off" : (burst == BURST_INTERNAL ? "internal" : "external")));
FILE_LOG(logINFO, ("\tSetting %s Mode in Chip\n", burst == 1 ? "Burst" : "Continuous"));
int value = burst ? ASIC_GLOBAL_BURST_VALUE : ASIC_GLOBAL_CONT_VALUE;
if (setBurstModeinFPGA(burst) == FAIL) {
return FAIL;
}
FILE_LOG(logINFO, ("\tSetting %s Mode in Chip\n", burstMode == BURST_OFF ? "Continuous" : "Burst"));
int value = burstMode ? ASIC_GLOBAL_BURST_VALUE : ASIC_GLOBAL_CONT_VALUE;
const int padding = 6; // due to address (4) to make it byte aligned
const int lenTotalBits = padding + ASIC_GLOBAL_SETT_MAX_BITS + ASIC_ADDR_MAX_BITS; // 4 + 6 + 4 = 16
@ -1797,58 +1815,28 @@ int setBurstMode(int burst) {
return configureADC();
}
int getBurstMode() {
enum burstMode getBurstMode() {
uint32_t addr = ASIC_CONFIG_REG;
int runmode = bus_r (addr) & ASIC_CONFIG_RUN_MODE_MSK;
switch (runmode) {
case ASIC_CONFIG_RUN_MODE_CONT_VAL:
return BURST_OFF;
case ASIC_CONFIG_RUN_MODE_INT_BURST_VAL:
return BURST_INTERNAL;
case ASIC_CONFIG_RUN_MODE_EXT_BURST_VAL:
return 1;
return BURST_EXTERNAL;
default:
return 0;
}
}
void setBurstType(enum burstModeType val) {
uint32_t addr = ASIC_CONFIG_REG;
uint32_t runmode = ASIC_CONFIG_RUN_MODE_CONT_VAL;
if (burstMode) {
switch (val) {
case INTERNAL:
runmode = ASIC_CONFIG_RUN_MODE_INT_BURST_VAL;
break;
case EXTERNAL:
runmode = ASIC_CONFIG_RUN_MODE_EXT_BURST_VAL;
break;
default:
FILE_LOG(logERROR, ("Unknown burst type %d\n", val));
return;
}
FILE_LOG(logDEBUG1, ("Run mode: %d\n", runmode));
bus_w(addr, bus_r(addr) &~ ASIC_CONFIG_RUN_MODE_MSK);
bus_w(addr, bus_r(addr) | ((runmode << ASIC_CONFIG_RUN_MODE_OFST) & ASIC_CONFIG_RUN_MODE_MSK));
}
}
enum burstModeType getBurstType() {
uint32_t addr = ASIC_CONFIG_REG;
int runmode = bus_r (addr) & ASIC_CONFIG_RUN_MODE_MSK;
switch (runmode) {
case ASIC_CONFIG_RUN_MODE_INT_BURST_VAL:
return INTERNAL;
case ASIC_CONFIG_RUN_MODE_EXT_BURST_VAL:
return EXTERNAL;
default:
FILE_LOG(logERROR, ("Unknown burst type read from FPGA: %d\n", runmode));
FILE_LOG(logERROR, ("Unknown run mode read from FPGA %d\n", runmode));
return -1;
}
}
/* aquisition */
int updateAcquisitionRegisters(char* mess) {
// burst mode
if (burstMode) {
if (burstMode != BURST_OFF) {
// validate #frames in burst mode
if (nframes > MAX_FRAMES_IN_BURST_MODE) {
sprintf(mess, "Could not start acquisition because number of frames %lld must be <= %d in burst mode.\n", (long long unsigned int)nframes, MAX_FRAMES_IN_BURST_MODE);
@ -1945,9 +1933,19 @@ void* start_timer(void* arg) {
int numFrames = (getNumFrames() *
getNumTriggers() );
int64_t exp_ns = getExpTime();
int datasize = 2560;
int imagesize = NCHAN * NCHIP * 2;
int datasize = imagesize;
int packetsize = datasize + sizeof(sls_detector_header);
// Generate data
char imageData[imagesize];
memset(imageData, 0, imagesize);
{
int i = 0;
for (i = 0; i < imagesize; i += sizeof(uint8_t)) {
*((uint8_t*)(imageData + i)) = i;
}
}
int frameNr = 0;
// loop over number of frames
@ -1974,7 +1972,10 @@ void* start_timer(void* arg) {
header->row = detPos[X];
header->column = detPos[Y];
header->detType = (uint16_t)myDetectorType;
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
// fill data
memcpy(packetData + sizeof(sls_detector_header), imageData, datasize);
// send 1 packet = 1 frame
sendUDPPacket(0, packetData, packetsize);

View File

@ -29,8 +29,7 @@
#define TYPE_NO_MODULE_STARTING_VAL (800)
/** Default Parameters */
#define DEFAULT_BURST_MODE (1)
#define DEFAULT_BURST_TYPE (INTERNAL)
#define DEFAULT_BURST_MODE (BURST_INTERNAL)
#define DEFAULT_NUM_FRAMES (1)
#define DEFAULT_NUM_CYCLES (1)
#define DEFAULT_EXPTIME (1 * 1000 * 1000) // 1 ms
@ -61,7 +60,7 @@ enum DACINDEX {G2_VREF_H_ADC, /* 0 */ \
G2_VB_COMP_FE, /* 2 */ \
G2_VB_COMP_ADC, /* 3 */ \
G2_VCOM_CDS, /* 4 */ \
G2_VREF_RESTORE,/* 5 */ \
G2_VREF_RSTORE,/* 5 */ \
G2_VB_OPA_1ST, /* 6 */ \
G2_VREF_COMP_FE,/* 7 */ \
G2_VCOM_ADC1, /* 8 */ \
@ -73,7 +72,7 @@ enum DACINDEX {G2_VREF_H_ADC, /* 0 */ \
G2_DAC_UNUSED2, /* 14 */ \
G2_VCOM_ADC2 /* 15*/ \
};
#define DAC_NAMES "vref_h_adc", "dac_unused", "vb_comp_fe", "vb_comp_adc", "vcom_cds", "vref_restore", "vb_opa_1st", "vref_comp_fe", "vcom_adc1", "vref_prech", "vref_l_adc", "vref_cds", "vb_cs", "vb_opa_fd", "dac_unused2", "vcom_adc2"
#define DAC_NAMES "vref_h_adc", "dac_unused", "vb_comp_fe", "vb_comp_adc", "vcom_cds", "vref_rstore", "vb_opa_1st", "vref_comp_fe", "vcom_adc1", "vref_prech", "vref_l_adc", "vref_cds", "vb_cs", "vb_opa_fd", "dac_unused2", "vcom_adc2"
enum ONCHIP_DACINDEX {G2_VCHIP_COMP_FE, /* 0 */ \
G2_VCHIP_OPA_1ST, /* 1 */ \

View File

@ -1178,27 +1178,23 @@ int setHighVoltage(int val){
void setTiming( enum timingMode arg){
u_int32_t addr = EXT_SIGNAL_REG;
if (arg != GET_TIMING_MODE){
switch(arg){
case AUTO_TIMING:
FILE_LOG(logINFO, ("Set Timing: Auto\n"));
bus_w(addr, EXT_SIGNAL_OFF_VAL);
break;
case TRIGGER_EXPOSURE:
if (signalMode == TRIGGER_IN_FALLING_EDGE) {
FILE_LOG(logINFO, ("Set Timing: Trigger (Falling Edge)\n"));
bus_w(addr, EXT_SIGNAL_TRGGR_IN_FLLNG_VAL);
} else {
FILE_LOG(logINFO, ("Set Timing: Trigger (Rising Edge)\n"));
bus_w(addr, EXT_SIGNAL_TRGGR_IN_RSNG_VAL);
}
break;
default:
FILE_LOG(logERROR, ("Unknown timing mode %d for this detector\n", (int)arg));
return;
}
}
switch(arg) {
case AUTO_TIMING:
FILE_LOG(logINFO, ("Set Timing: Auto\n"));
bus_w(addr, EXT_SIGNAL_OFF_VAL);
break;
case TRIGGER_EXPOSURE:
if (signalMode == TRIGGER_IN_FALLING_EDGE) {
FILE_LOG(logINFO, ("Set Timing: Trigger (Falling Edge)\n"));
bus_w(addr, EXT_SIGNAL_TRGGR_IN_FLLNG_VAL);
} else {
FILE_LOG(logINFO, ("Set Timing: Trigger (Rising Edge)\n"));
bus_w(addr, EXT_SIGNAL_TRGGR_IN_RSNG_VAL);
}
break;
default:
FILE_LOG(logERROR, ("Unknown timing mode %d for this detector\n", (int)arg));
}
}
enum timingMode getTiming() {

View File

@ -919,22 +919,18 @@ int setHighVoltage(int val){
void setTiming( enum timingMode arg){
if(arg != GET_TIMING_MODE){
switch(arg){
case AUTO_TIMING:
FILE_LOG(logINFO, ("Set Timing: Auto\n"));
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) & ~EXT_SIGNAL_MSK);
break;
case TRIGGER_EXPOSURE:
FILE_LOG(logINFO, ("Set Timing: Trigger\n"));
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) | EXT_SIGNAL_MSK);
break;
default:
FILE_LOG(logERROR, ("Unknown timing mode %d\n", arg));
return;
}
}
switch(arg){
case AUTO_TIMING:
FILE_LOG(logINFO, ("Set Timing: Auto\n"));
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) & ~EXT_SIGNAL_MSK);
break;
case TRIGGER_EXPOSURE:
FILE_LOG(logINFO, ("Set Timing: Trigger\n"));
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) | EXT_SIGNAL_MSK);
break;
default:
FILE_LOG(logERROR, ("Unknown timing mode %d\n", arg));
}
}

View File

@ -29,6 +29,10 @@
/* Formatting of data core */
#define BASE_FMT (0x0120) // 0x1806_0120 - 0x1806_012F
/* Packetizer */
#define BASE_PKT (0x0140) // 0x1806_0140 - 0x1806_014F
// https://git.psi.ch/sls_detectors_firmware/mythen_III_mcb/blob/master/code/hdl/pkt/pkt_ctrl.vhd
/* Pattern control and status registers */
#define BASE_PATTERN_CONTROL (0x00200) // 0x1806_0200 - 0x1806_02FF
// https://git.psi.ch/sls_detectors_firmware/vhdl_library/blob/2e81ccbdbc5cb81813ba190fbdba43e8d6884eb9/pattern_flow/pattern_flow_ctrl.vhd
@ -128,6 +132,30 @@
/* Packetizer -------------------------------------------------------------*/
/* Packetizer Config Register */
#define PKT_CONFIG_REG (0x00 * REG_OFFSET + BASE_PKT)
#define PKT_CONFIG_NRXR_MAX_OFST (0)
#define PKT_CONFIG_NRXR_MAX_MSK (0x0000003F << PKT_CONFIG_NRXR_MAX_OFST)
#define PKT_CONFIG_RXR_START_ID_OFST (8)
#define PKT_CONFIG_RXR_START_ID_MSK (0x0000003F << PKT_CONFIG_RXR_START_ID_OFST)
/* Module Coordinates Register */
#define COORD_0_REG (0x02 * REG_OFFSET + BASE_PKT)
#define COORD_ROW_OFST (0)
#define COORD_ROW_MSK (0x0000FFFF << COORD_ROW_OFST)
#define COORD_COL_OFST (16)
#define COORD_COL_MSK (0x0000FFFF << COORD_COL_OFST)
/* Module ID Register */
#define COORD_1_REG (0x03 * REG_OFFSET + BASE_PKT)
#define COORD_RESERVED_OFST (0)
#define COORD_RESERVED_MSK (0x0000FFFF << COORD_RESERVED_OFST)
#define COORD_ID_OFST (16) // Not connected in firmware TODO
#define COORD_ID_MSK (0x0000FFFF << COORD_ID_OFST) // Not connected in firmware TODO
/* Pattern Control registers --------------------------------------------------*/

View File

@ -21,6 +21,7 @@
// Global variable from slsDetectorServer_funcs
extern int debugflag;
extern udpStruct udpDetails;
extern const enum detectorType myDetectorType;
int initError = OK;
int initCheckDone = 0;
@ -846,6 +847,43 @@ void calcChecksum(udp_header* udp) {
udp->ip_checksum = checksum;
}
int setDetectorPosition(int pos[]) {
memcpy(detPos, pos, sizeof(detPos));
uint32_t addr = COORD_0_REG;
int value = 0;
int valueRead = 0;
int ret = OK;
// row
value = detPos[X];
bus_w(addr, (bus_r(addr) &~COORD_ROW_MSK) | ((value << COORD_ROW_OFST) & COORD_ROW_MSK));
valueRead = ((bus_r(addr) & COORD_ROW_MSK) >> COORD_ROW_OFST);
if (valueRead != value) {
FILE_LOG(logERROR, ("Could not set row. Set %d, read %d\n", value, valueRead));
ret = FAIL;
}
// col
value = detPos[Y];
bus_w(addr, (bus_r(addr) &~COORD_COL_MSK) | ((value << COORD_COL_OFST) & COORD_COL_MSK));
valueRead = ((bus_r(addr) & COORD_COL_MSK) >> COORD_COL_OFST);
if (valueRead != value) {
FILE_LOG(logERROR, ("Could not set column. Set %d, read %d\n", value, valueRead));
ret = FAIL;
}
if (ret == OK) {
FILE_LOG(logINFO, ("\tPosition set to [%d, %d]\n", detPos[X], detPos[Y]));
}
return ret;
}
int* getDetectorPosition() {
return detPos;
}
/* pattern */
uint64_t readPatternWord(int addr) {
@ -1063,6 +1101,22 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
}
}
void setPatternMask(uint64_t mask) {
set64BitReg(mask, PATTERN_MASK_LSB_REG, PATTERN_MASK_MSB_REG);
}
uint64_t getPatternMask() {
return get64BitReg(PATTERN_MASK_LSB_REG, PATTERN_MASK_MSB_REG);
}
void setPatternBitMask(uint64_t mask) {
set64BitReg(mask, PATTERN_SET_LSB_REG, PATTERN_SET_MSB_REG);
}
uint64_t getPatternBitMask() {
return get64BitReg(PATTERN_SET_LSB_REG, PATTERN_SET_MSB_REG);
}
int checkDetectorType() {
FILE_LOG(logINFO, ("Checking type of module\n"));
FILE* fd = fopen(TYPE_FILE_NAME, "r");
@ -1291,15 +1345,6 @@ int getClockDivider(enum CLKINDEX ind) {
/* aquisition */
int setDetectorPosition(int pos[]) {
memcpy(detPos, pos, sizeof(detPos));
return OK;
}
int* getDetectorPosition() {
return detPos;
}
int startStateMachine(){
#ifdef VIRTUAL
// create udp socket
@ -1338,22 +1383,64 @@ void* start_timer(void* arg) {
getNumTriggers() );
int64_t exp_ns = getExpTime();
int imagesize = calculateDataBytes();
int datasize = imagesize / PACKETS_PER_FRAME;
int packetsize = datasize + sizeof(sls_detector_header);
int frameNr = 0;
// Generate data
char imageData[imagesize];
memset(imageData, 0, imagesize);
{
int i = 0;
for (i = 0; i < imagesize; i += sizeof(uint8_t)) {
*((uint8_t*)(imageData + i)) = i;
}
}
int frameNr = 1;
// loop over number of frames
for(frameNr=0; frameNr!= numFrames; ++frameNr ) {
for (frameNr = 0; frameNr != numFrames; ++frameNr) {
//check if virtual_stop is high
if(virtual_stop == 1){
break;
}
int srcOffset = 0;
// sleep for exposure time
struct timespec begin, end;
clock_gettime(CLOCK_REALTIME, &begin);
usleep(exp_ns / 1000);
clock_gettime(CLOCK_REALTIME, &end);
// loop packet
{
int i = 0;
for(i = 0; i!=PACKETS_PER_FRAME; ++i) {
char packetData[packetsize];
memset(packetData, 0, packetsize);
// set header
sls_detector_header* header = (sls_detector_header*)(packetData);
header->frameNumber = frameNr + 1;
header->packetNumber = i;
header->modId = 0;
header->row = detPos[X];
header->column = detPos[Y];
header->detType = (uint16_t)myDetectorType;
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
// fill data
memcpy(packetData + sizeof(sls_detector_header), imageData + srcOffset, datasize);
srcOffset += datasize;
sendUDPPacket(0, packetData, packetsize);
}
}
FILE_LOG(logINFO, ("Sent frame: %d\n", frameNr));
// calculate time left in period
clock_gettime(CLOCK_REALTIME, &end);
int64_t time_ns = ((end.tv_sec - begin.tv_sec) * 1E9 +
(end.tv_nsec - begin.tv_nsec));
@ -1468,14 +1555,22 @@ u_int32_t runBusy() {
return virtual_status;
#endif
u_int32_t s = (bus_r(PAT_STATUS_REG) & PAT_STATUS_RUN_BUSY_MSK);
FILE_LOG(logDEBUG1, ("Status Register: %08x\n", s));
//FILE_LOG(logDEBUG1, ("Status Register: %08x\n", s));
return s;
}
/* common */
int calculateDataBytes() {
return 0;
int numCounters = __builtin_popcount(getCounterMask());
int dr = setDynamicRange(-1);
int databytes = NCHAN_1_COUNTER * NCHIP * numCounters *
((dr > 16) ? 4 : // 32 bit
((dr > 8) ? 2 : // 16 bit
((dr > 4) ? 0.5 : // 4 bit
0.125))); // 1 bit
return databytes;
}
int getTotalNumberOfChannels() {return (getNumberOfChannelsPerChip() * getNumberOfChips());}

View File

@ -8,6 +8,7 @@
/* Hardware Definitions */
#define NCOUNTERS (3)
#define MAX_COUNTER_MSK (0x7)
#define NCHAN_1_COUNTER (128)
#define NCHAN (128 * NCOUNTERS)
#define NCHIP (10)
#define NDAC (16)
@ -95,4 +96,5 @@ typedef struct udp_header_struct {
uint16_t udp_checksum;
uint16_t udp_destport;
} udp_header;
#define UDP_IP_HEADER_LENGTH_BYTES (28)
#define UDP_IP_HEADER_LENGTH_BYTES (28)
#define PACKETS_PER_FRAME (2)

View File

@ -437,6 +437,10 @@ uint64_t writePatternWord(int addr, uint64_t word);
int setPatternWaitAddress(int level, int addr);
uint64_t setPatternWaitTime(int level, uint64_t t);
void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop);
void setPatternMask(uint64_t mask);
uint64_t getPatternMask();
void setPatternBitMask(uint64_t mask);
uint64_t getPatternBitMask();
int checkDetectorType();
int powerChip (int on);
int setPhase(enum CLKINDEX ind, int val, int degrees);
@ -470,10 +474,9 @@ int setVetoPhoton(int chipIndex, int gainIndex, int* values);
int getVetoPhoton(int chipIndex, int* retvals);
int configureSingleADCDriver(int chipIndex);
int configureADC();
int setBurstMode(int burst);
int getBurstMode();
void setBurstType(enum burstModeType val);
enum burstModeType getBurstType();
int setBurstModeinFPGA(enum burstMode value);
int setBurstMode(enum burstMode burst);
enum burstMode getBurstMode();
#endif

View File

@ -206,5 +206,3 @@ int set_adc_enable_mask_10g(int);
int get_adc_enable_mask_10g(int);
int set_counter_mask(int);
int get_counter_mask(int);
int set_burst_type(int);
int get_burst_type(int);

View File

@ -308,8 +308,6 @@ const char* getFunctionName(enum detFuncs func) {
case F_GET_ADC_ENABLE_MASK_10G: return "F_GET_ADC_ENABLE_MASK_10G";
case F_SET_COUNTER_MASK: return "F_SET_COUNTER_MASK";
case F_GET_COUNTER_MASK: return "F_GET_COUNTER_MASK";
case F_SET_BURST_TYPE: return "F_SET_BURST_TYPE";
case F_GET_BURST_TYPE: return "F_GET_BURST_TYPE";
default: return "Unknown Function";
}
@ -494,8 +492,6 @@ void function_table() {
flist[F_GET_ADC_ENABLE_MASK_10G] = &get_adc_enable_mask_10g;
flist[F_SET_COUNTER_MASK] = &set_counter_mask;
flist[F_GET_COUNTER_MASK] = &get_counter_mask;
flist[F_SET_BURST_TYPE] = &set_burst_type;
flist[F_GET_BURST_TYPE] = &get_burst_type;
// check
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
@ -1000,8 +996,8 @@ int set_dac(int file_des) {
case VCOM_CDS:
serverDacIndex = G2_VCOM_CDS;
break;
case VREF_RESTORE:
serverDacIndex = G2_VREF_RESTORE;
case VREF_RSTORE:
serverDacIndex = G2_VREF_RSTORE;
break;
case VB_OPA_1ST:
serverDacIndex = G2_VB_OPA_1ST;
@ -3199,7 +3195,7 @@ int set_pattern_mask(int file_des) {
return printSocketReadError();
FILE_LOG(logDEBUG1, ("Set Pattern Mask to %d\n", arg));
#if (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD))
#if !defined(MOENCHD) && !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
functionNotImplemented();
#else
// only set
@ -3220,7 +3216,7 @@ int get_pattern_mask(int file_des) {
FILE_LOG(logDEBUG1, ("Get Pattern Mask\n"));
#if (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD))
#if !defined(MOENCHD) && !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
functionNotImplemented();
#else
// only get
@ -3240,7 +3236,7 @@ int set_pattern_bit_mask(int file_des) {
return printSocketReadError();
FILE_LOG(logDEBUG1, ("Set Pattern Bit Mask to %d\n", arg));
#if (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD))
#if !defined(MOENCHD) && !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
functionNotImplemented();
#else
// only set
@ -3261,7 +3257,7 @@ int get_pattern_bit_mask(int file_des){
FILE_LOG(logDEBUG1, ("Get Pattern Bit Mask\n"));
#if (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD))
#if !defined(MOENCHD) && !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
functionNotImplemented();
#else
// only get
@ -6499,22 +6495,35 @@ int set_veto_reference(int file_des) {
int set_burst_mode(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int arg = -1;
enum burstMode arg = BURST_OFF;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
FILE_LOG(logINFO, ("Setting burst mode: %d\n", arg));
FILE_LOG(logDEBUG1, ("Setting burst mode: %d\n", arg));
#ifndef GOTTHARD2D
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
arg = arg == 0 ? 0 : 1;
ret = setBurstMode(arg);
if (ret == FAIL) {
sprintf(mess, "Could not set burst mode to %d\n", arg);
FILE_LOG(logERROR, (mess));
switch (arg) {
case BURST_OFF:
case BURST_INTERNAL:
case BURST_EXTERNAL:
break;
default:
modeNotImplemented("Burst mode", (int)arg);
break;
}
if (ret == OK) {
setBurstMode(arg);
enum burstMode retval = getBurstMode();
FILE_LOG(logDEBUG, ("burst mode retval: %d\n", retval));
if (retval != arg) {
ret = FAIL;
sprintf(mess, "Could not set burst type. Set %d, got %d\n", arg, retval);
FILE_LOG(logERROR, (mess));
}
}
}
#endif
@ -6525,7 +6534,7 @@ int set_burst_mode(int file_des) {
int get_burst_mode(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retval = -1;
enum burstMode retval = BURST_OFF;
FILE_LOG(logDEBUG1, ("Getting burst mode\n"));
@ -6534,7 +6543,7 @@ int get_burst_mode(int file_des) {
#else
// get only
retval = getBurstMode();
FILE_LOG(logDEBUG1, ("Get burst mode:%d\n", retval));
FILE_LOG(logDEBUG1, ("Get burst mode retval:%d\n", retval));
#endif
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
}
@ -6594,60 +6603,3 @@ int get_counter_mask(int file_des) {
#endif
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
}
int set_burst_type(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
enum burstModeType arg = 0;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
FILE_LOG(logINFO, ("Setting burst type: %d\n", arg));
#ifndef GOTTHARD2D
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
switch (arg) {
case INTERNAL:
case EXTERNAL:
break;
default:
modeNotImplemented("Burst type", (int)arg);
break;
}
if (ret == OK) {
setBurstType(arg);
enum burstModeType retval = getBurstType();
FILE_LOG(logDEBUG, ("burst type retval: %d\n", retval));
if (retval != arg) {
ret = FAIL;
sprintf(mess, "Could not set burst type. Set %s, got %s\n", (arg == 0 ? "internal" : "external"), (retval == 0 ? "internal" : "external"));
FILE_LOG(logERROR, (mess));
}
}
}
#endif
return Server_SendResult(file_des, INT32, UPDATE, NULL, 0);
}
int get_burst_type(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
enum burstModeType retval = 0;
FILE_LOG(logDEBUG1, ("Getting burst type\n"));
#ifndef GOTTHARD2D
functionNotImplemented();
#else
// get only
retval = getBurstType();
FILE_LOG(logDEBUG, ("burst type retval: %d\n", retval));
#endif
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
}

View File

@ -916,16 +916,10 @@ class Detector {
void setVetoReference(const int gainIndex, const int value, Positions pos = {});
/** [Gotthard2] */
Result<bool> getBurstMode(Positions pos = {});
Result<defs::burstMode> getBurstMode(Positions pos = {});
/** [Gotthard2] true = burst mode or false = continuous mode */
void setBurstMode(bool enable, Positions pos = {});
/** [Gotthard2] */
Result<defs::burstModeType> getBurstType(Positions pos = {});
/** [Gotthard2] Options: INTERNAL, EXTERNAL */
void setBurstType(defs::burstModeType val, Positions pos = {});
/** [Gotthard2] BURST_OFF, BURST_INTERNAL (default), BURST_EXTERNAL */
void setBurstMode(defs::burstMode value, Positions pos = {});
/**************************************************
* *
@ -1115,52 +1109,54 @@ class Detector {
/** [CTB] */
void setPatternClockControl(uint64_t word, Positions pos = {});
/** [Mythen3][CTB] same as executing for CTB */
/** [CTB] same as executing
* [Mythen3] */
Result<uint64_t> getPatternWord(int addr, Positions pos = {});
/** [Mythen3][CTB] Caution: If word is -1 reads the addr (same as
* executing the pattern) */
/** [CTB] Caution: If word is -1 reads the addr (same as
* executing the pattern)
* [Mythen3] */
void setPatternWord(int addr, uint64_t word, Positions pos = {});
/** [Mythen3][CTB] Options: level: -1 (complete pattern) and 0-2 levels
/**[CTB][Mythen3] Options: level: -1 (complete pattern) and 0-2 levels
* @returns array of start address and stop address
*/
Result<std::array<int, 2>> getPatternLoopAddresses(int level,
Positions pos = {}) const;
/** [Mythen3][CTB] Options: level: -1 (complete pattern) and 0-2 levels */
/** [CTB][Mythen3] Options: level: -1 (complete pattern) and 0-2 levels */
void setPatternLoopAddresses(int level, int start, int stop, Positions pos = {});
/** [Mythen3][CTB] Options: level: -1 (complete pattern) and 0-2 levels
/**[CTB][Mythen3] Options: level: -1 (complete pattern) and 0-2 levels
* @returns number of loops
*/
Result<int> getPatternLoopCycles(int level, Positions pos = {}) const;
/** [Mythen3][CTB] n: 0-2, level: -1 (complete pattern) and 0-2 levels */
/** [CTB][Mythen3] n: 0-2, level: -1 (complete pattern) and 0-2 levels */
void setPatternLoopCycles(int level, int n, Positions pos = {});
/* [Mythen3][CTB] */
/* [CTB][Mythen3] */
Result<int> getPatternWaitAddr(int level, Positions pos = {}) const;
/** [Mythen3][CTB] Options: level 0-2 */
/** [CTB][Mythen3] Options: level 0-2 */
void setPatternWaitAddr(int level, int addr, Positions pos = {});
/** [Mythen3][CTB] */
/** [CTB][Mythen3] */
Result<uint64_t> getPatternWaitTime(int level, Positions pos = {}) const;
/** [Mythen3][CTB] Options: level 0-2 */
/** [CTB][Mythen3] Options: level 0-2 */
void setPatternWaitTime(int level, uint64_t t, Positions pos = {});
/** [CTB] */
/** [CTB][Mythen3] */
Result<uint64_t> getPatternMask(Positions pos = {});
/** [CTB] Sets the mask applied to every pattern to the selected bit mask */
/** [CTB][Mythen3] Sets the mask applied to every pattern to the selected bit mask */
void setPatternMask(uint64_t mask, Positions pos = {});
/** [CTB] */
/** [CTB][Mythen3] */
Result<uint64_t> getPatternBitMask(Positions pos = {}) const;
/** [CTB] Sets the bitmask that the mask will be applied to for every
/** [CTB][Mythen3] Sets the bitmask that the mask will be applied to for every
* pattern
*/
void setPatternBitMask(uint64_t mask, Positions pos = {});

View File

@ -697,7 +697,7 @@ std::vector<std::string> CmdProxy::DacCommands() {
case defs::GOTTHARD2:
return std::vector<std::string>{
"vref_h_adc", "vb_comp_fe", "vb_comp_adc", "vcom_cds",
"vref_restore", "vb_opa_1st", "vref_comp_fe", "vcom_adc1",
"vref_rstore", "vb_opa_1st", "vref_comp_fe", "vcom_adc1",
"vref_prech", "vref_l_adc", "vref_cds", "vb_cs",
"vb_opa_fd", "vcom_adc2"};
break;
@ -1225,6 +1225,51 @@ std::string CmdProxy::VetoReference(int action) {
return os.str();
}
std::string CmdProxy::BurstMode(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[off or 0, internal or 1, external or 2]\n\t[Gotthard2] Default is burst internal type"
<< '\n';
} else {
if (action == defs::GET_ACTION) {
if (!args.empty()) {
WrongNumberOfParameters(0);
}
auto t = det->getBurstMode({det_id});
os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) {
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
defs::burstMode t;
try {
int ival = std::stoi(args[0]);
switch (ival) {
case 0:
t = defs::BURST_OFF;
break;
case 1:
t = defs::BURST_INTERNAL;
break;
case 2:
t = defs::BURST_EXTERNAL;
break;
default:
throw sls::RuntimeError("Unknown burst mode " + args[0]);
}
} catch (...) {
t = sls::StringTo<defs::burstMode>(args[0]);
}
det->setBurstMode(t, {det_id});
os << sls::ToString(t) << '\n'; // no args to convert 0,1,2 as well
} else {
throw sls::RuntimeError("Unknown action");
}
}
return os.str();
}
/* Mythen3 Specific */
std::string CmdProxy::Counters(int action) {
@ -1471,7 +1516,7 @@ std::string CmdProxy::PatternWord(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[step or address] [64 bit mask]\n\t[Mythen3][Ctb] 64 bit pattern at "
os << "[step or address] [64 bit mask]\n\t[Ctb][Mythen3] 64 bit pattern at "
"address of pattern memory."
<< '\n';
} else if (action == defs::GET_ACTION) {
@ -1497,17 +1542,17 @@ std::string CmdProxy::PatternLoopAddresses(int action) {
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (cmd == "patlimits") {
os << "[start addr] [stop addr] \n\t[Mythen3][Ctb] Limits of complete "
os << "[start addr] [stop addr] \n\t[Ctb][Mythen3] Limits of complete "
"pattern."
<< '\n';
} else if (cmd == "patloop0") {
os << "[start addr] [stop addr] \n\t[Mythen3][Ctb] Limits of loop 0."
os << "[start addr] [stop addr] \n\t[Ctb][Mythen3] Limits of loop 0."
<< '\n';
} else if (cmd == "patloop1") {
os << "[start addr] [stop addr] \n\t[Mythen3][Ctb] Limits of loop 1."
os << "[start addr] [stop addr] \n\t[Ctb][Mythen3] Limits of loop 1."
<< '\n';
} else if (cmd == "patloop2") {
os << "[start addr] [stop addr] \n\t[Mythen3][Ctb] Limits of loop 2."
os << "[start addr] [stop addr] \n\t[Ctb][Mythen3] Limits of loop 2."
<< '\n';
} else {
throw sls::RuntimeError(
@ -1552,11 +1597,11 @@ std::string CmdProxy::PatternLoopCycles(int action) {
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (cmd == "patnloop0") {
os << "[n_cycles] \n\t[Mythen3][Ctb] Number of cycles of loop 0." << '\n';
os << "[n_cycles] \n\t[Ctb][Mythen3] Number of cycles of loop 0." << '\n';
} else if (cmd == "patnloop1") {
os << "[n_cycles] \n\t[Mythen3][Ctb] Number of cycles of loop 1." << '\n';
os << "[n_cycles] \n\t[Ctb][Mythen3] Number of cycles of loop 1." << '\n';
} else if (cmd == "patnloop2") {
os << "[n_cycles] \n\t[Mythen3][Ctb] Number of cycles of loop 2." << '\n';
os << "[n_cycles] \n\t[Ctb][Mythen3] Number of cycles of loop 2." << '\n';
} else {
throw sls::RuntimeError(
"Unknown command, use list to list all commands");
@ -1597,11 +1642,11 @@ std::string CmdProxy::PatternWaitAddress(int action) {
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (cmd == "patwait0") {
os << "[addr] \n\t[Mythen3][Ctb] Wait 0 address." << '\n';
os << "[addr] \n\t[Ctb][Mythen3] Wait 0 address." << '\n';
} else if (cmd == "patwait1") {
os << "[addr] \n\t[Mythen3][Ctb] Wait 1 address." << '\n';
os << "[addr] \n\t[Ctb][Mythen3] Wait 1 address." << '\n';
} else if (cmd == "patwait2") {
os << "[addr] \n\t[Mythen3][Ctb] Wait 2 address." << '\n';
os << "[addr] \n\t[Ctb][Mythen3] Wait 2 address." << '\n';
} else {
throw sls::RuntimeError(
"Unknown command, use list to list all commands");
@ -1642,11 +1687,11 @@ std::string CmdProxy::PatternWaitTime(int action) {
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (cmd == "patwaittime0") {
os << "[n_clk] \n\t[Mythen3][Ctb] Wait 0 time in clock cycles." << '\n';
os << "[n_clk] \n\t[Ctb][Mythen3] Wait 0 time in clock cycles." << '\n';
} else if (cmd == "patwaittime1") {
os << "[n_clk] \n\t[Mythen3][Ctb] Wait 1 time in clock cycles." << '\n';
os << "[n_clk] \n\t[Ctb][Mythen3] Wait 1 time in clock cycles." << '\n';
} else if (cmd == "patwaittime2") {
os << "[n_clk] \n\t[Mythen3][Ctb] Wait 2 time in clock cycles." << '\n';
os << "[n_clk] \n\t[Ctb][Mythen3] Wait 2 time in clock cycles." << '\n';
} else {
throw sls::RuntimeError(
"Unknown command, use list to list all commands");

View File

@ -648,7 +648,7 @@ class CmdProxy {
{"vb_comp_fe", &CmdProxy::vb_comp_fe},
{"vb_comp_adc", &CmdProxy::vb_comp_adc},
{"vcom_cds", &CmdProxy::vcom_cds},
{"vref_restore", &CmdProxy::vref_restore},
{"vref_rstore", &CmdProxy::vref_rstore},
{"vb_opa_1st", &CmdProxy::vb_opa_1st},
{"vref_comp_fe", &CmdProxy::vref_comp_fe},
{"vcom_adc1", &CmdProxy::vcom_adc1},
@ -787,8 +787,7 @@ class CmdProxy {
{"inj_ch", &CmdProxy::InjectChannel},
{"vetophoton", &CmdProxy::VetoPhoton},
{"vetoref", &CmdProxy::VetoReference},
{"burstmode", &CmdProxy::burstmode},
{"bursttype", &CmdProxy::bursttype},
{"burstmode", &CmdProxy::BurstMode},
/* Mythen3 Specific */
{"counters", &CmdProxy::Counters},
@ -948,6 +947,7 @@ class CmdProxy {
std::string InjectChannel(int action);
std::string VetoPhoton(int action);
std::string VetoReference(int action);
std::string BurstMode(int action);
/* Mythen3 Specific */
std::string Counters(int action);
/* CTB Specific */
@ -1231,7 +1231,7 @@ class CmdProxy {
DAC_COMMAND(vcom_cds, getDAC, setDAC, defs::VCOM_CDS,
"[dac or mv value][(optional unit) mv] \n\t[Gotthard2] Dac for common mode voltage of CDS stage.");
DAC_COMMAND(vref_restore, getDAC, setDAC, defs::VREF_RESTORE,
DAC_COMMAND(vref_rstore, getDAC, setDAC, defs::VREF_RSTORE,
"[dac or mv value][(optional unit) mv] \n\t[Gotthard2] Dac for reference charging voltage of temparory storage cell in high gain.");
DAC_COMMAND(vb_opa_1st, getDAC, setDAC, defs::VB_OPA_1ST,
@ -1554,12 +1554,6 @@ class CmdProxy {
"[0, 1]\n\t[Gotthard] 1 adds channel intensity with precalculated values when taking an acquisition. Default is 0.");
/* Gotthard2 Specific */
INTEGER_COMMAND(burstmode, getBurstMode, setBurstMode, std::stoi,
"[0, 1]\n\t[Gotthard2] 1 sets to burst mode. 0 sets to continuous mode. Default is burst mode.");
INTEGER_COMMAND(bursttype, getBurstType, setBurstType, sls::StringTo<slsDetectorDefs::burstModeType>,
"[internal, external]\n\t[Gotthard2] Default is internal type.");
/* Mythen3 Specific */
/* CTB Specific */
@ -1679,10 +1673,10 @@ class CmdProxy {
"[64 bit mask]\n\t[Ctb] 64 bit mask defining output clock enable.");
INTEGER_COMMAND_HEX(patmask, getPatternMask, setPatternMask, stoulHex,
"[64 bit mask]\n\t[Ctb] 64 bit mask applied to every pattern. Only these bits for each pattern will be masked against.");
"[64 bit mask]\n\t[Ctb][Mythen3] 64 bit mask applied to every pattern. Only these bits for each pattern will be masked against.");
INTEGER_COMMAND_HEX(patsetbit, getPatternBitMask, setPatternBitMask, stoulHex,
"[64 bit mask]\n\t[Ctb] 64 bit values applied to the selected patmask for every pattern.");
"[64 bit mask]\n\t[Ctb][Mythen3] 64 bit values applied to the selected patmask for every pattern.");
/* Moench */

View File

@ -1180,20 +1180,12 @@ void Detector::setVetoReference(const int gainIndex, const int value, Positions
pimpl->Parallel(&slsDetector::setVetoReference, pos, gainIndex, value);
}
Result<bool> Detector::getBurstMode(Positions pos) {
Result<defs::burstMode> Detector::getBurstMode(Positions pos) {
return pimpl->Parallel(&slsDetector::getBurstMode, pos);
}
void Detector::setBurstMode(bool enable, Positions pos) {
pimpl->Parallel(&slsDetector::setBurstMode, pos, enable);
}
Result<defs::burstModeType> Detector::getBurstType(Positions pos) {
return pimpl->Parallel(&slsDetector::getBurstType, pos);
}
void Detector::setBurstType(defs::burstModeType value, Positions pos) {
pimpl->Parallel(&slsDetector::setBurstType, pos, value);
void Detector::setBurstMode(defs::burstMode value, Positions pos) {
pimpl->Parallel(&slsDetector::setBurstMode, pos, value);
}
// Mythen3 Specific

View File

@ -2476,32 +2476,19 @@ void slsDetector::setVetoReference(const int gainIndex, const int value) {
sendToDetector(F_SET_VETO_REFERENCE, args, nullptr);
}
bool slsDetector::getBurstMode() {
slsDetectorDefs::burstMode slsDetector::getBurstMode() {
int retval = -1;
sendToDetector(F_GET_BURST_MODE, nullptr, retval);
FILE_LOG(logDEBUG1) << "Burst mode:" << retval;
return static_cast<bool>(retval);
return static_cast<slsDetectorDefs::burstMode>(retval);
}
void slsDetector::setBurstMode(bool enable) {
int arg = static_cast<int>(enable);
void slsDetector::setBurstMode(slsDetectorDefs::burstMode value) {
int arg = static_cast<int>(value);
FILE_LOG(logDEBUG1) << "Setting burst mode to " << arg;
sendToDetector(F_SET_BURST_MODE, arg, nullptr);
}
slsDetectorDefs::burstModeType slsDetector::getBurstType() {
int retval = -1;
sendToDetector(F_GET_BURST_TYPE, nullptr, retval);
FILE_LOG(logDEBUG1) << "Burst mode:" << retval;
return static_cast<burstModeType>(retval);
}
void slsDetector::setBurstType (burstModeType val) {
int arg = static_cast<int>(val);
FILE_LOG(logDEBUG1) << "Setting burst type to " << ToString(val);
sendToDetector(F_SET_BURST_TYPE, arg, nullptr);
}
int slsDetector::setCounterBit(int cb) {
int retval = -1;
FILE_LOG(logDEBUG1) << "Sending counter bit " << cb;

View File

@ -1131,17 +1131,11 @@ class slsDetector : public virtual slsDetectorDefs {
void setVetoReference(const int gainIndex, const int value);
/** [Gotthard2] */
bool getBurstMode();
burstMode getBurstMode();
/** [Gotthard2] true = burst mode or false = continuous mode */
void setBurstMode(bool enable);
/** [Gotthard2] */
burstModeType getBurstType();
/** [Gotthard2] Options: INTERNAL, EXTERNAL */
void setBurstType(burstModeType val);
/** [Gotthard2] BURST_OFF, BURST_INTERNAL (default), BURST_EXTERNAL */
void setBurstMode(burstMode value);
/**
* Set/get counter bit in detector (Gotthard)
* @param i is -1 to get, 0 to reset and any other value to set the counter
@ -1764,16 +1758,16 @@ class slsDetector : public virtual slsDetectorDefs {
uint64_t setPatternClockControl(uint64_t word = -1);
/**
* Writes a pattern word (CTB/ Moench)
* Writes a pattern word (CTB/ Moench/ Mythen3)
* @param addr address of the word
* @param word 64bit word to be written, -1 reads the addr (same as
* executing the pattern)
* executing the pattern for ctb)
* @returns actual value
*/
uint64_t setPatternWord(int addr, uint64_t word);
/**
* Sets the pattern or loop limits (CTB/ Moench)
* Sets the pattern or loop limits (CTB/ Moench/ Mythen3)
* @param level -1 complete pattern, 0,1,2, loop level
* @param start start address for level 0-2, -1 gets
* @param stop stop address for level 0-2, -1 gets
@ -1783,7 +1777,7 @@ class slsDetector : public virtual slsDetectorDefs {
int stop = -1);
/**
* Sets the pattern or loop limits (CTB/ Moench)
* Sets the pattern or loop limits (CTB/ Moench/ Mythen3)
* @param level -1 complete pattern, 0,1,2, loop level
* @param n number of loops for level 0-2, -1 gets
* @returns number of loops
@ -1792,7 +1786,7 @@ class slsDetector : public virtual slsDetectorDefs {
/**
* Sets the wait address (CTB/ Moench)
* Sets the wait address (CTB/ Moench/ Mythen3)
* @param level 0,1,2, wait level
* @param addr wait address, -1 gets
* @returns actual value
@ -1800,7 +1794,7 @@ class slsDetector : public virtual slsDetectorDefs {
int setPatternWaitAddr(int level, int addr = -1);
/**
* Sets the wait time (CTB/ Moench)
* Sets the wait time (CTB/ Moench/ Mythen3)
* @param level 0,1,2, wait level
* @param t wait time, -1 gets
* @returns actual value
@ -1808,27 +1802,27 @@ class slsDetector : public virtual slsDetectorDefs {
uint64_t setPatternWaitTime(int level, uint64_t t = -1);
/**
* Sets the mask applied to every pattern (CTB/ Moench)
* Sets the mask applied to every pattern (CTB/ Moench/ Mythen3)
* @param mask mask to be applied
*/
void setPatternMask(uint64_t mask);
/**
* Gets the mask applied to every pattern (CTB/ Moench)
* Gets the mask applied to every pattern (CTB/ Moench/ Mythen3)
* @returns mask set
*/
uint64_t getPatternMask();
/**
* Selects the bits that the mask will be applied to for every pattern (CTB/
* Moench)
* Moench/ Mythen3)
* @param mask mask to select bits
*/
void setPatternBitMask(uint64_t mask);
/**
* Gets the bits that the mask will be applied to for every pattern (CTB/
* Moench)
* Moench/ Mythen3)
* @returns mask of bits selected
*/
uint64_t getPatternBitMask();

View File

@ -361,7 +361,7 @@ TEST_CASE("Setting and reading back EIGER dacs", "[.cmd]") {
REQUIRE_THROWS(proxy.Call("vb_comp_fe", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("vb_comp_adc", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("vcom_cds", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("vref_restore", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("vref_rstore", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("vb_opa_1st", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("vref_comp_fe", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("vcom_adc1", {}, -1, GET));

View File

@ -69,7 +69,7 @@ TEST_CASE("Setting and reading back MYTHEN3 dacs", "[.cmd][.dacs]") {
REQUIRE_THROWS(proxy.Call("vb_comp_fe", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("vb_comp_adc", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("vcom_cds", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("vref_restore", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("vref_rstore", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("vb_opa_1st", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("vref_comp_fe", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("vcom_adc1", {}, -1, GET));

View File

@ -311,7 +311,7 @@ TEST_CASE("type", "[.cmd]"){
// REQUIRE_THROWS(multiSlsDetectorClient("vb_comp_fe", GET));
// REQUIRE_THROWS(multiSlsDetectorClient("vb_comp_adc", GET));
// REQUIRE_THROWS(multiSlsDetectorClient("vcom_cds", GET));
// REQUIRE_THROWS(multiSlsDetectorClient("vref_restore", GET));
// REQUIRE_THROWS(multiSlsDetectorClient("vref_rstore", GET));
// REQUIRE_THROWS(multiSlsDetectorClient("vb_opa_1st", GET));
// REQUIRE_THROWS(multiSlsDetectorClient("vref_comp_fe", GET));
// REQUIRE_THROWS(multiSlsDetectorClient("vcom_adc1", GET));
@ -474,7 +474,7 @@ TEST_CASE("type", "[.cmd]"){
// REQUIRE_THROWS(multiSlsDetectorClient("vb_comp_fe", GET));
// REQUIRE_THROWS(multiSlsDetectorClient("vb_comp_adc", GET));
// REQUIRE_THROWS(multiSlsDetectorClient("vcom_cds", GET));
// REQUIRE_THROWS(multiSlsDetectorClient("vref_restore", GET));
// REQUIRE_THROWS(multiSlsDetectorClient("vref_rstore", GET));
// REQUIRE_THROWS(multiSlsDetectorClient("vb_opa_1st", GET));
// REQUIRE_THROWS(multiSlsDetectorClient("vref_comp_fe", GET));
// REQUIRE_THROWS(multiSlsDetectorClient("vcom_adc1", GET));
@ -557,7 +557,7 @@ TEST_CASE("type", "[.cmd]"){
// REQUIRE_THROWS(multiSlsDetectorClient("vb_comp_fe", GET));
// REQUIRE_THROWS(multiSlsDetectorClient("vb_comp_adc", GET));
// REQUIRE_THROWS(multiSlsDetectorClient("vcom_cds", GET));
// REQUIRE_THROWS(multiSlsDetectorClient("vref_restore", GET));
// REQUIRE_THROWS(multiSlsDetectorClient("vref_rstore", GET));
// REQUIRE_THROWS(multiSlsDetectorClient("vb_opa_1st", GET));
// REQUIRE_THROWS(multiSlsDetectorClient("vref_comp_fe", GET));
// REQUIRE_THROWS(multiSlsDetectorClient("vcom_adc1", GET));
@ -634,17 +634,17 @@ TEST_CASE("type", "[.cmd]"){
// std::to_string(prev_val), PUT));
// {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("vref_restore", GET,
// REQUIRE_NOTHROW(multiSlsDetectorClient("vref_rstore", GET,
// nullptr, oss)); std::string s = (oss.str()).erase (0,
// strlen("vref_restore ")); prev_val = std::stoi(s);
// strlen("vref_rstore ")); prev_val = std::stoi(s);
// }
// {
// REQUIRE_NOTHROW(multiSlsDetectorClient("vref_restore 1000",
// REQUIRE_NOTHROW(multiSlsDetectorClient("vref_rstore 1000",
// PUT)); std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("vref_restore", GET,
// nullptr, oss)); REQUIRE(oss.str() == "vref_restore 1000\n");
// REQUIRE_NOTHROW(multiSlsDetectorClient("vref_rstore", GET,
// nullptr, oss)); REQUIRE(oss.str() == "vref_rstore 1000\n");
// }
// REQUIRE_NOTHROW(multiSlsDetectorClient("vref_restore " +
// REQUIRE_NOTHROW(multiSlsDetectorClient("vref_rstore " +
// std::to_string(prev_val), PUT));
// {
// std::ostringstream oss;

View File

@ -204,11 +204,13 @@ inline std::string ToString(const defs::detectorModeType s) {
}
}
inline std::string ToString(const defs::burstModeType s) {
inline std::string ToString(const defs::burstMode s) {
switch (s) {
case defs::INTERNAL:
case defs::BURST_OFF:
return std::string("off");
case defs::BURST_INTERNAL:
return std::string("internal");
case defs::EXTERNAL:
case defs::BURST_EXTERNAL:
return std::string("external");
default:
return std::string("Unknown");
@ -562,12 +564,14 @@ inline defs::dacIndex StringTo(const std::string& s) {
}
template <>
inline defs::burstModeType StringTo(const std::string& s) {
inline defs::burstMode StringTo(const std::string& s) {
if (s == "off")
return defs::BURST_OFF;
if (s == "internal")
return defs::INTERNAL;
return defs::BURST_INTERNAL;
if (s == "external")
return defs::EXTERNAL;
throw sls::RuntimeError("Unknown burst mode type" + s);
return defs::BURST_EXTERNAL;
throw sls::RuntimeError("Unknown burst mode " + s);
}

View File

@ -317,7 +317,7 @@ class slsDetectorDefs {
VB_COMP_FE,
VB_COMP_ADC,
VCOM_CDS,
VREF_RESTORE,
VREF_RSTORE,
VB_OPA_1ST,
VREF_COMP_FE,
VCOM_ADC1,
@ -439,11 +439,12 @@ class slsDetectorDefs {
};
/**
* burst mode type for gotthard2
* burst mode for gotthard2
*/
enum burstModeType {
INTERNAL,
EXTERNAL,
enum burstMode {
BURST_OFF,
BURST_INTERNAL,
BURST_EXTERNAL,
};

View File

@ -188,8 +188,6 @@ enum detFuncs{
F_GET_ADC_ENABLE_MASK_10G,
F_SET_COUNTER_MASK,
F_GET_COUNTER_MASK,
F_SET_BURST_TYPE,
F_GET_BURST_TYPE,
NUM_DET_FUNCTIONS,
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this (detector server should not compile anyway) */
@ -445,8 +443,6 @@ static const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_GET_ADC_ENABLE_MASK_10G: return "F_GET_ADC_ENABLE_MASK_10G";
case F_SET_COUNTER_MASK: return "F_SET_COUNTER_MASK";
case F_GET_COUNTER_MASK: return "F_GET_COUNTER_MASK";
case F_SET_BURST_TYPE: return "F_SET_BURST_TYPE";
case F_GET_BURST_TYPE: return "F_GET_BURST_TYPE";
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";

View File

@ -6,7 +6,7 @@
#define APIMOENCH 0x190820
#define APICTB 0x200122
#define APIGOTTHARD 0x200122
#define APIGOTTHARD2 0x200122
#define APIEIGER 0x200122
#define APIJUNGFRAU 0x200122
#define APIMYTHEN3 0x200122
#define APIEIGER 0x200122
#define APIGOTTHARD2 0x200123