merge from developer

This commit is contained in:
maliakal_d 2020-08-04 17:43:38 +02:00
commit 321ed13659
8 changed files with 32 additions and 131 deletions

View File

@ -409,9 +409,6 @@ void setupDetector() {
setDefaultDacs();
setASICDefaults();
// no roi for 1g and 10g
setumberOfDeserializers(MAX_NUM_DESERIALIZERS, 0);
setumberOfDeserializers(MAX_NUM_DESERIALIZERS, 1);
// dynamic range
setDynamicRange(DEFAULT_DYNAMIC_RANGE);
// enable all counters
@ -555,7 +552,7 @@ int setDynamicRange(int dr) {
// set it
bus_w(CONFIG_REG, bus_r(CONFIG_REG) & ~CONFIG_DYNAMIC_RANGE_MSK);
bus_w(CONFIG_REG, bus_r(CONFIG_REG) | regval);
updateNumberOfPackets();
updatePacketizing();
}
uint32_t regval = bus_r(CONFIG_REG) & CONFIG_DYNAMIC_RANGE_MSK;
@ -1036,7 +1033,7 @@ void setCounterMask(uint32_t arg) {
CONFIG_COUNTERS_ENA_MSK));
LOG(logDEBUG, ("Config Reg: 0x%x\n", bus_r(addr)));
updateNumberOfPackets();
updatePacketizing();
updateGatePeriod();
}
@ -1044,22 +1041,8 @@ uint32_t getCounterMask() {
return ((bus_r(CONFIG_REG) & CONFIG_COUNTERS_ENA_MSK) >>
CONFIG_COUNTERS_ENA_OFST);
}
void setumberOfDeserializers(int val, int tgEnable) {
const uint32_t addr = PKT_FRAG_REG;
LOG(logINFO, ("Setting Number of deserializers per packet: %d for %s\n",
val, (tgEnable ? "10g" : "1g")));
if (tgEnable) {
bus_w(addr, bus_r(addr) & ~PKT_FRAG_10G_N_DSR_PER_PKT_MSK);
bus_w(addr, bus_r(addr) | ((val << PKT_FRAG_10G_N_DSR_PER_PKT_OFST) &
PKT_FRAG_10G_N_DSR_PER_PKT_MSK));
} else {
bus_w(addr, bus_r(addr) & ~PKT_FRAG_1G_N_DSR_PER_PKT_MSK);
bus_w(addr, bus_r(addr) | ((val << PKT_FRAG_1G_N_DSR_PER_PKT_OFST) &
PKT_FRAG_1G_N_DSR_PER_PKT_MSK));
}
}
void updateNumberOfPackets() {
void updatePacketizing() {
const int ncounters = __builtin_popcount(getCounterMask());
const int tgEnable = enableTenGigabitEthernet(-1);
int packetsPerFrame = 0;
@ -1080,21 +1063,31 @@ void updateNumberOfPackets() {
}
packetsPerFrame = calculateDataBytes() / dataSize;
}
const int deserializersPerPacket = MAX_NUM_DESERIALIZERS / packetsPerFrame;
// bus_w()
LOG(logINFO, ("Number of Packets/Frame: %d for %s\n", packetsPerFrame,
(tgEnable ? "10g" : "1g")));
LOG(logINFO,
("[#Packets/Frame: %d, #Deserializers/Packet: %d] for %s\n",
packetsPerFrame, deserializersPerPacket, (tgEnable ? "10g" : "1g")));
const uint32_t addr = PKT_FRAG_REG;
if (tgEnable) {
bus_w(addr, bus_r(addr) & ~PKT_FRAG_10G_NUM_PACKETS_MSK);
bus_w(addr, bus_r(addr) |
((packetsPerFrame << PKT_FRAG_10G_NUM_PACKETS_OFST) &
PKT_FRAG_10G_NUM_PACKETS_MSK));
bus_w(addr, bus_r(addr) & ~PKT_FRAG_10G_N_DSR_PER_PKT_MSK);
bus_w(addr, bus_r(addr) | ((deserializersPerPacket
<< PKT_FRAG_10G_N_DSR_PER_PKT_OFST) &
PKT_FRAG_10G_N_DSR_PER_PKT_MSK));
} else {
bus_w(addr, bus_r(addr) & ~PKT_FRAG_1G_NUM_PACKETS_MSK);
bus_w(addr,
bus_r(addr) | ((packetsPerFrame << PKT_FRAG_1G_NUM_PACKETS_OFST) &
PKT_FRAG_1G_NUM_PACKETS_MSK));
bus_w(addr, bus_r(addr) & ~PKT_FRAG_1G_N_DSR_PER_PKT_MSK);
bus_w(addr, bus_r(addr) | ((deserializersPerPacket
<< PKT_FRAG_1G_N_DSR_PER_PKT_OFST) &
PKT_FRAG_1G_N_DSR_PER_PKT_MSK));
}
}
@ -1567,7 +1560,7 @@ int enableTenGigabitEthernet(int val) {
else {
bus_w(addr, bus_r(addr) & (~PKT_CONFIG_1G_INTERFACE_MSK));
}
updateNumberOfPackets();
updatePacketizing();
}
int oneG = ((bus_r(addr) & PKT_CONFIG_1G_INTERFACE_MSK) >>
PKT_CONFIG_1G_INTERFACE_OFST);

View File

@ -250,8 +250,7 @@ int getNumDigitalSamples();
#ifdef MYTHEN3D
void setCounterMask(uint32_t arg);
uint32_t getCounterMask();
void setumberOfDeserializers(int val, int tgEnable);
void updateNumberOfPackets();
void updatePacketizing();
#endif
#if defined(JUNGFRAUD) || defined(GOTTHARDD) || defined(CHIPTESTBOARDD) || \

View File

@ -2615,7 +2615,7 @@ void Module::sendToReceiver(int fnum, const void *args, size_t args_size,
}
template <typename Arg, typename Ret>
void Module::sendToReceiver(int fnum, const Arg &args, Ret &retval) {
void Module::sendToReceiver(int fnum, const Arg &args, Ret &retval) const{
LOG(logDEBUG1) << "Sending to Receiver: ["
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
<< ", " << args << ", " << sizeof(args) << ", "
@ -2627,7 +2627,7 @@ void Module::sendToReceiver(int fnum, const Arg &args, Ret &retval) {
}
template <typename Arg, typename Ret>
void Module::sendToReceiver(int fnum, const Arg &args, Ret &retval) const {
void Module::sendToReceiver(int fnum, const Arg &args, Ret &retval) {
static_cast<const Module &>(*this).sendToReceiver(fnum, args, retval);
}

View File

@ -527,8 +527,6 @@ int ClientInterface::set_num_frames(Interface &socket) {
verifyIdle(socket);
LOG(logDEBUG1) << "Setting num frames to " << value;
impl()->setNumberOfFrames(value);
int64_t retval = impl()->getNumberOfFrames();
validate(value, retval, "set number of frames", DEC);
return socket.Send(OK);
}
@ -539,10 +537,7 @@ int ClientInterface::set_num_triggers(Interface &socket) {
std::to_string(value));
}
verifyIdle(socket);
LOG(logDEBUG1) << "Setting num triggers to " << value;
impl()->setNumberOfTriggers(value);
int64_t retval = impl()->getNumberOfTriggers();
validate(value, retval, "set number of triggers", DEC);
return socket.Send(OK);
}
@ -552,10 +547,7 @@ int ClientInterface::set_num_bursts(Interface &socket) {
throw RuntimeError("Invalid number of bursts " + std::to_string(value));
}
verifyIdle(socket);
LOG(logDEBUG1) << "Setting num bursts to " << value;
impl()->setNumberOfBursts(value);
int64_t retval = impl()->getNumberOfBursts();
validate(value, retval, "set number of bursts", DEC);
return socket.Send(OK);
}
@ -568,8 +560,6 @@ int ClientInterface::set_num_add_storage_cells(Interface &socket) {
verifyIdle(socket);
LOG(logDEBUG1) << "Setting num additional storage cells to " << value;
impl()->setNumberOfAdditionalStorageCells(value);
int retval = impl()->getNumberOfAdditionalStorageCells();
validate(value, retval, "set number of additional storage cells", DEC);
return socket.Send(OK);
}
@ -581,8 +571,6 @@ int ClientInterface::set_timing_mode(Interface &socket) {
verifyIdle(socket);
LOG(logDEBUG1) << "Setting timing mode to " << value;
impl()->setTimingMode(static_cast<timingMode>(value));
int retval = impl()->getTimingMode();
validate(value, retval, "set timing mode", DEC);
return socket.Send(OK);
}
@ -594,8 +582,6 @@ int ClientInterface::set_burst_mode(Interface &socket) {
verifyIdle(socket);
LOG(logDEBUG1) << "Setting burst mode to " << value;
impl()->setBurstMode(static_cast<burstMode>(value));
int retval = impl()->getBurstMode();
validate(value, retval, "set burst mode", DEC);
return socket.Send(OK);
}
@ -752,11 +738,7 @@ int ClientInterface::set_streaming_frequency(Interface &socket) {
std::to_string(index));
}
verifyIdle(socket);
LOG(logDEBUG1) << "Setting streaming frequency: " << index;
impl()->setStreamingFrequency(index);
int retval = impl()->getStreamingFrequency();
validate(index, retval, "set streaming frequency", DEC);
return socket.Send(OK);
}
@ -839,12 +821,7 @@ int ClientInterface::set_file_index(Interface &socket) {
throw RuntimeError("Invalid file index: " + std::to_string(index));
}
verifyIdle(socket);
LOG(logDEBUG1) << "Setting file index: " << index;
impl()->setFileIndex(index);
int64_t retval = impl()->getFileIndex();
validate(index, retval, "set file index", DEC);
LOG(logDEBUG1) << "file index:" << retval;
return socket.Send(OK);
}
@ -866,8 +843,7 @@ int ClientInterface::get_missing_packets(Interface &socket) {
auto size = static_cast<int>(missing_packets.size());
socket.Send(OK);
socket.Send(size);
socket.Send(missing_packets.data(),
sizeof(missing_packets[0]) * missing_packets.size());
socket.Send(missing_packets);
return OK;
}
@ -886,10 +862,6 @@ int ClientInterface::set_file_write(Interface &socket) {
verifyIdle(socket);
LOG(logDEBUG1) << "Setting File write enable:" << enable;
impl()->setFileWriteEnable(enable);
int retval = impl()->getFileWriteEnable();
validate(enable, retval, "set file write enable", DEC);
LOG(logDEBUG1) << "file write enable:" << retval;
return socket.Send(OK);
}
@ -1082,12 +1054,7 @@ int ClientInterface::set_streaming_port(Interface &socket) {
throw RuntimeError("Invalid zmq port " + std::to_string(port));
}
verifyIdle(socket);
LOG(logDEBUG1) << "Setting streaming port:" << port;
impl()->setStreamingPort(port);
int retval = impl()->getStreamingPort();
validate(port, retval, "set streaming port", DEC);
LOG(logDEBUG1) << "streaming port:" << retval;
return socket.Send(OK);
}
@ -1132,10 +1099,6 @@ int ClientInterface::set_silent_mode(Interface &socket) {
verifyIdle(socket);
LOG(logDEBUG1) << "Setting silent mode:" << value;
impl()->setSilentMode(value);
auto retval = static_cast<int>(impl()->getSilentMode());
validate(value, retval, "set silent mode", DEC);
LOG(logDEBUG1) << "silent mode:" << retval;
return socket.Send(OK);
}
@ -1222,10 +1185,6 @@ int ClientInterface::set_frames_per_file(Interface &socket) {
verifyIdle(socket);
LOG(logDEBUG1) << "Setting frames per file: " << index;
impl()->setFramesPerFile(index);
auto retval = static_cast<int>(impl()->getFramesPerFile());
validate(index, retval, "set frames per file", DEC);
LOG(logDEBUG1) << "frames per file:" << retval;
return socket.Send(OK);
}
@ -1270,9 +1229,6 @@ int ClientInterface::set_discard_policy(Interface &socket) {
verifyIdle(socket);
LOG(logDEBUG1) << "Setting frames discard policy: " << index;
impl()->setFrameDiscardPolicy(static_cast<frameDiscardPolicy>(index));
int retval = impl()->getFrameDiscardPolicy();
validate(index, retval, "set discard policy", DEC);
LOG(logDEBUG1) << "frame discard policy:" << retval;
return socket.Send(OK);
}
@ -1290,10 +1246,6 @@ int ClientInterface::set_padding_enable(Interface &socket) {
verifyIdle(socket);
LOG(logDEBUG1) << "Setting frames padding enable: " << index;
impl()->setFramePaddingEnable(static_cast<bool>(index));
auto retval = static_cast<int>(impl()->getFramePaddingEnable());
validate(index, retval, "set frame padding enable", DEC);
LOG(logDEBUG1) << "Frame Padding Enable:" << retval;
return socket.Send(OK);
}
@ -1315,10 +1267,6 @@ int ClientInterface::set_deactivated_padding_enable(Interface &socket) {
verifyIdle(socket);
LOG(logDEBUG1) << "Setting deactivated padding enable: " << enable;
impl()->setDeactivatedPadding(enable > 0);
auto retval = static_cast<int>(impl()->getDeactivatedPadding());
validate(enable, retval, "set deactivated padding enable", DEC);
LOG(logDEBUG1) << "Deactivated Padding Enable: " << retval;
return socket.Send(OK);
}
@ -1614,12 +1562,10 @@ int ClientInterface::set_additional_json_parameter(Interface &socket) {
}
int ClientInterface::get_additional_json_parameter(Interface &socket) {
char arg[SHORT_STR_LENGTH]{};
socket.Receive(arg);
char retval[SHORT_STR_LENGTH]{};
sls::strcpy_safe(retval, impl()->getAdditionalJsonParameter(arg).c_str());
LOG(logDEBUG1) << "additional json parameter (" << arg << "):" << retval;
return socket.sendResult(retval);
std::string key = socket.Receive(SHORT_STR_LENGTH);
std::string value = impl()->getAdditionalJsonParameter(key);
value.resize(SHORT_STR_LENGTH);
return socket.sendResult(value);
}
int ClientInterface::get_progress(Interface &socket) {
@ -1691,9 +1637,6 @@ int ClientInterface::set_streaming_start_fnum(Interface &socket) {
verifyIdle(socket);
LOG(logDEBUG1) << "Setting streaming start fnum: " << index;
impl()->setStreamingStartingFrameNumber(index);
int retval = impl()->getStreamingStartingFrameNumber();
validate(index, retval, "set streaming start fnum", DEC);
return socket.Send(OK);
}
@ -1705,7 +1648,7 @@ int ClientInterface::set_rate_correct(Interface &socket) {
}
LOG(logDEBUG) << "Number of detectors for rate correction: " << index;
std::vector<int64_t> t(index);
socket.Receive(t.data(), t.size() * sizeof(t[0]));
socket.Receive(t);
verifyIdle(socket);
LOG(logINFOBLUE) << "Setting rate corrections[" << index << ']';
impl()->setRateCorrections(t);

View File

@ -393,21 +393,16 @@ std::string Implementation::getDetectorHostname() const {
}
void Implementation::setDetectorHostname(const std::string &c) {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
if (!c.empty())
detHostname = c;
LOG(logINFO) << "Detector Hostname: " << detHostname;
}
bool Implementation::getSilentMode() const {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
return silentMode;
}
void Implementation::setSilentMode(const bool i) {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
silentMode = i;
LOG(logINFO) << "Silent Mode: " << i;
}
@ -427,27 +422,20 @@ void Implementation::setFifoDepth(const uint32_t i) {
slsDetectorDefs::frameDiscardPolicy
Implementation::getFrameDiscardPolicy() const {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
return frameDiscardMode;
}
void Implementation::setFrameDiscardPolicy(const frameDiscardPolicy i) {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
if (i >= 0 && i < NUM_DISCARD_POLICIES)
frameDiscardMode = i;
frameDiscardMode = i;
LOG(logINFO) << "Frame Discard Policy: " << sls::ToString(frameDiscardMode);
}
bool Implementation::getFramePaddingEnable() const {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
return framePadding;
}
void Implementation::setFramePaddingEnable(const bool i) {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
framePadding = i;
LOG(logINFO) << "Frame Padding: " << framePadding;
}
@ -545,8 +533,6 @@ uint64_t Implementation::getFileIndex() const {
}
void Implementation::setFileIndex(const uint64_t i) {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
fileIndex = i;
LOG(logINFO) << "File Index: " << fileIndex;
}
@ -590,21 +576,16 @@ bool Implementation::getOverwriteEnable() const {
}
void Implementation::setOverwriteEnable(const bool b) {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
overwriteEnable = b;
LOG(logINFO) << "Overwrite Enable: "
<< (overwriteEnable ? "enabled" : "disabled");
}
uint32_t Implementation::getFramesPerFile() const {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
return framesPerFile;
}
void Implementation::setFramesPerFile(const uint32_t i) {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
framesPerFile = i;
LOG(logINFO) << "Frames per file: " << framesPerFile;
}
@ -1249,9 +1230,7 @@ uint32_t Implementation::getStreamingFrequency() const {
}
void Implementation::setStreamingFrequency(const uint32_t freq) {
if (streamingFrequency != freq) {
streamingFrequency = freq;
}
streamingFrequency = freq;
LOG(logINFO) << "Streaming Frequency: " << streamingFrequency;
}
@ -1273,37 +1252,30 @@ uint32_t Implementation::getStreamingStartingFrameNumber() const {
}
void Implementation::setStreamingStartingFrameNumber(const uint32_t fnum) {
if (streamingStartFnum != fnum) {
streamingStartFnum = fnum;
}
streamingStartFnum = fnum;
LOG(logINFO) << "Streaming Start Frame num: " << streamingStartFnum;
}
uint32_t Implementation::getStreamingPort() const {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
return streamingPort;
}
void Implementation::setStreamingPort(const uint32_t i) {
streamingPort = i;
LOG(logINFO) << "Streaming Port: " << streamingPort;
}
sls::IpAddr Implementation::getStreamingSourceIP() const {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
return streamingSrcIP;
}
void Implementation::setStreamingSourceIP(const sls::IpAddr ip) {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
streamingSrcIP = ip;
LOG(logINFO) << "Streaming Source IP: " << streamingSrcIP;
}
std::map<std::string, std::string>
Implementation::getAdditionalJsonHeader() const {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
return additionalJsonHeader;
}
@ -1448,7 +1420,6 @@ slsDetectorDefs::timingMode Implementation::getTimingMode() const {
}
void Implementation::setTimingMode(const slsDetectorDefs::timingMode i) {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
timingMode = i;
LOG(logINFO) << "Timing Mode: " << timingMode;
updateTotalNumberOfFrames();
@ -1460,7 +1431,6 @@ slsDetectorDefs::burstMode Implementation::getBurstMode() const {
}
void Implementation::setBurstMode(const slsDetectorDefs::burstMode i) {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
burstMode = i;
LOG(logINFO) << "Burst Mode: " << burstMode;
updateTotalNumberOfFrames();
@ -1781,12 +1751,10 @@ void Implementation::setQuad(const bool b) {
}
bool Implementation::getActivate() const {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
return activated;
}
bool Implementation::setActivate(bool enable) {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
activated = enable;
LOG(logINFO) << "Activation: " << (activated ? "enabled" : "disabled");
return activated;
@ -1797,12 +1765,10 @@ bool Implementation::getDeactivatedPadding() const {
return deactivatedPaddingEnable;
}
bool Implementation::setDeactivatedPadding(bool enable) {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
void Implementation::setDeactivatedPadding(bool enable) {
deactivatedPaddingEnable = enable;
LOG(logINFO) << "Deactivated Padding Enable: "
<< (deactivatedPaddingEnable ? "enabled" : "disabled");
return deactivatedPaddingEnable;
}
int Implementation::getReadNLines() const {

View File

@ -208,7 +208,7 @@ class Implementation : private virtual slsDetectorDefs {
bool setActivate(const bool enable);
bool getDeactivatedPadding() const;
/* [Eiger] */
bool setDeactivatedPadding(const bool enable);
void setDeactivatedPadding(const bool enable);
int getReadNLines() const;
/* [Eiger] */
void setReadNLines(const int value);

View File

@ -7,6 +7,6 @@
#define APIGOTTHARD 0x200804
#define APIGOTTHARD2 0x200804
#define APIJUNGFRAU 0x200804
#define APIMYTHEN3 0x200804
#define APIMOENCH 0x200730
#define APIEIGER 0x200804
#define APIMYTHEN3 0x200804