mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 01:58:00 +02:00
Commandline (#66)
* WIP * WIP * removed status to string from defs * WIP * WIP * WIP removed unused functions in multi * WIP * print hex in a terrible way * WIP, loadconfig error * WIP, type to string * WIP * fix to conversion * WIP, hostname doesnt work * WIP * WIP * WIP * WIP, threshold * WIP, threshold * WIP * WIP, triggers * WIP, cycles to triggers * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * rx_udsocksize fx, WIP * WIP * WIP * WIP * file index (64 bit), WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * merge * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * New python mod
This commit is contained in:
@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "ThreadObject.h"
|
||||
#include "network_utils.h"
|
||||
|
||||
class GeneralData;
|
||||
class Fifo;
|
||||
@ -107,9 +108,9 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
||||
* (throws an exception if it couldnt create zmq sockets)
|
||||
* @param nunits pointer to number of theads/ units per detector
|
||||
* @param port streaming port start index
|
||||
* @param srcip streaming source ip
|
||||
* @param ip streaming source ip
|
||||
*/
|
||||
void CreateZmqSockets(int* nunits, uint32_t port, const char* srcip);
|
||||
void CreateZmqSockets(int* nunits, uint32_t port, const sls::IpAddr ip);
|
||||
|
||||
/**
|
||||
* Shuts down and deletes Zmq Sockets
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "logger.h"
|
||||
#include <cmath> //ceil
|
||||
#include <vector>
|
||||
#include "ToString.h"
|
||||
|
||||
|
||||
class GeneralData {
|
||||
@ -218,7 +219,7 @@ public:
|
||||
*/
|
||||
virtual void Print(TLogLevel level = logDEBUG1) const {
|
||||
FILE_LOG(level) << "\n\nDetector Data Variables:";
|
||||
FILE_LOG(level) << "myDetectorType: " << slsDetectorDefs::detectorTypeToString(myDetectorType);
|
||||
FILE_LOG(level) << "myDetectorType: " << sls::ToString(myDetectorType);
|
||||
FILE_LOG(level) << "Pixels X: " << nPixelsX;
|
||||
FILE_LOG(level) << "Pixels Y: " << nPixelsY;
|
||||
FILE_LOG(level) << "Header Size in Packet: " << headerSizeinPacket;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "container_utils.h"
|
||||
#include "logger.h"
|
||||
#include "receiver_defs.h"
|
||||
#include "network_utils.h"
|
||||
class GeneralData;
|
||||
class Listener;
|
||||
class DataProcessor;
|
||||
@ -352,7 +353,7 @@ class slsReceiverImplementation : private virtual slsDetectorDefs {
|
||||
* Get streaming source ip
|
||||
* @return streaming source ip
|
||||
*/
|
||||
std::string getStreamingSourceIP() const;
|
||||
sls::IpAddr getStreamingSourceIP() const;
|
||||
|
||||
/**
|
||||
* Get additional json header
|
||||
@ -571,7 +572,7 @@ class slsReceiverImplementation : private virtual slsDetectorDefs {
|
||||
* Set streaming source ip
|
||||
* @param c streaming source ip
|
||||
*/
|
||||
void setStreamingSourceIP(const char *c);
|
||||
void setStreamingSourceIP(const sls::IpAddr ip);
|
||||
|
||||
/**
|
||||
* Set additional json header
|
||||
@ -974,7 +975,7 @@ class slsReceiverImplementation : private virtual slsDetectorDefs {
|
||||
/** streaming port */
|
||||
uint32_t streamingPort;
|
||||
/** streaming port */
|
||||
char streamingSrcIP[MAX_STR_LENGTH];
|
||||
sls::IpAddr streamingSrcIP;
|
||||
/** additional json header */
|
||||
char additionalJsonHeader[MAX_STR_LENGTH];
|
||||
|
||||
|
@ -140,11 +140,11 @@ void DataStreamer::SetFlippedDataX(int fd) {
|
||||
flippedDataX = fd;
|
||||
}
|
||||
|
||||
void DataStreamer::CreateZmqSockets(int* nunits, uint32_t port, const char* srcip) {
|
||||
void DataStreamer::CreateZmqSockets(int* nunits, uint32_t port, const sls::IpAddr ip) {
|
||||
uint32_t portnum = port + index;
|
||||
|
||||
std::string sip = ip.str();
|
||||
try {
|
||||
zmqSocket = new ZmqSocket(portnum, (strlen(srcip)?srcip:nullptr));
|
||||
zmqSocket = new ZmqSocket(portnum, (ip != 0? sip.c_str(): nullptr));
|
||||
} catch (...) {
|
||||
FILE_LOG(logERROR) << "Could not create Zmq socket on port " << portnum << " for Streamer " << index;
|
||||
throw;
|
||||
|
@ -233,7 +233,7 @@ void Listener::ShutDownUDPSocket() {
|
||||
|
||||
|
||||
int Listener::CreateDummySocketForUDPSocketBufferSize(int64_t s) {
|
||||
FILE_LOG(logINFO) << "Testing UDP Socket Buffer size with test port " << *udpPortNumber;
|
||||
FILE_LOG(logINFO) << "Testing UDP Socket Buffer size " << s << " with test port " << *udpPortNumber;
|
||||
|
||||
if (!(*activated)) {
|
||||
*actualUDPSocketBufferSize = (s*2);
|
||||
@ -256,9 +256,11 @@ int Listener::CreateDummySocketForUDPSocketBufferSize(int64_t s) {
|
||||
|
||||
// doubled due to kernel bookkeeping (could also be less due to permissions)
|
||||
*actualUDPSocketBufferSize = g.getActualUDPSocketBufferSize();
|
||||
if (*actualUDPSocketBufferSize != (s*2)) {
|
||||
*udpSocketBufferSize = temp;
|
||||
}
|
||||
if (*actualUDPSocketBufferSize == -1) {
|
||||
*udpSocketBufferSize = temp;
|
||||
} else {
|
||||
*udpSocketBufferSize = (*actualUDPSocketBufferSize) / 2;
|
||||
}
|
||||
|
||||
} catch (...) {
|
||||
FILE_LOG(logERROR) << "Could not create a test UDP socket on port " << *udpPortNumber;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "Listener.h"
|
||||
#include "ZmqSocket.h" //just for the zmq port define
|
||||
#include "file_utils.h"
|
||||
#include "ToString.h"
|
||||
|
||||
#include <cerrno> //eperm
|
||||
#include <cstdlib> //system
|
||||
@ -111,7 +112,7 @@ void slsReceiverImplementation::InitializeMembers() {
|
||||
streamingTimerInMs = DEFAULT_STREAMING_TIMER_IN_MS;
|
||||
dataStreamEnable = false;
|
||||
streamingPort = 0;
|
||||
memset(streamingSrcIP, 0, sizeof(streamingSrcIP));
|
||||
streamingSrcIP = 0u;
|
||||
memset(additionalJsonHeader, 0, sizeof(additionalJsonHeader));
|
||||
|
||||
//** class objects ***
|
||||
@ -410,9 +411,9 @@ uint32_t slsReceiverImplementation::getStreamingPort() const {
|
||||
return streamingPort;
|
||||
}
|
||||
|
||||
std::string slsReceiverImplementation::getStreamingSourceIP() const {
|
||||
sls::IpAddr slsReceiverImplementation::getStreamingSourceIP() const {
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
return std::string(streamingSrcIP);
|
||||
return streamingSrcIP;
|
||||
}
|
||||
|
||||
std::string slsReceiverImplementation::getAdditionalJsonHeader() const {
|
||||
@ -560,7 +561,7 @@ int slsReceiverImplementation::setReadoutMode(const readoutMode f) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
FILE_LOG(logINFO) << "Readout Mode: " << getReadoutModeType(f);
|
||||
FILE_LOG(logINFO) << "Readout Mode: " << sls::ToString(f);
|
||||
FILE_LOG(logINFO) << "Packets per Frame: "
|
||||
<< (generalData->packetsPerFrame);
|
||||
return OK;
|
||||
@ -581,7 +582,7 @@ void slsReceiverImplementation::setFileFormat(const fileFormat f) {
|
||||
for (const auto &it : dataProcessor)
|
||||
it->SetFileFormat(f);
|
||||
|
||||
FILE_LOG(logINFO) << "File Format: " << getFileFormatType(fileFormatType);
|
||||
FILE_LOG(logINFO) << "File Format: " << sls::ToString(fileFormatType);
|
||||
}
|
||||
|
||||
void slsReceiverImplementation::setFileName(const char c[]) {
|
||||
@ -624,7 +625,7 @@ void slsReceiverImplementation::setFrameDiscardPolicy(
|
||||
frameDiscardMode = i;
|
||||
|
||||
FILE_LOG(logINFO) << "Frame Discard Policy: "
|
||||
<< getFrameDiscardPolicyType(frameDiscardMode);
|
||||
<< sls::ToString(frameDiscardMode);
|
||||
}
|
||||
|
||||
void slsReceiverImplementation::setFramePaddingEnable(const bool i) {
|
||||
@ -924,9 +925,9 @@ void slsReceiverImplementation::setStreamingPort(const uint32_t i) {
|
||||
FILE_LOG(logINFO) << "Streaming Port: " << streamingPort;
|
||||
}
|
||||
|
||||
void slsReceiverImplementation::setStreamingSourceIP(const char c[]) {
|
||||
void slsReceiverImplementation::setStreamingSourceIP(const sls::IpAddr ip) {
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
strcpy(streamingSrcIP, c);
|
||||
streamingSrcIP = ip;
|
||||
FILE_LOG(logINFO) << "Streaming Source IP: " << streamingSrcIP;
|
||||
}
|
||||
|
||||
@ -1122,7 +1123,7 @@ int slsReceiverImplementation::setDetectorType(const detectorType d) {
|
||||
case JUNGFRAU:
|
||||
case CHIPTESTBOARD:
|
||||
case MOENCH:
|
||||
FILE_LOG(logINFO) << " ***** " << detectorTypeToString(d)
|
||||
FILE_LOG(logINFO) << " ***** " << sls::ToString(d)
|
||||
<< " Receiver *****";
|
||||
break;
|
||||
default:
|
||||
@ -1196,7 +1197,7 @@ int slsReceiverImplementation::setDetectorType(const detectorType d) {
|
||||
it->SetGeneralData(generalData);
|
||||
SetThreadPriorities();
|
||||
|
||||
FILE_LOG(logDEBUG) << " Detector type set to " << detectorTypeToString(d);
|
||||
FILE_LOG(logDEBUG) << " Detector type set to " << sls::ToString(d);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -1275,7 +1276,7 @@ int slsReceiverImplementation::startReceiver(char *c) {
|
||||
StartRunning();
|
||||
|
||||
FILE_LOG(logINFO) << "Receiver Started";
|
||||
FILE_LOG(logINFO) << "Status: " << runStatusType(status);
|
||||
FILE_LOG(logINFO) << "Status: " << sls::ToString(status);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -1326,7 +1327,7 @@ void slsReceiverImplementation::stopReceiver() {
|
||||
}
|
||||
|
||||
status = RUN_FINISHED;
|
||||
FILE_LOG(logINFO) << "Status: " << runStatusType(status);
|
||||
FILE_LOG(logINFO) << "Status: " << sls::ToString(status);
|
||||
|
||||
{ // statistics
|
||||
uint64_t tot = 0;
|
||||
@ -1368,7 +1369,7 @@ void slsReceiverImplementation::stopReceiver() {
|
||||
status = IDLE;
|
||||
|
||||
FILE_LOG(logINFO) << "Receiver Stopped";
|
||||
FILE_LOG(logINFO) << "Status: " << runStatusType(status);
|
||||
FILE_LOG(logINFO) << "Status: " << sls::ToString(status);
|
||||
}
|
||||
|
||||
void slsReceiverImplementation::startReadout() {
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "sls_detector_exceptions.h"
|
||||
#include "string_utils.h"
|
||||
#include "versionAPI.h"
|
||||
#include "ToString.h"
|
||||
|
||||
#include <array>
|
||||
#include <cstdlib>
|
||||
@ -318,7 +319,7 @@ int slsReceiverTCPIPInterface::lock_receiver(Interface &socket) {
|
||||
}
|
||||
|
||||
int slsReceiverTCPIPInterface::get_last_client_ip(Interface &socket) {
|
||||
return socket.sendResult(server->getLastClient().arr());
|
||||
return socket.sendResult(server->getLastClient());
|
||||
}
|
||||
|
||||
int slsReceiverTCPIPInterface::set_port(Interface &socket) {
|
||||
@ -327,7 +328,7 @@ int slsReceiverTCPIPInterface::set_port(Interface &socket) {
|
||||
throw RuntimeError("Port Number: " + std::to_string(p_number) +
|
||||
" is too low (<1024)");
|
||||
|
||||
FILE_LOG(logINFO) << "set port to " << p_number << std::endl;
|
||||
FILE_LOG(logINFO) << "TCP port set to " << p_number << std::endl;
|
||||
auto new_server = sls::make_unique<sls::ServerSocket>(p_number);
|
||||
new_server->setLockedBy(server->getLockedBy());
|
||||
new_server->setLastClient(server->getThisClient());
|
||||
@ -347,11 +348,12 @@ int slsReceiverTCPIPInterface::update_client(Interface &socket) {
|
||||
int slsReceiverTCPIPInterface::send_update(Interface &socket) {
|
||||
int n = 0;
|
||||
int i32 = -1;
|
||||
int64_t i64 = -1;
|
||||
char cstring[MAX_STR_LENGTH]{};
|
||||
|
||||
char ip[INET_ADDRSTRLEN]{};
|
||||
sls::strcpy_safe(ip, server->getLastClient().str().c_str());
|
||||
n += socket.Send(ip, sizeof(ip));
|
||||
sls::IpAddr ip = 0u;
|
||||
ip = server->getLastClient();
|
||||
n += socket.Send(&ip, sizeof(ip));
|
||||
|
||||
// filepath
|
||||
sls::strcpy_safe(cstring, receiver->getFilePath().c_str());
|
||||
@ -362,8 +364,8 @@ int slsReceiverTCPIPInterface::send_update(Interface &socket) {
|
||||
n += socket.Send(cstring, sizeof(cstring));
|
||||
|
||||
// index
|
||||
i32 = receiver->getFileIndex();
|
||||
n += socket.Send(&i32, sizeof(i32));
|
||||
i64 = receiver->getFileIndex();
|
||||
n += socket.Send(&i64, sizeof(i64));
|
||||
|
||||
// file format
|
||||
i32 = (int)receiver->getFileFormat();
|
||||
@ -406,8 +408,8 @@ int slsReceiverTCPIPInterface::send_update(Interface &socket) {
|
||||
n += socket.Send(&i32, sizeof(i32));
|
||||
|
||||
// streaming source ip
|
||||
sls::strcpy_safe(cstring, receiver->getStreamingSourceIP().c_str());
|
||||
n += socket.Send(cstring, sizeof(cstring));
|
||||
ip = receiver->getStreamingSourceIP();
|
||||
n += socket.Send(&ip, sizeof(ip));
|
||||
|
||||
// additional json header
|
||||
sls::strcpy_safe(cstring, receiver->getAdditionalJsonHeader().c_str());
|
||||
@ -542,7 +544,7 @@ int slsReceiverTCPIPInterface::set_timer(Interface &socket) {
|
||||
ret = impl()->setAcquisitionPeriod(value);
|
||||
break;
|
||||
case FRAME_NUMBER:
|
||||
case CYCLES_NUMBER:
|
||||
case TRIGGER_NUMBER:
|
||||
case STORAGE_CELL_NUMBER:
|
||||
impl()->setNumberOfFrames(value);
|
||||
break;
|
||||
@ -583,7 +585,7 @@ int slsReceiverTCPIPInterface::set_timer(Interface &socket) {
|
||||
retval = impl()->getAcquisitionPeriod();
|
||||
break;
|
||||
case FRAME_NUMBER:
|
||||
case CYCLES_NUMBER:
|
||||
case TRIGGER_NUMBER:
|
||||
case STORAGE_CELL_NUMBER:
|
||||
retval = impl()->getNumberOfFrames();
|
||||
break;
|
||||
@ -669,16 +671,12 @@ int slsReceiverTCPIPInterface::set_streaming_frequency(Interface &socket) {
|
||||
|
||||
int slsReceiverTCPIPInterface::get_status(Interface &socket) {
|
||||
auto retval = impl()->getStatus();
|
||||
FILE_LOG(logDEBUG1) << "Status:" << runStatusType(retval);
|
||||
FILE_LOG(logDEBUG1) << "Status:" << sls::ToString(retval);
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
int slsReceiverTCPIPInterface::start_receiver(Interface &socket) {
|
||||
runStatus status = impl()->getStatus();
|
||||
if (status != IDLE) {
|
||||
throw RuntimeError("Cannot start Receiver as it is: " +
|
||||
runStatusType(status));
|
||||
} else {
|
||||
if (impl()->getStatus() == IDLE) {
|
||||
FILE_LOG(logDEBUG1) << "Starting Receiver";
|
||||
ret = impl()->startReceiver(mess);
|
||||
if (ret == FAIL) {
|
||||
@ -689,14 +687,14 @@ int slsReceiverTCPIPInterface::start_receiver(Interface &socket) {
|
||||
}
|
||||
|
||||
int slsReceiverTCPIPInterface::stop_receiver(Interface &socket) {
|
||||
if (impl()->getStatus() != IDLE) {
|
||||
if (impl()->getStatus() == RUNNING) {
|
||||
FILE_LOG(logDEBUG1) << "Stopping Receiver";
|
||||
impl()->stopReceiver();
|
||||
}
|
||||
auto s = impl()->getStatus();
|
||||
if (s != IDLE)
|
||||
throw RuntimeError("Could not stop receiver. It as it is: " +
|
||||
runStatusType(s));
|
||||
sls::ToString(s));
|
||||
|
||||
return socket.Send(OK);
|
||||
}
|
||||
@ -740,13 +738,13 @@ int slsReceiverTCPIPInterface::set_file_name(Interface &socket) {
|
||||
}
|
||||
|
||||
int slsReceiverTCPIPInterface::set_file_index(Interface &socket) {
|
||||
auto index = socket.Receive<int>();
|
||||
auto index = socket.Receive<int64_t>();
|
||||
if (index >= 0) {
|
||||
VerifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting file index: " << index;
|
||||
impl()->setFileIndex(index);
|
||||
}
|
||||
int retval = impl()->getFileIndex();
|
||||
int64_t retval = impl()->getFileIndex();
|
||||
validate(index, retval, "set file index", DEC);
|
||||
FILE_LOG(logDEBUG1) << "file index:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
@ -956,15 +954,19 @@ int slsReceiverTCPIPInterface::set_streaming_port(Interface &socket) {
|
||||
}
|
||||
|
||||
int slsReceiverTCPIPInterface::set_streaming_source_ip(Interface &socket) {
|
||||
char arg[MAX_STR_LENGTH]{};
|
||||
char retval[MAX_STR_LENGTH]{};
|
||||
sls::IpAddr arg = 0u;
|
||||
socket.Receive(arg);
|
||||
VerifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting streaming source ip:" << arg;
|
||||
impl()->setStreamingSourceIP(arg);
|
||||
sls::strcpy_safe(retval, impl()->getStreamingSourceIP().c_str());
|
||||
FILE_LOG(logDEBUG1) << "streaming source ip:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
sls::IpAddr retval = impl()->getStreamingSourceIP();
|
||||
if (retval != arg) {
|
||||
std::ostringstream os;
|
||||
os << "Could not set streaming ip. Set " << arg
|
||||
<< ", but read " << retval << '\n';
|
||||
throw RuntimeError(os.str());
|
||||
}
|
||||
return socket.Send(OK);
|
||||
}
|
||||
|
||||
int slsReceiverTCPIPInterface::set_silent_mode(Interface &socket) {
|
||||
|
Reference in New Issue
Block a user