merge fix with developer

This commit is contained in:
2022-03-28 10:26:28 +02:00
29 changed files with 365 additions and 136 deletions

View File

@ -1755,10 +1755,13 @@ class Detector {
/** [Jungfrau][Gotthard][CTB][Moench][Mythen3][Gotthard2]
* Advanced user Function!
* Program firmware from command line, after which detector controller is
* rebooted. [Jungfrau][CTB][Moench] fname is a pof file (full path) \n
* [Mythen3][Gotthard2] fname is an rbf file (full path)
* rebooted. forceDeleteNormalFile is true, if normal file found
* in device tree, it must be deleted, a new device drive created and
* programming continued.[Jungfrau][CTB][Moench] fname is a pof file (full
* path) \n [Mythen3][Gotthard2] fname is an rbf file (full path)
*/
void programFPGA(const std::string &fname, Positions pos = {});
void programFPGA(const std::string &fname, const bool forceDeleteNormalFile,
Positions pos = {});
/** [Jungfrau][CTB][Moench] Advanced user Function! */
void resetFPGA(Positions pos = {});

View File

@ -2876,19 +2876,31 @@ std::string CmdProxy::ProgramFpga(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[fname.pof | fname.rbf (full path)]\n\t[Jungfrau][Ctb][Moench] "
"Programs FPGA from pof file (full path). Then, detector "
"controller is rebooted \n\t[Mythen3][Gotthard2] Programs FPGA "
"from rbf file (full path). Then, detector controller is "
"rebooted."
os << "[fname.pof | fname.rbf (full "
"path)][(opitonal)--force-delete-normal-file]\n\t[Jungfrau][Ctb]["
"Moench] Programs FPGA from pof file (full path). Then, detector "
"controller is rebooted. \n\t\tUse --force-delete-normal-file "
"argument, if normal file found in device tree, it must be "
"deleted, a new device drive created and programming "
"continued.\n\t[Mythen3][Gotthard2] Programs FPGA from rbf file "
"(full path). Then, detector controller is rebooted."
<< '\n';
} else if (action == defs::GET_ACTION) {
throw sls::RuntimeError("Cannot get");
} else if (action == defs::PUT_ACTION) {
if (args.size() != 1) {
bool forceDeteleNormalFile = false;
if (args.size() == 2) {
if (args[1] != "--force-delete-normal-file") {
throw sls::RuntimeError(
"Could not scan second argument. Did you "
"mean --force-delete-normal-file?");
}
forceDeteleNormalFile = true;
} else if (args.size() != 1) {
WrongNumberOfParameters(1);
}
det->programFPGA(args[0], std::vector<int>{det_id});
det->programFPGA(args[0], forceDeteleNormalFile,
std::vector<int>{det_id});
os << "successful\n";
} else {
throw sls::RuntimeError("Unknown action");

View File

@ -883,7 +883,7 @@ Result<std::string> Detector::getScanErrorMessage(Positions pos) const {
Result<int> Detector::getNumberofUDPInterfaces(Positions pos) const {
// also called by vetostream (for gotthard2)
return pimpl->getNumberofUDPInterfaces(pos);
return pimpl->Parallel(&Module::getNumberofUDPInterfacesFromShm, pos);
}
void Detector::setNumberofUDPInterfaces(int n, Positions pos) {
@ -1751,7 +1751,7 @@ Result<defs::streamingInterface> Detector::getVetoStream(Positions pos) const {
// 3gbe
auto r3 = pimpl->Parallel(&Module::getVetoStream, pos);
// 10gbe (debugging interface) opens 2nd udp interface in receiver
auto r10 = pimpl->getNumberofUDPInterfaces(pos);
auto r10 = getNumberofUDPInterfaces(pos);
Result<defs::streamingInterface> res(r3.size());
for (unsigned int i = 0; i < res.size(); ++i) {
@ -1773,7 +1773,7 @@ void Detector::setVetoStream(defs::streamingInterface interface,
pimpl->Parallel(&Module::setVetoStream, pos, LOW_LATENCY_LINK);
// 10gbe (debugging interface) opens 2nd udp interface in receiver
int old_numinterfaces = pimpl->getNumberofUDPInterfaces(pos).tsquash(
int old_numinterfaces = getNumberofUDPInterfaces(pos).tsquash(
"retrieved inconsistent number of udp interfaces");
int numinterfaces =
(((interface & defs::streamingInterface::ETHERNET_10GB) ==
@ -2230,10 +2230,11 @@ void Detector::setAdditionalJsonParameter(const std::string &key,
// Advanced
void Detector::programFPGA(const std::string &fname, Positions pos) {
void Detector::programFPGA(const std::string &fname,
const bool forceDeleteNormalFile, Positions pos) {
LOG(logINFO) << "Updating Firmware...";
std::vector<char> buffer = pimpl->readProgrammingFile(fname);
pimpl->Parallel(&Module::programFPGA, pos, buffer);
pimpl->Parallel(&Module::programFPGA, pos, buffer, forceDeleteNormalFile);
rebootController(pos);
}
@ -2278,7 +2279,7 @@ void Detector::updateFirmwareAndServer(const std::string &sname,
LOG(logINFO) << "Updating Firmware and Detector Server (with tftp)...";
LOG(logINFO) << "Updating Detector Server (via tftp)...";
pimpl->Parallel(&Module::copyDetectorServer, pos, sname, hostname);
programFPGA(fname, pos);
programFPGA(fname, false, pos);
}
void Detector::updateFirmwareAndServer(const std::string &sname,
@ -2289,7 +2290,7 @@ void Detector::updateFirmwareAndServer(const std::string &sname,
std::vector<char> buffer = readBinaryFile(sname, "Update Detector Server");
std::string filename = sls::getFileNameFromFilePath(sname);
pimpl->Parallel(&Module::updateDetectorServer, pos, buffer, filename);
programFPGA(fname, pos);
programFPGA(fname, false, pos);
}
Result<bool> Detector::getUpdateMode(Positions pos) const {
@ -2399,7 +2400,7 @@ Result<ns> Detector::getMeasurementTime(Positions pos) const {
std::string Detector::getUserDetails() const { return pimpl->getUserDetails(); }
std::vector<int> Detector::getPortNumbers(int start_port) {
int num_sockets_per_detector = pimpl->getNumberofUDPInterfaces({}).tsquash(
int num_sockets_per_detector = getNumberofUDPInterfaces({}).tsquash(
"Number of UDP Interfaces is not consistent among modules");
std::vector<int> res;
res.reserve(size());

View File

@ -32,7 +32,8 @@
namespace sls {
DetectorImpl::DetectorImpl(int detector_index, bool verify, bool update)
: detectorIndex(detector_index), shm(detector_index, -1),ctb_shm(detector_index, -1, CtbConfig::shm_tag()) {
: detectorIndex(detector_index), shm(detector_index, -1),
ctb_shm(detector_index, -1, CtbConfig::shm_tag()) {
setupDetector(verify, update);
}
@ -44,7 +45,7 @@ void DetectorImpl::setupDetector(bool verify, bool update) {
if (update) {
updateUserdetails();
}
if (ctb_shm.IsExisting())
ctb_shm.OpenSharedMemory();
}
@ -94,7 +95,7 @@ void DetectorImpl::freeSharedMemory() {
shm.RemoveSharedMemory();
client_downstream = false;
if(ctb_shm.IsExisting())
if (ctb_shm.IsExisting())
ctb_shm.RemoveSharedMemory();
}
@ -155,7 +156,7 @@ void DetectorImpl::initSharedMemory(bool verify) {
}
}
// std::cout <<
// std::cout <<
}
void DetectorImpl::initializeDetectorStructure() {
@ -258,20 +259,11 @@ void DetectorImpl::setHostname(const std::vector<std::string> &name) {
}
updateDetectorSize();
// update zmq port (especially for eiger)
int numInterfaces = modules[0]->getNumberofUDPInterfaces();
if (numInterfaces == 2) {
for (size_t i = 0; i < modules.size(); ++i) {
modules[i]->setClientStreamingPort(DEFAULT_ZMQ_CL_PORTNO +
i * numInterfaces);
}
}
// Here we know the detector type and can add ctb shared memory
// if needed, CTB dac names are only on detector level
//Here we know the detector type and can add ctb shared memory
//if needed, CTB dac names are only on detector level
if (shm()->detType == defs::CHIPTESTBOARD){
if(ctb_shm.IsExisting())
if (shm()->detType == defs::CHIPTESTBOARD) {
if (ctb_shm.IsExisting())
ctb_shm.OpenSharedMemory();
else
ctb_shm.CreateSharedMemory();
@ -303,6 +295,13 @@ void DetectorImpl::addModule(const std::string &hostname) {
// get type by connecting
detectorType type = Module::getTypeFromDetector(host, port);
// gotthard cannot have more than 2 modules (50um=1, 25um=2
if ((type == GOTTHARD || type == GOTTHARD2) && modules.size() > 2) {
freeSharedMemory();
throw sls::RuntimeError("Gotthard cannot have more than 2 modules");
}
auto pos = modules.size();
modules.emplace_back(
sls::make_unique<Module>(type, detectorIndex, pos, false));
@ -310,11 +309,20 @@ void DetectorImpl::addModule(const std::string &hostname) {
modules[pos]->setControlPort(port);
modules[pos]->setStopPort(port + 1);
modules[pos]->setHostname(host, shm()->initialChecks);
// module type updated by now
shm()->detType = Parallel(&Module::getDetectorType, {})
.tsquash("Inconsistent detector types.");
// for moench and ctb
modules[pos]->updateNumberOfChannels();
// for eiger, jungfrau, gotthard2
modules[pos]->updateNumberofUDPInterfaces();
// update zmq port in case numudpinterfaces changed
int numInterfaces = modules[pos]->getNumberofUDPInterfacesFromShm();
modules[pos]->setClientStreamingPort(DEFAULT_ZMQ_CL_PORTNO +
pos * numInterfaces);
}
void DetectorImpl::updateDetectorSize() {
@ -1383,10 +1391,6 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
return buffer;
}
sls::Result<int> DetectorImpl::getNumberofUDPInterfaces(Positions pos) const {
return Parallel(&Module::getNumberofUDPInterfaces, pos);
}
sls::Result<int> DetectorImpl::getDefaultDac(defs::dacIndex index,
defs::detectorSettings sett,
Positions pos) {
@ -1398,16 +1402,15 @@ void DetectorImpl::setDefaultDac(defs::dacIndex index, int defaultValue,
Parallel(&Module::setDefaultDac, pos, index, defaultValue, sett);
}
std::vector<std::string> DetectorImpl::getCtbDacNames() const {
return ctb_shm()->getDacNames();
}
void DetectorImpl::setCtbDacNames(const std::vector<std::string>& names){
void DetectorImpl::setCtbDacNames(const std::vector<std::string> &names) {
ctb_shm()->setDacNames(names);
}
std::string DetectorImpl::getCtbDacName(defs::dacIndex i) const{
std::string DetectorImpl::getCtbDacName(defs::dacIndex i) const {
return ctb_shm()->getDacName(static_cast<int>(i));
}

View File

@ -293,7 +293,6 @@ class DetectorImpl : public virtual slsDetectorDefs {
*/
std::vector<char> readProgrammingFile(const std::string &fname);
sls::Result<int> getNumberofUDPInterfaces(Positions pos) const;
void setNumberofUDPInterfaces(int n, Positions pos);
sls::Result<int> getDefaultDac(defs::dacIndex index,
defs::detectorSettings sett,

View File

@ -976,9 +976,8 @@ int Module::getNumberofUDPInterfacesFromShm() const {
return shm()->numUDPInterfaces;
}
int Module::getNumberofUDPInterfaces() const {
void Module::updateNumberofUDPInterfaces() {
shm()->numUDPInterfaces = sendToDetector<int>(F_GET_NUM_INTERFACES);
return shm()->numUDPInterfaces;
}
void Module::setNumberofUDPInterfaces(int n) {
@ -1186,7 +1185,7 @@ std::string Module::printReceiverConfiguration() {
<< getReceiverHostname();
if (shm()->detType == JUNGFRAU) {
os << "\nNumber of Interfaces:\t" << getNumberofUDPInterfaces()
os << "\nNumber of Interfaces:\t" << getNumberofUDPInterfacesFromShm()
<< "\nSelected Interface:\t" << getSelectedUDPInterface();
}
@ -2591,12 +2590,14 @@ void Module::setAdditionalJsonParameter(const std::string &key,
}
// Advanced
void Module::programFPGA(std::vector<char> buffer) {
void Module::programFPGA(std::vector<char> buffer,
const bool forceDeleteNormalFile) {
switch (shm()->detType) {
case JUNGFRAU:
case CHIPTESTBOARD:
case MOENCH:
sendProgram(true, buffer, F_PROGRAM_FPGA, "Update Firmware");
sendProgram(true, buffer, F_PROGRAM_FPGA, "Update Firmware", "",
forceDeleteNormalFile);
break;
case MYTHEN3:
case GOTTHARD2:
@ -3219,10 +3220,10 @@ void Module::initializeModuleStructure(detectorType type) {
sls::strcpy_safe(shm()->rxHostname, "none");
shm()->rxTCPPort = DEFAULT_PORTNO + 2;
shm()->useReceiverFlag = false;
shm()->numUDPInterfaces = 1;
shm()->zmqport =
DEFAULT_ZMQ_CL_PORTNO + moduleIndex * shm()->numUDPInterfaces;
shm()->zmqip = IpAddr{};
shm()->numUDPInterfaces = 1;
shm()->stoppedFlag = false;
// get the Module parameters based on type
@ -3583,7 +3584,8 @@ sls_detector_module Module::readSettingsFile(const std::string &fname,
void Module::sendProgram(bool blackfin, std::vector<char> buffer,
const int functionEnum,
const std::string &functionType,
const std::string serverName) {
const std::string serverName,
const bool forceDeleteNormalFile) {
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
<< "): Sending " << functionType;
@ -3607,6 +3609,11 @@ void Module::sendProgram(bool blackfin, std::vector<char> buffer,
client.Send(sname);
}
// send forceDeleteNormalFile flag
if (blackfin) {
client.Send(static_cast<int>(forceDeleteNormalFile));
}
// validate memory allocation etc in detector
if (client.Receive<int>() == FAIL) {
std::ostringstream os;

View File

@ -219,7 +219,7 @@ class Module : public virtual slsDetectorDefs {
* *
* ************************************************/
int getNumberofUDPInterfacesFromShm() const;
int getNumberofUDPInterfaces() const;
void updateNumberofUDPInterfaces();
void setNumberofUDPInterfaces(int n);
int getSelectedUDPInterface() const;
void selectUDPInterface(int n);
@ -545,7 +545,8 @@ class Module : public virtual slsDetectorDefs {
* Advanced *
* *
* ************************************************/
void programFPGA(std::vector<char> buffer);
void programFPGA(std::vector<char> buffer,
const bool forceDeleteNormalFile);
void resetFPGA();
void copyDetectorServer(const std::string &fname,
const std::string &hostname);
@ -760,7 +761,8 @@ class Module : public virtual slsDetectorDefs {
bool trimbits = true);
void sendProgram(bool blackfin, std::vector<char> buffer,
const int functionEnum, const std::string &functionType,
const std::string serverName = "");
const std::string serverName = "",
const bool forceDeleteNormalFile = false);
void simulatingActivityinDetector(const std::string &functionType,
const int timeRequired);