rx_zmqstartfnum, not tested

This commit is contained in:
maliakal_d 2020-07-16 12:18:18 +02:00
parent ca298580f3
commit 67bb0dff1a
12 changed files with 94 additions and 6 deletions

View File

@ -695,6 +695,15 @@ class Detector {
*/ */
void setRxZmqTimer(int time_in_ms, Positions pos = {}); void setRxZmqTimer(int time_in_ms, Positions pos = {});
Result<int> getRxZmqStartingFrame(Positions pos = {}) const;
/**
* The starting frame index to stream out. 0 by default, which streams
* the first frame in an acquisition, and then depending on the rx zmq
* frequency/ timer.
*/
void setRxZmqStartingFrame(int fnum, Positions pos = {});
Result<int> getRxZmqPort(Positions pos = {}) const; Result<int> getRxZmqPort(Positions pos = {}) const;
/** /**

View File

@ -807,6 +807,7 @@ class CmdProxy {
/* ZMQ Streaming Parameters (Receiver<->Client) */ /* ZMQ Streaming Parameters (Receiver<->Client) */
{"rx_datastream", &CmdProxy::rx_datastream}, {"rx_datastream", &CmdProxy::rx_datastream},
{"rx_readfreq", &CmdProxy::rx_readfreq}, {"rx_readfreq", &CmdProxy::rx_readfreq},
{"rx_zmqstartfnum", &CmdProxy::rx_zmqstartfnum},
{"rx_zmqport", &CmdProxy::rx_zmqport}, {"rx_zmqport", &CmdProxy::rx_zmqport},
{"zmqport", &CmdProxy::zmqport}, {"zmqport", &CmdProxy::zmqport},
{"rx_zmqip", &CmdProxy::rx_zmqip}, {"rx_zmqip", &CmdProxy::rx_zmqip},
@ -1784,6 +1785,10 @@ class CmdProxy {
"[nth frame]\n\tStream out every nth frame. Default is 1. 0 means " "[nth frame]\n\tStream out every nth frame. Default is 1. 0 means "
"streaming every 200 ms and discarding frames in this interval."); "streaming every 200 ms and discarding frames in this interval.");
INTEGER_COMMAND(
rx_zmqstartfnum, getRxZmqStartingFrame, setRxZmqStartingFrame, StringTo<int>,
"[fnum]\n\tThe starting frame index to stream out. 0 by default, which streams the first frame in an acquisition, and then depending on the rx zmq frequency/ timer");
INTEGER_COMMAND( INTEGER_COMMAND(
rx_zmqport, getRxZmqPort, setRxZmqPort, StringTo<int>, rx_zmqport, getRxZmqPort, setRxZmqPort, StringTo<int>,
"[port]\n\tZmq port for data to be streamed out of the receiver. Also " "[port]\n\tZmq port for data to be streamed out of the receiver. Also "

View File

@ -954,6 +954,14 @@ void Detector::setRxZmqTimer(int time_in_ms, Positions pos) {
pimpl->Parallel(&Module::setReceiverStreamingTimer, pos, time_in_ms); pimpl->Parallel(&Module::setReceiverStreamingTimer, pos, time_in_ms);
} }
Result<int> Detector::getRxZmqStartingFrame(Positions pos) const {
return pimpl->Parallel(&Module::getReceiverStreamingStartingFrame, pos);
}
void Detector::setRxZmqStartingFrame(int fnum, Positions pos) {
pimpl->Parallel(&Module::setReceiverStreamingStartingFrame, pos, fnum);
}
Result<int> Detector::getRxZmqPort(Positions pos) const { Result<int> Detector::getRxZmqPort(Positions pos) const {
return pimpl->Parallel(&Module::getReceiverStreamingPort, pos); return pimpl->Parallel(&Module::getReceiverStreamingPort, pos);
} }

View File

@ -967,6 +967,18 @@ void Module::setReceiverStreamingTimer(int time_in_ms) {
sendToReceiver<int>(F_RECEIVER_STREAMING_TIMER, time_in_ms); sendToReceiver<int>(F_RECEIVER_STREAMING_TIMER, time_in_ms);
} }
int Module::getReceiverStreamingStartingFrame() {
return sendToReceiver<int>(F_GET_RECEIVER_STREAMING_START_FNUM);
}
void Module::setReceiverStreamingStartingFrame(int fnum) {
if (fnum < 0) {
throw RuntimeError("Invalid streaming starting frame number " +
std::to_string(fnum));
}
sendToReceiver(F_SET_RECEIVER_STREAMING_START_FNUM, fnum, nullptr);
}
int Module::getReceiverStreamingPort() { int Module::getReceiverStreamingPort() {
return sendToReceiver<int>(F_GET_RECEIVER_STREAMING_PORT); return sendToReceiver<int>(F_GET_RECEIVER_STREAMING_PORT);
} }

View File

@ -274,6 +274,8 @@ class Module : public virtual slsDetectorDefs {
void setReceiverStreamingFrequency(int freq); void setReceiverStreamingFrequency(int freq);
int getReceiverStreamingTimer(); int getReceiverStreamingTimer();
void setReceiverStreamingTimer(int time_in_ms = 200); void setReceiverStreamingTimer(int time_in_ms = 200);
int getReceiverStreamingStartingFrame();
void setReceiverStreamingStartingFrame(int fnum);
int getReceiverStreamingPort(); int getReceiverStreamingPort();
void setReceiverStreamingPort(int port); void setReceiverStreamingPort(int port);
sls::IpAddr getReceiverStreamingIP(); sls::IpAddr getReceiverStreamingIP();

View File

@ -199,6 +199,8 @@ int ClientInterface::functionTable(){
flist[F_SET_RECEIVER_NUM_GATES] = &ClientInterface::set_num_gates; flist[F_SET_RECEIVER_NUM_GATES] = &ClientInterface::set_num_gates;
flist[F_SET_RECEIVER_GATE_DELAY] = &ClientInterface::set_gate_delay; flist[F_SET_RECEIVER_GATE_DELAY] = &ClientInterface::set_gate_delay;
flist[F_GET_RECEIVER_THREAD_IDS] = &ClientInterface::get_thread_ids; flist[F_GET_RECEIVER_THREAD_IDS] = &ClientInterface::get_thread_ids;
flist[F_GET_RECEIVER_STREAMING_START_FNUM] = &ClientInterface::get_streaming_start_fnum;
flist[F_SET_RECEIVER_STREAMING_START_FNUM] = &ClientInterface::set_streaming_start_fnum;
for (int i = NUM_DET_FUNCTIONS + 1; i < NUM_REC_FUNCTIONS ; i++) { for (int i = NUM_DET_FUNCTIONS + 1; i < NUM_REC_FUNCTIONS ; i++) {
LOG(logDEBUG1) << "function fnum: " << i << " (" << LOG(logDEBUG1) << "function fnum: " << i << " (" <<
@ -1708,3 +1710,24 @@ int ClientInterface::get_thread_ids(Interface &socket) {
LOG(logDEBUG1) << "thread ids retval: " << sls::ToString(retval); LOG(logDEBUG1) << "thread ids retval: " << sls::ToString(retval);
return socket.sendResult(retval); return socket.sendResult(retval);
} }
int ClientInterface::get_streaming_start_fnum(Interface &socket) {
int retval = impl()->getStreamingStartingFrameNumber();
LOG(logDEBUG1) << "streaming start fnum:" << retval;
return socket.sendResult(retval);
}
int ClientInterface::set_streaming_start_fnum(Interface &socket) {
auto index = socket.Receive<int>();
if (index < 0) {
throw RuntimeError("Invalid streaming start frame number: " +
std::to_string(index));
}
verifyIdle(socket);
LOG(logDEBUG1) << "Setting streaming start fnum: " << index;
impl()->setStreamingStartingFrameNumber(index);
int retval = impl()->getStreamingStartingFrameNumber();
validate(index, retval, "set streaming start fnum", DEC);
return socket.Send(OK);
}

View File

@ -155,6 +155,8 @@ class ClientInterface : private virtual slsDetectorDefs {
int set_num_gates(sls::ServerInterface &socket); int set_num_gates(sls::ServerInterface &socket);
int set_gate_delay(sls::ServerInterface &socket); int set_gate_delay(sls::ServerInterface &socket);
int get_thread_ids(sls::ServerInterface &socket); int get_thread_ids(sls::ServerInterface &socket);
int get_streaming_start_fnum(sls::ServerInterface &socket);
int set_streaming_start_fnum(sls::ServerInterface &socket);
Implementation *impl() { Implementation *impl() {
if (receiver != nullptr) { if (receiver != nullptr) {

View File

@ -24,13 +24,14 @@ const std::string DataProcessor::TypeName = "DataProcessor";
DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo *f, DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo *f,
fileFormat *ftype, bool fwenable, bool *mfwenable, fileFormat *ftype, bool fwenable, bool *mfwenable,
bool *dsEnable, uint32_t *dr, uint32_t *freq, bool *dsEnable, uint32_t *dr, uint32_t *freq,
uint32_t *timer, bool *fp, bool *act, uint32_t *timer, uint32_t *sfnum, bool *fp, bool *act,
bool *depaden, bool *sm, bool *qe, bool *depaden, bool *sm, bool *qe,
std::vector<int> *cdl, int *cdo, int *cad) std::vector<int> *cdl, int *cdo, int *cad)
: ThreadObject(ind, TypeName), fifo(f), myDetectorType(dtype), : ThreadObject(ind, TypeName), fifo(f), myDetectorType(dtype),
dataStreamEnable(dsEnable), fileFormatType(ftype), dataStreamEnable(dsEnable), fileFormatType(ftype),
fileWriteEnable(fwenable), masterFileWriteEnable(mfwenable), fileWriteEnable(fwenable), masterFileWriteEnable(mfwenable),
dynamicRange(dr), streamingFrequency(freq), streamingTimerInMs(timer), dynamicRange(dr), streamingFrequency(freq), streamingTimerInMs(timer),
streamingStartFnum(sfnum),
activated(act), deactivatedPaddingEnable(depaden), silentMode(sm), activated(act), deactivatedPaddingEnable(depaden), silentMode(sm),
quadEnable(qe), framePadding(fp), ctbDbitList(cdl), ctbDbitOffset(cdo), quadEnable(qe), framePadding(fp), ctbDbitList(cdl), ctbDbitOffset(cdo),
ctbAnalogDataBytes(cad) { ctbAnalogDataBytes(cad) {
@ -229,7 +230,7 @@ void DataProcessor::ProcessAnImage(char *buf) {
timerBegin.tv_nsec -= ((*streamingTimerInMs) % 1000) * 1000000; timerBegin.tv_nsec -= ((*streamingTimerInMs) % 1000) * 1000000;
// to send first image // to send first image
currentFreqCount = *streamingFrequency; currentFreqCount = *streamingFrequency - *streamingStartFnum;
} }
} }

View File

@ -37,6 +37,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
* @param dr pointer to dynamic range * @param dr pointer to dynamic range
* @param freq pointer to streaming frequency * @param freq pointer to streaming frequency
* @param timer pointer to timer if streaming frequency is random * @param timer pointer to timer if streaming frequency is random
* @param sfnum pointer to streaming starting fnum
* @param fp pointer to frame padding enable * @param fp pointer to frame padding enable
* @param act pointer to activated * @param act pointer to activated
* @param depaden pointer to deactivated padding enable * @param depaden pointer to deactivated padding enable
@ -48,7 +49,8 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
*/ */
DataProcessor(int ind, detectorType dtype, Fifo *f, fileFormat *ftype, DataProcessor(int ind, detectorType dtype, Fifo *f, fileFormat *ftype,
bool fwenable, bool *mfwenable, bool *dsEnable, uint32_t *dr, bool fwenable, bool *mfwenable, bool *dsEnable, uint32_t *dr,
uint32_t *freq, uint32_t *timer, bool *fp, bool *act, uint32_t *freq, uint32_t *timer,
uint32_t *sfnum, bool *fp, bool *act,
bool *depaden, bool *sm, bool *qe, std::vector<int> *cdl, bool *depaden, bool *sm, bool *qe, std::vector<int> *cdl,
int *cdo, int *cad); int *cdo, int *cad);
@ -275,6 +277,9 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
/** Pointer to the timer if Streaming frequency is random */ /** Pointer to the timer if Streaming frequency is random */
uint32_t *streamingTimerInMs; uint32_t *streamingTimerInMs;
/** Pointer to streaming starting fnum */
uint32_t *streamingStartFnum;
/** Current frequency count */ /** Current frequency count */
uint32_t currentFreqCount{0}; uint32_t currentFreqCount{0};

View File

@ -91,6 +91,7 @@ void Implementation::InitializeMembers() {
dataStreamEnable = false; dataStreamEnable = false;
streamingFrequency = 1; streamingFrequency = 1;
streamingTimerInMs = DEFAULT_STREAMING_TIMER_IN_MS; streamingTimerInMs = DEFAULT_STREAMING_TIMER_IN_MS;
streamingStartFnum = 0;
streamingPort = 0; streamingPort = 0;
streamingSrcIP = sls::IpAddr{}; streamingSrcIP = sls::IpAddr{};
@ -292,7 +293,7 @@ void Implementation::setDetectorType(const detectorType d) {
dataProcessor.push_back(sls::make_unique<DataProcessor>( dataProcessor.push_back(sls::make_unique<DataProcessor>(
i, myDetectorType, fifo_ptr, &fileFormatType, fileWriteEnable, i, myDetectorType, fifo_ptr, &fileFormatType, fileWriteEnable,
&masterFileWriteEnable, &dataStreamEnable, &dynamicRange, &masterFileWriteEnable, &dataStreamEnable, &dynamicRange,
&streamingFrequency, &streamingTimerInMs, &framePadding, &streamingFrequency, &streamingTimerInMs, &streamingStartFnum, &framePadding,
&activated, &deactivatedPaddingEnable, &silentMode, &quadEnable, &activated, &deactivatedPaddingEnable, &silentMode, &quadEnable,
&ctbDbitList, &ctbDbitOffset, &ctbAnalogDataBytes)); &ctbDbitList, &ctbDbitOffset, &ctbAnalogDataBytes));
} catch (...) { } catch (...) {
@ -1017,7 +1018,7 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
dataProcessor.push_back(sls::make_unique<DataProcessor>( dataProcessor.push_back(sls::make_unique<DataProcessor>(
i, myDetectorType, fifo_ptr, &fileFormatType, i, myDetectorType, fifo_ptr, &fileFormatType,
fileWriteEnable, &masterFileWriteEnable, &dataStreamEnable, fileWriteEnable, &masterFileWriteEnable, &dataStreamEnable,
&dynamicRange, &streamingFrequency, &streamingTimerInMs, &dynamicRange, &streamingFrequency, &streamingTimerInMs, &streamingStartFnum,
&framePadding, &activated, &deactivatedPaddingEnable, &framePadding, &activated, &deactivatedPaddingEnable,
&silentMode, &quadEnable, &ctbDbitList, &ctbDbitOffset, &silentMode, &quadEnable, &ctbDbitList, &ctbDbitOffset,
&ctbAnalogDataBytes)); &ctbAnalogDataBytes));
@ -1232,6 +1233,18 @@ void Implementation::setStreamingTimer(const uint32_t time_in_ms) {
LOG(logINFO) << "Streamer Timer: " << streamingTimerInMs; LOG(logINFO) << "Streamer Timer: " << streamingTimerInMs;
} }
uint32_t Implementation::getStreamingStartingFrameNumber() const {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
return streamingStartFnum;
}
void Implementation::setStreamingStartingFrameNumber(const uint32_t fnum) {
if (streamingStartFnum != fnum) {
streamingStartFnum = fnum;
}
LOG(logINFO) << "Streaming Start Frame num: " << streamingStartFnum;
}
uint32_t Implementation::getStreamingPort() const { uint32_t Implementation::getStreamingPort() const {
LOG(logDEBUG3) << __SHORT_AT__ << " called"; LOG(logDEBUG3) << __SHORT_AT__ << " called";
return streamingPort; return streamingPort;

View File

@ -121,6 +121,8 @@ class Implementation : private virtual slsDetectorDefs {
void setStreamingFrequency(const uint32_t freq); void setStreamingFrequency(const uint32_t freq);
uint32_t getStreamingTimer() const; uint32_t getStreamingTimer() const;
void setStreamingTimer(const uint32_t time_in_ms); void setStreamingTimer(const uint32_t time_in_ms);
uint32_t getStreamingStartingFrameNumber() const;
void setStreamingStartingFrameNumber(const uint32_t fnum);
uint32_t getStreamingPort() const; uint32_t getStreamingPort() const;
void setStreamingPort(const uint32_t i); void setStreamingPort(const uint32_t i);
sls::IpAddr getStreamingSourceIP() const; sls::IpAddr getStreamingSourceIP() const;
@ -299,6 +301,7 @@ class Implementation : private virtual slsDetectorDefs {
bool dataStreamEnable; bool dataStreamEnable;
uint32_t streamingFrequency; uint32_t streamingFrequency;
uint32_t streamingTimerInMs; uint32_t streamingTimerInMs;
uint32_t streamingStartFnum;
uint32_t streamingPort; uint32_t streamingPort;
sls::IpAddr streamingSrcIP; sls::IpAddr streamingSrcIP;
std::map<std::string, std::string> additionalJsonHeader; std::map<std::string, std::string> additionalJsonHeader;

View File

@ -308,6 +308,8 @@ enum detFuncs {
F_SET_RECEIVER_NUM_GATES, F_SET_RECEIVER_NUM_GATES,
F_SET_RECEIVER_GATE_DELAY, F_SET_RECEIVER_GATE_DELAY,
F_GET_RECEIVER_THREAD_IDS, F_GET_RECEIVER_THREAD_IDS,
F_GET_RECEIVER_STREAMING_START_FNUM,
F_SET_RECEIVER_STREAMING_START_FNUM,
NUM_REC_FUNCTIONS NUM_REC_FUNCTIONS
}; };
@ -618,6 +620,9 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_SET_RECEIVER_GATE_DELAY: return "F_SET_RECEIVER_GATE_DELAY"; case F_SET_RECEIVER_GATE_DELAY: return "F_SET_RECEIVER_GATE_DELAY";
case F_GET_RECEIVER_THREAD_IDS: return "F_GET_RECEIVER_THREAD_IDS"; case F_GET_RECEIVER_THREAD_IDS: return "F_GET_RECEIVER_THREAD_IDS";
case F_GET_RECEIVER_STREAMING_START_FNUM: return "F_GET_RECEIVER_STREAMING_START_FNUM";
case F_SET_RECEIVER_STREAMING_START_FNUM: return "F_SET_RECEIVER_STREAMING_START_FNUM";
case NUM_REC_FUNCTIONS: return "NUM_REC_FUNCTIONS"; case NUM_REC_FUNCTIONS: return "NUM_REC_FUNCTIONS";
default: return "Unknown Function"; default: return "Unknown Function";
} }