mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 15:20:02 +02:00
done, but need to compile
This commit is contained in:
parent
0254ff0281
commit
c755a8974c
@ -308,7 +308,7 @@ int receiveData(int file_des, void* buf,int length, intType itype){
|
|||||||
int ret = receiveDataOnly(file_des, buf, length);
|
int ret = receiveDataOnly(file_des, buf, length);
|
||||||
#ifndef PCCOMPILE
|
#ifndef PCCOMPILE
|
||||||
#ifdef EIGERD
|
#ifdef EIGERD
|
||||||
swapData(buf, length, itype);
|
if (ret >= 0) swapData(buf, length, itype);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
@ -316,9 +316,9 @@ int receiveData(int file_des, void* buf,int length, intType itype){
|
|||||||
|
|
||||||
|
|
||||||
int sendDataOnly(int file_des, void* buf,int length) {
|
int sendDataOnly(int file_des, void* buf,int length) {
|
||||||
|
int ret = write(file_des, buf, length); //value of -1 is other end socket crash as sigpipe is ignored
|
||||||
|
if (ret < 0) cprintf(BG_RED, "Error writing to socket. Possible socket crash\n");
|
||||||
return write(file_des, buf, length);
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -332,33 +332,23 @@ int receiveData(int file_des, void* buf,int length, intType itype){
|
|||||||
printf("want to receive %d Bytes\n", length);
|
printf("want to receive %d Bytes\n", length);
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
while(length>0){
|
while(length > 0) {
|
||||||
nreceiving = (length>send_rec_max_size) ? send_rec_max_size:length;
|
nreceiving = (length>send_rec_max_size) ? send_rec_max_size:length;
|
||||||
|
|
||||||
//#ifdef VERY_VERBOSE
|
|
||||||
// printf("want to receive %d Bytes\n", nreceiving);
|
|
||||||
//#endif
|
|
||||||
nreceived = read(file_des,(char*)buf+total_received,nreceiving);
|
nreceived = read(file_des,(char*)buf+total_received,nreceiving);
|
||||||
//#ifdef VERY_VERBOSE
|
if(!nreceived){
|
||||||
// printf("read %d \n", nreceived);
|
if(!total_received) {
|
||||||
//#endif
|
cprintf(BG_RED, "Error reading from socket. Possible socket crash\n");
|
||||||
if(!nreceived) break;
|
return -1; //to handle it
|
||||||
// if(nreceived<0) break;
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
length-=nreceived;
|
length-=nreceived;
|
||||||
total_received+=nreceived;
|
total_received+=nreceived;
|
||||||
// cout<<"nrec: "<<nreceived<<" waiting for ("<<length<<")"<<endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//#ifdef VERY_VERBOSE
|
|
||||||
// printf("received %d Bytes\n", total_received);
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
if (total_received>0)
|
if (total_received>0)
|
||||||
strcpy(thisClientIP,dummyClientIP);
|
strcpy(thisClientIP,dummyClientIP);
|
||||||
|
|
||||||
//if (strcmp(lastClientIP,"none")==0)
|
|
||||||
//strcpy(lastClientIP,thisClientIP);
|
|
||||||
|
|
||||||
if (strcmp(lastClientIP,thisClientIP))
|
if (strcmp(lastClientIP,thisClientIP))
|
||||||
differentClients=1;
|
differentClients=1;
|
||||||
else
|
else
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#ifndef SLS_DETECTOR_FUNCS_H
|
#ifndef SLS_DETECTOR_FUNCS_H
|
||||||
#define SLS_DETECTOR_FUNCS_H
|
#define SLS_DETECTOR_FUNCS_H
|
||||||
|
|
||||||
enum {
|
enum detFuncs{
|
||||||
|
|
||||||
// General purpose functions
|
// General purpose functions
|
||||||
F_EXEC_COMMAND=0, /**< command is executed */
|
F_EXEC_COMMAND=0, /**< command is executed */
|
||||||
@ -109,10 +109,13 @@ enum {
|
|||||||
F_PROGRAM_FPGA, /**< program FPGA */
|
F_PROGRAM_FPGA, /**< program FPGA */
|
||||||
F_RESET_FPGA, /**< reset FPGA */
|
F_RESET_FPGA, /**< reset FPGA */
|
||||||
F_POWER_CHIP, /**< power chip */
|
F_POWER_CHIP, /**< power chip */
|
||||||
|
F_ACTIVATE, /** < activate */
|
||||||
|
F_PREPARE_ACQUISITION, /** < prepare acquisition */
|
||||||
/* Always append functions hereafter!!! */
|
/* Always append functions hereafter!!! */
|
||||||
|
|
||||||
/* Always append functions before!!! */
|
/* Always append functions before!!! */
|
||||||
TOO_MANY_FUNCTIONS_DEFINED=128 //you should get a compilation error if there are already so many functions defined. It conflicts with sls_receiver_funcs.h
|
NUM_DET_FUNCTIONS,
|
||||||
|
TOO_MANY_FUNCTIONS_DEFINED=127 //you should get a compilation error if there are already so many functions defined. It conflicts with sls_receiver_funcs.h
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -117,22 +117,6 @@ void checkFirmwareCompatibility(){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int moduleTest( enum digitalTestMode arg, int imod){
|
|
||||||
cprintf(BG_RED, "Warning: Module Test not implemented for this detector\n");
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int detectorTest( enum digitalTestMode arg){
|
|
||||||
cprintf(BG_RED, "Warning: Detector Tests not implemented for this detector\n");
|
|
||||||
//DETECTOR_FIRMWARE_TEST:testFpga()
|
|
||||||
//DETECTOR_MEMORY_TEST:testRAM()
|
|
||||||
//DETECTOR_BUS_TEST:testBus()
|
|
||||||
//DETECTOR_SOFTWARE_TEST:testFpga()
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Ids */
|
/* Ids */
|
||||||
@ -1079,7 +1063,7 @@ int setNetworkParameter(enum detNetworkParameter mode, int value){
|
|||||||
/* aquisition */
|
/* aquisition */
|
||||||
|
|
||||||
|
|
||||||
int startReceiver(int d){
|
int prepareAcquisition(){
|
||||||
|
|
||||||
printf("Going to prepare for acquisition with counter_bit:%d\n",Feb_Control_Get_Counter_Bit());
|
printf("Going to prepare for acquisition with counter_bit:%d\n",Feb_Control_Get_Counter_Bit());
|
||||||
Feb_Control_PrepareForAcquisition();
|
Feb_Control_PrepareForAcquisition();
|
||||||
@ -1159,10 +1143,10 @@ enum runStatus getRunStatus(){
|
|||||||
//if(trialMasterMode == IS_MASTER){
|
//if(trialMasterMode == IS_MASTER){
|
||||||
int i = Feb_Control_AcquisitionInProgress();
|
int i = Feb_Control_AcquisitionInProgress();
|
||||||
if(i== 0){
|
if(i== 0){
|
||||||
//printf("IDLE\n");
|
printf("Status: IDLE\n");
|
||||||
return IDLE;
|
return IDLE;
|
||||||
}else{
|
}else{
|
||||||
printf("RUNNING\n");
|
printf("Status: RUNNING...\n");
|
||||||
return RUNNING;
|
return RUNNING;
|
||||||
}
|
}
|
||||||
//}else printf("***** not master*** \n");
|
//}else printf("***** not master*** \n");
|
||||||
|
@ -76,6 +76,11 @@ enum NETWORK_PARA_INDEX {TXN_LEFT, TXN_RIGHT, TXN_FRAME,FLOWCTRL_10G};
|
|||||||
#define DEFAULT_TIMING_MODE (AUTO_TIMING)
|
#define DEFAULT_TIMING_MODE (AUTO_TIMING)
|
||||||
#define DEFAULT_PHOTON_ENERGY (-1)
|
#define DEFAULT_PHOTON_ENERGY (-1)
|
||||||
#define DEFAULT_RATE_CORRECTION (0)
|
#define DEFAULT_RATE_CORRECTION (0)
|
||||||
|
#define DEFAULT_EXT_GATING_ENABLE (0)
|
||||||
|
#define DEFAULT_EXT_GATING_POLARITY (1) //positive
|
||||||
|
#define DEFAULT_TEST_MODE (0)
|
||||||
|
#define DEFAULT_HIGH_VOLTAGE (0)
|
||||||
|
|
||||||
|
|
||||||
#define MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS (0x1FFFFFFF) /** 29 bit register for max subframe exposure value */
|
#define MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS (0x1FFFFFFF) /** 29 bit register for max subframe exposure value */
|
||||||
|
|
||||||
|
@ -1581,11 +1581,11 @@ int stop_acquisition(int file_des) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int start_readout(int file_des) {
|
int start_readout(int file_des) {
|
||||||
|
|
||||||
int n;
|
int n;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
|
|
||||||
strcpy(mess, "Start Readout is not implemented for this detector!\n");
|
strcpy(mess, "Start Readout is not implemented for this detector!\n");
|
||||||
cprintf(RED,"Warning: %s", mess);
|
cprintf(RED,"Warning: %s", mess);
|
||||||
|
|
||||||
|
@ -1001,7 +1001,10 @@ int voltageToDac(int value){
|
|||||||
int vmin = 0;
|
int vmin = 0;
|
||||||
int vmax = 2500;
|
int vmax = 2500;
|
||||||
int nsteps = 4096;
|
int nsteps = 4096;
|
||||||
if ((value < vmin) || (value > vmax)) return -1;
|
if ((value < vmin) || (value > vmax)) {
|
||||||
|
cprintf(RED,"Voltage value (to convert to dac value) is outside bounds: %d\n", value);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return (int)(((value - vmin) / (vmax - vmin)) * (nsteps - 1) + 0.5);
|
return (int)(((value - vmin) / (vmax - vmin)) * (nsteps - 1) + 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1010,32 +1013,35 @@ int dacToVoltage(unsigned int digital){
|
|||||||
int vmax = 2500;
|
int vmax = 2500;
|
||||||
int nsteps = 4096;
|
int nsteps = 4096;
|
||||||
int v = vmin + (vmax - vmin) * digital / (nsteps - 1);
|
int v = vmin + (vmax - vmin) * digital / (nsteps - 1);
|
||||||
if((v < 0) || (v > nsteps - 1))
|
if((v < 0) || (v > nsteps - 1)) {
|
||||||
|
cprintf(RED,"\nVoltage value (converted from dac value) is outside bounds: %d\n", v);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void setDAC(enum DAC_INDEX ind, int val, int imod, int mV, int retval[]){
|
void setDAC(enum DAC_INDEX ind, int val, int imod, int mV, int retval[]){
|
||||||
|
int dacval = val;
|
||||||
|
|
||||||
//if set and mv, convert to dac
|
//if set and mv, convert to dac
|
||||||
if (val > 0 && mV)
|
if (val > 0 && mV) {
|
||||||
val = voltageToDac(val); //gives -1 on error
|
val = voltageToDac(val); //gives -1 on error
|
||||||
|
}
|
||||||
|
|
||||||
if ( (val >= 0) || (val == -100)) {
|
if ( (val >= 0) || (val == -100)) {
|
||||||
u_int32_t codata;
|
u_int32_t codata;
|
||||||
int csdx = dacnum / NDAC + DAC_SERIAL_CS_OUT_OFST; // old board (16 dacs),so can be DAC_SERIAL_CS_OUT_OFST or +1
|
int csdx = dacnum / NDAC + DAC_SERIAL_CS_OUT_OFST; // old board (16 dacs),so can be DAC_SERIAL_CS_OUT_OFST or +1
|
||||||
int dacchannel = dacnum % NDAC; // 0-8, dac channel number (also for dacnum 9-15 in old board)
|
int dacchannel = dacnum % NDAC; // 0-8, dac channel number (also for dacnum 9-15 in old board)
|
||||||
|
|
||||||
printf("\n Setting of DAC %d with value %d\n",dacnum, dacvalue);
|
printf("\n Setting of DAC %d : (%d dac units)\t %d mV\n",dacnum, dacval, val);
|
||||||
// command
|
// command
|
||||||
if (dacvalue >= 0) {
|
if (val >= 0) {
|
||||||
printf("Write to Input Register and Update\n");
|
printf("Write to Input Register and Update\n");
|
||||||
codata = LTC2620_DAC_CMD_SET;
|
codata = LTC2620_DAC_CMD_SET;
|
||||||
|
|
||||||
} else if (dacvalue == -100) {
|
} else if (val == -100) {
|
||||||
printf("POWER DOWN\n");
|
printf("POWER DOWN\n");
|
||||||
codata = LTC2620_DAC_CMD_POWER_DOWN;
|
codata = LTC2620_DAC_CMD_POWER_DOWN;
|
||||||
}
|
}
|
||||||
@ -1043,19 +1049,19 @@ void setDAC(enum DAC_INDEX ind, int val, int imod, int mV, int retval[]){
|
|||||||
printf("Chip select bit:%d\n"
|
printf("Chip select bit:%d\n"
|
||||||
"Dac Channel:0x%x\n3"
|
"Dac Channel:0x%x\n3"
|
||||||
"Dac Value:0x%x",
|
"Dac Value:0x%x",
|
||||||
csdx, dacchannel, dacvalue);
|
csdx, dacchannel, val);
|
||||||
codata += ((dacchannel << LTC2620_DAC_ADDR_OFST) & LTC2620_DAC_ADDR_MSK) +
|
codata += ((dacchannel << LTC2620_DAC_ADDR_OFST) & LTC2620_DAC_ADDR_MSK) +
|
||||||
((dacvalue << LTC2620_DAC_DATA_OFST) & LTC2620_DAC_DATA_MSK);
|
((val << LTC2620_DAC_DATA_OFST) & LTC2620_DAC_DATA_MSK);
|
||||||
// to spi
|
// to spi
|
||||||
serializeToSPI(SPI_REG, codata, (0x1 << csdx), LTC2620_DAC_NUMBITS,
|
serializeToSPI(SPI_REG, codata, (0x1 << csdx), LTC2620_DAC_NUMBITS,
|
||||||
DAC_SERIAL_CLK_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_OFST);
|
DAC_SERIAL_CLK_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_OFST);
|
||||||
|
|
||||||
dacValues[dacnum] = dacvalue;
|
dacValues[dacnum] = dacval;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\nGetting DAC %d\n",dacnum);
|
printf("\nGetting DAC %d : ",dacnum);
|
||||||
retval[0] = dacValues[dacnum];
|
retval[0] = dacValues[dacnum]; printf("(%d dac units)\t", retval[0]);
|
||||||
retval[1] = dacToVoltage(retval[0]);
|
retval[1] = dacToVoltage(retval[0]);printf("%d mV\n", retval[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1222,6 +1228,7 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
|
|||||||
resetCore();
|
resetCore();
|
||||||
|
|
||||||
usleep(500 * 1000); /* todo maybe without */
|
usleep(500 * 1000); /* todo maybe without */
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,6 +58,7 @@ enum DAC_INDEX {VB_COMP, VDD_PROT, VIN_COM, VREF_PRECH, VB_PIXBUF, VB_DS, VRE
|
|||||||
#define NCHIP (8)
|
#define NCHIP (8)
|
||||||
#define NADC (0)
|
#define NADC (0)
|
||||||
#define NDAC (8)
|
#define NDAC (8)
|
||||||
|
#define NDAC_OLDBOARD (16)
|
||||||
#define DYNAMIC_RANGE (16)
|
#define DYNAMIC_RANGE (16)
|
||||||
#define NUM_BITS_PER_PIXEL (DYNAMIC_RANGE / 8)
|
#define NUM_BITS_PER_PIXEL (DYNAMIC_RANGE / 8)
|
||||||
#define DATA_BYTES (NCHIP * NCHAN * NUM_BITS_PER_PIXEL)
|
#define DATA_BYTES (NCHIP * NCHAN * NUM_BITS_PER_PIXEL)
|
||||||
|
@ -1304,6 +1304,7 @@ string slsDetector::checkOnline() {
|
|||||||
|
|
||||||
int slsDetector::activate(int const enable){
|
int slsDetector::activate(int const enable){
|
||||||
int fnum = F_ACTIVATE;
|
int fnum = F_ACTIVATE;
|
||||||
|
int fnum2 = F_RECEIVER_ACTIVATE;
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
int arg = enable;
|
int arg = enable;
|
||||||
char mess[MAX_STR_LENGTH]="";
|
char mess[MAX_STR_LENGTH]="";
|
||||||
@ -1355,7 +1356,7 @@ int slsDetector::activate(int const enable){
|
|||||||
std::cout << "Activating/Deactivating Receiver: " << retval << std::endl;
|
std::cout << "Activating/Deactivating Receiver: " << retval << std::endl;
|
||||||
#endif
|
#endif
|
||||||
if (connectData() == OK){
|
if (connectData() == OK){
|
||||||
ret=thisReceiver->sendInt(fnum,retval,retval);
|
ret=thisReceiver->sendInt(fnum2,retval,retval);
|
||||||
disconnectData();
|
disconnectData();
|
||||||
}
|
}
|
||||||
if(ret==FAIL)
|
if(ret==FAIL)
|
||||||
@ -3851,14 +3852,12 @@ int slsDetector::updateDetectorNoWait() {
|
|||||||
|
|
||||||
n += controlSocket->ReceiveDataOnly( &nm,sizeof(nm));
|
n += controlSocket->ReceiveDataOnly( &nm,sizeof(nm));
|
||||||
thisDetector->dataBytes=nm;
|
thisDetector->dataBytes=nm;
|
||||||
|
|
||||||
//t=setSettings(GET_SETTINGS);
|
//t=setSettings(GET_SETTINGS);
|
||||||
n += controlSocket->ReceiveDataOnly( &t,sizeof(t));
|
n += controlSocket->ReceiveDataOnly( &t,sizeof(t));
|
||||||
thisDetector->currentSettings=t;
|
thisDetector->currentSettings=t;
|
||||||
|
|
||||||
if((thisDetector->myDetectorType!= GOTTHARD)&&
|
if((thisDetector->myDetectorType == EIGER) || (thisDetector->myDetectorType == MYTHEN)){
|
||||||
(thisDetector->myDetectorType!= PROPIX)&&
|
|
||||||
(thisDetector->myDetectorType!= JUNGFRAU)&&
|
|
||||||
(thisDetector->myDetectorType!= MOENCH) && (thisDetector->myDetectorType!= JUNGFRAUCTB)){
|
|
||||||
//thr=getThresholdEnergy();
|
//thr=getThresholdEnergy();
|
||||||
n += controlSocket->ReceiveDataOnly( &thr,sizeof(thr));
|
n += controlSocket->ReceiveDataOnly( &thr,sizeof(thr));
|
||||||
thisDetector->currentThresholdEV=thr;
|
thisDetector->currentThresholdEV=thr;
|
||||||
@ -3867,6 +3866,7 @@ int slsDetector::updateDetectorNoWait() {
|
|||||||
//retval=setFrames(tns);
|
//retval=setFrames(tns);
|
||||||
n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
|
n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
|
||||||
thisDetector->timerValue[FRAME_NUMBER]=retval;
|
thisDetector->timerValue[FRAME_NUMBER]=retval;
|
||||||
|
|
||||||
// retval=setExposureTime(tns);
|
// retval=setExposureTime(tns);
|
||||||
n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
|
n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
|
||||||
thisDetector->timerValue[ACQUISITION_TIME]=retval;
|
thisDetector->timerValue[ACQUISITION_TIME]=retval;
|
||||||
@ -3876,15 +3876,22 @@ int slsDetector::updateDetectorNoWait() {
|
|||||||
n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
|
n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
|
||||||
thisDetector->timerValue[SUBFRAME_ACQUISITION_TIME]=retval;
|
thisDetector->timerValue[SUBFRAME_ACQUISITION_TIME]=retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
//retval=setPeriod(tns);
|
//retval=setPeriod(tns);
|
||||||
n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
|
n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
|
||||||
thisDetector->timerValue[FRAME_PERIOD]=retval;
|
thisDetector->timerValue[FRAME_PERIOD]=retval;
|
||||||
|
|
||||||
|
if(thisDetector->myDetectorType != EIGER) {
|
||||||
//retval=setDelay(tns);
|
//retval=setDelay(tns);
|
||||||
n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
|
n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
|
||||||
thisDetector->timerValue[DELAY_AFTER_TRIGGER]=retval;
|
thisDetector->timerValue[DELAY_AFTER_TRIGGER]=retval;
|
||||||
|
}
|
||||||
|
|
||||||
// retval=setGates(tns);
|
// retval=setGates(tns);
|
||||||
|
if ((thisDetector->myDetectorType != JUNGFRAU) && (thisDetector->myDetectorType != EIGER)){
|
||||||
n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
|
n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
|
||||||
thisDetector->timerValue[GATES_NUMBER]=retval;
|
thisDetector->timerValue[GATES_NUMBER]=retval;
|
||||||
|
}
|
||||||
|
|
||||||
//retval=setProbes(tns);
|
//retval=setProbes(tns);
|
||||||
if (thisDetector->myDetectorType == MYTHEN){
|
if (thisDetector->myDetectorType == MYTHEN){
|
||||||
@ -3892,7 +3899,6 @@ int slsDetector::updateDetectorNoWait() {
|
|||||||
thisDetector->timerValue[PROBES_NUMBER]=retval;
|
thisDetector->timerValue[PROBES_NUMBER]=retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//retval=setTrains(tns);
|
//retval=setTrains(tns);
|
||||||
n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
|
n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
|
||||||
thisDetector->timerValue[CYCLES_NUMBER]=retval;
|
thisDetector->timerValue[CYCLES_NUMBER]=retval;
|
||||||
@ -3908,9 +3914,7 @@ int slsDetector::updateDetectorNoWait() {
|
|||||||
|
|
||||||
//retval=setProbes(tns);
|
//retval=setProbes(tns);
|
||||||
getTotalNumberOfChannels();
|
getTotalNumberOfChannels();
|
||||||
|
|
||||||
// thisDetector->dataBytes=getTotalNumberOfChannels()*thisDetector->dynamicRange/8*thisDetector->timerValue[SAMPLES_JCTB];
|
// thisDetector->dataBytes=getTotalNumberOfChannels()*thisDetector->dynamicRange/8*thisDetector->timerValue[SAMPLES_JCTB];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -6964,7 +6968,7 @@ int slsDetector::programFPGA(string fname){
|
|||||||
#endif
|
#endif
|
||||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||||
if (connectControl() == OK){
|
if (connectControl() == OK){
|
||||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
controlSocket->SendDataOnly(&fnum,sizeof(fnum));cprintf(BG_RED,"size of filesize:%d\n",sizeof(filesize));
|
||||||
controlSocket->SendDataOnly(&filesize,sizeof(filesize));
|
controlSocket->SendDataOnly(&filesize,sizeof(filesize));
|
||||||
//check opening error
|
//check opening error
|
||||||
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||||
|
@ -25,9 +25,11 @@ int checkType();
|
|||||||
u_int32_t testFpga(void);
|
u_int32_t testFpga(void);
|
||||||
int testBus(void);
|
int testBus(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(MYTHEND) || defined(JUNGFRAUD)
|
||||||
int moduleTest( enum digitalTestMode arg, int imod);
|
int moduleTest( enum digitalTestMode arg, int imod);
|
||||||
int detectorTest( enum digitalTestMode arg);
|
int detectorTest( enum digitalTestMode arg);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Ids
|
// Ids
|
||||||
int64_t getDetectorId(enum idMode arg);
|
int64_t getDetectorId(enum idMode arg);
|
||||||
@ -89,7 +91,7 @@ int getPhase();
|
|||||||
int setNMod(int nm, enum dimension dim); // mythen specific, but for detector compatibility as a get
|
int setNMod(int nm, enum dimension dim); // mythen specific, but for detector compatibility as a get
|
||||||
int getNModBoard(enum dimension arg); // mythen specific, but for detector compatibility as a get
|
int getNModBoard(enum dimension arg); // mythen specific, but for detector compatibility as a get
|
||||||
int setDynamicRange(int dr);
|
int setDynamicRange(int dr);
|
||||||
#ifdef MYTHEND
|
#ifdef GOTTHARD
|
||||||
int setROI(int n, ROI arg[], int *retvalsize, int *ret);
|
int setROI(int n, ROI arg[], int *retvalsize, int *ret);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -126,8 +128,8 @@ enum detectorSettings setSettings(enum detectorSettings sett, int imod);
|
|||||||
enum detectorSettings getSettings();
|
enum detectorSettings getSettings();
|
||||||
|
|
||||||
|
|
||||||
#if defined(MYTHEND) || defined(EIGERD)
|
|
||||||
// parameters - threshold
|
// parameters - threshold
|
||||||
|
#if defined(MYTHEND) || defined(EIGERD)
|
||||||
int getThresholdEnergy(int imod);
|
int getThresholdEnergy(int imod);
|
||||||
int setThresholdEnergy(int ev, int imod);
|
int setThresholdEnergy(int ev, int imod);
|
||||||
#endif
|
#endif
|
||||||
@ -166,15 +168,16 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
|
|||||||
|
|
||||||
|
|
||||||
// very detector specific
|
// very detector specific
|
||||||
#ifdef GOTTHARDD
|
|
||||||
// gotthard specific - image, pedestal
|
// gotthard specific - image, pedestal
|
||||||
|
#ifdef GOTTHARDD
|
||||||
int loadImage(enum imageType index, char *imageVals);
|
int loadImage(enum imageType index, char *imageVals);
|
||||||
int readCounterBlock(int startACQ, char *counterVals);
|
int readCounterBlock(int startACQ, char *counterVals);
|
||||||
int resetCounterBlock(int startACQ);
|
int resetCounterBlock(int startACQ);
|
||||||
int calibratePedestal(int frames);
|
int calibratePedestal(int frames);
|
||||||
|
|
||||||
#elif JUNGFRAUD
|
|
||||||
// jungfrau specific - pll, flashing firmware
|
// jungfrau specific - pll, flashing firmware
|
||||||
|
#elif JUNGFRAUD
|
||||||
void resetPLL();
|
void resetPLL();
|
||||||
u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val);
|
u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val);
|
||||||
void configurePll();
|
void configurePll();
|
||||||
@ -183,8 +186,8 @@ int startWritingFPGAprogram(FILE** filefp);
|
|||||||
int stopWritingFPGAprogram(FILE* filefp);
|
int stopWritingFPGAprogram(FILE* filefp);
|
||||||
int writeFPGAProgram(char* fpgasrc, size_t fsize, FILE* filefp);
|
int writeFPGAProgram(char* fpgasrc, size_t fsize, FILE* filefp);
|
||||||
|
|
||||||
|
// eiger specific - iodelay, 10g, pulse, rate, temp, activate, delay nw parameter
|
||||||
#elif EIGERD
|
#elif EIGERD
|
||||||
//eiger specific - iodelay, 10g, pulse, rate, temp, activate, delay nw parameter
|
|
||||||
int setIODelay(int val, int imod);
|
int setIODelay(int val, int imod);
|
||||||
int enableTenGigabitEthernet(int val);
|
int enableTenGigabitEthernet(int val);
|
||||||
int setCounterBit(int val);
|
int setCounterBit(int val);
|
||||||
@ -208,8 +211,8 @@ int setNetworkParameter(enum NETWORK_PARA_INDEX mode, int value);
|
|||||||
|
|
||||||
|
|
||||||
// aquisition
|
// aquisition
|
||||||
#ifdef defined(EIGERD) || defined(GOTTHARD)
|
#if defined(EIGERD) || defined(GOTTHARD)
|
||||||
int startReceiver(int d);
|
int prepareAcquisition();
|
||||||
#endif
|
#endif
|
||||||
int startStateMachine();
|
int startStateMachine();
|
||||||
int stopStateMachine();
|
int stopStateMachine();
|
||||||
|
@ -23,13 +23,16 @@ int main(int argc, char *argv[]){
|
|||||||
int retval=OK;
|
int retval=OK;
|
||||||
int sd, fd;
|
int sd, fd;
|
||||||
|
|
||||||
|
// if socket crash, ignores SISPIPE, prevents global signal handler
|
||||||
|
// subsequent read/write to socket gives error - must handle locally
|
||||||
|
signal(SIGPIPE, SIG_IGN);
|
||||||
|
|
||||||
|
|
||||||
#ifdef STOP_SERVER
|
#ifdef STOP_SERVER
|
||||||
char cmd[100];
|
char cmd[100];
|
||||||
#endif
|
#endif
|
||||||
if (argc==1) {
|
if (argc==1) {
|
||||||
|
|
||||||
basictests();
|
basictests();
|
||||||
//#endif
|
|
||||||
portno = DEFAULT_PORTNO;
|
portno = DEFAULT_PORTNO;
|
||||||
printf("opening control server on port %d\n",portno );
|
printf("opening control server on port %d\n",portno );
|
||||||
b=1;
|
b=1;
|
||||||
@ -39,22 +42,18 @@ int main(int argc, char *argv[]){
|
|||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
portno = DEFAULT_PORTNO+1;
|
portno = DEFAULT_PORTNO+1;
|
||||||
if ( sscanf(argv[1],"%d",&portno) ==0) {
|
if ( sscanf(argv[1],"%d",&portno) == 0) {
|
||||||
printf("could not open stop server: unknown port\n");
|
printf("could not open stop server: unknown port\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
printf("opening stop server on port %d\n",portno);
|
printf("opening stop server on port %d\n",portno);
|
||||||
b=0;
|
b=0;
|
||||||
}
|
}
|
||||||
//#endif
|
|
||||||
|
|
||||||
|
|
||||||
init_detector(b); //defined in slsDetectorServer_funcs
|
init_detector(b); //defined in slsDetectorServer_funcs
|
||||||
|
|
||||||
sd=bindSocket(portno); //defined in communication_funcs
|
sd=bindSocket(portno); //defined in communication_funcs
|
||||||
|
|
||||||
sockfd=sd;
|
sockfd=sd;
|
||||||
|
|
||||||
if (getServerError(sd)) { //defined in communication_funcs
|
if (getServerError(sd)) { //defined in communication_funcs
|
||||||
printf("server error!\n");
|
printf("server error!\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,37 +1,20 @@
|
|||||||
#ifndef SERVER_FUNCS_H
|
#ifndef SERVER_FUNCS_H
|
||||||
#define SERVER_FUNCS_H
|
#define SERVER_FUNCS_H
|
||||||
|
|
||||||
#include "sls_detector_defs.h"
|
#include "sls_receiver_defs.h"
|
||||||
#include "slsDetectorServer_defs.h"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
// initialization functions
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//basic server functions
|
|
||||||
void basictests();
|
void basictests();
|
||||||
int init_detector(int);
|
void init_detector(int);
|
||||||
int decode_function(int);
|
int decode_function(int);
|
||||||
int function_table();
|
const char* getFunctionName(enum detFuncs func);
|
||||||
//int swap_int32(int val);
|
void function_table();
|
||||||
//int64_t swap_int64(int64_t val);
|
|
||||||
int M_nofunc(int);
|
int M_nofunc(int);
|
||||||
int exit_server(int);
|
|
||||||
|
// functions called by client
|
||||||
int exec_command(int);
|
int exec_command(int);
|
||||||
|
int get_error(int);
|
||||||
//advnaced server functions
|
|
||||||
int lock_server(int);
|
|
||||||
int get_last_client_ip(int);
|
|
||||||
int set_port(int);
|
|
||||||
int send_update(int);
|
|
||||||
int update_client(int);
|
|
||||||
int set_master(int);
|
|
||||||
int set_synchronization(int);
|
|
||||||
|
|
||||||
//detector specific functions
|
|
||||||
//F_GET_ERROR
|
|
||||||
int get_detector_type(int);
|
int get_detector_type(int);
|
||||||
int set_number_of_modules(int);
|
int set_number_of_modules(int);
|
||||||
int get_max_number_of_modules(int);
|
int get_max_number_of_modules(int);
|
||||||
@ -39,24 +22,23 @@ int set_external_signal_flag(int);
|
|||||||
int set_external_communication_mode(int);
|
int set_external_communication_mode(int);
|
||||||
int get_id(int);
|
int get_id(int);
|
||||||
int digital_test(int);
|
int digital_test(int);
|
||||||
//F_ANALOG_TEST
|
int analog_test(int);
|
||||||
//F_ENABLE_ANALOG_OUT
|
int enable_analog_out(int);
|
||||||
//F_CALIBRATION_PULSE
|
int calibration_pulse(int);
|
||||||
int set_dac(int);
|
int set_dac(int);
|
||||||
int get_adc(int);
|
int get_adc(int);
|
||||||
int write_register(int);
|
int write_register(int);
|
||||||
int read_register(int);
|
int read_register(int);
|
||||||
//F_WRITE_MEMORY
|
int write_memory(int);
|
||||||
//F_READ_MEMORY
|
int read_memory(int);
|
||||||
int set_channel(int);
|
int set_channel(int);
|
||||||
int get_channel(int);
|
int get_channel(int);
|
||||||
//F_SET_ALL_CHANNELS
|
int set_all_channels(int);
|
||||||
int set_chip(int);
|
int set_chip(int);
|
||||||
int get_chip(int);
|
int get_chip(int);
|
||||||
//F_SET_ALL_CHIPS
|
int set_all_chips(int);
|
||||||
int set_module(int);
|
int set_module(int);
|
||||||
int get_module(int);
|
int get_module(int);
|
||||||
//F_SET_ALL_MODULES
|
|
||||||
int set_settings(int);
|
int set_settings(int);
|
||||||
int get_threshold_energy(int);
|
int get_threshold_energy(int);
|
||||||
int set_threshold_energy(int);
|
int set_threshold_energy(int);
|
||||||
@ -74,22 +56,35 @@ int set_readout_flags(int);
|
|||||||
int set_roi(int);
|
int set_roi(int);
|
||||||
int set_speed(int);
|
int set_speed(int);
|
||||||
int execute_trimming(int);
|
int execute_trimming(int);
|
||||||
|
int exit_server(int);
|
||||||
|
int lock_server(int);
|
||||||
|
int get_last_client_ip(int);
|
||||||
|
int set_port(int);
|
||||||
|
int update_client(int);
|
||||||
|
int send_update(int);
|
||||||
int configure_mac(int);
|
int configure_mac(int);
|
||||||
int load_image(int);
|
int load_image(int);
|
||||||
|
int set_master(int);
|
||||||
|
int set_synchronization(int);
|
||||||
int read_counter_block(int);
|
int read_counter_block(int);
|
||||||
int reset_counter_block(int);
|
int reset_counter_block(int);
|
||||||
int start_receiver(int);
|
|
||||||
int stop_receiver(int);
|
|
||||||
int calibrate_pedestal(int);
|
int calibrate_pedestal(int);
|
||||||
int enable_ten_giga(int);
|
int enable_ten_giga(int);
|
||||||
int set_all_trimbits(int);
|
int set_all_trimbits(int);
|
||||||
|
int set_ctb_pattern(int);
|
||||||
|
int write_adc_register(int);
|
||||||
int set_counter_bit(int);
|
int set_counter_bit(int);
|
||||||
int pulse_pixel(int);
|
int pulse_pixel(int);
|
||||||
int pulse_pixel_and_move(int);
|
int pulse_pixel_and_move(int);
|
||||||
int pulse_chip(int);
|
int pulse_chip(int);
|
||||||
int set_rate_correct(int);
|
int set_rate_correct(int);
|
||||||
int get_rate_correct(int);
|
int get_rate_correct(int);
|
||||||
int set_activate(int);
|
|
||||||
int set_network_parameter(int);
|
int set_network_parameter(int);
|
||||||
|
int program_fpga(int);
|
||||||
|
int reset_fpga(int);
|
||||||
|
int power_chip(int);
|
||||||
|
int set_activate(int);
|
||||||
|
int prepare_acquisition(int);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user