Merge pull request #170 from slsdetectorgroup/m3parallel

M3parallel
This commit is contained in:
Dhanya Thattil 2020-09-09 13:44:40 +02:00 committed by GitHub
commit 8bdfe7527f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 583 additions and 552 deletions

View File

@ -1315,7 +1315,7 @@ class Detector(CppDetectorApi):
@element
def parallel(self):
"""
[Eiger] Enable or disable the parallel readout mode of Eiger.
[Eiger][Mythen3] Enable or disable the parallel readout mode of detector.
"""
return self.getParallelMode()

View File

@ -413,252 +413,6 @@ Directory where one saves the data.
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="boxCorrection_2">
<property name="title">
<string>Options</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QRadioButton" name="radioDefaultDeadtime">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Default Dead Time</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="chkTenGiga">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;nobr&gt;
Compression using Root. Available only for Gotthard in Expert Mode.
&lt;/nobr&gt;&lt;br&gt;&lt;nobr&gt;
#r_compression#
&lt;/nobr&gt;</string>
</property>
<property name="text">
<string>10GbE</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QSpinBox" name="spinCustomDeadTime">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string>ns</string>
</property>
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>200000000</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="chkRate">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Rate:</string>
</property>
</widget>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="3">
<widget class="QRadioButton" name="radioCustomDeadtime">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Custom Dead Time:</string>
</property>
</widget>
</item>
<item row="1" column="5">
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0" colspan="6">
<widget class="QWidget" name="widgetEiger" native="true">
<property name="enabled">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridEiger">
<item row="0" column="1">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QComboBox" name="comboEigerClkDivider">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<item>
<property name="text">
<string>Full Speed</string>
</property>
</item>
<item>
<property name="text">
<string>Half Speed</string>
</property>
</item>
<item>
<property name="text">
<string>Quarter Speed</string>
</property>
</item>
</widget>
</item>
<item row="1" column="4">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblEigerFlags">
<property name="maximumSize">
<size>
<width>105</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Flags:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblClkDivider">
<property name="maximumSize">
<size>
<width>105</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Clock Divider:</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QComboBox" name="comboEigerParallelFlag">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<item>
<property name="text">
<string>Parallel</string>
</property>
</item>
<item>
<property name="text">
<string>Non Parallel</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
@ -675,6 +429,232 @@ Compression using Root. Available only for Gotthard in Expert Mode.
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="boxCorrection_2">
<property name="title">
<string>Options</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="lblClkDivider">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>105</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Clock Divider:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="comboClkDivider">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<item>
<property name="text">
<string>Full Speed</string>
</property>
</item>
<item>
<property name="text">
<string>Half Speed</string>
</property>
</item>
<item>
<property name="text">
<string>Quarter Speed</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="chkParallel">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Parallel Readout</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="chkTenGiga">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;nobr&gt;
Compression using Root. Available only for Gotthard in Expert Mode.
&lt;/nobr&gt;&lt;br&gt;&lt;nobr&gt;
#r_compression#
&lt;/nobr&gt;</string>
</property>
<property name="text">
<string>10GbE</string>
</property>
</widget>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="chkRate">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Rate:</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioDefaultDeadtime">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Default Dead Time</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QRadioButton" name="radioCustomDeadtime">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Custom Dead Time:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinCustomDeadTime">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string>ns</string>
</property>
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>200000000</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<tabstops>
@ -683,12 +663,6 @@ Compression using Root. Available only for Gotthard in Expert Mode.
<tabstop>btnOutputBrowse</tabstop>
<tabstop>comboFileFormat</tabstop>
<tabstop>chkOverwriteEnable</tabstop>
<tabstop>chkTenGiga</tabstop>
<tabstop>chkRate</tabstop>
<tabstop>radioDefaultDeadtime</tabstop>
<tabstop>radioCustomDeadtime</tabstop>
<tabstop>spinCustomDeadTime</tabstop>
<tabstop>comboEigerClkDivider</tabstop>
</tabstops>
<resources>
<include location="../include/icons.qrc"/>

View File

@ -21,7 +21,7 @@ class qTabDataOutput : public QWidget, private Ui::TabDataOutputObject {
void EnableRateCorrection();
void SetRateCorrection();
void SetSpeed(int speed);
void SetFlags();
void SetParallel(bool enable);
private:
void SetupWidgetWindow();
@ -35,11 +35,9 @@ class qTabDataOutput : public QWidget, private Ui::TabDataOutputObject {
void GetTenGigaEnable();
void GetRateCorrection();
void GetSpeed();
void GetFlags();
void GetParallel();
sls::Detector *det;
// Button group for radiobuttons for rate
QButtonGroup *btnGroupRate;
// enum for the Eiger Parallel flag
enum { PARALLEL, NONPARALLEL };
};

View File

@ -32,12 +32,20 @@ void qTabDataOutput::SetupWidgetWindow() {
radioDefaultDeadtime->setEnabled(true);
radioCustomDeadtime->setEnabled(true);
// flags and speed
widgetEiger->setVisible(true);
widgetEiger->setEnabled(true);
lblClkDivider->setEnabled(true);
comboClkDivider->setEnabled(true);
chkParallel->setEnabled(true);
break;
case slsDetectorDefs::MOENCH:
chkTenGiga->setEnabled(true);
break;
case slsDetectorDefs::MYTHEN3:
chkParallel->setEnabled(true);
break;
case slsDetectorDefs::JUNGFRAU:
lblClkDivider->setEnabled(true);
comboClkDivider->setEnabled(true);
break;
default:
break;
}
@ -74,12 +82,15 @@ void qTabDataOutput::Initialization() {
connect(spinCustomDeadTime, SIGNAL(valueChanged(int)), this,
SLOT(SetRateCorrection()));
}
// flags, speed
if (widgetEiger->isEnabled()) {
connect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this,
// parallel
if (chkParallel->isEnabled()) {
connect(chkParallel, SIGNAL(toggled(bool)), this,
SLOT(SetParallel(bool)));
}
// speed
if (comboClkDivider->isEnabled()) {
connect(comboClkDivider, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSpeed(int)));
connect(comboEigerParallelFlag, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetFlags()));
}
}
@ -359,22 +370,21 @@ void qTabDataOutput::SetRateCorrection() {
void qTabDataOutput::GetSpeed() {
LOG(logDEBUG) << "Getting Speed";
disconnect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this,
disconnect(comboClkDivider, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSpeed(int)));
try {
auto retval =
det->getSpeed().tsquash("Speed is inconsistent for all detectors.");
comboEigerClkDivider->setCurrentIndex(static_cast<int>(retval));
comboClkDivider->setCurrentIndex(static_cast<int>(retval));
}
CATCH_DISPLAY("Could not get speed.", "qTabDataOutput::GetSpeed")
connect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this,
connect(comboClkDivider, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSpeed(int)));
}
void qTabDataOutput::SetSpeed(int speed) {
LOG(logINFO) << "Setting Speed to "
<< comboEigerClkDivider->currentText().toAscii().data();
;
<< comboClkDivider->currentText().toAscii().data();
try {
det->setSpeed(static_cast<slsDetectorDefs::speedLevel>(speed));
}
@ -382,34 +392,28 @@ void qTabDataOutput::SetSpeed(int speed) {
&qTabDataOutput::GetSpeed)
}
void qTabDataOutput::GetFlags() {
LOG(logDEBUG) << "Getting readout flags";
disconnect(comboEigerParallelFlag, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetFlags()));
void qTabDataOutput::GetParallel() {
LOG(logDEBUG) << "Getting parallel readout";
disconnect(chkParallel, SIGNAL(toggled(bool)), this,
SLOT(SetParallel(bool)));
try {
auto retval = det->getParallelMode().tsquash(
"Parallel Flag is inconsistent for all detectors.");
// parallel or non parallel
if (retval)
comboEigerParallelFlag->setCurrentIndex(PARALLEL);
else
comboEigerParallelFlag->setCurrentIndex(NONPARALLEL);
chkParallel->setChecked(retval);
}
CATCH_DISPLAY("Could not get flags.", "qTabDataOutput::GetFlags")
connect(comboEigerParallelFlag, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetFlags()));
CATCH_DISPLAY("Could not get parallel readout.",
"qTabDataOutput::GetParallel")
connect(chkParallel, SIGNAL(toggled(bool)), this, SLOT(SetParallel(bool)));
}
void qTabDataOutput::SetFlags() {
auto mode =
comboEigerParallelFlag->currentIndex() == PARALLEL ? true : false;
void qTabDataOutput::SetParallel(bool enable) {
LOG(logINFO) << "Setting PArallel readout to " << enable;
try {
LOG(logINFO) << "Setting Readout Flags to "
<< comboEigerParallelFlag->currentText().toAscii().data();
det->setParallelMode(mode);
det->setParallelMode(enable);
}
CATCH_HANDLE("Could not set readout flags.", "qTabDataOutput::SetFlags",
this, &qTabDataOutput::GetFlags)
CATCH_HANDLE("Could not set parallel readout.",
"qTabDataOutput::SetParallel", this,
&qTabDataOutput::GetParallel)
}
void qTabDataOutput::Refresh() {
@ -427,9 +431,11 @@ void qTabDataOutput::Refresh() {
if (chkTenGiga->isEnabled()) {
GetTenGigaEnable();
}
if (widgetEiger->isEnabled()) {
if (chkParallel->isEnabled()) {
GetParallel();
}
if (comboClkDivider->isEnabled()) {
GetSpeed();
GetFlags();
}
LOG(logDEBUG) << "**Updated DataOutput Tab";

View File

@ -49,6 +49,10 @@
#define BASE_ASIC_RDO (0x00500) // 0x1806_0500 - 0x1806_050F
// https://git.psi.ch/sls_detectors_firmware/mythen_III_mcb/blob/master/code/hdl/asic_rdo/asic_rdo.vhd
/** Dead time Free Controller */
#define BASE_DEADTIME_FREE_CTRL (0x00580) // 0x1806_0580 - 0x1806_0587
// https://git.psi.ch/sls_detectors_firmware/mythen_III_mcb/blob/master/code/hdl/DeadTimeFreeController/DeadTimeFreeCtrl.vhd
/* UDP datagram generator */
#define BASE_UDP_RAM (0x01000) // 0x1806_1000 - 0x1806_1FFF
@ -467,4 +471,15 @@
#define ASICRDO_CNFG_RESSTRG_LNGTH_OFST (0)
#define ASICRDO_CNFG_RESSTRG_LNGTH_MSK (0x000000FF << ASICRDO_CNFG_RESSTRG_LNGTH_OFST)
/** Dead time Free Controller
* --------------------------------------------------*/
#define DEADTIME_CONFIG_REG (0x00 * REG_OFFSET + BASE_DEADTIME_FREE_CTRL)
#define DEADTIME_FREE_MODE_ENBL_OFST (0)
#define DEADTIME_FREE_MODE_ENBL_MSK (0x00000001 << DEADTIME_FREE_MODE_ENBL_OFST)
#define DEADTIME_EARLY_EXP_FIN_ERR_OFST (4)
#define DEADTIME_EARLY_EXP_FIN_ERR_MSK (0x00000001 << DEADTIME_EARLY_EXP_FIN_ERR_OFST)
// clang-format on

View File

@ -573,240 +573,28 @@ int setDynamicRange(int dr) {
}
}
/* parameters - module, speed, readout */
/* set parameters - readout */
int setModule(sls_detector_module myMod, char *mess) {
LOG(logINFO, ("Setting module\n"));
/* future implementation
// settings (not yet implemented)
setSettings((enum detectorSettings)myMod.reg);
if (myMod.reg >= 0) {
detectorModules->reg = myMod.reg;
}
// threshold
if (myMod.eV >= 0)
setThresholdEnergy(myMod.eV);
else {
// (loading a random trim file) (dont return fail)
setSettings(UNDEFINED);
LOG(logERROR,
("Settings has been changed to undefined (random trim
file)\n"));
}
*/
// dacs
for (int i = 0; i < NDAC; ++i) {
// ignore dacs with -1
if (myMod.dacs[i] != -1) {
setDAC((enum DACINDEX)i, myMod.dacs[i], 0);
if (myMod.dacs[i] != detectorDacs[i]) {
sprintf(mess, "Could not set module. Could not set dac %d\n",
i);
LOG(logERROR, (mess));
// setSettings(UNDEFINED);
// LOG(logERROR, ("Settings has been changed to undefined\n"));
return FAIL;
}
}
}
// trimbits
if (myMod.nchan == 0) {
LOG(logINFO, ("Setting module without trimbits\n"));
} else {
// set trimbits
if (setTrimbits(myMod.chanregs) == FAIL) {
sprintf(mess, "Could not set module. Could not set trimbits\n");
LOG(logERROR, (mess));
// setSettings(UNDEFINED);
// LOG(logERROR, ("Settings has been changed to undefined (random "
// "trim file)\n"));
return FAIL;
}
}
return OK;
}
int setBit(int ibit, int patword) { return patword |= (1 << ibit); }
int clearBit(int ibit, int patword) { return patword &= ~(1 << ibit); }
int setTrimbits(int *trimbits) {
LOG(logINFOBLUE, ("Setting trimbits\n"));
// validate
for (int ichan = 0; ichan < ((detectorModules)->nchan); ++ichan) {
if (trimbits[ichan] < 0 || trimbits[ichan] > 63) {
LOG(logERROR, ("Trimbit value (%d) for channel %d is invalid\n",
trimbits[ichan], ichan));
return FAIL;
}
}
LOG(logINFO, ("Trimbits validated\n"));
trimmingPrint = logDEBUG5;
uint64_t patword = 0;
int iaddr = 0;
for (int ichip = 0; ichip < NCHIP; ichip++) {
LOG(logDEBUG1, (" Chip %d\n", ichip));
iaddr = 0;
patword = 0;
writePatternWord(iaddr++, patword);
// chip select
patword = setBit(SIGNAL_TBLoad_1 + ichip, patword);
writePatternWord(iaddr++, patword);
// reset trimbits
patword = setBit(SIGNAL_resStorage, patword);
patword = setBit(SIGNAL_resCounter, patword);
writePatternWord(iaddr++, patword);
writePatternWord(iaddr++, patword);
patword = clearBit(SIGNAL_resStorage, patword);
patword = clearBit(SIGNAL_resCounter, patword);
writePatternWord(iaddr++, patword);
writePatternWord(iaddr++, patword);
// select first channel
patword = setBit(SIGNAL_CHSserialIN, patword);
writePatternWord(iaddr++, patword);
// 1 clk pulse
patword = setBit(SIGNAL_CHSclk, patword);
writePatternWord(iaddr++, patword);
patword = clearBit(SIGNAL_CHSclk, patword);
// clear 1st channel
writePatternWord(iaddr++, patword);
patword = clearBit(SIGNAL_CHSserialIN, patword);
// 2 clk pulses
for (int i = 0; i < 2; i++) {
patword = setBit(SIGNAL_CHSclk, patword);
writePatternWord(iaddr++, patword);
patword = clearBit(SIGNAL_CHSclk, patword);
writePatternWord(iaddr++, patword);
}
// for each channel (all chips)
for (int ich = 0; ich < NCHAN_1_COUNTER; ich++) {
LOG(logDEBUG1, (" Chip %d, Channel %d\n", ichip, ich));
int val = trimbits[ichip * NCHAN_1_COUNTER * NCOUNTERS +
NCOUNTERS * ich] +
trimbits[ichip * NCHAN_1_COUNTER * NCOUNTERS +
NCOUNTERS * ich + 1] *
64 +
trimbits[ichip * NCHAN_1_COUNTER * NCOUNTERS +
NCOUNTERS * ich + 2] *
64 * 64;
// push 6 0 bits
for (int i = 0; i < 6; i++) {
patword = clearBit(SIGNAL_serialIN, patword);
patword = clearBit(SIGNAL_clk, patword);
writePatternWord(iaddr++, patword);
patword = setBit(SIGNAL_clk, patword);
writePatternWord(iaddr++, patword);
}
// deserialize
for (int i = 0; i < 18; i++) {
if (val & (1 << i)) {
patword = setBit(SIGNAL_serialIN, patword);
} else {
patword = clearBit(SIGNAL_serialIN, patword);
}
patword = clearBit(SIGNAL_clk, patword);
writePatternWord(iaddr++, patword);
patword = setBit(SIGNAL_clk, patword);
writePatternWord(iaddr++, patword);
}
writePatternWord(iaddr++, patword);
writePatternWord(iaddr++, patword);
// move to next channel
for (int i = 0; i < 3; i++) {
patword = setBit(SIGNAL_CHSclk, patword);
writePatternWord(iaddr++, patword);
patword = clearBit(SIGNAL_CHSclk, patword);
writePatternWord(iaddr++, patword);
}
}
// chip unselect
patword = clearBit(SIGNAL_TBLoad_1 + ichip, patword);
writePatternWord(iaddr++, patword);
// last iaddr check
if (iaddr >= MAX_PATTERN_LENGTH) {
LOG(logERROR, ("Addr 0x%x is past max_address_length 0x%x!\n",
iaddr, MAX_PATTERN_LENGTH));
trimmingPrint = logINFO;
return FAIL;
}
// set pattern wait address
for (int i = 0; i <= 2; i++)
setPatternWaitAddress(i, MAX_PATTERN_LENGTH - 1);
// pattern loop
for (int i = 0; i <= 2; i++) {
int stop = MAX_PATTERN_LENGTH - 1, nloop = 0;
setPatternLoop(i, &stop, &stop, &nloop);
}
// pattern limits
{
int start = 0, nloop = 0;
setPatternLoop(-1, &start, &iaddr, &nloop);
}
// send pattern to the chips
startPattern();
}
// copy trimbits locally
for (int ichan = 0; ichan < ((detectorModules)->nchan); ++ichan) {
detectorChans[ichan] = trimbits[ichan];
}
trimmingPrint = logINFO;
LOG(logINFO, ("All trimbits have been loaded\n"));
return OK;
}
int setAllTrimbits(int val) {
int *trimbits = malloc(sizeof(int) * ((detectorModules)->nchan));
for (int ichan = 0; ichan < ((detectorModules)->nchan); ++ichan) {
trimbits[ichan] = val;
}
if (setTrimbits(trimbits) == FAIL) {
LOG(logERROR, ("Could not set all trimbits to %d\n", val));
free(trimbits);
int setParallelMode(int mode) {
if (mode < 0)
return FAIL;
LOG(logINFO, ("Setting %s mode\n", (mode ? "Parallel" : "Non Parallel")));
uint32_t addr = DEADTIME_CONFIG_REG;
if (mode) {
bus_w(addr, bus_r(addr) | DEADTIME_FREE_MODE_ENBL_MSK);
} else {
bus_w(addr, bus_r(addr) & ~DEADTIME_FREE_MODE_ENBL_MSK);
}
// setSettings(UNDEFINED);
// LOG(logERROR, ("Settings has been changed to undefined (random "
// "trim file)\n"));
LOG(logINFO, ("All trimbits have been set to %d\n", val));
free(trimbits);
return OK;
}
int getAllTrimbits() {
int value = detectorChans[0];
if (detectorModules) {
for (int ichan = 0; ichan < ((detectorModules)->nchan); ichan++) {
if (detectorChans[ichan] != value) {
value = -1;
break;
}
}
}
LOG(logINFO, ("Value of all Trimbits: %d\n", value));
return value;
int getParallelMode() {
return ((bus_r(DEADTIME_CONFIG_REG) & DEADTIME_FREE_MODE_ENBL_MSK) >>
DEADTIME_FREE_MODE_ENBL_OFST);
}
/* parameters - timer */
void setNumFrames(int64_t val) {
if (val > 0) {
LOG(logINFO, ("Setting number of frames %lld\n", (long long int)val));
@ -1148,6 +936,240 @@ int64_t getMeasurementTime() {
(1E-9 * FIXED_PLL_FREQUENCY);
}
/* parameters - module, speed, readout */
int setModule(sls_detector_module myMod, char *mess) {
LOG(logINFO, ("Setting module\n"));
/* future implementation
// settings (not yet implemented)
setSettings((enum detectorSettings)myMod.reg);
if (myMod.reg >= 0) {
detectorModules->reg = myMod.reg;
}
// threshold
if (myMod.eV >= 0)
setThresholdEnergy(myMod.eV);
else {
// (loading a random trim file) (dont return fail)
setSettings(UNDEFINED);
LOG(logERROR,
("Settings has been changed to undefined (random trim
file)\n"));
}
*/
// dacs
for (int i = 0; i < NDAC; ++i) {
// ignore dacs with -1
if (myMod.dacs[i] != -1) {
setDAC((enum DACINDEX)i, myMod.dacs[i], 0);
if (myMod.dacs[i] != detectorDacs[i]) {
sprintf(mess, "Could not set module. Could not set dac %d\n",
i);
LOG(logERROR, (mess));
// setSettings(UNDEFINED);
// LOG(logERROR, ("Settings has been changed to undefined\n"));
return FAIL;
}
}
}
// trimbits
if (myMod.nchan == 0) {
LOG(logINFO, ("Setting module without trimbits\n"));
} else {
// set trimbits
if (setTrimbits(myMod.chanregs) == FAIL) {
sprintf(mess, "Could not set module. Could not set trimbits\n");
LOG(logERROR, (mess));
// setSettings(UNDEFINED);
// LOG(logERROR, ("Settings has been changed to undefined (random "
// "trim file)\n"));
return FAIL;
}
}
return OK;
}
int setBit(int ibit, int patword) { return patword |= (1 << ibit); }
int clearBit(int ibit, int patword) { return patword &= ~(1 << ibit); }
int setTrimbits(int *trimbits) {
LOG(logINFOBLUE, ("Setting trimbits\n"));
// validate
for (int ichan = 0; ichan < ((detectorModules)->nchan); ++ichan) {
if (trimbits[ichan] < 0 || trimbits[ichan] > 63) {
LOG(logERROR, ("Trimbit value (%d) for channel %d is invalid\n",
trimbits[ichan], ichan));
return FAIL;
}
}
LOG(logINFO, ("Trimbits validated\n"));
trimmingPrint = logDEBUG5;
uint64_t patword = 0;
int iaddr = 0;
for (int ichip = 0; ichip < NCHIP; ichip++) {
LOG(logDEBUG1, (" Chip %d\n", ichip));
iaddr = 0;
patword = 0;
writePatternWord(iaddr++, patword);
// chip select
patword = setBit(SIGNAL_TBLoad_1 + ichip, patword);
writePatternWord(iaddr++, patword);
// reset trimbits
patword = setBit(SIGNAL_resStorage, patword);
patword = setBit(SIGNAL_resCounter, patword);
writePatternWord(iaddr++, patword);
writePatternWord(iaddr++, patword);
patword = clearBit(SIGNAL_resStorage, patword);
patword = clearBit(SIGNAL_resCounter, patword);
writePatternWord(iaddr++, patword);
writePatternWord(iaddr++, patword);
// select first channel
patword = setBit(SIGNAL_CHSserialIN, patword);
writePatternWord(iaddr++, patword);
// 1 clk pulse
patword = setBit(SIGNAL_CHSclk, patword);
writePatternWord(iaddr++, patword);
patword = clearBit(SIGNAL_CHSclk, patword);
// clear 1st channel
writePatternWord(iaddr++, patword);
patword = clearBit(SIGNAL_CHSserialIN, patword);
// 2 clk pulses
for (int i = 0; i < 2; i++) {
patword = setBit(SIGNAL_CHSclk, patword);
writePatternWord(iaddr++, patword);
patword = clearBit(SIGNAL_CHSclk, patword);
writePatternWord(iaddr++, patword);
}
// for each channel (all chips)
for (int ich = 0; ich < NCHAN_1_COUNTER; ich++) {
LOG(logDEBUG1, (" Chip %d, Channel %d\n", ichip, ich));
int val = trimbits[ichip * NCHAN_1_COUNTER * NCOUNTERS +
NCOUNTERS * ich] +
trimbits[ichip * NCHAN_1_COUNTER * NCOUNTERS +
NCOUNTERS * ich + 1] *
64 +
trimbits[ichip * NCHAN_1_COUNTER * NCOUNTERS +
NCOUNTERS * ich + 2] *
64 * 64;
// push 6 0 bits
for (int i = 0; i < 6; i++) {
patword = clearBit(SIGNAL_serialIN, patword);
patword = clearBit(SIGNAL_clk, patword);
writePatternWord(iaddr++, patword);
patword = setBit(SIGNAL_clk, patword);
writePatternWord(iaddr++, patword);
}
// deserialize
for (int i = 0; i < 18; i++) {
if (val & (1 << i)) {
patword = setBit(SIGNAL_serialIN, patword);
} else {
patword = clearBit(SIGNAL_serialIN, patword);
}
patword = clearBit(SIGNAL_clk, patword);
writePatternWord(iaddr++, patword);
patword = setBit(SIGNAL_clk, patword);
writePatternWord(iaddr++, patword);
}
writePatternWord(iaddr++, patword);
writePatternWord(iaddr++, patword);
// move to next channel
for (int i = 0; i < 3; i++) {
patword = setBit(SIGNAL_CHSclk, patword);
writePatternWord(iaddr++, patword);
patword = clearBit(SIGNAL_CHSclk, patword);
writePatternWord(iaddr++, patword);
}
}
// chip unselect
patword = clearBit(SIGNAL_TBLoad_1 + ichip, patword);
writePatternWord(iaddr++, patword);
// last iaddr check
if (iaddr >= MAX_PATTERN_LENGTH) {
LOG(logERROR, ("Addr 0x%x is past max_address_length 0x%x!\n",
iaddr, MAX_PATTERN_LENGTH));
trimmingPrint = logINFO;
return FAIL;
}
// set pattern wait address
for (int i = 0; i <= 2; i++)
setPatternWaitAddress(i, MAX_PATTERN_LENGTH - 1);
// pattern loop
for (int i = 0; i <= 2; i++) {
int stop = MAX_PATTERN_LENGTH - 1, nloop = 0;
setPatternLoop(i, &stop, &stop, &nloop);
}
// pattern limits
{
int start = 0, nloop = 0;
setPatternLoop(-1, &start, &iaddr, &nloop);
}
// send pattern to the chips
startPattern();
}
// copy trimbits locally
for (int ichan = 0; ichan < ((detectorModules)->nchan); ++ichan) {
detectorChans[ichan] = trimbits[ichan];
}
trimmingPrint = logINFO;
LOG(logINFO, ("All trimbits have been loaded\n"));
return OK;
}
int setAllTrimbits(int val) {
int *trimbits = malloc(sizeof(int) * ((detectorModules)->nchan));
for (int ichan = 0; ichan < ((detectorModules)->nchan); ++ichan) {
trimbits[ichan] = val;
}
if (setTrimbits(trimbits) == FAIL) {
LOG(logERROR, ("Could not set all trimbits to %d\n", val));
free(trimbits);
return FAIL;
}
// setSettings(UNDEFINED);
// LOG(logERROR, ("Settings has been changed to undefined (random "
// "trim file)\n"));
LOG(logINFO, ("All trimbits have been set to %d\n", val));
free(trimbits);
return OK;
}
int getAllTrimbits() {
int value = detectorChans[0];
if (detectorModules) {
for (int ichan = 0; ichan < ((detectorModules)->nchan); ichan++) {
if (detectorChans[ichan] != value) {
value = -1;
break;
}
}
}
LOG(logINFO, ("Value of all Trimbits: %d\n", value));
return value;
}
/* parameters - dac, hv */
void setDAC(enum DACINDEX ind, int val, int mV) {
if (val < 0) {
@ -2318,8 +2340,17 @@ enum runStatus getRunStatus() {
// not running
else {
// error from too short exptime in parallel mode
uint32_t deadtimeReg = bus_r(DEADTIME_CONFIG_REG);
if ((deadtimeReg & DEADTIME_EARLY_EXP_FIN_ERR_MSK) >>
DEADTIME_EARLY_EXP_FIN_ERR_OFST) {
LOG(logERROR,
("Status: ERROR in Dead Time Reg (too short exptime) %08x\n",
deadtimeReg));
s = ERROR;
}
// stopped or error
if (retval & FLOW_STATUS_FIFO_FULL_MSK) {
else if (retval & FLOW_STATUS_FIFO_FULL_MSK) {
LOG(logINFOBLUE, ("Status: STOPPED\n")); // FIFO FULL??
s = STOPPED;
} else if (retval & FLOW_STATUS_CSM_BUSY_MSK) {

View File

@ -179,9 +179,11 @@ int setExternalSampling(int val);
#endif
// parameters - readout
#ifdef EIGERD
#if defined(EIGERD) || defined(MYTHEN3D)
int setParallelMode(int mode);
int getParallelMode();
#endif
#ifdef EIGERD
int setOverFlowMode(int mode);
int getOverFlowMode();
#endif
@ -277,9 +279,9 @@ int64_t getMeasurementTime();
int setModule(sls_detector_module myMod, char *mess);
#endif
#ifdef MYTHEN3D
int setTrimbits(int *trimbits);
int setBit(int ibit, int patword);
int clearBit(int ibit, int patword);
int setTrimbits(int *trimbits);
int setAllTrimbits(int val);
int getAllTrimbits();
#endif

View File

@ -5427,7 +5427,7 @@ int set_parallel_mode(int file_des) {
return printSocketReadError();
LOG(logINFO, ("Setting parallel mode: %u\n", arg));
#ifndef EIGERD
#if !defined(EIGERD) && !defined(MYTHEN3D)
functionNotImplemented();
#else
// only set
@ -5458,7 +5458,7 @@ int get_parallel_mode(int file_des) {
LOG(logDEBUG1, ("Getting parallel mode\n"));
#ifndef EIGERD
#if !defined(EIGERD) && !defined(MYTHEN3D)
functionNotImplemented();
#else
// get only

View File

@ -393,6 +393,14 @@ class Detector {
void setExternalSignalFlags(int signalIndex, defs::externalSignalFlag value,
Positions pos = {});
/** [Eiger][Mythen3] */
Result<bool> getParallelMode(Positions pos = {}) const;
/** [Eiger][Mythen3]
* [Mythen3] If exposure time is too short, acquisition will return with an
* ERROR and take fewer frames than expected */
void setParallelMode(bool value, Positions pos = {});
/**************************************************
* *
* Acquisition *
@ -853,12 +861,6 @@ class Detector {
/** [Eiger] Directory where settings files are loaded from/to */
void setSettingsPath(const std::string &value, Positions pos = {});
/** [Eiger] */
Result<bool> getParallelMode(Positions pos = {}) const;
/** [Eiger] */
void setParallelMode(bool value, Positions pos = {});
/** [Eiger] */
Result<bool> getOverFlowMode(Positions pos = {}) const;

View File

@ -682,6 +682,7 @@ class CmdProxy {
{"powerchip", &CmdProxy::powerchip},
{"imagetest", &CmdProxy::imagetest},
{"extsig", &CmdProxy::ExternalSignal},
{"parallel", &CmdProxy::parallel},
/** temperature */
{"templist", &CmdProxy::templist},
@ -849,7 +850,6 @@ class CmdProxy {
{"threshold", &CmdProxy::Threshold},
{"thresholdnotb", &CmdProxy::ThresholdNoTb},
{"settingspath", &CmdProxy::settingspath},
{"parallel", &CmdProxy::parallel},
{"overflow", &CmdProxy::overflow},
{"flippeddatax", &CmdProxy::flippeddatax},
{"trimen", &CmdProxy::TrimEnergies},
@ -1247,6 +1247,12 @@ class CmdProxy {
"\n\t[Eiger][Jungfrau] Only for Virtual servers. If 0, each pixel "
"intensity incremented by 1. If 1, all pixels almost saturated.");
INTEGER_COMMAND(parallel, getParallelMode, setParallelMode, StringTo<int>,
"[0, 1]\n\t[Eiger][Mythen3] Enable or disable parallel "
"mode.\n\t[Mythen3] If exptime is too short, the "
"acquisition will return ERROR status and take fewer "
"frames than expected.");
/** temperature */
GET_COMMAND_NOID(
templist, getTemperatureList,
@ -1913,9 +1919,6 @@ class CmdProxy {
settingspath, getSettingsPath, setSettingsPath,
"[path]\n\t[Eiger] Directory where settings files are loaded from/to.");
INTEGER_COMMAND(parallel, getParallelMode, setParallelMode, StringTo<int>,
"[0, 1]\n\t[Eiger] Enable or disable parallel mode.");
INTEGER_COMMAND(overflow, getOverFlowMode, setOverFlowMode, StringTo<int>,
"[0, 1]\n\t[Eiger] Enable or disable show overflow flag in "
"32 bit mode. Default is disabled.");

View File

@ -575,6 +575,14 @@ void Detector::setExternalSignalFlags(int signalIndex,
pimpl->Parallel(&Module::setExternalSignalFlags, pos, signalIndex, value);
}
Result<bool> Detector::getParallelMode(Positions pos) const {
return pimpl->Parallel(&Module::getParallelMode, pos);
}
void Detector::setParallelMode(bool value, Positions pos) {
pimpl->Parallel(&Module::setParallelMode, pos, value);
}
// Acquisition
void Detector::acquire() { pimpl->acquire(); }
@ -1129,14 +1137,6 @@ void Detector::setSettingsPath(const std::string &value, Positions pos) {
pimpl->Parallel(&Module::setSettingsDir, pos, value);
}
Result<bool> Detector::getParallelMode(Positions pos) const {
return pimpl->Parallel(&Module::getParallelMode, pos);
}
void Detector::setParallelMode(bool value, Positions pos) {
pimpl->Parallel(&Module::setParallelMode, pos, value);
}
Result<bool> Detector::getOverFlowMode(Positions pos) const {
return pimpl->Parallel(&Module::getOverFlowMode, pos);
}

View File

@ -382,6 +382,14 @@ void Module::setExternalSignalFlags(int signalIndex, externalSignalFlag type) {
sendToDetector(F_SET_EXTERNAL_SIGNAL_FLAG, args, nullptr);
}
bool Module::getParallelMode() const {
return sendToDetector<int>(F_GET_PARALLEL_MODE);
}
void Module::setParallelMode(const bool enable) {
sendToDetector(F_SET_PARALLEL_MODE, static_cast<int>(enable), nullptr);
}
// Acquisition
void Module::startReceiver() {
@ -1108,14 +1116,6 @@ std::string Module::setSettingsDir(const std::string &dir) {
return shm()->settingsDir;
}
bool Module::getParallelMode() const {
return sendToDetector<int>(F_GET_PARALLEL_MODE);
}
void Module::setParallelMode(const bool enable) {
sendToDetector(F_SET_PARALLEL_MODE, static_cast<int>(enable), nullptr);
}
bool Module::getOverFlowMode() const {
return sendToDetector<int>(F_GET_OVERFLOW_MODE);
}

View File

@ -149,6 +149,8 @@ class Module : public virtual slsDetectorDefs {
int value);
externalSignalFlag getExternalSignalFlags(int signalIndex) const;
void setExternalSignalFlags(int signalIndex, externalSignalFlag type);
bool getParallelMode() const;
void setParallelMode(const bool enable);
/**************************************************
* *
@ -303,8 +305,6 @@ class Module : public virtual slsDetectorDefs {
bool trimbits);
std::string getSettingsDir() const;
std::string setSettingsDir(const std::string &dir);
bool getParallelMode() const;
void setParallelMode(const bool enable);
bool getOverFlowMode() const;
void setOverFlowMode(const bool enable);
bool getFlippedDataX() const;

View File

@ -3,11 +3,11 @@
#define APILIB 0x200810
#define APIRECEIVER 0x200810
#define APIGUI 0x200804
#define APICTB 0x200909
#define APIGOTTHARD 0x200909
#define APIGOTTHARD2 0x200909
#define APIJUNGFRAU 0x200909
#define APIMYTHEN3 0x200909
#define APIMOENCH 0x200909
#define APIEIGER 0x200909
#define APIMYTHEN3 0x200909