mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-28 01:00:02 +02:00
Defaultdacs (#214)
This commit is contained in:
parent
b6b9a5d598
commit
4c4e2ccb6b
Binary file not shown.
Binary file not shown.
@ -681,18 +681,7 @@ void allocateDetectorStructureMemory() {
|
||||
void setupDetector() {
|
||||
|
||||
allocateDetectorStructureMemory();
|
||||
// set dacs
|
||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||
{
|
||||
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
|
||||
for (int i = 0; i < NDAC; ++i) {
|
||||
setDAC((enum DACINDEX)i, defaultvals[i], 0);
|
||||
if ((detectorModules)->dacs[i] != defaultvals[i]) {
|
||||
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
|
||||
defaultvals[i], (detectorModules)->dacs[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
setDefaultDacs();
|
||||
#ifdef VIRTUAL
|
||||
sharedMemory_setStatus(IDLE);
|
||||
#endif
|
||||
@ -754,6 +743,21 @@ void setupDetector() {
|
||||
LOG(logDEBUG1, ("Setup detector done\n\n"));
|
||||
}
|
||||
|
||||
int setDefaultDacs() {
|
||||
int ret = OK;
|
||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
|
||||
for (int i = 0; i < NDAC; ++i) {
|
||||
setDAC((enum DACINDEX)i, defaultvals[i], 0);
|
||||
if ((detectorModules)->dacs[i] != defaultvals[i]) {
|
||||
ret = FAIL;
|
||||
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
|
||||
defaultvals[i], (detectorModules)->dacs[i]));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* advanced read/write reg */
|
||||
int writeRegister(uint32_t offset, uint32_t data) {
|
||||
#ifdef VIRTUAL
|
||||
|
Binary file not shown.
@ -48,6 +48,8 @@ double systemFrequency = 0;
|
||||
int highvoltage = 0;
|
||||
int dacValues[NDAC] = {};
|
||||
int onChipdacValues[ONCHIP_NDAC][NCHIP] = {};
|
||||
int defaultDacValues[NDAC] = {};
|
||||
int defaultOnChipdacValues[ONCHIP_NDAC][NCHIP] = {};
|
||||
int injectedChannelsOffset = 0;
|
||||
int injectedChannelsIncrement = 0;
|
||||
int vetoReference[NCHIP][NCHAN];
|
||||
@ -389,9 +391,13 @@ void setupDetector() {
|
||||
cdsGain = 0;
|
||||
memset(clkPhase, 0, sizeof(clkPhase));
|
||||
memset(dacValues, 0, sizeof(dacValues));
|
||||
for (int i = 0; i < NDAC; ++i) {
|
||||
defaultDacValues[i] = -1;
|
||||
}
|
||||
for (int i = 0; i < ONCHIP_NDAC; ++i) {
|
||||
for (int j = 0; j < NCHIP; ++j) {
|
||||
onChipdacValues[i][j] = -1;
|
||||
defaultOnChipdacValues[i][j] = -1;
|
||||
}
|
||||
}
|
||||
memset(vetoReference, 0, sizeof(vetoReference));
|
||||
@ -475,6 +481,40 @@ void setupDetector() {
|
||||
setCurrentSource(DEFAULT_CURRENT_SOURCE);
|
||||
}
|
||||
|
||||
int setDefaultDacs() {
|
||||
int ret = OK;
|
||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||
for (int i = 0; i < NDAC; ++i) {
|
||||
if (defaultDacValues[i] != -1) {
|
||||
setDAC((enum DACINDEX)i, defaultDacValues[i], 0);
|
||||
if (dacValues[i] != defaultDacValues[i]) {
|
||||
ret = FAIL;
|
||||
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
|
||||
defaultDacValues[i], dacValues[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
LOG(logINFOBLUE, ("Setting Default On-chip Dac values\n"));
|
||||
for (int ichip = 0; ichip < NCHIP; ++ichip) {
|
||||
for (int idac = 0; idac < ONCHIP_NDAC; ++idac) {
|
||||
if (defaultOnChipdacValues[idac][ichip] != -1) {
|
||||
setOnChipDAC((enum ONCHIP_DACINDEX)idac, ichip,
|
||||
defaultOnChipdacValues[idac][ichip]);
|
||||
if (onChipdacValues[idac][ichip] !=
|
||||
defaultOnChipdacValues[idac][ichip]) {
|
||||
ret = FAIL;
|
||||
LOG(logERROR,
|
||||
("Setting on-chip dac %d (ichip:%d) failed, "
|
||||
"wrote %d, read %d\n",
|
||||
idac, ichip, defaultOnChipdacValues[idac][ichip],
|
||||
onChipdacValues[idac][ichip]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int readConfigFile() {
|
||||
|
||||
if (initError == FAIL) {
|
||||
@ -691,6 +731,18 @@ int readConfigFile() {
|
||||
break;
|
||||
}
|
||||
|
||||
// set default on chip dac variable
|
||||
// specific chip
|
||||
if (ichip != -1) {
|
||||
defaultOnChipdacValues[idac][ichip] = value;
|
||||
}
|
||||
// all chips
|
||||
else {
|
||||
for (int i = 0; i < NCHIP; ++i) {
|
||||
defaultOnChipdacValues[idac][i] = value;
|
||||
}
|
||||
}
|
||||
|
||||
// set on chip dac
|
||||
if (setOnChipDAC(idac, ichip, value) == FAIL) {
|
||||
sprintf(initErrorMessage,
|
||||
@ -703,7 +755,6 @@ int readConfigFile() {
|
||||
|
||||
// dac command
|
||||
else {
|
||||
|
||||
enum DACINDEX idac = 0;
|
||||
int value = 0;
|
||||
|
||||
@ -752,6 +803,9 @@ int readConfigFile() {
|
||||
break;
|
||||
}
|
||||
|
||||
// set default dac variables
|
||||
defaultDacValues[idac] = value;
|
||||
|
||||
// set dac
|
||||
setDAC(idac, value, 0);
|
||||
int retval = getDAC(idac, 0);
|
||||
|
Binary file not shown.
@ -436,9 +436,11 @@ int setDefaultDacs() {
|
||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
|
||||
for (int i = 0; i < NDAC; ++i) {
|
||||
// if not already default, set it to default
|
||||
setDAC((enum DACINDEX)i, defaultvals[i], 0);
|
||||
if (dacValues[i] != defaultvals[i]) {
|
||||
setDAC((enum DACINDEX)i, defaultvals[i], 0);
|
||||
ret = FAIL;
|
||||
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
|
||||
defaultvals[i], dacValues[i]));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
Binary file not shown.
@ -458,9 +458,11 @@ int setDefaultDacs() {
|
||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
|
||||
for (int i = 0; i < NDAC; ++i) {
|
||||
// if not already default, set it to default
|
||||
setDAC((enum DACINDEX)i, defaultvals[i], 0);
|
||||
if (dacValues[i] != defaultvals[i]) {
|
||||
setDAC((enum DACINDEX)i, defaultvals[i], 0);
|
||||
ret = FAIL;
|
||||
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
|
||||
defaultvals[i], dacValues[i]));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
Binary file not shown.
@ -616,9 +616,11 @@ int setDefaultDacs() {
|
||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
|
||||
for (int i = 0; i < NDAC; ++i) {
|
||||
// if not already default, set it to default
|
||||
setDAC((enum DACINDEX)i, defaultvals[i], 0);
|
||||
if (dacValues[i] != defaultvals[i]) {
|
||||
setDAC((enum DACINDEX)i, defaultvals[i], 0);
|
||||
ret = FAIL;
|
||||
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
|
||||
defaultvals[i], dacValues[i]));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
Binary file not shown.
@ -493,6 +493,7 @@ int setDefaultDacs() {
|
||||
for (int i = 0; i < NDAC; ++i) {
|
||||
setDAC((enum DACINDEX)i, defaultvals[i], 0);
|
||||
if (detectorDacs[i] != defaultvals[i]) {
|
||||
ret = FAIL;
|
||||
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
|
||||
defaultvals[i], detectorDacs[i]));
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "slsDetectorServer_defs.h" // DAC_INDEX, ADC_INDEX, also include RegisterDefs.h
|
||||
#include "sls/sls_detector_defs.h"
|
||||
#include "slsDetectorServer_defs.h" // DAC_INDEX, ADC_INDEX, also include RegisterDefs.h
|
||||
#ifdef GOTTHARDD
|
||||
#include "AD9252.h" // old board compatibility
|
||||
#include "clogger.h" // runState(enum TLogLevel)
|
||||
@ -114,8 +114,7 @@ int updateDatabytesandAllocateRAM();
|
||||
void updateDataBytes();
|
||||
#endif
|
||||
|
||||
#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(MYTHEN3D) || \
|
||||
defined(MOENCHD)
|
||||
#ifndef CHIPTESTBOARDD
|
||||
int setDefaultDacs();
|
||||
#endif
|
||||
#ifdef MYTHEN3D
|
||||
|
@ -240,4 +240,5 @@ int set_bad_channels(int);
|
||||
int reconfigure_udp(int);
|
||||
int validate_udp_configuration(int);
|
||||
int get_bursts_left(int);
|
||||
int start_readout(int);
|
||||
int start_readout(int);
|
||||
int set_default_dacs(int);
|
@ -2,8 +2,8 @@
|
||||
#include "clogger.h"
|
||||
#include "communication_funcs.h"
|
||||
#include "sharedMemory.h"
|
||||
#include "slsDetectorFunctionList.h"
|
||||
#include "sls/sls_detector_funcs.h"
|
||||
#include "slsDetectorFunctionList.h"
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <pthread.h>
|
||||
@ -359,6 +359,7 @@ void function_table() {
|
||||
flist[F_VALIDATE_UDP_CONFIG] = &validate_udp_configuration;
|
||||
flist[F_GET_BURSTS_LEFT] = &get_bursts_left;
|
||||
flist[F_START_READOUT] = &start_readout;
|
||||
flist[F_SET_DEFAULT_DACS] = &set_default_dacs;
|
||||
|
||||
// check
|
||||
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
||||
@ -1634,8 +1635,7 @@ int set_settings(int file_des) {
|
||||
|
||||
if ((int)isett != GET_FLAG) {
|
||||
validate((int)isett, (int)retval, "set settings", DEC);
|
||||
#if defined(JUNGFRAUD) || defined(GOTTHARDD)
|
||||
// gotthard2 does not set default dacs
|
||||
#ifdef GOTTHARDD
|
||||
if (ret == OK) {
|
||||
ret = setDefaultDacs();
|
||||
if (ret == FAIL) {
|
||||
@ -8145,3 +8145,21 @@ int start_readout(int file_des) {
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
||||
int set_default_dacs(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
|
||||
#ifdef CHIPTESTBOARDD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (setDefaultDacs() == FAIL) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Could not set default dacs");
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
@ -381,6 +381,9 @@ class Detector {
|
||||
/** gets list of dac enums for this detector */
|
||||
std::vector<defs::dacIndex> getDacList() const;
|
||||
|
||||
/** [Eiger][Jungfrau][Moench][Gotthard][Gotthard2][Mythen3] */
|
||||
void setDefaultDacs(Positions pos = {});
|
||||
|
||||
Result<int> getDAC(defs::dacIndex index, bool mV = false,
|
||||
Positions pos = {}) const;
|
||||
|
||||
|
@ -826,6 +826,7 @@ class CmdProxy {
|
||||
{"dac", &CmdProxy::Dac},
|
||||
{"daclist", &CmdProxy::daclist},
|
||||
{"dacvalues", &CmdProxy::DacValues},
|
||||
{"defaultdacs", &CmdProxy::defaultdacs},
|
||||
|
||||
/* on chip dacs */
|
||||
{"vchip_comp_fe", &CmdProxy::vchip_comp_fe},
|
||||
@ -1211,7 +1212,8 @@ class CmdProxy {
|
||||
"\n\t[Moench] - [g1_hg | g1_lg | g2_hc_hg | g2_hc_lg | "
|
||||
"g2_lc_hg | g2_lc_lg | g4_hg | g4_lg]"
|
||||
"\n\t[Eiger] Use threshold or thresholdnotb. \n\t[Eiger] "
|
||||
"settings loaded from file found in settingspath.");
|
||||
"settings loaded from file found in settingspath. \n\t[Gotthard] Also "
|
||||
"loads default dacs on to the detector.");
|
||||
|
||||
EXECUTE_SET_COMMAND_1ARG(
|
||||
trimbits, loadTrimbits,
|
||||
@ -1378,6 +1380,10 @@ class CmdProxy {
|
||||
daclist, getDacList,
|
||||
"\n\tGets the list of commands for every dac for this detector.");
|
||||
|
||||
EXECUTE_SET_COMMAND(defaultdacs, setDefaultDacs,
|
||||
"\n\t[Eiger][Jungfrau][Gotthard][Moench][Gotthard2]["
|
||||
"Mythen3]Sets default dacs on to the detector.");
|
||||
|
||||
/* on chip dacs */
|
||||
INTEGER_USER_IND_COMMAND(
|
||||
vchip_comp_fe, getOnChipDAC, setOnChipDAC, StringTo<int>,
|
||||
|
@ -542,6 +542,10 @@ std::vector<defs::dacIndex> Detector::getDacList() const {
|
||||
return retval;
|
||||
}
|
||||
|
||||
void Detector::setDefaultDacs(Positions pos) {
|
||||
pimpl->Parallel(&Module::setDefaultDacs, pos);
|
||||
}
|
||||
|
||||
Result<int> Detector::getDAC(defs::dacIndex index, bool mV,
|
||||
Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getDAC, pos, index, mV);
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "Module.h"
|
||||
#include "sls/ClientSocket.h"
|
||||
#include "SharedMemory.h"
|
||||
#include "sls/ClientSocket.h"
|
||||
#include "sls/ToString.h"
|
||||
#include "sls/container_utils.h"
|
||||
#include "sls/file_utils.h"
|
||||
@ -335,6 +335,8 @@ int Module::getDAC(dacIndex index, bool mV) const {
|
||||
return sendToDetector<int>(F_SET_DAC, args);
|
||||
}
|
||||
|
||||
void Module::setDefaultDacs() { sendToDetector(F_SET_DEFAULT_DACS); }
|
||||
|
||||
void Module::setDAC(int val, dacIndex index, bool mV) {
|
||||
int args[]{static_cast<int>(index), static_cast<int>(mV), val};
|
||||
sendToDetector<int>(F_SET_DAC, args);
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include "sls/ClientSocket.h"
|
||||
#include "SharedMemory.h"
|
||||
#include "sls/ClientSocket.h"
|
||||
#include "sls/StaticVector.h"
|
||||
#include "sls/logger.h"
|
||||
#include "sls/network_utils.h"
|
||||
@ -136,6 +136,8 @@ class Module : public virtual slsDetectorDefs {
|
||||
int getMaxClockPhaseShift(int clkIndex) const;
|
||||
int getClockFrequency(int clkIndex) const;
|
||||
void setClockFrequency(int clkIndex, int value);
|
||||
/** [Eiger][Jungfrau][Moench][Gotthard][Gotthard2][Mythen3] */
|
||||
void setDefaultDacs();
|
||||
int getDAC(dacIndex index, bool mV) const;
|
||||
void setDAC(int val, dacIndex index, bool mV);
|
||||
bool getPowerChip() const;
|
||||
|
@ -1146,6 +1146,19 @@ TEST_CASE("dacvalues", "[.cmd][.new]") {
|
||||
REQUIRE_THROWS(proxy.Call("dacvalues", {}, -1, PUT));
|
||||
}
|
||||
|
||||
TEST_CASE("defaultdacs", "[.cmd][.new]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type != defs::CHIPTESTBOARD) {
|
||||
REQUIRE_THROWS(proxy.Call("defaultdacs", {}, -1, GET));
|
||||
REQUIRE_NOTHROW(proxy.Call("defaultdacs", {}, -1, PUT));
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("defaultdacs", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("defaultdacs", {}, -1, PUT));
|
||||
}
|
||||
}
|
||||
|
||||
/* acquisition */
|
||||
|
||||
TEST_CASE("trigger", "[.cmd][.new]") {
|
||||
|
@ -215,6 +215,7 @@ enum detFuncs {
|
||||
F_VALIDATE_UDP_CONFIG,
|
||||
F_GET_BURSTS_LEFT,
|
||||
F_START_READOUT,
|
||||
F_SET_DEFAULT_DACS,
|
||||
|
||||
NUM_DET_FUNCTIONS,
|
||||
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
|
||||
@ -535,6 +536,7 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
||||
case F_VALIDATE_UDP_CONFIG: return "F_VALIDATE_UDP_CONFIG";
|
||||
case F_GET_BURSTS_LEFT: return "F_GET_BURSTS_LEFT";
|
||||
case F_START_READOUT: return "F_START_READOUT";
|
||||
case F_SET_DEFAULT_DACS: return "F_SET_DEFAULT_DACS";
|
||||
|
||||
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
|
||||
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
|
||||
|
@ -1,12 +1,12 @@
|
||||
/** API versions */
|
||||
#define GITBRANCH "developer"
|
||||
#define APICTB 0x201102
|
||||
#define APIGOTTHARD 0x201102
|
||||
#define APIGOTTHARD2 0x201102
|
||||
#define APIJUNGFRAU 0x201102
|
||||
#define APIMYTHEN3 0x201102
|
||||
#define APIMOENCH 0x201102
|
||||
#define APIEIGER 0x201102
|
||||
#define APILIB 0x201102
|
||||
#define APIRECEIVER 0x201102
|
||||
#define APIGUI 0x201102
|
||||
#define APICTB 0x201110
|
||||
#define APIGOTTHARD 0x201110
|
||||
#define APIGOTTHARD2 0x201110
|
||||
#define APIJUNGFRAU 0x201110
|
||||
#define APIMYTHEN3 0x201110
|
||||
#define APIMOENCH 0x201110
|
||||
#define APIEIGER 0x201110
|
||||
|
Loading…
x
Reference in New Issue
Block a user