mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 19:30:03 +02:00
gotthard fixed roi only xmin and xmax.remove updateoffsets
This commit is contained in:
parent
2fe06c7163
commit
d4d8cbe9bc
@ -54,7 +54,7 @@
|
||||
<enum>QTabWidget::North</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="elideMode">
|
||||
<enum>Qt::ElideLeft</enum>
|
||||
@ -132,102 +132,20 @@
|
||||
<string>Region of Interest</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="btnAddRoi">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>130</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> Add ROI Slot </string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../include/icons.qrc">
|
||||
<normaloff>:/icons/images/add.png</normaloff>:/icons/images/add.png</iconset>
|
||||
<string>X Min:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QPushButton" name="btnGetRoi">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>130</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> Get ROI </string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../include/icons.qrc">
|
||||
<normaloff>:/icons/images/download.png</normaloff>:/icons/images/download.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_7">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="btnSetRoi">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>130</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> Set ROI </string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../include/icons.qrc">
|
||||
<normaloff>:/icons/images/upload.png</normaloff>:/icons/images/upload.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="6">
|
||||
<item row="1" column="8">
|
||||
<widget class="QPushButton" name="btnClearRoi">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
@ -237,12 +155,12 @@
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>130</width>
|
||||
<height>0</height>
|
||||
<width>0</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> Clear ROI </string>
|
||||
<string>Clear ROI </string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../include/icons.qrc">
|
||||
@ -250,45 +168,159 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="spinXmin">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>160</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1279</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="7">
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="7">
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
<property name="text">
|
||||
<string>X Max:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="QSpinBox" name="spinXmax">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>160</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1279</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Readout: </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="6">
|
||||
<widget class="QPushButton" name="btnSetRoi">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Set ROI </string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../include/icons.qrc">
|
||||
<normaloff>:/icons/images/refresh.png</normaloff>:/icons/images/refresh.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="5">
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="4">
|
||||
<widget class="QComboBox" name="comboReadout">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>160</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<widget class="QWidget" name="roiWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>735</width>
|
||||
<height>235</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridRoi">
|
||||
<property name="horizontalSpacing">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>15</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -399,7 +431,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Detector Control Port:</string>
|
||||
<string>Readout Control Port:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -910,7 +942,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Detector UDP MAC:</string>
|
||||
<string>Readout UDP MAC:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -929,7 +961,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Detector:</string>
|
||||
<string>Readout:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -968,7 +1000,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Detector UDP IP:</string>
|
||||
<string>Readout UDP IP:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -981,7 +1013,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Detector Stop Port:</string>
|
||||
<string>Readout Stop Port:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -1402,11 +1434,11 @@ Exposure Time of a sub frame. Only for Eiger in 32 bit mode
|
||||
<tabstops>
|
||||
<tabstop>tabAdvancedSettings</tabstop>
|
||||
<tabstop>spinSetAllTrimbits</tabstop>
|
||||
<tabstop>btnAddRoi</tabstop>
|
||||
<tabstop>comboReadout</tabstop>
|
||||
<tabstop>spinXmin</tabstop>
|
||||
<tabstop>spinXmax</tabstop>
|
||||
<tabstop>btnSetRoi</tabstop>
|
||||
<tabstop>btnGetRoi</tabstop>
|
||||
<tabstop>btnClearRoi</tabstop>
|
||||
<tabstop>scrollArea</tabstop>
|
||||
<tabstop>comboDetector</tabstop>
|
||||
<tabstop>spinControlPort</tabstop>
|
||||
<tabstop>spinStopPort</tabstop>
|
||||
|
@ -29,7 +29,6 @@ private slots:
|
||||
void SetRxrUDPMAC();
|
||||
void SetRxrZMQPort(int port);
|
||||
void SetRxrZMQIP();
|
||||
void AddROISlot();
|
||||
void GetROI();
|
||||
void ClearROI();
|
||||
void SetROI();
|
||||
@ -56,22 +55,12 @@ private:
|
||||
void GetRxrUDPMAC();
|
||||
void GetRxrZMQPort();
|
||||
void GetRxrZMQIP();
|
||||
void ClearROIWidgets();
|
||||
void GetAllTrimbits();
|
||||
void GetNumStoragecells();
|
||||
void GetSubExposureTime();
|
||||
void GetSubDeadTime();
|
||||
|
||||
multiSlsDetector *myDet;
|
||||
/** ROI */
|
||||
std::vector <QLabel*> lblFromX;
|
||||
std::vector <QSpinBox*> spinFromX;
|
||||
std::vector <QLabel*> lblFromY;
|
||||
std::vector <QSpinBox*> spinFromY;
|
||||
std::vector <QLabel*> lblToX;
|
||||
std::vector <QSpinBox*> spinToX;
|
||||
std::vector <QLabel*> lblToY;
|
||||
std::vector <QSpinBox*> spinToY;
|
||||
};
|
||||
|
||||
|
||||
|
@ -10,18 +10,7 @@ qTabAdvanced::qTabAdvanced(QWidget *parent, multiSlsDetector *detector)
|
||||
FILE_LOG(logDEBUG) << "Advanced ready";
|
||||
}
|
||||
|
||||
qTabAdvanced::~qTabAdvanced() {
|
||||
for (size_t i = 0; i < lblFromX.size(); ++i) {
|
||||
delete lblFromX[i];
|
||||
delete lblFromY[i];
|
||||
delete lblToX[i];
|
||||
delete lblToY[i];
|
||||
delete spinFromX[i];
|
||||
delete spinFromY[i];
|
||||
delete spinToX[i];
|
||||
delete spinToY[i];
|
||||
}
|
||||
}
|
||||
qTabAdvanced::~qTabAdvanced() {}
|
||||
|
||||
void qTabAdvanced::SetupWidgetWindow() {
|
||||
// enabling according to det type
|
||||
@ -93,9 +82,8 @@ void qTabAdvanced::Initialization() {
|
||||
|
||||
// roi
|
||||
if (tab_roi->isEnabled()) {
|
||||
connect(btnAddRoi, SIGNAL(clicked()), this, SLOT(AddROISlot()));
|
||||
connect(comboReadout, SIGNAL(currentIndexChanged(int)), this, SLOT(GetROI()));
|
||||
connect(btnSetRoi, SIGNAL(clicked()), this, SLOT(SetROI()));
|
||||
connect(btnGetRoi, SIGNAL(clicked()), this, SLOT(GetROI()));
|
||||
connect(btnClearRoi, SIGNAL(clicked()), this, SLOT(ClearROI()));
|
||||
}
|
||||
|
||||
@ -122,14 +110,20 @@ void qTabAdvanced::PopulateDetectors() {
|
||||
FILE_LOG(logDEBUG) << "Populating detectors";
|
||||
disconnect(comboDetector, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetDetector(int)));
|
||||
disconnect(comboReadout, SIGNAL(currentIndexChanged(int)), this, SLOT(GetROI()));
|
||||
|
||||
comboDetector->clear();
|
||||
for (unsigned int i = 0; i < myDet->size(); ++i)
|
||||
comboReadout->clear();
|
||||
for (unsigned int i = 0; i < myDet->size(); ++i) {
|
||||
comboDetector->addItem(QString(myDet->getHostname(i).c_str()));
|
||||
comboReadout->addItem(QString(myDet->getHostname(i).c_str()));
|
||||
}
|
||||
comboDetector->setCurrentIndex(0);
|
||||
comboReadout->setCurrentIndex(0);
|
||||
|
||||
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetDetector(int)));
|
||||
connect(comboReadout, SIGNAL(currentIndexChanged(int)), this, SLOT(GetROI()));
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetControlPort() {
|
||||
@ -462,173 +456,33 @@ void qTabAdvanced::SetRxrZMQIP() {
|
||||
&qTabAdvanced::GetRxrZMQIP)
|
||||
}
|
||||
|
||||
void qTabAdvanced::AddROISlot() {
|
||||
FILE_LOG(logDEBUG) << "Add ROI Slot";
|
||||
|
||||
QLabel *lFromX = new QLabel("x min:");
|
||||
QLabel *lFromY = new QLabel("y min:");
|
||||
QLabel *lToX = new QLabel("x max:");
|
||||
QLabel *lToY = new QLabel("y max:");
|
||||
QSpinBox *sFromX = new QSpinBox();
|
||||
QSpinBox *sFromY = new QSpinBox();
|
||||
QSpinBox *sToX = new QSpinBox();
|
||||
QSpinBox *sToY = new QSpinBox();
|
||||
lFromX->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
lFromY->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
lToX->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
lToY->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
sFromX->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
sFromY->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
sToX->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
sToY->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
lFromX->setFixedWidth(50);
|
||||
lFromY->setFixedWidth(50);
|
||||
lToX->setFixedWidth(50);
|
||||
lToY->setFixedWidth(50);
|
||||
sFromX->setFixedWidth(80);
|
||||
sFromY->setFixedWidth(80);
|
||||
sToX->setFixedWidth(80);
|
||||
sToY->setFixedWidth(80);
|
||||
sFromX->setFixedHeight(19);
|
||||
sFromY->setFixedHeight(19);
|
||||
sToX->setFixedHeight(19);
|
||||
sToY->setFixedHeight(19);
|
||||
sFromX->setMaximum(myDet->getTotalNumberOfChannels(slsDetectorDefs::X) - 1);
|
||||
sToX->setMaximum(myDet->getTotalNumberOfChannels(slsDetectorDefs::X) - 1);
|
||||
sFromY->setMaximum(myDet->getTotalNumberOfChannels(slsDetectorDefs::Y) - 1);
|
||||
sToY->setMaximum(myDet->getTotalNumberOfChannels(slsDetectorDefs::Y) - 1);
|
||||
sFromX->setMinimum(-1);
|
||||
sToX->setMinimum(-1);
|
||||
sFromY->setMinimum(-1);
|
||||
sToY->setMinimum(-1);
|
||||
sFromX->setValue(-1);
|
||||
sFromY->setValue(-1);
|
||||
sToX->setValue(-1);
|
||||
sToY->setValue(-1);
|
||||
|
||||
lblFromX.push_back(lFromX);
|
||||
lblFromY.push_back(lFromY);
|
||||
lblToX.push_back(lToX);
|
||||
lblToY.push_back(lToY);
|
||||
spinFromX.push_back(sFromX);
|
||||
spinFromY.push_back(sFromY);
|
||||
spinToX.push_back(sToX);
|
||||
spinToY.push_back(sToY);
|
||||
|
||||
int nroi = (int)lblFromX.size();
|
||||
gridRoi->addWidget(lblFromX[nroi], nroi, 0, Qt::AlignTop);
|
||||
gridRoi->addWidget(spinFromX[nroi], nroi, 1, Qt::AlignTop);
|
||||
// FIXME: gridRoi->addItem(new
|
||||
// QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed),
|
||||
// nroi,2,Qt::AlignTop);
|
||||
gridRoi->addWidget(lblToX[nroi], nroi, 3, Qt::AlignTop);
|
||||
gridRoi->addWidget(spinToX[nroi], nroi, 4, Qt::AlignTop);
|
||||
// FIXME: gridRoi->addItem(new
|
||||
// QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed),
|
||||
// nroi,5,Qt::AlignTop);
|
||||
gridRoi->addWidget(lblFromY[nroi], nroi, 6, Qt::AlignTop);
|
||||
gridRoi->addWidget(spinFromY[nroi], nroi, 7, Qt::AlignTop);
|
||||
// FIXME: gridRoi->addItem(new
|
||||
// QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed),
|
||||
// nroi,8,Qt::AlignTop);
|
||||
gridRoi->addWidget(lblToY[nroi], nroi, 9, Qt::AlignTop);
|
||||
gridRoi->addWidget(spinToY[nroi], nroi, 10, Qt::AlignTop);
|
||||
|
||||
lblFromX[nroi]->show();
|
||||
spinFromX[nroi]->show();
|
||||
lblToX[nroi]->show();
|
||||
spinToX[nroi]->show();
|
||||
lblFromY[nroi]->show();
|
||||
spinFromY[nroi]->show();
|
||||
lblToY[nroi]->show();
|
||||
spinToY[nroi]->show();
|
||||
|
||||
FILE_LOG(logDEBUG) << "ROI Inputs added";
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetROI() {
|
||||
FILE_LOG(logDEBUG) << "Getting ROI";
|
||||
ClearROIWidgets();
|
||||
|
||||
try {
|
||||
int nroi = 0;
|
||||
const slsDetectorDefs::ROI *roi = myDet->getROI(nroi);
|
||||
if (roi != nullptr) {
|
||||
for (int i = 0; i < nroi; ++i) {
|
||||
AddROISlot();
|
||||
spinFromX[i]->setValue(roi[i].xmin);
|
||||
spinFromY[i]->setValue(roi[i].ymin);
|
||||
spinToX[i]->setValue(roi[i].xmax);
|
||||
spinToY[i]->setValue(roi[i].ymax);
|
||||
}
|
||||
FILE_LOG(logDEBUG) << "ROIs populated: " << nroi;
|
||||
}
|
||||
|
||||
slsDetectorDefs::ROI roi = myDet->getROI(comboReadout->currentIndex());
|
||||
spinXmin->setValue(roi.xmin);
|
||||
spinXmax->setValue(roi.xmax);
|
||||
} CATCH_DISPLAY ("Could not get ROI.", "qTabAdvanced::GetROI")
|
||||
}
|
||||
|
||||
void qTabAdvanced::ClearROIWidgets() {
|
||||
FILE_LOG(logDEBUG) << "Clear ROI Widgets";
|
||||
|
||||
// hide widgets
|
||||
QLayoutItem *item;
|
||||
while ((item = gridRoi->takeAt(0))) {
|
||||
if (item->widget()) {
|
||||
item->widget()->hide();
|
||||
gridRoi->removeWidget(item->widget());
|
||||
}
|
||||
}
|
||||
|
||||
// delete widgets
|
||||
for (size_t i = 0; i < lblFromX.size(); ++i) {
|
||||
delete lblFromX[i];
|
||||
delete spinFromX[i];
|
||||
delete lblToX[i];
|
||||
delete spinToY[i];
|
||||
delete lblFromY[i];
|
||||
delete spinFromY[i];
|
||||
delete lblToY[i];
|
||||
delete spinToY[i];
|
||||
}
|
||||
lblFromX.clear();
|
||||
spinFromX.clear();
|
||||
lblToX.clear();
|
||||
spinToY.clear();
|
||||
lblFromY.clear();
|
||||
spinFromY.clear();
|
||||
lblToY.clear();
|
||||
spinToY.clear();
|
||||
}
|
||||
|
||||
void qTabAdvanced::ClearROI() {
|
||||
FILE_LOG(logINFO) << "Clearing ROI";
|
||||
if (QMessageBox::warning(
|
||||
this, "Clear ROI",
|
||||
"Are you sure you want to clear all the ROI in detector?",
|
||||
QMessageBox::Yes | QMessageBox::No,
|
||||
QMessageBox::No) == QMessageBox::Yes) {
|
||||
|
||||
ClearROIWidgets();
|
||||
SetROI();
|
||||
FILE_LOG(logDEBUG) << "ROIs cleared";
|
||||
}
|
||||
spinXmin->setValue(-1);
|
||||
spinXmax->setValue(-1);
|
||||
SetROI();
|
||||
FILE_LOG(logDEBUG) << "ROIs cleared";
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetROI() {
|
||||
// get roi from widgets
|
||||
int nroi = (int)lblFromX.size();
|
||||
slsDetectorDefs::ROI roi[nroi];
|
||||
for (int i = 0; i < nroi; ++i) {
|
||||
roi[i].xmin = spinFromX[i]->value();
|
||||
roi[i].ymin = spinFromY[i]->value();
|
||||
roi[i].xmax = spinToX[i]->value();
|
||||
roi[i].ymax = spinToY[i]->value();
|
||||
}
|
||||
|
||||
slsDetectorDefs::ROI roi;
|
||||
roi.xmin = spinXmin->value();
|
||||
roi.xmax = spinXmax->value();
|
||||
|
||||
// set roi
|
||||
FILE_LOG(logINFO) << "Setting ROI:" << nroi;
|
||||
FILE_LOG(logINFO) << "Setting ROI: [" << roi.xmin << ", " << roi.xmax << "]";
|
||||
try {
|
||||
myDet->setROI(nroi, roi, -1);
|
||||
myDet->setROI(roi, comboReadout->currentIndex());
|
||||
} CATCH_DISPLAY ("Could not set these ROIs.",
|
||||
"qTabAdvanced::SetROI")
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
@ -37,8 +37,7 @@ int digitalTestBit = 0;
|
||||
|
||||
// roi configuration
|
||||
int adcConfigured = -1;
|
||||
ROI rois[MAX_ROIS];
|
||||
int nROI = 0;
|
||||
ROI rois;
|
||||
int ipPacketSize = 0;
|
||||
int udpPacketSize = 0;
|
||||
|
||||
@ -397,7 +396,9 @@ void setupDetector() {
|
||||
bus_w(TEMP_SPI_OUT_REG, 0x0);
|
||||
|
||||
// roi, gbit readout
|
||||
setROIADC(-1); // set adcsyncreg, daqreg, chipofinterestreg, cleanfifos,
|
||||
rois.xmin = -1;
|
||||
rois.xmax = -1;
|
||||
setROI(rois);// set adcsyncreg, daqreg, chipofinterestreg, cleanfifos,
|
||||
setGbitReadout();
|
||||
|
||||
// master, slave (25um)
|
||||
@ -726,95 +727,49 @@ int setDynamicRange(int dr){
|
||||
return DYNAMIC_RANGE;
|
||||
}
|
||||
|
||||
ROI* setROI(int n, ROI arg[], int *retvalsize, int *ret) {
|
||||
int setROI(ROI arg) {
|
||||
|
||||
// set ROI
|
||||
if(n >= 0){
|
||||
// print
|
||||
if (!n) {
|
||||
FILE_LOG(logINFO, ("Clearing ROI\n"));
|
||||
} else {
|
||||
FILE_LOG(logINFO, ("Setting ROI:\n"));
|
||||
int i = 0;
|
||||
for (i = 0; i < n; ++i) {
|
||||
FILE_LOG(logINFO, ("\t(%d, %d)\n", arg[i].xmin, arg[i].xmax));
|
||||
}
|
||||
int adc = -1;
|
||||
if (arg.xmin == -1) {
|
||||
FILE_LOG(logINFO, ("Clearing ROI\n"));
|
||||
rois.xmin = -1;
|
||||
rois.xmax = -1;
|
||||
} else {
|
||||
FILE_LOG(logINFO, ("Setting ROI:(%d, %d)\n", arg.xmin, arg.xmax));
|
||||
// validation
|
||||
// xmin divisible by 256 and less than 1280
|
||||
if (((arg.xmin % NCHAN_PER_ADC) != 0) || (arg.xmin >= (NCHAN * NCHIP))) {
|
||||
FILE_LOG(logERROR, ("Could not set roi. xmin is invalid\n"));
|
||||
return FAIL;
|
||||
}
|
||||
// only one ROI allowed per module
|
||||
if (n > 1) {
|
||||
FILE_LOG(logERROR, ("\tCannot set more than 1 ROI per module\n"));
|
||||
*ret = FAIL;
|
||||
*retvalsize = nROI;
|
||||
return rois;
|
||||
// xmax must be 255 more than xmin
|
||||
if (arg.xmax != (arg.xmin + NCHAN_PER_ADC - 1)) {
|
||||
FILE_LOG(logERROR, ("Could not set roi. xmax is invalid\n"));
|
||||
return FAIL;
|
||||
}
|
||||
rois.xmin = arg.xmin;
|
||||
rois.xmax = arg.xmax;
|
||||
adc = arg.xmin / NCHAN_PER_ADC;
|
||||
}
|
||||
FILE_LOG(logINFO, ("\tAdc to be configured: %d\n", adc));
|
||||
FILE_LOG(logINFO, ("\tROI to be configured: (%d, %d)\n",
|
||||
(adc == -1) ? 0 : (rois.xmin),
|
||||
(adc == -1) ? (NCHIP * NCHAN - 1) : (rois.xmax)));
|
||||
|
||||
//clear all rois
|
||||
nROI = 0;
|
||||
//set adc of interest
|
||||
setROIADC(adc);
|
||||
return OK;
|
||||
}
|
||||
|
||||
// find adc number and recorrect channel limits
|
||||
int adc = -1;
|
||||
if (n) {
|
||||
// all channels
|
||||
if ((arg[0].xmin <= 0) && (arg[0].xmax >= NCHIP * NCHAN))
|
||||
adc = -1;
|
||||
// single adc
|
||||
else {
|
||||
//adc = mid value/numchans
|
||||
adc = ((((arg[0].xmax) + (arg[0].xmin))/2) / (NCHAN * NCHIPS_PER_ADC));
|
||||
// incorrect adc
|
||||
if((adc < 0) || (adc > 4)) {
|
||||
FILE_LOG(logERROR, ("\tadc value greater than 5. deleting roi\n"));
|
||||
adc = -1;
|
||||
}
|
||||
// recorrect roi values
|
||||
else {
|
||||
rois[0].xmin = adc * (NCHAN * NCHIPS_PER_ADC);
|
||||
rois[0].xmax = (adc + 1) * (NCHAN * NCHIPS_PER_ADC) - 1;
|
||||
rois[0].ymin = -1;
|
||||
rois[0].ymax = -1;
|
||||
nROI = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (adc == -1)
|
||||
nROI = 0;
|
||||
|
||||
FILE_LOG(logINFO, ("\tAdc to be configured: %d\n", adc));
|
||||
FILE_LOG(logINFO, ("\tROI to be configured: (%d, %d)\n",
|
||||
(adc == -1) ? 0 : (rois[0].xmin),
|
||||
(adc == -1) ? (NCHIP * NCHAN - 1) : (rois[0].xmax)));
|
||||
|
||||
// could not set roi
|
||||
if((n != 0) && ((arg[0].xmin != rois[0].xmin)||
|
||||
(arg[0].xmax != rois[0].xmax)||
|
||||
(arg[0].ymin != rois[0].ymin)||
|
||||
(arg[0].ymax != rois[0].ymax))) {
|
||||
*ret = FAIL;
|
||||
FILE_LOG(logERROR, ("\tCould not set given ROI\n"));
|
||||
}
|
||||
if(n != nROI) {
|
||||
*ret = FAIL;
|
||||
FILE_LOG(logERROR, ("\tCould not set or clear ROIs\n"));
|
||||
}
|
||||
|
||||
//set adc of interest
|
||||
setROIADC(adc);
|
||||
} else FILE_LOG(logINFO, ("Getting ROI:\n"));
|
||||
ROI getROI() {
|
||||
FILE_LOG(logINFO, ("Getting ROI:\n"));
|
||||
|
||||
// print
|
||||
if (!nROI) {
|
||||
if (rois.xmin == -1) {
|
||||
FILE_LOG(logINFO, ("\tROI: None\n"));
|
||||
} else {
|
||||
FILE_LOG(logINFO, ("ROI:\n"));
|
||||
int i = 0;
|
||||
for (i = 0; i < nROI; ++i) {
|
||||
FILE_LOG(logINFO, ("\t(%d, %d)\n", rois[i].xmin, rois[i].xmax));
|
||||
|
||||
}
|
||||
FILE_LOG(logINFO, ("ROI: (%d,%d)\n", rois.xmin, rois.xmax));
|
||||
}
|
||||
|
||||
*retvalsize = nROI;
|
||||
return rois;
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ enum DACINDEX {VREF_DS, VCASCN_PB, VCASCP_PB, VOUT_CM, VCASC_OUT, VIN
|
||||
#define NCHIP (10)
|
||||
#define NDAC (8)
|
||||
#define NCHIPS_PER_ADC (2)
|
||||
#define NCHAN_PER_ADC (256)
|
||||
#define DYNAMIC_RANGE (16)
|
||||
#define NUM_BITS_PER_PIXEL (DYNAMIC_RANGE / 8)
|
||||
#define DATA_BYTES (NCHIP * NCHAN * NUM_BITS_PER_PIXEL)
|
||||
|
@ -114,7 +114,8 @@ void resetPeripheral();
|
||||
// parameters - dr, roi
|
||||
int setDynamicRange(int dr);
|
||||
#ifdef GOTTHARDD
|
||||
ROI* setROI(int n, ROI arg[], int *retvalsize, int *ret);
|
||||
int setROI(ROI arg);
|
||||
ROI getROI();
|
||||
#endif
|
||||
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
||||
int setADCEnableMask(uint32_t mask);
|
||||
|
@ -189,6 +189,7 @@ const char* getFunctionName(enum detFuncs func) {
|
||||
case F_SET_DYNAMIC_RANGE: return "F_SET_DYNAMIC_RANGE";
|
||||
case F_SET_READOUT_FLAGS: return "F_SET_READOUT_FLAGS";
|
||||
case F_SET_ROI: return "F_SET_ROI";
|
||||
case F_GET_ROI: return "F_GET_ROI";
|
||||
case F_SET_SPEED: return "F_SET_SPEED";
|
||||
case F_EXIT_SERVER: return "F_EXIT_SERVER";
|
||||
case F_LOCK_SERVER: return "F_LOCK_SERVER";
|
||||
@ -279,6 +280,7 @@ void function_table() {
|
||||
flist[F_SET_DYNAMIC_RANGE] = &set_dynamic_range;
|
||||
flist[F_SET_READOUT_FLAGS] = &set_readout_flags;
|
||||
flist[F_SET_ROI] = &set_roi;
|
||||
flist[F_GET_ROI] = &get_roi;
|
||||
flist[F_SET_SPEED] = &set_speed;
|
||||
flist[F_EXIT_SERVER] = &exit_server;
|
||||
flist[F_LOCK_SERVER] = &lock_server;
|
||||
@ -1896,76 +1898,49 @@ int set_readout_flags(int file_des) {
|
||||
int set_roi(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int narg = -1;
|
||||
ROI arg[MAX_ROIS];
|
||||
int nretval = -1;
|
||||
ROI* retval = NULL;
|
||||
ROI arg;
|
||||
|
||||
// receive number of ROIs
|
||||
if (receiveData(file_des, &narg, sizeof(narg), INT32) < 0)
|
||||
// receive ROI
|
||||
if (receiveData(file_des, &arg.xmin, sizeof(int), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
// receive ROIs
|
||||
{
|
||||
int iloop = 0;
|
||||
for (iloop = 0; iloop < narg; ++iloop) {
|
||||
if (receiveData(file_des, &arg[iloop].xmin, sizeof(int), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
if (receiveData(file_des, &arg[iloop].xmax, sizeof(int), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
if (receiveData(file_des, &arg[iloop].ymin, sizeof(int), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
if (receiveData(file_des, &arg[iloop].ymax, sizeof(int), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
}
|
||||
}
|
||||
FILE_LOG(logDEBUG1, ("Set ROI (narg:%d)\n", narg));
|
||||
{
|
||||
int iloop = 0;
|
||||
for (iloop = 0; iloop < narg; ++iloop) {
|
||||
FILE_LOG(logDEBUG1, ("%d: %d\t%d\t%d\t%d\n",
|
||||
arg[iloop].xmin, arg[iloop].xmax, arg[iloop].ymin, arg[iloop].ymax));
|
||||
}
|
||||
}
|
||||
if (receiveData(file_des, &arg.xmax, sizeof(int), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
FILE_LOG(logDEBUG1, ("Set ROI: [%d, %d]\n", arg.xmin, arg.xmax));
|
||||
|
||||
#ifndef GOTTHARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// set & get
|
||||
if ((narg == GET_READOUT_FLAGS) || (Server_VerifyLock() == OK)) {
|
||||
if (myDetectorType == GOTTHARD && narg > 1) {
|
||||
ret = FAIL;
|
||||
strcpy(mess,"Can not set more than one ROI per module.\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
} else {
|
||||
retval = setROI(narg, arg, &nretval, &ret);
|
||||
if (ret == FAIL) {
|
||||
if (nretval == -1) // chip test board
|
||||
sprintf(mess,"Could not set ROI. Max ROI level (100) reached!\n");
|
||||
else if (nretval == -2)
|
||||
sprintf(mess, "Could not set ROI. Could not allocate RAM\n");
|
||||
else
|
||||
sprintf(mess,"Could not set all roi. "
|
||||
"Set %d rois, but read %d rois\n", narg, nretval);
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
FILE_LOG(logDEBUG1, ("nRois: %d\n", nretval));
|
||||
}
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
ret = setROI(arg);
|
||||
if (ret == FAIL) {
|
||||
sprintf(mess, "Could not set ROI. Invalid xmin or xmax\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Server_SendResult(file_des, INT32, UPDATE, NULL, 0);
|
||||
return Server_SendResult(file_des, INT32, UPDATE, NULL, 0);
|
||||
}
|
||||
|
||||
|
||||
int get_roi(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
ROI retval;
|
||||
|
||||
#ifndef GOTTHARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only get
|
||||
retval = getROI();
|
||||
FILE_LOG(logDEBUG1, ("nRois: (%d, %d)\n", retval.xmin, retval.xmax));
|
||||
#endif
|
||||
|
||||
Server_SendResult(file_des, INT32, UPDATE, NULL, 0);
|
||||
if (ret != FAIL) {
|
||||
//retvalsize could be swapped during sendData
|
||||
int nretval1 = nretval;
|
||||
sendData(file_des, &nretval1, sizeof(nretval1), INT32);
|
||||
int iloop = 0;
|
||||
for(iloop = 0; iloop < nretval; ++iloop) {
|
||||
sendData(file_des, &retval[iloop].xmin, sizeof(int), INT32);
|
||||
sendData(file_des, &retval[iloop].xmax, sizeof(int), INT32);
|
||||
sendData(file_des, &retval[iloop].ymin, sizeof(int), INT32);
|
||||
sendData(file_des, &retval[iloop].ymax, sizeof(int), INT32);
|
||||
}
|
||||
sendData(file_des, &retval.xmin, sizeof(int), INT32);
|
||||
sendData(file_des, &retval.xmax, sizeof(int), INT32);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -1973,7 +1948,6 @@ int set_roi(int file_des) {
|
||||
|
||||
|
||||
|
||||
|
||||
int set_speed(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
@ -2284,20 +2258,9 @@ int send_update(int file_des) {
|
||||
|
||||
// roi
|
||||
#if defined(GOTTHARDD)
|
||||
ROI* retval = NULL;
|
||||
ROI arg[1];
|
||||
int ret = OK, nretval = 0;
|
||||
retval = setROI(-1, arg, &nretval, &ret);
|
||||
//retvalsize could be swapped during sendData
|
||||
int nretval1 = nretval;
|
||||
sendData(file_des, &nretval1, sizeof(nretval1), INT32);
|
||||
int iloop = 0;
|
||||
for(iloop = 0; iloop < nretval; ++iloop) {
|
||||
sendData(file_des, &retval[iloop].xmin, sizeof(int), INT32);
|
||||
sendData(file_des, &retval[iloop].xmax, sizeof(int), INT32);
|
||||
sendData(file_des, &retval[iloop].ymin, sizeof(int), INT32);
|
||||
sendData(file_des, &retval[iloop].ymax, sizeof(int), INT32);
|
||||
}
|
||||
ROI retval = getROI();
|
||||
sendData(file_des, &retval.xmin, sizeof(int), INT32);
|
||||
sendData(file_des, &retval.xmax, sizeof(int), INT32);
|
||||
#endif
|
||||
|
||||
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
||||
|
@ -49,6 +49,7 @@ int get_time_left(int);
|
||||
int set_dynamic_range(int);
|
||||
int set_readout_flags(int);
|
||||
int set_roi(int);
|
||||
int get_roi(int);
|
||||
int set_speed(int);
|
||||
int exit_server(int);
|
||||
int lock_server(int);
|
||||
|
@ -82,16 +82,10 @@ class Detector {
|
||||
/**
|
||||
* Sets the maximum number of channels of complete detector in both
|
||||
* dimensions. -1 means no limit in this dimension. This value is used to
|
||||
* calculate row and column offsets for each module.
|
||||
* calculate row and column channels for each module.
|
||||
*/
|
||||
void setMaxNumberOfChannels(const defs::coordinates value);
|
||||
|
||||
/** [Gotthard] */
|
||||
Result<defs::coordinates> getDetectorOffsets(Positions pos = {}) const;
|
||||
|
||||
/** [Gotthard] */
|
||||
void setDetectorOffsets(defs::coordinates value, Positions pos = {});
|
||||
|
||||
/** [Eiger with specific quad hardware] */
|
||||
Result<bool> getQuad(Positions pos = {}) const;
|
||||
|
||||
@ -664,15 +658,16 @@ class Detector {
|
||||
/** [Eiger] If it is set, it resets chips completely (else partially) before an acquisition TODO: if it makes sense */
|
||||
void setCounterBit(bool value, Positions pos = {});
|
||||
|
||||
/** [Gotthard, CTB]*/
|
||||
Result<std::vector<defs::ROI>> getROI(Positions pos = {}) const;
|
||||
/** [Gotthard]*/
|
||||
Result<defs::ROI> getROI(Positions pos = {}) const;
|
||||
|
||||
/**
|
||||
* [Gotthard Options: Only a single chip or all chips, only 1 ROI allowed]
|
||||
* [CTB: multiple ROIs allowed]
|
||||
* subset modules not allowed
|
||||
* [Gotthard]
|
||||
* Options: Only a single ROI per module
|
||||
* Can set only a single ROI at a time
|
||||
* @param module position index
|
||||
*/
|
||||
void setROI(std::vector<defs::ROI> value, Positions pos = {});
|
||||
void setROI(defs::ROI value, int moduleId);
|
||||
|
||||
/** [CTB]*/
|
||||
Result<uint32_t> getADCEnableMask(Positions pos = {}) const;
|
||||
|
@ -65,16 +65,6 @@ struct sharedMultiSlsDetector {
|
||||
/** total number of channels including gap pixels in one dimension */
|
||||
int numberOfChannelInclGapPixels[2];
|
||||
|
||||
/** total number of channels for all detectors */
|
||||
int maxNumberOfChannels;
|
||||
|
||||
/** max number of channels for all detectors in one dimension*/
|
||||
int maxNumberOfChannel[2];
|
||||
|
||||
/** max number of channels including gap pixels for all detectors in
|
||||
* one dimension*/
|
||||
int maxNumberOfChannelInclGapPixels[2];
|
||||
|
||||
/** max number of channels allowed for the complete set of detectors in
|
||||
* one dimension */
|
||||
int maxNumberOfChannelsPerDetector[2];
|
||||
@ -432,8 +422,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
|
||||
|
||||
/**
|
||||
* Returns the maximum number of channels of all sls detectors in each
|
||||
* dimension d from shared memory. multi detector shared memory variable to
|
||||
* calculate offsets for each sls detector
|
||||
* dimension d from shared memory.
|
||||
* @param d dimension d
|
||||
* @returns the maximum number of channels of all sls detectors in dimension
|
||||
* d
|
||||
@ -442,8 +431,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
|
||||
|
||||
/**
|
||||
* Sets the maximum number of channels of all sls detectors in each
|
||||
* dimension d from shared memory, multi detector shared memory variable to
|
||||
* calculate offsets for each sls detector
|
||||
* dimension d from shared memory
|
||||
* @param d dimension d
|
||||
* @param i maximum number of channels for multi structure in dimension d
|
||||
* @returns the maximum number of channels of all sls detectors in dimension
|
||||
@ -453,37 +441,18 @@ class multiSlsDetector : public virtual slsDetectorDefs {
|
||||
|
||||
/**
|
||||
* Returns maximum number of channels of all sls detectors in each
|
||||
* dimension d from shared memory, multi detector shared memory variable to
|
||||
* calculate offsets for each sls detector
|
||||
* dimension d from shared memory
|
||||
* @returns maximum number of channels of all sls detectors
|
||||
*/
|
||||
slsDetectorDefs::coordinates getMaxNumberOfChannels() const; //
|
||||
|
||||
/**
|
||||
* Sets maximum number of channels of all sls detectors in each
|
||||
* dimension d from shared memory, multi detector shared memory variable to
|
||||
* calculate offsets for each sls detector
|
||||
* dimension d from shared memory
|
||||
* @param c maximum number of channels of all sls detectors
|
||||
*/
|
||||
void setMaxNumberOfChannels(const slsDetectorDefs::coordinates c); //
|
||||
|
||||
/**
|
||||
* Get Detector offset from shared memory in dimension d
|
||||
* @param d dimension d
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns offset in dimension d, -1 if pos is not an actual position in
|
||||
* list
|
||||
*/
|
||||
int getDetectorOffset(dimension d, int detPos = -1); //
|
||||
|
||||
/**
|
||||
* Set Detector offset in shared memory in dimension d
|
||||
* @param d dimension d
|
||||
* @param off offset for detector
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
*/
|
||||
void setDetectorOffset(dimension d, int off, int detPos = -1);//
|
||||
|
||||
/**
|
||||
* Get Quad Type (Only for Eiger Quad detector hardware)
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
@ -1376,22 +1345,27 @@ class multiSlsDetector : public virtual slsDetectorDefs {
|
||||
int setCounterBit(int i = -1, int detPos = -1); //
|
||||
|
||||
/**
|
||||
* Set ROI (Gotthard)
|
||||
* At the moment only one set allowed
|
||||
* @param n number of rois
|
||||
* @param roiLimits array of roi
|
||||
* Clear ROI (Gotthard)
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
*/
|
||||
void setROI(int n = -1, ROI roiLimits[] = nullptr, int detPos = -1);
|
||||
void clearROI(int detPos = -1);
|
||||
|
||||
/**
|
||||
* Get ROI from each detector and convert it to the multi detector scale
|
||||
* (Gotthard)
|
||||
* @param n number of rois
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns OK or FAIL
|
||||
* Set ROI (Gotthard)
|
||||
* At the moment only one set allowed per module
|
||||
* Only allowed to set one ROI per module
|
||||
* @param arg roi
|
||||
* @param detPos specific detector position
|
||||
*/
|
||||
const ROI *getROI(int &n, int detPos = -1);
|
||||
void setROI(slsDetectorDefs::ROI arg, int detPos = -1);
|
||||
|
||||
/**
|
||||
* Get ROI (Gotthard)
|
||||
* Only allowed to set one ROI per module
|
||||
* @param detPos specific detector position
|
||||
* @returns roi
|
||||
*/
|
||||
slsDetectorDefs::ROI getROI(int detPos) const;
|
||||
|
||||
/**
|
||||
* Set ADC Enable Mask (CTB, Moench)
|
||||
@ -2187,14 +2161,6 @@ class multiSlsDetector : public virtual slsDetectorDefs {
|
||||
*/
|
||||
void initializeMembers(bool verify = true);
|
||||
|
||||
/**
|
||||
* Appends detectors to the end of the list in shared memory
|
||||
* Connects to them
|
||||
* @param name concatenated hostname of the sls detectors to be appended to
|
||||
* the list
|
||||
*/
|
||||
void addMultipleDetectors(const char *name);//
|
||||
|
||||
/**
|
||||
* Update user details in detector structure
|
||||
*/
|
||||
@ -2206,23 +2172,6 @@ class multiSlsDetector : public virtual slsDetectorDefs {
|
||||
*/
|
||||
bool isAcquireReady();
|
||||
|
||||
/**
|
||||
* Decodes which detector and the corresponding channel numbers for it
|
||||
* Mainly useful in a multi detector setROI (Gotthard)
|
||||
* @param offsetX channel number or total channel offset in x direction
|
||||
* @param offsetY channel number or total channel offset in y direction
|
||||
* @param channelX channel number from detector offset in x direction
|
||||
* @param channelY channel number from detector offset in x direction
|
||||
* @returns detector id or -1 if channel number out of range
|
||||
*/
|
||||
int decodeNChannel(int offsetX, int offsetY, int &channelX, int &channelY);
|
||||
|
||||
/**
|
||||
* Updates the channel offsets in X and Y dimension for all the sls
|
||||
* detectors It is required for decodeNMod and setting ROI
|
||||
*/
|
||||
void updateOffsets();
|
||||
|
||||
/**
|
||||
* Execute in command line and return result
|
||||
* @param cmd command
|
||||
@ -2230,12 +2179,26 @@ class multiSlsDetector : public virtual slsDetectorDefs {
|
||||
*/
|
||||
std::string exec(const char *cmd);
|
||||
|
||||
/**
|
||||
* Appends detectors to the end of the list in shared memory
|
||||
* Connects to them
|
||||
* @param name concatenated hostname of the sls detectors to be appended to
|
||||
* the list
|
||||
*/
|
||||
void addMultipleDetectors(const char *name);//
|
||||
|
||||
/**
|
||||
* Add sls detector
|
||||
* @param s hostname of the single detector
|
||||
*/
|
||||
void addSlsDetector(const std::string &hostname);
|
||||
|
||||
/**
|
||||
* Updates the channel size in X and Y dimension for all the sls
|
||||
* detectors
|
||||
*/
|
||||
void updateDetectorSize();
|
||||
|
||||
/**
|
||||
* increments file index
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
@ -2243,13 +2206,6 @@ class multiSlsDetector : public virtual slsDetectorDefs {
|
||||
*/
|
||||
int incrementFileIndex(int detPos = -1);
|
||||
|
||||
/**
|
||||
* Ensures that min is less than max in both dimensions (Gotthard)
|
||||
* @param n number of rois
|
||||
* @param r array of rois
|
||||
*/
|
||||
void verifyMinMaxROI(int n, ROI r[]);
|
||||
|
||||
/**
|
||||
* add gap pixels to the image (only for Eiger in 4 bit mode)
|
||||
* @param image pointer to image without gap pixels
|
||||
|
@ -13,7 +13,7 @@
|
||||
class ServerInterface;
|
||||
|
||||
#define SLS_SHMAPIVERSION 0x190726
|
||||
#define SLS_SHMVERSION 0x190726
|
||||
#define SLS_SHMVERSION 0x190813
|
||||
|
||||
/**
|
||||
* @short structure allocated in shared memory to store detector settings for
|
||||
@ -35,10 +35,6 @@ struct sharedSlsDetector {
|
||||
|
||||
/** END OF FIXED PATTERN -----------------------------------------------*/
|
||||
|
||||
/** Detector offset in the X & Y direction in the multi detector structure
|
||||
*/
|
||||
int offset[2];
|
||||
|
||||
/** Number of detectors in multi list in x dir and y dir */
|
||||
int multiSize[2];
|
||||
|
||||
@ -75,11 +71,8 @@ struct sharedSlsDetector {
|
||||
/** size of the data that are transfered from the detector */
|
||||
int dataBytes;
|
||||
|
||||
/** number of rois defined */
|
||||
int nROI;
|
||||
|
||||
/** list of rois */
|
||||
slsDetectorDefs::ROI roiLimits[MAX_ROIS];
|
||||
/** roi */
|
||||
slsDetectorDefs::ROI roi;
|
||||
|
||||
/** adc enable mask */
|
||||
uint32_t adcEnableMask;
|
||||
@ -339,7 +332,7 @@ class slsDetector : public virtual slsDetectorDefs {
|
||||
|
||||
/**
|
||||
* Update total number of channels (chiptestboard or moench)
|
||||
* depending on the number of samples, roi, readout flags(ctb)
|
||||
* depending on the number of samples, adenablemask, readout flags(ctb)
|
||||
*/
|
||||
void updateTotalNumberOfChannels();
|
||||
|
||||
@ -423,32 +416,6 @@ class slsDetector : public virtual slsDetectorDefs {
|
||||
*/
|
||||
int getReadNLines();
|
||||
|
||||
/**
|
||||
* Get Detector offset from shared memory in dimension d
|
||||
* @param d dimension d
|
||||
* @returns offset in dimension d
|
||||
*/
|
||||
int getDetectorOffset(dimension d) const;
|
||||
|
||||
/**
|
||||
* Get Detector offset from shared memory in dimension d
|
||||
* @returns offset
|
||||
*/
|
||||
slsDetectorDefs::coordinates getDetectorOffsets() const;
|
||||
|
||||
/**
|
||||
* Set Detector offset in shared memory in dimension d
|
||||
* @param d dimension d
|
||||
* @param off offset for detector
|
||||
*/
|
||||
void setDetectorOffset(dimension d, int off);
|
||||
|
||||
/**
|
||||
* Set Detector offset in shared memory
|
||||
* @param value offset for detector
|
||||
*/
|
||||
void setDetectorOffsets(slsDetectorDefs::coordinates value);
|
||||
|
||||
/**
|
||||
* Set Detector offset in shared memory in dimension d
|
||||
* @param detx number of detectors in X dir in multi list
|
||||
@ -1143,35 +1110,29 @@ class slsDetector : public virtual slsDetectorDefs {
|
||||
*/
|
||||
int setCounterBit(int cb = -1);
|
||||
|
||||
/**
|
||||
* Clear ROI (Gotthard)
|
||||
*/
|
||||
void clearROI();
|
||||
|
||||
/**
|
||||
* Set ROI (Gotthard)
|
||||
* At the moment only one set allowed
|
||||
* @param n number of rois
|
||||
* @param roiLimits array of roi
|
||||
* Also calls configuremac
|
||||
* @param arg roi
|
||||
*/
|
||||
void setROI(int n = -1, ROI roiLimits[] = nullptr);
|
||||
void setROI(slsDetectorDefs::ROI arg);
|
||||
|
||||
/**
|
||||
* Get ROI from each detector and convert it to the multi detector scale
|
||||
* (Gotthard)
|
||||
* @param n number of rois
|
||||
* @returns OK or FAIL
|
||||
* Send ROI from shared memory to Receiver (Gotthard)
|
||||
*/
|
||||
const slsDetectorDefs::ROI *getROI(int &n);
|
||||
void sendROItoReceiver();
|
||||
|
||||
/**
|
||||
* Returns number of rois
|
||||
* @returns number of ROIs
|
||||
* Get ROI (Gotthard)
|
||||
* Update receiver if different from shm
|
||||
* @returns roi
|
||||
*/
|
||||
int getNRoi();
|
||||
|
||||
/**
|
||||
* Send ROI to the detector after calculating
|
||||
* from setROI
|
||||
* @param n number of ROIs (-1 to get)
|
||||
* @param roiLimits ROI
|
||||
*/
|
||||
void sendROI(int n = -1, ROI roiLimits[] = nullptr);
|
||||
slsDetectorDefs::ROI getROI();
|
||||
|
||||
/**
|
||||
* Set ADC Enable Mask (CTB, Moench)
|
||||
|
@ -104,7 +104,7 @@ public:
|
||||
/**
|
||||
* Returns the maximum number of channels of all detectors
|
||||
* (provided by user in config file using detsizechan command)
|
||||
* Offsets are calculated according to these dimensions
|
||||
* number of channels in x and y are calculated according to these dimensions
|
||||
* @param nx number of channels in horizontal
|
||||
* @param ny number of channels in vertical
|
||||
* @returns the maximum number of channels of all detectors
|
||||
@ -112,15 +112,13 @@ public:
|
||||
int getMaximumDetectorSize(int &nx, int &ny);
|
||||
|
||||
/**
|
||||
* Returns the size and offsets of detector/multi detector
|
||||
* @param x horizontal position origin in channel number
|
||||
* @param y vertical position origin in channel number
|
||||
* Returns the size of detector/multi detector
|
||||
* @param nx number of channels in horiziontal
|
||||
* @param ny number of channels in vertical
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns the total number of channels of all sls detectors
|
||||
*/
|
||||
int getDetectorSize(int &x, int &y, int &nx, int &ny, int detPos = -1);
|
||||
int getDetectorSize(int &nx, int &ny, int detPos);
|
||||
|
||||
/**
|
||||
* Gets detector type
|
||||
@ -496,22 +494,22 @@ public:
|
||||
int setFlowControl10G(int enable = -1, int detPos = -1);
|
||||
|
||||
/**
|
||||
* Set ROI (Gotthard) (>= 1 roi, but max 1 roi per module)
|
||||
* At the moment only one set allowed
|
||||
* @param n number of rois
|
||||
* @param roiLimits array of roi
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* Set ROI (Gotthard)
|
||||
* At the moment only one set allowed per module
|
||||
* Only allowed to set one ROI per module
|
||||
* @param arg roi
|
||||
* @param detPos specific detector position
|
||||
*/
|
||||
void setROI(int n=-1, slsDetectorDefs::ROI roiLimits[]=NULL, int detPos = -1);
|
||||
void setROI(slsDetectorDefs::ROI arg, int detPos = -1);
|
||||
|
||||
|
||||
/**
|
||||
* Get ROI from each detector and convert it to the multi detector scale (Gotthard)
|
||||
* >= 1 roi, but max 1 roi per module
|
||||
* @param n number of rois
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns pointer to array of ROI structure
|
||||
* Get ROI (Gotthard)
|
||||
* Only allowed to set one ROI per module
|
||||
* @param detPos specific detector position
|
||||
* @returns roi
|
||||
*/
|
||||
const slsDetectorDefs::ROI* getROI(int &n, int detPos = -1);
|
||||
slsDetectorDefs::ROI getROI(int detPos = -1);
|
||||
|
||||
|
||||
|
||||
|
@ -110,16 +110,6 @@ void Detector::setMaxNumberOfChannels(const defs::coordinates value) {
|
||||
pimpl->setMaxNumberOfChannels(value);
|
||||
}
|
||||
|
||||
Result<defs::coordinates> Detector::getDetectorOffsets(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getDetectorOffsets, pos);
|
||||
}
|
||||
|
||||
void Detector::setDetectorOffsets(defs::coordinates value, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setDetectorOffsets, pos, value);
|
||||
// pimpl->Parallel<defs::coordinates>(&slsDetector::setDetectorOffset, pos,
|
||||
// value);
|
||||
}
|
||||
|
||||
Result<bool> Detector::getQuad(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getQuad, pos);
|
||||
}
|
||||
@ -1071,41 +1061,15 @@ void Detector::setCounterBit(bool value, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setCounterBit, pos, value);
|
||||
}
|
||||
|
||||
Result<std::vector<defs::ROI>> Detector::getROI(Positions pos) const {
|
||||
//vector holding module_id for the modules that should be read
|
||||
const std::vector<int> id_vec = [&]() {
|
||||
if (pos.empty() || (pos.size() == 1 && pos[0] == -1)){
|
||||
std::vector<int> tmp;
|
||||
for(size_t i=0; i!= pimpl->size(); ++i)
|
||||
tmp.push_back(i);
|
||||
return tmp;
|
||||
}else{
|
||||
return pos;
|
||||
}
|
||||
}();
|
||||
|
||||
|
||||
//values to return
|
||||
Result<std::vector<defs::ROI>> res;
|
||||
|
||||
//for each detector id get the ROI
|
||||
for (const auto& i :id_vec){
|
||||
int n = 0;
|
||||
auto ptr = pimpl->getROI(n, i);
|
||||
// res.emplace_back(ptr, ptr+n);
|
||||
}
|
||||
return res;
|
||||
Result<defs::ROI> Detector::getROI(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getROI, pos);
|
||||
}
|
||||
|
||||
void Detector::setROI(std::vector<defs::ROI> value, Positions pos) {
|
||||
if (pos.empty() || (pos.size() == 1 && pos[0] == -1)) {
|
||||
pimpl->setROI(static_cast<int>(value.size()), value.data(), -1);
|
||||
} else if (pos.size() > 1) {
|
||||
throw RuntimeError("Cannot set roi to a subset of modules");
|
||||
} else {
|
||||
pimpl->Parallel(&slsDetector::setROI, pos,
|
||||
static_cast<int>(value.size()), value.data());
|
||||
void Detector::setROI(defs::ROI value, int moduleId) {
|
||||
if (moduleId < 0 && size() > 1) {
|
||||
throw RuntimeError("Cannot set ROI for all modules simultaneously");
|
||||
}
|
||||
pimpl->Parallel(&slsDetector::setROI, {moduleId}, value);
|
||||
}
|
||||
|
||||
Result<uint32_t> Detector::getADCEnableMask(Positions pos) const {
|
||||
|
@ -283,8 +283,8 @@ void multiSlsDetector::initializeDetectorStructure() {
|
||||
multi_shm()->numberOfChannel[Y] = 0;
|
||||
multi_shm()->numberOfChannelInclGapPixels[X] = 0;
|
||||
multi_shm()->numberOfChannelInclGapPixels[Y] = 0;
|
||||
multi_shm()->maxNumberOfChannelsPerDetector[X] = 0;
|
||||
multi_shm()->maxNumberOfChannelsPerDetector[Y] = 0;
|
||||
multi_shm()->maxNumberOfChannelsPerDetector[X] = -1;
|
||||
multi_shm()->maxNumberOfChannelsPerDetector[Y] = -1;
|
||||
multi_shm()->acquiringFlag = false;
|
||||
multi_shm()->receiver_upstream = false;
|
||||
}
|
||||
@ -303,9 +303,6 @@ void multiSlsDetector::initializeMembers(bool verify) {
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// depend on number of detectors
|
||||
updateOffsets();
|
||||
}
|
||||
|
||||
void multiSlsDetector::updateUserdetails() {
|
||||
@ -333,197 +330,6 @@ bool multiSlsDetector::isAcquireReady() {
|
||||
return OK != 0u;
|
||||
}
|
||||
|
||||
int multiSlsDetector::decodeNChannel(int offsetX, int offsetY, int &channelX,
|
||||
int &channelY) {
|
||||
channelX = -1;
|
||||
channelY = -1;
|
||||
// loop over
|
||||
for (size_t i = 0; i < detectors.size(); ++i) {
|
||||
int x = detectors[i]->getDetectorOffset(X);
|
||||
int y = detectors[i]->getDetectorOffset(Y);
|
||||
// check x offset range
|
||||
if ((offsetX >= x) &&
|
||||
(offsetX <
|
||||
(x + detectors[i]->getTotalNumberOfChannelsInclGapPixels(X)))) {
|
||||
if (offsetY == -1) {
|
||||
channelX = offsetX - x;
|
||||
return i;
|
||||
} else {
|
||||
// check y offset range
|
||||
if ((offsetY >= y) &&
|
||||
(offsetY <
|
||||
(y + detectors[i]->getTotalNumberOfChannelsInclGapPixels(
|
||||
Y)))) {
|
||||
channelX = offsetX - x;
|
||||
channelY = offsetY - y;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void multiSlsDetector::updateOffsets() {
|
||||
FILE_LOG(logDEBUG1) << "Updating Multi-Detector Offsets";
|
||||
|
||||
int offsetX = 0, offsetY = 0, numX = 0, numY = 0;
|
||||
int maxChanX = multi_shm()->maxNumberOfChannelsPerDetector[X];
|
||||
int maxChanY = multi_shm()->maxNumberOfChannelsPerDetector[Y];
|
||||
int prevChanX = 0;
|
||||
int prevChanY = 0;
|
||||
bool firstTime = true;
|
||||
|
||||
multi_shm()->numberOfChannel[X] = 0;
|
||||
multi_shm()->numberOfChannel[Y] = 0;
|
||||
multi_shm()->numberOfDetector[X] = 0;
|
||||
multi_shm()->numberOfDetector[Y] = 0;
|
||||
|
||||
// gap pixels
|
||||
int offsetX_gp = 0, offsetY_gp = 0, numX_gp = 0, numY_gp = 0;
|
||||
int prevChanX_gp = 0, prevChanY_gp = 0;
|
||||
multi_shm()->numberOfChannelInclGapPixels[X] = 0;
|
||||
multi_shm()->numberOfChannelInclGapPixels[Y] = 0;
|
||||
|
||||
for (size_t idet = 0; idet < detectors.size(); ++idet) {
|
||||
FILE_LOG(logDEBUG1)
|
||||
<< "offsetX:" << offsetX << " prevChanX:" << prevChanX
|
||||
<< " offsetY:" << offsetY << " prevChanY:" << prevChanY
|
||||
<< " offsetX_gp:" << offsetX_gp << " prevChanX_gp:" << prevChanX_gp
|
||||
<< " offsetY_gp:" << offsetY_gp << " prevChanY_gp:" << prevChanY_gp;
|
||||
|
||||
// incrementing in both direction
|
||||
if (firstTime) {
|
||||
// incrementing in both directions
|
||||
firstTime = false;
|
||||
if ((maxChanX > 0) &&
|
||||
((offsetX + detectors[idet]->getTotalNumberOfChannels(X)) >
|
||||
maxChanX)) {
|
||||
FILE_LOG(logWARNING)
|
||||
<< "\nDetector[" << idet
|
||||
<< "] exceeds maximum channels "
|
||||
"allowed for complete detector set in X dimension!";
|
||||
}
|
||||
if ((maxChanY > 0) &&
|
||||
((offsetY + detectors[idet]->getTotalNumberOfChannels(Y)) >
|
||||
maxChanY)) {
|
||||
FILE_LOG(logERROR)
|
||||
<< "\nDetector[" << idet
|
||||
<< "] exceeds maximum channels "
|
||||
"allowed for complete detector set in Y dimension!";
|
||||
}
|
||||
prevChanX = detectors[idet]->getTotalNumberOfChannels(X);
|
||||
prevChanY = detectors[idet]->getTotalNumberOfChannels(Y);
|
||||
prevChanX_gp =
|
||||
detectors[idet]->getTotalNumberOfChannelsInclGapPixels(X);
|
||||
prevChanY_gp =
|
||||
detectors[idet]->getTotalNumberOfChannelsInclGapPixels(Y);
|
||||
numX += detectors[idet]->getTotalNumberOfChannels(X);
|
||||
numY += detectors[idet]->getTotalNumberOfChannels(Y);
|
||||
numX_gp +=
|
||||
detectors[idet]->getTotalNumberOfChannelsInclGapPixels(X);
|
||||
numY_gp +=
|
||||
detectors[idet]->getTotalNumberOfChannelsInclGapPixels(Y);
|
||||
++multi_shm()->numberOfDetector[X];
|
||||
++multi_shm()->numberOfDetector[Y];
|
||||
FILE_LOG(logDEBUG1) << "incrementing in both direction";
|
||||
}
|
||||
|
||||
// incrementing in y direction
|
||||
else if ((maxChanY == -1) ||
|
||||
((maxChanY > 0) && ((offsetY + prevChanY +
|
||||
detectors[idet]->getTotalNumberOfChannels(
|
||||
Y)) <= maxChanY))) {
|
||||
offsetY += prevChanY;
|
||||
offsetY_gp += prevChanY_gp;
|
||||
prevChanY = detectors[idet]->getTotalNumberOfChannels(Y);
|
||||
prevChanY_gp =
|
||||
detectors[idet]->getTotalNumberOfChannelsInclGapPixels(Y);
|
||||
numY += detectors[idet]->getTotalNumberOfChannels(Y);
|
||||
numY_gp +=
|
||||
detectors[idet]->getTotalNumberOfChannelsInclGapPixels(Y);
|
||||
// increment in y again only in the first column (else you double
|
||||
// increment)
|
||||
if (multi_shm()->numberOfDetector[X] == 1)
|
||||
++multi_shm()->numberOfDetector[Y];
|
||||
FILE_LOG(logDEBUG1) << "incrementing in y direction";
|
||||
}
|
||||
|
||||
// incrementing in x direction
|
||||
else {
|
||||
if ((maxChanX > 0) &&
|
||||
((offsetX + prevChanX +
|
||||
detectors[idet]->getTotalNumberOfChannels(X)) > maxChanX)) {
|
||||
FILE_LOG(logDEBUG1)
|
||||
<< "\nDetector[" << idet
|
||||
<< "] exceeds maximum channels "
|
||||
"allowed for complete detector set in X dimension!";
|
||||
}
|
||||
offsetY = 0;
|
||||
offsetY_gp = 0;
|
||||
prevChanY = detectors[idet]->getTotalNumberOfChannels(Y);
|
||||
prevChanY_gp =
|
||||
detectors[idet]->getTotalNumberOfChannelsInclGapPixels(Y);
|
||||
numY = 0; // assuming symmetry with this statement.
|
||||
// whats on 1st column should be on 2nd column
|
||||
numY_gp = 0;
|
||||
offsetX += prevChanX;
|
||||
offsetX_gp += prevChanX_gp;
|
||||
prevChanX = detectors[idet]->getTotalNumberOfChannels(X);
|
||||
prevChanX_gp =
|
||||
detectors[idet]->getTotalNumberOfChannelsInclGapPixels(X);
|
||||
numX += detectors[idet]->getTotalNumberOfChannels(X);
|
||||
numX_gp +=
|
||||
detectors[idet]->getTotalNumberOfChannelsInclGapPixels(X);
|
||||
++multi_shm()->numberOfDetector[X];
|
||||
FILE_LOG(logDEBUG1) << "incrementing in x direction";
|
||||
}
|
||||
|
||||
double bytesperchannel =
|
||||
(double)detectors[idet]->getDataBytes() /
|
||||
(double)(detectors[idet]->getTotalNumberOfChannels(X) *
|
||||
detectors[idet]->getTotalNumberOfChannels(Y));
|
||||
detectors[idet]->setDetectorOffset(
|
||||
X, (bytesperchannel >= 1.0) ? offsetX_gp : offsetX);
|
||||
detectors[idet]->setDetectorOffset(
|
||||
Y, (bytesperchannel >= 1.0) ? offsetY_gp : offsetY);
|
||||
|
||||
FILE_LOG(logDEBUG1) << "Detector[" << idet << "] has offsets ("
|
||||
<< detectors[idet]->getDetectorOffset(X) << ", "
|
||||
<< detectors[idet]->getDetectorOffset(Y) << ")";
|
||||
// offsetY has been reset sometimes and offsetX the first time,
|
||||
// but remember the highest values
|
||||
if (numX > multi_shm()->numberOfChannel[X]) {
|
||||
multi_shm()->numberOfChannel[X] = numX;
|
||||
}
|
||||
if (numY > multi_shm()->numberOfChannel[Y]) {
|
||||
multi_shm()->numberOfChannel[Y] = numY;
|
||||
}
|
||||
if (numX_gp > multi_shm()->numberOfChannelInclGapPixels[X]) {
|
||||
multi_shm()->numberOfChannelInclGapPixels[X] = numX_gp;
|
||||
}
|
||||
if (numY_gp > multi_shm()->numberOfChannelInclGapPixels[Y]) {
|
||||
multi_shm()->numberOfChannelInclGapPixels[Y] = numY_gp;
|
||||
}
|
||||
}
|
||||
FILE_LOG(logDEBUG1)
|
||||
<< "\n\tNumber of Channels in X direction:"
|
||||
<< multi_shm()->numberOfChannel[X]
|
||||
<< "\n\tNumber of Channels in Y direction:"
|
||||
<< multi_shm()->numberOfChannel[Y]
|
||||
<< "\n\tNumber of Channels in X direction with Gap Pixels:"
|
||||
<< multi_shm()->numberOfChannelInclGapPixels[X]
|
||||
<< "\n\tNumber of Channels in Y direction with Gap Pixels:"
|
||||
<< multi_shm()->numberOfChannelInclGapPixels[Y];
|
||||
|
||||
multi_shm()->numberOfChannels =
|
||||
multi_shm()->numberOfChannel[0] * multi_shm()->numberOfChannel[1];
|
||||
|
||||
for (auto &d : detectors) {
|
||||
d->updateMultiSize(multi_shm()->numberOfDetector[0],
|
||||
multi_shm()->numberOfDetector[1]);
|
||||
}
|
||||
}
|
||||
|
||||
std::string multiSlsDetector::exec(const char *cmd) {
|
||||
int bufsize = 128;
|
||||
@ -560,8 +366,6 @@ void multiSlsDetector::setHostname(const std::vector<std::string> &name) {
|
||||
for (const auto &hostname : name) {
|
||||
addSlsDetector(hostname);
|
||||
}
|
||||
|
||||
updateOffsets();
|
||||
}
|
||||
|
||||
void multiSlsDetector::setHostname(const char *name, int detPos) {
|
||||
@ -598,8 +402,7 @@ void multiSlsDetector::addMultipleDetectors(const char *name) {
|
||||
for (const auto &hostname : sls::split(name, '+')) {
|
||||
addSlsDetector(hostname);
|
||||
}
|
||||
|
||||
updateOffsets();
|
||||
updateDetectorSize();
|
||||
}
|
||||
|
||||
void multiSlsDetector::addSlsDetector(const std::string &hostname) {
|
||||
@ -623,11 +426,63 @@ void multiSlsDetector::addSlsDetector(const std::string &hostname) {
|
||||
sls::make_unique<slsDetector>(type, multiId, pos, false));
|
||||
multi_shm()->numberOfDetectors = detectors.size();
|
||||
multi_shm()->numberOfChannels += detectors[pos]->getTotalNumberOfChannels();
|
||||
|
||||
detectors[pos]->setHostname(hostname);
|
||||
multi_shm()->multiDetectorType = getDetectorTypeAsEnum(-1);// -1 needed here
|
||||
}
|
||||
|
||||
void multiSlsDetector::updateDetectorSize() {
|
||||
FILE_LOG(logDEBUG) << "Updating Multi-Detector Size: " << size();
|
||||
|
||||
int my = detectors[0]->getTotalNumberOfChannels(Y);
|
||||
int mx = detectors[0]->getTotalNumberOfChannels(X);
|
||||
int mgy = detectors[0]->getTotalNumberOfChannelsInclGapPixels(Y);
|
||||
int mgx = detectors[0]->getTotalNumberOfChannelsInclGapPixels(X);
|
||||
if (mgy == 0) {
|
||||
mgy = my;
|
||||
mgx = mx;
|
||||
}
|
||||
|
||||
int maxy = multi_shm()->maxNumberOfChannelsPerDetector[Y];
|
||||
if (maxy == -1) {
|
||||
maxy = my * size();
|
||||
}
|
||||
|
||||
int ndety = maxy / my;
|
||||
int ndetx = size() / ndety;
|
||||
if ((maxy % my) > 0) {
|
||||
++ndetx;
|
||||
}
|
||||
|
||||
multi_shm()->numberOfDetector[X] = ndetx;
|
||||
multi_shm()->numberOfDetector[Y] = ndety;
|
||||
multi_shm()->numberOfChannel[X] = mx * ndetx;
|
||||
multi_shm()->numberOfChannel[Y] = my * ndety;
|
||||
multi_shm()->numberOfChannelInclGapPixels[X] = mgx * ndetx;
|
||||
multi_shm()->numberOfChannelInclGapPixels[Y] = mgy * ndety;
|
||||
|
||||
FILE_LOG(logDEBUG)
|
||||
<< "\n\tNumber of Detectors in X direction:"
|
||||
<< multi_shm()->numberOfDetector[X]
|
||||
<< "\n\tNumber of Detectors in Y direction:"
|
||||
<< multi_shm()->numberOfDetector[Y]
|
||||
<< "\n\tNumber of Channels in X direction:"
|
||||
<< multi_shm()->numberOfChannel[X]
|
||||
<< "\n\tNumber of Channels in Y direction:"
|
||||
<< multi_shm()->numberOfChannel[Y]
|
||||
<< "\n\tNumber of Channels in X direction with Gap Pixels:"
|
||||
<< multi_shm()->numberOfChannelInclGapPixels[X]
|
||||
<< "\n\tNumber of Channels in Y direction with Gap Pixels:"
|
||||
<< multi_shm()->numberOfChannelInclGapPixels[Y];
|
||||
|
||||
multi_shm()->numberOfChannels =
|
||||
multi_shm()->numberOfChannel[0] * multi_shm()->numberOfChannel[1];
|
||||
|
||||
for (auto &d : detectors) {
|
||||
d->updateMultiSize(multi_shm()->numberOfDetector[0],
|
||||
multi_shm()->numberOfDetector[1]);
|
||||
}
|
||||
}
|
||||
|
||||
slsDetectorDefs::detectorType multiSlsDetector::getDetectorTypeAsEnum() const {
|
||||
return multi_shm()->multiDetectorType;
|
||||
}
|
||||
@ -732,14 +587,6 @@ void multiSlsDetector::setMaxNumberOfChannels(const slsDetectorDefs::coordinates
|
||||
multi_shm()->maxNumberOfChannelsPerDetector[Y] = c.y;
|
||||
}
|
||||
|
||||
int multiSlsDetector::getDetectorOffset(dimension d, int detPos) {
|
||||
return detectors[detPos]->getDetectorOffset(d);
|
||||
}
|
||||
|
||||
void multiSlsDetector::setDetectorOffset(dimension d, int off, int detPos) {
|
||||
detectors[detPos]->setDetectorOffset(d, off);
|
||||
}
|
||||
|
||||
int multiSlsDetector::getQuad(int detPos) {
|
||||
int retval = detectors[0]->getQuad();
|
||||
if (retval && size() > 1) {
|
||||
@ -1272,8 +1119,6 @@ int multiSlsDetector::setDynamicRange(int dr, int detPos) {
|
||||
// change in dr
|
||||
if (dr != -1 && dr != prevValue) {
|
||||
|
||||
updateOffsets();
|
||||
|
||||
// update speed, check ratecorrection
|
||||
if (getDetectorTypeAsEnum() == EIGER) {
|
||||
|
||||
@ -2172,318 +2017,40 @@ int multiSlsDetector::setCounterBit(int i, int detPos) {
|
||||
return sls::minusOneIfDifferent(r);
|
||||
}
|
||||
|
||||
void multiSlsDetector::verifyMinMaxROI(int n, ROI r[]) {
|
||||
int temp;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
if ((r[i].xmax) < (r[i].xmin)) {
|
||||
temp = r[i].xmax;
|
||||
r[i].xmax = r[i].xmin;
|
||||
r[i].xmin = temp;
|
||||
}
|
||||
if ((r[i].ymax) < (r[i].ymin)) {
|
||||
temp = r[i].ymax;
|
||||
r[i].ymax = r[i].ymin;
|
||||
r[i].ymin = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void multiSlsDetector::setROI(int n, ROI roiLimits[], int detPos) {
|
||||
void multiSlsDetector::clearROI(int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
detectors[detPos]->setROI(n, roiLimits);
|
||||
detectors[detPos]->clearROI();
|
||||
}
|
||||
|
||||
// multi
|
||||
int xmin = 0, xmax = 0, ymin = 0, ymax = 0, channelX = 0, channelY = 0,
|
||||
idet = 0, lastChannelX = 0, lastChannelY = 0, index = 0, offsetX = 0,
|
||||
offsetY = 0;
|
||||
|
||||
bool invalidroi = false;
|
||||
int ndet = detectors.size();
|
||||
ROI allroi[ndet][n];
|
||||
int nroi[ndet];
|
||||
for (int i = 0; i < ndet; ++i) {
|
||||
nroi[i] = 0;
|
||||
}
|
||||
|
||||
if ((n < 0) || (roiLimits == nullptr)) {
|
||||
throw RuntimeError("Cannot set ROI due to Invalid ROI");
|
||||
}
|
||||
|
||||
// ensures min < max
|
||||
verifyMinMaxROI(n, roiLimits);
|
||||
FILE_LOG(logDEBUG1) << "Setting ROI for " << n << "rois:";
|
||||
for (int i = 0; i < n; ++i) {
|
||||
FILE_LOG(logDEBUG1)
|
||||
<< i << ":" << roiLimits[i].xmin << "\t" << roiLimits[i].xmax
|
||||
<< "\t" << roiLimits[i].ymin << "\t" << roiLimits[i].ymax;
|
||||
}
|
||||
// for each roi
|
||||
for (int i = 0; i < n; ++i) {
|
||||
xmin = roiLimits[i].xmin;
|
||||
xmax = roiLimits[i].xmax;
|
||||
ymin = roiLimits[i].ymin;
|
||||
ymax = roiLimits[i].ymax;
|
||||
|
||||
if (size() > 1) {
|
||||
// check roi max values
|
||||
idet = decodeNChannel(xmax, ymax, channelX, channelY);
|
||||
FILE_LOG(logDEBUG1) << "Decoded Channel max vals: " << std::endl
|
||||
<< "det:" << idet << "\t" << xmax << "\t"
|
||||
<< ymax << "\t" << channelX << "\t" << channelY;
|
||||
if (idet == -1) {
|
||||
FILE_LOG(logERROR) << "invalid roi";
|
||||
continue;
|
||||
}
|
||||
|
||||
// split in x dir
|
||||
while (xmin <= xmax) {
|
||||
invalidroi = false;
|
||||
ymin = roiLimits[i].ymin;
|
||||
// split in y dir
|
||||
while (ymin <= ymax) {
|
||||
// get offset for each detector
|
||||
idet = decodeNChannel(xmin, ymin, channelX, channelY);
|
||||
FILE_LOG(logDEBUG1)
|
||||
<< "Decoded Channel min vals: " << std::endl
|
||||
<< "det:" << idet << "\t" << xmin << "\t" << ymin
|
||||
<< "\t" << channelX << "\t" << channelY;
|
||||
if (idet < 0 || idet >= (int)detectors.size()) {
|
||||
FILE_LOG(logDEBUG1) << "invalid roi";
|
||||
invalidroi = true;
|
||||
break;
|
||||
}
|
||||
// get last channel for each det in x and y dir
|
||||
lastChannelX =
|
||||
(detectors[idet]->getTotalNumberOfChannelsInclGapPixels(
|
||||
X)) -
|
||||
1;
|
||||
lastChannelY =
|
||||
(detectors[idet]->getTotalNumberOfChannelsInclGapPixels(
|
||||
Y)) -
|
||||
1;
|
||||
|
||||
offsetX = detectors[idet]->getDetectorOffset(X);
|
||||
offsetY = detectors[idet]->getDetectorOffset(Y);
|
||||
// at the end in x dir
|
||||
if ((offsetX + lastChannelX) >= xmax) {
|
||||
lastChannelX = xmax - offsetX;
|
||||
}
|
||||
// at the end in y dir
|
||||
if ((offsetY + lastChannelY) >= ymax) {
|
||||
lastChannelY = ymax - offsetY;
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG1)
|
||||
<< "lastChannelX:" << lastChannelX << "\t"
|
||||
<< "lastChannelY:" << lastChannelY;
|
||||
|
||||
// creating the list of roi for corresponding detector
|
||||
index = nroi[idet];
|
||||
allroi[idet][index].xmin = channelX;
|
||||
allroi[idet][index].xmax = lastChannelX;
|
||||
allroi[idet][index].ymin = channelY;
|
||||
allroi[idet][index].ymax = lastChannelY;
|
||||
nroi[idet] = nroi[idet] + 1;
|
||||
|
||||
ymin = lastChannelY + offsetY + 1;
|
||||
if ((lastChannelY + offsetY) == ymax) {
|
||||
ymin = ymax + 1;
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG1)
|
||||
<< "nroi[idet]:" << nroi[idet] << "\tymin:" << ymin;
|
||||
}
|
||||
if (invalidroi) {
|
||||
break;
|
||||
}
|
||||
|
||||
xmin = lastChannelX + offsetX + 1;
|
||||
if ((lastChannelX + offsetX) == xmax) {
|
||||
xmin = xmax + 1;
|
||||
}
|
||||
}
|
||||
} else { // FIXME: check if xmax is greater? or reduce logic above?
|
||||
idet = 0;
|
||||
nroi[idet] = n;
|
||||
index = 0;
|
||||
allroi[idet][index].xmin = xmin;
|
||||
allroi[idet][index].xmax = xmax;
|
||||
allroi[idet][index].ymin = ymin;
|
||||
allroi[idet][index].ymax = ymax;
|
||||
// nroi[idet] = nroi[idet] + 1;
|
||||
}
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG1) << "Setting ROI :";
|
||||
for (size_t i = 0; i < detectors.size(); ++i) {
|
||||
FILE_LOG(logDEBUG1) << "detector " << i;
|
||||
for (int j = 0; j < nroi[i]; ++j) {
|
||||
FILE_LOG(logDEBUG1)
|
||||
<< allroi[i][j].xmin << "\t" << allroi[i][j].xmax << "\t"
|
||||
<< allroi[i][j].ymin << "\t" << allroi[i][j].ymax;
|
||||
}
|
||||
}
|
||||
|
||||
// settings the rois for each detector
|
||||
for (size_t i = 0; i != detectors.size(); ++i) {
|
||||
detectors[i]->setROI(nroi[i], allroi[i]);
|
||||
}
|
||||
parallelCall(&slsDetector::clearROI);
|
||||
}
|
||||
|
||||
const slsDetectorDefs::ROI *multiSlsDetector::getROI(int &n, int detPos) {
|
||||
void multiSlsDetector::setROI(slsDetectorDefs::ROI arg, int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->getROI(n);
|
||||
detectors[detPos]->setROI(arg);
|
||||
}
|
||||
|
||||
// multi
|
||||
n = 0;
|
||||
int num = 0;
|
||||
int ndet = detectors.size();
|
||||
int maxroi = ndet * MAX_ROIS;
|
||||
ROI temproi;
|
||||
ROI roiLimits[maxroi];
|
||||
ROI *retval = new ROI[maxroi];
|
||||
const ROI *temp = nullptr;
|
||||
int index = 0;
|
||||
if (detPos < 0 && size() > 1) {
|
||||
throw RuntimeError("Cannot set ROI for all modules simultaneously");
|
||||
}
|
||||
detectors[0]->setROI(arg);
|
||||
}
|
||||
|
||||
// get each detector's roi array
|
||||
for (size_t idet = 0; idet < detectors.size(); ++idet) {
|
||||
temp = detectors[idet]->getROI(index);
|
||||
if (temp != nullptr) {
|
||||
if (index != 0) {
|
||||
FILE_LOG(logINFO) << "detector " << idet << ":";
|
||||
}
|
||||
for (int j = 0; j < index; ++j) {
|
||||
FILE_LOG(logINFO)
|
||||
<< temp[j].xmin << "\t" << temp[j].xmax << "\t"
|
||||
<< temp[j].ymin << "\t" << temp[j].ymax;
|
||||
int x = detectors[idet]->getDetectorOffset(X);
|
||||
int y = detectors[idet]->getDetectorOffset(Y);
|
||||
roiLimits[n].xmin = temp[j].xmin + x;
|
||||
roiLimits[n].xmax = temp[j].xmax + x;
|
||||
roiLimits[n].ymin = temp[j].ymin + y;
|
||||
roiLimits[n].ymax = temp[j].ymin + y;
|
||||
++n;
|
||||
}
|
||||
}
|
||||
slsDetectorDefs::ROI multiSlsDetector::getROI(int detPos) const {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->getROI();
|
||||
}
|
||||
|
||||
// empty roi
|
||||
if (n == 0) {
|
||||
return nullptr;
|
||||
// multi
|
||||
if (detPos < 0 && size() > 1) {
|
||||
throw RuntimeError("Cannot get ROI for all modules simultaneously");
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG1) << "ROI :" << std::endl;
|
||||
for (int j = 0; j < n; ++j) {
|
||||
FILE_LOG(logDEBUG1)
|
||||
<< roiLimits[j].xmin << "\t" << roiLimits[j].xmax << "\t"
|
||||
<< roiLimits[j].ymin << "\t" << roiLimits[j].ymax;
|
||||
}
|
||||
|
||||
// combine all the adjacent rois in x direction
|
||||
for (int i = 0; i < n; ++i) {
|
||||
// since the ones combined are replaced by -1
|
||||
if ((roiLimits[i].xmin) == -1) {
|
||||
continue;
|
||||
}
|
||||
for (int j = i + 1; j < n; ++j) {
|
||||
// since the ones combined are replaced by -1
|
||||
if ((roiLimits[j].xmin) == -1) {
|
||||
continue;
|
||||
}
|
||||
// if y values are same
|
||||
if (((roiLimits[i].ymin) == (roiLimits[j].ymin)) &&
|
||||
((roiLimits[i].ymax) == (roiLimits[j].ymax))) {
|
||||
// if adjacent, increase [i] range and replace all [j] with -1
|
||||
if ((roiLimits[i].xmax) + 1 == roiLimits[j].xmin) {
|
||||
roiLimits[i].xmax = roiLimits[j].xmax;
|
||||
roiLimits[j].xmin = -1;
|
||||
roiLimits[j].xmax = -1;
|
||||
roiLimits[j].ymin = -1;
|
||||
roiLimits[j].ymax = -1;
|
||||
}
|
||||
// if adjacent, increase [i] range and replace all [j] with -1
|
||||
else if ((roiLimits[i].xmin) - 1 == roiLimits[j].xmax) {
|
||||
roiLimits[i].xmin = roiLimits[j].xmin;
|
||||
roiLimits[j].xmin = -1;
|
||||
roiLimits[j].xmax = -1;
|
||||
roiLimits[j].ymin = -1;
|
||||
roiLimits[j].ymax = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG1) << "Combined along x axis Getting ROI :\ndetector "
|
||||
<< n;
|
||||
for (int j = 0; j < n; ++j) {
|
||||
FILE_LOG(logDEBUG1)
|
||||
<< roiLimits[j].xmin << "\t" << roiLimits[j].xmax << "\t"
|
||||
<< roiLimits[j].ymin << "\t" << roiLimits[j].ymax;
|
||||
}
|
||||
|
||||
// combine all the adjacent rois in y direction
|
||||
for (int i = 0; i < n; ++i) {
|
||||
// since the ones combined are replaced by -1
|
||||
if ((roiLimits[i].ymin) == -1) {
|
||||
continue;
|
||||
}
|
||||
for (int j = i + 1; j < n; ++j) {
|
||||
// since the ones combined are replaced by -1
|
||||
if ((roiLimits[j].ymin) == -1) {
|
||||
continue;
|
||||
}
|
||||
// if x values are same
|
||||
if (((roiLimits[i].xmin) == (roiLimits[j].xmin)) &&
|
||||
((roiLimits[i].xmax) == (roiLimits[j].xmax))) {
|
||||
// if adjacent, increase [i] range and replace all [j] with -1
|
||||
if ((roiLimits[i].ymax) + 1 == roiLimits[j].ymin) {
|
||||
roiLimits[i].ymax = roiLimits[j].ymax;
|
||||
roiLimits[j].xmin = -1;
|
||||
roiLimits[j].xmax = -1;
|
||||
roiLimits[j].ymin = -1;
|
||||
roiLimits[j].ymax = -1;
|
||||
}
|
||||
// if adjacent, increase [i] range and replace all [j] with -1
|
||||
else if ((roiLimits[i].ymin) - 1 == roiLimits[j].ymax) {
|
||||
roiLimits[i].ymin = roiLimits[j].ymin;
|
||||
roiLimits[j].xmin = -1;
|
||||
roiLimits[j].xmax = -1;
|
||||
roiLimits[j].ymin = -1;
|
||||
roiLimits[j].ymax = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get rid of -1s
|
||||
for (int i = 0; i < n; ++i) {
|
||||
if ((roiLimits[i].xmin) != -1) {
|
||||
retval[num] = roiLimits[i];
|
||||
++num;
|
||||
}
|
||||
}
|
||||
// sort final roi
|
||||
for (int i = 0; i < num; ++i) {
|
||||
for (int j = i + 1; j < num; ++j) {
|
||||
if (retval[j].xmin < retval[i].xmin) {
|
||||
temproi = retval[i];
|
||||
retval[i] = retval[j];
|
||||
retval[j] = temproi;
|
||||
}
|
||||
}
|
||||
}
|
||||
n = num;
|
||||
|
||||
FILE_LOG(logDEBUG1) << "\nxmin\txmax\tymin\tymax";
|
||||
for (int i = 0; i < n; ++i) {
|
||||
FILE_LOG(logDEBUG1) << retval[i].xmin << "\t" << retval[i].xmax << "\t"
|
||||
<< retval[i].ymin << "\t" << retval[i].ymax;
|
||||
}
|
||||
return retval;
|
||||
return detectors[0]->getROI();
|
||||
}
|
||||
|
||||
void multiSlsDetector::setADCEnableMask(uint32_t mask, int detPos) {
|
||||
@ -2688,15 +2255,16 @@ int multiSlsDetector::enableGapPixels(int val, int detPos) {
|
||||
int ret = sls::minusOneIfDifferent(r);
|
||||
|
||||
if (val != -1) {
|
||||
updateOffsets();
|
||||
multi_shm()->numberOfChannelInclGapPixels[X] = sls::sum(parallelCall(&slsDetector::getTotalNumberOfChannelsInclGapPixels, X));
|
||||
multi_shm()->numberOfChannelInclGapPixels[Y] = sls::sum(parallelCall(&slsDetector::getTotalNumberOfChannelsInclGapPixels, Y));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void multiSlsDetector::setGapPixelsEnable(bool enable, Positions pos){
|
||||
Parallel(&slsDetector::enableGapPixels, pos, static_cast<int>(enable));
|
||||
|
||||
updateOffsets();
|
||||
multi_shm()->numberOfChannelInclGapPixels[X] = sls::sum(parallelCall(&slsDetector::getTotalNumberOfChannelsInclGapPixels, X));
|
||||
multi_shm()->numberOfChannelInclGapPixels[Y] = sls::sum(parallelCall(&slsDetector::getTotalNumberOfChannelsInclGapPixels, Y));
|
||||
}
|
||||
|
||||
int multiSlsDetector::setTrimEn(std::vector<int> energies, int detPos) {
|
||||
|
@ -308,15 +308,13 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
|
||||
shm()->controlPort = DEFAULT_PORTNO;
|
||||
sls::strcpy_safe(shm()->hostname, DEFAULT_HOSTNAME);
|
||||
shm()->myDetectorType = type;
|
||||
shm()->offset[X] = 0;
|
||||
shm()->offset[Y] = 0;
|
||||
shm()->multiSize[X] = 0;
|
||||
shm()->multiSize[Y] = 0;
|
||||
|
||||
shm()->controlPort = DEFAULT_PORTNO;
|
||||
shm()->stopPort = DEFAULT_PORTNO + 1;
|
||||
sls::strcpy_safe(shm()->settingsDir, getenv("HOME"));
|
||||
shm()->nROI = 0;
|
||||
memset(shm()->roiLimits, 0, MAX_ROIS * sizeof(ROI));
|
||||
shm()->roi.xmin = -1;
|
||||
shm()->roi.xmax = -1;
|
||||
shm()->adcEnableMask = BIT32_MASK;
|
||||
shm()->roFlags = NORMAL_READOUT;
|
||||
shm()->currentSettings = UNINITIALIZED;
|
||||
@ -688,28 +686,6 @@ int slsDetector::getReadNLines() {
|
||||
return retval;
|
||||
}
|
||||
|
||||
int slsDetector::getDetectorOffset(dimension d) const {
|
||||
return shm()->offset[d];
|
||||
}
|
||||
|
||||
slsDetectorDefs::coordinates slsDetector::getDetectorOffsets() const {
|
||||
slsDetectorDefs::coordinates coord;
|
||||
coord.x = shm()->offset[X];
|
||||
coord.y = shm()->offset[Y];
|
||||
return coord;
|
||||
}
|
||||
|
||||
void slsDetector::setDetectorOffset(dimension d, int off) {
|
||||
if (off >= 0) {
|
||||
shm()->offset[d] = off;
|
||||
}
|
||||
}
|
||||
|
||||
void slsDetector::setDetectorOffsets(slsDetectorDefs::coordinates value) {
|
||||
shm()->offset[X] = value.x;
|
||||
shm()->offset[Y] = value.y;
|
||||
}
|
||||
|
||||
void slsDetector::updateMultiSize(int detx, int dety) {
|
||||
shm()->multiSize[0] = detx;
|
||||
shm()->multiSize[1] = dety;
|
||||
@ -878,17 +854,9 @@ void slsDetector::updateCachedDetectorVariables() {
|
||||
// roi
|
||||
if (shm()->myDetectorType == GOTTHARD) {
|
||||
n += client.Receive(&i32, sizeof(i32));
|
||||
shm()->nROI = i32;
|
||||
for (int i = 0; i < shm()->nROI; ++i) {
|
||||
n += client.Receive(&i32, sizeof(i32));
|
||||
shm()->roiLimits[i].xmin = i32;
|
||||
n += client.Receive(&i32, sizeof(i32));
|
||||
shm()->roiLimits[i].xmax = i32;
|
||||
n += client.Receive(&i32, sizeof(i32));
|
||||
shm()->roiLimits[i].ymin = i32;
|
||||
n += client.Receive(&i32, sizeof(i32));
|
||||
shm()->roiLimits[i].xmax = i32;
|
||||
}
|
||||
shm()->roi.xmin = i32;
|
||||
n += client.Receive(&i32, sizeof(i32));
|
||||
shm()->roi.xmax = i32;
|
||||
}
|
||||
|
||||
if (shm()->myDetectorType == CHIPTESTBOARD ||
|
||||
@ -1849,7 +1817,7 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) {
|
||||
break;
|
||||
|
||||
case GOTTHARD:
|
||||
sendROI(-1, nullptr);
|
||||
sendROItoReceiver();
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -2344,44 +2312,27 @@ int slsDetector::setCounterBit(int cb) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
void slsDetector::setROI(int n, ROI roiLimits[]) {
|
||||
std::sort(roiLimits, roiLimits + n,
|
||||
[](ROI a, ROI b) { return a.xmin < b.xmin; });
|
||||
|
||||
sendROI(n, roiLimits);
|
||||
void slsDetector::clearROI() {
|
||||
FILE_LOG(logDEBUG1) << "Clearing ROI";
|
||||
slsDetectorDefs::ROI arg;
|
||||
arg.xmin = -1;
|
||||
arg.xmax = -1;
|
||||
setROI(arg);
|
||||
}
|
||||
|
||||
const slsDetectorDefs::ROI *slsDetector::getROI(int &n) {
|
||||
sendROI(-1, nullptr);
|
||||
n = shm()->nROI;
|
||||
return shm()->roiLimits;
|
||||
}
|
||||
|
||||
int slsDetector::getNRoi() { return shm()->nROI; }
|
||||
|
||||
void slsDetector::sendROI(int n, ROI roiLimits[]) {
|
||||
void slsDetector::setROI(slsDetectorDefs::ROI arg) {
|
||||
int fnum = F_SET_ROI;
|
||||
int ret = FAIL;
|
||||
int narg = n;
|
||||
// send roiLimits if given, else from shm
|
||||
ROI *arg = (roiLimits != nullptr) ? roiLimits : shm()->roiLimits;
|
||||
int nretval = 0;
|
||||
ROI retval[MAX_ROIS];
|
||||
FILE_LOG(logDEBUG1) << "Sending ROI to detector" << narg;
|
||||
|
||||
if (arg.xmin < 0 || arg.xmax >= getTotalNumberOfChannels()) {
|
||||
arg.xmin = -1;
|
||||
arg.xmax = -1;
|
||||
}
|
||||
FILE_LOG(logDEBUG) << "Sending ROI to detector [" << arg.xmin << ", " << arg.xmax << "]";
|
||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||
client.Send(&fnum, sizeof(fnum));
|
||||
client.Send(&narg, sizeof(narg));
|
||||
if (narg != -1) {
|
||||
for (int i = 0; i < narg; ++i) {
|
||||
client.Send(&arg[i].xmin, sizeof(int));
|
||||
client.Send(&arg[i].xmax, sizeof(int));
|
||||
client.Send(&arg[i].ymin, sizeof(int));
|
||||
client.Send(&arg[i].ymax, sizeof(int));
|
||||
}
|
||||
}
|
||||
client.Send(&arg.xmin, sizeof(int));
|
||||
client.Send(&arg.xmax, sizeof(int));
|
||||
client.Receive(&ret, sizeof(ret));
|
||||
|
||||
// handle ret
|
||||
if (ret == FAIL) {
|
||||
char mess[MAX_STR_LENGTH]{};
|
||||
@ -2389,65 +2340,63 @@ void slsDetector::sendROI(int n, ROI roiLimits[]) {
|
||||
throw RuntimeError("Detector " + std::to_string(detId) +
|
||||
" returned error: " + std::string(mess));
|
||||
} else {
|
||||
client.Receive(&nretval, sizeof(nretval));
|
||||
int nrec = 0;
|
||||
for (int i = 0; i < nretval; ++i) {
|
||||
nrec += client.Receive(&retval[i].xmin, sizeof(int));
|
||||
nrec += client.Receive(&retval[i].xmax, sizeof(int));
|
||||
nrec += client.Receive(&retval[i].ymin, sizeof(int));
|
||||
nrec += client.Receive(&retval[i].ymax, sizeof(int));
|
||||
}
|
||||
shm()->nROI = nretval;
|
||||
FILE_LOG(logDEBUG1) << "nRoi: " << nretval;
|
||||
for (int i = 0; i < nretval; ++i) {
|
||||
shm()->roiLimits[i] = retval[i];
|
||||
FILE_LOG(logDEBUG1)
|
||||
<< "ROI [" << i << "] (" << shm()->roiLimits[i].xmin << ","
|
||||
<< shm()->roiLimits[i].xmax << "," << shm()->roiLimits[i].ymin
|
||||
<< "," << shm()->roiLimits[i].ymax << ")";
|
||||
memcpy(&shm()->roi, &arg, sizeof(ROI));
|
||||
if (ret == FORCE_UPDATE) {
|
||||
updateCachedDetectorVariables();
|
||||
}
|
||||
}
|
||||
if (ret == FORCE_UPDATE) {
|
||||
updateCachedDetectorVariables();
|
||||
}
|
||||
|
||||
// old firmware requires configuremac after setting roi
|
||||
if (shm()->myDetectorType == GOTTHARD && n != -1) {
|
||||
if (shm()->myDetectorType == GOTTHARD) {
|
||||
configureMAC();
|
||||
}
|
||||
|
||||
sendROItoReceiver();
|
||||
}
|
||||
|
||||
void slsDetector::sendROItoReceiver() {
|
||||
// update roi in receiver
|
||||
if (shm()->useReceiverFlag) {
|
||||
fnum = F_RECEIVER_SET_ROI;
|
||||
ret = FAIL;
|
||||
narg = shm()->nROI;
|
||||
arg = shm()->roiLimits;
|
||||
FILE_LOG(logDEBUG1) << "Sending ROI to receiver: " << shm()->nROI;
|
||||
|
||||
auto receiver = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort);
|
||||
receiver.Send(&fnum, sizeof(fnum));
|
||||
receiver.Send(&narg, sizeof(narg));
|
||||
if (narg != -1) {
|
||||
for (int i = 0; i < narg; ++i) {
|
||||
receiver.Send(&arg[i].xmin, sizeof(int));
|
||||
receiver.Send(&arg[i].xmax, sizeof(int));
|
||||
receiver.Send(&arg[i].ymin, sizeof(int));
|
||||
receiver.Send(&arg[i].ymax, sizeof(int));
|
||||
}
|
||||
}
|
||||
receiver.Receive(&ret, sizeof(ret));
|
||||
|
||||
if (ret == FAIL) {
|
||||
char mess[MAX_STR_LENGTH]{};
|
||||
receiver.Receive(mess, MAX_STR_LENGTH);
|
||||
throw ReceiverError("Receiver " + std::to_string(detId) +
|
||||
" returned error: " + std::string(mess));
|
||||
}
|
||||
if (ret == FORCE_UPDATE) {
|
||||
updateCachedReceiverVariables();
|
||||
}
|
||||
FILE_LOG(logDEBUG1) << "Sending ROI to receiver";
|
||||
sendToReceiver(F_RECEIVER_SET_ROI, shm()->roi, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
slsDetectorDefs::ROI slsDetector::getROI() {
|
||||
int fnum = F_GET_ROI;
|
||||
int ret = FAIL;
|
||||
FILE_LOG(logDEBUG1) << "Getting ROI from detector";
|
||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||
client.Send(&fnum, sizeof(fnum));
|
||||
client.Receive(&ret, sizeof(ret));
|
||||
// handle ret
|
||||
if (ret == FAIL) {
|
||||
char mess[MAX_STR_LENGTH]{};
|
||||
client.Receive(mess, MAX_STR_LENGTH);
|
||||
throw RuntimeError("Detector " + std::to_string(detId) +
|
||||
" returned error: " + std::string(mess));
|
||||
} else {
|
||||
ROI retval;
|
||||
client.Receive(&retval.xmin, sizeof(int));
|
||||
client.Receive(&retval.xmax, sizeof(int));
|
||||
FILE_LOG(logDEBUG1)
|
||||
<< "ROI retval [" << retval.xmin << ","
|
||||
<< retval.xmax << "]";
|
||||
if (ret == FORCE_UPDATE) {
|
||||
updateCachedDetectorVariables();
|
||||
}
|
||||
// if different from shm, update and send to receiver
|
||||
if (shm()->roi.xmin != retval.xmin || shm()->roi.xmax != retval.xmax) {
|
||||
memcpy(&shm()->roi, &retval, sizeof(ROI));
|
||||
sendROItoReceiver();
|
||||
}
|
||||
}
|
||||
|
||||
return shm()->roi;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void slsDetector::setADCEnableMask(uint32_t mask) {
|
||||
uint32_t arg = mask;
|
||||
FILE_LOG(logDEBUG1) << "Setting ADC Enable mask to 0x" << std::hex << arg
|
||||
|
@ -308,7 +308,14 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
||||
++i;
|
||||
|
||||
/*! \page config
|
||||
- <b>roi [i] [xmin] [xmax] [ymin] [ymax] </b> sets region of interest of the detector, where i is number of rois;i=0 to clear rois. Used for GOTTHARD only. \c Returns \c (int)
|
||||
- <b>clearroi </b> resets region of interest of the detector. Used for GOTTHARD only. \c Returns \c (string)
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "clearroi";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdDetectorSize;
|
||||
++i;
|
||||
|
||||
/*! \page config
|
||||
- <b>roi [xmin] [xmax] </b> sets region of interest of the detector. Used for GOTTHARD only. \c Returns \c (int)
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "roi";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdDetectorSize;
|
||||
@ -3252,28 +3259,28 @@ std::string slsDetectorCommand::cmdDetectorSize(int narg, const char * const arg
|
||||
|
||||
if (action == HELP_ACTION)
|
||||
return helpDetectorSize(action);
|
||||
int ret, val = -1, pos = -1, i;
|
||||
int ret, val = -1;
|
||||
char ans[1000];
|
||||
|
||||
|
||||
if (action == PUT_ACTION) {
|
||||
if (!sscanf(args[1], "%d", &val))
|
||||
if (cmd != "roi" && !sscanf(args[1], "%d", &val))
|
||||
return std::string("could not scan ") + std::string(args[0]) + std::string(" ") + std::string(args[1]);
|
||||
|
||||
if (cmd == "clearroi") {
|
||||
myDet->clearROI(detPos);
|
||||
}
|
||||
|
||||
if (cmd == "roi") {
|
||||
//debug number of arguments
|
||||
if ((val < 0) || (narg != ((val * 4) + 2)))
|
||||
if (narg != 3)
|
||||
return helpDetectorSize(action);
|
||||
ROI allroi[val];
|
||||
pos = 2;
|
||||
for (i = 0; i < val; ++i) {
|
||||
if ((!sscanf(args[pos++], "%d", &allroi[i].xmin)) ||
|
||||
(!sscanf(args[pos++], "%d", &allroi[i].xmax)) ||
|
||||
(!sscanf(args[pos++], "%d", &allroi[i].ymin)) ||
|
||||
(!sscanf(args[pos++], "%d", &allroi[i].ymax)))
|
||||
return std::string("cannot parse arguments for roi");
|
||||
}
|
||||
myDet->setROI(val, allroi, detPos);
|
||||
ROI roi;
|
||||
if (!sscanf(args[1], "%d", &roi.xmin))
|
||||
return std::string("cannot parse arguments for roi xmin");
|
||||
if (!sscanf(args[2], "%d", &roi.xmax))
|
||||
return std::string("cannot parse arguments for roi xmax");
|
||||
myDet->setROI(roi, detPos);
|
||||
}
|
||||
|
||||
if (cmd == "detsizechan") {
|
||||
@ -3308,17 +3315,21 @@ std::string slsDetectorCommand::cmdDetectorSize(int narg, const char * const arg
|
||||
if ((!sscanf(args[1], "%d", &val)) || (val != 0 && val != 1))
|
||||
return std::string("cannot scan gappixels mode: must be 0 or 1");
|
||||
|
||||
if (detPos < 0) // only in multi detector level to update offsets etc.
|
||||
if (detPos < 0) // only in multi detector level to update number of channels etc.
|
||||
myDet->enableGapPixels(val, detPos);
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd == "dr") {
|
||||
ret = myDet->setDynamicRange(val, detPos);
|
||||
} else if (cmd == "clearroi") {
|
||||
if (action == GET_ACTION) {
|
||||
return std::string("Cannot get");
|
||||
}
|
||||
return std::string("successful");
|
||||
} else if (cmd == "roi") {
|
||||
const ROI* r = myDet->getROI(ret, detPos);
|
||||
|
||||
delete [] r;
|
||||
ROI roi = myDet->getROI(detPos);
|
||||
return (std::string("[") + std::to_string(roi.xmin) + std::string(",") + std::to_string(roi.xmax) + std::string("]"));
|
||||
} else if (cmd == "detsizechan") {
|
||||
sprintf(ans, "%d %d", myDet->getMaxNumberOfChannelsPerDetector(X), myDet->getMaxNumberOfChannelsPerDetector(Y));
|
||||
return std::string(ans);
|
||||
@ -3330,7 +3341,7 @@ std::string slsDetectorCommand::cmdDetectorSize(int narg, const char * const arg
|
||||
return std::string("Not required for this detector\n");
|
||||
ret = myDet->getFlippedData(Y, detPos);
|
||||
} else if (cmd == "gappixels") {
|
||||
if (detPos >= 0) // only in multi detector level to update offsets etc.
|
||||
if (detPos >= 0) // only in multi detector level to update number of channels etc.
|
||||
return std::string("Cannot execute this command from slsDetector level. Please use multiSlsDetector level.\n");
|
||||
ret = myDet->enableGapPixels(-1, detPos);
|
||||
}
|
||||
@ -3349,7 +3360,8 @@ std::string slsDetectorCommand::helpDetectorSize(int action) {
|
||||
std::ostringstream os;
|
||||
if (action == PUT_ACTION || action == HELP_ACTION) {
|
||||
os << "dr i \n sets the dynamic range of the detector" << std::endl;
|
||||
os << "roi i xmin xmax ymin ymax \n sets region of interest where i is number of rois;i=0 to clear rois" << std::endl;
|
||||
os << "clearroi \n resets region of interest" << std::endl;
|
||||
os << "roi xmin xmax \n sets region of interest " << std::endl;
|
||||
os << "detsizechan x y \n sets the maximum number of channels for complete detector set in both directions; -1 is no limit" << std::endl;
|
||||
os << "quad i \n if i = 1, sets the detector size to a quad (Specific to an EIGER quad hardware). 0 by default."<< std::endl;
|
||||
os << "flippeddatax x \n sets if the data should be flipped on the x axis" << std::endl;
|
||||
|
@ -14,14 +14,7 @@ int slsDetectorUsers::getMaximumDetectorSize(int &nx, int &ny){
|
||||
return nx*ny;
|
||||
}
|
||||
|
||||
int slsDetectorUsers::getDetectorSize(int &x, int &y, int &nx, int &ny, int detPos){
|
||||
if (detPos < 0) {
|
||||
x = 0;
|
||||
y = 0;
|
||||
} else {
|
||||
x = detector.getDetectorOffset(slsDetectorDefs::X, detPos);
|
||||
y = detector.getDetectorOffset(slsDetectorDefs::Y, detPos);
|
||||
}
|
||||
int slsDetectorUsers::getDetectorSize(int &nx, int &ny, int detPos){
|
||||
nx=detector.getTotalNumberOfChannels(slsDetectorDefs::X, detPos);
|
||||
ny=detector.getTotalNumberOfChannels(slsDetectorDefs::Y, detPos);
|
||||
return nx*ny;
|
||||
@ -226,12 +219,12 @@ int slsDetectorUsers::setFlowControl10G(int i, int detPos) {
|
||||
return detector.setFlowControl10G(i, detPos);
|
||||
}
|
||||
|
||||
void slsDetectorUsers::setROI(int n, slsDetectorDefs::ROI roiLimits[], int detPos) {
|
||||
detector.setROI(n, roiLimits, detPos);
|
||||
void slsDetectorUsers::setROI(slsDetectorDefs::ROI arg, int detPos) {
|
||||
detector.setROI(arg, detPos);
|
||||
}
|
||||
|
||||
const slsDetectorDefs::ROI* slsDetectorUsers::getROI(int &n, int detPos) {
|
||||
return detector.getROI(n, detPos);
|
||||
slsDetectorDefs::ROI slsDetectorUsers::getROI(int detPos) {
|
||||
return detector.getROI(detPos);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
|
@ -32,7 +32,7 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
||||
* @param nd pointer to number of detectors in each dimension
|
||||
* @param gpEnable pointer to gap pixels enable
|
||||
*/
|
||||
DataStreamer(int ind, Fifo* f, uint32_t* dr, std::vector<ROI>* r,
|
||||
DataStreamer(int ind, Fifo* f, uint32_t* dr, ROI* r,
|
||||
uint64_t* fi, int fd, char* ajh, int* nd, bool* gpEnable);
|
||||
|
||||
/**
|
||||
@ -188,7 +188,7 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
||||
uint32_t* dynamicRange;
|
||||
|
||||
/** ROI */
|
||||
std::vector<ROI>* roi;
|
||||
ROI* roi;
|
||||
|
||||
/** adc Configured */
|
||||
int adcConfigured;
|
||||
|
@ -142,17 +142,17 @@ public:
|
||||
* Set ROI
|
||||
* @param i ROI
|
||||
*/
|
||||
virtual void SetROI(std::vector<slsDetectorDefs::ROI> i) {
|
||||
virtual void SetROI(slsDetectorDefs::ROI i) {
|
||||
FILE_LOG(logERROR) << "SetROI is a generic function that should be overloaded by a derived class";
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Adc configured
|
||||
* @param index thread index for debugging purposes
|
||||
* @param i pointer to a vector of ROI pointers
|
||||
* @param ROI
|
||||
* @returns adc configured
|
||||
*/
|
||||
virtual int GetAdcConfigured(int index, std::vector<slsDetectorDefs::ROI>* i) const{
|
||||
virtual int GetAdcConfigured(int index, slsDetectorDefs::ROI i) const{
|
||||
FILE_LOG(logERROR) << "GetAdcConfigured is a generic function that should be overloaded by a derived class";
|
||||
return 0;
|
||||
};
|
||||
@ -311,9 +311,9 @@ private:
|
||||
* Set ROI
|
||||
* @param i ROI
|
||||
*/
|
||||
void SetROI(std::vector<slsDetectorDefs::ROI> i) {
|
||||
void SetROI(slsDetectorDefs::ROI i) {
|
||||
// all adcs
|
||||
if(!i.size()) {
|
||||
if(i.xmin == -1) {
|
||||
nPixelsX = 1280;
|
||||
dataSize = 1280;
|
||||
packetSize = GOTTHARD_PACKET_SIZE;
|
||||
@ -352,28 +352,21 @@ private:
|
||||
/**
|
||||
* Get Adc configured
|
||||
* @param index thread index for debugging purposes
|
||||
* @param i pointer to a vector of ROI
|
||||
* @param i ROI
|
||||
* @returns adc configured
|
||||
*/
|
||||
int GetAdcConfigured(int index, std::vector<slsDetectorDefs::ROI>* i) const{
|
||||
int GetAdcConfigured(int index, slsDetectorDefs::ROI i) const{
|
||||
int adc = -1;
|
||||
// single adc
|
||||
if(i->size()) {
|
||||
if(i.xmin != -1) {
|
||||
// gotthard can have only one adc per detector enabled (or all)
|
||||
// so just looking at the first roi is enough (more not possible at the moment)
|
||||
|
||||
//if its for 1 adc or general
|
||||
if ((i->at(0).xmin == 0) && (i->at(0).xmax == nChip * nChan))
|
||||
//adc = mid value/numchans also for only 1 roi
|
||||
adc = ((((i.xmax) + (i.xmin))/2)/
|
||||
(nChan * nChipsPerAdc));
|
||||
if((adc < 0) || (adc > 4)) {
|
||||
FILE_LOG(logWARNING) << index << ": Deleting ROI. "
|
||||
"Adc value should be between 0 and 4";
|
||||
adc = -1;
|
||||
else {
|
||||
//adc = mid value/numchans also for only 1 roi
|
||||
adc = ((((i->at(0).xmax) + (i->at(0).xmin))/2)/
|
||||
(nChan * nChipsPerAdc));
|
||||
if((adc < 0) || (adc > 4)) {
|
||||
FILE_LOG(logWARNING) << index << ": Deleting ROI. "
|
||||
"Adc value should be between 0 and 4";
|
||||
adc = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
FILE_LOG(logINFO) << "Adc Configured: " << adc;
|
||||
|
@ -207,9 +207,9 @@ class slsReceiverImplementation : private virtual slsDetectorDefs {
|
||||
//***acquisition parameters***
|
||||
/**
|
||||
* Get ROI
|
||||
* @return index of adc enabled, else -1 if all enabled
|
||||
* @return roi
|
||||
*/
|
||||
std::vector<ROI> getROI() const;
|
||||
ROI getROI() const;
|
||||
|
||||
/**
|
||||
* Get ADC Enable Mask
|
||||
@ -529,10 +529,10 @@ class slsReceiverImplementation : private virtual slsDetectorDefs {
|
||||
//***acquisition parameters***
|
||||
/**
|
||||
* Set ROI
|
||||
* @param i ROI
|
||||
* @param arg ROI
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int setROI(const std::vector<ROI> new_roi);
|
||||
int setROI(ROI arg);
|
||||
|
||||
/**
|
||||
* Set ADC Enable Mask
|
||||
@ -961,7 +961,7 @@ class slsReceiverImplementation : private virtual slsDetectorDefs {
|
||||
|
||||
//***acquisition parameters***
|
||||
/* ROI */
|
||||
std::vector<ROI> roi;
|
||||
ROI roi;
|
||||
/** ADC Enable Mask */
|
||||
uint32_t adcEnableMask;
|
||||
/** streaming frequency */
|
||||
|
@ -16,7 +16,7 @@
|
||||
const std::string DataStreamer::TypeName = "DataStreamer";
|
||||
|
||||
|
||||
DataStreamer::DataStreamer(int ind, Fifo* f, uint32_t* dr, std::vector<ROI>* r,
|
||||
DataStreamer::DataStreamer(int ind, Fifo* f, uint32_t* dr, ROI* r,
|
||||
uint64_t* fi, int fd, char* ajh, int* nd, bool* gpEnable) :
|
||||
ThreadObject(ind),
|
||||
runningFlag(0),
|
||||
@ -93,9 +93,9 @@ void DataStreamer::ResetParametersforNewMeasurement(const std::string& fname){
|
||||
delete[] completeBuffer;
|
||||
completeBuffer = nullptr;
|
||||
}
|
||||
if (roi->size()) {
|
||||
if (roi->xmin != -1) {
|
||||
if (generalData->myDetectorType == GOTTHARD) {
|
||||
adcConfigured = generalData->GetAdcConfigured(index, roi);
|
||||
adcConfigured = generalData->GetAdcConfigured(index, *roi);
|
||||
}
|
||||
completeBuffer = new char[generalData->imageSizeComplete];
|
||||
memset(completeBuffer, 0, generalData->imageSizeComplete);
|
||||
|
@ -104,7 +104,8 @@ void slsReceiverImplementation::InitializeMembers() {
|
||||
overwriteEnable = true;
|
||||
|
||||
//***acquisition parameters***
|
||||
roi.clear();
|
||||
roi.xmin = -1;
|
||||
roi.xmax = -1;
|
||||
adcEnableMask = BIT32_MASK;
|
||||
streamingFrequency = 0;
|
||||
streamingTimerInMs = DEFAULT_STREAMING_TIMER_IN_MS;
|
||||
@ -305,7 +306,7 @@ int slsReceiverImplementation::getNumberofUDPInterfaces() const {
|
||||
}
|
||||
|
||||
/***acquisition parameters***/
|
||||
std::vector<slsDetectorDefs::ROI> slsReceiverImplementation::getROI() const {
|
||||
slsDetectorDefs::ROI slsReceiverImplementation::getROI() const {
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
return roi;
|
||||
}
|
||||
@ -858,51 +859,21 @@ int slsReceiverImplementation::setUDPSocketBufferSize(const int64_t s) {
|
||||
}
|
||||
|
||||
/***acquisition parameters***/
|
||||
int slsReceiverImplementation::setROI(
|
||||
const std::vector<slsDetectorDefs::ROI> new_roi) {
|
||||
bool change = false;
|
||||
if (roi.size() != new_roi.size())
|
||||
change = true;
|
||||
else {
|
||||
for (size_t i = 0; i != new_roi.size(); ++i) {
|
||||
if ((roi[i].xmin != new_roi[i].xmin) ||
|
||||
(roi[i].xmax != new_roi[i].xmax) ||
|
||||
(roi[i].ymin != new_roi[i].ymin) ||
|
||||
(roi[i].xmax != new_roi[i].xmax)) {
|
||||
change = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
int slsReceiverImplementation::setROI(slsDetectorDefs::ROI arg) {
|
||||
if (roi.xmin != arg.xmin || roi.xmax != arg.xmax) {
|
||||
roi.xmin = arg.xmin;
|
||||
roi.xmax = arg.xmax;
|
||||
|
||||
if (change) {
|
||||
roi = new_roi;
|
||||
switch (myDetectorType) {
|
||||
case GOTTHARD:
|
||||
generalData->SetROI(new_roi);
|
||||
framesPerFile = generalData->maxFramesPerFile;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// only for gotthard
|
||||
generalData->SetROI(arg);
|
||||
framesPerFile = generalData->maxFramesPerFile;
|
||||
for (const auto &it : dataProcessor)
|
||||
it->SetPixelDimension();
|
||||
if (SetupFifoStructure() == FAIL)
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
std::stringstream sstm;
|
||||
sstm << "ROI: ";
|
||||
if (!roi.size())
|
||||
sstm << "0";
|
||||
else {
|
||||
for (size_t i = 0; i < roi.size(); ++i) {
|
||||
sstm << "( " << roi[i].xmin << ", " << roi[i].xmax << ", "
|
||||
<< roi[i].ymin << ", " << roi[i].ymax << " )";
|
||||
}
|
||||
}
|
||||
std::string message = sstm.str();
|
||||
FILE_LOG(logINFO) << message;
|
||||
FILE_LOG(logINFO) << "ROI: [" << roi.xmin << ", " << roi.xmax << "]";;
|
||||
FILE_LOG(logINFO) << "Packets per Frame: "
|
||||
<< (generalData->packetsPerFrame);
|
||||
return OK;
|
||||
|
@ -510,22 +510,12 @@ int slsReceiverTCPIPInterface::set_detector_hostname(Interface &socket) {
|
||||
}
|
||||
|
||||
int slsReceiverTCPIPInterface::set_roi(Interface &socket) {
|
||||
static_assert(sizeof(ROI) == 4 * sizeof(int), "ROI not packed");
|
||||
auto narg = socket.Receive<int>();
|
||||
std::vector<ROI> arg;
|
||||
for (int iloop = 0; iloop < narg; ++iloop) {
|
||||
ROI temp{};
|
||||
socket.Receive(temp);
|
||||
arg.push_back(temp);
|
||||
}
|
||||
FILE_LOG(logDEBUG1) << "Set ROI narg: " << narg;
|
||||
for (int iloop = 0; iloop < narg; ++iloop) {
|
||||
FILE_LOG(logDEBUG1)
|
||||
<< "(" << arg[iloop].xmin << ", " << arg[iloop].xmax << ", "
|
||||
<< arg[iloop].ymin << ", " << arg[iloop].ymax << ")";
|
||||
}
|
||||
static_assert(sizeof(ROI) == 2 * sizeof(int), "ROI not packed");
|
||||
ROI arg;
|
||||
socket.Receive(arg);
|
||||
FILE_LOG(logDEBUG1) << "Set ROI: [" << arg.xmin << ", " << arg.xmax << "]";
|
||||
|
||||
if (myDetectorType == EIGER || myDetectorType == JUNGFRAU)
|
||||
if (myDetectorType != GOTTHARD)
|
||||
functionNotImplemented();
|
||||
|
||||
VerifyIdle(socket);
|
||||
|
@ -220,12 +220,18 @@ format
|
||||
@short structure for a region of interest
|
||||
xmin,xmax,ymin,ymax define the limits of the region
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
struct ROI {
|
||||
int xmin{-1}; /**< is the roi xmin (in channel number) */
|
||||
int xmax{-1}; /**< is the roi xmax (in channel number)*/
|
||||
};
|
||||
#else
|
||||
typedef struct {
|
||||
int xmin; /**< is the roi xmin (in channel number) */
|
||||
int xmax; /**< is the roi xmax (in channel number)*/
|
||||
int ymin; /**< is the roi ymin (in channel number)*/
|
||||
int ymax; /**< is the roi ymax (in channel number)*/
|
||||
} ROI;
|
||||
} ROI;
|
||||
#endif
|
||||
|
||||
/**
|
||||
network parameters
|
||||
|
@ -35,6 +35,7 @@ enum detFuncs{
|
||||
F_SET_DYNAMIC_RANGE, /**< set/get detector dynamic range */
|
||||
F_SET_READOUT_FLAGS, /**< set/get readout flags */
|
||||
F_SET_ROI, /**< set/get region of interest */
|
||||
F_GET_ROI,
|
||||
F_SET_SPEED, /**< set/get readout speed parameters */
|
||||
F_EXIT_SERVER, /**< turn off detector server */
|
||||
F_LOCK_SERVER, /**< Locks/Unlocks server communication to the given client */
|
||||
@ -185,6 +186,7 @@ static const char* getFunctionNameFromEnum(enum detFuncs func) {
|
||||
case F_SET_DYNAMIC_RANGE: return "F_SET_DYNAMIC_RANGE";
|
||||
case F_SET_READOUT_FLAGS: return "F_SET_READOUT_FLAGS";
|
||||
case F_SET_ROI: return "F_SET_ROI";
|
||||
case F_GET_ROI: return "F_GET_ROI";
|
||||
case F_SET_SPEED: return "F_SET_SPEED";
|
||||
case F_EXIT_SERVER: return "F_EXIT_SERVER";
|
||||
case F_LOCK_SERVER: return "F_LOCK_SERVER";
|
||||
|
@ -2,9 +2,9 @@
|
||||
#define GITBRANCH "developer"
|
||||
#define APIMOENCH 0x181108
|
||||
#define APICTB 0x190604
|
||||
#define APIGOTTHARD 0x190715
|
||||
#define APILIB 0x190723
|
||||
#define APIRECEIVER 0x190722
|
||||
#define APIGUI 0x190723
|
||||
#define APIJUNGFRAU 0x190730
|
||||
#define APIEIGER 0x190809
|
||||
#define APIGOTTHARD 0x190813
|
||||
#define APIEIGER 0x190814
|
||||
|
Loading…
x
Reference in New Issue
Block a user