This commit is contained in:
2020-09-21 11:23:46 +02:00
parent d65030f5ca
commit 569c014d3c
7 changed files with 91 additions and 40 deletions

View File

@ -1584,7 +1584,7 @@ std::string CmdProxy::ClearROI(int action) {
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "\n\t[Gotthard] Resets Region of interest in detector. All "
"channels enabled. Default is all channels."
"channels enabled. Default is all channels enabled."
<< '\n';
} else if (action == defs::GET_ACTION) {
throw sls::RuntimeError("Cannot get");
@ -2554,16 +2554,13 @@ std::string CmdProxy::BitOperations(int action) {
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (cmd == "setbit") {
os << "[address] [value\n\t[Moench] Minimum energy threshold (soft "
"setting) for processor."
os << "[reg address in hex] [bit index]\n\tSets bit in address."
<< '\n';
} else if (cmd == "clearbit") {
os << "[n_value]\n\t[Moench] Maximum energy threshold (soft "
"setting) for processor."
os << "[reg address in hex] [bit index]\n\tClears bit in address."
<< '\n';
} else if (cmd == "getbit") {
os << "[n_value]\n\t[Moench] Maximum energy threshold (soft "
"setting) for processor."
os << "[reg address in hex] [bit index]\n\tGets bit in address."
<< '\n';
} else {
throw sls::RuntimeError(
@ -2587,12 +2584,8 @@ std::string CmdProxy::BitOperations(int action) {
if (cmd == "setbit" || cmd == "clearbit") {
throw sls::RuntimeError("Cannot get");
}
auto t = det->readRegister(addr, std::vector<int>{det_id});
Result<int> result(t.size());
for (unsigned int i = 0; i < t.size(); ++i) {
result[i] = ((t[i] >> bitnr) & 0x1);
}
os << OutString(result) << '\n';
auto t = det->getBit(addr, bitnr, std::vector<int>{det_id});
os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) {
if (cmd == "getbit") {
throw sls::RuntimeError("Cannot put");

View File

@ -1589,7 +1589,8 @@ class CmdProxy {
DAC_COMMAND(
adcvpp, getDAC, setDAC, defs::ADC_VPP,
"[dac or mV value][(optional unit) mV] \n\t[Ctb][Moench] Vpp of "
"ADC.\n\t 0 -> 1V ; 1 -> 1.14V ; 2 -> 1.33V ; 3 -> 1.6V ; 4 -> 2V.");
"ADC.\n\t 0 -> 1V ; 1 -> 1.14V ; 2 -> 1.33V ; 3 -> 1.6V ; 4 -> 2V. "
"\n\tAdvanced User function! ");
DAC_COMMAND(vb_ds, getDAC, setDAC, defs::VB_DS,
"[dac or mV value][(optional unit) mV] \n\t[Jungfrau] Dac for "
@ -1669,9 +1670,10 @@ class CmdProxy {
/* acquisition */
EXECUTE_SET_COMMAND_NOID(clearbusy, clearAcquiringFlag,
"\n\tClears Acquiring Flag for unexpected acquire "
"command terminations.");
EXECUTE_SET_COMMAND_NOID(
clearbusy, clearAcquiringFlag,
"\n\tIf acquisition aborted during acquire command, use this to clear "
"acquiring flag in shared memory before starting next acquisition");
EXECUTE_SET_COMMAND_NOID(
rx_start, startReceiver,
@ -2107,9 +2109,10 @@ class CmdProxy {
"timing mode and burst mode. Use timing command to set timing mode and "
"burstmode command to set burst mode.");
TIME_COMMAND(burstperiod, getBurstPeriod, setBurstPeriod,
"[duration] [(optional unit) ns|us|ms|s]\n\t[Gotthard2] Burst "
"period. Only in burst mode and auto timing mode.");
TIME_COMMAND(
burstperiod, getBurstPeriod, setBurstPeriod,
"[duration] [(optional unit) ns|us|ms|s]\n\t[Gotthard2] "
"Period between 2 bursts. Only in burst mode and auto timing mode.");
INTEGER_COMMAND_VEC_ID(
cdsgain, getCDSGain, setCDSGain, StringTo<bool>,
@ -2171,13 +2174,13 @@ class CmdProxy {
INTEGER_COMMAND_HEX(adcenable, getADCEnableMask, setADCEnableMask,
StringTo<uint32_t>,
"[bitmask]\n\t[Ctb][Moench] ADC Enable Mask for 1Gb "
"Mode for each 32 ADC channel.");
"Enable for each 32 ADC channel.");
INTEGER_COMMAND_HEX(
adcenable10g, getTenGigaADCEnableMask, setTenGigaADCEnableMask,
StringTo<uint32_t>,
"[bitmask]\n\t[Ctb][Moench] ADC Enable Mask for 10Gb mode for each 32 "
"ADC channel. However, if any of consecutive 4 bits are enabled, the "
"ADC channel. However, if any of a consecutive 4 bits are enabled, the "
"complete 4 bits are enabled.");
/* CTB Specific */
@ -2321,7 +2324,8 @@ class CmdProxy {
EXECUTE_SET_COMMAND(
bustest, executeBusTest,
"\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][Ctb][Moench] Bus test, "
"ie. keeps writing and reading back different values in R/W register.");
"ie. Writes different values in a R/W register and confirms the "
"writes to check bus.\n\tAdvanced User function!");
INTEGER_COMMAND_HEX(
adcinvert, getADCInvert, setADCInvert, StringTo<uint32_t>,

View File

@ -384,7 +384,6 @@ Result<int> Detector::getClockFrequency(int clkIndex, Positions pos) {
return pimpl->Parallel(&Module::getClockFrequency, pos, clkIndex);
}
Result<int> Detector::getClockPhase(int clkIndex, Positions pos) {
return pimpl->Parallel(&Module::getClockPhase, pos, clkIndex, false);
}
@ -1883,6 +1882,10 @@ void Detector::clearBit(uint32_t addr, int bitnr, Positions pos) {
pimpl->Parallel(&Module::clearBit, pos, addr, bitnr);
}
Result<int> Detector::getBit(uint32_t addr, int bitnr, Positions pos) {
return pimpl->Parallel(&Module::getBit, pos, addr, bitnr);
}
void Detector::executeFirmwareTest(Positions pos) {
pimpl->Parallel(&Module::executeFirmwareTest, pos);
}

View File

@ -2199,21 +2199,29 @@ uint32_t Module::writeRegister(uint32_t addr, uint32_t val) {
return sendToDetectorStop<uint32_t>(F_WRITE_REGISTER, args);
}
uint32_t Module::setBit(uint32_t addr, int n) {
void Module::setBit(uint32_t addr, int n) {
if (n < 0 || n > 31) {
throw RuntimeError("Bit number " + std::to_string(n) + " out of Range");
} else {
uint32_t val = readRegister(addr);
return writeRegister(addr, val | 1 << n);
writeRegister(addr, val | 1 << n);
}
}
uint32_t Module::clearBit(uint32_t addr, int n) {
void Module::clearBit(uint32_t addr, int n) {
if (n < 0 || n > 31) {
throw RuntimeError("Bit number " + std::to_string(n) + " out of Range");
} else {
uint32_t val = readRegister(addr);
return writeRegister(addr, val & ~(1 << n));
writeRegister(addr, val & ~(1 << n));
}
}
int Module::getBit(uint32_t addr, int n) {
if (n < 0 || n > 31) {
throw RuntimeError("Bit number " + std::to_string(n) + " out of Range");
} else {
return ((readRegister(addr) >> n) & 0x1);
}
}

View File

@ -497,8 +497,9 @@ class Module : public virtual slsDetectorDefs {
void rebootController();
uint32_t readRegister(uint32_t addr) const;
uint32_t writeRegister(uint32_t addr, uint32_t val);
uint32_t setBit(uint32_t addr, int n);
uint32_t clearBit(uint32_t addr, int n);
void setBit(uint32_t addr, int n);
void clearBit(uint32_t addr, int n);
int getBit(uint32_t addr, int n);
void executeFirmwareTest();
void executeBusTest();
void writeAdcRegister(uint32_t addr, uint32_t val);