Merge branch 'apidhanya' of github.com:slsdetectorgroup/slsDetectorPackage into apidhanya

This commit is contained in:
Erik Frojdh 2019-08-09 16:35:33 +02:00
commit c350b53b7f
6 changed files with 240 additions and 54 deletions

View File

@ -823,6 +823,88 @@ class Detector {
*/ */
void setDBITPipeline(int value, Positions pos = {}); void setDBITPipeline(int value, Positions pos = {});
Result<int> getDynamicRange(Positions pos = {}) const;
/**
* (Eiger:
* Options: 4, 8, 16, 32
* If i is 32, also sets clkdivider to 2, if 16, sets clkdivider to 1)
*/
void setDynamicRange(int value);
Result<int> getHighVoltage(Positions pos = {}) const;
/**
* (Gotthard Options: 0, 90, 110, 120, 150, 180, 200)
* (Jungfrau, CTB Options: 0, 60 - 200)
* (Eiger Options: 0 - 200)
*/
void setHighVoltage(int value, Positions pos = {});
/**
* (Eiger)
*/
Result<int> getIODelay(Positions pos = {}) const;
/**
* (Eiger)
*/
void setIODelay(int value, Positions pos = {});
/**
* (Degrees)
* (Gotthard Options: TEMPERATURE_ADC, TEMPERATURE_FPGA)
* (Jungfrau Options: TEMPERATURE_ADC, TEMPERATURE_FPGA)
* (Eiger Options: TEMPERATURE_FPGA, TEMPERATURE_FPGAEXT, TEMPERATURE_10GE,
* TEMPERATURE_DCDC, TEMPERATURE_SODL, TEMPERATURE_SODR, TEMPERATURE_FPGA2,
* TEMPERATURE_FPGA3) (CTB Options: SLOW_ADC_TEMP)
*/
Result<int> getTemp(defs::dacIndex index, Positions pos = {}) const;
/**
* (CTB mV)
*/
Result<int> getVrefVoltage(bool mV, Positions pos = {}) const;
/**
* (CTB mV)
*/
void setVrefVoltage(int value, bool mV, Positions pos = {});
/**
* (CTB mV Options: V_LIMIT, V_POWER_A, V_POWER_B, V_POWER_C,
* V_POWER_D, V_POWER_IO, V_POWER_CHIP))
*/
Result<int> getVoltage(defs::dacIndex index, Positions pos = {}) const;
/**
* (CTB mV Options: V_LIMIT, V_POWER_A, V_POWER_B, V_POWER_C,
* V_POWER_D, V_POWER_IO, V_POWER_CHIP)
*/
void setVoltage(int value, defs::dacIndex index, Positions pos = {});
/**
* (CTB mV Options: V_POWER_A, V_POWER_B, V_POWER_C, V_POWER_D, V_POWER_IO,
* V_POWER_CHIP)
*/
Result<int> getMeasuredVoltage(defs::dacIndex index,
Positions pos = {}) const;
/**
* (CTB mA Options: I_POWER_A, I_POWER_B, I_POWER_C, I_POWER_D, I_POWER_IO)
*/
Result<int> getMeasuredCurrent(defs::dacIndex index,
Positions pos = {}) const;
/**
* (CTB Options: SLOW_ADC0 - SLOW_ADC7)
*/
Result<int> getSlowADC(defs::dacIndex index, Positions pos = {}) const;
Result<int> getDAC(defs::dacIndex index, bool mV, Positions pos = {}) const;
void setDAC(int value, defs::dacIndex index, bool mV, Positions pos = {});
// Erik // Erik
Result<int> getFramesCaughtByReceiver(Positions pos = {}) const; Result<int> getFramesCaughtByReceiver(Positions pos = {}) const;

View File

@ -56,12 +56,6 @@ struct sharedMultiSlsDetector {
/** Number of detectors operated at once */ /** Number of detectors operated at once */
int numberOfDetector[2]; int numberOfDetector[2];
/** size of the data that are transfered from all detectors */
int dataBytes;
/** data bytes including gap pixels transferred from all detectors */
int dataBytesInclGapPixels;
/** total number of channels for all detectors */ /** total number of channels for all detectors */
int numberOfChannels; int numberOfChannels;
@ -863,14 +857,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @param detPos -1 for all detectors in list or specific detector position * @param detPos -1 for all detectors in list or specific detector position
* @returns current dynamic range * @returns current dynamic range
*/ */
int setDynamicRange(int dr = -1, int detPos = -1); int setDynamicRange(int dr = -1, int detPos = -1);//
/**
* Recalculated number of data bytes for multi detector
* @param detPos -1 for all detectors in list or specific detector position
* @returns tota number of data bytes for multi detector
*/
int getDataBytes(int detPos = -1);
/** /**
* Set/get dacs value * Set/get dacs value
@ -880,7 +867,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @param detPos -1 for all detectors in list or specific detector position * @param detPos -1 for all detectors in list or specific detector position
* @returns current DAC value * @returns current DAC value
*/ */
int setDAC(int val, dacIndex index, int mV, int detPos = -1); int setDAC(int val, dacIndex index, int mV, int detPos = -1);//
/** /**
* Get adc value * Get adc value
@ -889,7 +876,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @returns current adc value (temperature for eiger and jungfrau in * @returns current adc value (temperature for eiger and jungfrau in
* millidegrees) * millidegrees)
*/ */
int getADC(dacIndex index, int detPos = -1); int getADC(dacIndex index, int detPos = -1);//
/** /**
* Set/get timing mode * Set/get timing mode

View File

@ -696,6 +696,8 @@ class slsDetector : public virtual slsDetectorDefs {
*/ */
int setDynamicRange(int n = -1); int setDynamicRange(int n = -1);
int getDynamicRangeFromShm();
/** /**
* Recalculated number of data bytes * Recalculated number of data bytes
* @returns tota number of data bytes * @returns tota number of data bytes

View File

@ -558,6 +558,146 @@ void Detector::setDBITPipeline(int value, Positions pos) {
pimpl->Parallel(&slsDetector::setSpeed, pos, defs::DBIT_PIPELINE, value, 0); pimpl->Parallel(&slsDetector::setSpeed, pos, defs::DBIT_PIPELINE, value, 0);
} }
Result<int> Detector::getDynamicRange(Positions pos) const {
return pimpl->Parallel(&slsDetector::setDynamicRange, pos, -1);
}
void Detector::setDynamicRange(int value) { pimpl->setDynamicRange(value); }
Result<int> Detector::getHighVoltage(Positions pos) const {
return pimpl->Parallel(&slsDetector::setDAC, pos, -1, defs::HIGH_VOLTAGE,
0);
}
void Detector::setHighVoltage(int value, Positions pos) {
pimpl->Parallel(&slsDetector::setDAC, pos, value, defs::HIGH_VOLTAGE, 0);
}
Result<int> Detector::getIODelay(Positions pos) const {
return pimpl->Parallel(&slsDetector::setDAC, pos, -1, defs::IO_DELAY, 0);
}
void Detector::setIODelay(int value, Positions pos) {
pimpl->Parallel(&slsDetector::setDAC, pos, value, defs::IO_DELAY, 0);
}
Result<int> Detector::getTemp(defs::dacIndex index, Positions pos) const {
switch (index) {
case defs::TEMPERATURE_ADC:
case defs::TEMPERATURE_FPGA:
case defs::TEMPERATURE_FPGAEXT:
case defs::TEMPERATURE_10GE:
case defs::TEMPERATURE_DCDC:
case defs::TEMPERATURE_SODL:
case defs::TEMPERATURE_SODR:
case defs::TEMPERATURE_FPGA2:
case defs::TEMPERATURE_FPGA3:
case defs::SLOW_ADC_TEMP:
break;
default:
throw RuntimeError("Unknown Temperature Index");
}
auto res = pimpl->Parallel(&slsDetector::getADC, pos, index);
switch (getDetectorType()) {
case defs::EIGER:
case defs::JUNGFRAU:
for (auto it : pos) {
it /= 1000;
}
break;
default:
break;
}
return res;
}
Result<int> Detector::getVrefVoltage(bool mV, Positions pos) const {
return pimpl->Parallel(&slsDetector::setDAC, pos, -1, defs::ADC_VPP, mV);
}
void Detector::setVrefVoltage(int value, bool mV, Positions pos) {
pimpl->Parallel(&slsDetector::setDAC, pos, value, defs::ADC_VPP, mV);
}
Result<int> Detector::getVoltage(defs::dacIndex index, Positions pos) const {
switch (index) {
case defs::V_LIMIT:
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 Voltage Index");
}
return pimpl->Parallel(&slsDetector::setDAC, pos, -1, index, 1);
}
void Detector::setVoltage(int value, defs::dacIndex index, Positions pos) {
switch (index) {
case defs::V_LIMIT:
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 Voltage Index");
}
pimpl->Parallel(&slsDetector::setDAC, pos, value, index, 1);
}
Result<int> Detector::getMeasuredVoltage(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 Voltage Index");
}
return pimpl->Parallel(&slsDetector::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(&slsDetector::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");
}
return pimpl->Parallel(&slsDetector::getADC, pos, index);
}
Result<int> Detector::getDAC(defs::dacIndex index, bool mV,
Positions pos) const {
return pimpl->Parallel(&slsDetector::setDAC, pos, -1, index, mV);
}
void Detector::setDAC(int value, defs::dacIndex index, bool mV, Positions pos) {
pimpl->Parallel(&slsDetector::setDAC, pos, value, index, mV);
}
// Erik // Erik
Result<int> Detector::getFramesCaughtByReceiver(Positions pos) const { Result<int> Detector::getFramesCaughtByReceiver(Positions pos) const {
return pimpl->Parallel(&slsDetector::getFramesCaughtByReceiver, pos); return pimpl->Parallel(&slsDetector::getFramesCaughtByReceiver, pos);

View File

@ -278,8 +278,6 @@ void multiSlsDetector::initializeDetectorStructure() {
multi_shm()->multiDetectorType = GENERIC; multi_shm()->multiDetectorType = GENERIC;
multi_shm()->numberOfDetector[X] = 0; multi_shm()->numberOfDetector[X] = 0;
multi_shm()->numberOfDetector[Y] = 0; multi_shm()->numberOfDetector[Y] = 0;
multi_shm()->dataBytes = 0;
multi_shm()->dataBytesInclGapPixels = 0;
multi_shm()->numberOfChannels = 0; multi_shm()->numberOfChannels = 0;
multi_shm()->numberOfChannel[X] = 0; multi_shm()->numberOfChannel[X] = 0;
multi_shm()->numberOfChannel[Y] = 0; multi_shm()->numberOfChannel[Y] = 0;
@ -624,9 +622,6 @@ void multiSlsDetector::addSlsDetector(const std::string &hostname) {
detectors.push_back( detectors.push_back(
sls::make_unique<slsDetector>(type, multiId, pos, false)); sls::make_unique<slsDetector>(type, multiId, pos, false));
multi_shm()->numberOfDetectors = detectors.size(); multi_shm()->numberOfDetectors = detectors.size();
multi_shm()->dataBytes += detectors[pos]->getDataBytes();
multi_shm()->dataBytesInclGapPixels +=
detectors[pos]->getDataBytesInclGapPixels();
multi_shm()->numberOfChannels += detectors[pos]->getTotalNumberOfChannels(); multi_shm()->numberOfChannels += detectors[pos]->getTotalNumberOfChannels();
detectors[pos]->setHostname(hostname); detectors[pos]->setHostname(hostname);
@ -1264,22 +1259,18 @@ int multiSlsDetector::setDynamicRange(int dr, int detPos) {
} }
// multi // multi
int prevValue = -1;
auto temp = Parallel(&slsDetector::getDynamicRangeFromShm, {});
if (temp.equal()) {
prevValue = temp.squash();
}
auto r = parallelCall(&slsDetector::setDynamicRange, dr); auto r = parallelCall(&slsDetector::setDynamicRange, dr);
int ret = sls::minusOneIfDifferent(r); int ret = sls::minusOneIfDifferent(r);
// update shm
int prevValue = multi_shm()->dataBytes;
int prevGValue = multi_shm()->dataBytesInclGapPixels;
multi_shm()->dataBytes = 0;
multi_shm()->dataBytesInclGapPixels = 0;
for (auto &d : detectors) {
multi_shm()->dataBytes += d->getDataBytes();
multi_shm()->dataBytesInclGapPixels += d->getDataBytesInclGapPixels();
}
// if there was a change FIXME:add dr to sls shm and check that instead // change in dr
if ((prevValue != multi_shm()->dataBytes) || if (dr != -1 && dr != prevValue) {
(prevGValue != multi_shm()->dataBytesInclGapPixels)) {
updateOffsets(); updateOffsets();
@ -1312,17 +1303,6 @@ int multiSlsDetector::setDynamicRange(int dr, int detPos) {
return ret; return ret;
} }
int multiSlsDetector::getDataBytes(int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->getDataBytes();
}
// multi
auto r = parallelCall(&slsDetector::getDataBytes);
return sls::sum(r);
}
int multiSlsDetector::setDAC(int val, dacIndex index, int mV, int detPos) { int multiSlsDetector::setDAC(int val, dacIndex index, int mV, int detPos) {
// single // single
if (detPos >= 0) { if (detPos >= 0) {
@ -2700,12 +2680,7 @@ int multiSlsDetector::enableGapPixels(int val, int detPos) {
auto r = parallelCall(&slsDetector::enableGapPixels, val); auto r = parallelCall(&slsDetector::enableGapPixels, val);
int ret = sls::minusOneIfDifferent(r); int ret = sls::minusOneIfDifferent(r);
// update data bytes incl gap pixels
if (val != -1) { if (val != -1) {
auto r2 = serialCall(&slsDetector::getDataBytesInclGapPixels);
multi_shm()->dataBytesInclGapPixels = sls::sum(r2);
// update
updateOffsets(); updateOffsets();
} }
return ret; return ret;
@ -2714,11 +2689,7 @@ int multiSlsDetector::enableGapPixels(int val, int detPos) {
void multiSlsDetector::setGapPixelsEnable(bool enable, Positions pos){ void multiSlsDetector::setGapPixelsEnable(bool enable, Positions pos){
Parallel(&slsDetector::enableGapPixels, pos, static_cast<int>(enable)); Parallel(&slsDetector::enableGapPixels, pos, static_cast<int>(enable));
// update data bytes incl gap pixels
auto r2 = serialCall(&slsDetector::getDataBytesInclGapPixels);
multi_shm()->dataBytesInclGapPixels = sls::sum(r2);
updateOffsets(); updateOffsets();
} }
int multiSlsDetector::setTrimEn(std::vector<int> energies, int detPos) { int multiSlsDetector::setTrimEn(std::vector<int> energies, int detPos) {

View File

@ -1539,6 +1539,10 @@ int slsDetector::setDynamicRange(int n) {
return shm()->dynamicRange; return shm()->dynamicRange;
} }
int slsDetector::getDynamicRangeFromShm() {
return shm()->dynamicRange;
}
int slsDetector::getDataBytes() { return shm()->dataBytes; } int slsDetector::getDataBytes() { return shm()->dataBytes; }
int slsDetector::getDataBytesInclGapPixels() { int slsDetector::getDataBytesInclGapPixels() {