mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-05-14 05:55:35 +02:00
wip
This commit is contained in:
@@ -1632,7 +1632,10 @@ class Detector {
|
||||
/** gets list of power enums */
|
||||
std::vector<defs::powerIndex> getPowerList() const;
|
||||
|
||||
/** [CTB][Xilinx CTB] */
|
||||
/** [CTB] Options: V_POWE_A, V_POWER_B, V_POWER_C,
|
||||
* V_POWER_D, V_POWER_IO, V_POWER_CHIP
|
||||
* [Xilinx CTB] Options: V_POWE_A, V_POWER_B, V_POWER_C,
|
||||
* V_POWER_D, V_POWER_IO */
|
||||
int getPowerDAC(defs::powerIndex index) const;
|
||||
|
||||
/** [CTB][Xilinx CTB] Options: V_POWE_A, V_POWER_B, V_POWER_C,
|
||||
|
||||
@@ -2166,15 +2166,92 @@ Result<int> Detector::getSYNCClock(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getClockFrequency, pos, defs::SYNC_CLOCK);
|
||||
}
|
||||
|
||||
std::vector<defs::dacIndex> Detector::getPowerList() const {
|
||||
std::vector<defs::powerIndex> Detector::getPowerList() const {
|
||||
auto dettype = getDetectorType().squash();
|
||||
if (dettype != defs::CHIPTESTBOARD &&
|
||||
dettype != defs::XILINX_CHIPTESTBOARD) {
|
||||
throw RuntimeError("Power list not implemented for this detector");
|
||||
}
|
||||
return std::vector<defs::dacIndex>{defs::V_POWER_A, defs::V_POWER_B,
|
||||
defs::V_POWER_C, defs::V_POWER_D,
|
||||
defs::V_POWER_IO};
|
||||
return std::vector<defs::powerIndex>{defs::V_POWER_A, defs::V_POWER_B,
|
||||
defs::V_POWER_C, defs::V_POWER_D,
|
||||
defs::V_POWER_IO};
|
||||
}
|
||||
|
||||
int Detector::getPowerDAC(defs::powerIndex index) const {
|
||||
pimpl->verifyChipTestBoard(__func__);
|
||||
return pimpl->Parallel(&Module::getPowerDac, {0}, index)[0];
|
||||
}
|
||||
|
||||
void Detector::setPowerDAC(defs::powerIndex index, int value) {
|
||||
pimpl->verifyChipTestBoard(__func__);
|
||||
pimpl->Parallel(&Module::setPowerDac, {0}, index, value);
|
||||
}
|
||||
|
||||
bool Detector::isPowerEnabled(defs::powerIndex index) const {
|
||||
pimpl->verifyChipTestBoard(__func__);
|
||||
std::vector<defs::powerIndex> valid_indices = getPowerList();
|
||||
if (std::find(valid_indices.begin(), valid_indices.end(), index) ==
|
||||
valid_indices.end()) {
|
||||
throw RuntimeError("Unknown Power Index " + std::to_string(index));
|
||||
}
|
||||
return pimpl->Parallel(&Module::isPowerEnabled, {0}, index)[0];
|
||||
}
|
||||
|
||||
void Detector::setPowerEnabled(const std::vector<defs::powerIndex> &indices,
|
||||
bool enable) {
|
||||
pimpl->verifyChipTestBoard(__func__);
|
||||
if (indices.empty()) {
|
||||
throw RuntimeError("No Power Index provided");
|
||||
}
|
||||
std::vector<defs::powerIndex> valid_indices = getPowerList();
|
||||
for (const auto &index : indices) {
|
||||
if (std::find(valid_indices.begin(), valid_indices.end(), index) ==
|
||||
valid_indices.end()) {
|
||||
throw RuntimeError("Unknown Power Index " + std::to_string(index));
|
||||
}
|
||||
}
|
||||
pimpl->Parallel(&Module::setPowerEnabled, {0}, indices, enable);
|
||||
}
|
||||
|
||||
int Detector::getMeasuredPower(defs::powerIndex index) const {
|
||||
pimpl->verifyChipTestBoard(__func__);
|
||||
switch (index) {
|
||||
case defs::V_POWER_A:
|
||||
case defs::V_POWER_B:
|
||||
case defs::V_POWER_C:
|
||||
case defs::V_POWER_D:
|
||||
case defs::V_POWER_IO:
|
||||
case defs::V_POWER_CHIP:
|
||||
break;
|
||||
default:
|
||||
throw RuntimeError("Unknown Power Index " + std::to_string(index));
|
||||
}
|
||||
return pimpl->Parallel(&Module::getPowerADC, {0}, index)[0];
|
||||
}
|
||||
|
||||
int Detector::getMeasuredCurrent(defs::powerIndex index) const {
|
||||
pimpl->verifyChipTestBoard(__func__);
|
||||
switch (index) {
|
||||
case defs::I_POWER_A:
|
||||
case defs::I_POWER_B:
|
||||
case defs::I_POWER_C:
|
||||
case defs::I_POWER_D:
|
||||
case defs::I_POWER_IO:
|
||||
break;
|
||||
default:
|
||||
throw RuntimeError("Unknown Current Index " + std::to_string(index));
|
||||
}
|
||||
return pimpl->Parallel(&Module::getPowerADC, {0}, index)[0];
|
||||
}
|
||||
|
||||
int Detector::getVoltageLimit() const {
|
||||
pimpl->verifyChipTestBoard(__func__);
|
||||
return pimpl->Parallel(&Module::getVoltageLimit, {0})[0];
|
||||
}
|
||||
|
||||
void Detector::setVoltageLimit(int value) {
|
||||
pimpl->verifyChipTestBoard(__func__);
|
||||
pimpl->Parallel(&Module::setVoltageLimit, {0}, value);
|
||||
}
|
||||
|
||||
std::vector<defs::dacIndex> Detector::getSlowADCList() const {
|
||||
@@ -2188,31 +2265,6 @@ std::vector<defs::dacIndex> Detector::getSlowADCList() const {
|
||||
defs::SLOW_ADC4, defs::SLOW_ADC5, defs::SLOW_ADC6, defs::SLOW_ADC7};
|
||||
}
|
||||
|
||||
Result<bool> Detector::isPowerEnabled(defs::dacIndex index,
|
||||
Positions pos) const {
|
||||
std::vector<defs::dacIndex> valid_indices = getPowerList();
|
||||
if (std::find(valid_indices.begin(), valid_indices.end(), index) ==
|
||||
valid_indices.end()) {
|
||||
throw RuntimeError("Unknown Power Index");
|
||||
}
|
||||
return pimpl->Parallel(&Module::isPowerEnabled, pos, index);
|
||||
}
|
||||
|
||||
void Detector::setPowerEnabled(const std::vector<defs::dacIndex> &indices,
|
||||
bool value, Positions pos) {
|
||||
if (indices.empty()) {
|
||||
throw RuntimeError("No Power Index provided");
|
||||
}
|
||||
std::vector<defs::dacIndex> valid_indices = getPowerList();
|
||||
for (const auto &index : indices) {
|
||||
if (std::find(valid_indices.begin(), valid_indices.end(), index) ==
|
||||
valid_indices.end()) {
|
||||
throw RuntimeError("Unknown Power Index");
|
||||
}
|
||||
}
|
||||
pimpl->Parallel(&Module::setPowerEnabled, pos, indices, value);
|
||||
}
|
||||
|
||||
Result<int> Detector::getADCVpp(bool mV, Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getDAC, pos, defs::ADC_VPP, mV);
|
||||
}
|
||||
@@ -2279,37 +2331,6 @@ void Detector::setDBITClock(int value_in_MHz, Positions pos) {
|
||||
value_in_MHz);
|
||||
}
|
||||
|
||||
Result<int> Detector::getMeasuredPower(defs::dacIndex index,
|
||||
Positions pos) const {
|
||||
switch (index) {
|
||||
case defs::V_POWER_A:
|
||||
case defs::V_POWER_B:
|
||||
case defs::V_POWER_C:
|
||||
case defs::V_POWER_D:
|
||||
case defs::V_POWER_IO:
|
||||
case defs::V_POWER_CHIP:
|
||||
break;
|
||||
default:
|
||||
throw RuntimeError("Unknown Power Index");
|
||||
}
|
||||
return pimpl->Parallel(&Module::getADC, pos, index);
|
||||
}
|
||||
|
||||
Result<int> Detector::getMeasuredCurrent(defs::dacIndex index,
|
||||
Positions pos) const {
|
||||
switch (index) {
|
||||
case defs::I_POWER_A:
|
||||
case defs::I_POWER_B:
|
||||
case defs::I_POWER_C:
|
||||
case defs::I_POWER_D:
|
||||
case defs::I_POWER_IO:
|
||||
break;
|
||||
default:
|
||||
throw RuntimeError("Unknown Current Index");
|
||||
}
|
||||
return pimpl->Parallel(&Module::getADC, pos, index);
|
||||
}
|
||||
|
||||
Result<int> Detector::getSlowADC(defs::dacIndex index, Positions pos) const {
|
||||
if (index < defs::SLOW_ADC0 || index > defs::SLOW_ADC7) {
|
||||
throw RuntimeError("Unknown Slow ADC Index");
|
||||
|
||||
@@ -188,6 +188,15 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
shm()->detType == defs::XILINX_CHIPTESTBOARD);
|
||||
}
|
||||
|
||||
inline void verifyChipTestBoard(const std::string &funcName) const {
|
||||
if (!isChipTestBoard())
|
||||
throw RuntimeError(funcName + " is only valid for chip test board");
|
||||
if (size() != 1)
|
||||
throw RuntimeError(
|
||||
funcName +
|
||||
" is only valid for single module setup (chip test board).");
|
||||
}
|
||||
|
||||
/** set acquiring flag in shared memory */
|
||||
void setAcquiringFlag(bool flag);
|
||||
|
||||
|
||||
@@ -819,25 +819,46 @@ void Module::setPowerChip(bool on) {
|
||||
sendToDetector<int>(F_POWER_CHIP, static_cast<int>(on));
|
||||
}
|
||||
|
||||
bool Module::isPowerEnabled(defs::dacIndex index) const {
|
||||
return sendToDetector<int>(F_GET_POWER, index);
|
||||
int Module::getPowerDAC(defs::powerIndex index) const {
|
||||
return sendToDetector<int>(F_GET_POWER_DAC, static_cast<int>(index));
|
||||
}
|
||||
|
||||
void Module::setPowerEnabled(const std::vector<defs::dacIndex> &indices,
|
||||
bool value) {
|
||||
void Module::setPowerDAC(defs::powerIndex index, int value) {
|
||||
int args[]{static_cast<int>(index), value};
|
||||
sendToDetector(F_SET_POWER_DAC, args, nullptr);
|
||||
}
|
||||
|
||||
bool Module::isPowerEnabled(defs::powerIndex index) const {
|
||||
return sendToDetector<int>(F_GET_POWER, static_cast<int>(index));
|
||||
}
|
||||
|
||||
void Module::setPowerEnabled(const std::vector<defs::powerIndex> &indices,
|
||||
bool enable) {
|
||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||
client.Send(F_SET_POWER);
|
||||
client.setFnum(F_SET_POWER);
|
||||
int count = indices.size();
|
||||
client.Send(count);
|
||||
client.Send(indices);
|
||||
client.Send(static_cast<int>(value));
|
||||
client.Send(static_cast<int>(enable));
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
throw DetectorError("Detector " + std::to_string(moduleIndex) +
|
||||
" returned error: " + client.readErrorMessage());
|
||||
}
|
||||
}
|
||||
|
||||
int Module::getPowerADC(defs::powerIndex index) const {
|
||||
return sendToDetector<int>(F_GET_POWER_ADC, static_cast<int>(index));
|
||||
}
|
||||
|
||||
int Module::getVoltageLimit() const {
|
||||
return sendToDetector<int>(F_GET_VOLTAGE_LIMIT);
|
||||
}
|
||||
|
||||
void Module::setVoltageLimit(const int limit_in_mV) {
|
||||
sendToDetector(F_SET_VOLTAGE_LIMIT, limit_in_mV, nullptr);
|
||||
}
|
||||
|
||||
int Module::getImageTestMode() const {
|
||||
return sendToDetector<int>(F_GET_IMAGE_TEST_MODE);
|
||||
}
|
||||
|
||||
@@ -177,9 +177,14 @@ class Module : public virtual slsDetectorDefs {
|
||||
void setDAC(int val, dacIndex index, bool mV);
|
||||
bool getPowerChip() const;
|
||||
void setPowerChip(bool on);
|
||||
bool isPowerEnabled(defs::dacIndex index) const;
|
||||
void setPowerEnabled(const std::vector<defs::dacIndex> &indices,
|
||||
bool value);
|
||||
int getPowerDAC(defs::powerIndex index) const;
|
||||
void setPowerDAC(defs::powerIndex index, int value);
|
||||
bool isPowerEnabled(defs::powerIndex index) const;
|
||||
void setPowerEnabled(const std::vector<defs::powerIndex> &indices,
|
||||
bool enable);
|
||||
int getPowerADC(defs::powerIndex index) const;
|
||||
int getVoltageLimit() const;
|
||||
void setVoltageLimit(const int limit_in_mV);
|
||||
int getImageTestMode() const;
|
||||
void setImageTestMode(const int value);
|
||||
/* temperature in millidegrees */
|
||||
|
||||
@@ -303,6 +303,11 @@ enum detFuncs {
|
||||
F_SPI_WRITE,
|
||||
F_GET_POWER,
|
||||
F_SET_POWER,
|
||||
F_GET_POWER_DAC,
|
||||
F_SET_POWER_DAC,
|
||||
F_GET_POWER_ADC,
|
||||
F_GET_VOLTAGE_LIMIT,
|
||||
F_SET_VOLTAGE_LIMIT,
|
||||
|
||||
NUM_DET_FUNCTIONS,
|
||||
RECEIVER_ENUM_START = 512, /**< detector function should not exceed this
|
||||
@@ -717,7 +722,11 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
||||
case F_SPI_WRITE: return "F_SPI_WRITE";
|
||||
case F_GET_POWER: return "F_GET_POWER";
|
||||
case F_SET_POWER: return "F_SET_POWER";
|
||||
|
||||
case F_GET_POWER_DAC: return "F_GET_POWER_DAC";
|
||||
case F_SET_POWER_DAC: return "F_SET_POWER_DAC";
|
||||
case F_GET_POWER_ADC: return "F_GET_POWER_ADC";
|
||||
case F_GET_VOLTAGE_LIMIT: return "F_GET_VOLTAGE_LIMIT";
|
||||
case F_SET_VOLTAGE_LIMIT: return "F_SET_VOLTAGE_LIMIT";
|
||||
|
||||
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
|
||||
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
|
||||
|
||||
Reference in New Issue
Block a user