mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 21:07:13 +02:00
Rx roi (#428)
* roi structure expanded to have ymin and ymax * compile with 'detector roi' * wip * wip, rx_roi, rx_clearroi * wip rxroi * rxroi wip * wip rxroi * merge fix * wip * rx_roi works, impl wip, test * tests in, impl left * wip, rxroi impl * wip, rxroi impl * wip * setrx_Roi works, getrx_roi, wip * rx_roi impl done * wip, rxroi * wip, getrx_roi rxr ports * fix ports * wip * wip * fix positions on server side * wip * numports wip * wip * jungfrau top inner interface row increment * x, y detpos, wip * removed eiger row indices flipping in gui (bottom flipping maintained) * wip * wip, jungfrau numinterfaces2 * jungfrau virtual works * eiger, jungfrau, g2 virtual server works * eiger positions fix, wip * binaries in * minor printout * binaries in * merge fix * merge fix * removing getposition * setrxroi wip * set upto port * get messed, wip * roi multi to module works, wip * wip * roi dont return -1 * added rxroi metadata in master file * added rxroifromshm, not yet in detector * rx roi in gui with box, also for gap pixels (gappixels for jungfrau mess) * fix for segfault in gui with detaching roi box in gui * wip * m3 gui: slave timing modes should be discarded when squashing * fixed m3 virtual data, and fixed counters in gui asthetics * m3 roi works * wip, g2 * wip * handling g225um boards, and showing roi for gainplot as well * udpate python functions * fix for 1d and a2d roi written * fixed actual roi written to file * no virtual hdf5 when handling rx roi * test * minor * binarie in
This commit is contained in:
@ -49,9 +49,6 @@
|
||||
// ctb/ moench 1g udp (read from fifo)
|
||||
#define UDP_PACKET_DATA_BYTES (1344)
|
||||
|
||||
/** maximum rois */
|
||||
#define MAX_ROIS 100
|
||||
|
||||
/** maximum trim en */
|
||||
#define MAX_TRIMEN 100
|
||||
|
||||
@ -172,13 +169,38 @@ class slsDetectorDefs {
|
||||
struct ROI {
|
||||
int xmin{-1};
|
||||
int xmax{-1};
|
||||
int ymin{-1};
|
||||
int ymax{-1};
|
||||
ROI() = default;
|
||||
ROI(int xmin, int xmax) : xmin(xmin), xmax(xmax){};
|
||||
ROI(int xmin, int xmax, int ymin, int ymax)
|
||||
: xmin(xmin), xmax(xmax), ymin(ymin), ymax(ymax){};
|
||||
constexpr std::array<int, 4> getIntArray() const {
|
||||
return std::array<int, 4> ({xmin, xmax, ymin, ymax});
|
||||
}
|
||||
constexpr bool completeRoi() const {
|
||||
return (xmin == -1 && xmax == -1 && ymin == -1 && ymax == -1);
|
||||
}
|
||||
constexpr bool noRoi() const {
|
||||
return (xmin == 0 && xmax == 0 && ymin == 0 && ymax == 0);
|
||||
}
|
||||
void setNoRoi() {
|
||||
xmin = 0;
|
||||
xmax = 0;
|
||||
ymin = 0;
|
||||
ymax = 0;
|
||||
}
|
||||
constexpr bool operator==(const ROI &other) const {
|
||||
return ((xmin == other.xmin) && (xmax == other.xmax) &&
|
||||
(ymin == other.ymin) && (ymax == other.ymax));
|
||||
}
|
||||
} __attribute__((packed));
|
||||
#else
|
||||
typedef struct {
|
||||
int xmin;
|
||||
int xmax;
|
||||
int ymin;
|
||||
int ymax;
|
||||
} ROI;
|
||||
#endif
|
||||
|
||||
|
@ -279,7 +279,7 @@ enum detFuncs {
|
||||
F_LOCK_RECEIVER,
|
||||
F_GET_LAST_RECEIVER_CLIENT_IP,
|
||||
F_GET_RECEIVER_VERSION,
|
||||
F_RECEIVER_SET_ROI,
|
||||
F_RECEIVER_SET_DETECTOR_ROI,
|
||||
F_RECEIVER_SET_NUM_FRAMES,
|
||||
F_SET_RECEIVER_NUM_TRIGGERS,
|
||||
F_SET_RECEIVER_NUM_BURSTS,
|
||||
@ -375,6 +375,9 @@ enum detFuncs {
|
||||
F_RECEIVER_SET_DATASTREAM,
|
||||
F_GET_RECEIVER_ARPING,
|
||||
F_SET_RECEIVER_ARPING,
|
||||
F_RECEIVER_GET_RECEIVER_ROI,
|
||||
F_RECEIVER_SET_RECEIVER_ROI,
|
||||
F_RECEIVER_SET_RECEIVER_ROI_METADATA,
|
||||
|
||||
NUM_REC_FUNCTIONS
|
||||
};
|
||||
@ -652,7 +655,7 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
||||
case F_LOCK_RECEIVER: return "F_LOCK_RECEIVER";
|
||||
case F_GET_LAST_RECEIVER_CLIENT_IP: return "F_GET_LAST_RECEIVER_CLIENT_IP";
|
||||
case F_GET_RECEIVER_VERSION: return "F_GET_RECEIVER_VERSION";
|
||||
case F_RECEIVER_SET_ROI: return "F_RECEIVER_SET_ROI";
|
||||
case F_RECEIVER_SET_DETECTOR_ROI: return "F_RECEIVER_SET_DETECTOR_ROI";
|
||||
case F_RECEIVER_SET_NUM_FRAMES: return "F_RECEIVER_SET_NUM_FRAMES";
|
||||
case F_SET_RECEIVER_NUM_TRIGGERS: return "F_SET_RECEIVER_NUM_TRIGGERS";
|
||||
case F_SET_RECEIVER_NUM_BURSTS: return "F_SET_RECEIVER_NUM_BURSTS";
|
||||
@ -748,6 +751,9 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
||||
case F_RECEIVER_SET_DATASTREAM: return "F_RECEIVER_SET_DATASTREAM";
|
||||
case F_GET_RECEIVER_ARPING: return "F_GET_RECEIVER_ARPING";
|
||||
case F_SET_RECEIVER_ARPING: return "F_SET_RECEIVER_ARPING";
|
||||
case F_RECEIVER_GET_RECEIVER_ROI: return "F_RECEIVER_GET_RECEIVER_ROI";
|
||||
case F_RECEIVER_SET_RECEIVER_ROI: return "F_RECEIVER_SET_RECEIVER_ROI";
|
||||
case F_RECEIVER_SET_RECEIVER_ROI_METADATA: return "F_RECEIVER_SET_RECEIVER_ROI_METADATA";
|
||||
|
||||
case NUM_REC_FUNCTIONS: return "NUM_REC_FUNCTIONS";
|
||||
default: return "Unknown Function";
|
||||
|
@ -1,15 +1,14 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
/** API versions */
|
||||
#define GITBRANCH "developer"
|
||||
#define APILIB 0x220408
|
||||
#define APIRECEIVER 0x220408
|
||||
#define APIGUI 0x220328
|
||||
|
||||
#define APICTB 0x220428
|
||||
#define APIGOTTHARD 0x220428
|
||||
#define APIGOTTHARD2 0x220428
|
||||
#define APIJUNGFRAU 0x220428
|
||||
#define APIMOENCH 0x220427
|
||||
#define APIEIGER 0x220428
|
||||
#define APIMYTHEN3 0x220510
|
||||
#define GITBRANCH "developer"
|
||||
#define APILIB 0x220408
|
||||
#define APIRECEIVER 0x220408
|
||||
#define APIGUI 0x220328
|
||||
#define APICTB 0x220516
|
||||
#define APIGOTTHARD 0x220516
|
||||
#define APIGOTTHARD2 0x220516
|
||||
#define APIJUNGFRAU 0x220516
|
||||
#define APIMYTHEN3 0x220516
|
||||
#define APIMOENCH 0x220503
|
||||
#define APIEIGER 0x220516
|
||||
|
@ -31,8 +31,10 @@ ServerSocket::ServerSocket(int port)
|
||||
if (bind(getSocketId(), (struct sockaddr *)&serverAddr,
|
||||
sizeof(serverAddr)) != 0) {
|
||||
close();
|
||||
throw sls::SocketError("Server ERROR: cannot bind socket. Please check "
|
||||
"if another instance is running.");
|
||||
throw sls::SocketError(
|
||||
std::string("Server ERROR: cannot bind socket with port number ") +
|
||||
std::to_string(port) +
|
||||
std::string(". Please check if another instance is running."));
|
||||
}
|
||||
if (listen(getSocketId(), DEFAULT_BACKLOG) != 0) {
|
||||
close();
|
||||
|
@ -17,7 +17,11 @@ std::ostream &operator<<(std::ostream &os, const slsDetectorDefs::xy &coord) {
|
||||
|
||||
std::string ToString(const slsDetectorDefs::ROI &roi) {
|
||||
std::ostringstream oss;
|
||||
oss << '[' << roi.xmin << ", " << roi.xmax << ']';
|
||||
oss << '[' << roi.xmin << ", " << roi.xmax;
|
||||
if (roi.ymin != -1 || roi.ymax != -1) {
|
||||
oss << ", " << roi.ymin << ", " << roi.ymax;
|
||||
}
|
||||
oss << ']';
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
|
@ -131,82 +131,57 @@ int ZmqSocket::Connect() {
|
||||
}
|
||||
|
||||
int ZmqSocket::SendHeader(int index, zmqHeader header) {
|
||||
std::ostringstream oss;
|
||||
oss << "{\"jsonversion\":" << header.jsonversion
|
||||
<< ", \"bitmode\":" << header.dynamicRange
|
||||
<< ", \"fileIndex\":" << header.fileIndex << ", \"detshape\":["
|
||||
<< header.ndetx << ", " << header.ndety << ']' << ", \"shape\":["
|
||||
<< header.npixelsx << ", " << header.npixelsy << ']'
|
||||
<< ", \"size\":" << header.imageSize
|
||||
<< ", \"acqIndex\":" << header.acqIndex
|
||||
<< ", \"frameIndex\":" << header.frameIndex
|
||||
<< ", \"progress\":" << header.progress << ", \"fname\":\""
|
||||
<< header.fname << '\"' << ", \"data\":" << (header.data ? 1 : 0)
|
||||
<< ", \"completeImage\":" << (header.completeImage ? 1 : 0)
|
||||
|
||||
/** Json Header Format */
|
||||
const char jsonHeaderFormat[] = "{"
|
||||
"\"jsonversion\":%u, "
|
||||
"\"bitmode\":%u, "
|
||||
"\"fileIndex\":%lu, "
|
||||
"\"detshape\":[%u, %u], "
|
||||
"\"shape\":[%u, %u], "
|
||||
"\"size\":%u, "
|
||||
"\"acqIndex\":%lu, "
|
||||
"\"frameIndex\":%lu, "
|
||||
"\"progress\":%lf, "
|
||||
"\"fname\":\"%s\", "
|
||||
"\"data\": %d, "
|
||||
"\"completeImage\": %d, "
|
||||
<< ", \"frameNumber\":" << header.frameNumber
|
||||
<< ", \"expLength\":" << header.expLength
|
||||
<< ", \"packetNumber\":" << header.packetNumber
|
||||
<< ", \"bunchId\":" << header.bunchId
|
||||
<< ", \"timestamp\":" << header.timestamp
|
||||
<< ", \"modId\":" << header.modId << ", \"row\":" << header.row
|
||||
<< ", \"column\":" << header.column
|
||||
<< ", \"reserved\":" << header.reserved
|
||||
<< ", \"debug\":" << header.debug
|
||||
<< ", \"roundRNumber\":" << header.roundRNumber
|
||||
<< ", \"detType\":" << static_cast<int>(header.detType)
|
||||
<< ", \"version\":"
|
||||
<< static_cast<int>(header.version)
|
||||
|
||||
"\"frameNumber\":%lu, "
|
||||
"\"expLength\":%u, "
|
||||
"\"packetNumber\":%u, "
|
||||
"\"bunchId\":%lu, "
|
||||
"\"timestamp\":%lu, "
|
||||
"\"modId\":%u, "
|
||||
"\"row\":%u, "
|
||||
"\"column\":%u, "
|
||||
"\"reserved\":%u, "
|
||||
"\"debug\":%u, "
|
||||
"\"roundRNumber\":%u, "
|
||||
"\"detType\":%u, "
|
||||
"\"version\":%u, "
|
||||
|
||||
// additional stuff
|
||||
"\"flipRows\":%u, "
|
||||
"\"quad\":%u"
|
||||
|
||||
; //"}\n";
|
||||
memset(header_buffer.get(), '\0', MAX_STR_LENGTH); // TODO! Do we need this
|
||||
sprintf(header_buffer.get(), jsonHeaderFormat, header.jsonversion,
|
||||
header.dynamicRange, header.fileIndex, header.ndetx, header.ndety,
|
||||
header.npixelsx, header.npixelsy, header.imageSize, header.acqIndex,
|
||||
header.frameIndex, header.progress, header.fname.c_str(),
|
||||
header.data ? 1 : 0, header.completeImage ? 1 : 0,
|
||||
|
||||
header.frameNumber, header.expLength, header.packetNumber,
|
||||
header.bunchId, header.timestamp, header.modId, header.row,
|
||||
header.column, header.reserved, header.debug, header.roundRNumber,
|
||||
header.detType, header.version,
|
||||
|
||||
// additional stuff
|
||||
header.flipRows, header.quad);
|
||||
// additional stuff
|
||||
<< ", \"flipRows\":" << header.flipRows << ", \"quad\":" << header.quad;
|
||||
|
||||
if (!header.addJsonHeader.empty()) {
|
||||
strcat(header_buffer.get(), ", ");
|
||||
strcat(header_buffer.get(), "\"addJsonHeader\": {");
|
||||
oss << ", \"addJsonHeader\": {";
|
||||
for (auto it = header.addJsonHeader.begin();
|
||||
it != header.addJsonHeader.end(); ++it) {
|
||||
if (it != header.addJsonHeader.begin()) {
|
||||
strcat(header_buffer.get(), ", ");
|
||||
oss << ", ";
|
||||
}
|
||||
strcat(header_buffer.get(), "\"");
|
||||
strcat(header_buffer.get(), it->first.c_str());
|
||||
strcat(header_buffer.get(), "\":\"");
|
||||
strcat(header_buffer.get(), it->second.c_str());
|
||||
strcat(header_buffer.get(), "\"");
|
||||
oss << "\"" << it->first.c_str() << "\":\"" << it->second.c_str()
|
||||
<< "\"";
|
||||
}
|
||||
strcat(header_buffer.get(), " } ");
|
||||
oss << " } ";
|
||||
}
|
||||
|
||||
strcat(header_buffer.get(), "}\n");
|
||||
int length = strlen(header_buffer.get());
|
||||
|
||||
#ifdef VERBOSE
|
||||
oss << "}\n";
|
||||
std::string message = oss.str();
|
||||
int length = message.length();
|
||||
#ifdef ZMQ_DETAIL
|
||||
// if(!index)
|
||||
cprintf(BLUE, "%d : Streamer: buf: %s\n", index, buf);
|
||||
LOG(logINFOBLUE) << index << " : Streamer: buf: " << message;
|
||||
#endif
|
||||
|
||||
if (zmq_send(sockfd.socketDescriptor, header_buffer.get(), length,
|
||||
if (zmq_send(sockfd.socketDescriptor, message.c_str(), length,
|
||||
header.data ? ZMQ_SNDMORE : 0) < 0) {
|
||||
PrintError();
|
||||
return 0;
|
||||
@ -232,13 +207,13 @@ int ZmqSocket::ReceiveHeader(const int index, zmqHeader &zHeader,
|
||||
if (bytes_received > 0) {
|
||||
#ifdef ZMQ_DETAIL
|
||||
cprintf(BLUE, "Header %d [%d] Length: %d Header:%s \n", index, portno,
|
||||
bytes_received, buffer.data());
|
||||
bytes_received, header_buffer.get());
|
||||
#endif
|
||||
if (ParseHeader(index, bytes_received, header_buffer.get(), zHeader,
|
||||
version)) {
|
||||
#ifdef ZMQ_DETAIL
|
||||
cprintf(RED, "Parsed Header %d [%d] Length: %d Header:%s \n", index,
|
||||
portno, bytes_received, buffer.data());
|
||||
portno, bytes_received, header_buffer.get());
|
||||
#endif
|
||||
if (!zHeader.data) {
|
||||
#ifdef ZMQ_DETAIL
|
||||
@ -333,7 +308,7 @@ int ZmqSocket::ReceiveData(const int index, char *buf, const int size) {
|
||||
memset(buf + length, 0xFF, size - length);
|
||||
} else {
|
||||
LOG(logERROR) << "Received weird packet size " << length
|
||||
<< " for socket " << index;
|
||||
<< " (expected " << size << ") for socket " << index;
|
||||
memset(buf, 0xFF, size);
|
||||
}
|
||||
|
||||
|
@ -227,14 +227,19 @@ TEST_CASE("Detector type") {
|
||||
TEST_CASE("Formatting slsDetectorDefs::ROI") {
|
||||
slsDetectorDefs::ROI roi(5, 159);
|
||||
REQUIRE(ToString(roi) == "[5, 159]");
|
||||
slsDetectorDefs::ROI roi1(5, 159, 6, 170);
|
||||
REQUIRE(ToString(roi1) == "[5, 159, 6, 170]");
|
||||
}
|
||||
|
||||
TEST_CASE("Streaming of slsDetectorDefs::ROI") {
|
||||
using namespace sls;
|
||||
slsDetectorDefs::ROI roi(-10, 1);
|
||||
std::ostringstream oss;
|
||||
std::ostringstream oss, oss1;
|
||||
oss << roi;
|
||||
REQUIRE(oss.str() == "[-10, 1]");
|
||||
slsDetectorDefs::ROI roi1(-10, 1, 5, 11);
|
||||
oss1 << roi1;
|
||||
REQUIRE(oss1.str() == "[-10, 1, 5, 11]");
|
||||
}
|
||||
|
||||
TEST_CASE("std::array") {
|
||||
|
Reference in New Issue
Block a user