client: must print detector or receiver returning error

This commit is contained in:
maliakal_d 2019-02-25 09:16:20 +01:00
parent eecfcae312
commit 15fc55f914
3 changed files with 124 additions and 123 deletions

View File

@ -98,7 +98,7 @@ int slsDetector::checkDetectorVersionCompatibility() {
// control server
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), nullptr, 0);
if (ret == FAIL) {
@ -108,7 +108,7 @@ int slsDetector::checkDetectorVersionCompatibility() {
} else {
thisDetector->detectorControlAPIVersion = arg;
ret = FAIL;
auto stop = sls::ClientSocket(thisDetector->hostname, thisDetector->stopPort);
auto stop = sls::ClientSocket(false, thisDetector->hostname, thisDetector->stopPort);
ret = stop.sendCommandThenRead(fnum, &arg, sizeof(arg), nullptr, 0);
if (ret == FAIL) {
thisDetector->detectorStopAPIVersion = 0;
@ -138,7 +138,7 @@ int slsDetector::checkReceiverVersionCompatibility() {
<< std::hex << arg << std::dec;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, &arg, sizeof(arg), nullptr, 0);
if (ret == FAIL) {
thisDetector->receiverAPIVersion = 0;
@ -168,7 +168,7 @@ int64_t slsDetector::getId(idMode mode) {
int ret = FAIL;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
int fnum = F_GET_RECEIVER_ID;
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, nullptr, 0, &retval, sizeof(retval));
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (OTHER_ERROR_CODE));
@ -182,7 +182,7 @@ int64_t slsDetector::getId(idMode mode) {
int fnum = F_GET_ID;
int ret = FAIL;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
// handle ret
@ -555,7 +555,7 @@ int slsDetector::sendModule(sls_detector_module *myMod) {
FILE_LOG(level) << "Sending Module";
int ts = 0;
int n = 0;
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
n = client.sendData(&(myMod->serialnumber), sizeof(myMod->serialnumber));
ts += n;
FILE_LOG(level) << "Serial number sent. " << n << " bytes. serialno: " << myMod->serialnumber;
@ -601,7 +601,7 @@ int slsDetector::sendModule(sls_detector_module *myMod) {
}
int slsDetector::receiveModule(sls_detector_module *myMod) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
int ts = 0;
ts += client.receiveData(&(myMod->serialnumber), sizeof(myMod->serialnumber));
ts += client.receiveData(&(myMod->nchan), sizeof(myMod->nchan));
@ -660,7 +660,7 @@ slsDetectorDefs::detectorType slsDetector::getTypeFromDetector(const std::string
detectorType retval = GENERIC;
FILE_LOG(logDEBUG1) << "Getting detector type ";
try {
sls::ClientSocket cs(hostname, cport);
sls::ClientSocket cs(false, hostname, cport);
cs.sendData(reinterpret_cast<char *>(&fnum), sizeof(fnum));
cs.receiveData(reinterpret_cast<char *>(&ret), sizeof(ret));
cs.receiveData(reinterpret_cast<char *>(&retval), sizeof(retval));
@ -682,7 +682,7 @@ int slsDetector::setDetectorType(detectorType const type) {
if (type == GET_DETECTOR_TYPE) {
if (thisDetector->onlineFlag == ONLINE_FLAG) {
//Create socket
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, nullptr, 0, &retval, sizeof(retval));
// handle ret
@ -710,7 +710,7 @@ int slsDetector::setDetectorType(detectorType const type) {
retval = GENERIC;
FILE_LOG(logDEBUG1) << "Sending detector type to Receiver: " << (int)thisDetector->myDetectorType;
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
// handle ret
@ -817,7 +817,7 @@ int slsDetector::setOnline(int value) {
int old = thisDetector->onlineFlag;
// connecting first time
if (thisDetector->onlineFlag == ONLINE_FLAG && old == OFFLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
FILE_LOG(logINFO) << "Detector connecting for the first time - updating!";
client.close();
updateDetector();
@ -840,8 +840,8 @@ std::string slsDetector::checkOnline() {
std::string retval;
try {
//Need both control and stop socket to work!
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto stop = sls::ClientSocket(thisDetector->hostname, thisDetector->stopPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
auto stop = sls::ClientSocket(false, thisDetector->hostname, thisDetector->stopPort);
retval = thisDetector->hostname;
} catch (...) {
//try catch should not be used for control but we should also not call this function
@ -860,7 +860,7 @@ int slsDetector::setControlPort(int port_number) {
if (port_number != thisDetector->controlPort) {
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, &port_number, sizeof(port_number), &retval, sizeof(retval));
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (COULDNOT_SET_CONTROL_PORT));
@ -887,7 +887,7 @@ int slsDetector::setStopPort(int port_number) {
if (port_number != thisDetector->stopPort) {
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto stop = sls::ClientSocket(thisDetector->hostname, thisDetector->stopPort);
auto stop = sls::ClientSocket(false, thisDetector->hostname, thisDetector->stopPort);
ret = stop.sendCommandThenRead(fnum, &port_number, sizeof(port_number), &retval, sizeof(retval));
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (COULDNOT_SET_STOP_PORT));
@ -922,7 +922,7 @@ int slsDetector::setReceiverPort(int port_number) {
// // set port
// if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
// auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
// auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
// ret = receiver.sendCommandThenRead(fnum, &port_number, sizeof(port_number), &retval, sizeof(retval));
// if (ret == FAIL) {
// setErrorMask((getErrorMask()) | (COULDNOT_SET_DATA_PORT));
@ -956,7 +956,7 @@ int slsDetector::lockServer(int lock) {
FILE_LOG(logDEBUG1) << "Setting detector server lock to " << lock;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, &lock, sizeof(lock), &retval, sizeof(retval));
// handle ret
@ -979,7 +979,7 @@ std::string slsDetector::getLastClientIP() {
FILE_LOG(logDEBUG1) << "Getting last client ip to detector server";
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, nullptr, 0, &retval, sizeof(retval));
// handle ret
@ -1001,7 +1001,7 @@ int slsDetector::exitServer() {
FILE_LOG(logDEBUG1) << "Sending exit command to detector server";
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
// no ret handling as ret never fail
FILE_LOG(logINFO) << "Shutting down the Detector server";
@ -1018,7 +1018,7 @@ int slsDetector::execCommand(const std::string &cmd) {
FILE_LOG(logDEBUG1) << "Sending command to detector " << arg;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, arg, sizeof(arg), retval, sizeof(retval));
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (OTHER_ERROR_CODE));
@ -1034,7 +1034,7 @@ int slsDetector::updateDetectorNoWait(sls::ClientSocket &client) {
int n = 0, i32 = 0;
int64_t i64 = 0;
char lastClientIP[INET_ADDRSTRLEN] = {0};
// auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
// auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
n += client.receiveData(lastClientIP, sizeof(lastClientIP));
FILE_LOG(logDEBUG1) << "Updating detector last modified by " << lastClientIP;
@ -1121,7 +1121,7 @@ int slsDetector::updateDetector() {
FILE_LOG(logDEBUG1) << "Sending update client to detector server";
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
// if it returns ok (jungfrau in programming mode), dont update
if (ret == FORCE_UPDATE) {
@ -1266,7 +1266,7 @@ slsDetectorDefs::detectorSettings slsDetector::sendSettingsOnly(detectorSettings
FILE_LOG(logDEBUG1) << "Setting settings to " << arg;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
// handle ret
@ -1291,7 +1291,7 @@ int slsDetector::getThresholdEnergy() {
FILE_LOG(logDEBUG1) << "Getting threshold energy";
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, nullptr, 0, &retval, sizeof(retval));
// handle ret
@ -1534,7 +1534,7 @@ slsDetectorDefs::runStatus slsDetector::getRunStatus() {
FILE_LOG(logDEBUG1) << "Getting status";
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto stop = sls::ClientSocket(thisDetector->hostname, thisDetector->stopPort);
auto stop = sls::ClientSocket(false, thisDetector->hostname, thisDetector->stopPort);
ret = stop.sendCommandThenRead(fnum, nullptr, 0, &retval, sizeof(retval));
if (ret == FAIL) {
@ -1555,7 +1555,7 @@ int slsDetector::prepareAcquisition() {
FILE_LOG(logDEBUG1) << "Preparing Detector for Acquisition";
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
// handle ret
@ -1578,7 +1578,7 @@ int slsDetector::startAcquisition() {
thisDetector->stoppedFlag = 0;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
// handle ret
@ -1606,7 +1606,7 @@ int slsDetector::stopAcquisition() {
FILE_LOG(logDEBUG1) << "Stopping Acquisition";
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto stop = sls::ClientSocket(thisDetector->hostname, thisDetector->stopPort);
auto stop = sls::ClientSocket(false, thisDetector->hostname, thisDetector->stopPort);
ret = stop.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
if (ret == FAIL) {
@ -1633,7 +1633,7 @@ int slsDetector::sendSoftwareTrigger() {
thisDetector->stoppedFlag = 0;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
// handle ret
@ -1656,7 +1656,7 @@ int slsDetector::startAndReadAll() {
thisDetector->stoppedFlag = 0;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
// handle ret
@ -1679,7 +1679,7 @@ int slsDetector::startReadOut() {
FILE_LOG(logDEBUG1) << "Starting readout";
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
// handle ret
@ -1700,7 +1700,7 @@ int slsDetector::readAll() {
int ret = FAIL;
FILE_LOG(logDEBUG1) << "Reading all frames";
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
// handle ret
@ -1800,7 +1800,7 @@ int slsDetector::configureMAC() {
// send to server
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, args, sizeof(args), retvals, sizeof(retvals));
// handle ret
@ -1862,7 +1862,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) {
// send to detector
int64_t oldtimer = thisDetector->timerValue[index];
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, args, sizeof(args), &retval, sizeof(retval));
// handle ret
if (ret == FAIL) {
@ -1895,7 +1895,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) {
// send to reciever
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && ret == OK) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
// char mess[MAX_STR_LENGTH]{};
switch (index) {
case FRAME_NUMBER:
@ -1967,7 +1967,7 @@ int64_t slsDetector::getTimeLeft(timerIndex index) {
FILE_LOG(logDEBUG1) << "Getting " << getTimerType(index) << " left";
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto stop = sls::ClientSocket(thisDetector->hostname, thisDetector->stopPort);
auto stop = sls::ClientSocket(false, thisDetector->hostname, thisDetector->stopPort);
ret = stop.sendCommandThenRead(fnum, &index, sizeof(index), &retval, sizeof(retval));
// handle ret
@ -1991,7 +1991,7 @@ int slsDetector::setSpeed(speedVariable sp, int value) {
FILE_LOG(logDEBUG1) << "Setting speed index " << sp << " to " << value;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, args, sizeof(args), &retval, sizeof(retval));
// handle ret
@ -2017,7 +2017,7 @@ int slsDetector::setDynamicRange(int n) {
int olddr = thisDetector->dynamicRange;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
// char mess[MAX_STR_LENGTH] = {};
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, &n, sizeof(n), &retval, sizeof(retval));
// handle ret
@ -2072,7 +2072,7 @@ int slsDetector::setDynamicRange(int n) {
n = thisDetector->dynamicRange;
retval = -1;
FILE_LOG(logDEBUG1) << "Sending dynamic range to receiver: " << n;
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, &n, sizeof(n), &retval, sizeof(retval));
// handle ret
@ -2105,7 +2105,7 @@ int slsDetector::setDAC(int val, dacIndex index, int mV) {
FILE_LOG(logDEBUG1) << "Setting DAC " << index << " to " << val << (mV ? "mV" : "dac units");
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, args, sizeof(args), &retval, sizeof(retval));
// handle ret
@ -2130,7 +2130,7 @@ int slsDetector::getADC(dacIndex index) {
FILE_LOG(logDEBUG1) << "Getting ADC " << index;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
// handle ret
@ -2154,7 +2154,7 @@ slsDetectorDefs::externalCommunicationMode slsDetector::setExternalCommunication
FILE_LOG(logDEBUG1) << "Setting communication to mode " << pol;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
// handle ret
@ -2179,7 +2179,7 @@ slsDetectorDefs::externalSignalFlag slsDetector::setExternalSignalFlags(
FILE_LOG(logDEBUG1) << "Setting signal " << signalindex << " to flag " << pol;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, args, sizeof(args), &retval, sizeof(retval));
// handle ret
@ -2203,7 +2203,7 @@ int slsDetector::setReadOutFlags(readOutFlags flag) {
FILE_LOG(logDEBUG1) << "Setting readout flags to " << flag;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
// handle ret
@ -2228,7 +2228,7 @@ uint32_t slsDetector::writeRegister(uint32_t addr, uint32_t val) {
FILE_LOG(logDEBUG1) << "Writing to register 0x" << std::hex << addr << "data: 0x" << std::hex << val << std::dec;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, args, sizeof(args), &retval, sizeof(retval));
// handle ret
@ -2252,7 +2252,7 @@ uint32_t slsDetector::readRegister(uint32_t addr) {
FILE_LOG(logDEBUG1) << "Reading register 0x" << std::hex << addr << std::dec;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
// handle ret
@ -2524,7 +2524,7 @@ void slsDetector::setReceiverStreamingPort(int port) {
FILE_LOG(logDEBUG1) << "Sending receiver streaming port to receiver: " << arg;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (COULDNOT_SET_NETWORK_PARAMETER));
@ -2600,7 +2600,7 @@ void slsDetector::setReceiverStreamingIP(std::string sourceIP) {
// send to receiver
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, args, sizeof(args), retvals, sizeof(retvals));
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (COULDNOT_SET_NETWORK_PARAMETER));
@ -2628,7 +2628,7 @@ int slsDetector::setDetectorNetworkParameter(networkParameter index, int delay)
FILE_LOG(logDEBUG1) << "Setting network parameter index " << index << " to " << delay;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, args, sizeof(args), &retval, sizeof(retval));
// handle ret
@ -2653,7 +2653,7 @@ std::string slsDetector::setAdditionalJsonHeader(const std::string &jsonheader)
FILE_LOG(logDEBUG1) << "Sending additional json header " << args;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, args, sizeof(args), retvals, sizeof(retvals));
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (COULDNOT_SET_NETWORK_PARAMETER));
@ -2763,7 +2763,7 @@ int slsDetector::setReceiverUDPSocketBufferSize(int udpsockbufsize) {
FILE_LOG(logDEBUG1) << "Sending UDP Socket Buffer size to receiver: " << arg;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
if (ret == FAIL) {
@ -2789,7 +2789,7 @@ int slsDetector::getReceiverRealUDPSocketBufferSize() {
FILE_LOG(logDEBUG1) << "Getting real UDP Socket Buffer size to receiver";
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, nullptr, 0, &retval, sizeof(retval));
if (ret == FAIL) {
@ -2843,7 +2843,7 @@ int slsDetector::setUDPConnection() {
FILE_LOG(logDEBUG1) << "Receiver udp port2: " << thisDetector->receiverUDPPort2;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, args, sizeof(args), retvals, sizeof(retvals));
if (ret == FAIL) {
@ -2879,7 +2879,7 @@ int slsDetector::digitalTest(digitalTestMode mode, int ival) {
FILE_LOG(logDEBUG1) << "Sending digital test of mode " << mode << ", ival " << ival;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, args, sizeof(args), &retval, sizeof(retval));
// handle ret
@ -2919,7 +2919,7 @@ int slsDetector::sendImageToDetector(imageType index, int16_t imageVals[]) {
FILE_LOG(logDEBUG1) << "Sending image to detector";
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
client.sendData(&fnum, sizeof(fnum));
client.sendData(args, sizeof(args));
client.sendData(imageVals, nChan * sizeof(int16_t));
@ -2960,7 +2960,7 @@ int slsDetector::getCounterBlock(int16_t image[], int startACQ) {
FILE_LOG(logDEBUG1) << "Reading Counter block with startacq: " << startACQ;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, args, sizeof(args), image, nChan * sizeof(int16_t));
// handle ret
@ -2981,7 +2981,7 @@ int slsDetector::resetCounterBlock(int startACQ) {
FILE_LOG(logDEBUG1) << "Resetting Counter with startacq: " << startACQ;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), nullptr, 0);
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (OTHER_ERROR_CODE));
@ -3001,7 +3001,7 @@ int slsDetector::setCounterBit(int i) {
FILE_LOG(logDEBUG1) << "Sending counter bit " << arg;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
// handle ret
@ -3071,7 +3071,7 @@ int slsDetector::sendROI(int n, ROI roiLimits[]) {
FILE_LOG(logDEBUG1) << "Sending ROI to detector" << narg;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
client.sendData(&fnum, sizeof(fnum));
client.sendData(&narg, sizeof(narg));
if (narg != -1) {
@ -3123,7 +3123,7 @@ int slsDetector::sendROI(int n, ROI roiLimits[]) {
arg = thisDetector->roiLimits;
FILE_LOG(logDEBUG1) << "Sending ROI to receiver: " << thisDetector->nROI;
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
receiver.sendData(&fnum, sizeof(fnum));
receiver.sendData(&narg, sizeof(narg));
if (narg != -1) {
@ -3158,7 +3158,7 @@ int slsDetector::writeAdcRegister(int addr, int val) {
FILE_LOG(logDEBUG1) << "Writing to ADC register 0x" << std::hex << addr << "data: 0x" << std::hex << val << std::dec;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, args, sizeof(args), nullptr, 0);
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (REGISER_WRITE_READ));
@ -3179,7 +3179,7 @@ int slsDetector::activate(int const enable) {
// detector
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
// handle ret
@ -3202,7 +3202,7 @@ int slsDetector::activate(int const enable) {
retval = -1;
FILE_LOG(logDEBUG1) << "Setting activate flag " << arg << " to receiver";
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
// handle ret
@ -3224,7 +3224,7 @@ int slsDetector::setDeactivatedRxrPaddingMode(int padding) {
FILE_LOG(logDEBUG1) << "Deactivated Receiver Padding Enable: " << arg;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
if (ret == FAIL) {
@ -3265,7 +3265,7 @@ int slsDetector::setFlippedData(dimension d, int value) {
FILE_LOG(logDEBUG1) << "Setting flipped data across axis " << d << " with value: " << value;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, args, sizeof(args), &retval, sizeof(retval));
if (ret == FAIL) {
@ -3288,7 +3288,7 @@ int slsDetector::setAllTrimbits(int val) {
FILE_LOG(logDEBUG1) << "Setting all trimbits to " << val;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (ALLTIMBITS_NOT_SET));
@ -3311,7 +3311,7 @@ int slsDetector::enableGapPixels(int val) {
FILE_LOG(logDEBUG1) << "Sending gap pixels enable to receiver: " << arg;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
if (ret == FAIL) {
@ -3365,7 +3365,7 @@ int slsDetector::pulsePixel(int n, int x, int y) {
FILE_LOG(logDEBUG1) << "Pulsing pixel " << n << " number of times at (" << x << "," << y << ")";
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, args, sizeof(args), nullptr, 0);
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (COULD_NOT_PULSE));
@ -3384,7 +3384,7 @@ int slsDetector::pulsePixelNMove(int n, int x, int y) {
FILE_LOG(logDEBUG1) << "Pulsing pixel " << n << " number of times and move by delta (" << x << "," << y << ")";
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, args, sizeof(args), nullptr, 0);
// handle ret
@ -3405,7 +3405,7 @@ int slsDetector::pulseChip(int n) {
FILE_LOG(logDEBUG1) << "Pulsing chip " << n << " number of times";
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), nullptr, 0);
// handle ret
@ -3427,7 +3427,7 @@ int slsDetector::setThresholdTemperature(int val) {
FILE_LOG(logDEBUG1) << "Setting threshold temperature to " << val;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto stop = sls::ClientSocket(thisDetector->hostname, thisDetector->stopPort);
auto stop = sls::ClientSocket(false, thisDetector->hostname, thisDetector->stopPort);
ret = stop.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
// handle ret
@ -3448,7 +3448,7 @@ int slsDetector::setTemperatureControl(int val) {
FILE_LOG(logDEBUG1) << "Setting temperature control to " << val;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto stop = sls::ClientSocket(thisDetector->hostname, thisDetector->stopPort);
auto stop = sls::ClientSocket(false, thisDetector->hostname, thisDetector->stopPort);
ret = stop.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
// handle ret
@ -3469,7 +3469,7 @@ int slsDetector::setTemperatureEvent(int val) {
FILE_LOG(logDEBUG1) << "Setting temperature event to " << val;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto stop = sls::ClientSocket(thisDetector->hostname, thisDetector->stopPort);
auto stop = sls::ClientSocket(false, thisDetector->hostname, thisDetector->stopPort);
ret = stop.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
// handle ret
@ -3490,7 +3490,7 @@ int slsDetector::setStoragecellStart(int pos) {
FILE_LOG(logDEBUG1) << "Setting storage cell start to " << pos;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
// handle ret
@ -3644,7 +3644,7 @@ int slsDetector::programFPGA(const std::string &fname) {
FILE_LOG(logDEBUG1) << "Sending programming binary to detector";
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
client.sendData(&fnum, sizeof(fnum));
client.sendData(&filesize, sizeof(filesize));
client.receiveData(&ret, sizeof(ret));
@ -3734,7 +3734,7 @@ int slsDetector::programFPGA(const std::string &fname) {
(strstr(mess, "-update") == nullptr)) {
fnum = F_RESET_FPGA;
int stopret = FAIL;
auto stop = sls::ClientSocket(thisDetector->hostname, thisDetector->stopPort);
auto stop = sls::ClientSocket(false, thisDetector->hostname, thisDetector->stopPort);
stop.sendData(&fnum, sizeof(fnum));
stop.receiveData(&stopret, sizeof(stopret));
if (stopret == FAIL) {
@ -3762,7 +3762,7 @@ int slsDetector::resetFPGA() {
FILE_LOG(logDEBUG1) << "Sending reset FPGA";
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
// handle ret
@ -3784,7 +3784,7 @@ int slsDetector::powerChip(int ival) {
FILE_LOG(logDEBUG1) << "Setting power chip to " << ival;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (POWER_CHIP));
@ -3806,7 +3806,7 @@ int slsDetector::setAutoComparatorDisableMode(int ival) {
FILE_LOG(logDEBUG1) << "Setting auto comp disable mode to " << ival;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (AUTO_COMP_DISABLE));
@ -3847,7 +3847,7 @@ int slsDetector::setModule(sls_detector_module module, int tb) {
}
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
client.sendData(&fnum, sizeof(fnum));
sendModule(&module);
client.receiveData(&ret, sizeof(ret));
@ -3912,7 +3912,7 @@ slsDetectorDefs::sls_detector_module *slsDetector::getModule() {
}
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
// handle ret
@ -3962,7 +3962,7 @@ int slsDetector::setRateCorrection(int64_t t) {
FILE_LOG(logDEBUG1) << "Setting Rate Correction to " << arg;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
// char mess[MAX_STR_LENGTH]{};
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), nullptr, 0);
// TODO! (Read error with this call)
// if (ret == FAIL) {
@ -3989,7 +3989,7 @@ int64_t slsDetector::getRateCorrection() {
FILE_LOG(logDEBUG1) << "Getting rate correction";
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, nullptr, 0, &retval, sizeof(retval));
// handle ret
@ -4039,7 +4039,7 @@ std::string slsDetector::checkReceiverOnline() {
//TODO! (Erik) Figure out usage of this function
std::string retval;
try {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
retval = thisDetector->receiver_hostname;
} catch (...) {
}
@ -4053,7 +4053,7 @@ int slsDetector::lockReceiver(int lock) {
FILE_LOG(logDEBUG1) << "Setting receiver server lock to " << lock;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, &lock, sizeof(lock), &retval, sizeof(retval));
if (ret == FAIL) {
@ -4075,7 +4075,7 @@ std::string slsDetector::getReceiverLastClientIP() {
FILE_LOG(logDEBUG1) << "Getting last client ip to receiver server";
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, nullptr, 0, &retval, sizeof(retval));
if (ret == FAIL) {
@ -4096,7 +4096,7 @@ int slsDetector::exitReceiver() {
FILE_LOG(logDEBUG1) << "Sending exit command to receiver server";
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
// no ret handling as ret never fail
FILE_LOG(logINFO) << "Shutting down the receiver server";
@ -4113,7 +4113,7 @@ int slsDetector::execReceiverCommand(const std::string &cmd) {
FILE_LOG(logDEBUG1) << "Sending command to receiver: " << arg;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, arg, sizeof(arg), retval, sizeof(retval));
if (ret == FAIL) {
@ -4219,7 +4219,7 @@ int slsDetector::updateReceiver() {
FILE_LOG(logDEBUG1) << "Sending update client to receiver server";
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (OTHER_ERROR_CODE));
@ -4238,7 +4238,7 @@ void slsDetector::sendMultiDetectorSize() {
FILE_LOG(logDEBUG1) << "Sending multi detector size to receiver: (" << thisDetector->multiSize[0] << "," << thisDetector->multiSize[1] << ")";
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, args, sizeof(args), &retval, sizeof(retval));
if (ret == FAIL) {
@ -4260,7 +4260,7 @@ void slsDetector::setDetectorId() {
FILE_LOG(logDEBUG1) << "Sending detector pos id to receiver: " << detId;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
if (ret == FAIL) {
@ -4283,7 +4283,7 @@ void slsDetector::setDetectorHostname() {
FILE_LOG(logDEBUG1) << "Sending detector hostname to receiver: " << args;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, args, sizeof(args), retvals, sizeof(retvals));
if (ret == FAIL) {
@ -4311,7 +4311,7 @@ std::string slsDetector::setFilePath(const std::string &path) {
FILE_LOG(logDEBUG1) << "Sending file path to receiver: " << args;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, args, sizeof(args), retvals, sizeof(retvals));
if (ret == FAIL) {
@ -4347,7 +4347,7 @@ std::string slsDetector::setFileName(const std::string &fname) {
FILE_LOG(logDEBUG1) << "Sending file name to receiver: " << args;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, args, sizeof(args), retvals, sizeof(retvals));
if (ret == FAIL) {
@ -4373,7 +4373,7 @@ int slsDetector::setReceiverFramesPerFile(int f) {
FILE_LOG(logDEBUG1) << "Setting receiver frames per file to " << arg;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
// handle ret
@ -4399,7 +4399,7 @@ slsDetectorDefs::frameDiscardPolicy slsDetector::setReceiverFramesDiscardPolicy(
FILE_LOG(logDEBUG1) << "Setting receiver frames discard policy to " << arg;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (RECEIVER_PARAMETER_NOT_SET));
@ -4422,7 +4422,7 @@ int slsDetector::setReceiverPartialFramesPadding(int f) {
FILE_LOG(logDEBUG1) << "Setting receiver partial frames enable to " << arg;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
// handle ret
@ -4448,7 +4448,7 @@ slsDetectorDefs::fileFormat slsDetector::setFileFormat(fileFormat f) {
FILE_LOG(logDEBUG1) << "Setting receiver file format to " << arg;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
// handle ret
@ -4483,7 +4483,7 @@ int slsDetector::setFileIndex(int i) {
FILE_LOG(logDEBUG1) << "Setting file index to " << arg;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
// handle ret
@ -4514,7 +4514,7 @@ int slsDetector::startReceiver() {
// char mess[MAX_STR_LENGTH]{};
FILE_LOG(logDEBUG1) << "Starting Receiver";
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
//TODO! (Erik) mess should be enum now ignoring
// if (ret == FAIL) {
@ -4538,7 +4538,7 @@ int slsDetector::stopReceiver() {
int ret = FAIL;
FILE_LOG(logDEBUG1) << "Stopping Receiver";
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
// handle ret
@ -4559,7 +4559,7 @@ slsDetectorDefs::runStatus slsDetector::getReceiverStatus() {
FILE_LOG(logDEBUG1) << "Getting Receiver Status";
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, nullptr, 0, &retval, sizeof(retval));
// handle ret
@ -4582,7 +4582,7 @@ int slsDetector::getFramesCaughtByReceiver() {
FILE_LOG(logDEBUG1) << "Getting Frames Caught by Receiver";
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, nullptr, 0, &retval, sizeof(retval));
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (OTHER_ERROR_CODE));
@ -4602,7 +4602,7 @@ int slsDetector::getReceiverCurrentFrameIndex() {
int retval = -1;
FILE_LOG(logDEBUG1) << "Getting Current Frame Index of Receiver";
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, nullptr, 0, &retval, sizeof(retval));
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (OTHER_ERROR_CODE));
@ -4622,7 +4622,7 @@ int slsDetector::resetFramesCaught() {
FILE_LOG(logDEBUG1) << "Reset Frames Caught by Receiver";
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (OTHER_ERROR_CODE));
@ -4642,7 +4642,7 @@ int slsDetector::enableWriteToFile(int enable) {
int retval = -1;
FILE_LOG(logDEBUG1) << "Sending enable file write to receiver: " << arg;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (RECEIVER_PARAMETER_NOT_SET));
@ -4667,7 +4667,7 @@ int slsDetector::overwriteFile(int enable) {
FILE_LOG(logDEBUG1) << "Sending enable file overwrite to receiver: " << arg;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (RECEIVER_PARAMETER_NOT_SET));
@ -4692,7 +4692,7 @@ int slsDetector::setReceiverStreamingFrequency(int freq) {
FILE_LOG(logDEBUG1) << "Sending read frequency to receiver: " << arg;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (RECEIVER_STREAMING_FREQUENCY));
@ -4716,7 +4716,7 @@ int slsDetector::setReceiverStreamingTimer(int time_in_ms) {
FILE_LOG(logDEBUG1) << "Sending read timer to receiver: " << arg;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (RECEIVER_STREAMING_TIMER));
@ -4739,7 +4739,7 @@ int slsDetector::enableDataStreamingFromReceiver(int enable) {
FILE_LOG(logDEBUG1) << "Sending Data Streaming to receiver: " << arg;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (DATA_STREAMING));
@ -4763,7 +4763,7 @@ int slsDetector::enableTenGigabitEthernet(int i) {
FILE_LOG(logDEBUG1) << "Enabling / Disabling 10Gbe: " << arg;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (DETECTOR_TEN_GIGA));
@ -4786,7 +4786,7 @@ int slsDetector::enableTenGigabitEthernet(int i) {
retval = -1;
FILE_LOG(logDEBUG1) << "Sending 10Gbe enable to receiver: " << arg;
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (RECEIVER_TEN_GIGA));
@ -4809,7 +4809,7 @@ int slsDetector::setReceiverFifoDepth(int i) {
FILE_LOG(logDEBUG1) << "Sending Receiver Fifo Depth: " << arg;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
// handle ret
@ -4833,7 +4833,7 @@ int slsDetector::setReceiverSilentMode(int i) {
FILE_LOG(logDEBUG1) << "Sending Receiver Silent Mode: " << arg;
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
// handle ret
@ -4856,7 +4856,7 @@ int slsDetector::restreamStopFromReceiver() {
FILE_LOG(logDEBUG1) << "Restream stop dummy from Receiver via zmq";
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) {
auto receiver = sls::ClientSocket(thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
auto receiver = sls::ClientSocket(true, thisDetector->receiver_hostname, thisDetector->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
// handle ret
@ -4895,7 +4895,7 @@ uint64_t slsDetector::setCTBWord(int addr, uint64_t word) {
FILE_LOG(logDEBUG1) << "Setting CTB word, addr: 0x" << std::hex << addr << ", word: 0x" << word << std::dec;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, args, sizeof(args), &retval, sizeof(retval));
if (ret == FAIL) {
setErrorMask((getErrorMask()) | (OTHER_ERROR_CODE));
@ -4920,7 +4920,7 @@ int slsDetector::setCTBPatLoops(int level, int &start, int &stop, int &n) {
<< level << ", start: " << start << ", stop: " << stop << ", n: " << n;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, args, sizeof(args), retvals, sizeof(retvals));
// handle ret
@ -4950,7 +4950,7 @@ int slsDetector::setCTBPatWaitAddr(uint64_t level, uint64_t addr) {
<< level << ", addr: 0x" << std::hex << addr << std::dec;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, args.data(), sizeof(args), &retval, sizeof(retval));
// handle ret
@ -4975,7 +4975,7 @@ uint64_t slsDetector::setCTBPatWaitTime(uint64_t level, uint64_t t) {
FILE_LOG(logDEBUG1) << "Setting CTB Wait Time, level: " << level << ", t: " << t;
if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(thisDetector->hostname, thisDetector->controlPort);
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, args.data(), sizeof(args), &retval, sizeof(retval));
// handle ret

View File

@ -9,12 +9,13 @@ namespace sls {
class ClientSocket : public DataSocket {
public:
ClientSocket(const std::string &hostname, uint16_t port_number);
ClientSocket(const bool isRx, const std::string &hostname, uint16_t port_number);
int sendCommandThenRead(int fnum, void *args, size_t args_size, void *retval, size_t retval_size);
private:
void readReply(int &ret, void *retval, size_t retval_size);
struct sockaddr_in serverAddr {};
bool isReceiver;
};
}; //namespace sls
}; //namespace sls

View File

@ -8,7 +8,7 @@
#include "sls_detector_defs.h"
namespace sls {
ClientSocket::ClientSocket(const std::string &host, uint16_t port) : DataSocket(socket(AF_INET, SOCK_STREAM, 0)) {
ClientSocket::ClientSocket(const bool isRx, const std::string &host, uint16_t port) : DataSocket(socket(AF_INET, SOCK_STREAM, 0)), isReceiver(isRx) {
struct addrinfo hints, *result;
memset(&hints, 0, sizeof(hints));
@ -51,7 +51,7 @@ void ClientSocket::readReply(int &ret, void *retval, size_t retval_size) {
//get error message
receiveData(mess, sizeof(mess));
// cprintf(RED, "%s %d returned error: %s", type.c_str(), index, mess);
cprintf(RED, "returned error: %s", mess);
cprintf(RED, "%s returned error: %s", (isReceiver ? "Receiver" : "Detector"), mess);
// unrecognized function, do not ask for retval
if (strstr(mess, "Unrecognized Function") != nullptr)