mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-16 17:58:05 +01:00
Defaultdacs (#214)
This commit is contained in:
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);
|
||||
}
|
||||
Reference in New Issue
Block a user