mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 23:10:02 +02:00
initial implementation
This commit is contained in:
parent
7c4f9ee044
commit
043d582616
@ -52,7 +52,7 @@ servers = [
|
||||
# "eigerDetectorServer",
|
||||
# "jungfrauDetectorServer",
|
||||
"mythen3DetectorServer",
|
||||
# "gotthard2DetectorServer",
|
||||
"gotthard2DetectorServer",
|
||||
# "gotthardDetectorServer",
|
||||
# "ctbDetectorServer",
|
||||
# "moenchDetectorServer",
|
||||
|
@ -14,4 +14,5 @@ clockIndex = _slsdet.slsDetectorDefs.clockIndex
|
||||
readoutMode = _slsdet.slsDetectorDefs.readoutMode
|
||||
masterFlags = _slsdet.slsDetectorDefs.masterFlags
|
||||
burstMode = _slsdet.slsDetectorDefs.burstMode
|
||||
timingSourceType = _slsdet.slsDetectorDefs.timingSourceType
|
||||
timingSourceType = _slsdet.slsDetectorDefs.timingSourceType
|
||||
M3_GainCaps = _slsdet.slsDetectorDefs.M3_GainCaps
|
@ -1140,6 +1140,9 @@ void init_det(py::module &m) {
|
||||
(Result<int>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getChipStatusRegister,
|
||||
py::arg() = Positions{})
|
||||
.def("setGainCaps",
|
||||
(void (Detector::*)(int, sls::Positions)) & Detector::setGainCaps,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("getNumberOfAnalogSamples",
|
||||
(Result<int>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getNumberOfAnalogSamples,
|
||||
|
@ -277,4 +277,13 @@ void init_enums(py::module &m) {
|
||||
.value("TIMING_EXTERNAL",
|
||||
slsDetectorDefs::timingSourceType::TIMING_EXTERNAL)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::M3_GainCaps>(Defs, "M3_GainCaps")
|
||||
.value("CSR_C10pre", slsDetectorDefs::M3_GainCaps::CSR_C10pre)
|
||||
.value("CSR_C15sh", slsDetectorDefs::M3_GainCaps::CSR_C15sh)
|
||||
.value("CSR_C30sh", slsDetectorDefs::M3_GainCaps::CSR_C30sh)
|
||||
.value("CSR_C50sh", slsDetectorDefs::M3_GainCaps::CSR_C50sh)
|
||||
.value("CSR_C225ACsh", slsDetectorDefs::M3_GainCaps::CSR_C225ACsh)
|
||||
.value("CSR_C15pre", slsDetectorDefs::M3_GainCaps::CSR_C15pre)
|
||||
.export_values();
|
||||
}
|
||||
|
Binary file not shown.
@ -35,6 +35,32 @@ int getChipStatusRegister(){
|
||||
return chipStatusRegister;
|
||||
}
|
||||
|
||||
// int setGainCaps(int caps){
|
||||
// int csr = getChipStatusRegister();
|
||||
|
||||
// int gain_mask = 0;
|
||||
// gain_mask |= 1 << CSR_C10pre;
|
||||
// gain_mask |= 1 << CSR_C15sh;
|
||||
// gain_mask |= 1 << CSR_C30sh;
|
||||
// gain_mask |= 1 << CSR_C50sh;
|
||||
// gain_mask |= 1 << CSR_C225ACsh;
|
||||
// gain_mask |= 1 << CSR_C15pre;
|
||||
|
||||
// LOG(logINFO, ("gain_mask: 0x%x\n", gain_mask));
|
||||
// LOG(logINFO, ("csr: 0x%x\n", csr));
|
||||
// csr &= ~gain_mask; //zero out the bits in the gain mask
|
||||
// LOG(logINFO, ("csr: 0x%x\n", csr));
|
||||
// caps &= gain_mask;
|
||||
// csr |= caps;
|
||||
|
||||
// LOG(logINFO, ("csr: 0x%x\n", csr));
|
||||
|
||||
// //now comes the actual setting
|
||||
|
||||
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
patternParameters *setChipStatusRegister(int csr) {
|
||||
int iaddr=0;
|
||||
int nbits=18;
|
||||
|
@ -48,6 +48,9 @@
|
||||
|
||||
#define CSR_default (1<<CSR_C10pre )|(1<< CSR_C30sh)
|
||||
|
||||
#define GAIN_MASK ((1 << CSR_C10pre) | ( 1 << CSR_C15sh) | (1 << CSR_C30sh) | (1 << CSR_C50sh) | (1 << CSR_C225ACsh) | ( 1 << CSR_C15pre))
|
||||
|
||||
|
||||
enum {Cp_0, Cp_10, Cp_15, Cp_45};
|
||||
enum {Csh_0,Csh_15,Csh_30,Csh_45,Csh_50,Csh_65,Csh_80,Csh_95};
|
||||
enum {Cac225, Cac_450};
|
||||
@ -58,6 +61,7 @@ enum {Cac225, Cac_450};
|
||||
int setBit(int ibit, int patword);
|
||||
int clearBit(int ibit, int patword);
|
||||
int getChipStatusRegister();
|
||||
|
||||
patternParameters *setChipStatusRegister(int csr);
|
||||
patternParameters *setChannelRegisterChip(int ichip, int *mask, int *trimbits);
|
||||
patternParameters *setInterpolation(int mask);
|
||||
|
@ -2660,6 +2660,60 @@ int getNumberOfChips() { return NCHIP; }
|
||||
int getNumberOfDACs() { return NDAC; }
|
||||
int getNumberOfChannelsPerChip() { return NCHAN; }
|
||||
|
||||
|
||||
|
||||
int setGainCaps(int caps){
|
||||
//TODO Refactor!!!!!
|
||||
int csr = getChipStatusRegister();
|
||||
|
||||
LOG(logINFO, ("gain_mask: 0x%x\n", GAIN_MASK));
|
||||
LOG(logINFO, ("csr: 0x%x\n", csr));
|
||||
csr &= ~GAIN_MASK; //zero out the bits in the gain mask
|
||||
LOG(logINFO, ("csr: 0x%x\n", csr));
|
||||
caps &= GAIN_MASK;
|
||||
csr |= caps;
|
||||
|
||||
LOG(logINFO, ("csr: 0x%x\n", csr));
|
||||
|
||||
//now comes the actual setting
|
||||
// remember previous run clock
|
||||
uint32_t prevRunClk = clkDivider[SYSTEM_C0];
|
||||
patternParameters *pat=NULL;
|
||||
int error=0;
|
||||
// set to trimming clock
|
||||
if (setClockDivider(SYSTEM_C0, DEFAULT_TRIMMING_RUN_CLKDIV) == FAIL) {
|
||||
LOG(logERROR,
|
||||
("Could not start trimming. Could not set to trimming clock\n"));
|
||||
return FAIL;
|
||||
}
|
||||
pat = setChipStatusRegister(csr);
|
||||
|
||||
if (pat) {
|
||||
error|=loadPattern(pat);
|
||||
if (error==0)
|
||||
startPattern();
|
||||
free(pat);
|
||||
} else
|
||||
error=1;
|
||||
/////////////////////////////////////////////////////////////////
|
||||
if (error == 0) {
|
||||
|
||||
LOG(logINFO, ("The gain has been changed\n"));
|
||||
}
|
||||
trimmingPrint = logINFO;
|
||||
// set back to previous clock
|
||||
if (setClockDivider(SYSTEM_C0, prevRunClk) == FAIL) {
|
||||
LOG(logERROR, ("Could not set to previous run clock after trimming\n"));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (error != 0) {
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
int setGain(int gain) {
|
||||
// remember previous run clock
|
||||
uint32_t prevRunClk = clkDivider[SYSTEM_C0];
|
||||
|
@ -357,6 +357,7 @@ enum timingMode getTiming();
|
||||
#ifdef MYTHEN3D
|
||||
void setInitialExtSignals();
|
||||
int isMaster();
|
||||
int setGainCaps(int caps);
|
||||
#endif
|
||||
#if defined(GOTTHARDD) || defined(MYTHEN3D)
|
||||
void setExtSignal(int signalIndex, enum externalSignalFlag mode);
|
||||
|
@ -247,4 +247,5 @@ int get_pattern(int);
|
||||
int load_default_pattern(int);
|
||||
int get_all_threshold_energy(int);
|
||||
int get_master(int);
|
||||
int get_csr();
|
||||
int get_csr();
|
||||
int set_gain_caps(int);
|
@ -370,6 +370,7 @@ void function_table() {
|
||||
flist[F_GET_ALL_THRESHOLD_ENERGY] = &get_all_threshold_energy;
|
||||
flist[F_GET_MASTER] = &get_master;
|
||||
flist[F_GET_CSR] = &get_csr;
|
||||
flist[F_SET_GAIN_CAPS] = &set_gain_caps;
|
||||
|
||||
// check
|
||||
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
||||
@ -8405,3 +8406,38 @@ int get_csr(int file_des){
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
int set_gain_caps(int file_des){
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int arg = 0;
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
LOG(logINFO, ("Setting gain caps to: %u\n", arg));
|
||||
|
||||
int retval = -1;
|
||||
|
||||
#ifndef MYTHEN3D
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
|
||||
if (Server_VerifyLock() == OK) {
|
||||
// if (arg != 0 && arg != 1) {
|
||||
// ret = FAIL;
|
||||
// sprintf(mess,
|
||||
// "Could not set gain caps. Invalid value %d. "
|
||||
// "Options [0-1]\n",
|
||||
// arg);
|
||||
// LOG(logERROR, (mess));
|
||||
// } else {
|
||||
setGainCaps(arg);
|
||||
retval = getChipStatusRegister(); //TODO! fix
|
||||
LOG(logDEBUG1, ("gain caps retval: %u\n", retval));
|
||||
// validate(arg, retval, " cds gain enable", DEC);
|
||||
// }
|
||||
}
|
||||
#endif
|
||||
// return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
|
@ -1312,6 +1312,8 @@ class Detector {
|
||||
//TODO! check if we really want to expose this !!!!!
|
||||
Result<int> getChipStatusRegister(Positions pos = {}) const;
|
||||
|
||||
void setGainCaps(int caps, Positions pos = {});
|
||||
|
||||
///@{
|
||||
|
||||
/** @name CTB / Moench Specific */
|
||||
|
@ -1619,6 +1619,10 @@ Result<int> Detector::getChipStatusRegister(Positions pos) const{
|
||||
return pimpl->Parallel(&Module::getChipStatusRegister, pos);
|
||||
}
|
||||
|
||||
void Detector::setGainCaps(int caps, Positions pos){
|
||||
return pimpl->Parallel(&Module::setGainCaps, pos, caps);
|
||||
}
|
||||
|
||||
|
||||
// CTB/ Moench Specific
|
||||
|
||||
|
@ -2002,6 +2002,10 @@ int Module::getChipStatusRegister() const{
|
||||
return sendToDetector<int>(F_GET_CSR);
|
||||
}
|
||||
|
||||
void Module::setGainCaps(int caps){
|
||||
sendToDetector<int>(F_SET_GAIN_CAPS, caps);
|
||||
}
|
||||
|
||||
// CTB / Moench Specific
|
||||
int Module::getNumberOfAnalogSamples() const {
|
||||
return sendToDetector<int>(F_GET_NUM_ANALOG_SAMPLES);
|
||||
|
@ -427,6 +427,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
std::array<time::ns, 3> getGateDelayForAllGates() const;
|
||||
bool isMaster() const;
|
||||
int getChipStatusRegister() const;
|
||||
void setGainCaps(int caps);
|
||||
|
||||
/**************************************************
|
||||
* *
|
||||
|
@ -394,6 +394,16 @@ typedef struct {
|
||||
*/
|
||||
enum timingSourceType { TIMING_INTERNAL, TIMING_EXTERNAL };
|
||||
|
||||
//gain caps Mythen3
|
||||
enum M3_GainCaps {
|
||||
CSR_C10pre= 1<<7,
|
||||
CSR_C15sh = 1<<10,
|
||||
CSR_C30sh = 1<<11,
|
||||
CSR_C50sh = 1<<12,
|
||||
CSR_C225ACsh = 1<<13,
|
||||
CSR_C15pre = 1<<14,
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
/** scan structure */
|
||||
@ -625,6 +635,10 @@ typedef struct {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
|
||||
|
||||
|
||||
// TODO! discuss this
|
||||
#include <vector> //hmm... but currently no way around
|
||||
namespace sls {
|
||||
|
@ -222,6 +222,7 @@ enum detFuncs {
|
||||
F_GET_ALL_THRESHOLD_ENERGY,
|
||||
F_GET_MASTER,
|
||||
F_GET_CSR,
|
||||
F_SET_GAIN_CAPS,
|
||||
|
||||
NUM_DET_FUNCTIONS,
|
||||
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
|
||||
|
Loading…
x
Reference in New Issue
Block a user