merge conflict and binaries in

This commit is contained in:
2021-09-09 11:22:09 +02:00
35 changed files with 237 additions and 289 deletions

View File

@ -1379,15 +1379,8 @@ IpAddr CmdProxy::getIpFromAuto() {
return val;
}
defs::udpDestination CmdProxy::getUdpList() {
uint32_t entry{};
uint32_t port{};
uint32_t port2{};
uint32_t ip{};
uint32_t ip2{};
uint64_t mac{};
uint64_t mac2{};
UdpDestination CmdProxy::getUdpEntry() {
UdpDestination udpDestination{};
bool hasEntry = false;
for (auto it : args) {
@ -1395,40 +1388,40 @@ defs::udpDestination CmdProxy::getUdpList() {
std::string key = it.substr(0, pos);
std::string value = it.substr(pos + 1);
if (key == "entry") {
entry = StringTo<int>(value);
udpDestination.entry = StringTo<int>(value);
hasEntry = true;
} else if (key == "ip") {
if (value == "auto") {
auto val = getIpFromAuto();
LOG(logINFO) << "Setting udp_dstip of detector " << det_id
<< " to " << val;
ip = val.uint32();
udpDestination.ip = val;
} else {
ip = IpAddr(value).uint32();
udpDestination.ip = IpAddr(value);
}
} else if (key == "ip2") {
if (value == "auto") {
auto val = getIpFromAuto();
LOG(logINFO) << "Setting udp_dstip2 of detector " << det_id
<< " to " << val;
ip2 = val.uint32();
udpDestination.ip2 = val;
} else {
ip2 = IpAddr(value).uint32();
udpDestination.ip2 = IpAddr(value);
}
} else if (key == "mac") {
mac = MacAddr(value).uint64();
udpDestination.mac = MacAddr(value);
} else if (key == "mac2") {
mac2 = MacAddr(value).uint64();
udpDestination.mac2 = MacAddr(value);
} else if (key == "port") {
port = StringTo<uint32_t>(value);
udpDestination.port = StringTo<uint32_t>(value);
} else if (key == "port2") {
port2 = StringTo<uint32_t>(value);
udpDestination.port2 = StringTo<uint32_t>(value);
}
}
if (!hasEntry) {
throw sls::RuntimeError("Found no entry argument.");
}
return defs::udpDestination(entry, port, ip, mac, port2, ip2, mac2);
return udpDestination;
}
std::string CmdProxy::UDPDestinationList(int action) {
@ -1454,7 +1447,7 @@ std::string CmdProxy::UDPDestinationList(int action) {
if (args.empty()) {
WrongNumberOfParameters(1);
}
auto t = getUdpList();
auto t = getUdpEntry();
det->setDestinationUDPList(t, det_id);
os << ToString(args) << std::endl;
} else {

View File

@ -1117,7 +1117,7 @@ class CmdProxy {
std::string Trigger(int action);
/* Network Configuration (Detector<->Receiver) */
IpAddr getIpFromAuto();
slsDetectorDefs::udpDestination getUdpList();
UdpDestination getUdpEntry();
std::string UDPDestinationList(int action);
std::string UDPDestinationIP(int action);
std::string UDPDestinationIP2(int action);
@ -1203,11 +1203,10 @@ class CmdProxy {
"\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][CTB][Moench]"
"Serial number of detector.");
INTEGER_COMMAND_HEX(
moduleid, getModuleId, setModuleId, StringTo<int>,
"[value]\n\t[Gotthard2][Eiger][Mythen3] 16 bit value (ideally unique) "
"that is streamed out in the UDP header of the detector. "
"\n\t[Gotthard2] Can set it too.");
GET_COMMAND_HEX(
moduleid, getModuleId,
"\n\t[Gotthard2][Eiger][Mythen3] 16 bit value (ideally unique) "
"that is streamed out in the UDP header of the detector. Picked up from a file on the module.");
GET_COMMAND(type, getDetectorType,
"\n\tReturns detector type. Can be Eiger, Jungfrau, Gotthard, "

View File

@ -123,10 +123,6 @@ Result<int> Detector::getModuleId(Positions pos) const {
return pimpl->Parallel(&Module::getModuleId, pos);
}
void Detector::setModuleId(const int value, Positions pos) {
pimpl->Parallel(&Module::setModuleId, pos, value);
}
Result<int64_t> Detector::getReceiverVersion(Positions pos) const {
return pimpl->Parallel(&Module::getReceiverSoftwareVersion, pos);
}
@ -908,12 +904,12 @@ void Detector::setSourceUDPMAC2(const MacAddr mac, Positions pos) {
pimpl->Parallel(&Module::setSourceUDPMAC2, pos, mac);
}
Result<defs::udpDestination>
Detector::getDestinationUDPList(const uint32_t entry, Positions pos) const {
Result<UdpDestination> Detector::getDestinationUDPList(const uint32_t entry,
Positions pos) const {
return pimpl->Parallel(&Module::getDestinationUDPList, pos, entry);
}
void Detector::setDestinationUDPList(const defs::udpDestination dest,
void Detector::setDestinationUDPList(const UdpDestination dest,
const int module_id) {
if (module_id == -1 && size() > 1) {
throw sls::RuntimeError("Cannot set this parameter at detector level.");

View File

@ -27,8 +27,8 @@
namespace sls {
// creating new shm
Module::Module(detectorType type, int det_id, int module_id, bool verify)
: moduleId(module_id), shm(det_id, module_id) {
Module::Module(detectorType type, int det_id, int module_index, bool verify)
: moduleIndex(module_index), shm(det_id, module_index) {
// ensure shared memory was not created before
if (shm.IsExisting()) {
@ -42,8 +42,8 @@ Module::Module(detectorType type, int det_id, int module_id, bool verify)
}
// opening existing shm
Module::Module(int det_id, int module_id, bool verify)
: moduleId(module_id), shm(det_id, module_id) {
Module::Module(int det_id, int module_index, bool verify)
: moduleIndex(module_index), shm(det_id, module_index) {
// getDetectorType From shm will check if existing
detectorType type = getDetectorTypeFromShm(det_id, verify);
@ -98,10 +98,6 @@ int64_t Module::getSerialNumber() const {
int Module::getModuleId() const { return sendToDetector<int>(F_GET_MODULE_ID); }
void Module::setModuleId(const int value) {
return sendToDetector(F_SET_MODULE_ID, value, nullptr);
}
int64_t Module::getReceiverSoftwareVersion() const {
if (shm()->useReceiverFlag) {
return sendToReceiver<int64_t>(F_GET_RECEIVER_VERSION);
@ -144,7 +140,7 @@ slsDetectorDefs::xy Module::getNumberOfChannels() const {
void Module::updateNumberOfDetector(slsDetectorDefs::xy det) {
shm()->numberOfDetector = det;
int args[2] = {shm()->numberOfDetector.y, moduleId};
int args[2] = {shm()->numberOfDetector.y, moduleIndex};
sendToDetector(F_SET_POSITION, args, nullptr);
}
@ -825,13 +821,13 @@ std::vector<uint64_t> Module::getNumMissingPackets() const {
auto client = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort);
client.Send(F_GET_NUM_MISSING_PACKETS);
if (client.Receive<int>() == FAIL) {
throw RuntimeError("Receiver " + std::to_string(moduleId) +
throw RuntimeError("Receiver " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage());
} else {
auto nports = client.Receive<int>();
std::vector<uint64_t> retval(nports);
client.Receive(retval);
LOG(logDEBUG1) << "Missing packets of Receiver" << moduleId << ": "
LOG(logDEBUG1) << "Missing packets of Receiver" << moduleIndex << ": "
<< sls::ToString(retval);
return retval;
}
@ -941,31 +937,30 @@ void Module::setSourceUDPMAC2(const sls::MacAddr mac) {
sendToDetector(F_SET_SOURCE_UDP_MAC2, mac, nullptr);
}
slsDetectorDefs::udpDestination
Module::getDestinationUDPList(const uint32_t entry) const {
return sendToDetector<udpDestination>(F_GET_DEST_UDP_LIST, entry);
sls::UdpDestination Module::getDestinationUDPList(const uint32_t entry) const {
return sendToDetector<sls::UdpDestination>(F_GET_DEST_UDP_LIST, entry);
}
void Module::setDestinationUDPList(const slsDetectorDefs::udpDestination dest) {
void Module::setDestinationUDPList(const sls::UdpDestination dest) {
// set them in the default way so the receivers are also set up
if (dest.entry_ == 0) {
if (dest.port_ != 0) {
setDestinationUDPPort(dest.port_);
if (dest.entry == 0) {
if (dest.port != 0) {
setDestinationUDPPort(dest.port);
}
if (dest.ip_ != 0) {
setDestinationUDPIP(IpAddr(dest.ip_));
if (dest.ip != 0) {
setDestinationUDPIP(dest.ip);
}
if (dest.mac_ != 0) {
setDestinationUDPMAC(MacAddr(dest.mac_));
if (dest.mac != 0) {
setDestinationUDPMAC(dest.mac);
}
if (dest.port2_ != 0) {
setDestinationUDPPort2(dest.port2_);
if (dest.port2 != 0) {
setDestinationUDPPort2(dest.port2);
}
if (dest.ip2_ != 0) {
setDestinationUDPIP2(IpAddr(dest.ip2_));
if (dest.ip2 != 0) {
setDestinationUDPIP2(dest.ip2);
}
if (dest.mac2_ != 0) {
setDestinationUDPMAC2(MacAddr(dest.mac2_));
if (dest.mac2 != 0) {
setDestinationUDPMAC2(dest.mac2);
}
} else {
sendToDetector(F_SET_DEST_UDP_LIST, dest, nullptr);
@ -1000,7 +995,7 @@ void Module::setDestinationUDPIP(const IpAddr ip) {
if (shm()->useReceiverFlag) {
sls::MacAddr retval(0LU);
sendToReceiver(F_SET_RECEIVER_UDP_IP, ip, retval);
LOG(logINFO) << "Setting destination udp mac of detector " << moduleId
LOG(logINFO) << "Setting destination udp mac of detector " << moduleIndex
<< " to " << retval;
sendToDetector(F_SET_DEST_UDP_MAC, retval, nullptr);
}
@ -1020,7 +1015,7 @@ void Module::setDestinationUDPIP2(const IpAddr ip) {
if (shm()->useReceiverFlag) {
sls::MacAddr retval(0LU);
sendToReceiver(F_SET_RECEIVER_UDP_IP2, ip, retval);
LOG(logINFO) << "Setting destination udp mac2 of detector " << moduleId
LOG(logINFO) << "Setting destination udp mac2 of detector " << moduleIndex
<< " to " << retval;
sendToDetector(F_SET_DEST_UDP_MAC2, retval, nullptr);
}
@ -1078,7 +1073,7 @@ void Module::validateUDPConfiguration() {
std::string Module::printReceiverConfiguration() {
std::ostringstream os;
os << "\n\nDetector " << moduleId << "\nReceiver Hostname:\t"
os << "\n\nDetector " << moduleIndex << "\nReceiver Hostname:\t"
<< getReceiverHostname();
if (shm()->myDetectorType == JUNGFRAU) {
@ -1192,7 +1187,7 @@ void Module::setReceiverHostname(const std::string &receiverIP) {
retval.detType = shm()->myDetectorType;
retval.numberOfDetector.x = shm()->numberOfDetector.x;
retval.numberOfDetector.y = shm()->numberOfDetector.y;
retval.moduleId = moduleId;
retval.moduleIndex = moduleIndex;
memset(retval.hostname, 0, sizeof(retval.hostname));
strcpy_safe(retval.hostname, shm()->hostname);
@ -1202,13 +1197,13 @@ void Module::setReceiverHostname(const std::string &receiverIP) {
if (retval.udp_dstmac == 0 && retvals[0] != 0) {
LOG(logINFO) << "Setting destination udp mac of "
"detector "
<< moduleId << " to " << retvals[0];
<< moduleIndex << " to " << retvals[0];
sendToDetector(F_SET_DEST_UDP_MAC, retvals[0], nullptr);
}
if (retval.udp_dstmac2 == 0 && retvals[1] != 0) {
LOG(logINFO) << "Setting destination udp mac2 of "
"detector "
<< moduleId << " to " << retvals[1];
<< moduleIndex << " to " << retvals[1];
sendToDetector(F_SET_DEST_UDP_MAC2, retvals[1], nullptr);
}
@ -1524,7 +1519,7 @@ void Module::sendReceiverRateCorrections(const std::vector<int64_t> &t) {
receiver.Send(static_cast<int>(t.size()));
receiver.Send(t);
if (receiver.Receive<int>() == FAIL) {
throw RuntimeError("Receiver " + std::to_string(moduleId) +
throw RuntimeError("Receiver " + std::to_string(moduleIndex) +
" returned error: " + receiver.readErrorMessage());
}
}
@ -1789,7 +1784,7 @@ void Module::sendVetoPhoton(const int chipIndex,
client.Send(gainIndices);
client.Send(values);
if (client.Receive<int>() == FAIL) {
throw RuntimeError("Detector " + std::to_string(moduleId) +
throw RuntimeError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage());
}
}
@ -1801,7 +1796,7 @@ void Module::getVetoPhoton(const int chipIndex,
client.Send(F_GET_VETO_PHOTON);
client.Send(chipIndex);
if (client.Receive<int>() == FAIL) {
throw RuntimeError("Detector " + std::to_string(moduleId) +
throw RuntimeError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage());
}
@ -2036,7 +2031,7 @@ void Module::getBadChannels(const std::string &fname) const {
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
client.Send(F_GET_BAD_CHANNELS);
if (client.Receive<int>() == FAIL) {
throw RuntimeError("Detector " + std::to_string(moduleId) +
throw RuntimeError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage());
}
// receive badchannels
@ -2093,7 +2088,7 @@ void Module::setBadChannels(const std::string &fname) {
client.Send(badchannels);
}
if (client.Receive<int>() == FAIL) {
throw RuntimeError("Detector " + std::to_string(moduleId) +
throw RuntimeError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage());
}
}
@ -2407,7 +2402,7 @@ std::map<std::string, std::string> Module::getAdditionalJsonHeader() const {
auto client = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort);
client.Send(F_GET_ADDITIONAL_JSON_HEADER);
if (client.Receive<int>() == FAIL) {
throw RuntimeError("Receiver " + std::to_string(moduleId) +
throw RuntimeError("Receiver " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage());
} else {
auto size = client.Receive<int>();
@ -2456,7 +2451,7 @@ void Module::setAdditionalJsonHeader(
client.Send(&buff[0], buff.size());
if (client.Receive<int>() == FAIL) {
throw RuntimeError("Receiver " + std::to_string(moduleId) +
throw RuntimeError("Receiver " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage());
}
}
@ -3010,7 +3005,7 @@ slsDetectorDefs::detectorType Module::getDetectorTypeFromShm(int det_id,
shm.OpenSharedMemory();
if (verify && shm()->shmversion != SLS_SHMVERSION) {
std::ostringstream ss;
ss << "Single shared memory (" << det_id << "-" << moduleId
ss << "Single shared memory (" << det_id << "-" << moduleIndex
<< ":)version mismatch (expected 0x" << std::hex << SLS_SHMVERSION
<< " but got 0x" << shm()->shmversion << ")" << std::dec
<< ". Clear Shared memory to continue.";
@ -3021,7 +3016,7 @@ slsDetectorDefs::detectorType Module::getDetectorTypeFromShm(int det_id,
}
void Module::initSharedMemory(detectorType type, int det_id, bool verify) {
shm = SharedMemory<sharedSlsDetector>(det_id, moduleId);
shm = SharedMemory<sharedSlsDetector>(det_id, moduleIndex);
if (!shm.IsExisting()) {
shm.CreateSharedMemory();
initializeDetectorStructure(type);
@ -3029,7 +3024,7 @@ void Module::initSharedMemory(detectorType type, int det_id, bool verify) {
shm.OpenSharedMemory();
if (verify && shm()->shmversion != SLS_SHMVERSION) {
std::ostringstream ss;
ss << "Single shared memory (" << det_id << "-" << moduleId
ss << "Single shared memory (" << det_id << "-" << moduleIndex
<< ":) version mismatch (expected 0x" << std::hex
<< SLS_SHMVERSION << " but got 0x" << shm()->shmversion << ")"
<< std::dec << ". Clear Shared memory to continue.";
@ -3051,7 +3046,7 @@ void Module::initializeDetectorStructure(detectorType type) {
shm()->rxTCPPort = DEFAULT_PORTNO + 2;
shm()->useReceiverFlag = false;
shm()->zmqport = DEFAULT_ZMQ_CL_PORTNO +
(moduleId * ((shm()->myDetectorType == EIGER) ? 2 : 1));
(moduleIndex * ((shm()->myDetectorType == EIGER) ? 2 : 1));
shm()->zmqip = IpAddr{};
shm()->numUDPInterfaces = 1;
shm()->stoppedFlag = false;
@ -3164,7 +3159,7 @@ void Module::setModule(sls_detector_module &module, bool trimbits) {
client.Send(F_SET_MODULE);
sendModule(&module, client);
if (client.Receive<int>() == FAIL) {
throw RuntimeError("Detector " + std::to_string(moduleId) +
throw RuntimeError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage());
}
}
@ -3177,7 +3172,7 @@ void Module::updateReceiverStreamingIP() {
if (ip == 0) {
ip = HostnameToIp(shm()->rxHostname);
}
LOG(logINFO) << "Setting default receiver " << moduleId
LOG(logINFO) << "Setting default receiver " << moduleIndex
<< " streaming zmq ip to " << ip;
}
setReceiverStreamingIP(ip);
@ -3426,7 +3421,7 @@ std::string Module::calculateChecksum(char *buffer, ssize_t bytes) {
void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
// send program from memory to detector
LOG(logINFO) << "Sending programming binary (from pof) to module "
<< moduleId << " (" << shm()->hostname << ")";
<< moduleIndex << " (" << shm()->hostname << ")";
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
client.Send(F_PROGRAM_FPGA);
uint64_t filesize = buffer.size();
@ -3444,7 +3439,7 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
if (client.Receive<int>() == FAIL) {
std::cout << '\n';
std::ostringstream os;
os << "Detector " << moduleId << " (" << shm()->hostname << ")"
os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage();
throw RuntimeError(os.str());
}
@ -3464,7 +3459,7 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
if (client.Receive<int>() == FAIL) {
std::cout << '\n';
std::ostringstream os;
os << "Detector " << moduleId << " (" << shm()->hostname << ")"
os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage();
throw RuntimeError(os.str());
}
@ -3475,22 +3470,22 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
// checksum
if (client.Receive<int>() == FAIL) {
std::ostringstream os;
os << "Detector " << moduleId << " (" << shm()->hostname << ")"
os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage();
throw RuntimeError(os.str());
}
if (moduleId == 0) {
if (moduleIndex == 0) {
LOG(logINFO) << "Checksum verified";
}
// copied to flash
if (client.Receive<int>() == FAIL) {
std::ostringstream os;
os << "Detector " << moduleId << " (" << shm()->hostname << ")"
os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage();
throw RuntimeError(os.str());
}
if (moduleId == 0) {
if (moduleIndex == 0) {
LOG(logINFO) << "Copied to flash and checksum verified";
}
@ -3500,7 +3495,7 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
void Module::programFPGAviaNios(std::vector<char> buffer) {
LOG(logINFO) << "Sending programming binary (from rbf) to detector "
<< moduleId << " (" << shm()->hostname << ")";
<< moduleIndex << " (" << shm()->hostname << ")";
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
client.Send(F_PROGRAM_FPGA);
@ -3517,14 +3512,14 @@ void Module::programFPGAviaNios(std::vector<char> buffer) {
if (client.Receive<int>() == FAIL) {
std::ostringstream os;
os << "Detector " << moduleId << " (" << shm()->hostname << ")"
os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage();
throw RuntimeError(os.str());
}
client.Send(buffer);
if (client.Receive<int>() == FAIL) {
std::ostringstream os;
os << "Detector " << moduleId << " (" << shm()->hostname << ")"
os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage();
throw RuntimeError(os.str());
}

View File

@ -66,12 +66,12 @@ class Module : public virtual slsDetectorDefs {
/** creating new shared memory
verify is if shared memory version matches existing one */
explicit Module(detectorType type, int det_id = 0, int module_id = 0,
explicit Module(detectorType type, int det_id = 0, int module_index = 0,
bool verify = true);
/** opening existing shared memory
verify is if shared memory version matches existing one */
explicit Module(int det_id = 0, int module_id = 0, bool verify = true);
explicit Module(int det_id = 0, int module_index = 0, bool verify = true);
virtual ~Module();
@ -91,7 +91,6 @@ class Module : public virtual slsDetectorDefs {
int64_t getDetectorServerVersion() const;
int64_t getSerialNumber() const;
int getModuleId() const;
void setModuleId(const int value);
int64_t getReceiverSoftwareVersion() const;
static detectorType getTypeFromDetector(const std::string &hostname,
int cport = DEFAULT_PORTNO);
@ -222,8 +221,8 @@ class Module : public virtual slsDetectorDefs {
void setSourceUDPMAC(const sls::MacAddr mac);
sls::MacAddr getSourceUDPMAC2() const;
void setSourceUDPMAC2(const sls::MacAddr mac);
udpDestination getDestinationUDPList(const uint32_t entry) const;
void setDestinationUDPList(const defs::udpDestination dest);
sls::UdpDestination getDestinationUDPList(const uint32_t entry) const;
void setDestinationUDPList(const sls::UdpDestination dest);
int getNumberofUDPDestinations() const;
void setNumberofUDPDestinations(const int value);
int getFirstUDPDestination() const;
@ -748,7 +747,7 @@ class Module : public virtual slsDetectorDefs {
void programFPGAviaBlackfin(std::vector<char> buffer);
void programFPGAviaNios(std::vector<char> buffer);
const int moduleId;
const int moduleIndex;
mutable sls::SharedMemory<sharedSlsDetector> shm{0, 0};
};