Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer

This commit is contained in:
bergamaschi 2020-03-02 14:50:48 +01:00
commit ecc3b36204
27 changed files with 402 additions and 29 deletions

View File

@ -34,4 +34,5 @@ deploy:
script: find $HOME/miniconda/envs/testenv/conda-bld/${TRAVIS_OS_NAME}-64 -name "*.tar.bz2" -exec anaconda -t $CONDA_TOKEN upload --force {} \; script: find $HOME/miniconda/envs/testenv/conda-bld/${TRAVIS_OS_NAME}-64 -name "*.tar.bz2" -exec anaconda -t $CONDA_TOKEN upload --force {} \;
on: on:
branch: developer branch: developer
tags: true

View File

@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.12)
project(slsDetectorPackage) project(slsDetectorPackage)
set(PROJECT_VERSION 5.0.0) set(PROJECT_VERSION 5.0.0)
include(CheckIPOSupported) include(CheckIPOSupported)
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
cmake_policy(SET CMP0074 NEW) cmake_policy(SET CMP0074 NEW)
include(cmake/project_version.cmake) include(cmake/project_version.cmake)
@ -44,6 +44,9 @@ option(SLS_USE_PYTHON "Python bindings" OFF)
option(SLS_USE_CTBGUI "ctb GUI" OFF) option(SLS_USE_CTBGUI "ctb GUI" OFF)
option(SLS_BUILD_DOCS "docs" OFF) option(SLS_BUILD_DOCS "docs" OFF)
option(SLS_BUILD_EXAMPLES "examples" OFF) option(SLS_BUILD_EXAMPLES "examples" OFF)
option(SLS_TUNE_LOCAL "tune to local machine" OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
@ -111,6 +114,11 @@ if(SLS_USE_SANITIZER)
# target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread) # target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread)
endif() endif()
if(SLS_TUNE_LOCAL)
target_compile_options(slsProjectOptions INTERFACE -mtune=native -march=native)
endif()
#rapidjson #rapidjson
add_library(rapidjson INTERFACE) add_library(rapidjson INTERFACE)
target_include_directories(rapidjson INTERFACE target_include_directories(rapidjson INTERFACE

View File

@ -1,13 +1,13 @@
package: package:
name: sls_detector_software name: sls_detector_software
version: "developer" version: {{ environ.get('GIT_DESCRIBE_TAG', '') }}
source: source:
- path: .. - path: ..
build: build:
number: 1 number: 2
binary_relocation: True binary_relocation: True
rpaths: rpaths:
- lib/ - lib/

View File

@ -3,9 +3,9 @@ import sys
import numpy as np import numpy as np
sys.path.append(os.path.join(os.getcwd(), 'bin')) sys.path.append(os.path.join(os.getcwd(), 'bin'))
from sls_detector import Detector, Mythen3, Eiger, Jungfrau, DetectorDacs, Dac, Ctb from slsdet import Detector, Mythen3, Eiger, Jungfrau, DetectorDacs, Dac, Ctb
from sls_detector import dacIndex, readoutMode from slsdet import dacIndex, readoutMode
from sls_detector.lookup import view, find from slsdet.lookup import view, find
d = Detector() d = Detector()
# e = Eiger() # e = Eiger()

View File

@ -8,7 +8,7 @@ import sys
import setuptools import setuptools
import os import os
__version__ = 'udp' __version__ = os.environ.get('GIT_DESCRIBE_TAG', 'developer')
def get_conda_path(): def get_conda_path():

View File

@ -1,9 +1,9 @@
from .detector import Detector from .detector import Detector
def view(name): def view(name, det = Detector):
names = find(name) names = find(name, det)
for n in names: for n in names:
print(n) print(n)
def find(name): def find(name, det = Detector):
return [n for n in dir(Detector) if name in n] return [n for n in dir(det) if name.lower() in n.lower()]

View File

@ -428,6 +428,13 @@ void init_det(py::module &m) {
py::arg() = Positions{}) py::arg() = Positions{})
.def("setImageTestMode", &Detector::setImageTestMode, py::arg(), .def("setImageTestMode", &Detector::setImageTestMode, py::arg(),
py::arg() = Positions{}) py::arg() = Positions{})
.def("getNumberOfBursts", &Detector::getNumberOfBursts,
py::arg() = Positions{})
.def("setNumberOfBursts", &Detector::setNumberOfBursts, py::arg())
.def("getBurstPeriod", &Detector::getBurstPeriod,
py::arg() = Positions{})
.def("setBurstPeriod", &Detector::setBurstPeriod, py::arg(),
py::arg() = Positions{})
.def("getInjectChannel", &Detector::getInjectChannel, .def("getInjectChannel", &Detector::getInjectChannel,
py::arg() = Positions{}) py::arg() = Positions{})
.def("setInjectChannel", &Detector::setInjectChannel, py::arg(), .def("setInjectChannel", &Detector::setInjectChannel, py::arg(),
@ -441,6 +448,14 @@ void init_det(py::module &m) {
.def("getBurstMode", &Detector::getBurstMode, py::arg() = Positions{}) .def("getBurstMode", &Detector::getBurstMode, py::arg() = Positions{})
.def("setBurstMode", &Detector::setBurstMode, py::arg(), .def("setBurstMode", &Detector::setBurstMode, py::arg(),
py::arg() = Positions{}) py::arg() = Positions{})
.def("getCurrentSource", &Detector::getCurrentSource,
py::arg() = Positions{})
.def("setCurrentSource", &Detector::setCurrentSource, py::arg(),
py::arg() = Positions{})
.def("getTimingSource", &Detector::getTimingSource,
py::arg() = Positions{})
.def("setTimingSource", &Detector::setTimingSource, py::arg(),
py::arg() = Positions{})
.def("getCounterMask", &Detector::getCounterMask, .def("getCounterMask", &Detector::getCounterMask,
py::arg() = Positions{}) py::arg() = Positions{})
.def("setCounterMask", &Detector::setCounterMask, py::arg(), .def("setCounterMask", &Detector::setCounterMask, py::arg(),

View File

@ -284,4 +284,11 @@ void init_enums(py::module &m) {
.value("BURST_INTERNAL", slsDetectorDefs::burstMode::BURST_INTERNAL) .value("BURST_INTERNAL", slsDetectorDefs::burstMode::BURST_INTERNAL)
.value("BURST_EXTERNAL", slsDetectorDefs::burstMode::BURST_EXTERNAL) .value("BURST_EXTERNAL", slsDetectorDefs::burstMode::BURST_EXTERNAL)
.export_values(); .export_values();
py::enum_<slsDetectorDefs::timingSourceType>(Defs, "timingSourceType")
.value("TIMING_INTERNAL",
slsDetectorDefs::timingSourceType::TIMING_INTERNAL)
.value("TIMING_EXTERNAL",
slsDetectorDefs::timingSourceType::TIMING_EXTERNAL)
.export_values();
} }

View File

@ -166,7 +166,7 @@ void qDrawPlot::SetupPlots() {
plot1d->SetTitleFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); plot1d->SetTitleFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
plot1d->SetXFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); plot1d->SetXFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
plot1d->SetYFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); plot1d->SetYFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
plot1d->SetTitle("--"); plot1d->SetTitle("");
plot1d->SetXTitle(xTitle1d); plot1d->SetXTitle(xTitle1d);
plot1d->SetYTitle(yTitle1d); plot1d->SetYTitle(yTitle1d);
h->Attach(plot1d); h->Attach(plot1d);
@ -186,12 +186,16 @@ void qDrawPlot::SetupPlots() {
gainhist1d->setSymbolMarkers(isMarkers); gainhist1d->setSymbolMarkers(isMarkers);
// setup 1d gain plot // setup 1d gain plot
gainplot1d = new SlsQt1DPlot(boxPlot); gainplot1d = new SlsQt1DPlot(boxPlot);
//gainplot1d->setFont(QFont("Sans Serif", 3, 20)); gainplot1d->SetTitleFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
gainplot1d->SetYFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
gainplot1d->SetTitle(""); gainplot1d->SetTitle("");
gainplot1d->axisScaleDraw(QwtPlot::xBottom)->enableComponent(QwtScaleDraw::Labels, false); gainplot1d->SetYTitle("Gain");
gainplot1d->axisScaleDraw(QwtPlot::xBottom)->enableComponent(QwtScaleDraw::Ticks, false); // set ticks to just 3
gainplot1d->axisScaleDraw(QwtPlot::yLeft)->enableComponent(QwtScaleDraw::Labels, false); QList<double> majorTicks({0, 1, 2, 3});
gainplot1d->axisScaleDraw(QwtPlot::yLeft)->enableComponent(QwtScaleDraw::Ticks, false); QwtScaleDiv div( 0, 3, QList<double>(), QList<double>(), majorTicks);
gainplot1d->setAxisScaleDiv( QwtPlot::yLeft, div );
//gainplot1d->axisScaleDraw(QwtPlot::xBottom)->enableComponent(QwtScaleDraw::Ticks, false);
//gainplot1d->axisScaleDraw(QwtPlot::yLeft)->enableComponent(QwtScaleDraw::Labels, false);
gainhist1d->setItemAttribute(QwtPlotItem::Legend, false); gainhist1d->setItemAttribute(QwtPlotItem::Legend, false);
gainhist1d->Attach(gainplot1d); gainhist1d->Attach(gainplot1d);
gainplot1d->hide(); gainplot1d->hide();
@ -233,18 +237,21 @@ void qDrawPlot::SetupPlots() {
gainplot2d = new SlsQt2DPlot(boxPlot); gainplot2d = new SlsQt2DPlot(boxPlot);
gainplot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5, nPixelsY - 0.5, gainData); gainplot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5, nPixelsY - 0.5, gainData);
gainplot2d->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); gainplot2d->SetTitleFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
gainplot2d->setTitle(""); gainplot2d->setTitle("Gain");
gainplot2d->enableAxis(0, false); gainplot2d->SetZTitle("");
gainplot2d->enableAxis(1, false); gainplot2d->enableAxis(QwtPlot::yLeft, false);
gainplot2d->enableAxis(2, false); //gainplot2d->enableAxis(1, false);
gainplot2d->enableAxis(QwtPlot::xBottom, false);
// set ticks to just 3
gainplot2d->setAxisScaleDiv( QwtPlot::yRight, div );
gainplot2d->hide(); gainplot2d->hide();
// layout of plots // layout of plots
int ratio = qDefs::DATA_GAIN_PLOT_RATIO - 1; int ratio = qDefs::DATA_GAIN_PLOT_RATIO - 1;
plotLayout->addWidget(plot1d, 0, 0, ratio, ratio); plotLayout->addWidget(plot1d, 0, 0, ratio, ratio);
plotLayout->addWidget(plot2d, 0, 0, ratio, ratio); plotLayout->addWidget(plot2d, 0, 0, ratio, ratio);
plotLayout->addWidget(gainplot1d, 0, ratio, 1, 1, Qt::AlignRight | Qt::AlignTop); plotLayout->addWidget(gainplot1d, ratio, 0, 1, ratio, Qt::AlignTop);
plotLayout->addWidget(gainplot2d, 0, ratio, 1, 1, Qt::AlignRight | Qt::AlignTop); plotLayout->addWidget(gainplot2d, 0, ratio, 1, 1, Qt::AlignRight | Qt::AlignTop);
} }
@ -254,7 +261,7 @@ void qDrawPlot::resizeEvent(QResizeEvent *event) {
gainplot2d->setFixedHeight(plot2d->height() / qDefs::DATA_GAIN_PLOT_RATIO); gainplot2d->setFixedHeight(plot2d->height() / qDefs::DATA_GAIN_PLOT_RATIO);
} }
if (gainplot1d->isVisible()) { if (gainplot1d->isVisible()) {
gainplot1d->setFixedWidth(plot1d->width() / qDefs::DATA_GAIN_PLOT_RATIO); gainplot1d->setFixedWidth(plot1d->width());
gainplot1d->setFixedHeight(plot1d->height() / qDefs::DATA_GAIN_PLOT_RATIO); gainplot1d->setFixedHeight(plot1d->height() / qDefs::DATA_GAIN_PLOT_RATIO);
} }
event->accept(); event->accept();
@ -871,7 +878,7 @@ void qDrawPlot::Update1dPlot() {
gainhist1d->setSymbolMarkers(isMarkers); gainhist1d->setSymbolMarkers(isMarkers);
gainhist1d->Attach(gainplot1d); gainhist1d->Attach(gainplot1d);
if (!gainplot1d->isVisible()) { if (!gainplot1d->isVisible()) {
gainplot1d->setFixedWidth(plot1d->width() / qDefs::DATA_GAIN_PLOT_RATIO); gainplot1d->setFixedWidth(plot1d->width() );
gainplot1d->setFixedHeight(plot1d->height() / qDefs::DATA_GAIN_PLOT_RATIO); gainplot1d->setFixedHeight(plot1d->height() / qDefs::DATA_GAIN_PLOT_RATIO);
gainplot1d->show(); gainplot1d->show();
} }

View File

@ -65,6 +65,8 @@ void qTabPlot::SetupWidgetWindow() {
case slsDetectorDefs::GOTTHARD2: case slsDetectorDefs::GOTTHARD2:
is1d = true; is1d = true;
chkGainPlot1D->setEnabled(true); chkGainPlot1D->setEnabled(true);
chkGainPlot1D->setChecked(true);
plot->EnableGainPlot(true);
break; break;
case slsDetectorDefs::EIGER: case slsDetectorDefs::EIGER:
chkGapPixels->setEnabled(true); chkGapPixels->setEnabled(true);
@ -72,6 +74,8 @@ void qTabPlot::SetupWidgetWindow() {
case slsDetectorDefs::JUNGFRAU: case slsDetectorDefs::JUNGFRAU:
case slsDetectorDefs::MOENCH: case slsDetectorDefs::MOENCH:
chkGainPlot->setEnabled(true); chkGainPlot->setEnabled(true);
chkGainPlot->setChecked(true);
plot->EnableGainPlot(true);
break; break;
default: default:
break; break;

View File

@ -104,6 +104,8 @@
#define CONTROL_PRPHRL_RST_MSK (0x00000001 << CONTROL_PRPHRL_RST_OFST) #define CONTROL_PRPHRL_RST_MSK (0x00000001 << CONTROL_PRPHRL_RST_OFST)
#define CONTROL_CLR_ACQSTN_FIFO_OFST (15) #define CONTROL_CLR_ACQSTN_FIFO_OFST (15)
#define CONTROL_CLR_ACQSTN_FIFO_MSK (0x00000001 << CONTROL_CLR_ACQSTN_FIFO_OFST) #define CONTROL_CLR_ACQSTN_FIFO_MSK (0x00000001 << CONTROL_CLR_ACQSTN_FIFO_OFST)
#define CONTROL_TIMING_SOURCE_EXT_OFST (17)
#define CONTROL_TIMING_SOURCE_EXT_MSK (0x00000001 << CONTROL_TIMING_SOURCE_EXT_OFST)
#define CONTROL_PWR_CHIP_OFST (31) #define CONTROL_PWR_CHIP_OFST (31)
#define CONTROL_PWR_CHIP_MSK (0x00000001 << CONTROL_PWR_CHIP_OFST) #define CONTROL_PWR_CHIP_MSK (0x00000001 << CONTROL_PWR_CHIP_OFST)
@ -128,6 +130,8 @@
#define ASIC_CONFIG_FIX_GAIN_1_VAL ((0x1 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK) #define ASIC_CONFIG_FIX_GAIN_1_VAL ((0x1 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK)
#define ASIC_CONFIG_FIX_GAIN_2_VAL ((0x2 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK) #define ASIC_CONFIG_FIX_GAIN_2_VAL ((0x2 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK)
#define ASIC_CONFIG_RESERVED_VAL ((0x3 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK) #define ASIC_CONFIG_RESERVED_VAL ((0x3 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK)
#define ASIC_CONFIG_CURRENT_SRC_EN_OFST (7)
#define ASIC_CONFIG_CURRENT_SRC_EN_MSK (0x00000001 << ASIC_CONFIG_CURRENT_SRC_EN_OFST)
#define ASIC_CONFIG_RST_DAC_OFST (15) #define ASIC_CONFIG_RST_DAC_OFST (15)
#define ASIC_CONFIG_RST_DAC_MSK (0x00000001 << ASIC_CONFIG_RST_DAC_OFST) #define ASIC_CONFIG_RST_DAC_MSK (0x00000001 << ASIC_CONFIG_RST_DAC_OFST)
#define ASIC_CONFIG_DONE_OFST (31) #define ASIC_CONFIG_DONE_OFST (31)

View File

@ -447,6 +447,8 @@ void setupDetector() {
setDelayAfterTrigger(DEFAULT_DELAY_AFTER_TRIGGER); setDelayAfterTrigger(DEFAULT_DELAY_AFTER_TRIGGER);
setBurstPeriod(DEFAULT_BURST_PERIOD); setBurstPeriod(DEFAULT_BURST_PERIOD);
setTiming(DEFAULT_TIMING_MODE); setTiming(DEFAULT_TIMING_MODE);
setCurrentSource(DEFAULT_CURRENT_SOURCE);
setTimingSource(DEFAULT_TIMING_SOURCE);
} }
int readConfigFile() { int readConfigFile() {
@ -1961,6 +1963,44 @@ enum burstMode getBurstMode() {
return burstMode; return burstMode;
} }
void setCurrentSource(int value) {
uint32_t addr = ASIC_CONFIG_REG;
if (value > 0) {
bus_w(addr, (bus_r(addr) | ASIC_CONFIG_CURRENT_SRC_EN_MSK));
} else if (value == 0) {
bus_w(addr, (bus_r(addr) &~ ASIC_CONFIG_CURRENT_SRC_EN_MSK));
}
}
int getCurrentSource() {
return ((bus_r(ASIC_CONFIG_REG) & ASIC_CONFIG_CURRENT_SRC_EN_MSK) >> ASIC_CONFIG_CURRENT_SRC_EN_OFST);
}
void setTimingSource(enum timingSourceType value) {
uint32_t addr = CONTROL_REG;
switch (value) {
case TIMING_INTERNAL:
FILE_LOG(logINFO, ("Setting timing source to internal\n"));
bus_w(addr, (bus_r(addr) &~ CONTROL_TIMING_SOURCE_EXT_MSK));
break;
case TIMING_EXTERNAL:
FILE_LOG(logINFO, ("Setting timing source to exernal\n"));
bus_w(addr, (bus_r(addr) | CONTROL_TIMING_SOURCE_EXT_MSK));
break;
default:
FILE_LOG(logERROR, ("Unknown timing source %d\n", value));
break;
}
}
enum timingSourceType getTimingSource() {
if (bus_r(CONTROL_REG) & CONTROL_TIMING_SOURCE_EXT_MSK) {
return TIMING_EXTERNAL;
}
return TIMING_INTERNAL;
}
/* aquisition */ /* aquisition */

View File

@ -41,6 +41,9 @@
#define DEFAULT_HIGH_VOLTAGE (0) #define DEFAULT_HIGH_VOLTAGE (0)
#define DEFAULT_TIMING_MODE (AUTO_TIMING) #define DEFAULT_TIMING_MODE (AUTO_TIMING)
#define DEFAULT_SETTINGS (DYNAMICGAIN) #define DEFAULT_SETTINGS (DYNAMICGAIN)
#define DEFAULT_CURRENT_SOURCE (0)
#define DEFAULT_TIMING_SOURCE (TIMING_INTERNAL)
#define DEFAULT_READOUT_C0 (144444448) // rdo_clk, 144 MHz #define DEFAULT_READOUT_C0 (144444448) // rdo_clk, 144 MHz
#define DEFAULT_READOUT_C1 (144444448) // rdo_x2_clk, 144 MHz #define DEFAULT_READOUT_C1 (144444448) // rdo_x2_clk, 144 MHz
#define DEFAULT_SYSTEM_C0 (144444448) // run_clk, 144 MHz #define DEFAULT_SYSTEM_C0 (144444448) // run_clk, 144 MHz
@ -50,7 +53,7 @@
/* Firmware Definitions */ /* Firmware Definitions */
#define IP_HEADER_SIZE (20) #define IP_HEADER_SIZE (20)
#define FIXED_PLL_FREQUENCY (020000000) // 20MHz #define FIXED_PLL_FREQUENCY (20000000) // 20MHz
#define READOUT_PLL_VCO_FREQ_HZ (866666688) // 866 MHz #define READOUT_PLL_VCO_FREQ_HZ (866666688) // 866 MHz
#define SYSTEM_PLL_VCO_FREQ_HZ (722222224) // 722 MHz #define SYSTEM_PLL_VCO_FREQ_HZ (722222224) // 722 MHz

View File

@ -482,6 +482,10 @@ int configureADC();
int setBurstModeinFPGA(enum burstMode value); int setBurstModeinFPGA(enum burstMode value);
int setBurstMode(enum burstMode burst); int setBurstMode(enum burstMode burst);
enum burstMode getBurstMode(); enum burstMode getBurstMode();
void setCurrentSource(int value);
int getCurrentSource();
void setTimingSource(enum timingSourceType value);
enum timingSourceType getTimingSource();
#endif #endif

View File

@ -212,3 +212,7 @@ int get_num_bursts(int);
int set_num_bursts(int); int set_num_bursts(int);
int get_burst_period(int); int get_burst_period(int);
int set_burst_period(int); int set_burst_period(int);
int get_current_source(int);
int set_current_source(int);
int get_timing_source(int);
int set_timing_source(int);

View File

@ -319,6 +319,10 @@ const char* getFunctionName(enum detFuncs func) {
case F_SET_NUM_BURSTS: return "F_SET_NUM_BURSTS"; case F_SET_NUM_BURSTS: return "F_SET_NUM_BURSTS";
case F_GET_BURST_PERIOD: return "F_GET_BURST_PERIOD"; case F_GET_BURST_PERIOD: return "F_GET_BURST_PERIOD";
case F_SET_BURST_PERIOD: return "F_SET_BURST_PERIOD"; case F_SET_BURST_PERIOD: return "F_SET_BURST_PERIOD";
case F_GET_CURRENT_SOURCE: return "F_GET_CURRENT_SOURCE";
case F_SET_CURRENT_SOURCE: return "F_SET_CURRENT_SOURCE";
case F_GET_TIMING_SOURCE: return "F_GET_TIMING_SOURCE";
case F_SET_TIMING_SOURCE: return "F_SET_TIMING_SOURCE";
default: return "Unknown Function"; default: return "Unknown Function";
} }
@ -507,6 +511,10 @@ void function_table() {
flist[F_SET_NUM_BURSTS] = &set_num_bursts; flist[F_SET_NUM_BURSTS] = &set_num_bursts;
flist[F_GET_BURST_PERIOD] = &get_burst_period; flist[F_GET_BURST_PERIOD] = &get_burst_period;
flist[F_SET_BURST_PERIOD] = &set_burst_period; flist[F_SET_BURST_PERIOD] = &set_burst_period;
flist[F_GET_CURRENT_SOURCE] = &get_current_source;
flist[F_SET_CURRENT_SOURCE] = &set_current_source;
flist[F_GET_TIMING_SOURCE] = &get_timing_source;
flist[F_SET_TIMING_SOURCE] = &set_timing_source;
// check // check
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) { if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
@ -6736,3 +6744,101 @@ int set_burst_period(int file_des) {
#endif #endif
return Server_SendResult(file_des, INT64, UPDATE, NULL, 0); return Server_SendResult(file_des, INT64, UPDATE, NULL, 0);
} }
int set_current_source(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int arg = 0;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
FILE_LOG(logINFO, ("Setting current source enable: %u\n", arg));
#ifndef GOTTHARD2D
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
setCurrentSource(arg);
int retval = getCurrentSource();
FILE_LOG(logDEBUG1, ("current source enable retval: %u\n", retval));
validate(arg, retval, "current source enable", DEC);
}
#endif
return Server_SendResult(file_des, INT32, UPDATE, NULL, 0);
}
int get_current_source(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retval = -1;
FILE_LOG(logDEBUG1, ("Getting current source enable\n"));
#ifndef GOTTHARD2D
functionNotImplemented();
#else
// get only
retval = getCurrentSource();
FILE_LOG(logDEBUG1, ("current source enable retval: %u\n", retval));
#endif
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
}
int set_timing_source(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
enum timingSourceType arg = TIMING_INTERNAL;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
FILE_LOG(logDEBUG1, ("Setting timing source: %d\n", arg));
#ifndef GOTTHARD2D
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
switch (arg) {
case TIMING_INTERNAL:
case TIMING_EXTERNAL:
break;
default:
modeNotImplemented("timing source", (int)arg);
break;
}
if (ret == OK) {
setTimingSource(arg);
enum timingSourceType retval = getTimingSource();
FILE_LOG(logDEBUG, ("timing source retval: %d\n", retval));
if (retval != arg) {
ret = FAIL;
sprintf(mess, "Could not set timing source. Set %d, got %d\n", arg, retval);
FILE_LOG(logERROR, (mess));
}
}
}
#endif
return Server_SendResult(file_des, INT32, UPDATE, NULL, 0);
}
int get_timing_source(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
enum timingSourceType retval = TIMING_INTERNAL;
FILE_LOG(logDEBUG1, ("Getting timing source\n"));
#ifndef GOTTHARD2D
functionNotImplemented();
#else
// get only
retval = getTimingSource();
FILE_LOG(logDEBUG1, ("Get timing source retval:%d\n", retval));
#endif
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
}

View File

@ -931,6 +931,18 @@ class Detector {
/** [Gotthard2] BURST_OFF, BURST_INTERNAL (default), BURST_EXTERNAL */ /** [Gotthard2] BURST_OFF, BURST_INTERNAL (default), BURST_EXTERNAL */
void setBurstMode(defs::burstMode value, Positions pos = {}); void setBurstMode(defs::burstMode value, Positions pos = {});
/** [Gotthard2] */
Result<bool> getCurrentSource(Positions pos = {}) const;
/** default disabled */
void setCurrentSource(bool value, Positions pos = {});
/** [Gotthard2] */
Result<defs::timingSourceType> getTimingSource(Positions pos = {}) const;
/** [Gotthard2] Options: TIMING_INTERNAL, TIMING_EXTERNAL */
void setTimingSource(defs::timingSourceType value, Positions pos = {});
/************************************************** /**************************************************
* * * *
* Mythen3 Specific * * Mythen3 Specific *

View File

@ -790,6 +790,8 @@ class CmdProxy {
{"vetophoton", &CmdProxy::VetoPhoton}, {"vetophoton", &CmdProxy::VetoPhoton},
{"vetoref", &CmdProxy::VetoReference}, {"vetoref", &CmdProxy::VetoReference},
{"burstmode", &CmdProxy::BurstMode}, {"burstmode", &CmdProxy::BurstMode},
{"currentsource", &CmdProxy::currentsource},
{"timingsource", &CmdProxy::timingsource},
/* Mythen3 Specific */ /* Mythen3 Specific */
{"counters", &CmdProxy::Counters}, {"counters", &CmdProxy::Counters},
@ -1564,6 +1566,12 @@ class CmdProxy {
"[0, 1]\n\t[Gotthard] 1 adds channel intensity with precalculated values when taking an acquisition. Default is 0."); "[0, 1]\n\t[Gotthard] 1 adds channel intensity with precalculated values when taking an acquisition. Default is 0.");
/* Gotthard2 Specific */ /* Gotthard2 Specific */
INTEGER_COMMAND(currentsource, getCurrentSource, setCurrentSource, std::stoi,
"[0, 1]\n\t[Gotthard2] Enable or disable current source. Default is disabled.");
INTEGER_COMMAND(timingsource, getTimingSource, setTimingSource, sls::StringTo<slsDetectorDefs::timingSourceType>,
"[internal|external]\n\t[Gotthard2] Timing source. Internal is crystal and external is system timing. Default is internal.");
/* Mythen3 Specific */ /* Mythen3 Specific */
/* CTB Specific */ /* CTB Specific */

View File

@ -1204,6 +1204,22 @@ void Detector::setBurstMode(defs::burstMode value, Positions pos) {
pimpl->Parallel(&slsDetector::setBurstMode, pos, value); pimpl->Parallel(&slsDetector::setBurstMode, pos, value);
} }
Result<bool> Detector::getCurrentSource(Positions pos) const {
return pimpl->Parallel(&slsDetector::getCurrentSource, pos);
}
void Detector::setCurrentSource(bool value, Positions pos) {
pimpl->Parallel(&slsDetector::setCurrentSource, pos, value);
}
Result<defs::timingSourceType> Detector::getTimingSource(Positions pos) const {
return pimpl->Parallel(&slsDetector::getTimingSource, pos);
}
void Detector::setTimingSource(defs::timingSourceType value, Positions pos) {
pimpl->Parallel(&slsDetector::setTimingSource, pos, value);
}
// Mythen3 Specific // Mythen3 Specific
Result<uint32_t> Detector::getCounterMask(Positions pos) const { Result<uint32_t> Detector::getCounterMask(Positions pos) const {

View File

@ -2546,6 +2546,32 @@ void slsDetector::setBurstMode(slsDetectorDefs::burstMode value) {
shm()->burstMode = value; shm()->burstMode = value;
} }
bool slsDetector::getCurrentSource() {
int retval = -1;
sendToDetector(F_GET_CURRENT_SOURCE, nullptr, retval);
FILE_LOG(logDEBUG1) << "Current source enable:" << retval;
return static_cast<bool>(retval);
}
void slsDetector::setCurrentSource(bool value) {
int arg = static_cast<int>(value);
FILE_LOG(logDEBUG1) << "Setting current source enable to " << arg;
sendToDetector(F_SET_CURRENT_SOURCE, arg, nullptr);
}
slsDetectorDefs::timingSourceType slsDetector::getTimingSource() {
int retval = -1;
sendToDetector(F_GET_TIMING_SOURCE, nullptr, retval);
FILE_LOG(logDEBUG1) << "Timing source:" << retval;
return static_cast<slsDetectorDefs::timingSourceType>(retval);
}
void slsDetector::setTimingSource(slsDetectorDefs::timingSourceType value) {
int arg = static_cast<int>(value);
FILE_LOG(logDEBUG1) << "Setting timing source to " << arg;
sendToDetector(F_SET_TIMING_SOURCE, arg, nullptr);
}
int slsDetector::setCounterBit(int cb) { int slsDetector::setCounterBit(int cb) {
int retval = -1; int retval = -1;
FILE_LOG(logDEBUG1) << "Sending counter bit " << cb; FILE_LOG(logDEBUG1) << "Sending counter bit " << cb;

View File

@ -1153,6 +1153,18 @@ class slsDetector : public virtual slsDetectorDefs {
/** [Gotthard2] BURST_OFF, BURST_INTERNAL (default), BURST_EXTERNAL */ /** [Gotthard2] BURST_OFF, BURST_INTERNAL (default), BURST_EXTERNAL */
void setBurstMode(burstMode value); void setBurstMode(burstMode value);
/** [Gotthard2] */
bool getCurrentSource();
/** default disabled */
void setCurrentSource(bool value);
/** [Gotthard2] */
slsDetectorDefs::timingSourceType getTimingSource();
/** [Gotthard2] Options: TIMING_INTERNAL, TIMING_EXTERNAL */
void setTimingSource(slsDetectorDefs::timingSourceType value);
/** /**
* Set/get counter bit in detector (Gotthard) * Set/get counter bit in detector (Gotthard)
* @param i is -1 to get, 0 to reset and any other value to set the counter * @param i is -1 to get, 0 to reset and any other value to set the counter

View File

@ -282,3 +282,62 @@ TEST_CASE("burstperiod", "[.cmd]") {
} }
TEST_CASE("currentsource", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD2) {
auto prev_val = det.getCurrentSource();
{
std::ostringstream oss;
proxy.Call("currentsource", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "currentsource 1\n");
}
{
std::ostringstream oss;
proxy.Call("currentsource", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "currentsource 0\n");
}
{
std::ostringstream oss;
proxy.Call("currentsource", {}, -1, GET, oss);
REQUIRE(oss.str() == "currentsource 0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setCurrentSource(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("currentsource", {}, -1, GET));
}
}
TEST_CASE("timingsource", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD2) {
auto prev_val = det.getTimingSource();
/* { until its activated in fpga
std::ostringstream oss;
proxy.Call("timingsource", {"external"}, -1, PUT, oss);
REQUIRE(oss.str() == "timingsource external\n");
}*/
{
std::ostringstream oss;
proxy.Call("timingsource", {"internal"}, -1, PUT, oss);
REQUIRE(oss.str() == "timingsource internal\n");
}
{
std::ostringstream oss;
proxy.Call("timingsource", {}, -1, GET, oss);
REQUIRE(oss.str() == "timingsource internal\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setTimingSource(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("timingsource", {}, -1, GET));
}
}

View File

@ -217,6 +217,18 @@ inline std::string ToString(const defs::burstMode s) {
} }
} }
inline std::string ToString(const defs::timingSourceType s) {
switch (s) {
case defs::TIMING_INTERNAL:
return std::string("internal");
case defs::TIMING_EXTERNAL:
return std::string("external");
default:
return std::string("Unknown");
}
}
// in case we already have a string // in case we already have a string
// causes a copy but might be needed in generic code // causes a copy but might be needed in generic code
inline std::string ToString(const std::string& s) { inline std::string ToString(const std::string& s) {
@ -574,6 +586,15 @@ inline defs::burstMode StringTo(const std::string& s) {
throw sls::RuntimeError("Unknown burst mode " + s); throw sls::RuntimeError("Unknown burst mode " + s);
} }
template <>
inline defs::timingSourceType StringTo(const std::string& s) {
if (s == "internal")
return defs::TIMING_INTERNAL;
if (s == "external")
return defs::TIMING_EXTERNAL;
throw sls::RuntimeError("Unknown timing source type " + s);
}
/** For types with a .str() method use this for conversion */ /** For types with a .str() method use this for conversion */
template <typename T> template <typename T>

View File

@ -444,7 +444,15 @@ class slsDetectorDefs {
enum burstMode { enum burstMode {
BURST_OFF, BURST_OFF,
BURST_INTERNAL, BURST_INTERNAL,
BURST_EXTERNAL, BURST_EXTERNAL
};
/**
* timing source for gotthard2
*/
enum timingSourceType {
TIMING_INTERNAL,
TIMING_EXTERNAL
}; };

View File

@ -192,6 +192,10 @@ enum detFuncs{
F_SET_NUM_BURSTS, F_SET_NUM_BURSTS,
F_GET_BURST_PERIOD, F_GET_BURST_PERIOD,
F_SET_BURST_PERIOD, F_SET_BURST_PERIOD,
F_GET_CURRENT_SOURCE,
F_SET_CURRENT_SOURCE,
F_GET_TIMING_SOURCE,
F_SET_TIMING_SOURCE,
NUM_DET_FUNCTIONS, NUM_DET_FUNCTIONS,
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this (detector server should not compile anyway) */ RECEIVER_ENUM_START = 256, /**< detector function should not exceed this (detector server should not compile anyway) */
@ -452,6 +456,10 @@ static const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_SET_NUM_BURSTS: return "F_SET_NUM_BURSTS"; case F_SET_NUM_BURSTS: return "F_SET_NUM_BURSTS";
case F_GET_BURST_PERIOD: return "F_GET_BURST_PERIOD"; case F_GET_BURST_PERIOD: return "F_GET_BURST_PERIOD";
case F_SET_BURST_PERIOD: return "F_SET_BURST_PERIOD"; case F_SET_BURST_PERIOD: return "F_SET_BURST_PERIOD";
case F_GET_CURRENT_SOURCE: return "F_GET_CURRENT_SOURCE";
case F_SET_CURRENT_SOURCE: return "F_SET_CURRENT_SOURCE";
case F_GET_TIMING_SOURCE: return "F_GET_TIMING_SOURCE";
case F_SET_TIMING_SOURCE: return "F_SET_TIMING_SOURCE";
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS"; case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START"; case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";

View File

@ -1,7 +1,6 @@
/** API versions */ /** API versions */
#define GITBRANCH "developer" #define GITBRANCH "developer"
#define APIMOENCH 0x200131 #define APIMOENCH 0x200131
#define APIGOTTHARD2 0x200226
#define APIMYTHEN3 0x200226 #define APIMYTHEN3 0x200226
#define APIJUNGFRAU 0x200226 #define APIJUNGFRAU 0x200226
#define APIEIGER 0x200226 #define APIEIGER 0x200226
@ -10,3 +9,4 @@
#define APIRECEIVER 0x200227 #define APIRECEIVER 0x200227
#define APIGUI 0x200227 #define APIGUI 0x200227
#define APICTB 0x200227 #define APICTB 0x200227
#define APIGOTTHARD2 0x200228