moench: get zmq goes to the receiver instead of shm, setand get threshold energey updates zmq and shm value, setand get roi anyways goes to the ddetector, so only updates zmq or gets it from rxr

This commit is contained in:
2019-02-25 12:57:44 +01:00
parent 4c7a9cd838
commit 966896b942
4 changed files with 73 additions and 4 deletions

View File

@ -1281,6 +1281,24 @@ slsDetectorDefs::detectorSettings slsDetector::sendSettingsOnly(detectorSettings
}
int slsDetector::getThresholdEnergy() {
// moench - get threshold energy from processor (due to different clients, diff shm)
if (thisDetector->myDetectorType == MOENCH) {
// get json from rxr, parse for threshold and update shm
getAdditionalJsonHeader();
std::string result = getAdditionalJsonParameter("threshold");
// convert to integer
try {
// udpate shm
thisDetector->currentThresholdEV = stoi(result);
return thisDetector->currentThresholdEV;
}
// not found or cannot scan integer
catch(...) {
return -1;
}
}
int fnum = F_GET_THRESHOLD_ENERGY;
int ret = FAIL;
int retval = -1;
@ -1316,8 +1334,11 @@ int slsDetector::setThresholdEnergy(int e_eV, detectorSettings isettings, int tb
// moench - send threshold energy to processor
else if (thisDetector->myDetectorType == MOENCH) {
std::string result = setAdditionalJsonParameter("threshold", std::to_string(e_eV));
if (result == std::to_string(e_eV))
return e_eV;
if (result == std::to_string(e_eV)) {
// update shm
thisDetector->currentThresholdEV = e_eV;
return thisDetector->currentThresholdEV;
}
return -1;
}
@ -2412,7 +2433,7 @@ std::string slsDetector::setReceiver(const std::string &receiverIP) {
setReceiverStreamingFrequency(thisDetector->receiver_read_freq);
setReceiverStreamingPort(getReceiverStreamingPort());
setReceiverStreamingIP(getReceiverStreamingIP());
setAdditionalJsonHeader(getAdditionalJsonHeader());
setAdditionalJsonHeader(thisDetector->receiver_additionalJsonHeader);
enableDataStreamingFromReceiver(enableDataStreamingFromReceiver(-1));
if (thisDetector->myDetectorType == GOTTHARD) {
sendROI(-1, nullptr);
@ -2670,10 +2691,29 @@ std::string slsDetector::setAdditionalJsonHeader(const std::string &jsonheader)
if (ret == FORCE_UPDATE) {
ret = updateReceiver();
}
return getAdditionalJsonHeader();
return std::string(thisDetector->receiver_additionalJsonHeader);
}
std::string slsDetector::getAdditionalJsonHeader() {
int fnum = F_GET_ADDITIONAL_JSON_HEADER;
int ret = FAIL;
char retvals[MAX_STR_LENGTH] = {0};
FILE_LOG(logDEBUG1) << "Getting additional json header ";
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, nullptr, 0, retvals, sizeof(retvals));
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (COULDNOT_SET_NETWORK_PARAMETER));
} else {
FILE_LOG(logDEBUG1) << "Additional json header: " << retvals;
memset(thisDetector->receiver_additionalJsonHeader, 0, MAX_STR_LENGTH);
sls::strcpy_safe(thisDetector->receiver_additionalJsonHeader, retvals);
}
}
if (ret == FORCE_UPDATE) {
ret = updateReceiver();
}
return std::string(thisDetector->receiver_additionalJsonHeader);
}
@ -3068,6 +3108,10 @@ slsDetectorDefs::ROI *slsDetector::getROI(int &n) {
n = thisDetector->nROI;
if (thisDetector->myDetectorType == CHIPTESTBOARD || thisDetector->myDetectorType == MOENCH) {
getTotalNumberOfChannels();
// moench - get json header(due to different clients, diff shm) (get roi is from detector: updated anyway)
if (thisDetector->myDetectorType == MOENCH) {
getAdditionalJsonHeader();
}
}
return thisDetector->roiLimits;
}

View File

@ -253,6 +253,9 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
/** set additional json header */
int set_additional_json_header();
/** get additional json header */
int get_additional_json_header();
/** set udp socket buffer size */
int set_udp_socket_buffer_size();

View File

@ -220,6 +220,7 @@ int slsReceiverTCPIPInterface::function_table(){
flist[F_ENABLE_GAPPIXELS_IN_RECEIVER] = &slsReceiverTCPIPInterface::enable_gap_pixels;
flist[F_RESTREAM_STOP_FROM_RECEIVER] = &slsReceiverTCPIPInterface::restream_stop;
flist[F_ADDITIONAL_JSON_HEADER] = &slsReceiverTCPIPInterface::set_additional_json_header;
flist[F_GET_ADDITIONAL_JSON_HEADER] = &slsReceiverTCPIPInterface::get_additional_json_header;
flist[F_RECEIVER_UDP_SOCK_BUF_SIZE] = &slsReceiverTCPIPInterface::set_udp_socket_buffer_size;
flist[F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE]= &slsReceiverTCPIPInterface::get_real_udp_socket_buffer_size;
flist[F_SET_RECEIVER_FRAMES_PER_FILE] = &slsReceiverTCPIPInterface::set_frames_per_file;
@ -1702,6 +1703,25 @@ int slsReceiverTCPIPInterface::set_additional_json_header() {
int slsReceiverTCPIPInterface::get_additional_json_header() {
ret = OK;
memset(mess, 0, sizeof(mess));
char retval[MAX_STR_LENGTH] = {0};
// no arg, check receiver is null
interface->Server_ReceiveArg(ret, mess, nullptr, 0, true, receiver);
// base object not null
if (ret == OK) {
// get
strcpy(retval, receiver->getAdditionalJsonHeader().c_str());
FILE_LOG(logDEBUG1) << "additional json header:" << retval;
}
return interface->Server_SendResult(true, ret, retval, MAX_STR_LENGTH, mess);
}
int slsReceiverTCPIPInterface::set_udp_socket_buffer_size() {
ret = OK;
memset(mess, 0, sizeof(mess));

View File

@ -111,6 +111,7 @@ enum detFuncs{
F_ENABLE_GAPPIXELS_IN_RECEIVER, /** < sets gap pixels in the receiver */
F_RESTREAM_STOP_FROM_RECEIVER, /** < restream stop from receiver */
F_ADDITIONAL_JSON_HEADER, /** < additional json header */
F_GET_ADDITIONAL_JSON_HEADER,/** < get additional json header */
F_RECEIVER_UDP_SOCK_BUF_SIZE, /** < UDP socket buffer size */
F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE, /** < real UDP socket buffer size */
F_SET_RECEIVER_FRAMES_PER_FILE, /** < receiver frames per file */
@ -226,6 +227,7 @@ static const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_ENABLE_GAPPIXELS_IN_RECEIVER: return "F_ENABLE_GAPPIXELS_IN_RECEIVER";
case F_RESTREAM_STOP_FROM_RECEIVER: return "F_RESTREAM_STOP_FROM_RECEIVER";
case F_ADDITIONAL_JSON_HEADER: return "F_ADDITIONAL_JSON_HEADER";
case F_GET_ADDITIONAL_JSON_HEADER: return "F_GET_ADDITIONAL_JSON_HEADER";
case F_RECEIVER_UDP_SOCK_BUF_SIZE: return "F_RECEIVER_UDP_SOCK_BUF_SIZE";
case F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE: return "F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE";
case F_SET_RECEIVER_FRAMES_PER_FILE: return "F_SET_RECEIVER_FRAMES_PER_FILE";