Minimal shared memory for receiver

This commit is contained in:
Dhanya Thattil 2020-03-19 02:01:32 -04:00 committed by GitHub
parent 8ab742c2b7
commit 4813b5567a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 1045 additions and 1117 deletions

View File

@ -1646,10 +1646,13 @@ void ctbAcquisition::update() {
} }
try { if (myDet->getDetectorType().squash() == slsDetectorDefs::MOENCH) {
dBitOffset = myDet->getRxDbitOffset().tsquash("Different values"); dBitOffset = 0;
} CATCH_DISPLAY ("Could not get receiver dbit offset", "ctbAcquisition::update") } else {
try {
dBitOffset = myDet->getRxDbitOffset().tsquash("Different values");
} CATCH_DISPLAY ("Could not get receiver dbit offset", "ctbAcquisition::update")
}
try { try {
tenG = myDet->getTenGiga().tsquash("Different values"); tenG = myDet->getTenGiga().tsquash("Different values");
} CATCH_DISPLAY ("Could not get ten giga enable", "ctbAcquisition::update") } CATCH_DISPLAY ("Could not get ten giga enable", "ctbAcquisition::update")
@ -1735,9 +1738,13 @@ void ctbAcquisition::toggleAcquisition() {
setDigitalSamples(retval); setDigitalSamples(retval);
} CATCH_DISPLAY ("Could not get number of digital samples", "ctbAcquisition::toggleAcquisition") } CATCH_DISPLAY ("Could not get number of digital samples", "ctbAcquisition::toggleAcquisition")
if (myDet->getDetectorType().squash() == slsDetectorDefs::MOENCH) {
dBitOffset = 0;
} else {
try { try {
dBitOffset = myDet->getRxDbitOffset().tsquash("Different values"); dBitOffset = myDet->getRxDbitOffset().tsquash("Different values");
} CATCH_DISPLAY ("Could not get receiver dbit offset", "ctbAcquisition::toggleAcquisition") } CATCH_DISPLAY ("Could not get receiver dbit offset", "ctbAcquisition::toggleAcquisition")
}
try { try {
roMode = static_cast<int>(myDet->getReadoutMode().tsquash("Different values")); roMode = static_cast<int>(myDet->getReadoutMode().tsquash("Different values"));
@ -1974,14 +1981,18 @@ void ctbAcquisition::setDbitEnable(Int_t reg){
void ctbAcquisition::updateChans() { void ctbAcquisition::updateChans() {
// dbit list // dbit list
try { if (myDet->getDetectorType().squash() == slsDetectorDefs::MOENCH) {
auto retval = myDet->getRxDbitList().tsquash("Different values");
dbitlist.clear(); dbitlist.clear();
if (!retval.empty()) { } else {
for (const auto &value : retval) try {
dbitlist.push_back(value); auto retval = myDet->getRxDbitList().tsquash("Different values");
} dbitlist.clear();
} CATCH_DISPLAY ("Could not get receiver dbit list.", "ctbAcquisition::updateChans") if (!retval.empty()) {
for (const auto &value : retval)
dbitlist.push_back(value);
}
} CATCH_DISPLAY ("Could not get receiver dbit list.", "ctbAcquisition::updateChans")
}
// adc mask // adc mask
try { try {

View File

@ -374,33 +374,43 @@ void ctbSignals::update() {
} CATCH_DISPLAY ("Could not get patternIOcontrol.", "ctbSignals::update") } CATCH_DISPLAY ("Could not get patternIOcontrol.", "ctbSignals::update")
try { if (myDet->getDetectorType().squash() == slsDetectorDefs::MOENCH) {
auto dbitlist = myDet->getRxDbitList().tsquash("Different values");
// enable all // enable all
if (dbitlist.empty()) { for (int is=0; is<64; is++) {
for (int is=0; is<64; is++) { signals[is]->setDbitList(1);
signals[is]->setDbitList(1); }
} eDbitOffset->SetNumber(0);
} }
else {
// disable all // ctb
for (int is=0; is<64; is++) { else {
signals[is]->setDbitList(0); try {
auto dbitlist = myDet->getRxDbitList().tsquash("Different values");
// enable all
if (dbitlist.empty()) {
for (int is=0; is<64; is++) {
signals[is]->setDbitList(1);
}
} }
// enable selected else {
for (const auto &value : dbitlist) { // disable all
signals[value]->setDbitList(1); for (int is=0; is<64; is++) {
signals[is]->setDbitList(0);
}
// enable selected
for (const auto &value : dbitlist) {
signals[value]->setDbitList(1);
}
} }
}
} CATCH_DISPLAY ("Could not get receiver dbit list.", "ctbSignals::update") } CATCH_DISPLAY ("Could not get receiver dbit list.", "ctbSignals::update")
try {
auto val = myDet->getRxDbitOffset().tsquash("Different values");
eDbitOffset->SetNumber(val);
} CATCH_DISPLAY ("Could not get receiver dbit offset.", "ctbSignals::update")
try {
auto val = myDet->getRxDbitOffset().tsquash("Different values");
eDbitOffset->SetNumber(val);
} CATCH_DISPLAY ("Could not get receiver dbit offset.", "ctbSignals::update")
}
} }

View File

@ -1,5 +1,6 @@
from _slsdet import CppDetectorApi from _slsdet import CppDetectorApi
from _slsdet import slsDetectorDefs from _slsdet import slsDetectorDefs
from _slsdet import IpAddr, MacAddr
runStatus = slsDetectorDefs.runStatus runStatus = slsDetectorDefs.runStatus
speedLevel = slsDetectorDefs.speedLevel speedLevel = slsDetectorDefs.speedLevel
@ -12,12 +13,13 @@ import datetime as dt
from functools import wraps from functools import wraps
from collections import namedtuple from collections import namedtuple
import socket
def freeze(cls): def freeze(cls):
cls._frozen = False cls._frozen = False
def frozensetattr(self, key, value): def frozensetattr(self, key, value):
if self._frozen and not hasattr(self, key): if self._frozen and not key in dir(self):
raise AttributeError( raise AttributeError(
"Class {} is frozen. Cannot set {} = {}".format( "Class {} is frozen. Cannot set {} = {}".format(
cls.__name__, key, value cls.__name__, key, value
@ -58,7 +60,6 @@ class Detector(CppDetectorApi):
self._adc_register = Adc_register(self) self._adc_register = Adc_register(self)
# CONFIGURATION # CONFIGURATION
def __len__(self): def __len__(self):
return self.size() return self.size()
@ -71,9 +72,6 @@ class Detector(CppDetectorApi):
def free(self): def free(self):
self.freeSharedMemory() self.freeSharedMemory()
@property @property
def config(self): def config(self):
return NotImplementedError("config is set only") return NotImplementedError("config is set only")
@ -92,6 +90,7 @@ class Detector(CppDetectorApi):
@property @property
def hostname(self): def hostname(self):
print('getting host!')
return self.getHostname() return self.getHostname()
@hostname.setter @hostname.setter
@ -422,7 +421,9 @@ class Detector(CppDetectorApi):
@udp_dstip.setter @udp_dstip.setter
def udp_dstip(self, ip): def udp_dstip(self, ip):
self.getDestinationUDPIP(ip) if ip == 'auto':
ip = socket.gethostbyname(self.rx_hostname)
self.setDestinationUDPIP(IpAddr(ip))
@property @property
def udp_dstip2(self): def udp_dstip2(self):
@ -430,7 +431,9 @@ class Detector(CppDetectorApi):
@udp_dstip2.setter @udp_dstip2.setter
def udp_dstip2(self, ip): def udp_dstip2(self, ip):
self.getDestinationUDPIP2(ip) if ip == 'auto':
ip = socket.gethostbyname(self.rx_hostname)
self.setDestinationUDPIP2(IpAddr(ip))
@property @property
def udp_dstmac(self): def udp_dstmac(self):
@ -438,7 +441,7 @@ class Detector(CppDetectorApi):
@udp_dstmac.setter @udp_dstmac.setter
def udp_dstmac(self, mac): def udp_dstmac(self, mac):
self.getDestinationUDPMAC2(mac) self.setDestinationUDPMAC(MacAddr(mac))
@property @property
def udp_dstmac2(self): def udp_dstmac2(self):
@ -446,7 +449,7 @@ class Detector(CppDetectorApi):
@udp_dstmac2.setter @udp_dstmac2.setter
def udp_dstmac2(self, mac): def udp_dstmac2(self, mac):
self.getDestinationUDPMAC2(mac) self.setDestinationUDPMAC2(MacAddr(mac))
@property @property
@ -455,7 +458,7 @@ class Detector(CppDetectorApi):
@udp_srcip.setter @udp_srcip.setter
def udp_srcip(self, ip): def udp_srcip(self, ip):
self.setSourceUDPIP(ip) self.setSourceUDPIP(IpAddr(ip))
@property @property
def udp_srcip2(self): def udp_srcip2(self):
@ -487,7 +490,7 @@ class Detector(CppDetectorApi):
@src_udpmac.setter @src_udpmac.setter
def src_udpmac(self, mac): def src_udpmac(self, mac):
self.setSourceUDPMAC(mac) self.setSourceUDPMAC(MacAddr(mac))
@property @property
def src_udpip2(self): def src_udpip2(self):
@ -495,7 +498,7 @@ class Detector(CppDetectorApi):
@src_udpip2.setter @src_udpip2.setter
def src_udpip2(self, ip): def src_udpip2(self, ip):
self.setSourceUDPIP(ip) self.setSourceUDPIP(IpAddr(ip))
@property @property
def src_udpip(self): def src_udpip(self):
@ -503,7 +506,7 @@ class Detector(CppDetectorApi):
@src_udpip.setter @src_udpip.setter
def src_udpip(self, ip): def src_udpip(self, ip):
self.setSourceUDPIP(ip) self.setSourceUDPIP(IpAddr(ip))
@property @property
@ -512,7 +515,7 @@ class Detector(CppDetectorApi):
@src_udpmac2.setter @src_udpmac2.setter
def src_udpmac2(self, mac): def src_udpmac2(self, mac):
self.setSourceUDPMAC2(mac) self.setSourceUDPMAC2(MacAddr(mac))
@property @property
def vhighvoltage(self): def vhighvoltage(self):

View File

@ -92,6 +92,15 @@ void init_det(py::module &m) {
py::arg() = Positions{}) py::arg() = Positions{})
.def("setADCPhaseInDegrees", &Detector::setADCPhaseInDegrees, py::arg(), .def("setADCPhaseInDegrees", &Detector::setADCPhaseInDegrees, py::arg(),
py::arg() = Positions{}) py::arg() = Positions{})
.def("getDBITPhase", &Detector::getDBITPhase, py::arg() = Positions{})
.def("setDBITPhase", &Detector::setDBITPhase, py::arg(),
py::arg() = Positions{})
.def("getMaxDBITPhaseShift", &Detector::getMaxDBITPhaseShift,
py::arg() = Positions{})
.def("getDBITPhaseInDegrees", &Detector::getDBITPhaseInDegrees,
py::arg() = Positions{})
.def("setDBITPhaseInDegrees", &Detector::setDBITPhaseInDegrees,
py::arg(), py::arg() = Positions{})
.def("getClockFrequency", &Detector::getClockFrequency, py::arg(), .def("getClockFrequency", &Detector::getClockFrequency, py::arg(),
py::arg() = Positions{}) py::arg() = Positions{})
.def("setClockFrequency", &Detector::setClockFrequency, py::arg(), .def("setClockFrequency", &Detector::setClockFrequency, py::arg(),
@ -464,29 +473,9 @@ void init_det(py::module &m) {
py::arg() = Positions{}) py::arg() = Positions{})
.def("setNumberOfAnalogSamples", &Detector::setNumberOfAnalogSamples, .def("setNumberOfAnalogSamples", &Detector::setNumberOfAnalogSamples,
py::arg(), py::arg() = Positions{}) py::arg(), py::arg() = Positions{})
.def("getNumberOfDigitalSamples", &Detector::getNumberOfDigitalSamples,
py::arg() = Positions{})
.def("setNumberOfDigitalSamples", &Detector::setNumberOfDigitalSamples,
py::arg(), py::arg() = Positions{})
.def("getReadoutMode", &Detector::getReadoutMode,
py::arg() = Positions{})
.def("setReadoutMode", &Detector::setReadoutMode, py::arg(),
py::arg() = Positions{})
.def("getDBITPhase", &Detector::getDBITPhase, py::arg() = Positions{})
.def("setDBITPhase", &Detector::setDBITPhase, py::arg(),
py::arg() = Positions{})
.def("getMaxDBITPhaseShift", &Detector::getMaxDBITPhaseShift,
py::arg() = Positions{})
.def("getDBITPhaseInDegrees", &Detector::getDBITPhaseInDegrees,
py::arg() = Positions{})
.def("setDBITPhaseInDegrees", &Detector::setDBITPhaseInDegrees,
py::arg(), py::arg() = Positions{})
.def("getADCClock", &Detector::getADCClock, py::arg() = Positions{}) .def("getADCClock", &Detector::getADCClock, py::arg() = Positions{})
.def("setADCClock", &Detector::setADCClock, py::arg(), .def("setADCClock", &Detector::setADCClock, py::arg(),
py::arg() = Positions{}) py::arg() = Positions{})
.def("getDBITClock", &Detector::getDBITClock, py::arg() = Positions{})
.def("setDBITClock", &Detector::setDBITClock, py::arg(),
py::arg() = Positions{})
.def("getRUNClock", &Detector::getRUNClock, py::arg() = Positions{}) .def("getRUNClock", &Detector::getRUNClock, py::arg() = Positions{})
.def("setRUNClock", &Detector::setRUNClock, py::arg(), .def("setRUNClock", &Detector::setRUNClock, py::arg(),
py::arg() = Positions{}) py::arg() = Positions{})
@ -495,20 +484,10 @@ void init_det(py::module &m) {
py::arg() = Positions{}) py::arg() = Positions{})
.def("setADCPipeline", &Detector::setADCPipeline, py::arg(), .def("setADCPipeline", &Detector::setADCPipeline, py::arg(),
py::arg() = Positions{}) py::arg() = Positions{})
.def("getDBITPipeline", &Detector::getDBITPipeline,
py::arg() = Positions{})
.def("setDBITPipeline", &Detector::setDBITPipeline, py::arg(),
py::arg() = Positions{})
.def("getVoltage", &Detector::getVoltage, py::arg(), .def("getVoltage", &Detector::getVoltage, py::arg(),
py::arg() = Positions{}) py::arg() = Positions{})
.def("setVoltage", &Detector::setVoltage, py::arg(), py::arg(), .def("setVoltage", &Detector::setVoltage, py::arg(), py::arg(),
py::arg() = Positions{}) py::arg() = Positions{})
.def("getMeasuredVoltage", &Detector::getMeasuredVoltage, py::arg(),
py::arg() = Positions{})
.def("getMeasuredCurrent", &Detector::getMeasuredCurrent, py::arg(),
py::arg() = Positions{})
.def("getSlowADC", &Detector::getSlowADC, py::arg(),
py::arg() = Positions{})
.def("getADCEnableMask", &Detector::getADCEnableMask, .def("getADCEnableMask", &Detector::getADCEnableMask,
py::arg() = Positions{}) py::arg() = Positions{})
.def("setADCEnableMask", &Detector::setADCEnableMask, py::arg(), .def("setADCEnableMask", &Detector::setADCEnableMask, py::arg(),
@ -517,8 +496,26 @@ void init_det(py::module &m) {
py::arg() = Positions{}) py::arg() = Positions{})
.def("setTenGigaADCEnableMask", &Detector::setTenGigaADCEnableMask, .def("setTenGigaADCEnableMask", &Detector::setTenGigaADCEnableMask,
py::arg(), py::arg() = Positions{}) py::arg(), py::arg() = Positions{})
.def("getADCInvert", &Detector::getADCInvert, py::arg() = Positions{}) .def("getNumberOfDigitalSamples", &Detector::getNumberOfDigitalSamples,
.def("setADCInvert", &Detector::setADCInvert, py::arg(), py::arg() = Positions{})
.def("setNumberOfDigitalSamples", &Detector::setNumberOfDigitalSamples,
py::arg(), py::arg() = Positions{})
.def("getReadoutMode", &Detector::getReadoutMode,
py::arg() = Positions{})
.def("setReadoutMode", &Detector::setReadoutMode, py::arg(),
py::arg() = Positions{})
.def("getDBITClock", &Detector::getDBITClock, py::arg() = Positions{})
.def("setDBITClock", &Detector::setDBITClock, py::arg(),
py::arg() = Positions{})
.def("getDBITPipeline", &Detector::getDBITPipeline,
py::arg() = Positions{})
.def("setDBITPipeline", &Detector::setDBITPipeline, py::arg(),
py::arg() = Positions{})
.def("getMeasuredVoltage", &Detector::getMeasuredVoltage, py::arg(),
py::arg() = Positions{})
.def("getMeasuredCurrent", &Detector::getMeasuredCurrent, py::arg(),
py::arg() = Positions{})
.def("getSlowADC", &Detector::getSlowADC, py::arg(),
py::arg() = Positions{}) py::arg() = Positions{})
.def("getExternalSamplingSource", &Detector::getExternalSamplingSource, .def("getExternalSamplingSource", &Detector::getExternalSamplingSource,
py::arg() = Positions{}) py::arg() = Positions{})
@ -627,6 +624,9 @@ void init_det(py::module &m) {
py::arg(), py::arg() = Positions{}) py::arg(), py::arg() = Positions{})
.def("getInitialChecks", &Detector::getInitialChecks) .def("getInitialChecks", &Detector::getInitialChecks)
.def("setInitialChecks", &Detector::setInitialChecks, py::arg()) .def("setInitialChecks", &Detector::setInitialChecks, py::arg())
.def("getADCInvert", &Detector::getADCInvert, py::arg() = Positions{})
.def("setADCInvert", &Detector::setADCInvert, py::arg(),
py::arg() = Positions{})
.def("getControlPort", &Detector::getControlPort, .def("getControlPort", &Detector::getControlPort,
py::arg() = Positions{}) py::arg() = Positions{})
.def("setControlPort", &Detector::setControlPort, py::arg(), .def("setControlPort", &Detector::setControlPort, py::arg(),

View File

@ -184,6 +184,11 @@ void init_enums(py::module &m) {
.value("VB_PIXBUF", slsDetectorDefs::dacIndex::VB_PIXBUF) .value("VB_PIXBUF", slsDetectorDefs::dacIndex::VB_PIXBUF)
.value("VIN_COM", slsDetectorDefs::dacIndex::VIN_COM) .value("VIN_COM", slsDetectorDefs::dacIndex::VIN_COM)
.value("VDD_PROT", slsDetectorDefs::dacIndex::VDD_PROT) .value("VDD_PROT", slsDetectorDefs::dacIndex::VDD_PROT)
.value("VBP_COLBUF", slsDetectorDefs::dacIndex::VBP_COLBUF)
.value("VB_SDA", slsDetectorDefs::dacIndex::VB_SDA)
.value("VCASC_SFP", slsDetectorDefs::dacIndex::VCASC_SFP)
.value("VIPRE_CDS", slsDetectorDefs::dacIndex::VIPRE_CDS)
.value("IBIAS_SFP", slsDetectorDefs::dacIndex::IBIAS_SFP)
.value("V_POWER_A", slsDetectorDefs::dacIndex::V_POWER_A) .value("V_POWER_A", slsDetectorDefs::dacIndex::V_POWER_A)
.value("V_POWER_B", slsDetectorDefs::dacIndex::V_POWER_B) .value("V_POWER_B", slsDetectorDefs::dacIndex::V_POWER_B)
.value("V_POWER_C", slsDetectorDefs::dacIndex::V_POWER_C) .value("V_POWER_C", slsDetectorDefs::dacIndex::V_POWER_C)
@ -224,6 +229,18 @@ void init_enums(py::module &m) {
.value("FORCESWITCHG2", .value("FORCESWITCHG2",
slsDetectorDefs::detectorSettings::FORCESWITCHG2) slsDetectorDefs::detectorSettings::FORCESWITCHG2)
.value("VERYLOWGAIN", slsDetectorDefs::detectorSettings::VERYLOWGAIN) .value("VERYLOWGAIN", slsDetectorDefs::detectorSettings::VERYLOWGAIN)
.value("G1_HIGHGAIN", slsDetectorDefs::detectorSettings::G1_HIGHGAIN)
.value("G1_LOWGAIN", slsDetectorDefs::detectorSettings::G1_LOWGAIN)
.value("G2_HIGHCAP_HIGHGAIN",
slsDetectorDefs::detectorSettings::G2_HIGHCAP_HIGHGAIN)
.value("G2_HIGHCAP_LOWGAIN",
slsDetectorDefs::detectorSettings::G2_HIGHCAP_LOWGAIN)
.value("G2_LOWCAP_HIGHGAIN",
slsDetectorDefs::detectorSettings::G2_LOWCAP_HIGHGAIN)
.value("G2_LOWCAP_LOWGAIN",
slsDetectorDefs::detectorSettings::G2_LOWCAP_LOWGAIN)
.value("G4_HIGHGAIN", slsDetectorDefs::detectorSettings::G4_HIGHGAIN)
.value("G4_LOWGAIN", slsDetectorDefs::detectorSettings::G4_LOWGAIN)
.value("UNDEFINED", slsDetectorDefs::detectorSettings::UNDEFINED) .value("UNDEFINED", slsDetectorDefs::detectorSettings::UNDEFINED)
.value("UNINITIALIZED", .value("UNINITIALIZED",
slsDetectorDefs::detectorSettings::UNINITIALIZED) slsDetectorDefs::detectorSettings::UNINITIALIZED)

View File

@ -15,10 +15,11 @@ using sls::IpAddr;
using sls::MacAddr; using sls::MacAddr;
void init_network(py::module &m) { void init_network(py::module &m) {
py::class_ <IpAddr> IpAddr(m, "IpAddr"); py::class_ <IpAddr>(m, "IpAddr")
IpAddr.def(py::init()) .def(py::init())
.def(py::init<const std::string&>()) .def(py::init<const std::string&>())
.def(py::init<uint32_t>()) .def(py::init<uint32_t>())
.def(py::init<const IpAddr&>())
.def("hex", &IpAddr::hex) .def("hex", &IpAddr::hex)
.def("uint32", &IpAddr::uint32) .def("uint32", &IpAddr::uint32)
.def(py::self == py::self) .def(py::self == py::self)
@ -26,10 +27,11 @@ void init_network(py::module &m) {
.def("str", &IpAddr::str); .def("str", &IpAddr::str);
py::class_ <MacAddr> MacAddr(m, "MacAddr"); py::class_ <MacAddr>(m, "MacAddr")
MacAddr.def(py::init()) .def(py::init())
.def(py::init<const std::string&>()) .def(py::init<const std::string&>())
.def(py::init<uint64_t>()) .def(py::init<uint64_t>())
.def(py::init<const MacAddr&>())
.def("hex", &MacAddr::hex) .def("hex", &MacAddr::hex)
.def(py::self == py::self) .def(py::self == py::self)
.def("uint64", &MacAddr::uint64) .def("uint64", &MacAddr::uint64)

View File

@ -365,15 +365,18 @@ double qDrawPlot::GetYMaximum() {
void qDrawPlot::SetDataCallBack(bool enable) { void qDrawPlot::SetDataCallBack(bool enable) {
LOG(logINFO) << "Setting data call back to " << std::boolalpha LOG(logINFO) << "Setting data call back to " << std::boolalpha
<< enable << std::noboolalpha; << enable << std::noboolalpha;
if (enable) { try {
isPlot = true; if (enable) {
det->setRxZmqDataStream(true); isPlot = true;
det->registerDataCallback(&(GetDataCallBack), this); det->registerDataCallback(&(GetDataCallBack), this);
} else { det->setRxZmqDataStream(true);
isPlot = false; } else {
det->setRxZmqDataStream(false); isPlot = false;
det->registerDataCallback(nullptr, this); det->registerDataCallback(nullptr, this);
} det->setRxZmqDataStream(false);
}
} CATCH_DISPLAY("Could not get set rxr data streaming enable.",
"qDrawPlot::SetDataCallBack")
} }
void qDrawPlot::SetBinary(bool enable, int from, int to) { void qDrawPlot::SetBinary(bool enable, int from, int to) {

View File

@ -771,6 +771,83 @@ std::vector<std::string> CmdProxy::DacCommands() {
/* acquisition */ /* acquisition */
/* Network Configuration (Detector<->Receiver) */ /* Network Configuration (Detector<->Receiver) */
std::string CmdProxy::UDPDestinationIP(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[x.x.x.x] or auto\n\tIp address of the receiver (destination) udp interface. If 'auto' used, then ip is set to ip of rx_hostname."
<< '\n';
} else if (action == defs::GET_ACTION) {
auto t = det->getDestinationUDPIP({det_id});
if (args.size() != 0) {
WrongNumberOfParameters(0);
}
os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) {
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
if (args[0] == "auto") {
std::string rxHostname = det->getRxHostname({det_id}).squash("none");
// Hostname could be ip try to decode otherwise look up the hostname
auto val = sls::IpAddr{rxHostname};
if (val == 0) {
val = HostnameToIp(rxHostname.c_str());
}
LOG(logINFO) << "Setting udp_dstip of detector " <<
det_id << " to " << val;
det->setDestinationUDPIP(val, {det_id});
os << val << '\n';
} else {
auto val = IpAddr(args[0]);
det->setDestinationUDPIP(val, {det_id});
os << args.front() << '\n';
}
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
std::string CmdProxy::UDPDestinationIP2(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[x.x.x.x] or auto\n\t[Jungfrau] Ip address of the receiver (destination) udp interface where the second half of detector data is sent to. If 'auto' used, then ip is set to ip of rx_hostname."
<< '\n';
} else if (action == defs::GET_ACTION) {
auto t = det->getDestinationUDPIP2({det_id});
if (args.size() != 0) {
WrongNumberOfParameters(0);
}
os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) {
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
if (args[0] == "auto") {
std::string rxHostname = det->getRxHostname({det_id}).squash("none");
// Hostname could be ip try to decode otherwise look up the hostname
auto val = sls::IpAddr{rxHostname};
if (val == 0) {
val = HostnameToIp(rxHostname.c_str());
}
LOG(logINFO) << "Setting udp_dstip2 of detector " <<
det_id << " to " << val;
det->setDestinationUDPIP2(val, {det_id});
os << val << '\n';
} else {
auto val = IpAddr(args[0]);
det->setDestinationUDPIP2(val, {det_id});
os << args.front() << '\n';
}
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
/* Receiver Config */ /* Receiver Config */
/* File */ /* File */
/* ZMQ Streaming Parameters (Receiver<->Client) */ /* ZMQ Streaming Parameters (Receiver<->Client) */

View File

@ -705,8 +705,8 @@ class CmdProxy {
{"selinterface", &CmdProxy::selinterface}, {"selinterface", &CmdProxy::selinterface},
{"udp_srcip", &CmdProxy::udp_srcip}, {"udp_srcip", &CmdProxy::udp_srcip},
{"udp_srcip2", &CmdProxy::udp_srcip2}, {"udp_srcip2", &CmdProxy::udp_srcip2},
{"udp_dstip", &CmdProxy::udp_dstip}, {"udp_dstip", &CmdProxy::UDPDestinationIP},
{"udp_dstip2", &CmdProxy::udp_dstip2}, {"udp_dstip2", &CmdProxy::UDPDestinationIP2},
{"udp_srcmac", &CmdProxy::udp_srcmac}, {"udp_srcmac", &CmdProxy::udp_srcmac},
{"udp_srcmac2", &CmdProxy::udp_srcmac2}, {"udp_srcmac2", &CmdProxy::udp_srcmac2},
{"udp_dstmac", &CmdProxy::udp_dstmac}, {"udp_dstmac", &CmdProxy::udp_dstmac},
@ -934,9 +934,10 @@ class CmdProxy {
std::string DacList(int action); std::string DacList(int action);
std::string DacValues(int action); std::string DacValues(int action);
std::vector<std::string> DacCommands(); std::vector<std::string> DacCommands();
std::string OnChipDac(int action);
/* acquisition */ /* acquisition */
/* Network Configuration (Detector<->Receiver) */ /* Network Configuration (Detector<->Receiver) */
std::string UDPDestinationIP(int action);
std::string UDPDestinationIP2(int action);
/* Receiver Config */ /* Receiver Config */
/* File */ /* File */
/* ZMQ Streaming Parameters (Receiver<->Client) */ /* ZMQ Streaming Parameters (Receiver<->Client) */
@ -1394,12 +1395,6 @@ class CmdProxy {
INTEGER_COMMAND(udp_srcip2, getSourceUDPIP2, setSourceUDPIP2, IpAddr, INTEGER_COMMAND(udp_srcip2, getSourceUDPIP2, setSourceUDPIP2, IpAddr,
"[x.x.x.x]\n\t[Jungfrau] Ip address of the bottom half of detector (source) udp interface. Must be same subnet as destination udp ip2."); "[x.x.x.x]\n\t[Jungfrau] Ip address of the bottom half of detector (source) udp interface. Must be same subnet as destination udp ip2.");
INTEGER_COMMAND(udp_dstip, getDestinationUDPIP, setDestinationUDPIP, IpAddr,
"[x.x.x.x]\n\tIp address of the receiver (destination) udp interface.");
INTEGER_COMMAND(udp_dstip2, getDestinationUDPIP2, setDestinationUDPIP2, IpAddr,
"[x.x.x.x]\n\t[Jungfrau] Ip address of the receiver (destination) udp interface where the second half of detector data is sent to.");
INTEGER_COMMAND(udp_srcmac, getSourceUDPMAC, setSourceUDPMAC, MacAddr, INTEGER_COMMAND(udp_srcmac, getSourceUDPMAC, setSourceUDPMAC, MacAddr,
"[x:x:x:x:x:x]\n\tMac address of the detector (source) udp interface. "); "[x:x:x:x:x:x]\n\tMac address of the detector (source) udp interface. ");
@ -1407,10 +1402,10 @@ class CmdProxy {
"[x:x:x:x:x:x]\n\t[Jungfrau] Mac address of the bottom half of detector (source) udp interface. "); "[x:x:x:x:x:x]\n\t[Jungfrau] Mac address of the bottom half of detector (source) udp interface. ");
INTEGER_COMMAND(udp_dstmac, getDestinationUDPMAC, setDestinationUDPMAC, MacAddr, INTEGER_COMMAND(udp_dstmac, getDestinationUDPMAC, setDestinationUDPMAC, MacAddr,
"[x:x:x:x:x:x]\n\tMac address of the receiver (destination) udp interface. Can be unused as rx_hostname/udp_dstip retrieves it."); "[x:x:x:x:x:x]\n\tMac address of the receiver (destination) udp interface. Can be unused as udp_dstip retrieves it.");
INTEGER_COMMAND(udp_dstmac2, getDestinationUDPMAC2, setDestinationUDPMAC2, MacAddr, INTEGER_COMMAND(udp_dstmac2, getDestinationUDPMAC2, setDestinationUDPMAC2, MacAddr,
"[x:x:x:x:x:x]\n\t[Jungfrau] Mac address of the receiver (destination) udp interface where the second half of detector data is sent to. Can be unused as rx_hostname/udp_dstip2 retrieves it."); "[x:x:x:x:x:x]\n\t[Jungfrau] Mac address of the receiver (destination) udp interface where the second half of detector data is sent to. Can be unused as udp_dstip2 retrieves it.");
INTEGER_COMMAND(udp_dstport, getDestinationUDPPort, setDestinationUDPPort, std::stoi, INTEGER_COMMAND(udp_dstport, getDestinationUDPPort, setDestinationUDPPort, std::stoi,
"[n]\n\tPort number of the receiver (destination) udp interface. Default is 50001."); "[n]\n\tPort number of the receiver (destination) udp interface. Default is 50001.");
@ -1440,7 +1435,7 @@ class CmdProxy {
/* Receiver Config */ /* Receiver Config */
STRING_COMMAND(rx_hostname, getRxHostname, setRxHostname, STRING_COMMAND(rx_hostname, getRxHostname, setRxHostname,
"[hostname or ip address]\n\tReceiver hostname or IP. Used for TCP control communication between client and receiver to configure receiver."); "[hostname or ip address]\n\tReceiver hostname or IP. Used for TCP control communication between client and receiver to configure receiver. Also updates receiver with detector parameters.");
INTEGER_COMMAND(rx_tcpport, getRxPort, setRxPort, std::stoi, INTEGER_COMMAND(rx_tcpport, getRxPort, setRxPort, std::stoi,
"[port]\n\tTCP port for client-receiver communication. Default is 1954. Must be different if multiple receivers on same pc. Must be first command to set a receiver parameter. Multi command will automatically increment for individual modules."); "[port]\n\tTCP port for client-receiver communication. Default is 1954. Must be different if multiple receivers on same pc. Must be first command to set a receiver parameter. Multi command will automatically increment for individual modules.");
@ -1544,7 +1539,7 @@ class CmdProxy {
"[0, 1]\n\t[Eiger] Enable or disable store in ram mode."); "[0, 1]\n\t[Eiger] Enable or disable store in ram mode.");
INTEGER_COMMAND(flippeddatax, getBottom, setBottom, std::stoi, INTEGER_COMMAND(flippeddatax, getBottom, setBottom, std::stoi,
"[0, 1]\n\t[Eiger] Top or Bottom Half of Eiger module. 1 is bottom, 0 is top. Used to let Receiver and Gui know to flip the bottom image over the x axis."); "[0, 1]\n\t[Eiger] Top or Bottom Half of Eiger module. 1 is bottom, 0 is top. Used to let Receivers and Gui know to flip the bottom image over the x axis. Files are not written without the flip however.");
INTEGER_COMMAND(trimval, getAllTrimbits, setAllTrimbits, std::stoi, INTEGER_COMMAND(trimval, getAllTrimbits, setAllTrimbits, std::stoi,
"[n_trimval]\n\t[Eiger] All trimbits set to this value. A get returns -1 if all trimbits are different values."); "[n_trimval]\n\t[Eiger] All trimbits set to this value. A get returns -1 if all trimbits are different values.");
@ -1727,7 +1722,7 @@ class CmdProxy {
/* Moench */ /* Moench */
STRING_COMMAND(rx_jsonaddheader, getAdditionalJsonHeader, setAdditionalJsonHeader, STRING_COMMAND(rx_jsonaddheader, getAdditionalJsonHeader, setAdditionalJsonHeader,
"[\"label1\":\"value1\"], [\"label2\":\"value2\"]\n\tAdditional json header to be streamd out from receiver via zmq. Default is empty. Use only if to be processed by an intermediate user process listening to receiver zmq packets."); "[\\\"label1\\\":\\\"value1\\\"], [\\\"label2\\\":\\\"value2\\\"]\n\tAdditional json header to be streamd out from receiver via zmq. Default is empty. Use only if to be processed by an intermediate user process listening to receiver zmq packets.");
INTEGER_COMMAND(framemode, getFrameMode, setFrameMode, sls::StringTo<slsDetectorDefs::frameModeType>, INTEGER_COMMAND(framemode, getFrameMode, setFrameMode, sls::StringTo<slsDetectorDefs::frameModeType>,
"[pedestal|newpedestal|flatfield|newflatfield]\n\t[Moench] Frame mode (soft setting) in processor."); "[pedestal|newpedestal|flatfield|newflatfield]\n\t[Moench] Frame mode (soft setting) in processor.");

View File

@ -470,8 +470,17 @@ Result<int> Detector::getNumberofUDPInterfaces(Positions pos) const {
void Detector::setNumberofUDPInterfaces(int n, Positions pos) { void Detector::setNumberofUDPInterfaces(int n, Positions pos) {
int previouslyClientStreaming = pimpl->enableDataStreamingToClient(); int previouslyClientStreaming = pimpl->enableDataStreamingToClient();
bool previouslyReceiverStreaming = getRxZmqDataStream(pos).squash(true); bool useReceiver = getUseReceiverFlag().squash(false);
bool previouslyReceiverStreaming = false;
if (useReceiver) {
previouslyReceiverStreaming = getRxZmqDataStream(pos).squash(true);
}
pimpl->Parallel(&Module::setNumberofUDPInterfaces, pos, n); pimpl->Parallel(&Module::setNumberofUDPInterfaces, pos, n);
// ensure receiver zmq socket ports are multiplied by 2 (2 interfaces)
if (getUseReceiverFlag().squash(false) && size()) {
int startingPort = getRxZmqPort({0}).squash(0);
setRxZmqPort(startingPort, -1);
}
// redo the zmq sockets if enabled // redo the zmq sockets if enabled
if (previouslyClientStreaming != 0) { if (previouslyClientStreaming != 0) {
pimpl->enableDataStreamingToClient(0); pimpl->enableDataStreamingToClient(0);
@ -675,18 +684,16 @@ void Detector::setRxFifoDepth(int nframes, Positions pos) {
} }
Result<bool> Detector::getRxSilentMode(Positions pos) const { Result<bool> Detector::getRxSilentMode(Positions pos) const {
return pimpl->Parallel(&Module::setReceiverSilentMode, pos, -1); return pimpl->Parallel(&Module::getReceiverSilentMode, pos);
} }
void Detector::setRxSilentMode(bool value, Positions pos) { void Detector::setRxSilentMode(bool value, Positions pos) {
pimpl->Parallel(&Module::setReceiverSilentMode, pos, pimpl->Parallel(&Module::setReceiverSilentMode, pos, value);
static_cast<int>(value));
} }
Result<defs::frameDiscardPolicy> Result<defs::frameDiscardPolicy>
Detector::getRxFrameDiscardPolicy(Positions pos) const { Detector::getRxFrameDiscardPolicy(Positions pos) const {
return pimpl->Parallel(&Module::setReceiverFramesDiscardPolicy, pos, return pimpl->Parallel(&Module::getReceiverFramesDiscardPolicy, pos);
defs::GET_FRAME_DISCARD_POLICY);
} }
void Detector::setRxFrameDiscardPolicy(defs::frameDiscardPolicy f, void Detector::setRxFrameDiscardPolicy(defs::frameDiscardPolicy f,
@ -797,18 +804,15 @@ void Detector::setFramesPerFile(int n, Positions pos) {
// Zmq Streaming (Receiver<->Client) // Zmq Streaming (Receiver<->Client)
Result<bool> Detector::getRxZmqDataStream(Positions pos) const { Result<bool> Detector::getRxZmqDataStream(Positions pos) const {
return pimpl->Parallel(&Module::enableDataStreamingFromReceiver, pos, return pimpl->Parallel(&Module::getReceiverStreaming, pos);
-1);
} }
void Detector::setRxZmqDataStream(bool value, Positions pos) { void Detector::setRxZmqDataStream(bool value, Positions pos) {
pimpl->Parallel(&Module::enableDataStreamingFromReceiver, pos, pimpl->Parallel(&Module::setReceiverStreaming, pos, value);
static_cast<int>(value));
} }
Result<int> Detector::getRxZmqFrequency(Positions pos) const { Result<int> Detector::getRxZmqFrequency(Positions pos) const {
return pimpl->Parallel(&Module::setReceiverStreamingFrequency, pos, return pimpl->Parallel(&Module::getReceiverStreamingFrequency, pos);
-1);
} }
void Detector::setRxZmqFrequency(int freq, Positions pos) { void Detector::setRxZmqFrequency(int freq, Positions pos) {
@ -969,8 +973,7 @@ Result<bool> Detector::getBottom(Positions pos) const {
} }
void Detector::setBottom(bool value, Positions pos) { void Detector::setBottom(bool value, Positions pos) {
pimpl->Parallel(&Module::setFlippedDataX, pos, pimpl->Parallel(&Module::setFlippedDataX, pos, value);
static_cast<int>(value));
} }
Result<int> Detector::getAllTrimbits(Positions pos) const { Result<int> Detector::getAllTrimbits(Positions pos) const {
@ -1034,12 +1037,11 @@ void Detector::setActive(bool active, Positions pos) {
} }
Result<bool> Detector::getRxPadDeactivatedMode(Positions pos) const { Result<bool> Detector::getRxPadDeactivatedMode(Positions pos) const {
return pimpl->Parallel(&Module::setDeactivatedRxrPaddingMode, pos, -1); return pimpl->Parallel(&Module::getDeactivatedRxrPaddingMode, pos);
} }
void Detector::setRxPadDeactivatedMode(bool pad, Positions pos) { void Detector::setRxPadDeactivatedMode(bool pad, Positions pos) {
pimpl->Parallel(&Module::setDeactivatedRxrPaddingMode, pos, pimpl->Parallel(&Module::setDeactivatedRxrPaddingMode, pos, pad);
static_cast<int>(pad));
} }
Result<bool> Detector::getPartialReset(Positions pos) const { Result<bool> Detector::getPartialReset(Positions pos) const {

View File

@ -407,55 +407,10 @@ void Module::initializeDetectorStructure(detectorType type) {
sls::strcpy_safe(shm()->rxHostname, "none"); sls::strcpy_safe(shm()->rxHostname, "none");
shm()->rxTCPPort = DEFAULT_PORTNO + 2; shm()->rxTCPPort = DEFAULT_PORTNO + 2;
shm()->useReceiverFlag = false; shm()->useReceiverFlag = false;
shm()->flippedDataX = false;
shm()->zmqport = DEFAULT_ZMQ_CL_PORTNO + shm()->zmqport = DEFAULT_ZMQ_CL_PORTNO +
(detId * ((shm()->myDetectorType == EIGER) ? 2 : 1)); (detId * ((shm()->myDetectorType == EIGER) ? 2 : 1));
shm()->rxZmqport = DEFAULT_ZMQ_RX_PORTNO +
(detId * ((shm()->myDetectorType == EIGER) ? 2 : 1));
shm()->rxUpstream = false;
shm()->rxReadFreq = 1;
shm()->zmqip = IpAddr{}; shm()->zmqip = IpAddr{};
shm()->rxZmqip = IpAddr{};
shm()->gappixels = 0U; shm()->gappixels = 0U;
memset(shm()->rxAdditionalJsonHeader, 0, MAX_STR_LENGTH);
shm()->rxFrameDiscardMode = NO_DISCARD;
shm()->rxFramePadding = true;
shm()->activated = true;
shm()->rxPadDeactivatedModules = true;
shm()->rxSilentMode = false;
sls::strcpy_safe(shm()->rxFilePath, "/");
sls::strcpy_safe(shm()->rxFileName, "run");
shm()->rxFileIndex = 0;
shm()->rxFileFormat = BINARY;
switch (shm()->myDetectorType) {
case GOTTHARD:
shm()->rxFramesPerFile = MAX_FRAMES_PER_FILE;
break;
case EIGER:
shm()->rxFramesPerFile = EIGER_MAX_FRAMES_PER_FILE;
break;
case JUNGFRAU:
shm()->rxFramesPerFile = JFRAU_MAX_FRAMES_PER_FILE;
break;
case CHIPTESTBOARD:
shm()->rxFramesPerFile = CTB_MAX_FRAMES_PER_FILE;
break;
case MOENCH:
shm()->rxFramesPerFile = MOENCH_MAX_FRAMES_PER_FILE;
break;
case MYTHEN3:
shm()->rxFramesPerFile = MYTHEN3_MAX_FRAMES_PER_FILE;
break;
case GOTTHARD2:
shm()->rxFramesPerFile = GOTTHARD2_MAX_FRAMES_PER_FILE;
break;
default:
break;
}
shm()->rxFileWrite = true;
shm()->rxMasterFileWrite = true;
shm()->rxFileOverWrite = true;
shm()->rxDbitOffset = 0;
shm()->numUDPInterfaces = 1; shm()->numUDPInterfaces = 1;
shm()->stoppedFlag = false; shm()->stoppedFlag = false;
@ -1163,7 +1118,9 @@ void Module::startAcquisition() {
void Module::stopAcquisition() { void Module::stopAcquisition() {
// get status before stopping acquisition // get status before stopping acquisition
runStatus s = ERROR, r = ERROR; runStatus s = ERROR, r = ERROR;
if (shm()->rxUpstream) { bool zmqstreaming = false;
if (shm()->useReceiverFlag && getReceiverStreaming()) {
zmqstreaming = true;
s = getRunStatus(); s = getRunStatus();
r = getReceiverStatus(); r = getReceiverStatus();
} }
@ -1172,7 +1129,7 @@ void Module::stopAcquisition() {
shm()->stoppedFlag = true; shm()->stoppedFlag = true;
LOG(logDEBUG1) << "Stopping Acquisition successful"; LOG(logDEBUG1) << "Stopping Acquisition successful";
// if rxr streaming and acquisition finished, restream dummy stop packet // if rxr streaming and acquisition finished, restream dummy stop packet
if ((shm()->rxUpstream) && (s == IDLE) && (r == IDLE)) { if (zmqstreaming && (s == IDLE) && (r == IDLE)) {
restreamStopFromReceiver(); restreamStopFromReceiver();
} }
} }
@ -1744,16 +1701,6 @@ std::string Module::setReceiverHostname(const std::string &receiverIP) {
LOG(logDEBUG1) << printReceiverConfiguration(); LOG(logDEBUG1) << printReceiverConfiguration();
setReceiverUDPSocketBufferSize(0); setReceiverUDPSocketBufferSize(0);
setFilePath(shm()->rxFilePath);
setFileName(shm()->rxFileName);
setFileIndex(shm()->rxFileIndex);
setFileFormat(shm()->rxFileFormat);
setFramesPerFile(shm()->rxFramesPerFile);
setReceiverFramesDiscardPolicy(shm()->rxFrameDiscardMode);
setPartialFramesPadding(shm()->rxFramePadding);
setFileWrite(shm()->rxFileWrite);
setMasterFileWrite(shm()->rxMasterFileWrite);
setFileOverWrite(shm()->rxFileOverWrite);
sendTotalNumFramestoReceiver(); sendTotalNumFramestoReceiver();
setExptime(getExptime()); setExptime(getExptime());
setPeriod(getPeriod()); setPeriod(getPeriod());
@ -1765,10 +1712,7 @@ std::string Module::setReceiverHostname(const std::string &receiverIP) {
setSubExptime(getSubExptime()); setSubExptime(getSubExptime());
setSubDeadTime(getSubDeadTime()); setSubDeadTime(getSubDeadTime());
setDynamicRange(shm()->dynamicRange); setDynamicRange(shm()->dynamicRange);
setFlippedDataX(-1);
activate(-1); activate(-1);
setDeactivatedRxrPaddingMode(
static_cast<int>(shm()->rxPadDeactivatedModules));
enableGapPixels(shm()->gappixels); enableGapPixels(shm()->gappixels);
enableTenGigabitEthernet(-1); enableTenGigabitEthernet(-1);
setQuad(getQuad()); setQuad(getQuad());
@ -1781,8 +1725,6 @@ std::string Module::setReceiverHostname(const std::string &receiverIP) {
setReadoutMode(getReadoutMode()); setReadoutMode(getReadoutMode());
setADCEnableMask(getADCEnableMask()); setADCEnableMask(getADCEnableMask());
setTenGigaADCEnableMask(getTenGigaADCEnableMask()); setTenGigaADCEnableMask(getTenGigaADCEnableMask());
setReceiverDbitOffset(shm()->rxDbitOffset);
setReceiverDbitList(shm()->rxDbitList);
break; break;
case MOENCH: case MOENCH:
@ -1805,14 +1747,8 @@ std::string Module::setReceiverHostname(const std::string &receiverIP) {
break; break;
} }
setReceiverSilentMode(static_cast<int>(shm()->rxSilentMode)); // to use rx_hostname if empty and also update client zmqip
// data streaming
setReceiverStreamingFrequency(shm()->rxReadFreq);
setReceiverStreamingPort(getReceiverStreamingPort());
updateReceiverStreamingIP(); updateReceiverStreamingIP();
setAdditionalJsonHeader(shm()->rxAdditionalJsonHeader);
enableDataStreamingFromReceiver(
static_cast<int>(enableDataStreamingFromReceiver(-1)));
} }
return std::string(shm()->rxHostname); return std::string(shm()->rxHostname);
@ -1897,7 +1833,7 @@ void Module::setDestinationUDPIP(const IpAddr ip) {
if (shm()->useReceiverFlag) { if (shm()->useReceiverFlag) {
sls::MacAddr retval(0LU); sls::MacAddr retval(0LU);
sendToReceiver(F_SET_RECEIVER_UDP_IP, ip, retval); sendToReceiver(F_SET_RECEIVER_UDP_IP, ip, retval);
LOG(logINFO) << "Setting destination udp mac to " << retval; LOG(logINFO) << "Setting destination udp mac of detector " << detId << " to " << retval;
sendToDetector(F_SET_DEST_UDP_MAC, retval, nullptr); sendToDetector(F_SET_DEST_UDP_MAC, retval, nullptr);
} }
} }
@ -1912,15 +1848,9 @@ sls::IpAddr Module::getDestinationUDPIP() {
void Module::updateRxDestinationUDPIP() { void Module::updateRxDestinationUDPIP() {
auto ip = getDestinationUDPIP(); auto ip = getDestinationUDPIP();
if (ip == 0) { if (ip != 0) {
// Hostname could be ip try to decode otherwise look up the hostname setDestinationUDPIP(ip);
ip = sls::IpAddr{shm()->rxHostname};
if (ip == 0) {
ip = HostnameToIp(shm()->rxHostname);
}
LOG(logINFO) << "Setting destination default udp ip to " << ip;
} }
setDestinationUDPIP(ip);
} }
void Module::setDestinationUDPIP2(const IpAddr ip) { void Module::setDestinationUDPIP2(const IpAddr ip) {
@ -1933,7 +1863,7 @@ void Module::setDestinationUDPIP2(const IpAddr ip) {
if (shm()->useReceiverFlag) { if (shm()->useReceiverFlag) {
sls::MacAddr retval(0LU); sls::MacAddr retval(0LU);
sendToReceiver(F_SET_RECEIVER_UDP_IP2, ip, retval); sendToReceiver(F_SET_RECEIVER_UDP_IP2, ip, retval);
LOG(logINFO) << "Setting destination udp mac2 to " << retval; LOG(logINFO) << "Setting destination udp mac2 of detector " << detId << " to " << retval;
sendToDetector(F_SET_DEST_UDP_MAC2, retval, nullptr); sendToDetector(F_SET_DEST_UDP_MAC2, retval, nullptr);
} }
} }
@ -1948,15 +1878,9 @@ sls::IpAddr Module::getDestinationUDPIP2() {
void Module::updateRxDestinationUDPIP2() { void Module::updateRxDestinationUDPIP2() {
auto ip = getDestinationUDPIP2(); auto ip = getDestinationUDPIP2();
if (ip == 0) { if (ip != 0) {
// Hostname could be ip try to decode otherwise look up the hostname setDestinationUDPIP2(ip);
ip = sls::IpAddr{shm()->rxHostname};
if (ip == 0) {
ip = HostnameToIp(shm()->rxHostname);
}
LOG(logINFO) << "Setting destination default udp ip2 to " << ip;
} }
setDestinationUDPIP2(ip);
} }
void Module::setDestinationUDPMAC(const MacAddr mac) { void Module::setDestinationUDPMAC(const MacAddr mac) {
@ -2067,16 +1991,18 @@ void Module::setClientStreamingPort(int port) { shm()->zmqport = port; }
int Module::getClientStreamingPort() { return shm()->zmqport; } int Module::getClientStreamingPort() { return shm()->zmqport; }
void Module::setReceiverStreamingPort(int port) { void Module::setReceiverStreamingPort(int port) {
if (shm()->useReceiverFlag) { if (!shm()->useReceiverFlag) {
auto retval = sendToReceiver<int>(F_SET_RECEIVER_STREAMING_PORT, port); throw RuntimeError("Set rx_hostname first to use receiver parameters (zmq port)");
LOG(logDEBUG1) << "Receiver streaming port: " << retval; }
shm()->rxZmqport = retval; sendToReceiver(F_SET_RECEIVER_STREAMING_PORT, port, nullptr);
} else {
shm()->rxZmqport = port;
}
} }
int Module::getReceiverStreamingPort() { return shm()->rxZmqport; } int Module::getReceiverStreamingPort() {
if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to get receiver parameters (zmq port)");
}
return sendToReceiver<int>(F_GET_RECEIVER_STREAMING_PORT);
}
void Module::setClientStreamingIP(const sls::IpAddr ip) { void Module::setClientStreamingIP(const sls::IpAddr ip) {
LOG(logDEBUG1) << "Setting client zmq ip to " << ip; LOG(logDEBUG1) << "Setting client zmq ip to " << ip;
@ -2089,29 +2015,25 @@ void Module::setClientStreamingIP(const sls::IpAddr ip) {
sls::IpAddr Module::getClientStreamingIP() { return shm()->zmqip; } sls::IpAddr Module::getClientStreamingIP() { return shm()->zmqip; }
void Module::setReceiverStreamingIP(const sls::IpAddr ip) { void Module::setReceiverStreamingIP(const sls::IpAddr ip) {
LOG(logDEBUG1) << "Setting rx zmq ip to " << ip; if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (streaming ip)");
}
if (ip == 0) { if (ip == 0) {
throw RuntimeError("Invalid receiver zmq ip address"); throw RuntimeError("Invalid receiver zmq ip address");
} }
// if zmqip is empty, update it // if client zmqip is empty, update it
if (shm()->zmqip == 0) { if (shm()->zmqip == 0) {
shm()->zmqip = ip; shm()->zmqip = ip;
} }
sendToReceiver(F_SET_RECEIVER_STREAMING_SRC_IP, ip, nullptr);
// send to receiver
if (shm()->useReceiverFlag) {
LOG(logDEBUG1)
<< "Sending receiver streaming IP to receiver: " << ip;
sendToReceiver(F_RECEIVER_STREAMING_SRC_IP, ip, nullptr);
shm()->rxZmqip = ip;
} else {
shm()->rxZmqip = ip;
}
} }
sls::IpAddr Module::getReceiverStreamingIP() { sls::IpAddr Module::getReceiverStreamingIP() {
return shm()->rxZmqip; if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (streaming ip)");
}
return sendToReceiver<sls::IpAddr>(F_GET_RECEIVER_STREAMING_SRC_IP);
} }
void Module::updateReceiverStreamingIP() { void Module::updateReceiverStreamingIP() {
@ -2122,12 +2044,11 @@ void Module::updateReceiverStreamingIP() {
if (ip == 0) { if (ip == 0) {
ip = HostnameToIp(shm()->rxHostname); ip = HostnameToIp(shm()->rxHostname);
} }
LOG(logINFO) << "Setting default receiver streaming zmq ip to " << ip; LOG(logINFO) << "Setting default receiver " << detId << " streaming zmq ip to " << ip;
} }
setReceiverStreamingIP(ip); setReceiverStreamingIP(ip);
} }
bool Module::getTenGigaFlowControl() { bool Module::getTenGigaFlowControl() {
int retval = -1; int retval = -1;
sendToDetector(F_GET_TEN_GIGA_FLOW_CONTROL, nullptr, retval); sendToDetector(F_GET_TEN_GIGA_FLOW_CONTROL, nullptr, retval);
@ -2178,36 +2099,22 @@ void Module::setTransmissionDelayRight(int value) {
} }
std::string void Module::setAdditionalJsonHeader(const std::string &jsonheader) {
Module::setAdditionalJsonHeader(const std::string &jsonheader) { if (!shm()->useReceiverFlag) {
int fnum = F_ADDITIONAL_JSON_HEADER; throw RuntimeError("Set rx_hostname first to use receiver parameters (zmq json header)");
}
char args[MAX_STR_LENGTH]{}; char args[MAX_STR_LENGTH]{};
char retvals[MAX_STR_LENGTH]{};
sls::strcpy_safe(args, jsonheader.c_str()); sls::strcpy_safe(args, jsonheader.c_str());
LOG(logDEBUG1) << "Sending additional json header " << args; sendToReceiver(F_SET_ADDITIONAL_JSON_HEADER, args, nullptr);
if (shm()->useReceiverFlag) {
sendToReceiver(fnum, args, retvals);
LOG(logDEBUG1) << "Additional json header: " << retvals;
memset(shm()->rxAdditionalJsonHeader, 0, MAX_STR_LENGTH);
sls::strcpy_safe(shm()->rxAdditionalJsonHeader, retvals);
} else {
sls::strcpy_safe(shm()->rxAdditionalJsonHeader, jsonheader.c_str());
}
return shm()->rxAdditionalJsonHeader;
} }
std::string Module::getAdditionalJsonHeader() { std::string Module::getAdditionalJsonHeader() {
int fnum = F_GET_ADDITIONAL_JSON_HEADER; if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (zmq json header)");
}
char retvals[MAX_STR_LENGTH]{}; char retvals[MAX_STR_LENGTH]{};
LOG(logDEBUG1) << "Getting additional json header "; sendToReceiver(F_GET_ADDITIONAL_JSON_HEADER, nullptr, retvals);
if (shm()->useReceiverFlag) { return std::string(retvals);
sendToReceiver(fnum, nullptr, retvals);
LOG(logDEBUG1) << "Additional json header: " << retvals;
memset(shm()->rxAdditionalJsonHeader, 0, MAX_STR_LENGTH);
sls::strcpy_safe(shm()->rxAdditionalJsonHeader, retvals);
}
return std::string(shm()->rxAdditionalJsonHeader);
} }
std::string Module::setAdditionalJsonParameter(const std::string &key, std::string Module::setAdditionalJsonParameter(const std::string &key,
@ -2239,7 +2146,7 @@ std::string Module::setAdditionalJsonParameter(const std::string &key,
valueLiteral.append("\""); valueLiteral.append("\"");
} }
std::string header(shm()->rxAdditionalJsonHeader); std::string header = getAdditionalJsonHeader();
size_t keyPos = header.find(keyLiteral); size_t keyPos = header.find(keyLiteral);
// if key found, replace value // if key found, replace value
@ -2267,8 +2174,9 @@ std::string Module::setAdditionalJsonParameter(const std::string &key,
std::string Module::getAdditionalJsonParameter(const std::string &key) { std::string Module::getAdditionalJsonParameter(const std::string &key) {
// additional json header is empty // additional json header is empty
if (strlen(shm()->rxAdditionalJsonHeader) == 0U) std::string jsonheader = getAdditionalJsonHeader();
return std::string(); if (jsonheader.empty())
return jsonheader;
// add quotations before and after the key value // add quotations before and after the key value
std::string keyLiteral = key; std::string keyLiteral = key;
@ -2277,7 +2185,7 @@ std::string Module::getAdditionalJsonParameter(const std::string &key) {
// loop through the parameters // loop through the parameters
for (const auto &parameter : for (const auto &parameter :
sls::split(shm()->rxAdditionalJsonHeader, ',')) { sls::split(jsonheader, ',')) {
// get a vector of key value pair for each parameter // get a vector of key value pair for each parameter
const auto &pairs = sls::split(parameter, ':'); const auto &pairs = sls::split(parameter, ':');
// match for key // match for key
@ -2652,6 +2560,10 @@ int Module::setExternalSampling(int value) {
int Module::getExternalSampling() { return setExternalSampling(-1); } int Module::getExternalSampling() { return setExternalSampling(-1); }
void Module::setReceiverDbitList(const std::vector<int>& list) { void Module::setReceiverDbitList(const std::vector<int>& list) {
if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (dbit list)");
}
LOG(logDEBUG1) << "Setting Receiver Dbit List"; LOG(logDEBUG1) << "Setting Receiver Dbit List";
if (list.size() > 64) { if (list.size() > 64) {
@ -2664,39 +2576,31 @@ void Module::setReceiverDbitList(const std::vector<int>& list) {
} }
} }
sls::FixedCapacityContainer<int, MAX_RX_DBIT> arg = list; sls::FixedCapacityContainer<int, MAX_RX_DBIT> arg = list;
if (shm()->useReceiverFlag) { sendToReceiver(F_SET_RECEIVER_DBIT_LIST, arg, nullptr);
sendToReceiver(F_SET_RECEIVER_DBIT_LIST, arg, nullptr);
shm()->rxDbitList = list;
} else {
shm()->rxDbitList = list;
}
} }
std::vector<int> Module::getReceiverDbitList() const { std::vector<int> Module::getReceiverDbitList() const {
if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (dbit list)");
}
sls::FixedCapacityContainer<int, MAX_RX_DBIT> retval; sls::FixedCapacityContainer<int, MAX_RX_DBIT> retval;
LOG(logDEBUG1) << "Getting Receiver Dbit List"; sendToReceiver(F_GET_RECEIVER_DBIT_LIST, nullptr, retval);
if (shm()->useReceiverFlag) { return retval;
sendToReceiver(F_GET_RECEIVER_DBIT_LIST, nullptr, retval);
shm()->rxDbitList = retval;
}
return shm()->rxDbitList;
} }
int Module::setReceiverDbitOffset(int value) { void Module::setReceiverDbitOffset(int value) {
int retval = -1; if (!shm()->useReceiverFlag) {
LOG(logDEBUG1) << "Setting digital bit offset in receiver to " throw RuntimeError("Set rx_hostname first to use receiver parameters (dbit offset)");
<< value; }
if (shm()->useReceiverFlag) { sendToReceiver(F_SET_RECEIVER_DBIT_OFFSET, value, nullptr);
sendToReceiver(F_RECEIVER_DBIT_OFFSET, value, retval);
LOG(logDEBUG1) << "Receiver digital bit offset: " << retval;
shm()->rxDbitOffset = value;
} else {
shm()->rxDbitOffset = value;
}
return shm()->rxDbitOffset;
} }
int Module::getReceiverDbitOffset() { return shm()->rxDbitOffset; } int Module::getReceiverDbitOffset() {
if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (dbit offset)");
}
return sendToReceiver<int>(F_GET_RECEIVER_DBIT_OFFSET);
}
void Module::writeAdcRegister(uint32_t addr, uint32_t val) { void Module::writeAdcRegister(uint32_t addr, uint32_t val) {
uint32_t args[]{addr, val}; uint32_t args[]{addr, val};
@ -2711,48 +2615,47 @@ int Module::activate(int enable) {
sendToDetector(F_ACTIVATE, enable, retval); sendToDetector(F_ACTIVATE, enable, retval);
sendToDetectorStop(F_ACTIVATE, enable, retval); sendToDetectorStop(F_ACTIVATE, enable, retval);
LOG(logDEBUG1) << "Activate: " << retval; LOG(logDEBUG1) << "Activate: " << retval;
shm()->activated = static_cast<bool>(retval);
if (shm()->useReceiverFlag) { if (shm()->useReceiverFlag) {
int fnum = F_RECEIVER_ACTIVATE; sendToReceiver(F_RECEIVER_ACTIVATE, retval, nullptr);
enable = static_cast<int>(shm()->activated);
retval = -1;
LOG(logDEBUG1)
<< "Setting activate flag " << enable << " to receiver";
sendToReceiver(fnum, enable, retval);
} }
return static_cast<int>(shm()->activated); return retval;
} }
bool Module::setDeactivatedRxrPaddingMode(int padding) { bool Module::getDeactivatedRxrPaddingMode() {
int fnum = F_RECEIVER_DEACTIVATED_PADDING_ENABLE; if (!shm()->useReceiverFlag) {
int retval = -1; throw RuntimeError("Set rx_hostname first to use receiver parameters (deactivated padding)");
LOG(logDEBUG1) << "Deactivated Receiver Padding Enable: " << padding; }
if (shm()->useReceiverFlag) { return sendToReceiver<int>(F_GET_RECEIVER_DEACTIVATED_PADDING);
sendToReceiver(fnum, padding, retval);
LOG(logDEBUG1) << "Deactivated Receiver Padding Enable:" << retval;
shm()->rxPadDeactivatedModules = static_cast<bool>(retval);
} else {
shm()->rxPadDeactivatedModules = padding;
}
return shm()->rxPadDeactivatedModules;
} }
bool Module::getFlippedDataX() const { return shm()->flippedDataX; } void Module::setDeactivatedRxrPaddingMode(bool padding) {
if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (deactivated padding)");
}
int arg = static_cast<int>(padding);
sendToReceiver(F_SET_RECEIVER_DEACTIVATED_PADDING, arg, nullptr);
}
void Module::setFlippedDataX(int value) { bool Module::getFlippedDataX() {
// replace get with shm value (write to shm right away as it is a det value, if (!shm()->useReceiverFlag) {
// not rx value) throw RuntimeError("Set rx_hostname first to use receiver parameters (flipped data x)");
if (value > -1) {
shm()->flippedDataX = (value > 0);
} }
int retval = -1; int retval = -1;
int arg = static_cast<int>(shm()->flippedDataX); int arg = -1;
sendToReceiver(F_SET_FLIPPED_DATA_RECEIVER, arg, retval);
LOG(logDEBUG1) << "Flipped data:" << retval;
return retval;
}
void Module::setFlippedDataX(bool value) {
if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (flipped data x)");
}
int retval = -1;
int arg = static_cast<int>(value);
LOG(logDEBUG1) << "Setting flipped data across x axis with value: " LOG(logDEBUG1) << "Setting flipped data across x axis with value: "
<< arg; << value;
if (shm()->useReceiverFlag) { sendToReceiver(F_SET_FLIPPED_DATA_RECEIVER, arg, retval);
sendToReceiver(F_SET_FLIPPED_DATA_RECEIVER, arg, retval);
LOG(logDEBUG1) << "Flipped data:" << retval;
}
} }
int Module::setAllTrimbits(int val) { int Module::setAllTrimbits(int val) {
@ -3184,101 +3087,16 @@ void Module::updateCachedReceiverVariables() const {
sls::ClientSocket("Receiver", shm()->rxHostname, shm()->rxTCPPort); sls::ClientSocket("Receiver", shm()->rxHostname, shm()->rxTCPPort);
receiver.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0); receiver.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
int n = 0, i32 = 0; int n = 0, i32 = 0;
int64_t i64 = 0;
char cstring[MAX_STR_LENGTH]{};
IpAddr ip; IpAddr ip;
n += receiver.Receive(&ip, sizeof(ip)); n += receiver.Receive(&ip, sizeof(ip));
LOG(logDEBUG1) LOG(logDEBUG1)
<< "Updating receiver last modified by " << ip; << "Updating receiver last modified by " << ip;
// filepath
n += receiver.Receive(cstring, sizeof(cstring));
sls::strcpy_safe(shm()->rxFilePath, cstring);
// filename
n += receiver.Receive(cstring, sizeof(cstring));
sls::strcpy_safe(shm()->rxFileName, cstring);
// index
n += receiver.Receive(&i64, sizeof(i64));
shm()->rxFileIndex = i64;
// file format
n += receiver.Receive(&i32, sizeof(i32));
shm()->rxFileFormat = static_cast<fileFormat>(i32);
// frames per file
n += receiver.Receive(&i32, sizeof(i32));
shm()->rxFramesPerFile = i32;
// frame discard policy
n += receiver.Receive(&i32, sizeof(i32));
shm()->rxFrameDiscardMode = static_cast<frameDiscardPolicy>(i32);
// frame padding
n += receiver.Receive(&i32, sizeof(i32));
shm()->rxFramePadding = static_cast<bool>(i32);
// file write enable
n += receiver.Receive(&i32, sizeof(i32));
shm()->rxFileWrite = static_cast<bool>(i32);
// master file write enable
n += receiver.Receive(&i32, sizeof(i32));
shm()->rxMasterFileWrite = static_cast<bool>(i32);
// file overwrite enable
n += receiver.Receive(&i32, sizeof(i32));
shm()->rxFileOverWrite = static_cast<bool>(i32);
// gap pixels // gap pixels
n += receiver.Receive(&i32, sizeof(i32)); n += receiver.Receive(&i32, sizeof(i32));
shm()->gappixels = i32; shm()->gappixels = i32;
// receiver read frequency
n += receiver.Receive(&i32, sizeof(i32));
shm()->rxReadFreq = i32;
// receiver streaming port
n += receiver.Receive(&i32, sizeof(i32));
shm()->rxZmqport = i32;
// streaming source ip
n += receiver.Receive(&ip, sizeof(ip));
shm()->rxZmqip = ip;
// additional json header
n += receiver.Receive(cstring, sizeof(cstring));
sls::strcpy_safe(shm()->rxAdditionalJsonHeader, cstring);
// receiver streaming enable
n += receiver.Receive(&i32, sizeof(i32));
shm()->rxUpstream = static_cast<bool>(i32);
// activate
n += receiver.Receive(&i32, sizeof(i32));
shm()->activated = static_cast<bool>(i32);
// deactivated padding enable
n += receiver.Receive(&i32, sizeof(i32));
shm()->rxPadDeactivatedModules = static_cast<bool>(i32);
// silent mode
n += receiver.Receive(&i32, sizeof(i32));
shm()->rxSilentMode = static_cast<bool>(i32);
// dbit list
{
sls::FixedCapacityContainer<int, MAX_RX_DBIT> temp;
n += receiver.Receive(&temp, sizeof(temp));
shm()->rxDbitList = temp;
}
// dbit offset
n += receiver.Receive(&i32, sizeof(i32));
shm()->rxDbitOffset = i32;
if (n == 0) { if (n == 0) {
throw RuntimeError( throw RuntimeError(
"Could not update receiver: " + std::string(shm()->rxHostname) + "Could not update receiver: " + std::string(shm()->rxHostname) +
@ -3319,137 +3137,128 @@ void Module::setDetectorHostname() {
} }
} }
std::string Module::getFilePath() { return shm()->rxFilePath; } std::string Module::getFilePath() {
if (!shm()->useReceiverFlag) {
std::string Module::setFilePath(const std::string &path) { throw RuntimeError("Set rx_hostname first to use receiver parameters (file path)");
if (!path.empty()) { }
char args[MAX_STR_LENGTH]{}; char retvals[MAX_STR_LENGTH]{};
char retvals[MAX_STR_LENGTH]{}; sendToReceiver(F_GET_RECEIVER_FILE_PATH, nullptr, retvals);
sls::strcpy_safe(args, path.c_str()); return std::string(retvals);
LOG(logDEBUG1) << "Sending file path to receiver: " << args;
if (shm()->useReceiverFlag) {
sendToReceiver(F_SET_RECEIVER_FILE_PATH, args, retvals);
LOG(logDEBUG1) << "Receiver file path: " << retvals;
sls::strcpy_safe(shm()->rxFilePath, retvals);
} else {
sls::strcpy_safe(shm()->rxFilePath, args);
}
}
return shm()->rxFilePath;
} }
std::string Module::getFileName() { return shm()->rxFileName; } void Module::setFilePath(const std::string &path) {
if (!shm()->useReceiverFlag) {
std::string Module::setFileName(const std::string &fname) { throw RuntimeError("Set rx_hostname first to use receiver parameters (file path)");
if (!fname.empty()) { }
char args[MAX_STR_LENGTH]{}; if (path.empty()) {
char retvals[MAX_STR_LENGTH]{}; throw RuntimeError("Cannot set empty file path");
sls::strcpy_safe(args, fname.c_str());
LOG(logDEBUG1) << "Sending file name to receiver: " << args;
if (shm()->useReceiverFlag) {
sendToReceiver(F_SET_RECEIVER_FILE_NAME, args, retvals);
LOG(logDEBUG1) << "Receiver file name: " << retvals;
sls::strcpy_safe(shm()->rxFileName, retvals);
} else {
sls::strcpy_safe(shm()->rxFileName, args);
}
} }
return shm()->rxFileName; char args[MAX_STR_LENGTH]{};
sls::strcpy_safe(args, path.c_str());
sendToReceiver(F_SET_RECEIVER_FILE_PATH, args, nullptr);
} }
int Module::setFramesPerFile(int n_frames) { std::string Module::getFileName() {
if (n_frames >= 0) { if (!shm()->useReceiverFlag) {
LOG(logDEBUG1) throw RuntimeError("Set rx_hostname first to use receiver parameters (file name prefix)");
<< "Setting receiver frames per file to " << n_frames; }
if (shm()->useReceiverFlag) { char retvals[MAX_STR_LENGTH]{};
int retval = -1; sendToReceiver(F_GET_RECEIVER_FILE_NAME, nullptr, retvals);
sendToReceiver(F_SET_RECEIVER_FRAMES_PER_FILE, n_frames, retval); return std::string(retvals);
LOG(logDEBUG1) << "Receiver frames per file: " << retval;
shm()->rxFramesPerFile = retval;
} else {
shm()->rxFramesPerFile = n_frames;
}
}
return getFramesPerFile();
} }
int Module::getFramesPerFile() const { return shm()->rxFramesPerFile; } void Module::setFileName(const std::string &fname) {
if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (file name prefix)");
}
if (fname.empty()) {
throw RuntimeError("Cannot set empty file name prefix");
}
char args[MAX_STR_LENGTH]{};
sls::strcpy_safe(args, fname.c_str());
sendToReceiver(F_SET_RECEIVER_FILE_NAME, args, nullptr);
}
slsDetectorDefs::frameDiscardPolicy int64_t Module::getFileIndex() {
Module::setReceiverFramesDiscardPolicy(frameDiscardPolicy f) { if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (file index)");
}
return sendToReceiver<int64_t>(F_GET_RECEIVER_FILE_INDEX);
}
void Module::setFileIndex(int64_t file_index) {
if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (file index)");
}
sendToReceiver(F_SET_RECEIVER_FILE_INDEX, file_index, nullptr);
}
void Module::incrementFileIndex() {
if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (increment file index)");
}
sendToReceiver(F_INCREMENT_FILE_INDEX, nullptr, nullptr);
}
slsDetectorDefs::fileFormat Module::getFileFormat() {
if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (file format)");
}
return static_cast<fileFormat>(
sendToReceiver<int>(F_GET_RECEIVER_FILE_FORMAT));
}
void Module::setFileFormat(fileFormat f) {
if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (file format)");
}
int arg = static_cast<int>(f); int arg = static_cast<int>(f);
LOG(logDEBUG1) << "Setting receiver frames discard policy to " << arg; sendToReceiver(F_SET_RECEIVER_FILE_FORMAT, arg, nullptr);
if (shm()->useReceiverFlag) {
auto retval = static_cast<frameDiscardPolicy>(-1);
sendToReceiver(F_RECEIVER_DISCARD_POLICY, arg, retval);
LOG(logDEBUG1) << "Receiver frames discard policy: " << retval;
shm()->rxFrameDiscardMode = retval;
} else {
shm()->rxFrameDiscardMode = f;
}
return shm()->rxFrameDiscardMode;
} }
bool Module::setPartialFramesPadding(bool padding) { int Module::getFramesPerFile() {
if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (frames per file)");
}
return sendToReceiver<int>(F_GET_RECEIVER_FRAMES_PER_FILE);
}
void Module::setFramesPerFile(int n_frames) {
if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (frames per file)");
}
sendToReceiver(F_SET_RECEIVER_FRAMES_PER_FILE, n_frames, nullptr);
}
slsDetectorDefs::frameDiscardPolicy Module::getReceiverFramesDiscardPolicy() {
if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (frame discard policy)");
}
return static_cast<frameDiscardPolicy>(
sendToReceiver<int>(F_GET_RECEIVER_DISCARD_POLICY));
}
void Module::setReceiverFramesDiscardPolicy(frameDiscardPolicy f) {
if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (frame discard policy)");
}
int arg = static_cast<int>(f);
sendToReceiver(F_SET_RECEIVER_DISCARD_POLICY, arg, nullptr);
}
bool Module::getPartialFramesPadding() {
if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (frame padding)");
}
return sendToReceiver<int>(F_GET_RECEIVER_PADDING);
}
void Module::setPartialFramesPadding(bool padding) {
if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (frame padding)");
}
int arg = static_cast<int>(padding); int arg = static_cast<int>(padding);
int retval = static_cast<int>(padding); sendToReceiver(F_SET_RECEIVER_PADDING, arg, nullptr);
LOG(logDEBUG1) << "Setting receiver partial frames enable to " << arg;
if (shm()->useReceiverFlag) {
sendToReceiver(F_RECEIVER_PADDING_ENABLE, arg, retval);
LOG(logDEBUG1) << "Receiver partial frames enable: " << retval;
shm()->rxFramePadding = static_cast<bool>(retval);
} else {
shm()->rxFramePadding = padding;
}
return getPartialFramesPadding();
}
bool Module::getPartialFramesPadding() const {
return shm()->rxFramePadding;
}
slsDetectorDefs::fileFormat Module::setFileFormat(fileFormat f) {
if (f != GET_FILE_FORMAT) {
auto arg = static_cast<int>(f);
auto retval = static_cast<fileFormat>(-1);
LOG(logDEBUG1) << "Setting receiver file format to " << arg;
if (shm()->useReceiverFlag) {
sendToReceiver(F_SET_RECEIVER_FILE_FORMAT, arg, retval);
LOG(logDEBUG1) << "Receiver file format: " << retval;
shm()->rxFileFormat = retval;
} else {
shm()->rxFileFormat = f;
}
}
return getFileFormat();
}
slsDetectorDefs::fileFormat Module::getFileFormat() const {
return shm()->rxFileFormat;
}
int64_t Module::setFileIndex(int64_t file_index) {
if (file_index >= 0) {
int64_t retval = -1;
LOG(logDEBUG1) << "Setting file index to " << file_index;
if (shm()->useReceiverFlag) {
sendToReceiver(F_SET_RECEIVER_FILE_INDEX, file_index, retval);
LOG(logDEBUG1) << "Receiver file index: " << retval;
shm()->rxFileIndex = retval;
} else {
shm()->rxFileIndex = file_index;
}
}
return getFileIndex();
}
int64_t Module::getFileIndex() const { return shm()->rxFileIndex; }
int64_t Module::incrementFileIndex() {
if (shm()->rxFileWrite) {
return setFileIndex(shm()->rxFileIndex + 1);
}
return shm()->rxFileIndex;
} }
void Module::startReceiver() { void Module::startReceiver() {
@ -3527,70 +3336,66 @@ uint64_t Module::getReceiverCurrentFrameIndex() const {
return retval; return retval;
} }
bool Module::setFileWrite(bool value) { void Module::setFileWrite(bool value) {
if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (file write enable)");
}
int arg = static_cast<int>(value); int arg = static_cast<int>(value);
int retval = -1; sendToReceiver(F_SET_RECEIVER_FILE_WRITE, arg, nullptr);
LOG(logDEBUG1) << "Sending enable file write to receiver: " << arg;
if (shm()->useReceiverFlag) {
sendToReceiver(F_ENABLE_RECEIVER_FILE_WRITE, arg, retval);
LOG(logDEBUG1) << "Receiver file write enable: " << retval;
shm()->rxFileWrite = static_cast<bool>(retval);
} else {
shm()->rxFileWrite = value;
}
return getFileWrite();
} }
bool Module::getFileWrite() const { return shm()->rxFileWrite; } bool Module::getFileWrite() {
if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (file_write enable)");
}
return sendToReceiver<int>(F_GET_RECEIVER_FILE_WRITE);
}
bool Module::setMasterFileWrite(bool value) { void Module::setMasterFileWrite(bool value) {
if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (master file write enable)");
}
int arg = static_cast<int>(value); int arg = static_cast<int>(value);
int retval = -1; sendToReceiver(F_SET_RECEIVER_MASTER_FILE_WRITE, arg, nullptr);
LOG(logDEBUG1) << "Sending enable master file write to receiver: "
<< arg;
if (shm()->useReceiverFlag) {
sendToReceiver(F_ENABLE_RECEIVER_MASTER_FILE_WRITE, arg, retval);
LOG(logDEBUG1) << "Receiver master file write enable: " << retval;
shm()->rxMasterFileWrite = static_cast<bool>(retval);
} else {
shm()->rxMasterFileWrite = value;
}
return getMasterFileWrite();
} }
bool Module::getMasterFileWrite() const { bool Module::getMasterFileWrite() {
return shm()->rxMasterFileWrite; if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (master file write enable)");
}
return sendToReceiver<int>(F_GET_RECEIVER_MASTER_FILE_WRITE);
} }
bool Module::setFileOverWrite(bool value) { void Module::setFileOverWrite(bool value) {
if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (file overwrite enable)");
}
int arg = static_cast<int>(value); int arg = static_cast<int>(value);
int retval = -1; sendToReceiver(F_SET_RECEIVER_OVERWRITE, arg, nullptr);
LOG(logDEBUG1) << "Sending enable file overwrite to receiver: " << arg;
if (shm()->useReceiverFlag) {
sendToReceiver(F_ENABLE_RECEIVER_OVERWRITE, arg, retval);
LOG(logDEBUG1) << "Receiver file overwrite enable: " << retval;
shm()->rxFileOverWrite = static_cast<bool>(retval);
} else {
shm()->rxFileOverWrite = value;
}
return getFileOverWrite();
} }
bool Module::getFileOverWrite() const { return shm()->rxFileOverWrite; } bool Module::getFileOverWrite() {
if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (file overwrite enable)");
}
return sendToReceiver<int>(F_GET_RECEIVER_OVERWRITE);
}
int Module::setReceiverStreamingFrequency(int freq) { int Module::getReceiverStreamingFrequency() {
if (freq >= 0) { if (!shm()->useReceiverFlag) {
LOG(logDEBUG1) << "Sending read frequency to receiver: " << freq; throw RuntimeError("Set rx_hostname first to use receiver parameters (streaming/read frequency)");
if (shm()->useReceiverFlag) {
int retval = -1;
sendToReceiver(F_RECEIVER_STREAMING_FREQUENCY, freq, retval);
LOG(logDEBUG1) << "Receiver read frequency: " << retval;
shm()->rxReadFreq = retval;
} else {
shm()->rxReadFreq = freq;
}
} }
return shm()->rxReadFreq; return sendToReceiver<int>(F_GET_RECEIVER_STREAMING_FREQUENCY);
}
void Module::setReceiverStreamingFrequency(int freq) {
if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (streaming/read frequency)");
}
if (freq < 0) {
throw RuntimeError("Invalid streaming frequency " + std::to_string(freq));
}
sendToReceiver(F_SET_RECEIVER_STREAMING_FREQUENCY, freq, nullptr);
} }
int Module::setReceiverStreamingTimer(int time_in_ms) { int Module::setReceiverStreamingTimer(int time_in_ms) {
@ -3603,19 +3408,19 @@ int Module::setReceiverStreamingTimer(int time_in_ms) {
return retval; return retval;
} }
bool Module::enableDataStreamingFromReceiver(int enable) { bool Module::getReceiverStreaming() {
if (enable >= 0) { if (!shm()->useReceiverFlag) {
LOG(logDEBUG1) << "Sending Data Streaming to receiver: " << enable; throw RuntimeError("Set rx_hostname first to get receiver parameters (zmq enable)");
if (shm()->useReceiverFlag) {
int retval = -1;
sendToReceiver(F_STREAM_DATA_FROM_RECEIVER, enable, retval);
LOG(logDEBUG1) << "Receiver Data Streaming: " << retval;
shm()->rxUpstream = static_cast<bool>(retval);
} else {
shm()->rxUpstream = enable;
}
} }
return shm()->rxUpstream; return sendToReceiver<int>(F_GET_RECEIVER_STREAMING);
}
void Module::setReceiverStreaming(bool enable) {
if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (zmq enable)");
}
int arg = static_cast<int>(enable);
sendToReceiver(F_SET_RECEIVER_STREAMING, arg, nullptr);
} }
bool Module::enableTenGigabitEthernet(int value) { bool Module::enableTenGigabitEthernet(int value) {
@ -3643,17 +3448,19 @@ int Module::setReceiverFifoDepth(int n_frames) {
return retval; return retval;
} }
bool Module::setReceiverSilentMode(int value) { bool Module::getReceiverSilentMode() {
LOG(logDEBUG1) << "Sending Receiver Silent Mode: " << value; if (!shm()->useReceiverFlag) {
if (shm()->useReceiverFlag) { throw RuntimeError("Set rx_hostname first to use receiver parameters (silent mode)");
int retval = -1; }
sendToReceiver(F_SET_RECEIVER_SILENT_MODE, value, retval); return sendToReceiver<int>(F_GET_RECEIVER_SILENT_MODE);
LOG(logDEBUG1) << "Receiver Data Streaming: " << retval; }
shm()->rxSilentMode = static_cast<bool>(retval);
} else { void Module::setReceiverSilentMode(bool enable) {
shm()->rxSilentMode = value; if (!shm()->useReceiverFlag) {
} throw RuntimeError("Set rx_hostname first to use receiver parameters (silent mode)");
return shm()->rxSilentMode; }
int arg = static_cast<int>(enable);
sendToReceiver(F_SET_RECEIVER_SILENT_MODE, arg, nullptr);
} }
void Module::restreamStopFromReceiver() { void Module::restreamStopFromReceiver() {

View File

@ -13,7 +13,7 @@
class ServerInterface; class ServerInterface;
#define SLS_SHMAPIVERSION 0x190726 #define SLS_SHMAPIVERSION 0x190726
#define SLS_SHMVERSION 0x200309 #define SLS_SHMVERSION 0x200318
namespace sls{ namespace sls{
@ -98,81 +98,18 @@ struct sharedSlsDetector {
* unset if socket connection is not possible */ * unset if socket connection is not possible */
bool useReceiverFlag; bool useReceiverFlag;
/** flipped data across x or y axis */
bool flippedDataX;
/** tcp port from gui/different process to receiver (only data) */ /** tcp port from gui/different process to receiver (only data) */
int zmqport; int zmqport;
/** tcp port from receiver to gui/different process (only data) */
int rxZmqport;
/** data streaming (up stream) enable in receiver
* (needed for restreaming dummy packet) */
bool rxUpstream;
/* Receiver read frequency */
int rxReadFreq;
/** zmq tcp src ip address in client (only data) **/ /** zmq tcp src ip address in client (only data) **/
sls::IpAddr zmqip; sls::IpAddr zmqip;
/** zmq tcp src ip address in receiver (only data) **/
sls::IpAddr rxZmqip;
/** gap pixels enable */ /** gap pixels enable */
int gappixels; int gappixels;
/** gap pixels in each direction */ /** gap pixels in each direction */
slsDetectorDefs::xy nGappixels; slsDetectorDefs::xy nGappixels;
/** additional json header */
char rxAdditionalJsonHeader[MAX_STR_LENGTH];
/** receiver frames discard policy */
slsDetectorDefs::frameDiscardPolicy rxFrameDiscardMode;
/** receiver partial frames padding enable */
bool rxFramePadding;
/** activated receiver */
bool activated;
/** padding enable in deactivated receiver */
bool rxPadDeactivatedModules;
/** silent receiver */
bool rxSilentMode;
/** path of the output files */
char rxFilePath[MAX_STR_LENGTH];
/** file name prefix */
char rxFileName[MAX_STR_LENGTH];
/** file index */
int64_t rxFileIndex;
/** file format */
slsDetectorDefs::fileFormat rxFileFormat;
/** frames per file */
int rxFramesPerFile;
/** file write enable */
bool rxFileWrite;
/** master file write enable */
bool rxMasterFileWrite;
/** overwrite enable */
bool rxFileOverWrite;
sls::FixedCapacityContainer<int, MAX_RX_DBIT> rxDbitList;
/** reciever dbit offset */
int rxDbitOffset;
/** num udp interfaces */ /** num udp interfaces */
int numUDPInterfaces; int numUDPInterfaces;
@ -1054,10 +991,8 @@ class Module : public virtual slsDetectorDefs {
/** /**
* Sets the additional json header\sa sharedSlsDetector * Sets the additional json header\sa sharedSlsDetector
* @param jsonheader additional json header * @param jsonheader additional json header
* @returns additional json header, returns "none" if default setting and no
* custom ip set
*/ */
std::string setAdditionalJsonHeader(const std::string &jsonheader); void setAdditionalJsonHeader(const std::string &jsonheader);
/** /**
* Returns the additional json header \sa sharedSlsDetector * Returns the additional json header \sa sharedSlsDetector
@ -1247,31 +1182,12 @@ class Module : public virtual slsDetectorDefs {
*/ */
int getExternalSampling(); int getExternalSampling();
/** /** digital data bits enable (CTB only) */
* Set external sampling enable (CTB only)
* @param list external sampling source (Option: 0-63)
* @param detPos -1 for all detectors in list or specific detector position
*/
void setReceiverDbitList(const std::vector<int>& list); void setReceiverDbitList(const std::vector<int>& list);
/**
* Get external sampling source (CTB only)
* @param detPos -1 for all detectors in list or specific detector position
* @returns external sampling enable
*/
std::vector<int> getReceiverDbitList() const; std::vector<int> getReceiverDbitList() const;
/** /** Set digital data offset in bytes (CTB only) */
* Set digital data offset in bytes (CTB only) void setReceiverDbitOffset(int value);
* @param value digital data offset in bytes
* @returns digital data offset in bytes
*/
int setReceiverDbitOffset(int value);
/**
* Get digital data offset in bytes (CTB only)
* @returns digital data offset in bytes
*/
int getReceiverDbitOffset(); int getReceiverDbitOffset();
/** /**
@ -1289,27 +1205,25 @@ class Module : public virtual slsDetectorDefs {
*/ */
int activate(int const enable = -1); int activate(int const enable = -1);
bool getDeactivatedRxrPaddingMode();
/** /**
* Set deactivated Receiver padding mode (Eiger only) * Set deactivated Receiver padding mode (Eiger only)
* @param padding padding option for deactivated receiver. Can be 1
* (padding), 0 (no padding), -1 (gets)
* @returns 1 (padding), 0 (no padding), -1 (inconsistent values) for
* padding option
*/ */
bool setDeactivatedRxrPaddingMode(int padding = -1); void setDeactivatedRxrPaddingMode(bool padding);
/** /**
* Returns the enable if data will be flipped across x axis (Eiger) * Returns the enable if data will be flipped across x axis (Eiger)
* @returns if flipped across x axis * @returns if flipped across x axis
*/ */
bool getFlippedDataX() const; bool getFlippedDataX();
/** /**
* Sets the enable which determines if * Sets the enable which determines if
* data will be flipped across x axis (Eiger) * data will be flipped across x axis (Eiger)
* @param value 0 or 1 to reset/set or -1 to get value * @param value 0 or 1 to reset/set
*/ */
void setFlippedDataX(int value = -1); void setFlippedDataX(bool value);
/** /**
* Sets all the trimbits to a particular value (Eiger) * Sets all the trimbits to a particular value (Eiger)
@ -1546,88 +1460,24 @@ class Module : public virtual slsDetectorDefs {
*/ */
void setDetectorHostname(); void setDetectorHostname();
/**
* Returns output file directory
* @returns output file directory
*/
std::string getFilePath(); std::string getFilePath();
void setFilePath(const std::string &path);
/**
* Sets up the file directory
* @param s file directory
* @returns file dir
*/
std::string setFilePath(const std::string &path);
/**
* Returns file name prefix
* @returns file name prefix
*/
std::string getFileName(); std::string getFileName();
void setFileName(const std::string &fname);
int64_t getFileIndex();
void setFileIndex(int64_t file_index);
void incrementFileIndex();
fileFormat getFileFormat() ;
void setFileFormat(fileFormat f);
int getFramesPerFile();
/** 0 will set frames per file to unlimited */
void setFramesPerFile(int n_frames);
frameDiscardPolicy getReceiverFramesDiscardPolicy();
void setReceiverFramesDiscardPolicy(frameDiscardPolicy f);
bool getPartialFramesPadding();
void setPartialFramesPadding(bool padding);
/**
* Sets up the file name prefix
* @param s file name prefix
* @returns file name prefix
*/
std::string setFileName(const std::string &fname);
/**
* Sets the max frames per file in receiver
* @param f max frames per file
* @returns max frames per file in receiver
*/
int setFramesPerFile(int n_frames);
int getFramesPerFile() const;
/**
* Sets the frames discard policy in receiver
* @param f frames discard policy
* @returns frames discard policy set in receiver
*/
frameDiscardPolicy setReceiverFramesDiscardPolicy(
frameDiscardPolicy f = GET_FRAME_DISCARD_POLICY);
/**
* Sets the partial frames padding enable in receiver
* @param f partial frames padding enable
* @returns partial frames padding enable in receiver
*/
bool setPartialFramesPadding(bool padding);
bool getPartialFramesPadding() const;
/**
* Returns file format
* @returns file format
*/
fileFormat getFileFormat() const;
/**
* Sets up the file format
* @param f file format
* @returns file format
*/
fileFormat setFileFormat(fileFormat f);
/**
* Sets up the file index
* @param i file index
* @returns file index
*/
int64_t setFileIndex(int64_t file_index);
/**
* Gets the file index
* @returns file index
*/
int64_t getFileIndex() const;
/**
* increments file index
* @returns the file index
*/
int64_t incrementFileIndex();
/** /**
* Receiver starts listening to packets * Receiver starts listening to packets
@ -1660,44 +1510,15 @@ class Module : public virtual slsDetectorDefs {
*/ */
uint64_t getReceiverCurrentFrameIndex() const; uint64_t getReceiverCurrentFrameIndex() const;
/**
* Sets/Gets receiver file write enable
* @param enable 1 or 0 to set/reset file write enable
* @returns file write enable
*/
bool setFileWrite(bool value);
/** void setFileWrite(bool value);
* Gets file write enable bool getFileWrite();
* @returns file write enable void setMasterFileWrite(bool value);
*/ bool getMasterFileWrite();
bool getFileWrite() const; void setFileOverWrite(bool value);
bool getFileOverWrite();
/** int getReceiverStreamingFrequency();
* Sets/Gets receiver master file write enable
* @param value 1 or 0 to set/reset master file write enable
* @returns master file write enable
*/
bool setMasterFileWrite(bool value);
/**
* Gets master file write enable
* @returns master file write enable
*/
bool getMasterFileWrite() const;
/**
* Sets file overwrite in the receiver
* @param enable true or false to set/reset file overwrite enable
* @returns file overwrite enable
*/
bool setFileOverWrite(bool value);
/**
* Gets file overwrite in the receiver
* @returns file overwrite enable
*/
bool getFileOverWrite() const;
/** /**
* (previously setReadReceiverFrequency) * (previously setReadReceiverFrequency)
@ -1705,9 +1526,8 @@ class Module : public virtual slsDetectorDefs {
* @param freq nth frame streamed out, if 0, streamed out at a timer of 200 * @param freq nth frame streamed out, if 0, streamed out at a timer of 200
* ms * ms
* @param detPos -1 for all detectors in list or specific detector position * @param detPos -1 for all detectors in list or specific detector position
* @returns receiver streaming frequency
*/ */
int setReceiverStreamingFrequency(int freq = -1); void setReceiverStreamingFrequency(int freq);
/** /**
* (previously setReceiverReadTimer) * (previously setReceiverReadTimer)
@ -1719,12 +1539,9 @@ class Module : public virtual slsDetectorDefs {
*/ */
int setReceiverStreamingTimer(int time_in_ms = 200); int setReceiverStreamingTimer(int time_in_ms = 200);
/** bool getReceiverStreaming();
* Enable or disable streaming data from receiver to client
* @param enable 0 to disable 1 to enable -1 to only get the value void setReceiverStreaming(bool enable);
* @returns data streaming from receiver enable
*/
bool enableDataStreamingFromReceiver(int enable = -1);
/** /**
* Enable/disable or 10Gbe * Enable/disable or 10Gbe
@ -1740,12 +1557,8 @@ class Module : public virtual slsDetectorDefs {
*/ */
int setReceiverFifoDepth(int n_frames = -1); int setReceiverFifoDepth(int n_frames = -1);
/** bool getReceiverSilentMode();
* Set/get receiver silent mode void setReceiverSilentMode(bool enable);
* @param i is -1 to get, 0 unsets silent mode, 1 sets silent mode
* @returns the receiver silent mode enable
*/
bool setReceiverSilentMode(int value = -1);
/** /**
* If data streaming in receiver is enabled, * If data streaming in receiver is enabled,

View File

@ -272,7 +272,7 @@ TEST_CASE("burstperiod", "[.cmd]") {
REQUIRE(oss_set.str() == "burstperiod 30ms\n"); REQUIRE(oss_set.str() == "burstperiod 30ms\n");
proxy.Call("burstperiod", {}, -1, GET, oss_get); proxy.Call("burstperiod", {}, -1, GET, oss_get);
REQUIRE(oss_get.str() == "burstperiod 30ms\n"); REQUIRE(oss_get.str() == "burstperiod 30ms\n");
// Reset all dacs to previous value // Reset to previous value
for (int i = 0; i != det.size(); ++i) { for (int i = 0; i != det.size(); ++i) {
det.setBurstPeriod(previous[i], {i}); det.setBurstPeriod(previous[i], {i});
} }

View File

@ -29,7 +29,7 @@ python/scripts/list_tested_cmd.py to check if all commands are covered
// std::cout << "end\n"; // std::cout << "end\n";
// } // }
TEST_CASE("rx_hostname", "[.cmd]") { TEST_CASE("rx_hostname", "[.cmd][.rx]") {
// TODO! find a proper way to test, now we read out the rx_hostname // TODO! find a proper way to test, now we read out the rx_hostname
// and then put it to see that we don't crash // and then put it to see that we don't crash
Detector det; Detector det;
@ -72,7 +72,7 @@ TEST_CASE("rx_hostname", "[.cmd]") {
} }
} }
TEST_CASE("rx_framescaught", "[.cmd]") { TEST_CASE("rx_framescaught", "[.cmd][.rx]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
@ -97,7 +97,7 @@ TEST_CASE("rx_framescaught", "[.cmd]") {
// } // }
} }
TEST_CASE("rx_status", "[.cmd]") { TEST_CASE("rx_status", "[.cmd][.rx]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
std::ostringstream oss; std::ostringstream oss;
@ -105,7 +105,7 @@ TEST_CASE("rx_status", "[.cmd]") {
REQUIRE(oss.str() == "rx_status idle\n"); REQUIRE(oss.str() == "rx_status idle\n");
} }
TEST_CASE("rx_version", "[.cmd]") { TEST_CASE("rx_version", "[.cmd][.rx]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
std::ostringstream oss; std::ostringstream oss;
@ -115,7 +115,7 @@ TEST_CASE("rx_version", "[.cmd]") {
REQUIRE(oss.str() == vs.str()); REQUIRE(oss.str() == vs.str());
} }
TEST_CASE("rx_start", "[.cmd]") { TEST_CASE("rx_start", "[.cmd][.rx]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
// PUT only command // PUT only command
@ -132,7 +132,7 @@ TEST_CASE("rx_start", "[.cmd]") {
} }
} }
TEST_CASE("rx_stop", "[.cmd]") { TEST_CASE("rx_stop", "[.cmd][.rx]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
// PUT only command // PUT only command
@ -149,7 +149,7 @@ TEST_CASE("rx_stop", "[.cmd]") {
} }
} }
TEST_CASE("rx_missingpackets", "[.cmd]") { TEST_CASE("rx_missingpackets", "[.cmd][.rx]") {
// TODO! This only tests for no crash how can we test // TODO! This only tests for no crash how can we test
// for correct values? // for correct values?
Detector det; Detector det;
@ -157,7 +157,7 @@ TEST_CASE("rx_missingpackets", "[.cmd]") {
proxy.Call("rx_missingpackets", {}, -1, GET); proxy.Call("rx_missingpackets", {}, -1, GET);
} }
TEST_CASE("rx_frameindex", "[.cmd]") { TEST_CASE("rx_frameindex", "[.cmd][.rx]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
proxy.Call("rx_frameindex", {}, -1, GET); proxy.Call("rx_frameindex", {}, -1, GET);
@ -166,7 +166,7 @@ TEST_CASE("rx_frameindex", "[.cmd]") {
REQUIRE_THROWS(proxy.Call("rx_frameindex", {"2"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("rx_frameindex", {"2"}, -1, PUT));
} }
TEST_CASE("rx_lastclient", "[.cmd]") { TEST_CASE("rx_lastclient", "[.cmd][.rx]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
std::ostringstream oss; std::ostringstream oss;
@ -174,13 +174,13 @@ TEST_CASE("rx_lastclient", "[.cmd]") {
REQUIRE(oss.str() == "rx_lastclient " + test::my_ip + "\n"); REQUIRE(oss.str() == "rx_lastclient " + test::my_ip + "\n");
} }
TEST_CASE("rx_printconfig", "[.cmd]") { TEST_CASE("rx_printconfig", "[.cmd][.rx]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
proxy.Call("rx_printconfig", {}, -1, GET); proxy.Call("rx_printconfig", {}, -1, GET);
} }
TEST_CASE("rx_fifodepth", "[.cmd]") { TEST_CASE("rx_fifodepth", "[.cmd][.rx]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
int prev_val = det.getRxFifoDepth().squash(); int prev_val = det.getRxFifoDepth().squash();
@ -203,7 +203,7 @@ TEST_CASE("rx_fifodepth", "[.cmd]") {
det.setRxFifoDepth(prev_val); det.setRxFifoDepth(prev_val);
} }
TEST_CASE("rx_silent", "[.cmd]") { TEST_CASE("rx_silent", "[.cmd][.rx]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
{ {
@ -223,7 +223,7 @@ TEST_CASE("rx_silent", "[.cmd]") {
} }
} }
TEST_CASE("rx_jsonaddheader", "[.cmd]") { TEST_CASE("rx_jsonaddheader", "[.cmd][.rx]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
@ -244,7 +244,7 @@ TEST_CASE("rx_jsonaddheader", "[.cmd]") {
} }
} }
TEST_CASE("rx_udpsocksize", "[.cmd]") { TEST_CASE("rx_udpsocksize", "[.cmd][.rx]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
{ {
@ -259,7 +259,7 @@ TEST_CASE("rx_udpsocksize", "[.cmd]") {
} }
} }
TEST_CASE("rx_realudpsocksize", "[.cmd]") { TEST_CASE("rx_realudpsocksize", "[.cmd][.rx]") {
// TODO! Is the real socket size always twice? // TODO! Is the real socket size always twice?
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
@ -279,7 +279,7 @@ TEST_CASE("rx_realudpsocksize", "[.cmd]") {
} }
} }
TEST_CASE("rx_framesperfile", "[.cmd]") { TEST_CASE("rx_framesperfile", "[.cmd][.rx]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
{ {
@ -299,7 +299,7 @@ TEST_CASE("rx_framesperfile", "[.cmd]") {
} }
} }
TEST_CASE("rx_discardpolicy", "[.cmd]") { TEST_CASE("rx_discardpolicy", "[.cmd][.rx]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
{ {
@ -324,7 +324,7 @@ TEST_CASE("rx_discardpolicy", "[.cmd]") {
} }
} }
TEST_CASE("rx_padding", "[.cmd]") { TEST_CASE("rx_padding", "[.cmd][.rx]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
{ {
@ -344,7 +344,7 @@ TEST_CASE("rx_padding", "[.cmd]") {
} }
} }
TEST_CASE("rx_readfreq", "[.cmd]") { TEST_CASE("rx_readfreq", "[.cmd][.rx]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
{ {
@ -364,7 +364,7 @@ TEST_CASE("rx_readfreq", "[.cmd]") {
} }
} }
TEST_CASE("rx_lock", "[.cmd]") { TEST_CASE("rx_lock", "[.cmd][.rx]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
{ {
@ -384,7 +384,7 @@ TEST_CASE("rx_lock", "[.cmd]") {
} }
} }
TEST_CASE("rx_zmqport", "[.cmd]") { TEST_CASE("rx_zmqport", "[.cmd][.rx]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
int socketsperdetector = 1; int socketsperdetector = 1;
@ -419,7 +419,7 @@ TEST_CASE("rx_zmqport", "[.cmd]") {
} }
} }
TEST_CASE("rx_datastream", "[.cmd]") { TEST_CASE("rx_datastream", "[.cmd][.rx]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
{ {
@ -441,7 +441,7 @@ TEST_CASE("rx_datastream", "[.cmd]") {
} }
} }
TEST_CASE("rx_tcpport", "[.cmd]") { TEST_CASE("rx_tcpport", "[.cmd][.rx]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
@ -463,7 +463,7 @@ TEST_CASE("rx_tcpport", "[.cmd]") {
} }
} }
TEST_CASE("rx_zmqip", "[.cmd]") { TEST_CASE("rx_zmqip", "[.cmd][.rx]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
{ {
@ -479,3 +479,67 @@ TEST_CASE("rx_zmqip", "[.cmd]") {
} }
} }
TEST_CASE("rx_dbitoffset", "[.cmd][.rx]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
auto previous = det.getRxDbitOffset();
{
std::ostringstream oss;
proxy.Call("rx_dbitoffset", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "rx_dbitoffset 1\n");
}
{
std::ostringstream oss;
proxy.Call("rx_dbitoffset", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "rx_dbitoffset 0\n");
}
{
std::ostringstream oss;
proxy.Call("rx_dbitoffset", {"15"}, -1, PUT, oss);
REQUIRE(oss.str() == "rx_dbitoffset 15\n");
}
{
std::ostringstream oss;
proxy.Call("rx_dbitoffset", {}, -1, GET, oss);
REQUIRE(oss.str() == "rx_dbitoffset 15\n");
}
// Reset to previous value
for (int i = 0; i != det.size(); ++i) {
det.setRxDbitOffset(previous[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("rx_dbitoffset", {}, -1, GET));
}
}
TEST_CASE("rx_dbitlist", "[.cmd][.rx]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
auto previous = det.getRxDbitList();
{
std::ostringstream oss;
proxy.Call("rx_dbitlist", {"0", "4", "5", "8", "9", "10", "52", "63"}, -1, PUT, oss);
REQUIRE(oss.str() == "rx_dbitlist [0, 4, 5, 8, 9, 10, 52, 63]\n");
}
{
std::ostringstream oss;
proxy.Call("rx_dbitlist", {}, -1, GET, oss);
REQUIRE(oss.str() == "rx_dbitlist [0, 4, 5, 8, 9, 10, 52, 63]\n");
}
REQUIRE_THROWS(proxy.Call("rx_dbitlist", {"67"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("rx_dbitlist", {"-1"}, -1, PUT));
REQUIRE_NOTHROW(proxy.Call("rx_dbitlist", {"all"}, -1, PUT));
// Reset to previous value
for (int i = 0; i != det.size(); ++i) {
det.setRxDbitList(previous[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("rx_dbitlist", {}, -1, GET));
}
}

View File

@ -709,54 +709,6 @@ TEST_CASE("stopport", "[.cmd]") {
// } // }
// } // }
// TEST_CASE("rx_dbitoffset", "[.cmd][.ctb]") {
// if (test::type == slsDetectorDefs::CHIPTESTBOARD) {
// {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("rx_dbitoffset 1", PUT,
// nullptr, oss)); REQUIRE(oss.str() == "rx_dbitoffset 1\n");
// }
// {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("rx_dbitoffset 0", PUT,
// nullptr, oss)); REQUIRE(oss.str() == "rx_dbitoffset 0\n");
// }
// {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("rx_dbitoffset 15", PUT,
// nullptr, oss)); REQUIRE(oss.str() == "rx_dbitoffset 15\n");
// }
// {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("rx_dbitoffset", GET,
// nullptr, oss)); REQUIRE(oss.str() == "rx_dbitoffset 15\n");
// }
// REQUIRE_NOTHROW(multiSlsDetectorClient("rx_dbitoffset 0", PUT));
// } else {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("rx_dbitoffset", GET,
// nullptr, oss)); REQUIRE(oss.str() == "rx_dbitoffset 0\n");
// }
// }
// TEST_CASE("rx_dbitlist", "[.cmd][.ctb]") {
// if (test::type == slsDetectorDefs::CHIPTESTBOARD) {
// REQUIRE_NOTHROW(multiSlsDetectorClient("rx_dbitlist 0 4 5 8 9 10 52
// 63", PUT));
// {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("0:rx_dbitlist", GET,
// nullptr, oss)); REQUIRE(oss.str() == "rx_dbitlist [0, 4, 5, 8, 9,
// 10, 52, 63]\n");
// }
// REQUIRE_NOTHROW(multiSlsDetectorClient("rx_dbitlist all", PUT));
// } else {
// std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("rx_dbitlist", GET, nullptr,
// oss)); REQUIRE(oss.str() == "rx_dbitlist []\n");
// }
// }
// TEST_CASE("extsampling", "[.cmd][.ctb]") { // TEST_CASE("extsampling", "[.cmd][.ctb]") {
// if (test::type == slsDetectorDefs::CHIPTESTBOARD) { // if (test::type == slsDetectorDefs::CHIPTESTBOARD) {
// { // {

View File

@ -126,47 +126,64 @@ int ClientInterface::functionTable(){
flist[F_RECEIVER_SET_SUB_EXPTIME] = &ClientInterface::set_subexptime; flist[F_RECEIVER_SET_SUB_EXPTIME] = &ClientInterface::set_subexptime;
flist[F_RECEIVER_SET_SUB_DEADTIME] = &ClientInterface::set_subdeadtime; flist[F_RECEIVER_SET_SUB_DEADTIME] = &ClientInterface::set_subdeadtime;
flist[F_SET_RECEIVER_DYNAMIC_RANGE] = &ClientInterface::set_dynamic_range; flist[F_SET_RECEIVER_DYNAMIC_RANGE] = &ClientInterface::set_dynamic_range;
flist[F_RECEIVER_STREAMING_FREQUENCY] = &ClientInterface::set_streaming_frequency; flist[F_SET_RECEIVER_STREAMING_FREQUENCY] = &ClientInterface::set_streaming_frequency;
flist[F_GET_RECEIVER_STREAMING_FREQUENCY] = &ClientInterface::get_streaming_frequency;
flist[F_GET_RECEIVER_STATUS] = &ClientInterface::get_status; flist[F_GET_RECEIVER_STATUS] = &ClientInterface::get_status;
flist[F_START_RECEIVER] = &ClientInterface::start_receiver; flist[F_START_RECEIVER] = &ClientInterface::start_receiver;
flist[F_STOP_RECEIVER] = &ClientInterface::stop_receiver; flist[F_STOP_RECEIVER] = &ClientInterface::stop_receiver;
flist[F_SET_RECEIVER_FILE_PATH] = &ClientInterface::set_file_dir; flist[F_SET_RECEIVER_FILE_PATH] = &ClientInterface::set_file_dir;
flist[F_GET_RECEIVER_FILE_PATH] = &ClientInterface::get_file_dir;
flist[F_SET_RECEIVER_FILE_NAME] = &ClientInterface::set_file_name; flist[F_SET_RECEIVER_FILE_NAME] = &ClientInterface::set_file_name;
flist[F_GET_RECEIVER_FILE_NAME] = &ClientInterface::get_file_name;
flist[F_SET_RECEIVER_FILE_INDEX] = &ClientInterface::set_file_index; flist[F_SET_RECEIVER_FILE_INDEX] = &ClientInterface::set_file_index;
flist[F_GET_RECEIVER_FILE_INDEX] = &ClientInterface::get_file_index;
flist[F_GET_RECEIVER_FRAME_INDEX] = &ClientInterface::get_frame_index; flist[F_GET_RECEIVER_FRAME_INDEX] = &ClientInterface::get_frame_index;
flist[F_GET_RECEIVER_FRAMES_CAUGHT] = &ClientInterface::get_frames_caught; flist[F_GET_RECEIVER_FRAMES_CAUGHT] = &ClientInterface::get_frames_caught;
flist[F_GET_NUM_MISSING_PACKETS] = &ClientInterface::get_missing_packets; flist[F_GET_NUM_MISSING_PACKETS] = &ClientInterface::get_missing_packets;
flist[F_ENABLE_RECEIVER_FILE_WRITE] = &ClientInterface::enable_file_write; flist[F_SET_RECEIVER_FILE_WRITE] = &ClientInterface::set_file_write;
flist[F_ENABLE_RECEIVER_MASTER_FILE_WRITE] = &ClientInterface::enable_master_file_write; flist[F_GET_RECEIVER_FILE_WRITE] = &ClientInterface::get_file_write;
flist[F_ENABLE_RECEIVER_OVERWRITE] = &ClientInterface::enable_overwrite; flist[F_SET_RECEIVER_MASTER_FILE_WRITE] = &ClientInterface::set_master_file_write;
flist[F_GET_RECEIVER_MASTER_FILE_WRITE] = &ClientInterface::get_master_file_write;
flist[F_SET_RECEIVER_OVERWRITE] = &ClientInterface::set_overwrite;
flist[F_GET_RECEIVER_OVERWRITE] = &ClientInterface::get_overwrite;
flist[F_ENABLE_RECEIVER_TEN_GIGA] = &ClientInterface::enable_tengiga; flist[F_ENABLE_RECEIVER_TEN_GIGA] = &ClientInterface::enable_tengiga;
flist[F_SET_RECEIVER_FIFO_DEPTH] = &ClientInterface::set_fifo_depth; flist[F_SET_RECEIVER_FIFO_DEPTH] = &ClientInterface::set_fifo_depth;
flist[F_RECEIVER_ACTIVATE] = &ClientInterface::set_activate; flist[F_RECEIVER_ACTIVATE] = &ClientInterface::set_activate;
flist[F_STREAM_DATA_FROM_RECEIVER] = &ClientInterface::set_data_stream_enable; flist[F_SET_RECEIVER_STREAMING] = &ClientInterface::set_streaming;
flist[F_GET_RECEIVER_STREAMING] = &ClientInterface::get_streaming;
flist[F_RECEIVER_STREAMING_TIMER] = &ClientInterface::set_streaming_timer; flist[F_RECEIVER_STREAMING_TIMER] = &ClientInterface::set_streaming_timer;
flist[F_SET_FLIPPED_DATA_RECEIVER] = &ClientInterface::set_flipped_data; flist[F_SET_FLIPPED_DATA_RECEIVER] = &ClientInterface::set_flipped_data;
flist[F_SET_RECEIVER_FILE_FORMAT] = &ClientInterface::set_file_format; flist[F_SET_RECEIVER_FILE_FORMAT] = &ClientInterface::set_file_format;
flist[F_GET_RECEIVER_FILE_FORMAT] = &ClientInterface::get_file_format;
flist[F_SEND_RECEIVER_DETPOSID] = &ClientInterface::set_detector_posid; flist[F_SEND_RECEIVER_DETPOSID] = &ClientInterface::set_detector_posid;
flist[F_SEND_RECEIVER_MULTIDETSIZE] = &ClientInterface::set_multi_detector_size; flist[F_SEND_RECEIVER_MULTIDETSIZE] = &ClientInterface::set_multi_detector_size;
flist[F_SET_RECEIVER_STREAMING_PORT] = &ClientInterface::set_streaming_port; flist[F_SET_RECEIVER_STREAMING_PORT] = &ClientInterface::set_streaming_port;
flist[F_RECEIVER_STREAMING_SRC_IP] = &ClientInterface::set_streaming_source_ip; flist[F_GET_RECEIVER_STREAMING_PORT] = &ClientInterface::get_streaming_port;
flist[F_SET_RECEIVER_STREAMING_SRC_IP] = &ClientInterface::set_streaming_source_ip;
flist[F_GET_RECEIVER_STREAMING_SRC_IP] = &ClientInterface::get_streaming_source_ip;
flist[F_SET_RECEIVER_SILENT_MODE] = &ClientInterface::set_silent_mode; flist[F_SET_RECEIVER_SILENT_MODE] = &ClientInterface::set_silent_mode;
flist[F_GET_RECEIVER_SILENT_MODE] = &ClientInterface::get_silent_mode;
flist[F_ENABLE_GAPPIXELS_IN_RECEIVER] = &ClientInterface::enable_gap_pixels; flist[F_ENABLE_GAPPIXELS_IN_RECEIVER] = &ClientInterface::enable_gap_pixels;
flist[F_RESTREAM_STOP_FROM_RECEIVER] = &ClientInterface::restream_stop; flist[F_RESTREAM_STOP_FROM_RECEIVER] = &ClientInterface::restream_stop;
flist[F_ADDITIONAL_JSON_HEADER] = &ClientInterface::set_additional_json_header; flist[F_SET_ADDITIONAL_JSON_HEADER] = &ClientInterface::set_additional_json_header;
flist[F_GET_ADDITIONAL_JSON_HEADER] = &ClientInterface::get_additional_json_header; flist[F_GET_ADDITIONAL_JSON_HEADER] = &ClientInterface::get_additional_json_header;
flist[F_RECEIVER_UDP_SOCK_BUF_SIZE] = &ClientInterface::set_udp_socket_buffer_size; flist[F_RECEIVER_UDP_SOCK_BUF_SIZE] = &ClientInterface::set_udp_socket_buffer_size;
flist[F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE]= &ClientInterface::get_real_udp_socket_buffer_size; flist[F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE]= &ClientInterface::get_real_udp_socket_buffer_size;
flist[F_SET_RECEIVER_FRAMES_PER_FILE] = &ClientInterface::set_frames_per_file; flist[F_SET_RECEIVER_FRAMES_PER_FILE] = &ClientInterface::set_frames_per_file;
flist[F_GET_RECEIVER_FRAMES_PER_FILE] = &ClientInterface::get_frames_per_file;
flist[F_RECEIVER_CHECK_VERSION] = &ClientInterface::check_version_compatibility; flist[F_RECEIVER_CHECK_VERSION] = &ClientInterface::check_version_compatibility;
flist[F_RECEIVER_DISCARD_POLICY] = &ClientInterface::set_discard_policy; flist[F_SET_RECEIVER_DISCARD_POLICY] = &ClientInterface::set_discard_policy;
flist[F_RECEIVER_PADDING_ENABLE] = &ClientInterface::set_padding_enable; flist[F_GET_RECEIVER_DISCARD_POLICY] = &ClientInterface::get_discard_policy;
flist[F_RECEIVER_DEACTIVATED_PADDING_ENABLE] = &ClientInterface::set_deactivated_padding_enable; flist[F_SET_RECEIVER_PADDING] = &ClientInterface::set_padding_enable;
flist[F_GET_RECEIVER_PADDING] = &ClientInterface::get_padding_enable;
flist[F_SET_RECEIVER_DEACTIVATED_PADDING] = &ClientInterface::set_deactivated_padding_enable;
flist[F_GET_RECEIVER_DEACTIVATED_PADDING] = &ClientInterface::get_deactivated_padding_enable;
flist[F_RECEIVER_SET_READOUT_MODE] = &ClientInterface::set_readout_mode; flist[F_RECEIVER_SET_READOUT_MODE] = &ClientInterface::set_readout_mode;
flist[F_RECEIVER_SET_ADC_MASK] = &ClientInterface::set_adc_mask; flist[F_RECEIVER_SET_ADC_MASK] = &ClientInterface::set_adc_mask;
flist[F_SET_RECEIVER_DBIT_LIST] = &ClientInterface::set_dbit_list; flist[F_SET_RECEIVER_DBIT_LIST] = &ClientInterface::set_dbit_list;
flist[F_GET_RECEIVER_DBIT_LIST] = &ClientInterface::get_dbit_list; flist[F_GET_RECEIVER_DBIT_LIST] = &ClientInterface::get_dbit_list;
flist[F_RECEIVER_DBIT_OFFSET] = &ClientInterface::set_dbit_offset; flist[F_SET_RECEIVER_DBIT_OFFSET] = &ClientInterface::set_dbit_offset;
flist[F_GET_RECEIVER_DBIT_OFFSET] = &ClientInterface::get_dbit_offset;
flist[F_SET_RECEIVER_QUAD] = &ClientInterface::set_quad_type; flist[F_SET_RECEIVER_QUAD] = &ClientInterface::set_quad_type;
flist[F_SET_RECEIVER_READ_N_LINES] = &ClientInterface::set_read_n_lines; flist[F_SET_RECEIVER_READ_N_LINES] = &ClientInterface::set_read_n_lines;
flist[F_SET_RECEIVER_UDP_IP] = &ClientInterface::set_udp_ip; flist[F_SET_RECEIVER_UDP_IP] = &ClientInterface::set_udp_ip;
@ -176,6 +193,7 @@ int ClientInterface::functionTable(){
flist[F_SET_RECEIVER_NUM_INTERFACES] = &ClientInterface::set_num_interfaces; flist[F_SET_RECEIVER_NUM_INTERFACES] = &ClientInterface::set_num_interfaces;
flist[F_RECEIVER_SET_ADC_MASK_10G] = &ClientInterface::set_adc_mask_10g; flist[F_RECEIVER_SET_ADC_MASK_10G] = &ClientInterface::set_adc_mask_10g;
flist[F_RECEIVER_SET_NUM_COUNTERS] = &ClientInterface::set_num_counters; flist[F_RECEIVER_SET_NUM_COUNTERS] = &ClientInterface::set_num_counters;
flist[F_INCREMENT_FILE_INDEX] = &ClientInterface::increment_file_index;
for (int i = NUM_DET_FUNCTIONS + 1; i < NUM_REC_FUNCTIONS ; i++) { for (int i = NUM_DET_FUNCTIONS + 1; i < NUM_REC_FUNCTIONS ; i++) {
LOG(logDEBUG1) << "function fnum: " << i << " (" << LOG(logDEBUG1) << "function fnum: " << i << " (" <<
@ -318,103 +336,15 @@ int ClientInterface::update_client(Interface &socket) {
int ClientInterface::send_update(Interface &socket) { int ClientInterface::send_update(Interface &socket) {
int n = 0; int n = 0;
int i32 = -1; int i32 = -1;
int64_t i64 = -1;
char cstring[MAX_STR_LENGTH]{};
sls::IpAddr ip; sls::IpAddr ip;
ip = server->getLastClient(); ip = server->getLastClient();
n += socket.Send(&ip, sizeof(ip)); n += socket.Send(&ip, sizeof(ip));
// filepath
sls::strcpy_safe(cstring, receiver->getFilePath().c_str());
n += socket.Send(cstring, sizeof(cstring));
// filename
sls::strcpy_safe(cstring, receiver->getFileName().c_str());
n += socket.Send(cstring, sizeof(cstring));
// index
i64 = receiver->getFileIndex();
n += socket.Send(&i64, sizeof(i64));
// file format
i32 = (int)receiver->getFileFormat();
n += socket.Send(&i32, sizeof(i32));
// frames per file
i32 = (int)receiver->getFramesPerFile();
n += socket.Send(&i32, sizeof(i32));
// frame discard policy
i32 = (int)receiver->getFrameDiscardPolicy();
n += socket.Send(&i32, sizeof(i32));
// frame padding
i32 = (int)receiver->getFramePaddingEnable();
n += socket.Send(&i32, sizeof(i32));
// file write enable
i32 = (int)receiver->getFileWriteEnable();
n += socket.Send(&i32, sizeof(i32));
// master file write enable
i32 = (int)receiver->getMasterFileWriteEnable();
n += socket.Send(&i32, sizeof(i32));
// file overwrite enable
i32 = (int)receiver->getOverwriteEnable();
n += socket.Send(&i32, sizeof(i32));
// gap pixels // gap pixels
i32 = (int)receiver->getGapPixelsEnable(); i32 = (int)receiver->getGapPixelsEnable();
n += socket.Send(&i32, sizeof(i32)); n += socket.Send(&i32, sizeof(i32));
// streaming frequency
i32 = (int)receiver->getStreamingFrequency();
n += socket.Send(&i32, sizeof(i32));
// streaming port
i32 = (int)receiver->getStreamingPort();
n += socket.Send(&i32, sizeof(i32));
// streaming source ip
ip = receiver->getStreamingSourceIP();
n += socket.Send(&ip, sizeof(ip));
// additional json header
sls::strcpy_safe(cstring, receiver->getAdditionalJsonHeader().c_str());
n += socket.Send(cstring, sizeof(cstring));
// data streaming enable
i32 = (int)receiver->getDataStreamEnable();
n += socket.Send(&i32, sizeof(i32));
// activate
i32 = (int)receiver->getActivate();
n += socket.Send(&i32, sizeof(i32));
// deactivated padding enable
i32 = (int)receiver->getDeactivatedPadding();
n += socket.Send(&i32, sizeof(i32));
// silent mode
i32 = (int)receiver->getSilentMode();
n += socket.Send(&i32, sizeof(i32));
// dbit list
{
std::vector<int> list = receiver->getDbitList();
int retvalsize = list.size();
int retval[retvalsize];
std::copy(std::begin(list), std::end(list), retval);
socket.Send(&retvalsize, sizeof(retvalsize));
socket.Send(retval, sizeof(retval));
}
// dbit offset
i32 = receiver->getDbitOffset();
n += socket.Send(&i32, sizeof(i32));
return OK; return OK;
} }
@ -614,13 +544,22 @@ int ClientInterface::set_dynamic_range(Interface &socket) {
int ClientInterface::set_streaming_frequency(Interface &socket) { int ClientInterface::set_streaming_frequency(Interface &socket) {
auto index = socket.Receive<int>(); auto index = socket.Receive<int>();
if (index >= 0) { if (index < 0) {
verifyIdle(socket); throw RuntimeError("Invalid streaming frequency: "
LOG(logDEBUG1) << "Setting streaming frequency: " << index; + std::to_string(index));
impl()->setStreamingFrequency(index);
} }
verifyIdle(socket);
LOG(logDEBUG1) << "Setting streaming frequency: " << index;
impl()->setStreamingFrequency(index);
int retval = impl()->getStreamingFrequency(); int retval = impl()->getStreamingFrequency();
validate(index, retval, "set streaming frequency", DEC); validate(index, retval, "set streaming frequency", DEC);
return socket.Send(OK);
}
int ClientInterface::get_streaming_frequency(Interface &socket) {
int retval = impl()->getStreamingFrequency();
LOG(logDEBUG1) << "streaming freq:" << retval;
return socket.sendResult(retval); return socket.sendResult(retval);
} }
@ -658,12 +597,14 @@ int ClientInterface::set_file_dir(Interface &socket) {
char retval[MAX_STR_LENGTH]{}; char retval[MAX_STR_LENGTH]{};
socket.Receive(fPath); socket.Receive(fPath);
if (strlen(fPath) != 0) { if (strlen(fPath) == 0) {
LOG(logDEBUG1) << "Setting file path: " << fPath; throw RuntimeError("Cannot set empty file path");
if(fPath[0] != '/')
throw RuntimeError("Receiver path needs to be absolute path");
impl()->setFilePath(fPath);
} }
if(fPath[0] != '/')
throw RuntimeError("Receiver path needs to be absolute path");
LOG(logDEBUG1) << "Setting file path: " << fPath;
impl()->setFilePath(fPath);
std::string s = impl()->getFilePath(); std::string s = impl()->getFilePath();
sls::strcpy_safe(retval, s.c_str()); sls::strcpy_safe(retval, s.c_str());
if ((s.empty()) || (strlen(fPath) && strcasecmp(fPath, retval))) if ((s.empty()) || (strlen(fPath) && strcasecmp(fPath, retval)))
@ -671,6 +612,14 @@ int ClientInterface::set_file_dir(Interface &socket) {
else else
LOG(logDEBUG1) << "file path:" << retval; LOG(logDEBUG1) << "file path:" << retval;
return socket.Send(OK);
}
int ClientInterface::get_file_dir(Interface &socket) {
char retval[MAX_STR_LENGTH]{};
std::string s = impl()->getFilePath();
sls::strcpy_safe(retval, s.c_str());
LOG(logDEBUG1) << "file path:" << retval;
return socket.sendResult(retval); return socket.sendResult(retval);
} }
@ -678,14 +627,21 @@ int ClientInterface::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.Receive(fName); socket.Receive(fName);
if (strlen(fName) != 0) { if (strlen(fName) == 0) {
LOG(logDEBUG1) << "Setting file name: " << fName; throw RuntimeError("Cannot set empty file name");
impl()->setFileName(fName);
} }
LOG(logDEBUG1) << "Setting file name: " << fName;
impl()->setFileName(fName);
std::string s = impl()->getFileName(); std::string s = impl()->getFileName();
if (s.empty()) sls::strcpy_safe(retval, s.c_str());
throw RuntimeError("file name is empty"); LOG(logDEBUG1) << "file name:" << retval;
return socket.Send(OK);
}
int ClientInterface::get_file_name(Interface &socket) {
char retval[MAX_STR_LENGTH]{};
std::string s = impl()->getFileName();
sls::strcpy_safe(retval, s.c_str()); sls::strcpy_safe(retval, s.c_str());
LOG(logDEBUG1) << "file name:" << retval; LOG(logDEBUG1) << "file name:" << retval;
return socket.sendResult(retval); return socket.sendResult(retval);
@ -693,14 +649,23 @@ int ClientInterface::set_file_name(Interface &socket) {
int ClientInterface::set_file_index(Interface &socket) { int ClientInterface::set_file_index(Interface &socket) {
auto index = socket.Receive<int64_t>(); auto index = socket.Receive<int64_t>();
if (index >= 0) { if (index < 0) {
verifyIdle(socket); throw RuntimeError("Invalid file index: "
LOG(logDEBUG1) << "Setting file index: " << index; + std::to_string(index));
impl()->setFileIndex(index);
} }
verifyIdle(socket);
LOG(logDEBUG1) << "Setting file index: " << index;
impl()->setFileIndex(index);
int64_t retval = impl()->getFileIndex(); int64_t retval = impl()->getFileIndex();
validate(index, retval, "set file index", DEC); validate(index, retval, "set file index", DEC);
LOG(logDEBUG1) << "file index:" << retval; LOG(logDEBUG1) << "file index:" << retval;
return socket.Send(OK);
}
int ClientInterface::get_file_index(Interface &socket) {
int64_t retval = impl()->getFileIndex();
LOG(logDEBUG1) << "file index:" << retval;
return socket.sendResult(retval); return socket.sendResult(retval);
} }
@ -728,42 +693,68 @@ int ClientInterface::get_frames_caught(Interface &socket) {
return socket.sendResult(retval); return socket.sendResult(retval);
} }
int ClientInterface::enable_file_write(Interface &socket) { int ClientInterface::set_file_write(Interface &socket) {
auto enable = socket.Receive<int>(); auto enable = socket.Receive<int>();
if (enable >= 0) { if (enable < 0) {
verifyIdle(socket); throw RuntimeError("Invalid file write enable: " + std::to_string(enable));
LOG(logDEBUG1) << "Setting File write enable:" << enable;
impl()->setFileWriteEnable(enable);
} }
verifyIdle(socket);
LOG(logDEBUG1) << "Setting File write enable:" << enable;
impl()->setFileWriteEnable(enable);
int retval = impl()->getFileWriteEnable(); int retval = impl()->getFileWriteEnable();
validate(enable, retval, "set file write enable", DEC); validate(enable, retval, "set file write enable", DEC);
LOG(logDEBUG1) << "file write enable:" << retval; LOG(logDEBUG1) << "file write enable:" << retval;
return socket.Send(OK);
}
int ClientInterface::get_file_write(Interface &socket) {
int retval = impl()->getFileWriteEnable();
LOG(logDEBUG1) << "file write enable:" << retval;
return socket.sendResult(retval); return socket.sendResult(retval);
} }
int ClientInterface::enable_master_file_write(Interface &socket) { int ClientInterface::set_master_file_write(Interface &socket) {
auto enable = socket.Receive<int>(); auto enable = socket.Receive<int>();
if (enable >= 0) { if (enable < 0) {
verifyIdle(socket); throw RuntimeError("Invalid master file write enable: "
LOG(logDEBUG1) << "Setting Master File write enable:" << enable; + std::to_string(enable));
impl()->setMasterFileWriteEnable(enable);
} }
verifyIdle(socket);
LOG(logDEBUG1) << "Setting Master File write enable:" << enable;
impl()->setMasterFileWriteEnable(enable);
int retval = impl()->getMasterFileWriteEnable(); int retval = impl()->getMasterFileWriteEnable();
validate(enable, retval, "set master file write enable", DEC); validate(enable, retval, "set master file write enable", DEC);
LOG(logDEBUG1) << "master file write enable:" << retval; LOG(logDEBUG1) << "master file write enable:" << retval;
return socket.Send(OK);
}
int ClientInterface::get_master_file_write(Interface &socket) {
int retval = impl()->getMasterFileWriteEnable();
LOG(logDEBUG1) << "master file write enable:" << retval;
return socket.sendResult(retval); return socket.sendResult(retval);
} }
int ClientInterface::enable_overwrite(Interface &socket) { int ClientInterface::set_overwrite(Interface &socket) {
auto index = socket.Receive<int>(); auto index = socket.Receive<int>();
if (index >= 0) { if (index < 0) {
verifyIdle(socket); throw RuntimeError("Invalid over write enable: "
LOG(logDEBUG1) << "Setting File overwrite enable:" << index; + std::to_string(index));
impl()->setOverwriteEnable(index);
} }
verifyIdle(socket);
LOG(logDEBUG1) << "Setting File overwrite enable:" << index;
impl()->setOverwriteEnable(index);
int retval = impl()->getOverwriteEnable(); int retval = impl()->getOverwriteEnable();
validate(index, retval, "set file overwrite enable", DEC); validate(index, retval, "set file overwrite enable", DEC);
LOG(logDEBUG1) << "file overwrite enable:" << retval; LOG(logDEBUG1) << "file overwrite enable:" << retval;
return socket.Send(OK);
}
int ClientInterface::get_overwrite(Interface &socket) {
int retval = impl()->getOverwriteEnable();
LOG(logDEBUG1) << "file overwrite enable:" << retval;
return socket.sendResult(retval); return socket.sendResult(retval);
} }
@ -821,20 +812,29 @@ int ClientInterface::set_activate(Interface &socket) {
return socket.sendResult(retval); return socket.sendResult(retval);
} }
int ClientInterface::set_data_stream_enable(Interface &socket) { int ClientInterface::set_streaming(Interface &socket) {
auto index = socket.Receive<int>(); auto index = socket.Receive<int>();
if (index >= 0) { if (index < 0) {
verifyIdle(socket); throw RuntimeError("Invalid streaming enable: "
LOG(logDEBUG1) << "Setting data stream enable:" << index; + std::to_string(index));
try {
impl()->setDataStreamEnable(index);
} catch(const RuntimeError &e) {
throw RuntimeError("Could not set data stream enable to " + std::to_string(index));
}
} }
verifyIdle(socket);
LOG(logDEBUG1) << "Setting data stream enable:" << index;
try {
impl()->setDataStreamEnable(index);
} catch(const RuntimeError &e) {
throw RuntimeError("Could not set data stream enable to " + std::to_string(index));
}
auto retval = static_cast<int>(impl()->getDataStreamEnable()); auto retval = static_cast<int>(impl()->getDataStreamEnable());
validate(index, retval, "set data stream enable", DEC); validate(index, retval, "set data stream enable", DEC);
LOG(logDEBUG1) << "data streaming enable:" << retval; LOG(logDEBUG1) << "data streaming enable:" << retval;
return socket.Send(OK);
}
int ClientInterface::get_streaming(Interface &socket) {
auto retval = static_cast<int>(impl()->getDataStreamEnable());
LOG(logDEBUG1) << "data streaming enable:" << retval;
return socket.sendResult(retval); return socket.sendResult(retval);
} }
@ -871,14 +871,23 @@ int ClientInterface::set_flipped_data(Interface &socket) {
int ClientInterface::set_file_format(Interface &socket) { int ClientInterface::set_file_format(Interface &socket) {
fileFormat f = GET_FILE_FORMAT; fileFormat f = GET_FILE_FORMAT;
socket.Receive(f); socket.Receive(f);
if (f >= 0) { if (f < 0 || f > NUM_FILE_FORMATS) {
verifyIdle(socket); throw RuntimeError("Invalid file format: "
LOG(logDEBUG1) << "Setting file format:" << f; + std::to_string(f));
impl()->setFileFormat(f);
} }
verifyIdle(socket);
LOG(logDEBUG1) << "Setting file format:" << f;
impl()->setFileFormat(f);
auto retval = impl()->getFileFormat(); auto retval = impl()->getFileFormat();
validate(f, retval, "set file format", DEC); validate(f, retval, "set file format", DEC);
LOG(logDEBUG1) << "File Format: " << retval; LOG(logDEBUG1) << "File Format: " << retval;
return socket.Send(OK);
}
int ClientInterface::get_file_format(Interface &socket) {
auto retval = impl()->getFileFormat();
LOG(logDEBUG1) << "File Format: " << retval;
return socket.sendResult(retval); return socket.sendResult(retval);
} }
@ -912,25 +921,38 @@ int ClientInterface::set_multi_detector_size(Interface &socket) {
int ClientInterface::set_streaming_port(Interface &socket) { int ClientInterface::set_streaming_port(Interface &socket) {
auto port = socket.Receive<int>(); auto port = socket.Receive<int>();
if (port >= 0) { if (port < 0) {
verifyIdle(socket); throw RuntimeError("Invalid zmq port " + std::to_string(port));
LOG(logDEBUG1) << "Setting streaming port:" << port;
impl()->setStreamingPort(port);
} }
verifyIdle(socket);
LOG(logDEBUG1) << "Setting streaming port:" << port;
impl()->setStreamingPort(port);
int retval = impl()->getStreamingPort(); int retval = impl()->getStreamingPort();
validate(port, retval, "set streaming port", DEC); validate(port, retval, "set streaming port", DEC);
LOG(logDEBUG1) << "streaming port:" << retval; LOG(logDEBUG1) << "streaming port:" << retval;
return socket.Send(OK);
}
int ClientInterface::get_streaming_port(Interface &socket) {
int retval = impl()->getStreamingPort();
LOG(logDEBUG1) << "streaming port:" << retval;
return socket.sendResult(retval); return socket.sendResult(retval);
} }
int ClientInterface::set_streaming_source_ip(Interface &socket) { int ClientInterface::set_streaming_source_ip(Interface &socket) {
sls::IpAddr arg; sls::IpAddr arg;
socket.Receive(arg); socket.Receive(arg);
if (arg == 0) {
throw RuntimeError("Invalid zmq ip " + arg.str());
}
verifyIdle(socket); verifyIdle(socket);
LOG(logDEBUG1) << "Setting streaming source ip:" << arg; LOG(logDEBUG1) << "Setting streaming source ip:" << arg;
impl()->setStreamingSourceIP(arg); impl()->setStreamingSourceIP(arg);
sls::IpAddr retval = impl()->getStreamingSourceIP(); sls::IpAddr retval = impl()->getStreamingSourceIP();
if (retval != arg) { LOG(logDEBUG1) << "streaming IP:" << retval;
if (retval != arg && arg != 0) {
std::ostringstream os; std::ostringstream os;
os << "Could not set streaming ip. Set " << arg os << "Could not set streaming ip. Set " << arg
<< ", but read " << retval << '\n'; << ", but read " << retval << '\n';
@ -939,16 +961,31 @@ int ClientInterface::set_streaming_source_ip(Interface &socket) {
return socket.Send(OK); return socket.Send(OK);
} }
int ClientInterface::get_streaming_source_ip(Interface &socket) {
sls::IpAddr retval = impl()->getStreamingSourceIP();
LOG(logDEBUG1) << "streaming IP:" << retval;
return socket.sendResult(retval);
}
int ClientInterface::set_silent_mode(Interface &socket) { int ClientInterface::set_silent_mode(Interface &socket) {
auto value = socket.Receive<int>(); auto value = socket.Receive<int>();
if (value >= 0) { if (value < 0) {
verifyIdle(socket); throw RuntimeError("Invalid silent mode: "
LOG(logDEBUG1) << "Setting silent mode:" << value; + std::to_string(value));
impl()->setSilentMode(value);
} }
verifyIdle(socket);
LOG(logDEBUG1) << "Setting silent mode:" << value;
impl()->setSilentMode(value);
auto retval = static_cast<int>(impl()->getSilentMode()); auto retval = static_cast<int>(impl()->getSilentMode());
validate(value, retval, "set silent mode", DEC); validate(value, retval, "set silent mode", DEC);
LOG(logDEBUG1) << "silent mode:" << retval; LOG(logDEBUG1) << "silent mode:" << retval;
return socket.Send(OK);
}
int ClientInterface::get_silent_mode(Interface &socket) {
auto retval = static_cast<int>(impl()->getSilentMode());
LOG(logDEBUG1) << "silent mode:" << retval;
return socket.sendResult(retval); return socket.sendResult(retval);
} }
@ -986,14 +1023,11 @@ int ClientInterface::restream_stop(Interface &socket) {
int ClientInterface::set_additional_json_header(Interface &socket) { int ClientInterface::set_additional_json_header(Interface &socket) {
char arg[MAX_STR_LENGTH]{}; char arg[MAX_STR_LENGTH]{};
char retval[MAX_STR_LENGTH]{};
socket.Receive(arg); socket.Receive(arg);
verifyIdle(socket); verifyIdle(socket);
LOG(logDEBUG1) << "Setting additional json header: " << arg; LOG(logDEBUG1) << "Setting additional json header: " << arg;
impl()->setAdditionalJsonHeader(arg); impl()->setAdditionalJsonHeader(arg);
sls::strcpy_safe(retval, impl()->getAdditionalJsonHeader().c_str()); return socket.Send(OK);
LOG(logDEBUG1) << "additional json header:" << retval;
return socket.sendResult(retval);
} }
int ClientInterface::get_additional_json_header(Interface &socket) { int ClientInterface::get_additional_json_header(Interface &socket) {
@ -1028,14 +1062,23 @@ int ClientInterface::get_real_udp_socket_buffer_size(
int ClientInterface::set_frames_per_file(Interface &socket) { int ClientInterface::set_frames_per_file(Interface &socket) {
auto index = socket.Receive<int>(); auto index = socket.Receive<int>();
if (index >= 0) { if (index < 0) {
verifyIdle(socket); throw RuntimeError("Invalid frames per file: "
LOG(logDEBUG1) << "Setting frames per file: " << index; + std::to_string(index));
impl()->setFramesPerFile(index);
} }
verifyIdle(socket);
LOG(logDEBUG1) << "Setting frames per file: " << index;
impl()->setFramesPerFile(index);
auto retval = static_cast<int>(impl()->getFramesPerFile()); auto retval = static_cast<int>(impl()->getFramesPerFile());
validate(index, retval, "set frames per file", DEC); validate(index, retval, "set frames per file", DEC);
LOG(logDEBUG1) << "frames per file:" << retval; LOG(logDEBUG1) << "frames per file:" << retval;
return socket.Send(OK);
}
int ClientInterface::get_frames_per_file(Interface &socket) {
auto retval = static_cast<int>(impl()->getFramesPerFile());
LOG(logDEBUG1) << "frames per file:" << retval;
return socket.sendResult(retval); return socket.sendResult(retval);
} }
@ -1069,44 +1112,71 @@ int ClientInterface::check_version_compatibility(Interface &socket) {
int ClientInterface::set_discard_policy(Interface &socket) { int ClientInterface::set_discard_policy(Interface &socket) {
auto index = socket.Receive<int>(); auto index = socket.Receive<int>();
if (index >= 0) { if (index < 0 || index > NUM_DISCARD_POLICIES) {
verifyIdle(socket); throw RuntimeError("Invalid discard policy " + std::to_string(index));
LOG(logDEBUG1) << "Setting frames discard policy: " << index;
impl()->setFrameDiscardPolicy(static_cast<frameDiscardPolicy>(index));
} }
verifyIdle(socket);
LOG(logDEBUG1) << "Setting frames discard policy: " << index;
impl()->setFrameDiscardPolicy(static_cast<frameDiscardPolicy>(index));
int retval = impl()->getFrameDiscardPolicy(); int retval = impl()->getFrameDiscardPolicy();
validate(index, retval, "set discard policy", DEC); validate(index, retval, "set discard policy", DEC);
LOG(logDEBUG1) << "frame discard policy:" << retval; LOG(logDEBUG1) << "frame discard policy:" << retval;
return socket.Send(OK);
}
int ClientInterface::get_discard_policy(Interface &socket) {
int retval = impl()->getFrameDiscardPolicy();
LOG(logDEBUG1) << "frame discard policy:" << retval;
return socket.sendResult(retval); return socket.sendResult(retval);
} }
int ClientInterface::set_padding_enable(Interface &socket) { int ClientInterface::set_padding_enable(Interface &socket) {
auto index = socket.Receive<int>(); auto index = socket.Receive<int>();
if (index >= 0) { if (index < 0) {
verifyIdle(socket); throw RuntimeError("Invalid padding enable: " + std::to_string(index));
LOG(logDEBUG1) << "Setting frames padding enable: " << index;
impl()->setFramePaddingEnable(static_cast<bool>(index));
} }
verifyIdle(socket);
LOG(logDEBUG1) << "Setting frames padding enable: " << index;
impl()->setFramePaddingEnable(static_cast<bool>(index));
auto retval = static_cast<int>(impl()->getFramePaddingEnable()); auto retval = static_cast<int>(impl()->getFramePaddingEnable());
validate(index, retval, "set frame padding enable", DEC); validate(index, retval, "set frame padding enable", DEC);
LOG(logDEBUG1) << "Frame Padding Enable:" << retval; LOG(logDEBUG1) << "Frame Padding Enable:" << retval;
return socket.Send(OK);
}
int ClientInterface::get_padding_enable(Interface &socket) {
auto retval = static_cast<int>(impl()->getFramePaddingEnable());
LOG(logDEBUG1) << "Frame Padding Enable:" << retval;
return socket.sendResult(retval); return socket.sendResult(retval);
} }
int ClientInterface::set_deactivated_padding_enable( int ClientInterface::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();
if (enable >= 0) {
verifyIdle(socket);
LOG(logDEBUG1) << "Setting deactivated padding enable: " << enable;
impl()->setDeactivatedPadding(enable > 0);
} }
if (enable < 0) {
throw RuntimeError("Invalid Deactivated padding: "
+ std::to_string(enable));
}
verifyIdle(socket);
LOG(logDEBUG1) << "Setting deactivated padding enable: " << enable;
impl()->setDeactivatedPadding(enable > 0);
auto retval = static_cast<int>(impl()->getDeactivatedPadding()); auto retval = static_cast<int>(impl()->getDeactivatedPadding());
validate(enable, retval, "set deactivated padding enable", DEC); validate(enable, retval, "set deactivated padding enable", DEC);
LOG(logDEBUG1) << "Deactivated Padding Enable: " << retval; LOG(logDEBUG1) << "Deactivated Padding Enable: " << retval;
return socket.Send(OK);
}
int ClientInterface::get_deactivated_padding_enable(
Interface &socket) {
if (myDetectorType != EIGER)
functionNotImplemented();
auto retval = static_cast<int>(impl()->getDeactivatedPadding());
LOG(logDEBUG1) << "Deactivated Padding Enable: " << retval;
return socket.sendResult(retval); return socket.sendResult(retval);
} }
@ -1155,6 +1225,8 @@ int ClientInterface::set_adc_mask(Interface &socket) {
int ClientInterface::set_dbit_list(Interface &socket) { int ClientInterface::set_dbit_list(Interface &socket) {
sls::FixedCapacityContainer<int, MAX_RX_DBIT> args; sls::FixedCapacityContainer<int, MAX_RX_DBIT> args;
socket.Receive(args); socket.Receive(args);
if (myDetectorType != CHIPTESTBOARD)
functionNotImplemented();
LOG(logDEBUG1) << "Setting DBIT list"; LOG(logDEBUG1) << "Setting DBIT list";
for (auto &it : args) { for (auto &it : args) {
LOG(logDEBUG1) << it << " "; LOG(logDEBUG1) << it << " ";
@ -1166,6 +1238,8 @@ int ClientInterface::set_dbit_list(Interface &socket) {
} }
int ClientInterface::get_dbit_list(Interface &socket) { int ClientInterface::get_dbit_list(Interface &socket) {
if (myDetectorType != CHIPTESTBOARD)
functionNotImplemented();
sls::FixedCapacityContainer<int, MAX_RX_DBIT> retval; sls::FixedCapacityContainer<int, MAX_RX_DBIT> retval;
retval = impl()->getDbitList(); retval = impl()->getDbitList();
LOG(logDEBUG1) << "Dbit list size retval:" << retval.size(); LOG(logDEBUG1) << "Dbit list size retval:" << retval.size();
@ -1174,14 +1248,27 @@ int ClientInterface::get_dbit_list(Interface &socket) {
int ClientInterface::set_dbit_offset(Interface &socket) { int ClientInterface::set_dbit_offset(Interface &socket) {
auto arg = socket.Receive<int>(); auto arg = socket.Receive<int>();
if (arg >= 0) { if (myDetectorType != CHIPTESTBOARD)
verifyIdle(socket); functionNotImplemented();
LOG(logDEBUG1) << "Setting Dbit offset: " << arg; if (arg < 0) {
impl()->setDbitOffset(arg); throw RuntimeError("Invalid dbit offset: "
+ std::to_string(arg));
} }
verifyIdle(socket);
LOG(logDEBUG1) << "Setting Dbit offset: " << arg;
impl()->setDbitOffset(arg);
int retval = impl()->getDbitOffset(); int retval = impl()->getDbitOffset();
validate(arg, retval, "set dbit offset", DEC); validate(arg, retval, "set dbit offset", DEC);
LOG(logDEBUG1) << "Dbit offset retval: " << retval; LOG(logDEBUG1) << "Dbit offset retval: " << retval;
return socket.Send(OK);
}
int ClientInterface::get_dbit_offset(Interface &socket) {
if (myDetectorType != CHIPTESTBOARD)
functionNotImplemented();
int retval = impl()->getDbitOffset();
LOG(logDEBUG1) << "Dbit offset retval: " << retval;
return socket.sendResult(retval); return socket.sendResult(retval);
} }
@ -1236,7 +1323,7 @@ int ClientInterface::set_udp_ip(Interface &socket) {
// get mac address // get mac address
auto retval = sls::InterfaceNameToMac(eth); auto retval = sls::InterfaceNameToMac(eth);
if (retval == 0) { if (retval == 0) {
throw RuntimeError("Failed to get udp mac adddress to listen to\n"); throw RuntimeError("Failed to get udp mac adddress to listen to (eth:" + eth + ", ip:" + arg.str() + ")\n");
} }
LOG(logINFO) << "Receiver MAC Address: " << retval; LOG(logINFO) << "Receiver MAC Address: " << retval;
return socket.sendResult(retval); return socket.sendResult(retval);
@ -1264,7 +1351,7 @@ int ClientInterface::set_udp_ip2(Interface &socket) {
// get mac address // get mac address
auto retval = sls::InterfaceNameToMac(eth); auto retval = sls::InterfaceNameToMac(eth);
if (retval == 0) { if (retval == 0) {
throw RuntimeError("Failed to get udp mac adddress2 to listen to\n"); throw RuntimeError("Failed to get udp mac adddress2 to listen to (eth:" + eth + ", ip:" + arg.str() + ")\n");
} }
LOG(logINFO) << "Receiver MAC Address2: " << retval; LOG(logINFO) << "Receiver MAC Address2: " << retval;
return socket.sendResult(retval); return socket.sendResult(retval);
@ -1331,4 +1418,11 @@ int ClientInterface::set_num_counters(Interface &socket) {
LOG(logDEBUG1) << "Setting counters: " << arg; LOG(logDEBUG1) << "Setting counters: " << arg;
impl()->setNumberofCounters(arg); impl()->setNumberofCounters(arg);
return socket.Send(OK); return socket.Send(OK);
}
int ClientInterface::increment_file_index(Interface &socket) {
verifyIdle(socket);
LOG(logDEBUG1) << "Incrementing file index";
impl()->setFileIndex(impl()->getFileIndex() + 1);
return socket.Send(OK);
} }

View File

@ -70,31 +70,43 @@ class ClientInterface : private virtual slsDetectorDefs {
int set_subdeadtime(sls::ServerInterface &socket); int set_subdeadtime(sls::ServerInterface &socket);
int set_dynamic_range(sls::ServerInterface &socket); int set_dynamic_range(sls::ServerInterface &socket);
int set_streaming_frequency(sls::ServerInterface &socket); int set_streaming_frequency(sls::ServerInterface &socket);
int get_streaming_frequency(sls::ServerInterface &socket);
int get_status(sls::ServerInterface &socket); int get_status(sls::ServerInterface &socket);
int start_receiver(sls::ServerInterface &socket); int start_receiver(sls::ServerInterface &socket);
int stop_receiver(sls::ServerInterface &socket); int stop_receiver(sls::ServerInterface &socket);
int set_file_dir(sls::ServerInterface &socket); int set_file_dir(sls::ServerInterface &socket);
int get_file_dir(sls::ServerInterface &socket);
int set_file_name(sls::ServerInterface &socket); int set_file_name(sls::ServerInterface &socket);
int get_file_name(sls::ServerInterface &socket);
int set_file_index(sls::ServerInterface &socket); int set_file_index(sls::ServerInterface &socket);
int get_file_index(sls::ServerInterface &socket);
int get_frame_index(sls::ServerInterface &socket); int get_frame_index(sls::ServerInterface &socket);
int get_missing_packets(sls::ServerInterface &socket); int get_missing_packets(sls::ServerInterface &socket);
int get_frames_caught(sls::ServerInterface &socket); int get_frames_caught(sls::ServerInterface &socket);
int enable_file_write(sls::ServerInterface &socket); int set_file_write(sls::ServerInterface &socket);
int enable_master_file_write(sls::ServerInterface &socket); int get_file_write(sls::ServerInterface &socket);
int set_master_file_write(sls::ServerInterface &socket);
int get_master_file_write(sls::ServerInterface &socket);
int enable_compression(sls::ServerInterface &socket); int enable_compression(sls::ServerInterface &socket);
int enable_overwrite(sls::ServerInterface &socket); int set_overwrite(sls::ServerInterface &socket);
int get_overwrite(sls::ServerInterface &socket);
int enable_tengiga(sls::ServerInterface &socket); int enable_tengiga(sls::ServerInterface &socket);
int set_fifo_depth(sls::ServerInterface &socket); int set_fifo_depth(sls::ServerInterface &socket);
int set_activate(sls::ServerInterface &socket); int set_activate(sls::ServerInterface &socket);
int set_data_stream_enable(sls::ServerInterface &socket); int set_streaming(sls::ServerInterface &socket);
int get_streaming(sls::ServerInterface &socket);
int set_streaming_timer(sls::ServerInterface &socket); int set_streaming_timer(sls::ServerInterface &socket);
int set_flipped_data(sls::ServerInterface &socket); int set_flipped_data(sls::ServerInterface &socket);
int set_file_format(sls::ServerInterface &socket); int set_file_format(sls::ServerInterface &socket);
int get_file_format(sls::ServerInterface &socket);
int set_detector_posid(sls::ServerInterface &socket); int set_detector_posid(sls::ServerInterface &socket);
int set_multi_detector_size(sls::ServerInterface &socket); int set_multi_detector_size(sls::ServerInterface &socket);
int set_streaming_port(sls::ServerInterface &socket); int set_streaming_port(sls::ServerInterface &socket);
int get_streaming_port(sls::ServerInterface &socket);
int set_streaming_source_ip(sls::ServerInterface &socket); int set_streaming_source_ip(sls::ServerInterface &socket);
int get_streaming_source_ip(sls::ServerInterface &socket);
int set_silent_mode(sls::ServerInterface &socket); int set_silent_mode(sls::ServerInterface &socket);
int get_silent_mode(sls::ServerInterface &socket);
int enable_gap_pixels(sls::ServerInterface &socket); int enable_gap_pixels(sls::ServerInterface &socket);
int restream_stop(sls::ServerInterface &socket); int restream_stop(sls::ServerInterface &socket);
int set_additional_json_header(sls::ServerInterface &socket); int set_additional_json_header(sls::ServerInterface &socket);
@ -102,15 +114,20 @@ class ClientInterface : private virtual slsDetectorDefs {
int set_udp_socket_buffer_size(sls::ServerInterface &socket); int set_udp_socket_buffer_size(sls::ServerInterface &socket);
int get_real_udp_socket_buffer_size(sls::ServerInterface &socket); int get_real_udp_socket_buffer_size(sls::ServerInterface &socket);
int set_frames_per_file(sls::ServerInterface &socket); int set_frames_per_file(sls::ServerInterface &socket);
int get_frames_per_file(sls::ServerInterface &socket);
int check_version_compatibility(sls::ServerInterface &socket); int check_version_compatibility(sls::ServerInterface &socket);
int set_discard_policy(sls::ServerInterface &socket); int set_discard_policy(sls::ServerInterface &socket);
int get_discard_policy(sls::ServerInterface &socket);
int set_padding_enable(sls::ServerInterface &socket); int set_padding_enable(sls::ServerInterface &socket);
int get_padding_enable(sls::ServerInterface &socket);
int set_deactivated_padding_enable(sls::ServerInterface &socket); int set_deactivated_padding_enable(sls::ServerInterface &socket);
int get_deactivated_padding_enable(sls::ServerInterface &socket);
int set_readout_mode(sls::ServerInterface &socket); int set_readout_mode(sls::ServerInterface &socket);
int set_adc_mask(sls::ServerInterface &socket); int set_adc_mask(sls::ServerInterface &socket);
int set_dbit_list(sls::ServerInterface &socket); int set_dbit_list(sls::ServerInterface &socket);
int get_dbit_list(sls::ServerInterface &socket); int get_dbit_list(sls::ServerInterface &socket);
int set_dbit_offset(sls::ServerInterface &socket); int set_dbit_offset(sls::ServerInterface &socket);
int get_dbit_offset(sls::ServerInterface &socket);
int set_quad_type(sls::ServerInterface &socket); int set_quad_type(sls::ServerInterface &socket);
int set_read_n_lines(sls::ServerInterface &socket); int set_read_n_lines(sls::ServerInterface &socket);
int set_udp_ip(sls::ServerInterface &socket); int set_udp_ip(sls::ServerInterface &socket);
@ -120,6 +137,7 @@ class ClientInterface : private virtual slsDetectorDefs {
int set_num_interfaces(sls::ServerInterface &socket); int set_num_interfaces(sls::ServerInterface &socket);
int set_adc_mask_10g(sls::ServerInterface &socket); int set_adc_mask_10g(sls::ServerInterface &socket);
int set_num_counters(sls::ServerInterface &socket); int set_num_counters(sls::ServerInterface &socket);
int increment_file_index(sls::ServerInterface &socket);
Implementation *impl() { Implementation *impl() {
if (receiver != nullptr) { if (receiver != nullptr) {

View File

@ -59,11 +59,11 @@ void Implementation::InitializeMembers() {
silentMode = false; silentMode = false;
fifoDepth = 0; fifoDepth = 0;
frameDiscardMode = NO_DISCARD; frameDiscardMode = NO_DISCARD;
framePadding = false; framePadding = true;
// file parameters // file parameters
fileFormatType = BINARY; fileFormatType = BINARY;
filePath = ""; filePath = "/";
fileName = "run"; fileName = "run";
fileIndex = 0; fileIndex = 0;
fileWriteEnable = true; fileWriteEnable = true;
@ -340,6 +340,11 @@ void Implementation::setDetectorPositionId(const int id) {
LOG(logDEBUG3) << __SHORT_AT__ << " called"; LOG(logDEBUG3) << __SHORT_AT__ << " called";
detID = id; detID = id;
LOG(logINFO) << "Detector Position Id:" << detID; LOG(logINFO) << "Detector Position Id:" << detID;
// update zmq port
streamingPort = DEFAULT_ZMQ_RX_PORTNO +
(detID * (myDetectorType == EIGER ? 2 : 1));
for (unsigned int i = 0; i < dataProcessor.size(); ++i) { for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
dataProcessor[i]->SetupFileWriter( dataProcessor[i]->SetupFileWriter(
fileWriteEnable, (int *)numDet, &framesPerFile, &fileName, &filePath, fileWriteEnable, (int *)numDet, &framesPerFile, &fileName, &filePath,

View File

@ -14,6 +14,15 @@
//files //files
#define MAX_FRAMES_PER_FILE 20000
#define SHORT_MAX_FRAMES_PER_FILE 100000
#define MOENCH_MAX_FRAMES_PER_FILE 100000
#define EIGER_MAX_FRAMES_PER_FILE 10000
#define JFRAU_MAX_FRAMES_PER_FILE 10000
#define CTB_MAX_FRAMES_PER_FILE 20000
#define MYTHEN3_MAX_FRAMES_PER_FILE 10000
#define GOTTHARD2_MAX_FRAMES_PER_FILE 20000
#define DO_NOTHING (0) #define DO_NOTHING (0)
#define DO_EVERYTHING (1) #define DO_EVERYTHING (1)

View File

@ -61,14 +61,6 @@
/** default maximum string length */ /** default maximum string length */
#define MAX_STR_LENGTH 1000 #define MAX_STR_LENGTH 1000
#define MAX_FRAMES_PER_FILE 20000
#define SHORT_MAX_FRAMES_PER_FILE 100000
#define MOENCH_MAX_FRAMES_PER_FILE 100000
#define EIGER_MAX_FRAMES_PER_FILE 10000
#define JFRAU_MAX_FRAMES_PER_FILE 10000
#define CTB_MAX_FRAMES_PER_FILE 20000
#define MYTHEN3_MAX_FRAMES_PER_FILE 10000
#define GOTTHARD2_MAX_FRAMES_PER_FILE 20000
#define DEFAULT_STREAMING_TIMER_IN_MS 200 #define DEFAULT_STREAMING_TIMER_IN_MS 200

View File

@ -219,47 +219,64 @@ enum detFuncs{
F_RECEIVER_SET_SUB_EXPTIME, F_RECEIVER_SET_SUB_EXPTIME,
F_RECEIVER_SET_SUB_DEADTIME, F_RECEIVER_SET_SUB_DEADTIME,
F_SET_RECEIVER_DYNAMIC_RANGE, F_SET_RECEIVER_DYNAMIC_RANGE,
F_RECEIVER_STREAMING_FREQUENCY, F_SET_RECEIVER_STREAMING_FREQUENCY,
F_GET_RECEIVER_STREAMING_FREQUENCY,
F_GET_RECEIVER_STATUS, F_GET_RECEIVER_STATUS,
F_START_RECEIVER, F_START_RECEIVER,
F_STOP_RECEIVER, F_STOP_RECEIVER,
F_SET_RECEIVER_FILE_PATH, F_SET_RECEIVER_FILE_PATH,
F_GET_RECEIVER_FILE_PATH,
F_SET_RECEIVER_FILE_NAME, F_SET_RECEIVER_FILE_NAME,
F_GET_RECEIVER_FILE_NAME,
F_SET_RECEIVER_FILE_INDEX, F_SET_RECEIVER_FILE_INDEX,
F_GET_RECEIVER_FILE_INDEX,
F_GET_RECEIVER_FRAME_INDEX, F_GET_RECEIVER_FRAME_INDEX,
F_GET_RECEIVER_FRAMES_CAUGHT, F_GET_RECEIVER_FRAMES_CAUGHT,
F_GET_NUM_MISSING_PACKETS, F_GET_NUM_MISSING_PACKETS,
F_ENABLE_RECEIVER_FILE_WRITE, F_SET_RECEIVER_FILE_WRITE,
F_ENABLE_RECEIVER_MASTER_FILE_WRITE, F_GET_RECEIVER_FILE_WRITE,
F_ENABLE_RECEIVER_OVERWRITE, F_SET_RECEIVER_MASTER_FILE_WRITE,
F_GET_RECEIVER_MASTER_FILE_WRITE,
F_SET_RECEIVER_OVERWRITE,
F_GET_RECEIVER_OVERWRITE,
F_ENABLE_RECEIVER_TEN_GIGA, F_ENABLE_RECEIVER_TEN_GIGA,
F_SET_RECEIVER_FIFO_DEPTH, F_SET_RECEIVER_FIFO_DEPTH,
F_RECEIVER_ACTIVATE, F_RECEIVER_ACTIVATE,
F_STREAM_DATA_FROM_RECEIVER, F_SET_RECEIVER_STREAMING,
F_GET_RECEIVER_STREAMING,
F_RECEIVER_STREAMING_TIMER, F_RECEIVER_STREAMING_TIMER,
F_SET_FLIPPED_DATA_RECEIVER, F_SET_FLIPPED_DATA_RECEIVER,
F_SET_RECEIVER_FILE_FORMAT, F_SET_RECEIVER_FILE_FORMAT,
F_GET_RECEIVER_FILE_FORMAT,
F_SEND_RECEIVER_DETPOSID, F_SEND_RECEIVER_DETPOSID,
F_SEND_RECEIVER_MULTIDETSIZE, F_SEND_RECEIVER_MULTIDETSIZE,
F_SET_RECEIVER_STREAMING_PORT, F_SET_RECEIVER_STREAMING_PORT,
F_RECEIVER_STREAMING_SRC_IP, F_GET_RECEIVER_STREAMING_PORT,
F_SET_RECEIVER_STREAMING_SRC_IP,
F_GET_RECEIVER_STREAMING_SRC_IP,
F_SET_RECEIVER_SILENT_MODE, F_SET_RECEIVER_SILENT_MODE,
F_GET_RECEIVER_SILENT_MODE,
F_ENABLE_GAPPIXELS_IN_RECEIVER, F_ENABLE_GAPPIXELS_IN_RECEIVER,
F_RESTREAM_STOP_FROM_RECEIVER, F_RESTREAM_STOP_FROM_RECEIVER,
F_ADDITIONAL_JSON_HEADER, F_SET_ADDITIONAL_JSON_HEADER,
F_GET_ADDITIONAL_JSON_HEADER, F_GET_ADDITIONAL_JSON_HEADER,
F_RECEIVER_UDP_SOCK_BUF_SIZE, F_RECEIVER_UDP_SOCK_BUF_SIZE,
F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE, F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE,
F_SET_RECEIVER_FRAMES_PER_FILE, F_SET_RECEIVER_FRAMES_PER_FILE,
F_GET_RECEIVER_FRAMES_PER_FILE,
F_RECEIVER_CHECK_VERSION, F_RECEIVER_CHECK_VERSION,
F_RECEIVER_DISCARD_POLICY, F_SET_RECEIVER_DISCARD_POLICY,
F_RECEIVER_PADDING_ENABLE, F_GET_RECEIVER_DISCARD_POLICY,
F_RECEIVER_DEACTIVATED_PADDING_ENABLE, F_SET_RECEIVER_PADDING,
F_GET_RECEIVER_PADDING,
F_SET_RECEIVER_DEACTIVATED_PADDING,
F_GET_RECEIVER_DEACTIVATED_PADDING,
F_RECEIVER_SET_READOUT_MODE, F_RECEIVER_SET_READOUT_MODE,
F_RECEIVER_SET_ADC_MASK, F_RECEIVER_SET_ADC_MASK,
F_SET_RECEIVER_DBIT_LIST, F_SET_RECEIVER_DBIT_LIST,
F_GET_RECEIVER_DBIT_LIST, F_GET_RECEIVER_DBIT_LIST,
F_RECEIVER_DBIT_OFFSET, F_SET_RECEIVER_DBIT_OFFSET,
F_GET_RECEIVER_DBIT_OFFSET,
F_SET_RECEIVER_QUAD, F_SET_RECEIVER_QUAD,
F_SET_RECEIVER_READ_N_LINES, F_SET_RECEIVER_READ_N_LINES,
F_SET_RECEIVER_UDP_IP, F_SET_RECEIVER_UDP_IP,
@ -269,6 +286,7 @@ enum detFuncs{
F_SET_RECEIVER_NUM_INTERFACES, F_SET_RECEIVER_NUM_INTERFACES,
F_RECEIVER_SET_ADC_MASK_10G, F_RECEIVER_SET_ADC_MASK_10G,
F_RECEIVER_SET_NUM_COUNTERS, F_RECEIVER_SET_NUM_COUNTERS,
F_INCREMENT_FILE_INDEX,
NUM_REC_FUNCTIONS NUM_REC_FUNCTIONS
}; };
@ -484,47 +502,64 @@ static const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_RECEIVER_SET_SUB_EXPTIME: return "F_RECEIVER_SET_SUB_EXPTIME"; case F_RECEIVER_SET_SUB_EXPTIME: return "F_RECEIVER_SET_SUB_EXPTIME";
case F_RECEIVER_SET_SUB_DEADTIME: return "F_RECEIVER_SET_SUB_DEADTIME"; case F_RECEIVER_SET_SUB_DEADTIME: return "F_RECEIVER_SET_SUB_DEADTIME";
case F_SET_RECEIVER_DYNAMIC_RANGE: return "F_SET_RECEIVER_DYNAMIC_RANGE"; case F_SET_RECEIVER_DYNAMIC_RANGE: return "F_SET_RECEIVER_DYNAMIC_RANGE";
case F_RECEIVER_STREAMING_FREQUENCY: return "F_RECEIVER_STREAMING_FREQUENCY"; case F_SET_RECEIVER_STREAMING_FREQUENCY: return "F_SET_RECEIVER_STREAMING_FREQUENCY";
case F_GET_RECEIVER_STREAMING_FREQUENCY: return "F_GET_RECEIVER_STREAMING_FREQUENCY";
case F_GET_RECEIVER_STATUS: return "F_GET_RECEIVER_STATUS"; case F_GET_RECEIVER_STATUS: return "F_GET_RECEIVER_STATUS";
case F_START_RECEIVER: return "F_START_RECEIVER"; case F_START_RECEIVER: return "F_START_RECEIVER";
case F_STOP_RECEIVER: return "F_STOP_RECEIVER"; case F_STOP_RECEIVER: return "F_STOP_RECEIVER";
case F_SET_RECEIVER_FILE_PATH: return "F_SET_RECEIVER_FILE_PATH"; case F_SET_RECEIVER_FILE_PATH: return "F_SET_RECEIVER_FILE_PATH";
case F_GET_RECEIVER_FILE_PATH: return "F_GET_RECEIVER_FILE_PATH";
case F_SET_RECEIVER_FILE_NAME: return "F_SET_RECEIVER_FILE_NAME"; case F_SET_RECEIVER_FILE_NAME: return "F_SET_RECEIVER_FILE_NAME";
case F_GET_RECEIVER_FILE_NAME: return "F_GET_RECEIVER_FILE_NAME";
case F_SET_RECEIVER_FILE_INDEX: return "F_SET_RECEIVER_FILE_INDEX"; case F_SET_RECEIVER_FILE_INDEX: return "F_SET_RECEIVER_FILE_INDEX";
case F_GET_RECEIVER_FILE_INDEX: return "F_GET_RECEIVER_FILE_INDEX";
case F_GET_RECEIVER_FRAME_INDEX: return "F_GET_RECEIVER_FRAME_INDEX"; case F_GET_RECEIVER_FRAME_INDEX: return "F_GET_RECEIVER_FRAME_INDEX";
case F_GET_RECEIVER_FRAMES_CAUGHT: return "F_GET_RECEIVER_FRAMES_CAUGHT"; case F_GET_RECEIVER_FRAMES_CAUGHT: return "F_GET_RECEIVER_FRAMES_CAUGHT";
case F_GET_NUM_MISSING_PACKETS: return "F_GET_NUM_MISSING_PACKETS"; case F_GET_NUM_MISSING_PACKETS: return "F_GET_NUM_MISSING_PACKETS";
case F_ENABLE_RECEIVER_FILE_WRITE: return "F_ENABLE_RECEIVER_FILE_WRITE"; case F_SET_RECEIVER_FILE_WRITE: return "F_SET_RECEIVER_FILE_WRITE";
case F_ENABLE_RECEIVER_MASTER_FILE_WRITE: return "F_ENABLE_RECEIVER_MASTER_FILE_WRITE"; case F_GET_RECEIVER_FILE_WRITE: return "F_GET_RECEIVER_FILE_WRITE";
case F_ENABLE_RECEIVER_OVERWRITE: return "F_ENABLE_RECEIVER_OVERWRITE"; case F_SET_RECEIVER_MASTER_FILE_WRITE: return "F_SET_RECEIVER_MASTER_FILE_WRITE";
case F_GET_RECEIVER_MASTER_FILE_WRITE: return "F_GET_RECEIVER_MASTER_FILE_WRITE";
case F_SET_RECEIVER_OVERWRITE: return "F_SET_RECEIVER_OVERWRITE";
case F_GET_RECEIVER_OVERWRITE: return "F_GET_RECEIVER_OVERWRITE";
case F_ENABLE_RECEIVER_TEN_GIGA: return "F_ENABLE_RECEIVER_TEN_GIGA"; case F_ENABLE_RECEIVER_TEN_GIGA: return "F_ENABLE_RECEIVER_TEN_GIGA";
case F_SET_RECEIVER_FIFO_DEPTH: return "F_SET_RECEIVER_FIFO_DEPTH"; case F_SET_RECEIVER_FIFO_DEPTH: return "F_SET_RECEIVER_FIFO_DEPTH";
case F_RECEIVER_ACTIVATE: return "F_RECEIVER_ACTIVATE"; case F_RECEIVER_ACTIVATE: return "F_RECEIVER_ACTIVATE";
case F_STREAM_DATA_FROM_RECEIVER: return "F_STREAM_DATA_FROM_RECEIVER"; case F_SET_RECEIVER_STREAMING: return "F_SET_RECEIVER_STREAMING";
case F_GET_RECEIVER_STREAMING: return "F_GET_RECEIVER_STREAMING";
case F_RECEIVER_STREAMING_TIMER: return "F_RECEIVER_STREAMING_TIMER"; case F_RECEIVER_STREAMING_TIMER: return "F_RECEIVER_STREAMING_TIMER";
case F_SET_FLIPPED_DATA_RECEIVER: return "F_SET_FLIPPED_DATA_RECEIVER"; case F_SET_FLIPPED_DATA_RECEIVER: return "F_SET_FLIPPED_DATA_RECEIVER";
case F_SET_RECEIVER_FILE_FORMAT: return "F_SET_RECEIVER_FILE_FORMAT"; case F_SET_RECEIVER_FILE_FORMAT: return "F_SET_RECEIVER_FILE_FORMAT";
case F_GET_RECEIVER_FILE_FORMAT: return "F_GET_RECEIVER_FILE_FORMAT";
case F_SEND_RECEIVER_DETPOSID: return "F_SEND_RECEIVER_DETPOSID"; case F_SEND_RECEIVER_DETPOSID: return "F_SEND_RECEIVER_DETPOSID";
case F_SEND_RECEIVER_MULTIDETSIZE: return "F_SEND_RECEIVER_MULTIDETSIZE"; case F_SEND_RECEIVER_MULTIDETSIZE: return "F_SEND_RECEIVER_MULTIDETSIZE";
case F_SET_RECEIVER_STREAMING_PORT: return "F_SET_RECEIVER_STREAMING_PORT"; case F_SET_RECEIVER_STREAMING_PORT: return "F_SET_RECEIVER_STREAMING_PORT";
case F_RECEIVER_STREAMING_SRC_IP: return "F_RECEIVER_STREAMING_SRC_IP"; case F_GET_RECEIVER_STREAMING_PORT: return "F_GET_RECEIVER_STREAMING_PORT";
case F_SET_RECEIVER_STREAMING_SRC_IP: return "F_SET_RECEIVER_STREAMING_SRC_IP";
case F_GET_RECEIVER_STREAMING_SRC_IP: return "F_GET_RECEIVER_STREAMING_SRC_IP";
case F_SET_RECEIVER_SILENT_MODE: return "F_SET_RECEIVER_SILENT_MODE"; case F_SET_RECEIVER_SILENT_MODE: return "F_SET_RECEIVER_SILENT_MODE";
case F_GET_RECEIVER_SILENT_MODE: return "F_GET_RECEIVER_SILENT_MODE";
case F_ENABLE_GAPPIXELS_IN_RECEIVER: return "F_ENABLE_GAPPIXELS_IN_RECEIVER"; case F_ENABLE_GAPPIXELS_IN_RECEIVER: return "F_ENABLE_GAPPIXELS_IN_RECEIVER";
case F_RESTREAM_STOP_FROM_RECEIVER: return "F_RESTREAM_STOP_FROM_RECEIVER"; case F_RESTREAM_STOP_FROM_RECEIVER: return "F_RESTREAM_STOP_FROM_RECEIVER";
case F_ADDITIONAL_JSON_HEADER: return "F_ADDITIONAL_JSON_HEADER"; case F_SET_ADDITIONAL_JSON_HEADER: return "F_SET_ADDITIONAL_JSON_HEADER";
case F_GET_ADDITIONAL_JSON_HEADER: return "F_GET_ADDITIONAL_JSON_HEADER"; case F_GET_ADDITIONAL_JSON_HEADER: return "F_GET_ADDITIONAL_JSON_HEADER";
case F_RECEIVER_UDP_SOCK_BUF_SIZE: return "F_RECEIVER_UDP_SOCK_BUF_SIZE"; case F_RECEIVER_UDP_SOCK_BUF_SIZE: return "F_RECEIVER_UDP_SOCK_BUF_SIZE";
case F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE: return "F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE"; case F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE: return "F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE";
case F_SET_RECEIVER_FRAMES_PER_FILE: return "F_SET_RECEIVER_FRAMES_PER_FILE"; case F_SET_RECEIVER_FRAMES_PER_FILE: return "F_SET_RECEIVER_FRAMES_PER_FILE";
case F_GET_RECEIVER_FRAMES_PER_FILE: return "F_GET_RECEIVER_FRAMES_PER_FILE";
case F_RECEIVER_CHECK_VERSION: return "F_RECEIVER_CHECK_VERSION"; case F_RECEIVER_CHECK_VERSION: return "F_RECEIVER_CHECK_VERSION";
case F_RECEIVER_DISCARD_POLICY: return "F_RECEIVER_DISCARD_POLICY"; case F_SET_RECEIVER_DISCARD_POLICY: return "F_SET_RECEIVER_DISCARD_POLICY";
case F_RECEIVER_PADDING_ENABLE: return "F_RECEIVER_PADDING_ENABLE"; case F_GET_RECEIVER_DISCARD_POLICY: return "F_GET_RECEIVER_DISCARD_POLICY";
case F_RECEIVER_DEACTIVATED_PADDING_ENABLE: return "F_RECEIVER_DEACTIVATED_PADDING_ENABLE"; case F_SET_RECEIVER_PADDING: return "F_SET_RECEIVER_PADDING";
case F_GET_RECEIVER_PADDING: return "F_GET_RECEIVER_PADDING";
case F_SET_RECEIVER_DEACTIVATED_PADDING: return "F_SET_RECEIVER_DEACTIVATED_PADDING";
case F_GET_RECEIVER_DEACTIVATED_PADDING: return "F_GET_RECEIVER_DEACTIVATED_PADDING";
case F_RECEIVER_SET_READOUT_MODE: return "F_RECEIVER_SET_READOUT_MODE"; case F_RECEIVER_SET_READOUT_MODE: return "F_RECEIVER_SET_READOUT_MODE";
case F_RECEIVER_SET_ADC_MASK: return "F_RECEIVER_SET_ADC_MASK"; case F_RECEIVER_SET_ADC_MASK: return "F_RECEIVER_SET_ADC_MASK";
case F_SET_RECEIVER_DBIT_LIST: return "F_SET_RECEIVER_DBIT_LIST"; case F_SET_RECEIVER_DBIT_LIST: return "F_SET_RECEIVER_DBIT_LIST";
case F_GET_RECEIVER_DBIT_LIST: return "F_GET_RECEIVER_DBIT_LIST"; case F_GET_RECEIVER_DBIT_LIST: return "F_GET_RECEIVER_DBIT_LIST";
case F_RECEIVER_DBIT_OFFSET: return "F_RECEIVER_DBIT_OFFSET"; case F_SET_RECEIVER_DBIT_OFFSET: return "F_SET_RECEIVER_DBIT_OFFSET";
case F_GET_RECEIVER_DBIT_OFFSET: return "F_GET_RECEIVER_DBIT_OFFSET";
case F_SET_RECEIVER_QUAD: return "F_SET_RECEIVER_QUAD"; case F_SET_RECEIVER_QUAD: return "F_SET_RECEIVER_QUAD";
case F_SET_RECEIVER_READ_N_LINES: return "F_SET_RECEIVER_READ_N_LINES"; case F_SET_RECEIVER_READ_N_LINES: return "F_SET_RECEIVER_READ_N_LINES";
case F_SET_RECEIVER_UDP_IP: return "F_SET_RECEIVER_UDP_IP"; case F_SET_RECEIVER_UDP_IP: return "F_SET_RECEIVER_UDP_IP";
@ -534,6 +569,7 @@ static const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_SET_RECEIVER_NUM_INTERFACES: return "F_SET_RECEIVER_NUM_INTERFACES"; case F_SET_RECEIVER_NUM_INTERFACES: return "F_SET_RECEIVER_NUM_INTERFACES";
case F_RECEIVER_SET_ADC_MASK_10G: return "F_RECEIVER_SET_ADC_MASK_10G"; case F_RECEIVER_SET_ADC_MASK_10G: return "F_RECEIVER_SET_ADC_MASK_10G";
case F_RECEIVER_SET_NUM_COUNTERS: return "F_RECEIVER_SET_NUM_COUNTERS"; case F_RECEIVER_SET_NUM_COUNTERS: return "F_RECEIVER_SET_NUM_COUNTERS";
case F_INCREMENT_FILE_INDEX: return "F_INCREMENT_FILE_INDEX";
case NUM_REC_FUNCTIONS: return "NUM_REC_FUNCTIONS"; case NUM_REC_FUNCTIONS: return "NUM_REC_FUNCTIONS";

View File

@ -70,7 +70,19 @@ int ClientSocket::sendCommandThenRead(int fnum, const void *args,
void ClientSocket::readReply(int &ret, void *retval, size_t retval_size) { void ClientSocket::readReply(int &ret, void *retval, size_t retval_size) {
Receive(&ret, sizeof(ret)); try {
Receive(&ret, sizeof(ret));
}
// debugging
catch (sls::SocketError &e) {
if (socketType == "Receiver") {
throw ReceiverError("Receiver returned: " + std::string(e.what()));
} else if (socketType == "Detector") {
throw DetectorError("Detector returned: " + std::string(e.what()));
} else {
throw GuiError(e.what());
}
}
if (ret == slsDetectorDefs::FAIL) { if (ret == slsDetectorDefs::FAIL) {
char mess[MAX_STR_LENGTH]{}; char mess[MAX_STR_LENGTH]{};
// get error message // get error message

View File

@ -85,7 +85,7 @@ IpAddr HostnameToIp(const char *hostname) {
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;
if (getaddrinfo(hostname, nullptr, &hints, &result)) { if (getaddrinfo(hostname, nullptr, &hints, &result)) {
freeaddrinfo(result); freeaddrinfo(result);
throw RuntimeError("Could not convert hostname to ip"); throw RuntimeError("Could not convert hostname (" + std::string(hostname) + ") to ip");
} }
uint32_t ip = ((sockaddr_in *)result->ai_addr)->sin_addr.s_addr; uint32_t ip = ((sockaddr_in *)result->ai_addr)->sin_addr.s_addr;
freeaddrinfo(result); freeaddrinfo(result);

View File

@ -105,4 +105,10 @@ TEST_CASE("MAC Output operator gives same result as string", "[support]") {
CHECK(os.str() == addr.str()); CHECK(os.str() == addr.str());
} }
TEST_CASE("Copy construct a MacAddr"){
MacAddr addr{"00:50:c2:46:d9:a6"};
MacAddr addr2(addr);
CHECK(addr == addr2);
}
// TODO!(Erik) Look up a real hostname and verify the IP // TODO!(Erik) Look up a real hostname and verify the IP