mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-29 09:30:02 +02:00
WIP
This commit is contained in:
parent
5b182469a1
commit
f0c576c779
@ -83,7 +83,8 @@ void ClientInterface::startTCPServer() {
|
|||||||
try {
|
try {
|
||||||
auto socket = server.accept();
|
auto socket = server.accept();
|
||||||
try {
|
try {
|
||||||
verifyLock();
|
verifyLock(); // lock should be checked only for set (not get),
|
||||||
|
// Move it back?
|
||||||
ret = decodeFunction(socket);
|
ret = decodeFunction(socket);
|
||||||
} catch (const RuntimeError &e) {
|
} catch (const RuntimeError &e) {
|
||||||
// We had an error needs to be sent to client
|
// We had an error needs to be sent to client
|
||||||
@ -1115,7 +1116,7 @@ int ClientInterface::set_additional_json_header(Interface &socket) {
|
|||||||
json[key] = value;
|
json[key] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
verifyIdle(socket);
|
// verifyIdle(socket); allowing it to be set on the fly
|
||||||
LOG(logDEBUG1) << "Setting additional json header: " << sls::ToString(json);
|
LOG(logDEBUG1) << "Setting additional json header: " << sls::ToString(json);
|
||||||
impl()->setAdditionalJsonHeader(json);
|
impl()->setAdditionalJsonHeader(json);
|
||||||
return socket.Send(OK);
|
return socket.Send(OK);
|
||||||
@ -1531,7 +1532,7 @@ int ClientInterface::increment_file_index(Interface &socket) {
|
|||||||
int ClientInterface::set_additional_json_parameter(Interface &socket) {
|
int ClientInterface::set_additional_json_parameter(Interface &socket) {
|
||||||
char args[2][SHORT_STR_LENGTH]{};
|
char args[2][SHORT_STR_LENGTH]{};
|
||||||
socket.Receive(args);
|
socket.Receive(args);
|
||||||
verifyIdle(socket);
|
// verifyIdle(socket); allowing it to be set on the fly
|
||||||
LOG(logDEBUG1) << "Setting additional json parameter (" << args[0]
|
LOG(logDEBUG1) << "Setting additional json parameter (" << args[0]
|
||||||
<< "): " << args[1];
|
<< "): " << args[1];
|
||||||
impl()->setAdditionalJsonParameter(args[0], args[1]);
|
impl()->setAdditionalJsonParameter(args[0], args[1]);
|
||||||
|
@ -69,7 +69,9 @@ void DataStreamer::SetFlippedDataX(int fd) { flippedDataX = fd; }
|
|||||||
|
|
||||||
void DataStreamer::SetAdditionalJsonHeader(
|
void DataStreamer::SetAdditionalJsonHeader(
|
||||||
const std::map<std::string, std::string> &json) {
|
const std::map<std::string, std::string> &json) {
|
||||||
additionJsonHeader = json;
|
std::lock guard<std::mutex> guard(additionalJsonMutex);
|
||||||
|
additionalJsonHeader = json;
|
||||||
|
isAdditionalJsonUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataStreamer::CreateZmqSockets(int *nunits, uint32_t port,
|
void DataStreamer::CreateZmqSockets(int *nunits, uint32_t port,
|
||||||
@ -232,7 +234,13 @@ int DataStreamer::SendHeader(sls_receiver_header *rheader, uint32_t size,
|
|||||||
zHeader.quad = *quadEnable;
|
zHeader.quad = *quadEnable;
|
||||||
zHeader.completeImage =
|
zHeader.completeImage =
|
||||||
(header.packetNumber < generalData->packetsPerFrame ? false : true);
|
(header.packetNumber < generalData->packetsPerFrame ? false : true);
|
||||||
zHeader.addJsonHeader = additionJsonHeader;
|
|
||||||
|
if (isAdditionalJsonUpdated) {
|
||||||
|
std::lock_guard<std::mutex> guard(additionalalJsonMutex);
|
||||||
|
localAdditionalJsonHeader = additionalJsonHeader;
|
||||||
|
isAdditionalalJsonUpdated = false;
|
||||||
|
}
|
||||||
|
zHeader.addJsonHeader = localAdditionalJsonHeader;
|
||||||
|
|
||||||
return zmqSocket->SendHeader(index, zHeader);
|
return zmqSocket->SendHeader(index, zHeader);
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,17 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
int flippedDataX;
|
int flippedDataX;
|
||||||
|
|
||||||
/** additional json header */
|
/** additional json header */
|
||||||
std::map<std::string, std::string> additionJsonHeader;
|
std::map<std::string, std::string> additionalJsonHeader;
|
||||||
|
|
||||||
|
/** Used by streamer thread to update local copy (reduce number of locks
|
||||||
|
* during streaming) */
|
||||||
|
std::atomic<bool>{false};
|
||||||
|
|
||||||
|
/** mutex to update json and to read and update local copy */
|
||||||
|
std::mutex additionalJsonMutex;
|
||||||
|
|
||||||
|
/** local copy of additional json header (it can be update on the fly) */
|
||||||
|
std::map<std::string, std::string> localAdditionalJsonHeader;
|
||||||
|
|
||||||
/** Aquisition Started flag */
|
/** Aquisition Started flag */
|
||||||
bool startedFlag{nullptr};
|
bool startedFlag{nullptr};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user