speed separated

This commit is contained in:
2019-11-05 18:50:35 +01:00
parent 96d64778ee
commit 1f64d2a4e2
29 changed files with 830 additions and 714 deletions

View File

@ -405,20 +405,25 @@ std::string CmdProxy::ClockFrequency(int action) {
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]));
os << std::stoi(args[1]) << '\n';
} else {
throw sls::RuntimeError("Unknown action");
} else {
if (det->getDetectorType().squash(defs::GENERIC) != defs::GOTTHARD2) {
throw sls::RuntimeError("Not implemented for this detector.");
}
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]), {det_id});
os << std::stoi(args[1]) << '\n';
} else {
throw sls::RuntimeError("Unknown action");
}
}
return os.str();
}
@ -429,34 +434,39 @@ std::string CmdProxy::ClockPhase(int action) {
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 (det->getDetectorType().squash(defs::GENERIC) != defs::GOTTHARD2) {
throw sls::RuntimeError("Not implemented for this detector.");
}
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");
}
} 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();
}
@ -466,16 +476,21 @@ std::string CmdProxy::MaxClockPhaseShift(int action) {
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");
} else {
if (det->getDetectorType().squash(defs::GENERIC) != defs::GOTTHARD2) {
throw sls::RuntimeError("Not implemented for this detector.");
}
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();
}
@ -485,20 +500,25 @@ std::string CmdProxy::ClockDivider(int action) {
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]));
os << std::stoi(args[1]) << '\n';
} else {
throw sls::RuntimeError("Unknown action");
} else {
if (det->getDetectorType().squash(defs::GENERIC) != defs::GOTTHARD2) {
throw sls::RuntimeError("Not implemented for this detector.");
}
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]), {det_id});
os << std::stoi(args[1]) << '\n';
} else {
throw sls::RuntimeError("Unknown action");
}
}
return os.str();
}
@ -656,7 +676,7 @@ std::string CmdProxy::Threshold(int action) {
if (args.size() != 0) {
WrongNumberOfParameters(0);
}
auto t = det->getThresholdEnergy();
auto t = det->getThresholdEnergy({det_id});
os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) {
if (args.size() == 1) {
@ -932,7 +952,7 @@ std::string CmdProxy::TemperatureEvent(int action) {
if (std::stoi(args[0]) != 0) {
throw sls::RuntimeError("Unknown argument for temp event. Did you mean 0 to reset event?");
}
det->resetTemperatureEvent();
det->resetTemperatureEvent({det_id});
os << "cleared" << '\n';
} else {
throw sls::RuntimeError("Unknown action");
@ -1017,8 +1037,8 @@ std::string CmdProxy::Samples(int action) {
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
det->setNumberOfAnalogSamples(std::stoi(args[0]));
det->setNumberOfDigitalSamples(std::stoi(args[0]));
det->setNumberOfAnalogSamples(std::stoi(args[0]), {det_id});
det->setNumberOfDigitalSamples(std::stoi(args[0]), {det_id});
os << args.front() << '\n';
} else {
throw sls::RuntimeError("Unknown action");
@ -1081,7 +1101,7 @@ std::string CmdProxy::SlowAdc(int action) {
auto t = det->getTemperature(defs::SLOW_ADC_TEMP, {det_id});
os << OutString(t) << " °C\n";
} else {
auto t = det->getSlowADC(static_cast<defs::dacIndex>(nchan + defs::SLOW_ADC0));
auto t = det->getSlowADC(static_cast<defs::dacIndex>(nchan + defs::SLOW_ADC0), {det_id});
os << OutString(t) << '\n';
}
} else if (action == defs::PUT_ACTION) {
@ -1140,7 +1160,7 @@ std::string CmdProxy::DigitalIODelay(int action) {
if (args.size() != 2) {
WrongNumberOfParameters(2);
}
det->setDigitalIODelay(stoulHex(args[0]), std::stoi(args[1]));
det->setDigitalIODelay(stoulHex(args[0]), std::stoi(args[1]), {det_id});
os << sls::ToString(args) << '\n';
} else {
throw sls::RuntimeError("Unknown action");
@ -1162,7 +1182,7 @@ std::string CmdProxy::Pattern(int action) {
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
det->setPattern(args[0]);
det->setPattern(args[0], {det_id});
os << args.front() << '\n';
} else {
throw sls::RuntimeError("Unknown action");
@ -1185,7 +1205,7 @@ std::string CmdProxy::PatternWord(int action) {
if (args.size() != 2) {
WrongNumberOfParameters(2);
}
det->setPatternWord(stoiHex(args[0]), stoulHex(args[1]));
det->setPatternWord(stoiHex(args[0]), stoulHex(args[1]), {det_id});
os << sls::ToString(args) << '\n';
} else {
throw sls::RuntimeError("Unknown action");

View File

@ -169,8 +169,7 @@ Result<ns> Detector::getPeriodLeft(Positions pos) const {
}
Result<defs::speedLevel> Detector::getSpeed(Positions pos) const {
auto res = pimpl->Parallel(&slsDetector::setSpeed, pos, defs::CLOCK_DIVIDER, -1,
0);
auto res = pimpl->Parallel(&slsDetector::getClockDivider, pos, defs::RUN_CLOCK);
Result<defs::speedLevel> speedResult(res.size());
for (unsigned int i = 0; i < res.size(); ++i) {
speedResult[i] = static_cast<defs::speedLevel>(res[i]);
@ -179,29 +178,29 @@ Result<defs::speedLevel> Detector::getSpeed(Positions pos) const {
}
void Detector::setSpeed(defs::speedLevel value, Positions pos) {
pimpl->Parallel(&slsDetector::setSpeed, pos, defs::CLOCK_DIVIDER,
static_cast<int>(value), 0);
pimpl->Parallel(&slsDetector::setClockDivider, pos, defs::RUN_CLOCK,
static_cast<int>(value));
}
Result<int> Detector::getADCPhase(Positions pos) const {
return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::ADC_PHASE, -1, 0);
return pimpl->Parallel(&slsDetector::getClockPhase, pos, defs::ADC_CLOCK, false);
}
void Detector::setADCPhase(int value, Positions pos) {
pimpl->Parallel(&slsDetector::setSpeed, pos, defs::ADC_PHASE, value, 0);
pimpl->Parallel(&slsDetector::setClockPhase, pos, defs::ADC_CLOCK, value, false);
}
Result<int> Detector::getMaxADCPhaseShift(Positions pos) const {
return pimpl->Parallel(&slsDetector::setSpeed, pos,
defs::MAX_ADC_PHASE_SHIFT, -1, 0);
return pimpl->Parallel(&slsDetector::getMaxClockPhaseShift, pos,
defs::ADC_CLOCK);
}
Result<int> Detector::getADCPhaseInDegrees(Positions pos) const {
return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::ADC_PHASE, -1, 1);
return pimpl->Parallel(&slsDetector::getClockPhase, pos, defs::ADC_CLOCK, true);
}
void Detector::setADCPhaseInDegrees(int value, Positions pos) {
pimpl->Parallel(&slsDetector::setSpeed, pos, defs::ADC_PHASE, value, 1);
pimpl->Parallel(&slsDetector::setClockPhase, pos, defs::ADC_CLOCK, value, true);
}
Result<int> Detector::getClockFrequency(int clkIndex, Positions pos) {
@ -1119,78 +1118,68 @@ void Detector::setReadoutMode(defs::readoutMode value, Positions pos) {
}
Result<int> Detector::getDBITPhase(Positions pos) const {
return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::DBIT_PHASE, -1,
0);
return pimpl->Parallel(&slsDetector::getClockPhase, pos, defs::DBIT_CLOCK, false);
}
void Detector::setDBITPhase(int value, Positions pos) {
pimpl->Parallel(&slsDetector::setSpeed, pos, defs::DBIT_PHASE, value, 0);
pimpl->Parallel(&slsDetector::setClockPhase, pos, defs::DBIT_CLOCK, value, false);
}
Result<int> Detector::getMaxDBITPhaseShift(Positions pos) const {
return pimpl->Parallel(&slsDetector::setSpeed, pos,
defs::MAX_DBIT_PHASE_SHIFT, -1, 0);
return pimpl->Parallel(&slsDetector::getMaxClockPhaseShift, pos,
defs::DBIT_CLOCK);
}
Result<int> Detector::getDBITPhaseInDegrees(Positions pos) const {
return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::DBIT_PHASE, -1,
1);
return pimpl->Parallel(&slsDetector::getClockPhase, pos, defs::DBIT_CLOCK, true);
}
void Detector::setDBITPhaseInDegrees(int value, Positions pos) {
pimpl->Parallel(&slsDetector::setSpeed, pos, defs::DBIT_PHASE, value, 1);
pimpl->Parallel(&slsDetector::setClockPhase, pos, defs::DBIT_CLOCK, value, true);
}
Result<int> Detector::getADCClock(Positions pos) const {
return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::ADC_CLOCK, -1, 0);
return pimpl->Parallel(&slsDetector::getClockFrequency, pos, defs::ADC_CLOCK);
}
void Detector::setADCClock(int value_in_MHz, Positions pos) {
pimpl->Parallel(&slsDetector::setSpeed, pos, defs::ADC_CLOCK, value_in_MHz,
0);
pimpl->Parallel(&slsDetector::setClockFrequency, pos, defs::ADC_CLOCK, value_in_MHz);
}
Result<int> Detector::getDBITClock(Positions pos) const {
return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::DBIT_CLOCK, -1,
0);
return pimpl->Parallel(&slsDetector::getClockFrequency, pos, defs::DBIT_CLOCK);
}
void Detector::setDBITClock(int value_in_MHz, Positions pos) {
pimpl->Parallel(&slsDetector::setSpeed, pos, defs::DBIT_CLOCK, value_in_MHz,
0);
pimpl->Parallel(&slsDetector::setClockFrequency, pos, defs::DBIT_CLOCK, value_in_MHz);
}
Result<int> Detector::getRUNClock(Positions pos) const {
return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::CLOCK_DIVIDER, -1,
0);
return pimpl->Parallel(&slsDetector::getClockFrequency, pos, defs::RUN_CLOCK);
}
void Detector::setRUNClock(int value_in_MHz, Positions pos) {
pimpl->Parallel(&slsDetector::setSpeed, pos, defs::CLOCK_DIVIDER,
value_in_MHz, 0);
pimpl->Parallel(&slsDetector::setClockFrequency, pos, defs::RUN_CLOCK, value_in_MHz);
}
Result<int> Detector::getSYNCClock(Positions pos) const {
return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::SYNC_CLOCK, -1,
0);
return pimpl->Parallel(&slsDetector::getClockFrequency, pos, defs::SYNC_CLOCK);
}
Result<int> Detector::getADCPipeline(Positions pos) const {
return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::ADC_PIPELINE, -1,
0);
return pimpl->Parallel(&slsDetector::getPipeline, pos, defs::ADC_CLOCK);
}
void Detector::setADCPipeline(int value, Positions pos) {
pimpl->Parallel(&slsDetector::setSpeed, pos, defs::ADC_PIPELINE, value, 0);
pimpl->Parallel(&slsDetector::setPipeline, pos, defs::ADC_CLOCK, value);
}
Result<int> Detector::getDBITPipeline(Positions pos) const {
return pimpl->Parallel(&slsDetector::setSpeed, pos, defs::DBIT_PIPELINE, -1,
0);
return pimpl->Parallel(&slsDetector::getPipeline, pos, defs::DBIT_CLOCK);
}
void Detector::setDBITPipeline(int value, Positions pos) {
pimpl->Parallel(&slsDetector::setSpeed, pos, defs::DBIT_PIPELINE, value, 0);
pimpl->Parallel(&slsDetector::setPipeline, pos, defs::DBIT_CLOCK, value);
}
Result<int> Detector::getVoltage(defs::dacIndex index, Positions pos) const {

View File

@ -1460,16 +1460,6 @@ int64_t slsDetector::getMeasurementTime() const {
return retval;
}
int slsDetector::setSpeed(speedVariable sp, int value, int mode) {
int args[]{static_cast<int>(sp), value, mode};
int retval = -1;
FILE_LOG(logDEBUG1) << "Setting speed index " << sp << " to " << value
<< " mode: " << mode;
sendToDetector(F_SET_SPEED, args, retval);
FILE_LOG(logDEBUG1) << "Speed index " << sp << ": " << retval;
return retval;
}
int slsDetector::setDynamicRange(int n) {
// TODO! Properly handle fail
int prevDr = shm()->dynamicRange;
@ -1494,9 +1484,9 @@ int slsDetector::setDynamicRange(int n) {
updateRateCorrection();
// update speed for usability
if (dr == 32) {
FILE_LOG(logINFO) << "Setting Clock to Quarter Speed to cope with Dynamic Range of 32"; setSpeed(CLOCK_DIVIDER, 2);
FILE_LOG(logINFO) << "Setting Clock to Quarter Speed to cope with Dynamic Range of 32"; setClockDivider(RUN_CLOCK, 2);
} else if (dr == 16) {
FILE_LOG(logINFO) << "Setting Clock to Half Speed to cope with Dynamic Range of 16"; setSpeed(CLOCK_DIVIDER, 1);
FILE_LOG(logINFO) << "Setting Clock to Half Speed to cope with Dynamic Range of 16"; setClockDivider(RUN_CLOCK, 1);
}
}
@ -3549,6 +3539,21 @@ void slsDetector::setClockDivider(int clkIndex, int value) {
sendToDetector(F_SET_CLOCK_DIVIDER, args, nullptr);
}
int slsDetector::getPipeline(int clkIndex) {
int retval = -1;
FILE_LOG(logDEBUG1) << "Getting Clock " << clkIndex << " pipeline";
sendToDetector(F_GET_PIPELINE, clkIndex, retval);
FILE_LOG(logDEBUG1) << "Clock " << clkIndex << " pipeline: " << retval;
return retval;
}
void slsDetector::setPipeline(int clkIndex, int value) {
int args[]{clkIndex, value};
FILE_LOG(logDEBUG1) << "Setting Clock " << clkIndex << " pipeline to " << value;
sendToDetector(F_SET_PIPELINE, args, nullptr);
}
sls_detector_module slsDetector::interpolateTrim(sls_detector_module *a,
sls_detector_module *b,
const int energy, const int e1,