mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 12:57: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:
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user