mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-26 00:00:02 +02:00
WIP
This commit is contained in:
parent
5b182469a1
commit
f0c576c779
@ -83,7 +83,8 @@ void ClientInterface::startTCPServer() {
|
||||
try {
|
||||
auto socket = server.accept();
|
||||
try {
|
||||
verifyLock();
|
||||
verifyLock(); // lock should be checked only for set (not get),
|
||||
// Move it back?
|
||||
ret = decodeFunction(socket);
|
||||
} catch (const RuntimeError &e) {
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
verifyIdle(socket);
|
||||
// verifyIdle(socket); allowing it to be set on the fly
|
||||
LOG(logDEBUG1) << "Setting additional json header: " << sls::ToString(json);
|
||||
impl()->setAdditionalJsonHeader(json);
|
||||
return socket.Send(OK);
|
||||
@ -1531,7 +1532,7 @@ int ClientInterface::increment_file_index(Interface &socket) {
|
||||
int ClientInterface::set_additional_json_parameter(Interface &socket) {
|
||||
char args[2][SHORT_STR_LENGTH]{};
|
||||
socket.Receive(args);
|
||||
verifyIdle(socket);
|
||||
// verifyIdle(socket); allowing it to be set on the fly
|
||||
LOG(logDEBUG1) << "Setting additional json parameter (" << args[0]
|
||||
<< "): " << args[1];
|
||||
impl()->setAdditionalJsonParameter(args[0], args[1]);
|
||||
|
@ -69,7 +69,9 @@ void DataStreamer::SetFlippedDataX(int fd) { flippedDataX = fd; }
|
||||
|
||||
void DataStreamer::SetAdditionalJsonHeader(
|
||||
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,
|
||||
@ -232,7 +234,13 @@ int DataStreamer::SendHeader(sls_receiver_header *rheader, uint32_t size,
|
||||
zHeader.quad = *quadEnable;
|
||||
zHeader.completeImage =
|
||||
(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);
|
||||
}
|
||||
|
@ -166,7 +166,17 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
||||
int flippedDataX;
|
||||
|
||||
/** 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 */
|
||||
bool startedFlag{nullptr};
|
||||
|
Loading…
x
Reference in New Issue
Block a user