This commit is contained in:
maliakal_d 2021-08-17 14:05:59 +02:00
parent f72f678d45
commit c4c16ad9c0
10 changed files with 273 additions and 91 deletions

View File

@ -268,4 +268,6 @@ int get_adc_pipeline(int);
int set_dbit_pipeline(int);
int get_dbit_pipeline(int);
int get_module_id(int);
int set_module_id(int);
int set_module_id(int);
int get_dest_udp_list(int);
int set_dest_udp_list(int);

View File

@ -394,6 +394,8 @@ void function_table() {
flist[F_GET_DBIT_PIPELINE] = &get_dbit_pipeline;
flist[F_GET_MODULE_ID] = &get_module_id;
flist[F_SET_MODULE_ID] = &set_module_id;
flist[F_GET_DEST_UDP_LIST] = &get_dest_udp_list;
flist[F_SET_DEST_UDP_LIST] = &set_dest_udp_list;
// check
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
@ -8977,4 +8979,146 @@ int set_module_id(int file_des) {
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}
}
int get_dest_udp_list(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
uint32_t arg = 0;
uint32_t retvals[5] = {0, 0, 0, 0, 0};
uint64_t retvals64[2] = {0, 0};
LOG(logDEBUG1, ("Getting udp destination list for entry %d\n", arg));
#if !defined(EIGERD) && !defined(JUNGFRAUD)
functionNotImplemented();
#else
// get only (allow entry 0???? if so, then must talk to receiver)
retvals[] = getCurrentSource();
LOG(logDEBUG1, ("current source enable retval: %u\n", retvals[0]));
#ifdef JUNGFRAUD
if (retvals[0]) {
retvals[1] = getFixCurrentSource();
retvals[2] = getNormalCurrentSource();
retval_select = getSelectCurrentSource();
}
LOG(logDEBUG1, ("current source parameters retval: [enable:%d fix:%d, "
"normal:%d, select:%lld]\n",
retvals[0], retvals[1], retvals[2], retval_select));
#endif
#endif
Server_SendResult(file_des, INT32, NULL, 0);
if (ret != FAIL) {
sendData(file_des, retvals, sizeof(retvals), INT32);
sendData(file_des, &retval_select, sizeof(retval_select), INT64);
}
return ret;
}
int set_dest_udp_list(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
uint64_t select = 0;
int args[3] = {-1, -1, -1};
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
return printSocketReadError();
if (receiveData(file_des, &select, sizeof(select), INT64) < 0)
return printSocketReadError();
int enable = args[0];
int fix = args[1];
int normal = args[2];
LOG(logINFOBLUE, ("Setting current source [enable:%d, fix:%d, select:%lld, "
"normal:%d]\n",
enable, fix, (long long int)select, normal));
#if !defined(GOTTHARD2D) && !defined(JUNGFRAUD)
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
if (enable != 0 && enable != 1) {
ret = FAIL;
strcpy(mess, "Could not enable/disable current source. Enable can "
"be 0 or 1 only.\n");
LOG(logERROR, (mess));
}
// disable
else if (enable == 0 && (fix != -1 || normal != -1)) {
ret = FAIL;
strcpy(
mess,
"Could not disable current source. Requires no parameters.\n");
LOG(logERROR, (mess));
}
// enable
else if (enable == 1) {
#ifdef GOTTHARD2D
// no parameters allowed
if (fix != -1 || normal != -1) {
ret = FAIL;
strcpy(mess, "Could not enable current source. Fix and normal "
"are invalid parameters for this detector.\n");
LOG(logERROR, (mess));
}
#else
int chipVersion = getChipVersion();
if (ret == OK) {
if (chipVersion == 11) {
// require both
if ((fix != 0 && fix != 1) ||
(normal != 0 && normal != 1)) {
ret = FAIL;
strcpy(mess, "Could not enable current source. Invalid "
"or insufficient parameters (fix or "
"normal). or Options: 0 or 1.\n");
LOG(logERROR, (mess));
}
}
// chipv1.0
else {
// require only fix
if (fix != 0 && fix != 1) {
ret = FAIL;
strcpy(mess,
"Could not enable current source. Invalid value "
"for parameter (fix). Options: 0 or 1.\n");
LOG(logERROR, (mess));
} else if (normal != -1) {
ret = FAIL;
strcpy(mess, "Could not enable current source. Invalid "
"parmaeter (normal). Require only fix and "
"select for chipv1.0.\n");
LOG(logERROR, (mess));
}
// select can only be 0-63
else if (select > MAX_SELECT_CHIP10_VAL) {
ret = FAIL;
strcpy(mess,
"Could not enable current source. Invalid value "
"for parameter (select). Options: 0-63.\n");
LOG(logERROR, (mess));
}
}
}
#endif
}
if (ret == OK) {
#ifdef JUNGFRAUD
if (enable == 0) {
disableCurrentSource();
} else {
enableCurrentSource(fix, select, normal);
}
#else
setCurrentSource(enable);
#endif
int retval = getCurrentSource();
LOG(logDEBUG1, ("current source enable retval: %u\n", retval));
validate(&ret, mess, enable, retval, "set current source enable",
DEC);
}
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}

View File

@ -667,7 +667,7 @@ class Detector {
void setSourceUDPMAC2(const MacAddr mac, Positions pos = {});
Result<defs::udpDestination>
getDestinationUDPList(const int entry, Positions pos = {}) const;
getDestinationUDPList(const uint32_t entry, Positions pos = {}) const;
void setDestinationUDPList(const defs::udpDestination, const int module_id);

View File

@ -1380,40 +1380,69 @@ IpAddr CmdProxy::getIpFromAuto() {
}
defs::udpDestination CmdProxy::getUdpList() {
defs::udpDestination dest{};
uint32_t entry{};
uint32_t port{};
uint32_t port2{};
uint32_t ip{};
uint32_t ip2{};
uint64_t mac{};
uint64_t mac2{};
bool hasEntry = false;
for (auto it : args) {
size_t pos = it.find('=');
std::string key = it.substr(0, pos);
std::string value = it.substr(pos + 1);
if (key == "ip") {
if (key == "entry") {
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;
dest.ip = val.uint32();
ip = val.uint32();
} else {
dest.ip = IpAddr(value).uint32();
ip = IpAddr(value).uint32();
}
} else if (key == "ip2") {
if (value == "auto") {
auto val = getIpFromAuto();
LOG(logINFO) << "Setting udp_dstip2 of detector " << det_id
<< " to " << val;
dest.ip2 = val.uint32();
ip2 = val.uint32();
} else {
dest.ip2 = IpAddr(value).uint32();
ip2 = IpAddr(value).uint32();
}
} else if (key == "mac") {
dest.mac = MacAddr(value).uint64();
mac = MacAddr(value).uint64();
} else if (key == "mac2") {
dest.mac2 = MacAddr(value).uint64();
mac2 = MacAddr(value).uint64();
} else if (key == "port") {
dest.port = StringTo<int>(value);
port = StringTo<uint32_t>(value);
} else if (key == "port2") {
dest.port2 = StringTo<int>(value);
port2 = StringTo<uint32_t>(value);
}
}
return dest;
// necessary arguments
if (hasEntry && ip != 0 && mac != 0 && port != 0) {
if (ip2 == 0 && mac2 == 0) {
// default (no second interface)
if (port2 == 0) {
return defs::udpDestination(entry, port, ip, mac);
}
// eiger (second udp port)
else {
return defs::udpDestination(entry, port, ip, mac, port2);
}
}
// jungfrau and gotthard2 (second interface)
if (ip2 != 0 && mac2 != 0 && port2 != 0) {
return defs::udpDestination(entry, port, ip, mac, port2, ip2, mac2);
}
}
throw sls::RuntimeError("Insufficient arguments");
}
std::string CmdProxy::UDPDestinationList(int action) {

View File

@ -909,7 +909,7 @@ void Detector::setSourceUDPMAC2(const MacAddr mac, Positions pos) {
}
Result<defs::udpDestination>
Detector::getDestinationUDPList(const int entry, Positions pos) const {
Detector::getDestinationUDPList(const uint32_t entry, Positions pos) const {
return pimpl->Parallel(&Module::getDestinationUDPList, pos, entry);
}

View File

@ -940,21 +940,26 @@ void Module::setSourceUDPMAC2(const sls::MacAddr mac) {
}
slsDetectorDefs::udpDestination
Module::getDestinationUDPList(const int entry) const {
// return sendToDetector<udpDestination>(F_GET_DEST_UDP_LIST);
return bla;
Module::getDestinationUDPList(const uint32_t entry) const {
return sendToDetector<udpDestination>(F_GET_DEST_UDP_LIST, entry);
}
void Module::setDestinationUDPList(const slsDetectorDefs::udpDestination dest) {
LOG(logINFO) << "setting stuff to " << dest;
bla.entry = dest.entry;
bla.ip = dest.ip;
bla.ip2 = dest.ip2;
bla.mac = dest.mac;
bla.mac2 = dest.mac2;
bla.port = dest.port;
bla.port2 = dest.port2;
// sendToDetector(F_SET_DEST_UDP_LIST, dest, nullptr);
// set them in the default way so the receivers are also set up
if (dest.entry_ == 0) {
setDestinationUDPPort(dest.port_);
setDestinationUDPIP(dest.ip_);
setDestinationUDPMAC(dest.mac_);
if (dest.port_ != 0) {
setDestinationUDPPort2(dest.port2_);
}
if (dest.ip2_ != 0) {
setDestinationUDPIP2(dest.ip2_);
setDestinationUDPMAC2(dest.mac2_);
}
} else {
sendToDetector(F_SET_DEST_UDP_LIST, dest, nullptr);
}
}
sls::IpAddr Module::getDestinationUDPIP() const {

View File

@ -222,7 +222,7 @@ class Module : public virtual slsDetectorDefs {
void setSourceUDPMAC(const sls::MacAddr mac);
sls::MacAddr getSourceUDPMAC2() const;
void setSourceUDPMAC2(const sls::MacAddr mac);
udpDestination getDestinationUDPList(const int entry) const;
udpDestination getDestinationUDPList(const uint32_t entry) const;
void setDestinationUDPList(const defs::udpDestination dest);
sls::IpAddr getDestinationUDPIP() const;
void setDestinationUDPIP(const sls::IpAddr ip);
@ -745,7 +745,6 @@ class Module : public virtual slsDetectorDefs {
const int moduleId;
mutable sls::SharedMemory<sharedSlsDetector> shm{0, 0};
udpDestination bla{};
};
} // namespace sls

View File

@ -457,64 +457,63 @@ typedef struct {
} __attribute__((packed));
struct currentSrcParameters {
int enable;
int fix;
int normal;
uint64_t select;
int enable_;
int fix_;
int normal_;
uint64_t select_;
/** [Gotthard2][Jungfrau] disable */
currentSrcParameters() : enable(0), fix(-1), normal(-1), select(0) {}
currentSrcParameters()
: enable_(0), fix_(-1), normal_(-1), select_(0) {}
/** [Gotthard2] enable or disable */
explicit currentSrcParameters(bool ena)
: enable(static_cast<int>(ena)), fix(-1), normal(-1), select(0) {}
explicit currentSrcParameters(bool enable)
: enable_(static_cast<int>(enable)), fix_(-1), normal_(-1),
select_(0) {}
/** [Jungfrau](chipv1.0) enable current src with fix or no fix,
* selectColumn is 0 to 63 columns only */
currentSrcParameters(bool fixCurrent, uint64_t selectColumn)
: enable(1), fix(static_cast<int>(fixCurrent)), normal(-1),
select(selectColumn) {}
* select is 0 to 63 columns only */
currentSrcParameters(bool fix, uint64_t select)
: enable_(1), fix_(static_cast<int>(fix)), normal_(-1),
select_(select) {}
/** [Jungfrau](chipv1.1) enable current src, fixCurrent[fix|no fix],
* selectColumn is a mask of 63 bits (muliple columns can be selected
* simultaneously, normalCurrent [normal|low] */
currentSrcParameters(bool fixCurrent, uint64_t selectColumn,
bool normalCurrent)
: enable(1), fix(static_cast<int>(fixCurrent)),
normal(static_cast<int>(normalCurrent)), select(selectColumn) {}
/** [Jungfrau](chipv1.1) enable current src, fix[fix|no fix],
* select is a mask of 63 bits (muliple columns can be selected
* simultaneously, normal [normal|low] */
currentSrcParameters(bool fix, uint64_t select, bool normal)
: enable_(1), fix_(static_cast<int>(fix)),
normal_(static_cast<int>(normal)), select_(select) {}
bool operator==(const currentSrcParameters &other) const {
return ((enable == other.enable) && (fix == other.fix) &&
(normal == other.normal) && (select == other.select));
return ((enable_ == other.enable_) && (fix_ == other.fix_) &&
(normal_ == other.normal_) && (select_ == other.select_));
}
} __attribute__((packed));
struct udpDestination {
int entry;
uint32_t ip{};
uint32_t ip2{};
uint64_t mac{};
uint64_t mac2{};
int port{};
int port2{};
udpDestination();
uint32_t entry_{};
uint32_t port_{};
uint32_t port2_{};
uint32_t ip_{};
uint32_t ip2_{};
uint64_t mac_{};
uint64_t mac2_{};
udpDestination() {}
udpDestination(uint32_t entry, uint32_t port, uint32_t ip, uint64_t mac)
: entry_(entry), port_(port), ip_(ip), mac_(mac) {}
udpDestination(uint32_t entry, uint32_t port, uint32_t ip, uint64_t mac,
uint32_t port2)
: entry_(entry), port_(port), port2_(port2), ip_(ip), mac_(mac) {}
udpDestination(uint32_t entry, uint32_t port, uint32_t ip, uint64_t mac,
uint32_t port2, uint32_t ip2, uint64_t mac2)
: entry_(entry), port_(port), port2_(port2), ip_(ip), ip2_(ip2),
mac_(mac), mac2_(mac2) {}
bool operator==(const udpDestination &other) const {
return ((entry == other.entry) && (ip == other.ip) &&
(ip2 == other.ip2) && (mac == other.mac) &&
(mac2 == other.mac2) && (port == other.port) &&
(port2 == other.port2));
}
udpDestination operator=(const udpDestination &other) const {
if (this == &other)
return *this;
entry = other.entry;
ip = other.ip;
ip2 = other.ip2;
mac = other.mac;
mac2 = other.mac2;
port = other.port;
port2 = other.port2;
return *this;
return ((entry_ == other.entry_) && (port_ == other.port_) &&
(port2_ == other.port2_) && (ip_ == other.ip_) &&
(ip2_ == other.ip2_) && (mac_ == other.mac_) &&
(mac2_ == other.mac2_));
}
} __attribute__((packed));

View File

@ -245,6 +245,8 @@ enum detFuncs {
F_GET_DBIT_PIPELINE,
F_GET_MODULE_ID,
F_SET_MODULE_ID,
F_GET_DEST_UDP_LIST,
F_SET_DEST_UDP_LIST,
NUM_DET_FUNCTIONS,
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
@ -597,6 +599,8 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_GET_DBIT_PIPELINE: return "F_GET_DBIT_PIPELINE";
case F_GET_MODULE_ID: return "F_GET_MODULE_ID";
case F_SET_MODULE_ID: return "F_SET_MODULE_ID";
case F_GET_DEST_UDP_LIST: return "F_GET_DEST_UDP_LIST";
case F_SET_DEST_UDP_LIST: return "F_SET_DEST_UDP_LIST";
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";

View File

@ -116,25 +116,25 @@ std::ostream &operator<<(std::ostream &os,
std::string ToString(const slsDetectorDefs::currentSrcParameters &r) {
std::ostringstream oss;
if (r.fix < -1 || r.fix > 1 || r.normal < -1 || r.normal > 1) {
if (r.fix_ < -1 || r.fix_ > 1 || r.normal_ < -1 || r.normal_ > 1) {
throw sls::RuntimeError(
"Invalid current source parameters. Cannot print.");
}
oss << '[';
if (r.enable) {
if (r.enable_) {
oss << "enabled";
// [jungfrau]
if (r.fix != -1) {
oss << (r.fix == 1 ? ", fix" : ", nofix");
if (r.fix_ != -1) {
oss << (r.fix_ == 1 ? ", fix" : ", nofix");
}
// [jungfrau chip v1.1]
if (r.normal != -1) {
oss << ", " << ToStringHex(r.select, 16);
oss << (r.normal == 1 ? ", normal" : ", low");
if (r.normal_ != -1) {
oss << ", " << ToStringHex(r.select_, 16);
oss << (r.normal_ == 1 ? ", normal" : ", low");
}
// [jungfrau chip v1.0]
else {
oss << ", " << r.select;
oss << ", " << r.select_;
}
} else {
oss << "disabled";
@ -151,18 +151,18 @@ std::ostream &operator<<(std::ostream &os,
std::string ToString(const slsDetectorDefs::udpDestination &r) {
std::ostringstream oss;
oss << '[' << std::endl
<< "entry " << r.entry << std::endl
<< "ip " << IpAddr(r.ip) << std::endl
<< "mac " << MacAddr(r.mac) << std::endl
<< "port " << r.port << std::endl;
if (r.port2 != 0) {
oss << "port2 " << r.port2 << std::endl;
<< "entry " << r.entry_ << std::endl
<< "ip " << IpAddr(r.ip_) << std::endl
<< "mac " << MacAddr(r.mac_) << std::endl
<< "port " << r.port_ << std::endl;
if (r.port2_ != 0) {
oss << "port2 " << r.port2_ << std::endl;
}
if (r.ip2 != 0) {
oss << "ip2 " << IpAddr(r.ip2) << std::endl;
if (r.ip2_ != 0) {
oss << "ip2 " << IpAddr(r.ip2_) << std::endl;
}
if (r.mac2 != 0) {
oss << "mac2 " << MacAddr(r.mac2) << std::endl;
if (r.mac2_ != 0) {
oss << "mac2 " << MacAddr(r.mac2_) << std::endl;
}
oss << ']';
return oss.str();