mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-02 19:00:05 +02:00
Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer
This commit is contained in:
commit
0c6304bdf8
@ -422,49 +422,49 @@ int slsDetector::sendModule(sls_detector_module *myMod,
|
|||||||
FILE_LOG(level) << "Sending Module";
|
FILE_LOG(level) << "Sending Module";
|
||||||
int ts = 0;
|
int ts = 0;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
n = client.sendData(&(myMod->serialnumber), sizeof(myMod->serialnumber));
|
n = client.Send(&(myMod->serialnumber), sizeof(myMod->serialnumber));
|
||||||
ts += n;
|
ts += n;
|
||||||
FILE_LOG(level) << "Serial number sent. " << n
|
FILE_LOG(level) << "Serial number sent. " << n
|
||||||
<< " bytes. serialno: " << myMod->serialnumber;
|
<< " bytes. serialno: " << myMod->serialnumber;
|
||||||
|
|
||||||
n = client.sendData(&(myMod->nchan), sizeof(myMod->nchan));
|
n = client.Send(&(myMod->nchan), sizeof(myMod->nchan));
|
||||||
ts += n;
|
ts += n;
|
||||||
FILE_LOG(level) << "nchan sent. " << n
|
FILE_LOG(level) << "nchan sent. " << n
|
||||||
<< " bytes. serialno: " << myMod->nchan;
|
<< " bytes. serialno: " << myMod->nchan;
|
||||||
|
|
||||||
n = client.sendData(&(myMod->nchip), sizeof(myMod->nchip));
|
n = client.Send(&(myMod->nchip), sizeof(myMod->nchip));
|
||||||
ts += n;
|
ts += n;
|
||||||
FILE_LOG(level) << "nchip sent. " << n
|
FILE_LOG(level) << "nchip sent. " << n
|
||||||
<< " bytes. serialno: " << myMod->nchip;
|
<< " bytes. serialno: " << myMod->nchip;
|
||||||
|
|
||||||
n = client.sendData(&(myMod->ndac), sizeof(myMod->ndac));
|
n = client.Send(&(myMod->ndac), sizeof(myMod->ndac));
|
||||||
ts += n;
|
ts += n;
|
||||||
FILE_LOG(level) << "ndac sent. " << n
|
FILE_LOG(level) << "ndac sent. " << n
|
||||||
<< " bytes. serialno: " << myMod->ndac;
|
<< " bytes. serialno: " << myMod->ndac;
|
||||||
|
|
||||||
n = client.sendData(&(myMod->reg), sizeof(myMod->reg));
|
n = client.Send(&(myMod->reg), sizeof(myMod->reg));
|
||||||
ts += n;
|
ts += n;
|
||||||
FILE_LOG(level) << "reg sent. " << n << " bytes. serialno: " << myMod->reg;
|
FILE_LOG(level) << "reg sent. " << n << " bytes. serialno: " << myMod->reg;
|
||||||
|
|
||||||
n = client.sendData(&(myMod->iodelay), sizeof(myMod->iodelay));
|
n = client.Send(&(myMod->iodelay), sizeof(myMod->iodelay));
|
||||||
ts += n;
|
ts += n;
|
||||||
FILE_LOG(level) << "iodelay sent. " << n
|
FILE_LOG(level) << "iodelay sent. " << n
|
||||||
<< " bytes. serialno: " << myMod->iodelay;
|
<< " bytes. serialno: " << myMod->iodelay;
|
||||||
|
|
||||||
n = client.sendData(&(myMod->tau), sizeof(myMod->tau));
|
n = client.Send(&(myMod->tau), sizeof(myMod->tau));
|
||||||
ts += n;
|
ts += n;
|
||||||
FILE_LOG(level) << "tau sent. " << n << " bytes. serialno: " << myMod->tau;
|
FILE_LOG(level) << "tau sent. " << n << " bytes. serialno: " << myMod->tau;
|
||||||
|
|
||||||
n = client.sendData(&(myMod->eV), sizeof(myMod->eV));
|
n = client.Send(&(myMod->eV), sizeof(myMod->eV));
|
||||||
ts += n;
|
ts += n;
|
||||||
FILE_LOG(level) << "ev sent. " << n << " bytes. serialno: " << myMod->eV;
|
FILE_LOG(level) << "ev sent. " << n << " bytes. serialno: " << myMod->eV;
|
||||||
|
|
||||||
n = client.sendData(myMod->dacs, sizeof(int) * (myMod->ndac));
|
n = client.Send(myMod->dacs, sizeof(int) * (myMod->ndac));
|
||||||
ts += n;
|
ts += n;
|
||||||
FILE_LOG(level) << "dacs sent. " << n << " bytes";
|
FILE_LOG(level) << "dacs sent. " << n << " bytes";
|
||||||
|
|
||||||
if (shm()->myDetectorType == EIGER) {
|
if (shm()->myDetectorType == EIGER) {
|
||||||
n = client.sendData(myMod->chanregs, sizeof(int) * (myMod->nchan));
|
n = client.Send(myMod->chanregs, sizeof(int) * (myMod->nchan));
|
||||||
ts += n;
|
ts += n;
|
||||||
FILE_LOG(level) << "channels sent. " << n << " bytes";
|
FILE_LOG(level) << "channels sent. " << n << " bytes";
|
||||||
}
|
}
|
||||||
@ -475,19 +475,19 @@ int slsDetector::receiveModule(sls_detector_module *myMod,
|
|||||||
sls::ClientSocket &client) {
|
sls::ClientSocket &client) {
|
||||||
int ts = 0;
|
int ts = 0;
|
||||||
ts +=
|
ts +=
|
||||||
client.receiveData(&(myMod->serialnumber), sizeof(myMod->serialnumber));
|
client.Receive(&(myMod->serialnumber), sizeof(myMod->serialnumber));
|
||||||
ts += client.receiveData(&(myMod->nchan), sizeof(myMod->nchan));
|
ts += client.Receive(&(myMod->nchan), sizeof(myMod->nchan));
|
||||||
ts += client.receiveData(&(myMod->nchip), sizeof(myMod->nchip));
|
ts += client.Receive(&(myMod->nchip), sizeof(myMod->nchip));
|
||||||
ts += client.receiveData(&(myMod->ndac), sizeof(myMod->ndac));
|
ts += client.Receive(&(myMod->ndac), sizeof(myMod->ndac));
|
||||||
ts += client.receiveData(&(myMod->reg), sizeof(myMod->reg));
|
ts += client.Receive(&(myMod->reg), sizeof(myMod->reg));
|
||||||
ts += client.receiveData(&(myMod->iodelay), sizeof(myMod->iodelay));
|
ts += client.Receive(&(myMod->iodelay), sizeof(myMod->iodelay));
|
||||||
ts += client.receiveData(&(myMod->tau), sizeof(myMod->tau));
|
ts += client.Receive(&(myMod->tau), sizeof(myMod->tau));
|
||||||
ts += client.receiveData(&(myMod->eV), sizeof(myMod->eV));
|
ts += client.Receive(&(myMod->eV), sizeof(myMod->eV));
|
||||||
|
|
||||||
ts += client.receiveData(myMod->dacs, sizeof(int) * (myMod->ndac));
|
ts += client.Receive(myMod->dacs, sizeof(int) * (myMod->ndac));
|
||||||
FILE_LOG(logDEBUG1) << "received dacs of size " << ts;
|
FILE_LOG(logDEBUG1) << "received dacs of size " << ts;
|
||||||
if (shm()->myDetectorType == EIGER) {
|
if (shm()->myDetectorType == EIGER) {
|
||||||
ts += client.receiveData(myMod->chanregs, sizeof(int) * (myMod->nchan));
|
ts += client.Receive(myMod->chanregs, sizeof(int) * (myMod->nchan));
|
||||||
FILE_LOG(logDEBUG1)
|
FILE_LOG(logDEBUG1)
|
||||||
<< "nchans= " << shm()->nChans << " nchips= " << shm()->nChips
|
<< "nchans= " << shm()->nChans << " nchips= " << shm()->nChips
|
||||||
<< "mod - nchans= " << myMod->nchan << " nchips= " << myMod->nchip
|
<< "mod - nchans= " << myMod->nchan << " nchips= " << myMod->nchip
|
||||||
@ -528,9 +528,9 @@ slsDetector::getTypeFromDetector(const std::string &hostname, int cport) {
|
|||||||
detectorType retval = GENERIC;
|
detectorType retval = GENERIC;
|
||||||
FILE_LOG(logDEBUG1) << "Getting detector type ";
|
FILE_LOG(logDEBUG1) << "Getting detector type ";
|
||||||
sls::ClientSocket cs("Detector", hostname, cport);
|
sls::ClientSocket cs("Detector", hostname, cport);
|
||||||
cs.sendData(reinterpret_cast<char *>(&fnum), sizeof(fnum));
|
cs.Send(reinterpret_cast<char *>(&fnum), sizeof(fnum));
|
||||||
cs.receiveData(reinterpret_cast<char *>(&ret), sizeof(ret));
|
cs.Receive(reinterpret_cast<char *>(&ret), sizeof(ret));
|
||||||
cs.receiveData(reinterpret_cast<char *>(&retval), sizeof(retval));
|
cs.Receive(reinterpret_cast<char *>(&retval), sizeof(retval));
|
||||||
FILE_LOG(logDEBUG1) << "Detector type is " << retval;
|
FILE_LOG(logDEBUG1) << "Detector type is " << retval;
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
@ -788,91 +788,91 @@ int slsDetector::updateDetectorNoWait(sls::ClientSocket &client) {
|
|||||||
int n = 0, i32 = 0;
|
int n = 0, i32 = 0;
|
||||||
int64_t i64 = 0;
|
int64_t i64 = 0;
|
||||||
char lastClientIP[INET_ADDRSTRLEN] = {0};
|
char lastClientIP[INET_ADDRSTRLEN] = {0};
|
||||||
n += client.receiveData(lastClientIP, sizeof(lastClientIP));
|
n += client.Receive(lastClientIP, sizeof(lastClientIP));
|
||||||
FILE_LOG(logDEBUG1) << "Updating detector last modified by "
|
FILE_LOG(logDEBUG1) << "Updating detector last modified by "
|
||||||
<< lastClientIP;
|
<< lastClientIP;
|
||||||
|
|
||||||
// dr
|
// dr
|
||||||
n += client.receiveData(&i32, sizeof(i32));
|
n += client.Receive(&i32, sizeof(i32));
|
||||||
shm()->dynamicRange = i32;
|
shm()->dynamicRange = i32;
|
||||||
|
|
||||||
// databytes
|
// databytes
|
||||||
n += client.receiveData(&i32, sizeof(i32));
|
n += client.Receive(&i32, sizeof(i32));
|
||||||
shm()->dataBytes = i32;
|
shm()->dataBytes = i32;
|
||||||
|
|
||||||
// settings
|
// settings
|
||||||
if ((shm()->myDetectorType != CHIPTESTBOARD) &&
|
if ((shm()->myDetectorType != CHIPTESTBOARD) &&
|
||||||
(shm()->myDetectorType != MOENCH)) {
|
(shm()->myDetectorType != MOENCH)) {
|
||||||
n += client.receiveData(&i32, sizeof(i32));
|
n += client.Receive(&i32, sizeof(i32));
|
||||||
shm()->currentSettings = static_cast<detectorSettings>(i32);
|
shm()->currentSettings = static_cast<detectorSettings>(i32);
|
||||||
}
|
}
|
||||||
|
|
||||||
// threshold
|
// threshold
|
||||||
if (shm()->myDetectorType == EIGER) {
|
if (shm()->myDetectorType == EIGER) {
|
||||||
n += client.receiveData(&i32, sizeof(i32));
|
n += client.Receive(&i32, sizeof(i32));
|
||||||
shm()->currentThresholdEV = i32;
|
shm()->currentThresholdEV = i32;
|
||||||
}
|
}
|
||||||
|
|
||||||
// frame number
|
// frame number
|
||||||
n += client.receiveData(&i64, sizeof(i64));
|
n += client.Receive(&i64, sizeof(i64));
|
||||||
shm()->timerValue[FRAME_NUMBER] = i64;
|
shm()->timerValue[FRAME_NUMBER] = i64;
|
||||||
|
|
||||||
// exptime
|
// exptime
|
||||||
n += client.receiveData(&i64, sizeof(i64));
|
n += client.Receive(&i64, sizeof(i64));
|
||||||
shm()->timerValue[ACQUISITION_TIME] = i64;
|
shm()->timerValue[ACQUISITION_TIME] = i64;
|
||||||
|
|
||||||
// subexptime, subdeadtime
|
// subexptime, subdeadtime
|
||||||
if (shm()->myDetectorType == EIGER) {
|
if (shm()->myDetectorType == EIGER) {
|
||||||
n += client.receiveData(&i64, sizeof(i64));
|
n += client.Receive(&i64, sizeof(i64));
|
||||||
shm()->timerValue[SUBFRAME_ACQUISITION_TIME] = i64;
|
shm()->timerValue[SUBFRAME_ACQUISITION_TIME] = i64;
|
||||||
|
|
||||||
n += client.receiveData(&i64, sizeof(i64));
|
n += client.Receive(&i64, sizeof(i64));
|
||||||
shm()->timerValue[SUBFRAME_DEADTIME] = i64;
|
shm()->timerValue[SUBFRAME_DEADTIME] = i64;
|
||||||
}
|
}
|
||||||
|
|
||||||
// period
|
// period
|
||||||
n += client.receiveData(&i64, sizeof(i64));
|
n += client.Receive(&i64, sizeof(i64));
|
||||||
shm()->timerValue[FRAME_PERIOD] = i64;
|
shm()->timerValue[FRAME_PERIOD] = i64;
|
||||||
|
|
||||||
// delay
|
// delay
|
||||||
if (shm()->myDetectorType != EIGER) {
|
if (shm()->myDetectorType != EIGER) {
|
||||||
n += client.receiveData(&i64, sizeof(i64));
|
n += client.Receive(&i64, sizeof(i64));
|
||||||
shm()->timerValue[DELAY_AFTER_TRIGGER] = i64;
|
shm()->timerValue[DELAY_AFTER_TRIGGER] = i64;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shm()->myDetectorType == JUNGFRAU) {
|
if (shm()->myDetectorType == JUNGFRAU) {
|
||||||
// storage cell
|
// storage cell
|
||||||
n += client.receiveData(&i64, sizeof(i64));
|
n += client.Receive(&i64, sizeof(i64));
|
||||||
shm()->timerValue[STORAGE_CELL_NUMBER] = i64;
|
shm()->timerValue[STORAGE_CELL_NUMBER] = i64;
|
||||||
|
|
||||||
// storage cell delay
|
// storage cell delay
|
||||||
n += client.receiveData(&i64, sizeof(i64));
|
n += client.Receive(&i64, sizeof(i64));
|
||||||
shm()->timerValue[STORAGE_CELL_DELAY] = i64;
|
shm()->timerValue[STORAGE_CELL_DELAY] = i64;
|
||||||
}
|
}
|
||||||
|
|
||||||
// cycles
|
// cycles
|
||||||
n += client.receiveData(&i64, sizeof(i64));
|
n += client.Receive(&i64, sizeof(i64));
|
||||||
shm()->timerValue[CYCLES_NUMBER] = i64;
|
shm()->timerValue[CYCLES_NUMBER] = i64;
|
||||||
|
|
||||||
// readout flags
|
// readout flags
|
||||||
if (shm()->myDetectorType == EIGER ||
|
if (shm()->myDetectorType == EIGER ||
|
||||||
shm()->myDetectorType == CHIPTESTBOARD) {
|
shm()->myDetectorType == CHIPTESTBOARD) {
|
||||||
n += client.receiveData(&i32, sizeof(i32));
|
n += client.Receive(&i32, sizeof(i32));
|
||||||
shm()->roFlags = static_cast<readOutFlags>(i32);
|
shm()->roFlags = static_cast<readOutFlags>(i32);
|
||||||
}
|
}
|
||||||
|
|
||||||
// roi
|
// roi
|
||||||
if (shm()->myDetectorType == GOTTHARD) {
|
if (shm()->myDetectorType == GOTTHARD) {
|
||||||
n += client.receiveData(&i32, sizeof(i32));
|
n += client.Receive(&i32, sizeof(i32));
|
||||||
shm()->nROI = i32;
|
shm()->nROI = i32;
|
||||||
for (int i = 0; i < shm()->nROI; ++i) {
|
for (int i = 0; i < shm()->nROI; ++i) {
|
||||||
n += client.receiveData(&i32, sizeof(i32));
|
n += client.Receive(&i32, sizeof(i32));
|
||||||
shm()->roiLimits[i].xmin = i32;
|
shm()->roiLimits[i].xmin = i32;
|
||||||
n += client.receiveData(&i32, sizeof(i32));
|
n += client.Receive(&i32, sizeof(i32));
|
||||||
shm()->roiLimits[i].xmax = i32;
|
shm()->roiLimits[i].xmax = i32;
|
||||||
n += client.receiveData(&i32, sizeof(i32));
|
n += client.Receive(&i32, sizeof(i32));
|
||||||
shm()->roiLimits[i].ymin = i32;
|
shm()->roiLimits[i].ymin = i32;
|
||||||
n += client.receiveData(&i32, sizeof(i32));
|
n += client.Receive(&i32, sizeof(i32));
|
||||||
shm()->roiLimits[i].xmax = i32;
|
shm()->roiLimits[i].xmax = i32;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -880,20 +880,20 @@ int slsDetector::updateDetectorNoWait(sls::ClientSocket &client) {
|
|||||||
if (shm()->myDetectorType == CHIPTESTBOARD ||
|
if (shm()->myDetectorType == CHIPTESTBOARD ||
|
||||||
shm()->myDetectorType == MOENCH) {
|
shm()->myDetectorType == MOENCH) {
|
||||||
// analog samples
|
// analog samples
|
||||||
n += client.receiveData(&i64, sizeof(i64));
|
n += client.Receive(&i64, sizeof(i64));
|
||||||
if (i64 >= 0) {
|
if (i64 >= 0) {
|
||||||
shm()->timerValue[ANALOG_SAMPLES] = i64;
|
shm()->timerValue[ANALOG_SAMPLES] = i64;
|
||||||
}
|
}
|
||||||
|
|
||||||
// digital samples
|
// digital samples
|
||||||
n += client.receiveData(&i64, sizeof(i64));
|
n += client.Receive(&i64, sizeof(i64));
|
||||||
if (i64 >= 0) {
|
if (i64 >= 0) {
|
||||||
shm()->timerValue[DIGITAL_SAMPLES] = i64;
|
shm()->timerValue[DIGITAL_SAMPLES] = i64;
|
||||||
}
|
}
|
||||||
|
|
||||||
// adcmask
|
// adcmask
|
||||||
uint32_t u32 = 0;
|
uint32_t u32 = 0;
|
||||||
n += client.receiveData(&u32, sizeof(u32));
|
n += client.Receive(&u32, sizeof(u32));
|
||||||
shm()->adcEnableMask = u32;
|
shm()->adcEnableMask = u32;
|
||||||
if (shm()->myDetectorType == MOENCH)
|
if (shm()->myDetectorType == MOENCH)
|
||||||
setAdditionalJsonParameter("adcmask", std::to_string(u32));
|
setAdditionalJsonParameter("adcmask", std::to_string(u32));
|
||||||
@ -2459,13 +2459,13 @@ int slsDetector::sendImageToDetector(imageType index, int16_t imageVals[]) {
|
|||||||
|
|
||||||
if (shm()->onlineFlag == ONLINE_FLAG) {
|
if (shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||||
client.sendData(&fnum, sizeof(fnum));
|
client.Send(&fnum, sizeof(fnum));
|
||||||
client.sendData(args, sizeof(args));
|
client.Send(args, sizeof(args));
|
||||||
client.sendData(imageVals, nChan * sizeof(int16_t));
|
client.Send(imageVals, nChan * sizeof(int16_t));
|
||||||
client.receiveData(&ret, sizeof(ret));
|
client.Receive(&ret, sizeof(ret));
|
||||||
if (ret == FAIL) {
|
if (ret == FAIL) {
|
||||||
char mess[MAX_STR_LENGTH]{};
|
char mess[MAX_STR_LENGTH]{};
|
||||||
client.receiveData(mess, MAX_STR_LENGTH);
|
client.Receive(mess, MAX_STR_LENGTH);
|
||||||
throw DetectorError("Detector " + std::to_string(detId) +
|
throw DetectorError("Detector " + std::to_string(detId) +
|
||||||
" returned error: " + std::string(mess));
|
" returned error: " + std::string(mess));
|
||||||
}
|
}
|
||||||
@ -2554,32 +2554,32 @@ int slsDetector::sendROI(int n, ROI roiLimits[]) {
|
|||||||
|
|
||||||
if (shm()->onlineFlag == ONLINE_FLAG) {
|
if (shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||||
client.sendData(&fnum, sizeof(fnum));
|
client.Send(&fnum, sizeof(fnum));
|
||||||
client.sendData(&narg, sizeof(narg));
|
client.Send(&narg, sizeof(narg));
|
||||||
if (narg != -1) {
|
if (narg != -1) {
|
||||||
for (int i = 0; i < narg; ++i) {
|
for (int i = 0; i < narg; ++i) {
|
||||||
client.sendData(&arg[i].xmin, sizeof(int));
|
client.Send(&arg[i].xmin, sizeof(int));
|
||||||
client.sendData(&arg[i].xmax, sizeof(int));
|
client.Send(&arg[i].xmax, sizeof(int));
|
||||||
client.sendData(&arg[i].ymin, sizeof(int));
|
client.Send(&arg[i].ymin, sizeof(int));
|
||||||
client.sendData(&arg[i].ymax, sizeof(int));
|
client.Send(&arg[i].ymax, sizeof(int));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
client.receiveData(&ret, sizeof(ret));
|
client.Receive(&ret, sizeof(ret));
|
||||||
|
|
||||||
// handle ret
|
// handle ret
|
||||||
if (ret == FAIL) {
|
if (ret == FAIL) {
|
||||||
char mess[MAX_STR_LENGTH]{};
|
char mess[MAX_STR_LENGTH]{};
|
||||||
client.receiveData(mess, MAX_STR_LENGTH);
|
client.Receive(mess, MAX_STR_LENGTH);
|
||||||
throw RuntimeError("Detector " + std::to_string(detId) +
|
throw RuntimeError("Detector " + std::to_string(detId) +
|
||||||
" returned error: " + std::string(mess));
|
" returned error: " + std::string(mess));
|
||||||
} else {
|
} else {
|
||||||
client.receiveData(&nretval, sizeof(nretval));
|
client.Receive(&nretval, sizeof(nretval));
|
||||||
int nrec = 0;
|
int nrec = 0;
|
||||||
for (int i = 0; i < nretval; ++i) {
|
for (int i = 0; i < nretval; ++i) {
|
||||||
nrec += client.receiveData(&retval[i].xmin, sizeof(int));
|
nrec += client.Receive(&retval[i].xmin, sizeof(int));
|
||||||
nrec += client.receiveData(&retval[i].xmax, sizeof(int));
|
nrec += client.Receive(&retval[i].xmax, sizeof(int));
|
||||||
nrec += client.receiveData(&retval[i].ymin, sizeof(int));
|
nrec += client.Receive(&retval[i].ymin, sizeof(int));
|
||||||
nrec += client.receiveData(&retval[i].ymax, sizeof(int));
|
nrec += client.Receive(&retval[i].ymax, sizeof(int));
|
||||||
}
|
}
|
||||||
shm()->nROI = nretval;
|
shm()->nROI = nretval;
|
||||||
FILE_LOG(logDEBUG1) << "nRoi: " << nretval;
|
FILE_LOG(logDEBUG1) << "nRoi: " << nretval;
|
||||||
@ -2618,21 +2618,21 @@ int slsDetector::sendROI(int n, ROI roiLimits[]) {
|
|||||||
FILE_LOG(logDEBUG1) << "Sending ROI to receiver: " << shm()->nROI;
|
FILE_LOG(logDEBUG1) << "Sending ROI to receiver: " << shm()->nROI;
|
||||||
|
|
||||||
auto receiver = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort);
|
auto receiver = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort);
|
||||||
receiver.sendData(&fnum, sizeof(fnum));
|
receiver.Send(&fnum, sizeof(fnum));
|
||||||
receiver.sendData(&narg, sizeof(narg));
|
receiver.Send(&narg, sizeof(narg));
|
||||||
if (narg != -1) {
|
if (narg != -1) {
|
||||||
for (int i = 0; i < narg; ++i) {
|
for (int i = 0; i < narg; ++i) {
|
||||||
receiver.sendData(&arg[i].xmin, sizeof(int));
|
receiver.Send(&arg[i].xmin, sizeof(int));
|
||||||
receiver.sendData(&arg[i].xmax, sizeof(int));
|
receiver.Send(&arg[i].xmax, sizeof(int));
|
||||||
receiver.sendData(&arg[i].ymin, sizeof(int));
|
receiver.Send(&arg[i].ymin, sizeof(int));
|
||||||
receiver.sendData(&arg[i].ymax, sizeof(int));
|
receiver.Send(&arg[i].ymax, sizeof(int));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
receiver.receiveData(&ret, sizeof(ret));
|
receiver.Receive(&ret, sizeof(ret));
|
||||||
|
|
||||||
if (ret == FAIL) {
|
if (ret == FAIL) {
|
||||||
char mess[MAX_STR_LENGTH]{};
|
char mess[MAX_STR_LENGTH]{};
|
||||||
receiver.receiveData(mess, MAX_STR_LENGTH);
|
receiver.Receive(mess, MAX_STR_LENGTH);
|
||||||
throw ReceiverError("Receiver " + std::to_string(detId) +
|
throw ReceiverError("Receiver " + std::to_string(detId) +
|
||||||
" returned error: " + std::string(mess));
|
" returned error: " + std::string(mess));
|
||||||
}
|
}
|
||||||
@ -2979,12 +2979,12 @@ int slsDetector::programFPGA(std::vector<char> buffer) {
|
|||||||
|
|
||||||
if (shm()->onlineFlag == ONLINE_FLAG) {
|
if (shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||||
client.sendData(&fnum, sizeof(fnum));
|
client.Send(&fnum, sizeof(fnum));
|
||||||
client.sendData(&filesize, sizeof(filesize));
|
client.Send(&filesize, sizeof(filesize));
|
||||||
client.receiveData(&ret, sizeof(ret));
|
client.Receive(&ret, sizeof(ret));
|
||||||
// error in detector at opening file pointer to flash
|
// error in detector at opening file pointer to flash
|
||||||
if (ret == FAIL) {
|
if (ret == FAIL) {
|
||||||
client.receiveData(mess, sizeof(mess));
|
client.Receive(mess, sizeof(mess));
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "Detector " << detId << " (" << shm()->hostname << ")"
|
os << "Detector " << detId << " (" << shm()->hostname << ")"
|
||||||
<< " returned error: " << mess;
|
<< " returned error: " << mess;
|
||||||
@ -3029,8 +3029,8 @@ int slsDetector::programFPGA(std::vector<char> buffer) {
|
|||||||
FILE_LOG(logDEBUG1) << "unitprogramsize:" << unitprogramsize
|
FILE_LOG(logDEBUG1) << "unitprogramsize:" << unitprogramsize
|
||||||
<< "\t filesize:" << filesize;
|
<< "\t filesize:" << filesize;
|
||||||
|
|
||||||
client.sendData(&buffer[currentPointer], unitprogramsize);
|
client.Send(&buffer[currentPointer], unitprogramsize);
|
||||||
client.receiveData(&ret, sizeof(ret));
|
client.Receive(&ret, sizeof(ret));
|
||||||
if (ret != FAIL) {
|
if (ret != FAIL) {
|
||||||
filesize -= unitprogramsize;
|
filesize -= unitprogramsize;
|
||||||
currentPointer += unitprogramsize;
|
currentPointer += unitprogramsize;
|
||||||
@ -3043,7 +3043,7 @@ int slsDetector::programFPGA(std::vector<char> buffer) {
|
|||||||
std::cout << std::flush;
|
std::cout << std::flush;
|
||||||
} else {
|
} else {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
client.receiveData(mess, sizeof(mess));
|
client.Receive(mess, sizeof(mess));
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "Detector " << detId << " (" << shm()->hostname << ")"
|
os << "Detector " << detId << " (" << shm()->hostname << ")"
|
||||||
<< " returned error: " << mess;
|
<< " returned error: " << mess;
|
||||||
@ -3090,7 +3090,7 @@ int slsDetector::rebootController() {
|
|||||||
<< " (" << shm()->hostname << ")";
|
<< " (" << shm()->hostname << ")";
|
||||||
if (shm()->onlineFlag == ONLINE_FLAG) {
|
if (shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||||
client.sendData(&fnum, sizeof(fnum));
|
client.Send(&fnum, sizeof(fnum));
|
||||||
ret = OK;
|
ret = OK;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -3128,16 +3128,16 @@ int slsDetector::setModule(sls_detector_module &module, int tb) {
|
|||||||
}
|
}
|
||||||
if (shm()->onlineFlag == ONLINE_FLAG) {
|
if (shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||||
client.sendData(&fnum, sizeof(fnum));
|
client.Send(&fnum, sizeof(fnum));
|
||||||
sendModule(&module, client);
|
sendModule(&module, client);
|
||||||
client.receiveData(&ret, sizeof(ret));
|
client.Receive(&ret, sizeof(ret));
|
||||||
if (ret == FAIL) {
|
if (ret == FAIL) {
|
||||||
char mess[MAX_STR_LENGTH] = {0};
|
char mess[MAX_STR_LENGTH] = {0};
|
||||||
client.receiveData(mess, sizeof(mess));
|
client.Receive(mess, sizeof(mess));
|
||||||
throw RuntimeError("Detector " + std::to_string(detId) +
|
throw RuntimeError("Detector " + std::to_string(detId) +
|
||||||
" returned error: " + mess);
|
" returned error: " + mess);
|
||||||
}
|
}
|
||||||
client.receiveData(&retval, sizeof(retval));
|
client.Receive(&retval, sizeof(retval));
|
||||||
FILE_LOG(logDEBUG1) << "Set Module returned: " << retval;
|
FILE_LOG(logDEBUG1) << "Set Module returned: " << retval;
|
||||||
}
|
}
|
||||||
if (ret == FORCE_UPDATE) {
|
if (ret == FORCE_UPDATE) {
|
||||||
@ -3317,95 +3317,95 @@ int slsDetector::updateCachedReceiverVariables() const {
|
|||||||
char cstring[MAX_STR_LENGTH]{};
|
char cstring[MAX_STR_LENGTH]{};
|
||||||
char lastClientIP[INET_ADDRSTRLEN]{};
|
char lastClientIP[INET_ADDRSTRLEN]{};
|
||||||
|
|
||||||
n += receiver.receiveData(lastClientIP, sizeof(lastClientIP));
|
n += receiver.Receive(lastClientIP, sizeof(lastClientIP));
|
||||||
FILE_LOG(logDEBUG1)
|
FILE_LOG(logDEBUG1)
|
||||||
<< "Updating receiver last modified by " << lastClientIP;
|
<< "Updating receiver last modified by " << lastClientIP;
|
||||||
|
|
||||||
// filepath
|
// filepath
|
||||||
n += receiver.receiveData(cstring, sizeof(cstring));
|
n += receiver.Receive(cstring, sizeof(cstring));
|
||||||
sls::strcpy_safe(shm()->rxFilePath, cstring);
|
sls::strcpy_safe(shm()->rxFilePath, cstring);
|
||||||
|
|
||||||
// filename
|
// filename
|
||||||
n += receiver.receiveData(cstring, sizeof(cstring));
|
n += receiver.Receive(cstring, sizeof(cstring));
|
||||||
sls::strcpy_safe(shm()->rxFileName, cstring);
|
sls::strcpy_safe(shm()->rxFileName, cstring);
|
||||||
|
|
||||||
// index
|
// index
|
||||||
n += receiver.receiveData(&i32, sizeof(i32));
|
n += receiver.Receive(&i32, sizeof(i32));
|
||||||
shm()->rxFileIndex = i32;
|
shm()->rxFileIndex = i32;
|
||||||
|
|
||||||
// file format
|
// file format
|
||||||
n += receiver.receiveData(&i32, sizeof(i32));
|
n += receiver.Receive(&i32, sizeof(i32));
|
||||||
shm()->rxFileFormat = static_cast<fileFormat>(i32);
|
shm()->rxFileFormat = static_cast<fileFormat>(i32);
|
||||||
|
|
||||||
// frames per file
|
// frames per file
|
||||||
n += receiver.receiveData(&i32, sizeof(i32));
|
n += receiver.Receive(&i32, sizeof(i32));
|
||||||
shm()->rxFramesPerFile = i32;
|
shm()->rxFramesPerFile = i32;
|
||||||
|
|
||||||
// frame discard policy
|
// frame discard policy
|
||||||
n += receiver.receiveData(&i32, sizeof(i32));
|
n += receiver.Receive(&i32, sizeof(i32));
|
||||||
shm()->rxFrameDiscardMode = static_cast<frameDiscardPolicy>(i32);
|
shm()->rxFrameDiscardMode = static_cast<frameDiscardPolicy>(i32);
|
||||||
|
|
||||||
// frame padding
|
// frame padding
|
||||||
n += receiver.receiveData(&i32, sizeof(i32));
|
n += receiver.Receive(&i32, sizeof(i32));
|
||||||
shm()->rxFramePadding = static_cast<bool>(i32);
|
shm()->rxFramePadding = static_cast<bool>(i32);
|
||||||
|
|
||||||
// file write enable
|
// file write enable
|
||||||
n += receiver.receiveData(&i32, sizeof(i32));
|
n += receiver.Receive(&i32, sizeof(i32));
|
||||||
shm()->rxFileWrite = static_cast<bool>(i32);
|
shm()->rxFileWrite = static_cast<bool>(i32);
|
||||||
|
|
||||||
// master file write enable
|
// master file write enable
|
||||||
n += receiver.receiveData(&i32, sizeof(i32));
|
n += receiver.Receive(&i32, sizeof(i32));
|
||||||
shm()->rxMasterFileWrite = static_cast<bool>(i32);
|
shm()->rxMasterFileWrite = static_cast<bool>(i32);
|
||||||
|
|
||||||
// file overwrite enable
|
// file overwrite enable
|
||||||
n += receiver.receiveData(&i32, sizeof(i32));
|
n += receiver.Receive(&i32, sizeof(i32));
|
||||||
shm()->rxFileOverWrite = static_cast<bool>(i32);
|
shm()->rxFileOverWrite = static_cast<bool>(i32);
|
||||||
|
|
||||||
// gap pixels
|
// gap pixels
|
||||||
n += receiver.receiveData(&i32, sizeof(i32));
|
n += receiver.Receive(&i32, sizeof(i32));
|
||||||
shm()->gappixels = i32;
|
shm()->gappixels = i32;
|
||||||
|
|
||||||
// receiver read frequency
|
// receiver read frequency
|
||||||
n += receiver.receiveData(&i32, sizeof(i32));
|
n += receiver.Receive(&i32, sizeof(i32));
|
||||||
shm()->rxReadFreq = i32;
|
shm()->rxReadFreq = i32;
|
||||||
|
|
||||||
// receiver streaming port
|
// receiver streaming port
|
||||||
n += receiver.receiveData(&i32, sizeof(i32));
|
n += receiver.Receive(&i32, sizeof(i32));
|
||||||
shm()->rxZmqport = i32;
|
shm()->rxZmqport = i32;
|
||||||
|
|
||||||
// streaming source ip
|
// streaming source ip
|
||||||
n += receiver.receiveData(cstring, sizeof(cstring));
|
n += receiver.Receive(cstring, sizeof(cstring));
|
||||||
sls::strcpy_safe(shm()->rxZmqip, cstring);
|
sls::strcpy_safe(shm()->rxZmqip, cstring);
|
||||||
|
|
||||||
// additional json header
|
// additional json header
|
||||||
n += receiver.receiveData(cstring, sizeof(cstring));
|
n += receiver.Receive(cstring, sizeof(cstring));
|
||||||
sls::strcpy_safe(shm()->rxAdditionalJsonHeader, cstring);
|
sls::strcpy_safe(shm()->rxAdditionalJsonHeader, cstring);
|
||||||
|
|
||||||
// receiver streaming enable
|
// receiver streaming enable
|
||||||
n += receiver.receiveData(&i32, sizeof(i32));
|
n += receiver.Receive(&i32, sizeof(i32));
|
||||||
shm()->rxUpstream = static_cast<bool>(i32);
|
shm()->rxUpstream = static_cast<bool>(i32);
|
||||||
|
|
||||||
// activate
|
// activate
|
||||||
n += receiver.receiveData(&i32, sizeof(i32));
|
n += receiver.Receive(&i32, sizeof(i32));
|
||||||
shm()->activated = static_cast<bool>(i32);
|
shm()->activated = static_cast<bool>(i32);
|
||||||
|
|
||||||
// deactivated padding enable
|
// deactivated padding enable
|
||||||
n += receiver.receiveData(&i32, sizeof(i32));
|
n += receiver.Receive(&i32, sizeof(i32));
|
||||||
shm()->rxPadDeactivatedModules = static_cast<bool>(i32);
|
shm()->rxPadDeactivatedModules = static_cast<bool>(i32);
|
||||||
|
|
||||||
// silent mode
|
// silent mode
|
||||||
n += receiver.receiveData(&i32, sizeof(i32));
|
n += receiver.Receive(&i32, sizeof(i32));
|
||||||
shm()->rxSilentMode = static_cast<bool>(i32);
|
shm()->rxSilentMode = static_cast<bool>(i32);
|
||||||
|
|
||||||
// dbit list
|
// dbit list
|
||||||
{
|
{
|
||||||
sls::FixedCapacityContainer<int, MAX_RX_DBIT> temp;
|
sls::FixedCapacityContainer<int, MAX_RX_DBIT> temp;
|
||||||
n += receiver.receiveData(&temp, sizeof(temp));
|
n += receiver.Receive(&temp, sizeof(temp));
|
||||||
shm()->rxDbitList = temp;
|
shm()->rxDbitList = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// dbit offset
|
// dbit offset
|
||||||
n += receiver.receiveData(&i32, sizeof(i32));
|
n += receiver.Receive(&i32, sizeof(i32));
|
||||||
shm()->rxDbitOffset = i32;
|
shm()->rxDbitOffset = i32;
|
||||||
|
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
|
@ -212,7 +212,7 @@ int slsReceiverTCPIPInterface::function_table(){
|
|||||||
// clang-format on
|
// clang-format on
|
||||||
int slsReceiverTCPIPInterface::decode_function(Interface &socket) {
|
int slsReceiverTCPIPInterface::decode_function(Interface &socket) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
socket.receiveArg(fnum);
|
socket.Receive(fnum);
|
||||||
if (fnum <= NUM_DET_FUNCTIONS || fnum >= NUM_REC_FUNCTIONS) {
|
if (fnum <= NUM_DET_FUNCTIONS || fnum >= NUM_REC_FUNCTIONS) {
|
||||||
throw RuntimeError("Unrecognized Function enum " +
|
throw RuntimeError("Unrecognized Function enum " +
|
||||||
std::to_string(fnum) + "\n");
|
std::to_string(fnum) + "\n");
|
||||||
@ -274,7 +274,7 @@ void slsReceiverTCPIPInterface::VerifyIdle(Interface &socket) {
|
|||||||
int slsReceiverTCPIPInterface::exec_command(Interface &socket) {
|
int slsReceiverTCPIPInterface::exec_command(Interface &socket) {
|
||||||
char cmd[MAX_STR_LENGTH]{};
|
char cmd[MAX_STR_LENGTH]{};
|
||||||
char retval[MAX_STR_LENGTH]{};
|
char retval[MAX_STR_LENGTH]{};
|
||||||
socket.receiveArg(cmd);
|
socket.Receive(cmd);
|
||||||
FILE_LOG(logINFO) << "Executing command (" << cmd << ")";
|
FILE_LOG(logINFO) << "Executing command (" << cmd << ")";
|
||||||
const size_t tempsize = 256;
|
const size_t tempsize = 256;
|
||||||
std::array<char, tempsize> temp;
|
std::array<char, tempsize> temp;
|
||||||
@ -295,12 +295,12 @@ int slsReceiverTCPIPInterface::exec_command(Interface &socket) {
|
|||||||
|
|
||||||
int slsReceiverTCPIPInterface::exit_server(Interface &socket) {
|
int slsReceiverTCPIPInterface::exit_server(Interface &socket) {
|
||||||
FILE_LOG(logINFO) << "Closing server";
|
FILE_LOG(logINFO) << "Closing server";
|
||||||
socket.sendData(OK);
|
socket.Send(OK);
|
||||||
return GOODBYE;
|
return GOODBYE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::lock_receiver(Interface &socket) {
|
int slsReceiverTCPIPInterface::lock_receiver(Interface &socket) {
|
||||||
auto lock = socket.receive<int>();
|
auto lock = socket.Receive<int>();
|
||||||
FILE_LOG(logDEBUG1) << "Locking Server to " << lock;
|
FILE_LOG(logDEBUG1) << "Locking Server to " << lock;
|
||||||
if (lock >= 0) {
|
if (lock >= 0) {
|
||||||
if (!lockStatus || (server->getLockedBy() == server->getThisClient())) {
|
if (!lockStatus || (server->getLockedBy() == server->getThisClient())) {
|
||||||
@ -323,7 +323,7 @@ int slsReceiverTCPIPInterface::get_last_client_ip(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_port(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_port(Interface &socket) {
|
||||||
auto p_number = socket.receive<int>();
|
auto p_number = socket.Receive<int>();
|
||||||
if (p_number < 1024)
|
if (p_number < 1024)
|
||||||
throw RuntimeError("Port Number: " + std::to_string(p_number) +
|
throw RuntimeError("Port Number: " + std::to_string(p_number) +
|
||||||
" is too low (<1024)");
|
" is too low (<1024)");
|
||||||
@ -341,7 +341,7 @@ int slsReceiverTCPIPInterface::update_client(Interface &socket) {
|
|||||||
if (receiver == nullptr)
|
if (receiver == nullptr)
|
||||||
throw sls::SocketError(
|
throw sls::SocketError(
|
||||||
"Receiver not set up. Please use rx_hostname first.\n");
|
"Receiver not set up. Please use rx_hostname first.\n");
|
||||||
socket.sendData(OK);
|
socket.Send(OK);
|
||||||
return send_update(socket);
|
return send_update(socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -352,83 +352,83 @@ int slsReceiverTCPIPInterface::send_update(Interface &socket) {
|
|||||||
|
|
||||||
char ip[INET_ADDRSTRLEN]{};
|
char ip[INET_ADDRSTRLEN]{};
|
||||||
sls::strcpy_safe(ip, server->getLastClient().str().c_str());
|
sls::strcpy_safe(ip, server->getLastClient().str().c_str());
|
||||||
n += socket.sendData(ip, sizeof(ip));
|
n += socket.Send(ip, sizeof(ip));
|
||||||
|
|
||||||
// filepath
|
// filepath
|
||||||
strcpy(cstring, receiver->getFilePath().c_str());
|
strcpy(cstring, receiver->getFilePath().c_str());
|
||||||
n += socket.sendData(cstring, sizeof(cstring));
|
n += socket.Send(cstring, sizeof(cstring));
|
||||||
|
|
||||||
// filename
|
// filename
|
||||||
strcpy(cstring, receiver->getFileName().c_str());
|
strcpy(cstring, receiver->getFileName().c_str());
|
||||||
n += socket.sendData(cstring, sizeof(cstring));
|
n += socket.Send(cstring, sizeof(cstring));
|
||||||
|
|
||||||
// index
|
// index
|
||||||
i32 = receiver->getFileIndex();
|
i32 = receiver->getFileIndex();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.Send(&i32, sizeof(i32));
|
||||||
|
|
||||||
// file format
|
// file format
|
||||||
i32 = (int)receiver->getFileFormat();
|
i32 = (int)receiver->getFileFormat();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.Send(&i32, sizeof(i32));
|
||||||
|
|
||||||
// frames per file
|
// frames per file
|
||||||
i32 = (int)receiver->getFramesPerFile();
|
i32 = (int)receiver->getFramesPerFile();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.Send(&i32, sizeof(i32));
|
||||||
|
|
||||||
// frame discard policy
|
// frame discard policy
|
||||||
i32 = (int)receiver->getFrameDiscardPolicy();
|
i32 = (int)receiver->getFrameDiscardPolicy();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.Send(&i32, sizeof(i32));
|
||||||
|
|
||||||
// frame padding
|
// frame padding
|
||||||
i32 = (int)receiver->getFramePaddingEnable();
|
i32 = (int)receiver->getFramePaddingEnable();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.Send(&i32, sizeof(i32));
|
||||||
|
|
||||||
// file write enable
|
// file write enable
|
||||||
i32 = (int)receiver->getFileWriteEnable();
|
i32 = (int)receiver->getFileWriteEnable();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.Send(&i32, sizeof(i32));
|
||||||
|
|
||||||
// master file write enable
|
// master file write enable
|
||||||
i32 = (int)receiver->getMasterFileWriteEnable();
|
i32 = (int)receiver->getMasterFileWriteEnable();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.Send(&i32, sizeof(i32));
|
||||||
|
|
||||||
// file overwrite enable
|
// file overwrite enable
|
||||||
i32 = (int)receiver->getOverwriteEnable();
|
i32 = (int)receiver->getOverwriteEnable();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.Send(&i32, sizeof(i32));
|
||||||
|
|
||||||
// gap pixels
|
// gap pixels
|
||||||
i32 = (int)receiver->getGapPixelsEnable();
|
i32 = (int)receiver->getGapPixelsEnable();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.Send(&i32, sizeof(i32));
|
||||||
|
|
||||||
// streaming frequency
|
// streaming frequency
|
||||||
i32 = (int)receiver->getStreamingFrequency();
|
i32 = (int)receiver->getStreamingFrequency();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.Send(&i32, sizeof(i32));
|
||||||
|
|
||||||
// streaming port
|
// streaming port
|
||||||
i32 = (int)receiver->getStreamingPort();
|
i32 = (int)receiver->getStreamingPort();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.Send(&i32, sizeof(i32));
|
||||||
|
|
||||||
// streaming source ip
|
// streaming source ip
|
||||||
strcpy(cstring, receiver->getStreamingSourceIP().c_str());
|
strcpy(cstring, receiver->getStreamingSourceIP().c_str());
|
||||||
n += socket.sendData(cstring, sizeof(cstring));
|
n += socket.Send(cstring, sizeof(cstring));
|
||||||
|
|
||||||
// additional json header
|
// additional json header
|
||||||
strcpy(cstring, receiver->getAdditionalJsonHeader().c_str());
|
strcpy(cstring, receiver->getAdditionalJsonHeader().c_str());
|
||||||
n += socket.sendData(cstring, sizeof(cstring));
|
n += socket.Send(cstring, sizeof(cstring));
|
||||||
|
|
||||||
// data streaming enable
|
// data streaming enable
|
||||||
i32 = (int)receiver->getDataStreamEnable();
|
i32 = (int)receiver->getDataStreamEnable();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.Send(&i32, sizeof(i32));
|
||||||
|
|
||||||
// activate
|
// activate
|
||||||
i32 = (int)receiver->getActivate();
|
i32 = (int)receiver->getActivate();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.Send(&i32, sizeof(i32));
|
||||||
|
|
||||||
// deactivated padding enable
|
// deactivated padding enable
|
||||||
i32 = (int)receiver->getDeactivatedPadding();
|
i32 = (int)receiver->getDeactivatedPadding();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.Send(&i32, sizeof(i32));
|
||||||
|
|
||||||
// silent mode
|
// silent mode
|
||||||
i32 = (int)receiver->getSilentMode();
|
i32 = (int)receiver->getSilentMode();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.Send(&i32, sizeof(i32));
|
||||||
|
|
||||||
// dbit list
|
// dbit list
|
||||||
{
|
{
|
||||||
@ -436,13 +436,13 @@ int slsReceiverTCPIPInterface::send_update(Interface &socket) {
|
|||||||
int retvalsize = list.size();
|
int retvalsize = list.size();
|
||||||
int retval[retvalsize];
|
int retval[retvalsize];
|
||||||
std::copy(std::begin(list), std::end(list), retval);
|
std::copy(std::begin(list), std::end(list), retval);
|
||||||
socket.sendData(&retvalsize, sizeof(retvalsize));
|
socket.Send(&retvalsize, sizeof(retvalsize));
|
||||||
socket.sendData(retval, sizeof(retval));
|
socket.Send(retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
// dbit offset
|
// dbit offset
|
||||||
i32 = receiver->getDbitOffset();
|
i32 = receiver->getDbitOffset();
|
||||||
n += socket.sendData(&i32, sizeof(i32));
|
n += socket.Send(&i32, sizeof(i32));
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@ -452,7 +452,7 @@ int slsReceiverTCPIPInterface::get_id(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_detector_type(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_detector_type(Interface &socket) {
|
||||||
auto arg = socket.receive<detectorType>();
|
auto arg = socket.Receive<detectorType>();
|
||||||
// set
|
// set
|
||||||
if (arg >= 0) {
|
if (arg >= 0) {
|
||||||
// if object exists, verify unlocked and idle, else only verify lock
|
// if object exists, verify unlocked and idle, else only verify lock
|
||||||
@ -500,7 +500,7 @@ int slsReceiverTCPIPInterface::set_detector_type(Interface &socket) {
|
|||||||
int slsReceiverTCPIPInterface::set_detector_hostname(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_detector_hostname(Interface &socket) {
|
||||||
char hostname[MAX_STR_LENGTH]{};
|
char hostname[MAX_STR_LENGTH]{};
|
||||||
char retval[MAX_STR_LENGTH]{};
|
char retval[MAX_STR_LENGTH]{};
|
||||||
socket.receiveArg(hostname);
|
socket.Receive(hostname);
|
||||||
|
|
||||||
if (strlen(hostname)) {
|
if (strlen(hostname)) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
@ -516,11 +516,11 @@ int slsReceiverTCPIPInterface::set_detector_hostname(Interface &socket) {
|
|||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_roi(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_roi(Interface &socket) {
|
||||||
static_assert(sizeof(ROI) == 4 * sizeof(int), "ROI not packed");
|
static_assert(sizeof(ROI) == 4 * sizeof(int), "ROI not packed");
|
||||||
auto narg = socket.receive<int>();
|
auto narg = socket.Receive<int>();
|
||||||
std::vector<ROI> arg;
|
std::vector<ROI> arg;
|
||||||
for (int iloop = 0; iloop < narg; ++iloop) {
|
for (int iloop = 0; iloop < narg; ++iloop) {
|
||||||
ROI temp{};
|
ROI temp{};
|
||||||
socket.receiveArg(temp);
|
socket.Receive(temp);
|
||||||
arg.push_back(temp);
|
arg.push_back(temp);
|
||||||
}
|
}
|
||||||
FILE_LOG(logDEBUG1) << "Set ROI narg: " << narg;
|
FILE_LOG(logDEBUG1) << "Set ROI narg: " << narg;
|
||||||
@ -536,14 +536,14 @@ int slsReceiverTCPIPInterface::set_roi(Interface &socket) {
|
|||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
if (impl()->setROI(arg) == FAIL)
|
if (impl()->setROI(arg) == FAIL)
|
||||||
throw RuntimeError("Could not set ROI");
|
throw RuntimeError("Could not set ROI");
|
||||||
return socket.sendData(OK);
|
return socket.Send(OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::setup_udp(Interface &socket) {
|
int slsReceiverTCPIPInterface::setup_udp(Interface &socket) {
|
||||||
ret = OK;
|
ret = OK;
|
||||||
char args[5][MAX_STR_LENGTH]{};
|
char args[5][MAX_STR_LENGTH]{};
|
||||||
char retvals[2][MAX_STR_LENGTH]{};
|
char retvals[2][MAX_STR_LENGTH]{};
|
||||||
socket.receiveArg(args);
|
socket.Receive(args);
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
|
|
||||||
// setup interfaces count
|
// setup interfaces count
|
||||||
@ -641,7 +641,7 @@ int slsReceiverTCPIPInterface::set_timer(Interface &socket) {
|
|||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
int64_t index[2] = {-1, -1};
|
int64_t index[2] = {-1, -1};
|
||||||
int64_t retval = -1;
|
int64_t retval = -1;
|
||||||
socket.receiveArg(index);
|
socket.Receive(index);
|
||||||
if (index[1] >= 0) {
|
if (index[1] >= 0) {
|
||||||
FILE_LOG(logDEBUG1)
|
FILE_LOG(logDEBUG1)
|
||||||
<< "Setting timer index " << index[0] << " to " << index[1];
|
<< "Setting timer index " << index[0] << " to " << index[1];
|
||||||
@ -734,7 +734,7 @@ int slsReceiverTCPIPInterface::set_timer(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_dynamic_range(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_dynamic_range(Interface &socket) {
|
||||||
auto dr = socket.receive<int>();
|
auto dr = socket.Receive<int>();
|
||||||
if (dr >= 0) {
|
if (dr >= 0) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
FILE_LOG(logDEBUG1) << "Setting dynamic range: " << dr;
|
FILE_LOG(logDEBUG1) << "Setting dynamic range: " << dr;
|
||||||
@ -769,7 +769,7 @@ int slsReceiverTCPIPInterface::set_dynamic_range(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_streaming_frequency(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_streaming_frequency(Interface &socket) {
|
||||||
auto index = socket.receive<int>();
|
auto index = socket.Receive<int>();
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
FILE_LOG(logDEBUG1) << "Setting streaming frequency: " << index;
|
FILE_LOG(logDEBUG1) << "Setting streaming frequency: " << index;
|
||||||
@ -801,7 +801,7 @@ int slsReceiverTCPIPInterface::start_receiver(Interface &socket) {
|
|||||||
throw RuntimeError(mess);
|
throw RuntimeError(mess);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return socket.sendData(OK);
|
return socket.Send(OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::stop_receiver(Interface &socket) {
|
int slsReceiverTCPIPInterface::stop_receiver(Interface &socket) {
|
||||||
@ -814,13 +814,13 @@ int slsReceiverTCPIPInterface::stop_receiver(Interface &socket) {
|
|||||||
throw RuntimeError("Could not stop receiver. It as it is: " +
|
throw RuntimeError("Could not stop receiver. It as it is: " +
|
||||||
runStatusType(s));
|
runStatusType(s));
|
||||||
|
|
||||||
return socket.sendData(OK);
|
return socket.Send(OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_file_dir(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_file_dir(Interface &socket) {
|
||||||
char fPath[MAX_STR_LENGTH]{};
|
char fPath[MAX_STR_LENGTH]{};
|
||||||
char retval[MAX_STR_LENGTH]{};
|
char retval[MAX_STR_LENGTH]{};
|
||||||
socket.receiveArg(fPath);
|
socket.Receive(fPath);
|
||||||
|
|
||||||
if (strlen(fPath)) {
|
if (strlen(fPath)) {
|
||||||
FILE_LOG(logDEBUG1) << "Setting file path: " << fPath;
|
FILE_LOG(logDEBUG1) << "Setting file path: " << fPath;
|
||||||
@ -839,7 +839,7 @@ int slsReceiverTCPIPInterface::set_file_dir(Interface &socket) {
|
|||||||
int slsReceiverTCPIPInterface::set_file_name(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_file_name(Interface &socket) {
|
||||||
char fName[MAX_STR_LENGTH]{};
|
char fName[MAX_STR_LENGTH]{};
|
||||||
char retval[MAX_STR_LENGTH]{};
|
char retval[MAX_STR_LENGTH]{};
|
||||||
socket.receiveArg(fName);
|
socket.Receive(fName);
|
||||||
if (strlen(fName)) {
|
if (strlen(fName)) {
|
||||||
FILE_LOG(logDEBUG1) << "Setting file name: " << fName;
|
FILE_LOG(logDEBUG1) << "Setting file name: " << fName;
|
||||||
impl()->setFileName(fName);
|
impl()->setFileName(fName);
|
||||||
@ -854,7 +854,7 @@ int slsReceiverTCPIPInterface::set_file_name(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_file_index(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_file_index(Interface &socket) {
|
||||||
auto index = socket.receive<int>();
|
auto index = socket.Receive<int>();
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
FILE_LOG(logDEBUG1) << "Setting file index: " << index;
|
FILE_LOG(logDEBUG1) << "Setting file index: " << index;
|
||||||
@ -881,11 +881,11 @@ int slsReceiverTCPIPInterface::get_frames_caught(Interface &socket) {
|
|||||||
int slsReceiverTCPIPInterface::reset_frames_caught(Interface &socket) {
|
int slsReceiverTCPIPInterface::reset_frames_caught(Interface &socket) {
|
||||||
FILE_LOG(logDEBUG1) << "Reset frames caught";
|
FILE_LOG(logDEBUG1) << "Reset frames caught";
|
||||||
impl()->resetAcquisitionCount();
|
impl()->resetAcquisitionCount();
|
||||||
return socket.sendData(OK);
|
return socket.Send(OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::enable_file_write(Interface &socket) {
|
int slsReceiverTCPIPInterface::enable_file_write(Interface &socket) {
|
||||||
auto enable = socket.receive<int>();
|
auto enable = socket.Receive<int>();
|
||||||
if (enable >= 0) {
|
if (enable >= 0) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
FILE_LOG(logDEBUG1) << "Setting File write enable:" << enable;
|
FILE_LOG(logDEBUG1) << "Setting File write enable:" << enable;
|
||||||
@ -898,7 +898,7 @@ int slsReceiverTCPIPInterface::enable_file_write(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::enable_master_file_write(Interface &socket) {
|
int slsReceiverTCPIPInterface::enable_master_file_write(Interface &socket) {
|
||||||
auto enable = socket.receive<int>();
|
auto enable = socket.Receive<int>();
|
||||||
if (enable >= 0) {
|
if (enable >= 0) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
FILE_LOG(logDEBUG1) << "Setting Master File write enable:" << enable;
|
FILE_LOG(logDEBUG1) << "Setting Master File write enable:" << enable;
|
||||||
@ -911,7 +911,7 @@ int slsReceiverTCPIPInterface::enable_master_file_write(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::enable_overwrite(Interface &socket) {
|
int slsReceiverTCPIPInterface::enable_overwrite(Interface &socket) {
|
||||||
auto index = socket.receive<int>();
|
auto index = socket.Receive<int>();
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
FILE_LOG(logDEBUG1) << "Setting File overwrite enable:" << index;
|
FILE_LOG(logDEBUG1) << "Setting File overwrite enable:" << index;
|
||||||
@ -924,7 +924,7 @@ int slsReceiverTCPIPInterface::enable_overwrite(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::enable_tengiga(Interface &socket) {
|
int slsReceiverTCPIPInterface::enable_tengiga(Interface &socket) {
|
||||||
auto val = socket.receive<int>();
|
auto val = socket.Receive<int>();
|
||||||
if (myDetectorType != EIGER && myDetectorType != CHIPTESTBOARD &&
|
if (myDetectorType != EIGER && myDetectorType != CHIPTESTBOARD &&
|
||||||
myDetectorType != MOENCH)
|
myDetectorType != MOENCH)
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
@ -941,7 +941,7 @@ int slsReceiverTCPIPInterface::enable_tengiga(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_fifo_depth(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_fifo_depth(Interface &socket) {
|
||||||
auto value = socket.receive<int>();
|
auto value = socket.Receive<int>();
|
||||||
if (value >= 0) {
|
if (value >= 0) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
FILE_LOG(logDEBUG1) << "Setting fifo depth:" << value;
|
FILE_LOG(logDEBUG1) << "Setting fifo depth:" << value;
|
||||||
@ -954,7 +954,7 @@ int slsReceiverTCPIPInterface::set_fifo_depth(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_activate(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_activate(Interface &socket) {
|
||||||
auto enable = socket.receive<int>();
|
auto enable = socket.Receive<int>();
|
||||||
if (myDetectorType != EIGER)
|
if (myDetectorType != EIGER)
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
|
|
||||||
@ -970,7 +970,7 @@ int slsReceiverTCPIPInterface::set_activate(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_data_stream_enable(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_data_stream_enable(Interface &socket) {
|
||||||
auto index = socket.receive<int>();
|
auto index = socket.Receive<int>();
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
FILE_LOG(logDEBUG1) << "Setting data stream enable:" << index;
|
FILE_LOG(logDEBUG1) << "Setting data stream enable:" << index;
|
||||||
@ -983,7 +983,7 @@ int slsReceiverTCPIPInterface::set_data_stream_enable(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_streaming_timer(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_streaming_timer(Interface &socket) {
|
||||||
auto index = socket.receive<int>();
|
auto index = socket.Receive<int>();
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
FILE_LOG(logDEBUG1) << "Setting streaming timer:" << index;
|
FILE_LOG(logDEBUG1) << "Setting streaming timer:" << index;
|
||||||
@ -999,7 +999,7 @@ int slsReceiverTCPIPInterface::set_flipped_data(Interface &socket) {
|
|||||||
// TODO! Why 2 args?
|
// TODO! Why 2 args?
|
||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
int args[2]{0, -1};
|
int args[2]{0, -1};
|
||||||
socket.receiveArg(args);
|
socket.Receive(args);
|
||||||
|
|
||||||
if (myDetectorType != EIGER)
|
if (myDetectorType != EIGER)
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
@ -1017,7 +1017,7 @@ int slsReceiverTCPIPInterface::set_flipped_data(Interface &socket) {
|
|||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_file_format(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_file_format(Interface &socket) {
|
||||||
fileFormat f = GET_FILE_FORMAT;
|
fileFormat f = GET_FILE_FORMAT;
|
||||||
socket.receiveArg(f);
|
socket.Receive(f);
|
||||||
if (f >= 0) {
|
if (f >= 0) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
FILE_LOG(logDEBUG1) << "Setting file format:" << f;
|
FILE_LOG(logDEBUG1) << "Setting file format:" << f;
|
||||||
@ -1030,7 +1030,7 @@ int slsReceiverTCPIPInterface::set_file_format(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_detector_posid(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_detector_posid(Interface &socket) {
|
||||||
auto arg = socket.receive<int>();
|
auto arg = socket.Receive<int>();
|
||||||
if (arg >= 0) {
|
if (arg >= 0) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
FILE_LOG(logDEBUG1) << "Setting detector position id:" << arg;
|
FILE_LOG(logDEBUG1) << "Setting detector position id:" << arg;
|
||||||
@ -1044,7 +1044,7 @@ int slsReceiverTCPIPInterface::set_detector_posid(Interface &socket) {
|
|||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_multi_detector_size(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_multi_detector_size(Interface &socket) {
|
||||||
int arg[]{-1, -1};
|
int arg[]{-1, -1};
|
||||||
socket.receiveArg(arg);
|
socket.Receive(arg);
|
||||||
if ((arg[0] > 0) && (arg[1] > 0)) {
|
if ((arg[0] > 0) && (arg[1] > 0)) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
FILE_LOG(logDEBUG1)
|
FILE_LOG(logDEBUG1)
|
||||||
@ -1058,7 +1058,7 @@ int slsReceiverTCPIPInterface::set_multi_detector_size(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_streaming_port(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_streaming_port(Interface &socket) {
|
||||||
auto port = socket.receive<int>();
|
auto port = socket.Receive<int>();
|
||||||
if (port >= 0) {
|
if (port >= 0) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
FILE_LOG(logDEBUG1) << "Setting streaming port:" << port;
|
FILE_LOG(logDEBUG1) << "Setting streaming port:" << port;
|
||||||
@ -1073,7 +1073,7 @@ int slsReceiverTCPIPInterface::set_streaming_port(Interface &socket) {
|
|||||||
int slsReceiverTCPIPInterface::set_streaming_source_ip(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_streaming_source_ip(Interface &socket) {
|
||||||
char arg[MAX_STR_LENGTH]{};
|
char arg[MAX_STR_LENGTH]{};
|
||||||
char retval[MAX_STR_LENGTH]{};
|
char retval[MAX_STR_LENGTH]{};
|
||||||
socket.receiveArg(arg);
|
socket.Receive(arg);
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
FILE_LOG(logDEBUG1) << "Setting streaming source ip:" << arg;
|
FILE_LOG(logDEBUG1) << "Setting streaming source ip:" << arg;
|
||||||
impl()->setStreamingSourceIP(arg);
|
impl()->setStreamingSourceIP(arg);
|
||||||
@ -1083,7 +1083,7 @@ int slsReceiverTCPIPInterface::set_streaming_source_ip(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_silent_mode(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_silent_mode(Interface &socket) {
|
||||||
auto value = socket.receive<int>();
|
auto value = socket.Receive<int>();
|
||||||
if (value >= 0) {
|
if (value >= 0) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
FILE_LOG(logDEBUG1) << "Setting silent mode:" << value;
|
FILE_LOG(logDEBUG1) << "Setting silent mode:" << value;
|
||||||
@ -1096,7 +1096,7 @@ int slsReceiverTCPIPInterface::set_silent_mode(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::enable_gap_pixels(Interface &socket) {
|
int slsReceiverTCPIPInterface::enable_gap_pixels(Interface &socket) {
|
||||||
auto enable = socket.receive<int>();
|
auto enable = socket.Receive<int>();
|
||||||
if (myDetectorType != EIGER)
|
if (myDetectorType != EIGER)
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
|
|
||||||
@ -1122,14 +1122,14 @@ int slsReceiverTCPIPInterface::restream_stop(Interface &socket) {
|
|||||||
if (ret == FAIL)
|
if (ret == FAIL)
|
||||||
throw RuntimeError("Could not restream stop packet");
|
throw RuntimeError("Could not restream stop packet");
|
||||||
}
|
}
|
||||||
return socket.sendData(OK);
|
return socket.Send(OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_additional_json_header(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_additional_json_header(Interface &socket) {
|
||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
char arg[MAX_STR_LENGTH]{};
|
char arg[MAX_STR_LENGTH]{};
|
||||||
char retval[MAX_STR_LENGTH]{};
|
char retval[MAX_STR_LENGTH]{};
|
||||||
socket.receiveArg(arg);
|
socket.Receive(arg);
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
FILE_LOG(logDEBUG1) << "Setting additional json header: " << arg;
|
FILE_LOG(logDEBUG1) << "Setting additional json header: " << arg;
|
||||||
impl()->setAdditionalJsonHeader(arg);
|
impl()->setAdditionalJsonHeader(arg);
|
||||||
@ -1146,7 +1146,7 @@ int slsReceiverTCPIPInterface::get_additional_json_header(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_udp_socket_buffer_size(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_udp_socket_buffer_size(Interface &socket) {
|
||||||
auto index = socket.receive<int64_t>();
|
auto index = socket.Receive<int64_t>();
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
FILE_LOG(logDEBUG1) << "Setting UDP Socket Buffer size: " << index;
|
FILE_LOG(logDEBUG1) << "Setting UDP Socket Buffer size: " << index;
|
||||||
@ -1174,7 +1174,7 @@ int slsReceiverTCPIPInterface::get_real_udp_socket_buffer_size(
|
|||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_frames_per_file(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_frames_per_file(Interface &socket) {
|
||||||
auto index = socket.receive<int>();
|
auto index = socket.Receive<int>();
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
FILE_LOG(logDEBUG1) << "Setting frames per file: " << index;
|
FILE_LOG(logDEBUG1) << "Setting frames per file: " << index;
|
||||||
@ -1187,7 +1187,7 @@ int slsReceiverTCPIPInterface::set_frames_per_file(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::check_version_compatibility(Interface &socket) {
|
int slsReceiverTCPIPInterface::check_version_compatibility(Interface &socket) {
|
||||||
auto arg = socket.receive<int64_t>();
|
auto arg = socket.Receive<int64_t>();
|
||||||
FILE_LOG(logDEBUG1) << "Checking versioning compatibility with value "
|
FILE_LOG(logDEBUG1) << "Checking versioning compatibility with value "
|
||||||
<< arg;
|
<< arg;
|
||||||
int64_t client_requiredVersion = arg;
|
int64_t client_requiredVersion = arg;
|
||||||
@ -1219,11 +1219,11 @@ int slsReceiverTCPIPInterface::check_version_compatibility(Interface &socket) {
|
|||||||
} else {
|
} else {
|
||||||
FILE_LOG(logINFO) << "Compatibility with Client: Successful";
|
FILE_LOG(logINFO) << "Compatibility with Client: Successful";
|
||||||
}
|
}
|
||||||
return socket.sendData(OK);
|
return socket.Send(OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_discard_policy(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_discard_policy(Interface &socket) {
|
||||||
auto index = socket.receive<int>();
|
auto index = socket.Receive<int>();
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
FILE_LOG(logDEBUG1) << "Setting frames discard policy: " << index;
|
FILE_LOG(logDEBUG1) << "Setting frames discard policy: " << index;
|
||||||
@ -1236,7 +1236,7 @@ int slsReceiverTCPIPInterface::set_discard_policy(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_padding_enable(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_padding_enable(Interface &socket) {
|
||||||
auto index = socket.receive<int>();
|
auto index = socket.Receive<int>();
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
index = (index == 0) ? 0 : 1;
|
index = (index == 0) ? 0 : 1;
|
||||||
@ -1251,7 +1251,7 @@ int slsReceiverTCPIPInterface::set_padding_enable(Interface &socket) {
|
|||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_deactivated_padding_enable(
|
int slsReceiverTCPIPInterface::set_deactivated_padding_enable(
|
||||||
Interface &socket) {
|
Interface &socket) {
|
||||||
auto enable = socket.receive<int>();
|
auto enable = socket.Receive<int>();
|
||||||
if (myDetectorType != EIGER)
|
if (myDetectorType != EIGER)
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
|
|
||||||
@ -1268,7 +1268,7 @@ int slsReceiverTCPIPInterface::set_deactivated_padding_enable(
|
|||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_readout_flags(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_readout_flags(Interface &socket) {
|
||||||
auto arg = socket.receive<readOutFlags>();
|
auto arg = socket.Receive<readOutFlags>();
|
||||||
|
|
||||||
if (myDetectorType == JUNGFRAU || myDetectorType == GOTTHARD ||
|
if (myDetectorType == JUNGFRAU || myDetectorType == GOTTHARD ||
|
||||||
myDetectorType == MOENCH)
|
myDetectorType == MOENCH)
|
||||||
@ -1287,7 +1287,7 @@ int slsReceiverTCPIPInterface::set_readout_flags(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_adc_mask(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_adc_mask(Interface &socket) {
|
||||||
auto arg = socket.receive<uint32_t>();
|
auto arg = socket.Receive<uint32_t>();
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
FILE_LOG(logDEBUG1) << "Setting ADC enable mask: " << arg;
|
FILE_LOG(logDEBUG1) << "Setting ADC enable mask: " << arg;
|
||||||
impl()->setADCEnableMask(arg);
|
impl()->setADCEnableMask(arg);
|
||||||
@ -1303,7 +1303,7 @@ int slsReceiverTCPIPInterface::set_adc_mask(Interface &socket) {
|
|||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_dbit_list(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_dbit_list(Interface &socket) {
|
||||||
sls::FixedCapacityContainer<int, MAX_RX_DBIT> args;
|
sls::FixedCapacityContainer<int, MAX_RX_DBIT> args;
|
||||||
socket.receiveArg(args);
|
socket.Receive(args);
|
||||||
FILE_LOG(logDEBUG1) << "Setting DBIT list";
|
FILE_LOG(logDEBUG1) << "Setting DBIT list";
|
||||||
for (auto &it : args) {
|
for (auto &it : args) {
|
||||||
FILE_LOG(logDEBUG1) << it << " ";
|
FILE_LOG(logDEBUG1) << it << " ";
|
||||||
@ -1311,7 +1311,7 @@ int slsReceiverTCPIPInterface::set_dbit_list(Interface &socket) {
|
|||||||
FILE_LOG(logDEBUG1) << "\n";
|
FILE_LOG(logDEBUG1) << "\n";
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
impl()->setDbitList(args);
|
impl()->setDbitList(args);
|
||||||
return socket.sendData(OK);
|
return socket.Send(OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::get_dbit_list(Interface &socket) {
|
int slsReceiverTCPIPInterface::get_dbit_list(Interface &socket) {
|
||||||
@ -1322,7 +1322,7 @@ int slsReceiverTCPIPInterface::get_dbit_list(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::set_dbit_offset(Interface &socket) {
|
int slsReceiverTCPIPInterface::set_dbit_offset(Interface &socket) {
|
||||||
auto arg = socket.receive<int>();
|
auto arg = socket.Receive<int>();
|
||||||
if (arg >= 0) {
|
if (arg >= 0) {
|
||||||
VerifyIdle(socket);
|
VerifyIdle(socket);
|
||||||
FILE_LOG(logDEBUG1) << "Setting Dbit offset: " << arg;
|
FILE_LOG(logDEBUG1) << "Setting Dbit offset: " << arg;
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <numeric>
|
||||||
namespace sls {
|
namespace sls {
|
||||||
|
|
||||||
class DataSocket {
|
class DataSocket {
|
||||||
@ -16,13 +17,30 @@ class DataSocket {
|
|||||||
DataSocket(const DataSocket &) = delete;
|
DataSocket(const DataSocket &) = delete;
|
||||||
DataSocket &operator=(DataSocket const &) = delete;
|
DataSocket &operator=(DataSocket const &) = delete;
|
||||||
int getSocketId() const { return socketId_; }
|
int getSocketId() const { return socketId_; }
|
||||||
int sendData(const void *buffer, size_t size);
|
|
||||||
|
|
||||||
template <typename T> int sendData(T &&data) {
|
int Send(const void *buffer, size_t size);
|
||||||
return sendData(&data, sizeof(data));
|
template <typename T> int Send(T &&data) {
|
||||||
|
return Send(&data, sizeof(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Trick to send all
|
||||||
|
template <class... Args> int SendAll(Args &&... args) {
|
||||||
|
auto l = std::initializer_list<int>{Send(args)...};
|
||||||
|
auto sum = std::accumulate(begin(l), end(l), 0);
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Receive(void *buffer, size_t size);
|
||||||
|
|
||||||
|
template <typename T> int Receive(T &arg) {
|
||||||
|
return Receive(&arg, sizeof(arg));
|
||||||
|
}
|
||||||
|
template <typename T> T Receive() {
|
||||||
|
T arg;
|
||||||
|
Receive(&arg, sizeof(arg));
|
||||||
|
return arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
int receiveData(void *buffer, size_t size);
|
|
||||||
int read(void *buffer, size_t size);
|
int read(void *buffer, size_t size);
|
||||||
int write(void *buffer, size_t size);
|
int write(void *buffer, size_t size);
|
||||||
int setTimeOut(int t_seconds);
|
int setTimeOut(int t_seconds);
|
||||||
|
@ -22,23 +22,10 @@ class ServerInterface2 : public DataSocket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> int sendResult(T &&retval) {
|
template <typename T> int sendResult(T &&retval) {
|
||||||
sendData(defs::OK);
|
Send(defs::OK);
|
||||||
sendData(retval);
|
Send(retval);
|
||||||
return defs::OK;
|
return defs::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int receiveArg(void *arg, int sizeofArg);
|
|
||||||
|
|
||||||
template <typename T> int receiveArg(T &arg) {
|
|
||||||
return receiveArg(&arg, sizeof(arg));
|
|
||||||
}
|
|
||||||
template <typename T> T receive() {
|
|
||||||
T arg;
|
|
||||||
receiveArg(&arg, sizeof(arg));
|
|
||||||
return arg;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
@ -62,19 +62,19 @@ int ClientSocket::sendCommandThenRead(int fnum, const void *args,
|
|||||||
size_t args_size, void *retval,
|
size_t args_size, void *retval,
|
||||||
size_t retval_size) {
|
size_t retval_size) {
|
||||||
int ret = slsDetectorDefs::FAIL;
|
int ret = slsDetectorDefs::FAIL;
|
||||||
sendData(&fnum, sizeof(fnum));
|
Send(&fnum, sizeof(fnum));
|
||||||
sendData(args, args_size);
|
Send(args, args_size);
|
||||||
readReply(ret, retval, retval_size);
|
readReply(ret, retval, retval_size);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientSocket::readReply(int &ret, void *retval, size_t retval_size) {
|
void ClientSocket::readReply(int &ret, void *retval, size_t retval_size) {
|
||||||
|
|
||||||
read(&ret, sizeof(ret));
|
Receive(&ret, sizeof(ret));
|
||||||
if (ret == slsDetectorDefs::FAIL) {
|
if (ret == slsDetectorDefs::FAIL) {
|
||||||
char mess[MAX_STR_LENGTH]{};
|
char mess[MAX_STR_LENGTH]{};
|
||||||
// get error message
|
// get error message
|
||||||
read(mess, sizeof(mess));
|
Receive(mess, sizeof(mess));
|
||||||
// Do we need to know hostname here?
|
// Do we need to know hostname here?
|
||||||
// In that case save it???
|
// In that case save it???
|
||||||
if (socketType == "Receiver") {
|
if (socketType == "Receiver") {
|
||||||
@ -86,7 +86,7 @@ void ClientSocket::readReply(int &ret, void *retval, size_t retval_size) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// get retval
|
// get retval
|
||||||
read(retval, retval_size);
|
Receive(retval, retval_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // namespace sls
|
}; // namespace sls
|
||||||
|
@ -42,9 +42,8 @@ DataSocket &DataSocket::operator=(DataSocket &&move) noexcept {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DataSocket::receiveData(void *buffer, size_t size) {
|
int DataSocket::Receive(void *buffer, size_t size) {
|
||||||
// TODO!(Erik) Add sleep? how many reties?
|
// TODO!(Erik) Add sleep? how many reties?
|
||||||
assert(size > 0);
|
|
||||||
int bytes_expected = static_cast<int>(size); // signed size
|
int bytes_expected = static_cast<int>(size); // signed size
|
||||||
int bytes_read = 0;
|
int bytes_read = 0;
|
||||||
while (bytes_read < bytes_expected) {
|
while (bytes_read < bytes_expected) {
|
||||||
@ -65,7 +64,7 @@ int DataSocket::receiveData(void *buffer, size_t size) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int DataSocket::sendData(const void *buffer, size_t size) {
|
int DataSocket::Send(const void *buffer, size_t size) {
|
||||||
int bytes_sent = 0;
|
int bytes_sent = 0;
|
||||||
int data_size = static_cast<int>(size); // signed size
|
int data_size = static_cast<int>(size); // signed size
|
||||||
while (bytes_sent < (data_size)) {
|
while (bytes_sent < (data_size)) {
|
||||||
|
@ -21,18 +21,4 @@ int ServerInterface2::sendResult(int ret, void *retval, int retvalSize,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ServerInterface2::receiveArg(void *arg, int sizeofArg) {
|
|
||||||
assert(sizeofArg > 0);
|
|
||||||
int bytes_read = receiveData(arg, sizeofArg);
|
|
||||||
if (bytes_read == sizeofArg) {
|
|
||||||
return defs::OK;
|
|
||||||
} else {
|
|
||||||
std::ostringstream ss;
|
|
||||||
ss << "TCP socket error read " << bytes_read << " bytes instead of "
|
|
||||||
<< sizeofArg << " bytes";
|
|
||||||
|
|
||||||
throw sls::SocketError(ss.str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
@ -10,14 +10,14 @@ std::vector<char> server() {
|
|||||||
auto server = sls::ServerSocket(1950);
|
auto server = sls::ServerSocket(1950);
|
||||||
auto s = server.accept();
|
auto s = server.accept();
|
||||||
std::vector<char> buffer(100, '\0');
|
std::vector<char> buffer(100, '\0');
|
||||||
s.receiveData(buffer.data(), buffer.size());
|
s.Receive(buffer.data(), buffer.size());
|
||||||
std::cout << "ServerReceived: " << std::string(buffer.begin(), buffer.end())
|
std::cout << "ServerReceived: " << std::string(buffer.begin(), buffer.end())
|
||||||
<< '\n';
|
<< '\n';
|
||||||
|
|
||||||
std::vector<char> to_send(100, '\0');
|
std::vector<char> to_send(100, '\0');
|
||||||
to_send[0] = 'O';
|
to_send[0] = 'O';
|
||||||
to_send[1] = 'K';
|
to_send[1] = 'K';
|
||||||
s.sendData(to_send.data(), to_send.size());
|
s.Send(to_send.data(), to_send.size());
|
||||||
s.close();
|
s.close();
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
@ -31,8 +31,8 @@ TEST_CASE("The server recive the same message as we send", "[support]") {
|
|||||||
auto s = std::async(std::launch::async, server);
|
auto s = std::async(std::launch::async, server);
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
auto client = sls::DetectorSocket("localhost", 1950);
|
auto client = sls::DetectorSocket("localhost", 1950);
|
||||||
client.sendData(sent_message.data(), sent_message.size());
|
client.Send(sent_message.data(), sent_message.size());
|
||||||
client.receiveData(received_message.data(), received_message.size());
|
client.Receive(received_message.data(), received_message.size());
|
||||||
client.close();
|
client.close();
|
||||||
auto server_message = s.get();
|
auto server_message = s.get();
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
enum class func_id{read_data, read_int, read_half_data};
|
enum class func_id{read_data, read_int, read_half_data, combined};
|
||||||
constexpr size_t MB = 1048576;
|
constexpr size_t MB = 1048576;
|
||||||
constexpr size_t DATA_SIZE = 50*MB;
|
constexpr size_t DATA_SIZE = 50*MB;
|
@ -1,6 +1,6 @@
|
|||||||
#include "ClientSocket.h"
|
#include "ClientSocket.h"
|
||||||
#include "sls_detector_exceptions.h"
|
|
||||||
#include "clara.hpp"
|
#include "clara.hpp"
|
||||||
|
#include "sls_detector_exceptions.h"
|
||||||
#include "tests/testenum.h"
|
#include "tests/testenum.h"
|
||||||
|
|
||||||
#include "container_utils.h"
|
#include "container_utils.h"
|
||||||
@ -36,45 +36,50 @@ int main(int argc, char **argv) {
|
|||||||
for (int i = 0; i != 100; ++i) {
|
for (int i = 0; i != 100; ++i) {
|
||||||
std::cout << "Sending: " << i << "\n";
|
std::cout << "Sending: " << i << "\n";
|
||||||
auto socket = sls::ClientSocket("test", hostname, port);
|
auto socket = sls::ClientSocket("test", hostname, port);
|
||||||
std::cout << "Sent: " << socket.sendData(func_id::read_int)
|
std::cout << "Sent: " << socket.Send(func_id::read_int) << " bytes\n";
|
||||||
<< " bytes\n";
|
std::cout << "Sent: " << socket.Send(i) << " bytes\n";
|
||||||
std::cout << "Sent: " << socket.sendData(i) << " bytes\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sending larger blocks
|
// Sending larger blocks
|
||||||
for (int i = 0; i != 5; ++i) {
|
for (int i = 0; i != 5; ++i) {
|
||||||
std::cout << "Sending data\n";
|
std::cout << "Sending data\n";
|
||||||
auto socket = sls::ClientSocket("test", hostname, port);
|
auto socket = sls::ClientSocket("test", hostname, port);
|
||||||
std::cout << "Sent: " << socket.sendData(func_id::read_data)
|
std::cout << "Sent: " << socket.Send(func_id::read_data) << " bytes\n";
|
||||||
<< " bytes\n";
|
std::cout << "Sent: " << socket.Send(data.get(), DATA_SIZE)
|
||||||
std::cout << "Sent: " << socket.sendData(data.get(), DATA_SIZE)
|
|
||||||
<< " bytes\n";
|
<< " bytes\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send too little data
|
// Send too little data
|
||||||
{
|
{
|
||||||
auto socket = sls::ClientSocket("test", hostname, port);
|
auto socket = sls::ClientSocket("test", hostname, port);
|
||||||
std::cout << "Sent: " << socket.sendData(func_id::read_data)
|
std::cout << "Sent: " << socket.Send(func_id::read_data) << " bytes\n";
|
||||||
<< " bytes\n";
|
std::cout << "Sent: " << socket.Send(data.get(), DATA_SIZE / 2)
|
||||||
std::cout << "Sent: " << socket.sendData(data.get(), DATA_SIZE / 2)
|
|
||||||
<< " bytes\n";
|
<< " bytes\n";
|
||||||
}
|
}
|
||||||
// Send too much data
|
// Send too much data
|
||||||
try{
|
try {
|
||||||
auto socket = sls::ClientSocket("test", hostname, port);
|
auto socket = sls::ClientSocket("test", hostname, port);
|
||||||
std::cout << "Sent: " << socket.sendData(func_id::read_half_data)
|
std::cout << "Sent: " << socket.Send(func_id::read_half_data)
|
||||||
<< " bytes\n";
|
<< " bytes\n";
|
||||||
std::cout << "Sent: " << socket.sendData(data.get(), DATA_SIZE)
|
std::cout << "Sent: " << socket.Send(data.get(), DATA_SIZE)
|
||||||
<< " bytes\n";
|
<< " bytes\n";
|
||||||
}catch(const sls::SocketError& e){
|
} catch (const sls::SocketError &e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
// Some ints again
|
// Some ints again
|
||||||
for (int i = 0; i != 10; ++i) {
|
for (int i = 0; i != 10; ++i) {
|
||||||
std::cout << "Sending: " << i << "\n";
|
std::cout << "Sending: " << i << "\n";
|
||||||
auto socket = sls::ClientSocket("test", hostname, port);
|
auto socket = sls::ClientSocket("test", hostname, port);
|
||||||
std::cout << "Sent: " << socket.sendData(func_id::read_int)
|
std::cout << "Sent: " << socket.Send(func_id::read_int) << " bytes\n";
|
||||||
<< " bytes\n";
|
std::cout << "Sent: " << socket.Send(i) << " bytes\n";
|
||||||
std::cout << "Sent: " << socket.sendData(i) << " bytes\n";
|
}
|
||||||
|
|
||||||
|
// some combined sends
|
||||||
|
{
|
||||||
|
int a = 9;
|
||||||
|
double b = 18.3;
|
||||||
|
float c = -1.2;
|
||||||
|
auto socket = sls::ClientSocket("test", hostname, port);
|
||||||
|
int s = socket.SendAll(func_id::combined, a, b, c);
|
||||||
|
std::cout << "send all: " << s << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,26 +24,34 @@ using func_ptr = void (*)(Interface &);
|
|||||||
|
|
||||||
void read_data(Interface &socket) {
|
void read_data(Interface &socket) {
|
||||||
auto data = sls::make_unique<char[]>(DATA_SIZE);
|
auto data = sls::make_unique<char[]>(DATA_SIZE);
|
||||||
std::cout << "Read: " << socket.receiveData(data.get(), DATA_SIZE)
|
std::cout << "Read: " << socket.Receive(data.get(), DATA_SIZE)
|
||||||
<< " bytes into buffer\n";
|
<< " bytes into buffer\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_half_data(Interface &socket) {
|
void read_half_data(Interface &socket) {
|
||||||
auto data = sls::make_unique<char[]>(DATA_SIZE);
|
auto data = sls::make_unique<char[]>(DATA_SIZE);
|
||||||
std::cout << "Read: " << socket.receiveData(data.get(), DATA_SIZE / 2)
|
std::cout << "Read: " << socket.Receive(data.get(), DATA_SIZE / 2)
|
||||||
<< " bytes into buffer\n";
|
<< " bytes into buffer\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_int(Interface &socket) {
|
void read_int(Interface &socket) {
|
||||||
auto i = socket.receive<int>();
|
auto i = socket.Receive<int>();
|
||||||
std::cout << "Read <int>: " << i << "\n";
|
std::cout << "Read <int>: " << i << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void read_combined(Interface &socket){
|
||||||
|
auto i = socket.Receive<int>();
|
||||||
|
auto d = socket.Receive<double>();
|
||||||
|
auto f = socket.Receive<float>();
|
||||||
|
std::cout << "read i: " << i << " d: " << d << " f: " << f << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
// Map from int to function pointer, in this case probably a map would be faster
|
// Map from int to function pointer, in this case probably a map would be faster
|
||||||
std::unordered_map<func_id, func_ptr, EnumClassHash> fmap{
|
std::unordered_map<func_id, func_ptr, EnumClassHash> fmap{
|
||||||
{func_id::read_data, &read_data},
|
{func_id::read_data, &read_data},
|
||||||
{func_id::read_int, &read_int},
|
{func_id::read_int, &read_int},
|
||||||
{func_id::read_half_data, &read_half_data}};
|
{func_id::read_half_data, &read_half_data},
|
||||||
|
{func_id::combined, &read_combined}};
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
std::cout << "Starting test server...\n";
|
std::cout << "Starting test server...\n";
|
||||||
@ -63,7 +71,7 @@ int main(int argc, char **argv) {
|
|||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
auto socket = server.accept();
|
auto socket = server.accept();
|
||||||
auto fnum = socket.receive<func_id>();
|
auto fnum = socket.Receive<func_id>();
|
||||||
std::cout << "Calling func: " << (int)fnum << "\n";
|
std::cout << "Calling func: " << (int)fnum << "\n";
|
||||||
(*fmap[fnum])(socket); // call mapped function
|
(*fmap[fnum])(socket); // call mapped function
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user