mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 23:30:03 +02:00
commit
90d8ad40c9
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -113,6 +113,12 @@
|
||||
#define SYSTEM_STATUS_SLV_BRD_DTCT_MSK (0x00000001 << SYSTEM_STATUS_SLV_BRD_DTCT_OFST)
|
||||
|
||||
|
||||
#define MOD_ID_REG (0x0B * REG_OFFSET + BASE_CONTROL)
|
||||
|
||||
#define MOD_ID_OFST (0)
|
||||
#define MOD_ID_MSK (0x0000FFFF << MOD_ID_OFST)
|
||||
|
||||
|
||||
/* Config RW regiseter */
|
||||
#define CONFIG_REG (0x20 * REG_OFFSET + BASE_CONTROL)
|
||||
|
||||
|
Binary file not shown.
@ -283,7 +283,14 @@ u_int32_t getDetectorNumber() {
|
||||
|
||||
|
||||
int getModuleId(int *ret, char *mess) {
|
||||
return getModuleIdInFile(ret, mess, ID_FILE);
|
||||
return ((bus_r(MOD_ID_REG) & ~MOD_ID_MSK) >> MOD_ID_OFST);
|
||||
}
|
||||
|
||||
void setModuleId(int modid) {
|
||||
LOG(logINFOBLUE, ("Setting module id in fpga: %d\n", modid))
|
||||
bus_w(MOD_ID_REG, bus_r(MOD_ID_REG) & ~MOD_ID_MSK);
|
||||
bus_w(MOD_ID_REG,
|
||||
bus_r(MOD_ID_REG) | ((modid << MOD_ID_OFST) & MOD_ID_MSK));
|
||||
}
|
||||
|
||||
u_int64_t getDetectorMAC() {
|
||||
@ -445,12 +452,11 @@ void setupDetector() {
|
||||
setADIFDefaults();
|
||||
|
||||
// set module id in register
|
||||
getModuleIdInFile(&initError, initErrorMessage, ID_FILE);
|
||||
int modid = getModuleIdInFile(&initError, initErrorMessage, ID_FILE);
|
||||
if (initError == FAIL) {
|
||||
return;
|
||||
}
|
||||
// until firmware is done
|
||||
// setModuleId(modid);
|
||||
setModuleId(modid);
|
||||
|
||||
// set trigger flow for m3 (for all timing modes)
|
||||
bus_w(FLOW_TRIGGER_REG, bus_r(FLOW_TRIGGER_REG) | FLOW_TRIGGER_MSK);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "sls/sls_detector_defs.h"
|
||||
|
||||
#define REQRD_FRMWRE_VRSN (0x210201)
|
||||
#define REQRD_FRMWRE_VRSN (0x210910)
|
||||
#define KERNEL_DATE_VRSN "Wed May 20 13:58:38 CEST 2020"
|
||||
#define ID_FILE "detid_mythen3.txt"
|
||||
|
||||
|
@ -96,7 +96,7 @@ u_int32_t getDetectorNumber();
|
||||
#if defined(GOTTHARD2D) || defined(EIGERD) || defined(MYTHEN3D)
|
||||
int getModuleId(int *ret, char *mess);
|
||||
#endif
|
||||
#ifdef GOTTHARD2D
|
||||
#if defined(GOTTHARD2D) || defined(MYTHEN3D)
|
||||
void setModuleId(int modid);
|
||||
#endif
|
||||
u_int64_t getDetectorMAC();
|
||||
|
@ -1503,7 +1503,7 @@ int set_module(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
|
||||
#if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(GOTTHARD2D)
|
||||
#if !(defined(MYTHEN3D) || defined(EIGERD))
|
||||
functionNotImplemented();
|
||||
#else
|
||||
|
||||
@ -1524,7 +1524,6 @@ int set_module(int file_des) {
|
||||
} else
|
||||
module.dacs = myDac;
|
||||
|
||||
#if defined(EIGERD) || defined(MYTHEN3D)
|
||||
// allocate chans
|
||||
if (ret == OK) {
|
||||
myChan = malloc(getTotalNumberOfChannels() * sizeof(int));
|
||||
@ -1535,7 +1534,6 @@ int set_module(int file_des) {
|
||||
} else
|
||||
module.chanregs = myChan;
|
||||
}
|
||||
#endif
|
||||
// receive arguments
|
||||
if (ret == OK) {
|
||||
module.nchip = getNumberOfChips();
|
||||
@ -1573,6 +1571,7 @@ int set_module(int file_des) {
|
||||
|
||||
// setsettings
|
||||
#ifndef MYTHEN3D
|
||||
// m3 uses reg for chip (not settings)
|
||||
validate_settings((enum detectorSettings)(module.reg));
|
||||
#endif
|
||||
ret = setModule(module, mess);
|
||||
@ -8858,8 +8857,7 @@ int set_flip_rows(int file_des) {
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
|
||||
if (arg != 0 && arg != 1) {
|
||||
if ((check_detector_idle("set flip rows") == OK) && (arg != 0 && arg != 1)) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set flip rows. Invalid argument %d.\n",
|
||||
|
@ -67,7 +67,7 @@ int main(int argc, char *argv[]) {
|
||||
sls::Detector det(parser.multi_id());
|
||||
sls::CmdProxy proxy(&det);
|
||||
proxy.Call(parser.command(), parser.arguments(), parser.detector_id(),
|
||||
action);
|
||||
action, std::cout, parser.receiver_id());
|
||||
} catch (const sls::RuntimeError &e) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
@ -29,10 +29,11 @@ std::ostream &operator<<(std::ostream &os,
|
||||
|
||||
void CmdProxy::Call(const std::string &command,
|
||||
const std::vector<std::string> &arguments, int detector_id,
|
||||
int action, std::ostream &os) {
|
||||
int action, std::ostream &os, int receiver_id) {
|
||||
cmd = command;
|
||||
args = arguments;
|
||||
det_id = detector_id;
|
||||
rx_id = receiver_id;
|
||||
|
||||
std::string temp;
|
||||
while (temp != cmd) {
|
||||
@ -1381,16 +1382,13 @@ IpAddr CmdProxy::getIpFromAuto() {
|
||||
|
||||
UdpDestination CmdProxy::getUdpEntry() {
|
||||
UdpDestination udpDestination{};
|
||||
bool hasEntry = false;
|
||||
udpDestination.entry = rx_id;
|
||||
|
||||
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 == "entry") {
|
||||
udpDestination.entry = StringTo<int>(value);
|
||||
hasEntry = true;
|
||||
} else if (key == "ip") {
|
||||
if (key == "ip") {
|
||||
if (value == "auto") {
|
||||
auto val = getIpFromAuto();
|
||||
LOG(logINFO) << "Setting udp_dstip of detector " << det_id
|
||||
@ -1418,9 +1416,6 @@ UdpDestination CmdProxy::getUdpEntry() {
|
||||
udpDestination.port2 = StringTo<uint32_t>(value);
|
||||
}
|
||||
}
|
||||
if (!hasEntry) {
|
||||
throw sls::RuntimeError("Found no entry argument.");
|
||||
}
|
||||
return udpDestination;
|
||||
}
|
||||
|
||||
@ -1437,16 +1432,29 @@ std::string CmdProxy::UDPDestinationList(int action) {
|
||||
"set to ip of rx_hostname."
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
if (!args.empty()) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getDestinationUDPList(StringTo<int>(args[0]),
|
||||
std::vector<int>{det_id});
|
||||
if (det_id == -1) {
|
||||
throw sls::RuntimeError("udp_dstlist must be at module level.");
|
||||
}
|
||||
if (rx_id < 0 || rx_id >= MAX_UDP_DESTINATION) {
|
||||
throw sls::RuntimeError(
|
||||
"Invalid receiver index to get round robin entry.");
|
||||
}
|
||||
auto t = det->getDestinationUDPList(rx_id, std::vector<int>{det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.empty()) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
if (det_id == -1) {
|
||||
throw sls::RuntimeError("udp_dstlist must be at module level.");
|
||||
}
|
||||
if (rx_id < 0 || rx_id >= MAX_UDP_DESTINATION) {
|
||||
throw sls::RuntimeError(
|
||||
"Invalid receiver index to set round robin entry.");
|
||||
}
|
||||
auto t = getUdpEntry();
|
||||
det->setDestinationUDPList(t, det_id);
|
||||
os << ToString(args) << std::endl;
|
||||
|
@ -529,7 +529,8 @@ class CmdProxy {
|
||||
|
||||
void Call(const std::string &command,
|
||||
const std::vector<std::string> &arguments, int detector_id = -1,
|
||||
int action = -1, std::ostream &os = std::cout);
|
||||
int action = -1, std::ostream &os = std::cout,
|
||||
int receiver_id = -1);
|
||||
|
||||
bool ReplaceIfDepreciated(std::string &command);
|
||||
size_t GetFunctionMapSize() const noexcept { return functions.size(); };
|
||||
@ -541,6 +542,7 @@ class CmdProxy {
|
||||
std::string cmd;
|
||||
std::vector<std::string> args;
|
||||
int det_id{-1};
|
||||
int rx_id{-1};
|
||||
|
||||
template <typename V> std::string OutStringHex(const V &value) {
|
||||
if (value.equal())
|
||||
|
@ -256,7 +256,7 @@ void Detector::setSettingsPath(const std::string &value, Positions pos) {
|
||||
}
|
||||
|
||||
void Detector::loadTrimbits(const std::string &fname, Positions pos) {
|
||||
pimpl->Parallel(&Module::loadSettingsFile, pos, fname);
|
||||
pimpl->Parallel(&Module::loadTrimbits, pos, fname);
|
||||
}
|
||||
|
||||
Result<int> Detector::getAllTrimbits(Positions pos) const {
|
||||
|
@ -409,7 +409,7 @@ std::string Module::setSettingsDir(const std::string &dir) {
|
||||
return shm()->settingsDir;
|
||||
}
|
||||
|
||||
void Module::loadSettingsFile(const std::string &fname) {
|
||||
void Module::loadTrimbits(const std::string &fname) {
|
||||
// find specific file if it has detid in file name (.snxxx)
|
||||
if (shm()->myDetectorType == EIGER || shm()->myDetectorType == MYTHEN3) {
|
||||
std::ostringstream ostfn;
|
||||
|
@ -110,7 +110,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
detectorSettings isettings, bool trimbits);
|
||||
std::string getSettingsDir() const;
|
||||
std::string setSettingsDir(const std::string &dir);
|
||||
void loadSettingsFile(const std::string &fname);
|
||||
void loadTrimbits(const std::string &fname);
|
||||
int getAllTrimbits() const;
|
||||
void setAllTrimbits(int val);
|
||||
std::vector<int> getTrimEn() const;
|
||||
|
@ -2215,13 +2215,12 @@ TEST_CASE("udp_dstlist", "[.cmd]") {
|
||||
CmdProxy proxy(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::JUNGFRAU || det_type == defs::EIGER) {
|
||||
REQUIRE_NOTHROW(proxy.Call("udp_dstlist", {"0"}, -1, GET));
|
||||
REQUIRE_NOTHROW(proxy.Call("udp_dstlist", {}, 0, GET, std::cout, 0));
|
||||
REQUIRE_THROWS(proxy.Call(
|
||||
"udp_dstlist",
|
||||
{"entry=0", "ip=0.0.0.0", "mac=00:00:00:00:00:00", "port=1233"}, -1,
|
||||
PUT));
|
||||
"udp_dstlist", {"ip=0.0.0.0", "mac=00:00:00:00:00:00", "port=1233"},
|
||||
-1, PUT, std::cout, 0));
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("udp_dstlist", {"0"}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("udp_dstlist", {}, -1, GET, std::cout, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,10 +4,10 @@
|
||||
#define APIRECEIVER 0x210831
|
||||
#define APIGUI 0x210819
|
||||
|
||||
#define APICTB 0x210916
|
||||
#define APIGOTTHARD 0x210916
|
||||
#define APIGOTTHARD2 0x210916
|
||||
#define APIJUNGFRAU 0x210916
|
||||
#define APIMYTHEN3 0x210916
|
||||
#define APICTB 0x210917
|
||||
#define APIGOTTHARD 0x210917
|
||||
#define APIGOTTHARD2 0x210917
|
||||
#define APIJUNGFRAU 0x210917
|
||||
#define APIMYTHEN3 0x210917
|
||||
#define APIMOENCH 0x210916
|
||||
#define APIEIGER 0x210916
|
||||
#define APIEIGER 0x210917
|
||||
|
Loading…
x
Reference in New Issue
Block a user