mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 18:17:59 +02:00
set clock divider, phase and get clock freq for gotthard2, priliminary
This commit is contained in:
@ -141,7 +141,11 @@ class CmdProxy {
|
||||
{"rx_udpport", &CmdProxy::rx_udpport},
|
||||
{"rx_udpport2", &CmdProxy::rx_udpport2},
|
||||
{"numinterfaces", &CmdProxy::numinterfaces},
|
||||
{"selinterface", &CmdProxy::selinterface}};
|
||||
{"selinterface", &CmdProxy::selinterface},
|
||||
{"clkfreq", &CmdProxy::ClockFrequency},
|
||||
{"clkphase", &CmdProxy::ClockPhase},
|
||||
{"maxclkphaseshift", &CmdProxy::MaxClockPhaseShift},
|
||||
{"clkdiv", &CmdProxy::ClockDivider}};
|
||||
|
||||
StringMap depreciated_functions{{"r_readfreq", "rx_readfreq"},
|
||||
{"r_padding", "rx_padding"},
|
||||
@ -171,6 +175,10 @@ class CmdProxy {
|
||||
std::string Period(int action);
|
||||
std::string Exptime(int action);
|
||||
std::string SubExptime(int action);
|
||||
std::string ClockFrequency(int action);
|
||||
std::string ClockPhase(int action);
|
||||
std::string MaxClockPhaseShift(int action);
|
||||
std::string ClockDivider(int action);
|
||||
|
||||
INTEGER_COMMAND(
|
||||
rx_fifodepth, getRxFifoDepth, setRxFifoDepth, std::stoi,
|
||||
|
@ -1196,6 +1196,33 @@ class Detector {
|
||||
|
||||
Result<uint64_t> getRxCurrentFrameIndex(Positions pos = {}) const;
|
||||
|
||||
/** [Gotthard2] Hz */
|
||||
Result<int> getClockFrequency(int clkIndex, Positions pos = {});
|
||||
|
||||
/** [unknown] Hz */
|
||||
void setClockFrequency(int clkIndex, int value, Positions pos = {});
|
||||
|
||||
/** [Gotthard2] */
|
||||
Result<int> getClockPhase(int clkIndex, Positions pos = {});
|
||||
|
||||
/** [Gotthard2] */
|
||||
void setClockPhase(int clkIndex, int value, Positions pos = {});
|
||||
|
||||
/** [Gotthard2] */
|
||||
Result<int> getMaxClockPhaseShift(int clkIndex, Positions pos = {});
|
||||
|
||||
/** [Gotthard2] */
|
||||
Result<int> getClockPhaseinDegrees(int clkIndex, Positions pos = {});
|
||||
|
||||
/** [Gotthard2] */
|
||||
void setClockPhaseinDegrees(int clkIndex, int value, Positions pos = {});
|
||||
|
||||
/** [Gotthard2] */
|
||||
Result<int> getClockDivider(int clkIndex, Positions pos = {});
|
||||
|
||||
/** [Gotthard2] */
|
||||
void setClockDivider(int clkIndex, int value, Positions pos = {});
|
||||
|
||||
private:
|
||||
std::vector<int> getPortNumbers(int start_port);
|
||||
};
|
||||
|
@ -1679,6 +1679,27 @@ class slsDetector : public virtual slsDetectorDefs {
|
||||
*/
|
||||
void setDigitalIODelay(uint64_t pinMask, int delay);
|
||||
|
||||
/** [Gotthard2] */
|
||||
int getClockFrequency(int clkIndex);
|
||||
|
||||
/** [Gotthard2] */
|
||||
void setClockFrequency(int clkIndex, int value);
|
||||
|
||||
/** [Gotthard2] */
|
||||
int getClockPhase(int clkIndex, bool inDegrees);
|
||||
|
||||
/** [Gotthard2] */
|
||||
void setClockPhase(int clkIndex, int value, bool inDegrees);
|
||||
|
||||
/** [Gotthard2] */
|
||||
int getMaxClockPhaseShift(int clkIndex);
|
||||
|
||||
/** [Gotthard2] */
|
||||
int getClockDivider(int clkIndex);
|
||||
|
||||
/** [Gotthard2] */
|
||||
void setClockDivider(int clkIndex, int value);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Send function parameters to detector (control server)
|
||||
|
@ -181,4 +181,110 @@ std::string CmdProxy::ListCommands(int action) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string CmdProxy::ClockFrequency(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[n_clock (0-8)] [freq_in_Hz]\n\t[Gotthard2] Frequency of clock n_clock in Hz. Use clkdiv to set frequency." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
auto t = det->getClockFrequency(std::stoi(args[0]), {det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
det->setClockFrequency(std::stoi(args[0]), std::stoi(args[1]));
|
||||
//TODO print args
|
||||
os << std::stoi(args[1]) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
std::string CmdProxy::ClockPhase(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[n_clock (0-8)] [phase] [deg (optional)]\n\t[Gotthard2] Phase of clock n_clock. If deg, then phase shift in degrees, else absolute phase shift values." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() == 1) {
|
||||
auto t = det->getClockPhase(std::stoi(args[0]), {det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (args.size() == 2) {
|
||||
if (args[1] != "deg") {
|
||||
throw sls::RuntimeError("Cannot scan argument" + args[1] + ". Did you mean deg?");
|
||||
}
|
||||
auto t = det->getClockPhaseinDegrees(std::stoi(args[0]), {det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() == 2) {
|
||||
det->setClockPhase(std::stoi(args[0]), std::stoi(args[1]), {det_id});
|
||||
os << args[1] << '\n';
|
||||
} else if (args.size() == 3) {
|
||||
if (args[2] != "deg") {
|
||||
throw sls::RuntimeError("Cannot scan argument" + args[2] + ". Did you mean deg?");
|
||||
}
|
||||
det->setClockPhaseinDegrees(std::stoi(args[0]), std::stoi(args[1]), {det_id});
|
||||
os << std::stoi(args[1]) << '\n';
|
||||
} else {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::MaxClockPhaseShift(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[n_clock (0-8)]\n\t[Gotthard2] Absolute Maximum Phase shift of clock n_clock." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
auto t = det->getMaxClockPhaseShift(std::stoi(args[0]), {det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
throw sls::RuntimeError("Cannot put");
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::ClockDivider(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[n_clock (0-8)] [n_divider]\n\t[Gotthard2] Clock Divider of clock n_clock. Must be greater than 1." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
auto t = det->getClockDivider(std::stoi(args[0]), {det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
det->setClockDivider(std::stoi(args[0]), std::stoi(args[1]));
|
||||
//TODO print args
|
||||
os << std::stoi(args[1]) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
} // namespace sls
|
@ -1544,6 +1544,42 @@ Result<uint64_t> Detector::getRxCurrentFrameIndex(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getReceiverCurrentFrameIndex, pos);
|
||||
}
|
||||
|
||||
Result<int> Detector::getClockFrequency(int clkIndex, Positions pos) {
|
||||
return pimpl->Parallel(&slsDetector::getClockFrequency, pos, clkIndex);
|
||||
}
|
||||
|
||||
void Detector::setClockFrequency(int clkIndex, int value, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setClockFrequency, pos, clkIndex, value);
|
||||
}
|
||||
|
||||
Result<int> Detector::getClockPhase(int clkIndex, Positions pos) {
|
||||
return pimpl->Parallel(&slsDetector::getClockPhase, pos, clkIndex, false);
|
||||
}
|
||||
|
||||
void Detector::setClockPhase(int clkIndex, int value, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setClockPhase, pos, clkIndex, value, false);
|
||||
}
|
||||
|
||||
Result<int> Detector::getMaxClockPhaseShift(int clkIndex, Positions pos) {
|
||||
return pimpl->Parallel(&slsDetector::getMaxClockPhaseShift, pos, clkIndex);
|
||||
}
|
||||
|
||||
Result<int> Detector::getClockPhaseinDegrees(int clkIndex, Positions pos) {
|
||||
return pimpl->Parallel(&slsDetector::getClockPhase, pos, clkIndex, true);
|
||||
}
|
||||
|
||||
void Detector::setClockPhaseinDegrees(int clkIndex, int value, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setClockPhase, pos, clkIndex, value, true);
|
||||
}
|
||||
|
||||
Result<int> Detector::getClockDivider(int clkIndex, Positions pos) {
|
||||
return pimpl->Parallel(&slsDetector::getClockDivider, pos, clkIndex);
|
||||
}
|
||||
|
||||
void Detector::setClockDivider(int clkIndex, int value, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setClockDivider, pos, clkIndex, value);
|
||||
}
|
||||
|
||||
std::vector<int> Detector::getPortNumbers(int start_port) {
|
||||
int num_sockets_per_detector = 1;
|
||||
switch (getDetectorType({}).squash()) {
|
||||
|
@ -3425,6 +3425,57 @@ void slsDetector::setDigitalIODelay(uint64_t pinMask, int delay) {
|
||||
FILE_LOG(logDEBUG1) << "Digital IO Delay successful";
|
||||
}
|
||||
|
||||
int slsDetector::getClockFrequency(int clkIndex) {
|
||||
int retval = -1;
|
||||
FILE_LOG(logDEBUG1) << "Getting Clock " << clkIndex << " frequency";
|
||||
sendToDetector(F_GET_CLOCK_FREQUENCY, clkIndex, retval);
|
||||
FILE_LOG(logDEBUG1) << "Clock " << clkIndex << " frequency: " << retval;
|
||||
return retval;
|
||||
}
|
||||
|
||||
void slsDetector::setClockFrequency(int clkIndex, int value) {
|
||||
int args[]{clkIndex, value};
|
||||
FILE_LOG(logDEBUG1) << "Setting Clock " << clkIndex << " frequency to " << value;
|
||||
sendToDetector(F_SET_CLOCK_FREQUENCY, args, nullptr);
|
||||
}
|
||||
|
||||
int slsDetector::getClockPhase(int clkIndex, bool inDegrees) {
|
||||
int args[]{clkIndex, static_cast<int>(inDegrees)};
|
||||
int retval = -1;
|
||||
FILE_LOG(logDEBUG1) << "Getting Clock " << clkIndex << " phase " << (inDegrees ? "in degrees" : "");
|
||||
sendToDetector(F_GET_CLOCK_PHASE, args, retval);
|
||||
FILE_LOG(logDEBUG1) << "Clock " << clkIndex << " frequency: " << retval << (inDegrees ? "degrees" : "");
|
||||
return retval;
|
||||
}
|
||||
|
||||
void slsDetector::setClockPhase(int clkIndex, int value, bool inDegrees) {
|
||||
int args[]{clkIndex, value, static_cast<int>(inDegrees)};
|
||||
FILE_LOG(logDEBUG1) << "Setting Clock " << clkIndex << " phase to " << value << (inDegrees ? "degrees" : "");
|
||||
sendToDetector(F_SET_CLOCK_PHASE, args, nullptr);
|
||||
}
|
||||
|
||||
int slsDetector::getMaxClockPhaseShift(int clkIndex) {
|
||||
int retval = -1;
|
||||
FILE_LOG(logDEBUG1) << "Getting Max Phase Shift for Clock " << clkIndex;
|
||||
sendToDetector(F_GET_MAX_CLOCK_PHASE_SHIFT, clkIndex, retval);
|
||||
FILE_LOG(logDEBUG1) << "Max Phase Shift for Clock " << clkIndex << ": " << retval;
|
||||
return retval;
|
||||
}
|
||||
|
||||
int slsDetector::getClockDivider(int clkIndex) {
|
||||
int retval = -1;
|
||||
FILE_LOG(logDEBUG1) << "Getting Clock " << clkIndex << " divider";
|
||||
sendToDetector(F_GET_CLOCK_DIVIDER, clkIndex, retval);
|
||||
FILE_LOG(logDEBUG1) << "Clock " << clkIndex << " divider: " << retval;
|
||||
return retval;
|
||||
}
|
||||
|
||||
void slsDetector::setClockDivider(int clkIndex, int value) {
|
||||
int args[]{clkIndex, value};
|
||||
FILE_LOG(logDEBUG1) << "Setting Clock " << clkIndex << " divider to " << value;
|
||||
sendToDetector(F_SET_CLOCK_DIVIDER, args, nullptr);
|
||||
}
|
||||
|
||||
sls_detector_module slsDetector::interpolateTrim(sls_detector_module *a,
|
||||
sls_detector_module *b,
|
||||
const int energy, const int e1,
|
||||
|
@ -9,6 +9,7 @@
|
||||
auto GET = slsDetectorDefs::GET_ACTION;
|
||||
auto PUT = slsDetectorDefs::PUT_ACTION;
|
||||
|
||||
|
||||
TEST_CASE("rx_fifodepth", "[.cmd]") {
|
||||
|
||||
{
|
||||
|
Reference in New Issue
Block a user