mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-12-27 14:41:19 +01:00
Merged to developer
This commit is contained in:
@@ -69,14 +69,14 @@ gotthardVirtualServer: $(SRC_MYTHEN_SVC)
|
||||
|
||||
|
||||
%.o : %.cpp %.h Makefile
|
||||
$(CXX) -o $@ -c $< $(INCLUDES) $(DFLAGS) -fPIC $(EPICSFLAGS) -lpthread -lrt $(LIBZMQ) #$(FLAGS)
|
||||
$(CXX) -o $@ -c $< $(INCLUDES) $(DFLAGS) -fPIC $(EPICSFLAGS) -pthread -lrt $(LIBZMQ) $(FLAGS)
|
||||
|
||||
|
||||
package: $(OBJS) $(DESTDIR)/libSlsDetector.so $(DESTDIR)/libSlsDetector.a
|
||||
|
||||
|
||||
$(DESTDIR)/libSlsDetector.so: $(OBJS)
|
||||
$(CXX) -shared -Wl,-soname,libSlsDetector.so -o libSlsDetector.so $(OBJS) -lc $(INCLUDES) $(DFLAGS) $(FLAGS) $(EPICSFLAGS) -L/usr/lib64 -lpthread -lrt $(LIBZMQ)
|
||||
$(CXX) -shared -Wl,-soname,libSlsDetector.so -o libSlsDetector.so $(OBJS) -lc $(INCLUDES) $(DFLAGS) $(FLAGS) $(EPICSFLAGS) -L/usr/lib64 -pthread -lrt $(LIBZMQ)
|
||||
$(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR))
|
||||
mv libSlsDetector.so $(DESTDIR)
|
||||
|
||||
|
||||
@@ -308,7 +308,7 @@ int receiveData(int file_des, void* buf,int length, intType itype){
|
||||
int ret = receiveDataOnly(file_des, buf, length);
|
||||
#ifndef PCCOMPILE
|
||||
#ifdef EIGERD
|
||||
swapData(buf, length, itype);
|
||||
if (ret >= 0) swapData(buf, length, itype);
|
||||
#endif
|
||||
#endif
|
||||
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) {
|
||||
|
||||
|
||||
return write(file_des, buf, 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 ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -328,37 +328,32 @@ int receiveData(int file_des, void* buf,int length, intType itype){
|
||||
int nreceiving;
|
||||
int nreceived;
|
||||
if (file_des<0) return -1;
|
||||
<<<<<<< HEAD
|
||||
#ifdef VERY_VERBOSE
|
||||
printf("want to receive %d Bytes\n", length);
|
||||
#endif
|
||||
=======
|
||||
#ifdef VERY_VERBOSE
|
||||
printf("want to receive %d Bytes\n", length);
|
||||
#endif
|
||||
>>>>>>> e564542ad33a64e66ad6153066741c69c707f99d
|
||||
|
||||
while(length > 0) {
|
||||
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);
|
||||
//#ifdef VERY_VERBOSE
|
||||
// printf("read %d \n", nreceived);
|
||||
//#endif
|
||||
if(!nreceived) break;
|
||||
// if(nreceived<0) break;
|
||||
if(!nreceived){
|
||||
if(!total_received) {
|
||||
return -1; //to handle it
|
||||
}
|
||||
break;
|
||||
}
|
||||
length-=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)
|
||||
strcpy(thisClientIP,dummyClientIP);
|
||||
|
||||
//if (strcmp(lastClientIP,"none")==0)
|
||||
//strcpy(lastClientIP,thisClientIP);
|
||||
|
||||
if (strcmp(lastClientIP,thisClientIP))
|
||||
differentClients=1;
|
||||
else
|
||||
|
||||
@@ -19,11 +19,12 @@ using namespace std;
|
||||
|
||||
/** Error flags */
|
||||
/*Assumption: Only upto 63 detectors */
|
||||
#define CRITICAL_ERROR_MASK 0xFFFFFFFF
|
||||
|
||||
#define MULTI_DETECTORS_NOT_ADDED 0x8000000000000000ULL
|
||||
|
||||
#define CRITICAL_ERROR_MASK 0xFFFFFFF
|
||||
|
||||
// 0xFFFFFFF000000000ULL
|
||||
#define CANNOT_CONNECT_TO_DETECTOR 0x4000000000000000ULL
|
||||
#define CANNOT_CONNECT_TO_RECEIVER 0x2000000000000000ULL
|
||||
#define COULDNOT_SET_CONTROL_PORT 0x1000000000000000ULL
|
||||
@@ -40,10 +41,12 @@ using namespace std;
|
||||
#define COULD_NOT_CONFIGURE_MAC 0x0002000000000000ULL
|
||||
#define COULDNOT_START_RECEIVER 0x0001000000000000ULL // default error like starting threads
|
||||
#define COULDNOT_STOP_RECEIVER 0x0000800000000000ULL
|
||||
#define RECEIVER_DET_POSID_NOT_SET 0x0000400000000000ULL
|
||||
#define RECEIVER_MULTI_DET_SIZE_NOT_SET 0x0000200000000000ULL
|
||||
|
||||
// 0xFFFFFFFF00000000ULL
|
||||
|
||||
// 0xFFFFFFF000000000ULL
|
||||
|
||||
// 0x0000000FFFFFFFFFULL
|
||||
#define COULDNOT_SET_NETWORK_PARAMETER 0x0000000000000001ULL
|
||||
#define COULDNOT_SET_ROI 0x0000000000000002ULL
|
||||
#define RECEIVER_READ_FREQUENCY 0x0000000000000004ULL
|
||||
@@ -74,8 +77,10 @@ using namespace std;
|
||||
#define RECEIVER_READ_TIMER 0x0000000008000000ULL
|
||||
#define RECEIVER_ACQ_TIME_NOT_SET 0x0000000010000000ULL
|
||||
#define RECEIVER_FLIPPED_DATA_NOT_SET 0x0000000020000000ULL
|
||||
#define THRESHOLD_NOT_SET 0x0000000040000000ULL
|
||||
#define RECEIVER_FILE_FORMAT 0x0000000080000000ULL
|
||||
// 0x0000000FFFFFFFFFULL
|
||||
|
||||
// 0x00000000FFFFFFFFULL
|
||||
/** @short class returning all error messages for error mask */
|
||||
class errorDefs {
|
||||
|
||||
@@ -134,6 +139,12 @@ public:
|
||||
if(slsErrorMask&DETECTOR_ACTIVATE)
|
||||
retval.append("Could not activate/deactivate detector\n");
|
||||
|
||||
if(slsErrorMask&RECEIVER_DET_POSID_NOT_SET)
|
||||
retval.append("Could not set detector position id\n");
|
||||
|
||||
if(slsErrorMask&RECEIVER_MULTI_DET_SIZE_NOT_SET)
|
||||
retval.append("Could not set multi detector size\n");
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -234,6 +245,13 @@ public:
|
||||
if(slsErrorMask&RECEIVER_FLIPPED_DATA_NOT_SET)
|
||||
retval.append("Could not set receiver flipped data/bottom\n");
|
||||
|
||||
if(slsErrorMask&THRESHOLD_NOT_SET)
|
||||
retval.append("Could not set threshold\n");
|
||||
|
||||
if(slsErrorMask&RECEIVER_FILE_FORMAT)
|
||||
retval.append("Could not set receiver file format\n");
|
||||
|
||||
|
||||
//------------------------------------------------------ length of message
|
||||
|
||||
|
||||
|
||||
@@ -19,9 +19,6 @@
|
||||
/** header length for data :gotthard*/
|
||||
#define HEADERLENGTH 12
|
||||
|
||||
#define DEFAULT_SUBFRAME_EXPOSURE_VAL 2621440 /** default value for sub frame value 2.6ms*/
|
||||
#define MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS 0x1FFFFFFF /** 29 bit register for max subframe exposure value */
|
||||
|
||||
/** maximum rois */
|
||||
#define MAX_ROIS 100
|
||||
|
||||
@@ -129,7 +126,7 @@ class slsDetectorDefs: public virtual slsReceiverDefs{
|
||||
typedef struct {
|
||||
int module; /**< is the module number */
|
||||
int serialnumber; /**< is the module serial number */
|
||||
int nchan; /**< is the number of channels per chip */
|
||||
int nchan; /**< is the number of channels on the module*/
|
||||
int nchip; /**< is the number of chips on the module */
|
||||
int ndac; /**< is the number of dacs on the module */
|
||||
int nadc; /**< is the number of adcs on the module */
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#ifndef SLS_DETECTOR_FUNCS_H
|
||||
#define SLS_DETECTOR_FUNCS_H
|
||||
|
||||
enum {
|
||||
enum detFuncs{
|
||||
|
||||
// General purpose functions
|
||||
F_EXEC_COMMAND=0, /**< command is executed */
|
||||
@@ -109,10 +109,14 @@ enum {
|
||||
F_PROGRAM_FPGA, /**< program FPGA */
|
||||
F_RESET_FPGA, /**< reset FPGA */
|
||||
F_POWER_CHIP, /**< power chip */
|
||||
F_ACTIVATE, /** < activate */
|
||||
F_PREPARE_ACQUISITION, /** < prepare acquisition */
|
||||
F_CLEANUP_ACQUISITION, /** < clean up after acquisition */
|
||||
/* Always append functions hereafter!!! */
|
||||
|
||||
/* 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
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -180,24 +180,31 @@ void Beb_GetModuleConfiguration(int* master, int* top, int* normal){
|
||||
void Beb_EndofDataSend(int tengiga){
|
||||
//mapping new memory
|
||||
u_int32_t* csp0base=0;
|
||||
int l_framepktcounter2, l_txndelaycounter, l_framedelaycounter, r_framepktcounter2, r_txndelaycounter, r_framedelaycounter;
|
||||
int l_framepktcounter2_new, l_txndelaycounter_new, l_framedelaycounter_new, r_framepktcounter2_new, r_txndelaycounter_new, r_framedelaycounter_new;
|
||||
int addr_l_framepktcounter2, addr_l_txndelaycounter, addr_l_framedelaycounter, addr_r_framepktcounter2, addr_r_txndelaycounter, addr_r_framedelaycounter;
|
||||
int l_framepktLsbcounter, l_framepktMsbcounter, l_txndelaycounter, l_framedelaycounter;
|
||||
int r_framepktLsbcounter, r_framepktMsbcounter, r_txndelaycounter, r_framedelaycounter;
|
||||
int l_framepktLsbcounter_new, l_framepktMsbcounter_new, l_txndelaycounter_new, l_framedelaycounter_new;
|
||||
int r_framepktLsbcounter_new, r_framepktMsbcounter_new, r_txndelaycounter_new, r_framedelaycounter_new;
|
||||
int addr_l_framepktLsbcounter, addr_l_framepktMsbcounter, addr_l_txndelaycounter, addr_l_framedelaycounter;
|
||||
int addr_r_framepktLsbcounter, addr_r_framepktMsbcounter, addr_r_txndelaycounter, addr_r_framedelaycounter;
|
||||
|
||||
switch(tengiga){
|
||||
case 0:
|
||||
addr_l_framepktcounter2 = ONE_GIGA_LEFT_PKT_SEND_COUNTER;
|
||||
addr_l_framepktLsbcounter = ONE_GIGA_LEFT_INDEX_LSB_COUNTER;
|
||||
addr_l_framepktMsbcounter = ONE_GIGA_LEFT_INDEX_MSB_COUNTER;
|
||||
addr_l_txndelaycounter = ONE_GIGA_LEFT_TXN_DELAY_COUNTER;
|
||||
addr_l_framedelaycounter = ONE_GIGA_LEFT_FRAME_DELAY_COUNTER;
|
||||
addr_r_framepktcounter2 = ONE_GIGA_RIGHT_PKT_SEND_COUNTER;
|
||||
addr_r_framepktLsbcounter = ONE_GIGA_RIGHT_INDEX_LSB_COUNTER;
|
||||
addr_r_framepktMsbcounter = ONE_GIGA_RIGHT_INDEX_MSB_COUNTER;
|
||||
addr_r_txndelaycounter = ONE_GIGA_RIGHT_TXN_DELAY_COUNTER;
|
||||
addr_r_framedelaycounter = ONE_GIGA_RIGHT_FRAME_DELAY_COUNTER;
|
||||
break;
|
||||
case 1:
|
||||
addr_l_framepktcounter2 = TEN_GIGA_LEFT_PKT_SEND_COUNTER;
|
||||
addr_l_framepktLsbcounter = TEN_GIGA_LEFT_INDEX_LSB_COUNTER;
|
||||
addr_l_framepktMsbcounter = TEN_GIGA_LEFT_INDEX_MSB_COUNTER;
|
||||
addr_l_txndelaycounter = TEN_GIGA_LEFT_TXN_DELAY_COUNTER;
|
||||
addr_l_framedelaycounter = TEN_GIGA_LEFT_FRAME_DELAY_COUNTER;
|
||||
addr_r_framepktcounter2 = TEN_GIGA_RIGHT_PKT_SEND_COUNTER;
|
||||
addr_r_framepktLsbcounter = TEN_GIGA_RIGHT_INDEX_LSB_COUNTER;
|
||||
addr_r_framepktMsbcounter = TEN_GIGA_RIGHT_INDEX_MSB_COUNTER;
|
||||
addr_r_txndelaycounter = TEN_GIGA_RIGHT_TXN_DELAY_COUNTER;
|
||||
addr_r_framedelaycounter = TEN_GIGA_RIGHT_FRAME_DELAY_COUNTER;
|
||||
break;
|
||||
@@ -211,23 +218,27 @@ void Beb_EndofDataSend(int tengiga){
|
||||
return;
|
||||
}else{
|
||||
//read data first time
|
||||
l_framepktcounter2 = Beb_Read32(csp0base, addr_l_framepktcounter2);
|
||||
l_framepktLsbcounter = Beb_Read32(csp0base, addr_l_framepktLsbcounter);
|
||||
l_framepktMsbcounter = Beb_Read32(csp0base, addr_l_framepktMsbcounter);
|
||||
l_txndelaycounter = Beb_Read32(csp0base, addr_l_txndelaycounter);
|
||||
l_framedelaycounter = Beb_Read32(csp0base, addr_l_framedelaycounter);
|
||||
r_framepktcounter2 = Beb_Read32(csp0base, addr_r_framepktcounter2);
|
||||
r_framepktLsbcounter = Beb_Read32(csp0base, addr_r_framepktLsbcounter);
|
||||
r_framepktMsbcounter = Beb_Read32(csp0base, addr_r_framepktMsbcounter);
|
||||
r_txndelaycounter = Beb_Read32(csp0base, addr_r_txndelaycounter);
|
||||
r_framedelaycounter = Beb_Read32(csp0base, addr_r_framedelaycounter);
|
||||
//#ifdef VERBOSE
|
||||
printf("\nLeft\n"
|
||||
"Framepacketcounter: %d\n"
|
||||
"FramepacketLsbcounter: %d\n"
|
||||
"FramepacketMsbcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
"Framedelaycounter:%d\n"
|
||||
"\nRight\n"
|
||||
"Framepacketcounter: %d\n"
|
||||
"FramepacketLsbcounter: %d\n"
|
||||
"FramepacketMsbcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
"Framedelaycounter:%d\n\n",
|
||||
l_framepktcounter2,l_txndelaycounter,l_framedelaycounter,
|
||||
r_framepktcounter2,r_txndelaycounter,r_framedelaycounter);
|
||||
l_framepktLsbcounter,l_framepktMsbcounter,l_txndelaycounter,l_framedelaycounter,
|
||||
r_framepktLsbcounter,r_framepktMsbcounter,r_txndelaycounter,r_framedelaycounter);
|
||||
//#endif
|
||||
|
||||
//keep comparing with previous values
|
||||
@@ -239,33 +250,42 @@ void Beb_EndofDataSend(int tengiga){
|
||||
usleep(maxtimer);
|
||||
|
||||
//read new values
|
||||
l_framepktcounter2_new = Beb_Read32(csp0base, addr_l_framepktcounter2);
|
||||
l_framepktLsbcounter_new = Beb_Read32(csp0base, addr_l_framepktLsbcounter);
|
||||
l_framepktMsbcounter_new = Beb_Read32(csp0base, addr_l_framepktMsbcounter);
|
||||
l_txndelaycounter_new = Beb_Read32(csp0base, addr_l_txndelaycounter);
|
||||
l_framedelaycounter_new = Beb_Read32(csp0base, addr_l_framedelaycounter);
|
||||
r_framepktcounter2_new = Beb_Read32(csp0base, addr_r_framepktcounter2);
|
||||
r_framepktLsbcounter_new = Beb_Read32(csp0base, addr_r_framepktLsbcounter);
|
||||
r_framepktMsbcounter_new = Beb_Read32(csp0base, addr_r_framepktMsbcounter);
|
||||
r_txndelaycounter_new = Beb_Read32(csp0base, addr_r_txndelaycounter);
|
||||
r_framedelaycounter_new = Beb_Read32(csp0base, addr_r_framedelaycounter);
|
||||
//#ifdef VERBOSE
|
||||
printf("\nLeft\n"
|
||||
"Framepacketcounter: %d\n"
|
||||
"FramepacketLsbcounter: %d\n"
|
||||
"FramepacketMsbcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
"Framedelaycounter:%d\n"
|
||||
"\nRight\n"
|
||||
"Framepacketcounter: %d\n"
|
||||
"FramepacketLsbcounter: %d\n"
|
||||
"FramepacketMsbcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
"Framedelaycounter:%d\n\n",
|
||||
l_framepktcounter2_new,l_txndelaycounter_new,l_framedelaycounter_new,
|
||||
r_framepktcounter2_new,r_txndelaycounter_new,r_framedelaycounter_new);
|
||||
l_framepktLsbcounter_new,l_framepktMsbcounter_new,l_txndelaycounter_new,l_framedelaycounter_new,
|
||||
r_framepktLsbcounter_new,r_framepktMsbcounter_new,r_txndelaycounter_new,r_framedelaycounter_new);
|
||||
//#endif
|
||||
|
||||
if ((l_framepktcounter2 == l_framepktcounter2_new) && (r_framepktcounter2 == r_framepktcounter2_new))
|
||||
if ((l_framepktLsbcounter == l_framepktLsbcounter_new) &&
|
||||
(l_framepktMsbcounter == l_framepktMsbcounter_new) &&
|
||||
(r_framepktLsbcounter == r_framepktLsbcounter_new) &&
|
||||
(r_framepktMsbcounter == r_framepktMsbcounter_new))
|
||||
break;
|
||||
|
||||
//update old values
|
||||
l_framepktcounter2 = l_framepktcounter2_new;
|
||||
l_framepktLsbcounter = l_framepktLsbcounter_new;
|
||||
l_framepktMsbcounter = l_framepktMsbcounter_new;
|
||||
l_txndelaycounter = l_txndelaycounter_new;
|
||||
l_framedelaycounter = l_framedelaycounter_new;
|
||||
r_framepktcounter2 = r_framepktcounter2_new;
|
||||
r_framepktLsbcounter = r_framepktLsbcounter_new;
|
||||
r_framepktMsbcounter = r_framepktMsbcounter_new;
|
||||
r_txndelaycounter = r_txndelaycounter_new;
|
||||
r_framedelaycounter = r_framedelaycounter_new;
|
||||
|
||||
@@ -392,7 +412,7 @@ int Beb_Activate(int enable){
|
||||
}
|
||||
|
||||
|
||||
int Beb_SetNetworkParameter(enum detNetworkParameter mode, int val){
|
||||
int Beb_SetNetworkParameter(enum NETWORKINDEX mode, int val){
|
||||
|
||||
if(!Beb_activated)
|
||||
return val;
|
||||
|
||||
@@ -1,470 +0,0 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
|
||||
//return reversed 1 means good, 0 means failed
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
|
||||
#include "xfs_types.h"
|
||||
#include "xparameters.h"
|
||||
|
||||
#include "Beb.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
BebInfo::BebInfo(unsigned int beb_num){beb_number=beb_num;serial_address=0;src_mac_1GbE="";src_mac_10GbE="";src_ip_1GbE="";src_ip_10GbE=""; src_port_1GbE=src_port_10GbE=0;}
|
||||
bool BebInfo::SetHeaderInfo(bool ten_gig, string src_mac, string src_ip, unsigned int src_port){
|
||||
if(ten_gig){ src_mac_10GbE = src_mac; src_ip_10GbE = src_ip; src_port_10GbE = src_port;}
|
||||
else { src_mac_1GbE = src_mac; src_ip_1GbE = src_ip; src_port_1GbE = src_port;}
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool BebInfo::SetSerialAddress(unsigned int a){
|
||||
//address pre shifted
|
||||
if(a>0xff) return 0;
|
||||
serial_address = 0x04000000 | ((a&0xff)<<16);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void BebInfo::Print(){
|
||||
cout<<"\t"<<beb_number<<") Beb Info.:"<<endl;
|
||||
cout<<"\t\tSerial Add: 0x"<<hex<<serial_address<<dec<<endl;
|
||||
cout<<"\t\tMAC 1GbE: "<<src_mac_1GbE.c_str()<<endl;
|
||||
cout<<"\t\tIP 1GbE: "<<src_ip_1GbE.c_str()<<endl;
|
||||
cout<<"\t\tport 1GbE: "<<src_port_1GbE<<endl;
|
||||
cout<<"\t\tMAC 10GbE: "<<src_mac_10GbE.c_str()<<endl;
|
||||
cout<<"\t\tIP 10GbE: "<<src_ip_10GbE.c_str()<<endl;
|
||||
cout<<"\t\tport 10GbE: "<<src_port_10GbE<<endl;
|
||||
}
|
||||
|
||||
|
||||
Beb::Beb(int arg1){
|
||||
|
||||
send_ndata = 0;
|
||||
send_buffer_size = 1026;
|
||||
send_data_raw = new unsigned int [send_buffer_size+1];
|
||||
send_data = &send_data_raw[1];
|
||||
|
||||
recv_ndata = 0;
|
||||
recv_buffer_size = 1026;
|
||||
recv_data_raw = new unsigned int [recv_buffer_size+1];
|
||||
recv_data = &recv_data_raw[1];
|
||||
|
||||
if(!InitBebInfos()) exit(1);
|
||||
|
||||
cout<<"Printing Beb infos:"<<endl;
|
||||
for(unsigned int i=1;i<beb_infos.size();i++) beb_infos[i]->Print();
|
||||
cout<<endl<<endl;
|
||||
|
||||
bit_mode = 4;
|
||||
|
||||
ll = new LocalLinkInterface(XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR);
|
||||
|
||||
SetByteOrder();
|
||||
|
||||
|
||||
new_memory = new LocalLinkInterface();
|
||||
if(!new_memory->InitNewMemory(XPAR_PLB_LL_NEW_MEMORY, arg1))
|
||||
printf("New Memory FAIL\n");
|
||||
else
|
||||
printf("New Memory OK\n");
|
||||
|
||||
}
|
||||
|
||||
Beb::~Beb(){
|
||||
delete ll;
|
||||
delete [] send_data_raw;
|
||||
delete [] recv_data_raw;
|
||||
}
|
||||
|
||||
void Beb::ClearBebInfos(){
|
||||
for(unsigned int i=0;i<beb_infos.size();i++) delete beb_infos[i];
|
||||
beb_infos.clear();
|
||||
}
|
||||
|
||||
bool Beb::InitBebInfos(){//file name at some point
|
||||
ClearBebInfos();
|
||||
|
||||
BebInfo* b0 = new BebInfo(0);
|
||||
if(b0->SetSerialAddress(0xff)) beb_infos.push_back(b0); //all bebs for reset and possibly get request data?
|
||||
|
||||
if(!ReadSetUpFromFile("/home/root/executables/setup_beb.txt")) return 0;
|
||||
/*
|
||||
//loop through file to fill vector.
|
||||
BebInfo* b = new BebInfo(26);
|
||||
b->SetSerialAddress(0); //0xc4000000
|
||||
b->SetHeaderInfo(0,"00:50:c2:46:d9:34","129.129.205.78",42000 + 26); // 1 GbE, ip address can be acquire from the network "arp"
|
||||
b->SetHeaderInfo(1,"00:50:c2:46:d9:35","10.0.26.1",52000 + 26); //10 GbE, everything calculable/setable
|
||||
beb_infos.push_back(b);
|
||||
*/
|
||||
|
||||
return CheckSourceStuffBebInfo();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Beb::SetBebSrcHeaderInfos(unsigned int beb_number, bool ten_gig, string src_mac, string src_ip,unsigned int src_port){
|
||||
//so that the values can be reset externally for now....
|
||||
|
||||
unsigned int i = GetBebInfoIndex(beb_number);
|
||||
if(!i) return 0; //i must be greater than 0, zero is the global send
|
||||
beb_infos[i]->SetHeaderInfo(ten_gig,src_mac,src_ip,src_port);
|
||||
|
||||
cout<<"Printing Beb info number ("<<i<<") :"<<endl;
|
||||
beb_infos[i]->Print();
|
||||
cout<<endl<<endl;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
bool Beb::ReadSetUpFromFile(string file_name){
|
||||
|
||||
static ifstream infile;
|
||||
static string line;
|
||||
static char cmd_st[2000],str_mac1[200],str_ip1[200],str_mac10[200],str_ip10[200];
|
||||
static int value_i[2];
|
||||
|
||||
infile.open(file_name.c_str(),ios::in);
|
||||
if(!infile.is_open()){
|
||||
cout<<"Error could not open setup file: "<<file_name<<"."<<endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
cout<<endl;
|
||||
cout<<"Setting up detector:"<<endl;
|
||||
while(std::getline(infile,line)){
|
||||
if(line.length()<1) continue;
|
||||
istringstream iss(line);
|
||||
iss>>cmd_st;
|
||||
if(!strcmp("add_beb",cmd_st)){
|
||||
if(!(iss>>value_i[0]>>value_i[1]>>str_mac1>>str_ip1>>str_mac10>>str_ip10)){
|
||||
cout<<"Error adding beb from "<<file_name<<"."<<endl;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if(GetBebInfoIndex(value_i[0])){
|
||||
cout<<"Error adding beb from "<<file_name<<", beb number "<<value_i[0]<<" already added."<<endl;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
BebInfo* b = new BebInfo(value_i[0]);
|
||||
b->SetSerialAddress(value_i[1]);
|
||||
b->SetHeaderInfo(0,str_mac1,str_ip1,42000+value_i[0]);
|
||||
b->SetHeaderInfo(1,str_mac10,str_ip10,52000+value_i[0]);
|
||||
beb_infos.push_back(b);
|
||||
}
|
||||
}
|
||||
|
||||
infile.close();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Beb::CheckSourceStuffBebInfo(){
|
||||
for(unsigned int i=1;i<beb_infos.size();i++){ //header stuff always starts from 1
|
||||
if(!SetHeaderData(beb_infos[i]->GetBebNumber(),0,"00:00:00:00:00:00","10.0.0.1",20000)||!SetHeaderData(beb_infos[i]->GetBebNumber(),1,"00:00:00:00:00:00","10.0.0.1",20000)){
|
||||
cout<<"Error in BebInfo for module number "<<beb_infos[i]->GetBebNumber()<<"."<<endl;
|
||||
beb_infos[i]->Print();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned int Beb::GetBebInfoIndex(unsigned int beb_numb){
|
||||
if(!beb_numb) return 0;
|
||||
|
||||
for(unsigned int i=1;i<beb_infos.size();i++) if(beb_numb==beb_infos[i]->GetBebNumber()) return i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Beb::WriteTo(unsigned int index){
|
||||
if(index>=beb_infos.size()){
|
||||
cout<<"WriteTo index error."<<endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
send_data_raw[0] = 0x90000000 | beb_infos[index]->GetSerialAddress();
|
||||
if(ll->Write(4,send_data_raw)!=4) return 0;
|
||||
|
||||
send_data_raw[0] = 0xc0000000;
|
||||
if((send_ndata+1)*4!=ll->Write((send_ndata+1)*4,send_data_raw)) return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void Beb::SwapDataFun(bool little_endian, unsigned int n, unsigned int *d){
|
||||
if(little_endian) for(unsigned int i=0;i<n;i++) d[i] = (((d[i]&0xff)<<24) | ((d[i]&0xff00)<<8) | ((d[i]&0xff0000)>>8) | ((d[i]&0xff000000)>>24)); //little_endian
|
||||
else for(unsigned int i=0;i<n;i++) d[i] = (((d[i]&0xffff)<<16) | ((d[i]&0xffff0000)>>16));
|
||||
}
|
||||
|
||||
|
||||
bool Beb::SetByteOrder(){
|
||||
send_data_raw[0] = 0x8fff0000;
|
||||
if(ll->Write(4,send_data_raw)!=4) return 0;
|
||||
|
||||
while((ll->Read(recv_buffer_size*4,recv_data_raw)/4)>0) cout<<"\t) Cleanning buffer ..."<<endl;
|
||||
|
||||
if(beb_infos.size()<2) return 0;
|
||||
|
||||
send_ndata = 3;
|
||||
send_data[0] = 0x000c0000;
|
||||
send_data[1] = 0;
|
||||
send_data[2] = 0;
|
||||
WriteTo(0);
|
||||
|
||||
//using little endian for data, big endian not fully tested, swap on 16 bit boundary.
|
||||
send_ndata = 3;
|
||||
send_data[0] = 0x000c0000;
|
||||
send_data[1] = 1;
|
||||
send_data[2] = 0;
|
||||
SwapDataFun(0,2,&(send_data[1]));
|
||||
WriteTo(0);
|
||||
|
||||
cout<<"\tSetting Byte Order .............. ok"<<endl<<endl;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool Beb::SetUpUDPHeader(unsigned int beb_number, bool ten_gig, unsigned int header_number, string dst_mac, string dst_ip, unsigned int dst_port){
|
||||
unsigned int i = GetBebInfoIndex(beb_number);
|
||||
if(!i) return 0; //i must be greater than 0, zero is the global send
|
||||
|
||||
send_ndata = 14;
|
||||
send_data[0] = ten_gig ? 0x00020000 : 0x00010000; //write to fanout numbers 1 or 2
|
||||
send_data[1] = ((header_number*8)<<16);
|
||||
if(!SetHeaderData(beb_number,ten_gig,dst_mac,dst_ip,dst_port)) return 0;
|
||||
|
||||
SwapDataFun(1,12,&(send_data[2]));
|
||||
|
||||
if(!WriteTo(i)) return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
bool Beb::SetHeaderData(unsigned int beb_number, bool ten_gig, string dst_mac, string dst_ip, unsigned int dst_port){
|
||||
unsigned int i = GetBebInfoIndex(beb_number);
|
||||
if(!i) return 0; //i must be greater than 0, zero is the global send
|
||||
return SetHeaderData(beb_infos[i]->GetSrcMAC(ten_gig),beb_infos[i]->GetSrcIP(ten_gig),beb_infos[i]->GetSrcPort(ten_gig),dst_mac,dst_ip,dst_port);
|
||||
}
|
||||
|
||||
bool Beb::SetHeaderData(string src_mac, string src_ip, unsigned int src_port, string dst_mac, string dst_ip, unsigned int dst_port){
|
||||
/* example header*/
|
||||
//static unsigned int* word_ptr = new unsigned int [16];
|
||||
static udp_header_type udp_header = {
|
||||
{0x00, 0x50, 0xc5, 0xb2, 0xcb, 0x46}, // DST MAC
|
||||
{0x00, 0x50, 0xc2, 0x46, 0xd9, 0x02}, // SRC MAC
|
||||
{0x08, 0x00},
|
||||
{0x45},
|
||||
{0x00},
|
||||
{0x00, 0x00},
|
||||
{0x00, 0x00},
|
||||
{0x40},
|
||||
{0x00},
|
||||
{0xff},
|
||||
{0x11},
|
||||
{0x00, 0x00},
|
||||
{129, 205, 205, 128}, // Src IP
|
||||
{129, 205, 205, 122}, // Dst IP
|
||||
{0x0f, 0xa1},
|
||||
{0x13, 0x89},
|
||||
{0x00, 0x00}, //{0x00, 0x11},
|
||||
{0x00, 0x00}
|
||||
};
|
||||
|
||||
if(!SetMAC(src_mac,&(udp_header.src_mac[0]))) return 0;
|
||||
if(!SetIP(src_ip,&(udp_header.src_ip[0]))) return 0;
|
||||
if(!SetPortNumber(src_port,&(udp_header.src_port[0]))) return 0;
|
||||
|
||||
if(!SetMAC(dst_mac,&(udp_header.dst_mac[0]))) return 0;
|
||||
if(!SetIP(dst_ip,&(udp_header.dst_ip[0]))) return 0;
|
||||
if(!SetPortNumber(dst_port,&(udp_header.dst_port[0]))) return 0;
|
||||
|
||||
|
||||
AdjustIPChecksum(&udp_header);
|
||||
|
||||
unsigned int* base_ptr = (unsigned int *) &udp_header;
|
||||
unsigned int num_words = ( sizeof(udp_header_type) + 3 ) / 4;
|
||||
// for(unsigned int i=0; i<num_words; i++) word_ptr[i] = base_ptr[i];
|
||||
// for(unsigned int i=num_words; i<16; i++) word_ptr[i] = 0;
|
||||
// return word_ptr;
|
||||
|
||||
for(unsigned int i=0; i<num_words; i++) send_data[i+2] = base_ptr[i];
|
||||
for(unsigned int i=num_words; i<16; i++) send_data[i+2] = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
bool Beb::SetMAC(string mac, unsigned char* dst_ptr){
|
||||
for(int i=0;i<6;i++){
|
||||
size_t p0=mac.find(':');
|
||||
if((i!=5&&p0!=2)||(i==5&&mac.length()!=2)){
|
||||
cout<<"Error: in mac address -> "<<mac<<endl;
|
||||
return 0;
|
||||
}
|
||||
dst_ptr[i] = (unsigned char) strtoul(mac.substr(0,p0).c_str(),NULL,16);
|
||||
mac=mac.substr(p0+1);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool Beb::SetIP(string ip, unsigned char* dst_ptr){
|
||||
for(int i=0;i<4;i++){
|
||||
size_t p0=ip.find('.');
|
||||
if((i!=3&&(p0<1||p0>3))||(i==3&&(ip.length()<1||ip.length()>3))){
|
||||
cout<<"Error: in ip address -> "<<ip<<endl;
|
||||
return 0;
|
||||
}
|
||||
dst_ptr[i] = atoi(ip.substr(0,p0).c_str());
|
||||
ip=ip.substr(p0+1);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool Beb::SetPortNumber(unsigned int port_number, unsigned char* dst_ptr){
|
||||
dst_ptr[0] = (port_number >> 8) & 0xff ;
|
||||
dst_ptr[1] = port_number & 0xff;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void Beb::AdjustIPChecksum(udp_header_type *ip){
|
||||
unsigned char *cptr = (unsigned char *) ip->ver_headerlen;
|
||||
|
||||
ip->ip_header_checksum[0] = 0;
|
||||
ip->ip_header_checksum[1] = 0;
|
||||
ip->total_length[0] = 0;
|
||||
ip->total_length[1] = 28; // IP + UDP Header Length
|
||||
|
||||
// calc ip checksum
|
||||
unsigned int ip_checksum = 0;
|
||||
for(unsigned int i=0; i<10; i++){
|
||||
ip_checksum += ( (cptr[2*i] << 8) + (cptr[2*i + 1]) );
|
||||
if (ip_checksum & 0x00010000) ip_checksum = (ip_checksum + 1) & 0x0000ffff;
|
||||
}
|
||||
|
||||
ip->ip_header_checksum[0] = (ip_checksum >> 8) & 0xff ;
|
||||
ip->ip_header_checksum[1] = ip_checksum & 0xff ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Beb::SendMultiReadRequest(unsigned int beb_number, unsigned int left_right, bool ten_gig, unsigned int dst_number, unsigned int npackets, unsigned int packet_size, bool stop_read_when_fifo_empty){
|
||||
|
||||
unsigned int i = GetBebInfoIndex(beb_number); //zero is the global send
|
||||
|
||||
send_ndata = 3;
|
||||
if(left_right == 1) send_data[0] = 0x00040000;
|
||||
else if(left_right == 2) send_data[0] = 0x00080000;
|
||||
else if(left_right == 3) send_data[0] = 0x000c0000;
|
||||
else return 0;
|
||||
|
||||
//packet_size/=2;
|
||||
if(dst_number>0x3f) return 0;
|
||||
if(packet_size>0x3ff) return 0;
|
||||
if(npackets==0||npackets>0x100) return 0;
|
||||
npackets--;
|
||||
|
||||
|
||||
send_data[1] = 0x62000000 | (!stop_read_when_fifo_empty) << 27 | (ten_gig==1) << 24 | packet_size << 14 | dst_number << 8 | npackets;
|
||||
send_data[2] = 0;
|
||||
|
||||
SwapDataFun(0,2,&(send_data[1]));
|
||||
|
||||
if(!WriteTo(i)) return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
bool Beb::SetUpTransferParameters(short the_bit_mode){
|
||||
if(the_bit_mode!=4&&the_bit_mode!=8&&the_bit_mode!=16&&the_bit_mode!=32) return 0;
|
||||
bit_mode = the_bit_mode;
|
||||
|
||||
//nimages = the_number_of_images;
|
||||
// on_dst = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool Beb::RequestNImages(unsigned int beb_number, unsigned int left_right, bool ten_gig, unsigned int dst_number, unsigned int nimages, bool test_just_send_out_packets_no_wait){
|
||||
if(dst_number>64) return 0;
|
||||
|
||||
unsigned int header_size = 4; //4*64 bits
|
||||
unsigned int packet_size = ten_gig ? 0x200 : 0x80; // 4k or 1k packets
|
||||
unsigned int npackets = ten_gig ? bit_mode*4 : bit_mode*16;
|
||||
bool in_two_requests = (!ten_gig&&bit_mode==32);
|
||||
if(in_two_requests) npackets/=2;
|
||||
|
||||
//cout<<"here: "<<beb_number<<","<<left_right<<","<<ten_gig<<","<<dst_number<<","<<1<<","<<header_size<<","<<test_just_send_out_packets_no_wait<<endl;
|
||||
|
||||
for(unsigned int i=0;i<nimages;i++){
|
||||
//header then data request
|
||||
if(!SendMultiReadRequest(beb_number,left_right,ten_gig,dst_number,1,header_size,test_just_send_out_packets_no_wait) ||
|
||||
!SendMultiReadRequest(beb_number,left_right,ten_gig,dst_number,npackets,packet_size,test_just_send_out_packets_no_wait) ||
|
||||
(in_two_requests&&!SendMultiReadRequest(beb_number,left_right,ten_gig,dst_number,npackets,packet_size,test_just_send_out_packets_no_wait))) return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
bool Beb::Test(unsigned int beb_number){
|
||||
cout<<"Testing module number: "<<beb_number<<endl;
|
||||
|
||||
|
||||
//bool Beb::SetUpUDPHeader(unsigned int beb_number, bool ten_gig, unsigned int header_number, string dst_mac, string dst_ip, unsigned int dst_port){
|
||||
//SetUpUDPHeader(26,0,0,"60:fb:42:f4:e3:d2","129.129.205.186",22000);
|
||||
|
||||
unsigned int index = GetBebInfoIndex(beb_number);
|
||||
if(!index){
|
||||
cout<<"Error beb number ("<<beb_number<<")not in list????"<<endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
for(unsigned int i=0;i<64;i++){
|
||||
if(!SetUpUDPHeader(beb_number,0,i,"60:fb:42:f4:e3:d2","129.129.205.186",22000+i)){
|
||||
cout<<"Error setting up header table...."<<endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// SendMultiReadRequest(unsigned int beb_number, unsigned int left_right, bool ten_gig, unsigned int dst_number, unsigned int npackets, unsigned int packet_size, bool stop_read_when_fifo_empty=1);
|
||||
for(unsigned int i=0;i<64;i++){
|
||||
if(!SendMultiReadRequest(beb_number,i%3+1,0,i,1,0)){
|
||||
cout<<"Error requesting data...."<<endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ struct BebInfo{
|
||||
int Beb_SetMasterViaSoftware();
|
||||
int Beb_SetSlaveViaSoftware();
|
||||
int Beb_Activate(int enable);
|
||||
int Beb_SetNetworkParameter(enum detNetworkParameter mode, int val);
|
||||
int Beb_SetNetworkParameter(enum NETWORKINDEX mode, int val);
|
||||
int Beb_ResetToHardwareSettings();
|
||||
u_int32_t Beb_GetFirmwareRevision();
|
||||
u_int32_t Beb_GetFirmwareSoftwareAPIVersion();
|
||||
|
||||
@@ -1,388 +0,0 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <algorithm> // std::remove_if
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "Beb.h"
|
||||
#include "slsDetectorServer_defs.h" //include port number
|
||||
|
||||
using namespace std;
|
||||
|
||||
enum cmd_string {evNotFound,
|
||||
evRequestImages,evTestRequest,
|
||||
evSetBitMode,
|
||||
evSetupTableEntry,evSetDstParameters,
|
||||
evTest,evTestSend,
|
||||
evExitServer};
|
||||
|
||||
map<string, cmd_string> enum_map;
|
||||
|
||||
void init(){
|
||||
|
||||
enum_map["requestimages"] = evRequestImages; //<dst>
|
||||
enum_map["testrequest"] = evTestRequest; //<dst>
|
||||
|
||||
enum_map["setbitmode"] = evSetBitMode; // (resets on_dst and dst_requested)
|
||||
|
||||
enum_map["setuptableentry"] = evSetupTableEntry;
|
||||
enum_map["setdstparameters"] = evSetDstParameters; //<one_ten> <ndsts> <nimages_per_request> (resets on_dst and dst_requested)
|
||||
|
||||
enum_map["test"] = evTest;
|
||||
enum_map["testsend"] = evTestSend;
|
||||
enum_map["exitserver"] = evExitServer;
|
||||
|
||||
}
|
||||
|
||||
int server_list_s;
|
||||
int server_conn_s;
|
||||
int AccpetConnectionAndWaitForData(char* buffer, int maxlength);
|
||||
bool WriteNClose(const char* buffer, int length);
|
||||
bool SetupListenSocket(unsigned short int port);
|
||||
|
||||
|
||||
string LowerCase(string str);
|
||||
string GetNextString(string str,bool start_from_beginning=0);
|
||||
void AddNumber(string& str, int n, int location=-1);//-1 means append
|
||||
|
||||
int main(int argc, char* argv[]){
|
||||
cout<<endl<<endl;
|
||||
|
||||
/*
|
||||
if(argc<2){
|
||||
cout<<"Usage: eiger_beb_server port_number"<<endl<<endl;
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
init();
|
||||
|
||||
int arg1;
|
||||
Beb *bebs;
|
||||
|
||||
if(argc>1)
|
||||
bebs = new Beb(atoi(argv[1]));
|
||||
else
|
||||
bebs = new Beb(-1);
|
||||
|
||||
// unsigned short int port_number = atoi(argv[1]);
|
||||
|
||||
unsigned short int port_number = BEB_PORT;
|
||||
if(!SetupListenSocket(port_number)) return 1;
|
||||
|
||||
|
||||
int length=1000;
|
||||
char data[1000];
|
||||
|
||||
int stop = 0;
|
||||
time_t rawtime;
|
||||
struct tm *timeinfo;
|
||||
|
||||
bool send_to_ten_gig = 0;
|
||||
int ndsts_in_use=32;
|
||||
unsigned int nimages_per_request=1;
|
||||
|
||||
int on_dst=0;
|
||||
bool dst_requested[32] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
|
||||
while(!stop){
|
||||
|
||||
cout<<endl<<"\n\n\n\nWaiting for command -> "<<flush;
|
||||
int nread = AccpetConnectionAndWaitForData(data,length);
|
||||
if(nread<=0) return 0;
|
||||
|
||||
time(&rawtime); timeinfo=localtime(&rawtime);
|
||||
cout<<asctime(timeinfo);
|
||||
cout<<" Command received: "<<data<<endl<<endl;
|
||||
|
||||
|
||||
|
||||
string tmp_str[5];
|
||||
//float v1,v2,v3,v4,v5;
|
||||
int n[5];
|
||||
|
||||
string cmd = GetNextString(data,1);
|
||||
//static char retval_st[100];
|
||||
int ret_val = 1;
|
||||
string return_message = " Command recieved: ";
|
||||
return_message.append(data);
|
||||
return_message.append("\n");
|
||||
|
||||
int return_start_pos;
|
||||
while(cmd.length()>0){
|
||||
return_start_pos = return_message.length();
|
||||
|
||||
switch(enum_map.find(LowerCase(cmd))->second){
|
||||
|
||||
case evRequestImages :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
n[0] = atoi(tmp_str[0].data()); //dst number
|
||||
if(tmp_str[0].length()<1||n[0]<0||n[0]>=ndsts_in_use){
|
||||
return_message.append("\tError executing: RequestImages <dst_number> (note dst_number must be less than ndsts_in_use that is set with SetDstParameters\n");
|
||||
ret_val = 1;
|
||||
}else{
|
||||
dst_requested[n[0]] = 1;
|
||||
ret_val=0;
|
||||
tmp_str[1] = " ( ";
|
||||
while(dst_requested[on_dst]){
|
||||
//waits on data
|
||||
if((ret_val = (!bebs->RequestNImages(0,1,send_to_ten_gig,on_dst,nimages_per_request)||!bebs->RequestNImages(0,2,send_to_ten_gig,0x20|on_dst,nimages_per_request)))) break;
|
||||
AddNumber(tmp_str[1],on_dst);tmp_str[1].append(" ");
|
||||
dst_requested[on_dst++]=0;
|
||||
on_dst%=ndsts_in_use;
|
||||
}
|
||||
if(ret_val) return_message.append("\tError executing: RequestImages <dst_number>");
|
||||
else{ return_message.append("\tExecuted: RequestImages "); AddNumber(return_message,n[0]);}
|
||||
return_message.append(tmp_str[1]);
|
||||
return_message.append(" )\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case evTestRequest :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
n[0] = atoi(tmp_str[0].data()); //dst number
|
||||
if(tmp_str[0].length()<1||n[0]<0||n[0]>=ndsts_in_use){
|
||||
return_message.append("\tError executing: TestRequest <dst_number> (note dst_number must be less than 2xndsts_in_use that is set with SetDstParameters\n");
|
||||
ret_val = 1;
|
||||
}else{
|
||||
ret_val = (!bebs->RequestNImages(0,1,send_to_ten_gig,n[0],nimages_per_request,1)||!bebs->RequestNImages(0,2,send_to_ten_gig,0x20|n[0],nimages_per_request,1));
|
||||
if(ret_val) return_message.append("\tError executing: TestRequest <dst_number>\n");
|
||||
else{ return_message.append("\tExecuted: TestRequest "); AddNumber(return_message,n[0]); return_message.append("\n");}
|
||||
}
|
||||
break;
|
||||
|
||||
case evSetBitMode :
|
||||
on_dst = 0;
|
||||
for(n[0]=0;n[0]<32;n[0]++) dst_requested[n[0]] = 0; //clear dst requested
|
||||
n[0] = atoi(GetNextString(data).data());
|
||||
if((ret_val = !bebs->SetUpTransferParameters(n[0]))) return_message.append("\tError executing: SetBitMode <bit_mode 4,8,16,32>\n");
|
||||
else{ return_message.append("\tExecuted: SetBitMode ");AddNumber(return_message,n[0]);return_message.append("\n");}
|
||||
break;
|
||||
|
||||
case evSetDstParameters : //move below //<one_ten_gigabit> <ndsts> <nimages_per_request>
|
||||
on_dst = 0;
|
||||
for(n[0]=0;n[0]<32;n[0]++) dst_requested[n[0]] = 0; //clear dst requested
|
||||
n[0] = atoi(GetNextString(data).data()); //<1GbE(0) or 10GbE(1)>
|
||||
n[1] = atoi(GetNextString(data).data()); //<ndsts (1 to 32)>
|
||||
n[2] = atoi(GetNextString(data).data()); // <nimages_per_request (>0)>
|
||||
|
||||
if((n[0]!=0&&n[0]!=1)||(n[1]<1||n[1]>32)||n[2]<1){
|
||||
return_message.append("\tError executing: SetDstParameters <1GbE(0) or 10GbE(1)> <ndsts> <nimages_per_request>\n");
|
||||
ret_val=1;
|
||||
}
|
||||
else{
|
||||
send_to_ten_gig = n[0];
|
||||
ndsts_in_use=n[1];
|
||||
nimages_per_request=n[2];
|
||||
return_message.append("\tExecuted: SetDstParameters ");
|
||||
AddNumber(return_message,n[0]);return_message.append(" ");
|
||||
AddNumber(return_message,n[1]);return_message.append(" ");
|
||||
AddNumber(return_message,n[2]);return_message.append(" ");
|
||||
ret_val=0;
|
||||
}
|
||||
break;
|
||||
|
||||
case evSetupTableEntry :
|
||||
n[0] = atoi(GetNextString(data).data()); //beb_number;
|
||||
n[1] = atoi(GetNextString(data).data()); //<1GbE(0) or 10GbE(1)>
|
||||
n[2] = atoi(GetNextString(data).data()); //header_number
|
||||
tmp_str[0] = GetNextString(data); //src_mac
|
||||
tmp_str[1] = GetNextString(data); //src_ip
|
||||
n[3] = atoi(GetNextString(data).data()); //src_port
|
||||
tmp_str[2] = GetNextString(data); //dst_mac
|
||||
tmp_str[3] = GetNextString(data); //dst_ip
|
||||
n[4] = atoi((tmp_str[4]=GetNextString(data)).data()); //dst_port
|
||||
|
||||
if(n[0]<1||(n[1]!=0&&n[1]!=1)||(n[2]<0||n[2]>63)||tmp_str[0].length()<1||tmp_str[1].length()<1||n[3]<0||tmp_str[2].length()<1||tmp_str[3].length()<1||n[4]<0||tmp_str[4].length()<1){
|
||||
return_message.append("\tError executing: SetupTableEntry <beb_number> <1GbE(0) or 10GbE(1)> <dst_number> <src_mac> <src_ip> <src_port> <dst_mac> <dst_ip> <dst_port>\n");
|
||||
ret_val = 1;
|
||||
}else{
|
||||
for(int i=0;i<32;i++)/** modified for Aldo*/
|
||||
ret_val = !bebs->SetBebSrcHeaderInfos(n[0],n[1],tmp_str[0],tmp_str[1],n[3])||!bebs->SetUpUDPHeader(n[0],n[1],n[2]+i,tmp_str[2],tmp_str[3],n[4]);
|
||||
|
||||
if(ret_val) return_message.append("\tError Executing: SetupTableEntry ");
|
||||
else return_message.append("\tExecuted: SetupTableEntry ");
|
||||
AddNumber(return_message,n[0]);return_message.append(" ");
|
||||
AddNumber(return_message,n[1]);return_message.append(" ");
|
||||
AddNumber(return_message,n[2]);return_message.append(" ");
|
||||
return_message.append(tmp_str[0]);return_message.append(" ");
|
||||
return_message.append(tmp_str[1]);return_message.append(" ");
|
||||
AddNumber(return_message,n[3]);return_message.append(" ");
|
||||
return_message.append(tmp_str[2]);return_message.append(" ");
|
||||
return_message.append(tmp_str[3]);return_message.append(" ");
|
||||
AddNumber(return_message,n[4]);
|
||||
}
|
||||
break;
|
||||
|
||||
case evTest :
|
||||
n[0] = atoi(GetNextString(data).data());
|
||||
if(n[0]<1){
|
||||
return_message.append("\tError executing: Test <beb_number>\n");
|
||||
ret_val = 1;
|
||||
}else{
|
||||
ret_val = !bebs->Test(n[0]);
|
||||
if(ret_val) return_message.append("\tError Executing: Test ");
|
||||
else return_message.append("\tExecuted: Test ");
|
||||
AddNumber(return_message,n[0]);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case evTestSend :
|
||||
n[0] = atoi(GetNextString(data).data()); //beb_number;
|
||||
n[1] = atoi(GetNextString(data).data()); //giga bit, ten giga bit
|
||||
n[2] = atoi((tmp_str[0]=GetNextString(data)).data()); //header_number
|
||||
|
||||
if(n[0]<1||(n[1]!=0&&n[1]!=1)||(n[2]<0||n[2]>63)||tmp_str[0].length()<1){
|
||||
return_message.append("\tError executing: TestSend <beb_number> <1GbE(0) or 10GbE(1)> <dst_number>\n");
|
||||
ret_val = 1;
|
||||
}else{
|
||||
ret_val = !bebs->SendMultiReadRequest(n[0],1,n[1],n[2],1,0);
|
||||
|
||||
if(ret_val) return_message.append("\tError Executing: TestSend ");
|
||||
else return_message.append("\tExecuted: TestSend ");
|
||||
AddNumber(return_message,n[0]);return_message.append(" ");
|
||||
AddNumber(return_message,n[1]);return_message.append(" ");
|
||||
AddNumber(return_message,n[2]);return_message.append(" ");
|
||||
}
|
||||
break;
|
||||
|
||||
case evExitServer :
|
||||
return_message.append("\tExiting Server ....\n");
|
||||
stop = 1;
|
||||
ret_val = -200;
|
||||
break;
|
||||
|
||||
default :
|
||||
return_message.append("\tWarning command \"");
|
||||
return_message.append(cmd);
|
||||
return_message.append("\" not found.\n");
|
||||
return_message.append("\t\tValid commands: ");
|
||||
map<string, cmd_string>::iterator it = enum_map.begin();
|
||||
while(it!=enum_map.end()){
|
||||
return_message.append((it++)->first);
|
||||
return_message.append(" ");
|
||||
}
|
||||
|
||||
ret_val=-100;
|
||||
break;
|
||||
}
|
||||
|
||||
return_message.append("\n");
|
||||
AddNumber(return_message,ret_val,return_start_pos);
|
||||
if(ret_val!=0) break;
|
||||
|
||||
cmd = GetNextString(data);
|
||||
}
|
||||
return_message.append("\n\n\n");
|
||||
|
||||
AddNumber(return_message,ret_val,0);
|
||||
cout<<return_message.c_str()<<endl;
|
||||
cout<<"\treturn: "<<ret_val<<endl;
|
||||
|
||||
if(!WriteNClose(return_message.c_str(),return_message.length())) return 0;
|
||||
}
|
||||
|
||||
|
||||
delete bebs;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
string LowerCase(string str){
|
||||
string s = str;
|
||||
string::iterator i = s.begin();
|
||||
while(i!=s.end()) *i=tolower(*(i++));
|
||||
return s;
|
||||
}
|
||||
|
||||
string GetNextString(string str,bool start_from_beginning){
|
||||
static string::size_type start_pos = 0;
|
||||
if(start_from_beginning) start_pos = 0;
|
||||
|
||||
while(start_pos != string::npos){
|
||||
string::size_type found = str.find_first_of(" ",start_pos);
|
||||
string sub = str.substr(start_pos,found-start_pos);
|
||||
|
||||
start_pos = found;
|
||||
if(start_pos != string::npos) start_pos+=1;
|
||||
|
||||
sub.erase(remove_if(sub.begin(),sub.end(), ::isspace ),sub.end());
|
||||
|
||||
if(sub.length()>0) return sub;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AddNumber(string& str, int n, int location){
|
||||
static char retval_st[100];
|
||||
sprintf(retval_st,"%d",n);
|
||||
|
||||
if(location<0) str.append(retval_st);
|
||||
else str.insert(location,retval_st);
|
||||
}
|
||||
|
||||
|
||||
bool SetupListenSocket(unsigned short int port){
|
||||
server_list_s=0;
|
||||
server_conn_s=0;
|
||||
|
||||
if((server_list_s = socket(AF_INET, SOCK_STREAM, 0))<0) return 0;
|
||||
|
||||
struct sockaddr_in servaddr; /* socket address structure */
|
||||
memset(&servaddr, 0, sizeof(servaddr));
|
||||
servaddr.sin_family = AF_INET;
|
||||
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
servaddr.sin_port = htons(port);
|
||||
|
||||
if(bind(server_list_s,(struct sockaddr *) &servaddr,sizeof(servaddr))<0) return 0;
|
||||
|
||||
if(listen(server_list_s,32) < 0){ // 1024 /* Backlog for listen() */
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int AccpetConnectionAndWaitForData(char* buffer, int maxlength){
|
||||
if(server_list_s==0||maxlength<=0) return 0;
|
||||
|
||||
if((server_conn_s = accept(server_list_s,NULL,NULL))< 0) return 0;
|
||||
|
||||
int nread = read(server_conn_s,buffer,maxlength-1);
|
||||
|
||||
if(nread<0) return 0;
|
||||
|
||||
buffer[nread]='\0';
|
||||
return nread;
|
||||
}
|
||||
|
||||
bool WriteNClose(const char* buffer, int length){
|
||||
if(server_conn_s==0||length<=0) return 0;
|
||||
|
||||
int nsent = write(server_conn_s,buffer,length);
|
||||
if(close(server_conn_s)<0) return 0;
|
||||
|
||||
server_conn_s=0;
|
||||
return (nsent==length);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
|
||||
Internal setup:
|
||||
setdac
|
||||
trimbits
|
||||
rate correction tau
|
||||
high voltage
|
||||
|
||||
|
||||
Setup:
|
||||
photon energy
|
||||
dynamic range (4,8,16,32)
|
||||
number of images
|
||||
exposure time
|
||||
exposure period
|
||||
readout speed(full speed, 1/2 speed, 1/4 or super slow)
|
||||
readout mode (parallel, non-parallel or super safe)
|
||||
trigger mode (internal,external start of series, external start of acquisitions, external window)
|
||||
trigger polarity (pos/neg)
|
||||
external gating (on, pos/neg)
|
||||
|
||||
|
||||
Acquisition:
|
||||
start acquisition
|
||||
stop acquisition
|
||||
acquisition in progress
|
||||
wait until daq is finished
|
||||
status (needs to be implemented)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,179 +0,0 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
|
||||
#ifndef EIGER_H
|
||||
#define EIGER_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Feb.h"
|
||||
|
||||
|
||||
class Module{
|
||||
|
||||
private:
|
||||
unsigned int module_number;
|
||||
bool top_address_valid;
|
||||
unsigned int top_left_address;
|
||||
unsigned int top_right_address;
|
||||
bool bottom_address_valid;
|
||||
unsigned int bottom_left_address;
|
||||
unsigned int bottom_right_address;
|
||||
|
||||
unsigned int idelay_top[4]; //ll,lr,rl,ll
|
||||
unsigned int idelay_bottom[4]; //ll,lr,rl,ll
|
||||
float high_voltage;
|
||||
float* top_dac;
|
||||
float* bottom_dac;
|
||||
|
||||
public:
|
||||
Module(unsigned int number, unsigned int address_top); //for half module()
|
||||
Module(unsigned int number, unsigned int address_top, unsigned int address_bottom);
|
||||
~Module();
|
||||
|
||||
static const unsigned int ndacs;
|
||||
static const std::string dac_names[16];
|
||||
|
||||
unsigned int GetModuleNumber() {return module_number;}
|
||||
bool TopAddressIsValid() {return top_address_valid;}
|
||||
unsigned int GetTopBaseAddress() {return (top_left_address&0xff);}
|
||||
unsigned int GetTopLeftAddress() {return top_left_address;}
|
||||
unsigned int GetTopRightAddress() {return top_right_address;}
|
||||
unsigned int GetBottomBaseAddress() {return (bottom_left_address&0xff);}
|
||||
bool BottomAddressIsValid() {return bottom_address_valid;}
|
||||
unsigned int GetBottomLeftAddress() {return bottom_left_address;}
|
||||
unsigned int GetBottomRightAddress() {return bottom_right_address;}
|
||||
|
||||
unsigned int SetTopIDelay(unsigned int chip,unsigned int value) { return TopAddressIsValid() &&chip<4 ? (idelay_top[chip]=value) : 0;} //chip 0=ll,1=lr,0=rl,1=rr
|
||||
unsigned int GetTopIDelay(unsigned int chip) { return chip<4 ? idelay_top[chip] : 0;} //chip 0=ll,1=lr,0=rl,1=rr
|
||||
unsigned int SetBottomIDelay(unsigned int chip,unsigned int value) { return BottomAddressIsValid() &&chip<4 ? (idelay_bottom[chip]=value) : 0;} //chip 0=ll,1=lr,0=rl,1=rr
|
||||
unsigned int GetBottomIDelay(unsigned int chip) { return chip<4 ? idelay_bottom[chip] : 0;} //chip 0=ll,1=lr,0=rl,1=rr
|
||||
|
||||
float SetHighVoltage(float value) { return TopAddressIsValid() ? (high_voltage=value) : -1;}
|
||||
float GetHighVoltage() { return high_voltage;}
|
||||
|
||||
float SetTopDACVoltage(unsigned int i, float value) { return (i<ndacs && TopAddressIsValid()) ? (top_dac[i]=value) : -1;}
|
||||
float GetTopDACVoltage(unsigned int i) { return (i<ndacs) ? top_dac[i]:-1;}
|
||||
float SetBottomDACVoltage(unsigned int i, float value) { return (i<ndacs && BottomAddressIsValid()) ? (bottom_dac[i]=value) : -1;}
|
||||
float GetBottomDACVoltage(unsigned int i) { return (i<ndacs) ? bottom_dac[i]:-1;}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
class Eiger:private Feb{
|
||||
|
||||
private:
|
||||
|
||||
std::vector<Module*> modules;
|
||||
void ClearModules();
|
||||
|
||||
unsigned int staticBits; //program=1,m4=2,m8=4,test=8,rotest=16,cs_bar_left=32,cs_bar_right=64
|
||||
unsigned int acquireNReadoutMode; //safe or parallel, half or full speed
|
||||
unsigned int triggerMode; //internal timer, external start, external window, signal polarity (external trigger and enable)
|
||||
unsigned int externalEnableMode; //external enabling engaged and it's polarity
|
||||
unsigned int subFrameMode;
|
||||
|
||||
unsigned int photon_energy_eV;
|
||||
|
||||
unsigned int nimages;
|
||||
float exposure_time_in_sec;
|
||||
float exposure_period_in_sec;
|
||||
|
||||
unsigned int trimbit_size;
|
||||
unsigned char* last_downloaded_trimbits;
|
||||
|
||||
void PrintModuleList();
|
||||
bool GetModuleIndex(unsigned int module_number, unsigned int& module_index);
|
||||
bool CheckModuleAddresses(unsigned int top_address, unsigned int bottom_address);
|
||||
bool AddModule(unsigned int module_number, unsigned int top_address);
|
||||
bool AddModule(unsigned int module_number, unsigned int top_address, unsigned int bottom_address, bool half_module=0);
|
||||
|
||||
bool GetDACNumber(std::string s, unsigned int& n);
|
||||
bool SendDACValue(unsigned int dst_num, unsigned int ch, float& value);
|
||||
bool VoltageToDAC(float value, unsigned int& digital, unsigned int nsteps, float vmin, float vmax);
|
||||
float DACToVoltage(unsigned int digital,unsigned int nsteps,float vmin,float vmax);
|
||||
|
||||
bool SendHighVoltage(unsigned int module_index, float& value);
|
||||
|
||||
bool SendIDelays(unsigned int dst_num, bool chip_lr, unsigned int channels, unsigned int ndelay_units);
|
||||
|
||||
bool SetStaticBits();
|
||||
bool SetStaticBits(unsigned int the_static_bits);
|
||||
|
||||
unsigned int ConvertTimeToRegister(float time_in_sec);
|
||||
|
||||
bool SetCommandRegister(unsigned int cmd);
|
||||
bool GetDAQStatusRegister(int socket_num, unsigned int &ret_status);
|
||||
bool StartDAQOnlyNWaitForFinish(int sleep_time_us=5000);
|
||||
bool ResetDataStream();
|
||||
|
||||
bool ResetChipCompletely();
|
||||
|
||||
public:
|
||||
Eiger();
|
||||
virtual ~Eiger();
|
||||
|
||||
bool Init();
|
||||
bool ReadSetUpFileToAddModules(std::string file_name);
|
||||
bool ReadSetUpFile(unsigned int module_num, std::string file_name);
|
||||
bool CheckSetup();
|
||||
|
||||
unsigned int GetNModules();
|
||||
unsigned int GetNHalfModules();
|
||||
|
||||
//bool SetHighVoltage(float value);
|
||||
bool SetHighVoltage(unsigned int module_num,float value);
|
||||
|
||||
bool SetPhotonEnergy(unsigned int full_energy_eV);
|
||||
unsigned int GetPhotonEnergy(){return photon_energy_eV;}
|
||||
|
||||
bool SetIDelays(unsigned int module_num, unsigned int ndelay_units);
|
||||
bool SetIDelays(unsigned int module_num, unsigned int chip_pos, unsigned int ndelay_units);
|
||||
|
||||
bool SetDAC(std::string s, float value);
|
||||
bool GetDAC(std::string s, float& ret_value);
|
||||
bool GetDACName(unsigned int dac_num, std::string &s);
|
||||
|
||||
bool SetTrimbits(unsigned char* trimbits);
|
||||
unsigned char* GetTrimbits();
|
||||
|
||||
|
||||
|
||||
bool Reset();
|
||||
bool StartAcquisition();
|
||||
bool StopAcquisition();
|
||||
bool AcquisitionInProgress();
|
||||
bool WaitForFinishedFlag(int sleep_time_us=5000);
|
||||
|
||||
//functions for setting up exposure
|
||||
void PrintAcquisitionSetup();
|
||||
bool SetNImages(unsigned int n_images);
|
||||
unsigned int GetNImages();
|
||||
bool SetExposureTime(float the_exposure_time_in_sec);
|
||||
float GetExposureTime();
|
||||
bool SetExposurePeriod(float the_exposure_period_in_sec);
|
||||
float GetExposurePeriod();
|
||||
bool SetDynamicRange(unsigned int four_eight_sixteen_or_thirtytwo);
|
||||
unsigned int GetDynamicRange();
|
||||
bool SetReadoutSpeed(unsigned int readout_speed=0); //0->full,1->half,2->quarter or 3->super_slow
|
||||
bool SetReadoutMode(unsigned int readout_mode=0); //0->parallel,1->non-parallel,2-> safe_mode
|
||||
bool SetTriggerMode(unsigned int trigger_mode=0, bool polarity=1);
|
||||
bool SetExternalEnableMode(bool use_external_enable=0, bool polarity=1);
|
||||
|
||||
|
||||
//functions for testing
|
||||
bool SetTestModeVariable(bool on=1);
|
||||
bool GetTestModeVariable();
|
||||
|
||||
bool FebTest(){return Feb::Test();}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,200 +0,0 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
|
||||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
|
||||
#include "slsDetectorServer_defs.h" //include port number
|
||||
|
||||
struct sockaddr_in eiger_back_socket_addr;
|
||||
int eiger_back_max_message_length = 1024;
|
||||
char eiger_back_message[1024];
|
||||
int eiger_back_message_length = 0;
|
||||
int eiger_back_ret_val=0;
|
||||
|
||||
|
||||
int bit_mode=0;
|
||||
int ten_giga=0;
|
||||
|
||||
int EigerBackInit(){
|
||||
static int passed = 0;
|
||||
|
||||
if(!passed){
|
||||
struct hostent *dst_host;
|
||||
if((dst_host = gethostbyname("localhost")) == NULL){ //or look into getaddrinfo(3)
|
||||
fprintf(stderr,"ERROR, no such host\n");
|
||||
return 0;
|
||||
}else{
|
||||
//struct sockaddr_in eiger_back_socket_addr;
|
||||
int port = BEB_PORT;
|
||||
bzero((char *) &eiger_back_socket_addr, sizeof(eiger_back_socket_addr));
|
||||
eiger_back_socket_addr.sin_family = AF_INET;
|
||||
bcopy((char *)dst_host->h_addr,(char *)&eiger_back_socket_addr.sin_addr.s_addr,dst_host->h_length);
|
||||
eiger_back_socket_addr.sin_port = htons(port);
|
||||
passed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return passed;
|
||||
}
|
||||
|
||||
|
||||
int EigerBackSendCMD(){
|
||||
if(!EigerBackInit()||eiger_back_message_length<=0) return 0;
|
||||
|
||||
int sockfd = socket(AF_INET,SOCK_STREAM,0);
|
||||
if(sockfd<0){
|
||||
fprintf(stderr,"ERROR opening socket\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(connect(sockfd,(struct sockaddr *) &eiger_back_socket_addr,sizeof(eiger_back_socket_addr))<0){
|
||||
fprintf(stderr,"ERROR connecting\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int n = write(sockfd,eiger_back_message,eiger_back_message_length);
|
||||
int ret_length = read(sockfd,eiger_back_message,eiger_back_max_message_length);
|
||||
|
||||
close(sockfd);
|
||||
|
||||
if(n<0||ret_length<0) return 0;
|
||||
|
||||
|
||||
//fprintf(stdout,"%s\n",eiger_back_message);
|
||||
if(eiger_back_ret_val>0){
|
||||
int i=0;
|
||||
eiger_back_message[1]='\0';
|
||||
if(atoi(eiger_back_message)!=0) return 0;
|
||||
|
||||
for(i=2;i<ret_length;i++){
|
||||
if(eiger_back_message[i] == ' '){
|
||||
//fprintf(stdout," in : %d \n",i);
|
||||
eiger_back_message[i]='\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
eiger_back_ret_val = atoi(&eiger_back_message[2]);
|
||||
//fprintf(stdout," the \"%s\" %d\n",&eiger_back_message[2],eiger_back_ret_val);
|
||||
}
|
||||
|
||||
eiger_back_message_length = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int EigerSetBitMode(int i){
|
||||
eiger_back_ret_val=0;
|
||||
eiger_back_message_length = sprintf(eiger_back_message,"setbitmode %d",i);
|
||||
bit_mode = i;
|
||||
return EigerBackSendCMD();
|
||||
}
|
||||
|
||||
int EigerGetBitMode(){
|
||||
return bit_mode;
|
||||
}
|
||||
|
||||
//SetupTableEntry <beb_number> <1GbE(0) or 10GbE(1)> <dst_number> <src_mac> <src_ip> <src_port> <dst_mac> <dst_ip> <dst_port>
|
||||
int EigerSetupTableEntryLeft(int ipad, long long int macad, long long int detectormacadd, int detipad, int udpport){
|
||||
char src_mac[50], src_ip[50],dst_mac[50], dst_ip[50];
|
||||
|
||||
int src_port = 0xE185;
|
||||
int dst_port = udpport;
|
||||
sprintf(src_ip,"%d.%d.%d.%d",(detipad>>24)&0xff,(detipad>>16)&0xff,(detipad>>8)&0xff,(detipad)&0xff);
|
||||
sprintf(dst_ip,"%d.%d.%d.%d",(ipad>>24)&0xff,(ipad>>16)&0xff,(ipad>>8)&0xff,(ipad)&0xff);
|
||||
sprintf(src_mac,"%02x:%02x:%02x:%02x:%02x:%02x",(unsigned int)((detectormacadd>>40)&0xFF),
|
||||
(unsigned int)((detectormacadd>>32)&0xFF),
|
||||
(unsigned int)((detectormacadd>>24)&0xFF),
|
||||
(unsigned int)((detectormacadd>>16)&0xFF),
|
||||
(unsigned int)((detectormacadd>>8)&0xFF),
|
||||
(unsigned int)((detectormacadd>>0)&0xFF));
|
||||
sprintf(dst_mac,"%02x:%02x:%02x:%02x:%02x:%02x",(unsigned int)((macad>>40)&0xFF),
|
||||
(unsigned int)((macad>>32)&0xFF),
|
||||
(unsigned int)((macad>>24)&0xFF),
|
||||
(unsigned int)((macad>>16)&0xFF),
|
||||
(unsigned int)((macad>>8)&0xFF),
|
||||
(unsigned int)((macad>>0)&0xFF));
|
||||
|
||||
printf("Seting up Table Entry Left:\n");
|
||||
printf("src_port:%d\n",src_port);
|
||||
printf("dst_port:%d\n",dst_port);
|
||||
printf("src_ip:%s\n",src_ip);
|
||||
printf("dst_ip:%s\n",dst_ip);
|
||||
printf("src_mac:%s\n",src_mac);
|
||||
printf("dst_mac:%s\n\n",dst_mac);
|
||||
|
||||
|
||||
|
||||
eiger_back_ret_val=0;
|
||||
eiger_back_message_length = sprintf(eiger_back_message,"setuptableentry %d %d %d %s %s %d %s %s %d",34,ten_giga,0,src_mac,src_ip,src_port,dst_mac,dst_ip,dst_port);
|
||||
return EigerBackSendCMD();
|
||||
}
|
||||
|
||||
|
||||
int EigerSetupTableEntryRight(int ipad, long long int macad, long long int detectormacadd, int detipad, int udpport){
|
||||
char src_mac[50], src_ip[50],dst_mac[50], dst_ip[50];
|
||||
|
||||
int src_port = 0xE185;
|
||||
int dst_port = udpport+1;
|
||||
sprintf(src_ip,"%d.%d.%d.%d",(detipad>>24)&0xff,(detipad>>16)&0xff,(detipad>>8)&0xff,(detipad)&0xff);
|
||||
sprintf(dst_ip,"%d.%d.%d.%d",(ipad>>24)&0xff,(ipad>>16)&0xff,(ipad>>8)&0xff,(ipad)&0xff);
|
||||
sprintf(src_mac,"%02x:%02x:%02x:%02x:%02x:%02x",(unsigned int)((detectormacadd>>40)&0xFF),
|
||||
(unsigned int)((detectormacadd>>32)&0xFF),
|
||||
(unsigned int)((detectormacadd>>24)&0xFF),
|
||||
(unsigned int)((detectormacadd>>16)&0xFF),
|
||||
(unsigned int)((detectormacadd>>8)&0xFF),
|
||||
(unsigned int)((detectormacadd>>0)&0xFF));
|
||||
sprintf(dst_mac,"%02x:%02x:%02x:%02x:%02x:%02x",(unsigned int)((macad>>40)&0xFF),
|
||||
(unsigned int)((macad>>32)&0xFF),
|
||||
(unsigned int)((macad>>24)&0xFF),
|
||||
(unsigned int)((macad>>16)&0xFF),
|
||||
(unsigned int)((macad>>8)&0xFF),
|
||||
(unsigned int)((macad>>0)&0xFF));
|
||||
|
||||
printf("Seting up Table Entry Right:\n");
|
||||
printf("src_port:%d\n",src_port);
|
||||
printf("dst_port:%d\n",dst_port);
|
||||
printf("src_ip:%s\n",src_ip);
|
||||
printf("dst_ip:%s\n",dst_ip);
|
||||
printf("src_mac:%s\n",src_mac);
|
||||
printf("dst_mac:%s\n\n",dst_mac);
|
||||
|
||||
eiger_back_ret_val=0;
|
||||
eiger_back_message_length = sprintf(eiger_back_message,"setuptableentry %d %d %d %s %s %d %s %s %d",34,ten_giga,32,src_mac,src_ip,src_port,dst_mac,dst_ip,dst_port);
|
||||
return EigerBackSendCMD();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int RequestImages(){
|
||||
printf("Going to request images\n");
|
||||
eiger_back_ret_val=0;
|
||||
eiger_back_message_length = sprintf(eiger_back_message,"requestimages %d",0); // dst_number
|
||||
return EigerBackSendCMD();
|
||||
}
|
||||
|
||||
int SetDestinationParameters(int i){
|
||||
eiger_back_ret_val=0;
|
||||
eiger_back_message_length = sprintf(eiger_back_message,"setdstparameters %d %d %d",ten_giga,1,i);// number of dsts
|
||||
return EigerBackSendCMD();
|
||||
}
|
||||
|
||||
|
||||
void SetTenGigbaBitEthernet(int val){
|
||||
ten_giga = val;
|
||||
}
|
||||
|
||||
|
||||
int GetTenGigbaBitEthernet(){
|
||||
return ten_giga;
|
||||
}
|
||||
@@ -1,363 +0,0 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "slsDetectorServer_defs.h" //include port number
|
||||
|
||||
|
||||
|
||||
int eiger_nexposures = 1;
|
||||
float eiger_exposuretime = 0;
|
||||
float eiger_exposureperiod = 0;
|
||||
int eiger_ncycles = 1;
|
||||
int eiger_ngates = 0;
|
||||
int eiger_getphotonenergy = 0;
|
||||
int eiger_dynamicrange = 0;
|
||||
int eiger_readoutspeed = 0;
|
||||
int eiger_readoutmode = 0;
|
||||
int eiger_highvoltage = 0;
|
||||
int eiger_iodelay = 0;
|
||||
int eiger_triggermode = 0;
|
||||
int eiger_extgating = 0;
|
||||
int eiger_extgatingpolarity = 0;
|
||||
|
||||
const unsigned int ndacs = 16;
|
||||
const char* dac_names[16] = {"SvP","Vtr","Vrf","Vrs","SvN","Vtgstv","Vcmp_ll","Vcmp_lr","cal","Vcmp_rl","rxb_rb","rxb_lb","Vcmp_rr","Vcp","Vcn","Vis"};
|
||||
|
||||
int saved_trimbits[256*256*4];
|
||||
|
||||
|
||||
int EigerGetNumberOfExposures(){return eiger_nexposures;}
|
||||
float EigerGetExposureTime(){return eiger_exposuretime;}
|
||||
float EigerGetExposurePeriod(){return eiger_exposureperiod;}
|
||||
int EigerGetNumberOfCycles(){return eiger_ncycles;}
|
||||
/*int EigerGetNumberOfGates(){return eiger_ngates;}*/
|
||||
unsigned int EigerGetDynamicRange(){return eiger_dynamicrange;}
|
||||
int EigerGetPhotonEnergy(){return eiger_getphotonenergy;}
|
||||
int EigerGetReadoutSpeed(){return eiger_readoutspeed;}
|
||||
int EigerGetReadoutMode(){return eiger_readoutmode;}
|
||||
int EigerGetHighVoltage(){return eiger_highvoltage;}
|
||||
int EigerGetIODelay(){return eiger_iodelay;}
|
||||
int EigerGetTriggerMode(){return eiger_triggermode;}
|
||||
int EigerGetExternalGating(){return eiger_extgating;}
|
||||
int EigerGetExternalGatingPolarity(){return eiger_extgatingpolarity;}
|
||||
|
||||
int EigerInit(){
|
||||
saved_trimbits[0] = -1;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int EigerSendCMD(){
|
||||
if(!EigerInit()||eiger_message_length<=0) return 0;
|
||||
|
||||
int sockfd = socket(AF_INET,SOCK_STREAM,0);
|
||||
if(sockfd<0){
|
||||
fprintf(stderr,"ERROR opening socket\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(connect(sockfd,(struct sockaddr *) &eiger_socket_addr,sizeof(eiger_socket_addr))<0){
|
||||
fprintf(stderr,"ERROR connecting\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int n = write(sockfd,eiger_message,eiger_message_length);
|
||||
|
||||
int ret_length = read(sockfd,eiger_message,eiger_max_message_length);
|
||||
|
||||
close(sockfd);
|
||||
|
||||
if(n<0||ret_length<0) return 0;
|
||||
|
||||
|
||||
//fprintf(stdout,"%s\n",eiger_message);
|
||||
if(eiger_ret_val>0){
|
||||
int i=0;
|
||||
eiger_message[1]='\0';
|
||||
if(atoi(eiger_message)!=0) return 0;
|
||||
|
||||
for(i=2;i<ret_length;i++){
|
||||
if(eiger_message[i] == ' '){
|
||||
//fprintf(stdout," in : %d \n",i);
|
||||
eiger_message[i]='\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
eiger_ret_val = atoi(&eiger_message[2]);
|
||||
//fprintf(stdout," the \"%s\" %d\n",&eiger_message[2],eiger_ret_val);
|
||||
}
|
||||
|
||||
eiger_message_length = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* EigerGetDACName(int i){
|
||||
if(i>0&&i<ndacs) return dac_names[i];
|
||||
return dac_names[0];
|
||||
}
|
||||
|
||||
|
||||
int EigerSetDAC(const char* iname,int v, int mV){
|
||||
eiger_ret_val=0;
|
||||
if(mV)
|
||||
eiger_message_length = sprintf(eiger_message,"setdacvoltage %s %d",iname,v);
|
||||
else
|
||||
eiger_message_length = sprintf(eiger_message,"setdacvalue %s %d",iname,v);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
int EigerSetTrimbits(const int *data){
|
||||
eiger_ret_val=0;
|
||||
/*char tt[263681];
|
||||
tt[263680]='\0';
|
||||
int ip=0, ich=0;
|
||||
int iy, ix;
|
||||
int ichip;
|
||||
|
||||
// convert the trimbits from int32 to chars and add border pixels.
|
||||
for(iy=0;iy<256;iy++) {
|
||||
for (ichip=0; ichip<4; ichip++) {
|
||||
for(ix=0;ix<256;ix++) {
|
||||
tt[ip++]=(char)((data[ich++]&(0x3f))+'0');
|
||||
}
|
||||
if (ichip<3) {
|
||||
tt[ip++]=(char)(0+'0');
|
||||
tt[ip++]=(char)(0+'0');
|
||||
}
|
||||
}
|
||||
}
|
||||
eiger_message_length = sprintf(eiger_message,"settrimbits %s", tt);
|
||||
memcpy(saved_trimbits,data,256*256*4*sizeof(int));*/
|
||||
|
||||
eiger_message_length = sprintf(eiger_message,"settrimbits %d", 0);
|
||||
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
|
||||
|
||||
int EigerSetAllTrimbits(unsigned int value){
|
||||
eiger_ret_val=0;
|
||||
/*char tt[263681];
|
||||
tt[263680]='\0';
|
||||
int ip=0, ich=0;
|
||||
int iy, ix;
|
||||
int ichip;
|
||||
int sl=0;
|
||||
|
||||
|
||||
// convert the trimbits from int32 to chars and add border pixels.
|
||||
for(iy=0;iy<256;iy++) {
|
||||
for (ichip=0; ichip<4; ichip++) {
|
||||
for(ix=0;ix<256;ix++) {
|
||||
tt[ip++]=(char)((value&0x3f)+'0');
|
||||
}
|
||||
if (ichip<3) {
|
||||
tt[ip++]=(char)(0+'0');
|
||||
tt[ip++]=(char)(0+'0');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
eiger_message_length = sprintf(eiger_message,"settrimbits %s", tt);
|
||||
for(iy=0;iy<256*256*4;++iy)
|
||||
saved_trimbits[iy] = value;*/
|
||||
eiger_message_length = sprintf(eiger_message,"setalltrimbits %d", value);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
|
||||
|
||||
int EigerGetTrimbits(const int *data){
|
||||
eiger_ret_val=0;
|
||||
/*char tt[263681];
|
||||
tt[263680]='\0';
|
||||
int ip=0, ich=0;
|
||||
int iy, ix;
|
||||
int ichip;
|
||||
|
||||
eiger_message_length = sprintf(eiger_message,"gettrimbits ");
|
||||
memcpy(data,saved_trimbits,256*256*4*sizeof(int));*/
|
||||
|
||||
eiger_message_length = sprintf(eiger_message,"gettrimbits ");
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
|
||||
|
||||
int EigerGetDAC(const char* iname){
|
||||
eiger_ret_val=1;
|
||||
eiger_message_length = sprintf(eiger_message,"getdacvalue %s",iname);
|
||||
if(!EigerSendCMD()) return -1;
|
||||
return eiger_ret_val;
|
||||
}
|
||||
|
||||
int EigerGetDACmV(const char* iname){
|
||||
eiger_ret_val=1;
|
||||
eiger_message_length = sprintf(eiger_message,"getdacvoltage %s",iname);
|
||||
if(!EigerSendCMD()) return -1;
|
||||
return eiger_ret_val;
|
||||
}
|
||||
|
||||
int EigerSetNumberOfExposures(unsigned int n){
|
||||
eiger_nexposures = n;
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"setnumberofexposures %u",eiger_nexposures*eiger_ncycles);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
int EigerSetExposureTime(float v){
|
||||
eiger_exposuretime = v;
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"setexposuretime %f",v);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
|
||||
int EigerSetExposurePeriod(float v){
|
||||
eiger_exposureperiod = v;
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"setexposureperiod %f",v);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
int EigerSetNumberOfCycles(unsigned int n){
|
||||
eiger_ncycles = n;
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"setnumberofexposures %u",eiger_nexposures*eiger_ncycles);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
/*
|
||||
int EigerSetNumberOfGates(unsigned int n){
|
||||
eiger_ngates = n;
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"setnumberofexposures %u",n);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
*/
|
||||
int EigerSetDynamicRange(unsigned int i){
|
||||
eiger_dynamicrange = i;
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"setbitmode %u",i);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
|
||||
int EigerSetPhotonEnergy(int in_eV){
|
||||
eiger_getphotonenergy = in_eV;
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"setphotonenergy %d",in_eV);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
int EigerSetReadoutSpeed(int speed){
|
||||
eiger_readoutspeed = speed;
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"setreadoutspeed %d",speed);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
int EigerSetReadoutMode(int mode){
|
||||
eiger_readoutmode = mode;
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"setreadoutmode %d",mode);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
int EigerSetHighVoltage(int hv){
|
||||
eiger_highvoltage = hv;
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"sethighvoltage %d",hv);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
int EigerSetIODelay(int io){
|
||||
eiger_iodelay = io;
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"setinputdelays %d",io);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
int EigerSetTriggerMode(int m){
|
||||
eiger_triggermode = m;
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"settriggermode %d",m);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
int EigerSetExternalGating(int e, int p){
|
||||
eiger_extgating = e;
|
||||
eiger_extgatingpolarity = p;
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"setexternalgating %d %d",e,p);
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
int EigerStartAcquisition(){
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"startacquisition");
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
|
||||
int EigerRunStatus(){
|
||||
eiger_ret_val=1;
|
||||
eiger_message_length = sprintf(eiger_message,"isdaqstillrunning");
|
||||
if(!EigerSendCMD()) return -1;
|
||||
return eiger_ret_val;
|
||||
}
|
||||
|
||||
int EigerStopAcquisition(){
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"stopacquisition");
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
int EigerWaitForAcquisitionFinish(){
|
||||
eiger_ret_val=0;
|
||||
eiger_message_length = sprintf(eiger_message,"waituntildaqfinished");
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
|
||||
#ifdef TESTEIGERFUNCTIONS
|
||||
int main(){
|
||||
|
||||
int v=220;
|
||||
char n[2000] = "Vcmp_lr";
|
||||
|
||||
fprintf(stdout," ret : %d\n",EigerSetDAC(EigerGetDACName(7),2200));
|
||||
int t = EigerGetDAC(EigerGetDACName(7));
|
||||
fprintf(stdout," v : %d\n",t);
|
||||
|
||||
fprintf(stdout," ret : %d\n",EigerSetDAC(n,v));
|
||||
t = EigerGetDAC(n);
|
||||
fprintf(stdout," ret : %d\n",t);
|
||||
|
||||
float f=0.12;
|
||||
fprintf(stdout," ret : %d\n",EigerSetNumberOfExposures(120));
|
||||
fprintf(stdout," ret : %d\n",EigerSetExposureTime(0.12));
|
||||
fprintf(stdout," ret : %d\n",EigerSetExposurePeriod(0.22));
|
||||
fprintf(stdout," ret : %d\n",EigerSetPhotonEnergy(9200));
|
||||
fprintf(stdout," ret : %d\n",EigerSetDynamicRange(16));
|
||||
fprintf(stdout," ret : %d\n",EigerStartAcquisition());
|
||||
fprintf(stdout," aret : %d\n",EigerRunStatus());
|
||||
sleep(1);
|
||||
fprintf(stdout," ret : %d\n",EigerStopAcquisition());
|
||||
fprintf(stdout," bret : %d\n",EigerRunStatus());
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
|
||||
//daq register definitions
|
||||
#define DAQ_REG_CTRL 1
|
||||
#define DAQ_REG_CHIP_CMDS 2
|
||||
#define DAQ_REG_STATIC_BITS 3
|
||||
#define DAQ_REG_CLK_ROW_CLK_NTIMES 3
|
||||
#define DAQ_REG_SHIFT_IN_32 3
|
||||
#define DAQ_REG_READOUT_NROWS 3
|
||||
#define DAQ_REG_SEND_N_TESTPULSES 3
|
||||
|
||||
#define DAQ_REG_NEXPOSURES 3
|
||||
#define DAQ_REG_EXPOSURE_TIMER 4 // == (31 downto 3) * 10^(2 downto 0)
|
||||
#define DAQ_REG_EXPOSURE_REPEAT_TIMER 5 // == (31 downto 3) * 10^(2 downto 0)
|
||||
#define DAQ_REG_STATUS 6 //also pg and fifo status register
|
||||
|
||||
#define DAQ_CTRL_RESET 0x80000000
|
||||
#define DAQ_CTRL_START 0x40000000
|
||||
#define ACQ_CTRL_START 0x50000000 //this is 0x10000000 (acq) | 0x40000000 (daq)
|
||||
#define DAQ_CTRL_STOP 0x00000000
|
||||
|
||||
//direct chip commands to the DAQ_REG_CHIP_CMDS register
|
||||
#define DAQ_SET_STATIC_BIT 0x00000001
|
||||
#define DAQ_RESET_COMPLETELY 0x0000000E
|
||||
#define DAQ_RESET_PERIPHERY 0x00000002
|
||||
#define DAQ_RESET_PIXEL_COUNTERS 0x00000004
|
||||
#define DAQ_RESET_COLUMN_SELECT 0x00000008
|
||||
|
||||
#define DAQ_STORE_IMAGE 0x00000010
|
||||
#define DAQ_RELEASE_IMAGE_STORE 0x00000020
|
||||
|
||||
#define DAQ_SEND_A_TOKEN_IN 0x00000040
|
||||
#define DAQ_CLK_ROW_CLK_NTIMES 0x00000080
|
||||
#define DAQ_SERIALIN_SHIFT_IN_32 0x00000100
|
||||
#define DAQ_LOAD_16ROWS_OF_TRIMBITS 0x00000200
|
||||
|
||||
#define DAQ_IGNORE_INITIAL_CRAP 0x00000400 //crap before readout
|
||||
#define DAQ_READOUT_NROWS 0x00000800
|
||||
#define DAQ_CLKOUT_LAST_4_BITS_AND_RETURN_TO_START 0x00001000 //last 4 bit of data in the last frame
|
||||
|
||||
#define DAQ_RELEASE_IMAGE_STORE_AFTER_READOUT 0x00002000
|
||||
#define DAQ_RESET_PIXEL_COUNTERS_AFTER_READOUT 0x00004000
|
||||
|
||||
#define DAQ_CLK_ROW_CLK_TO_SELECT_NEXT_ROW 0x00008000
|
||||
#define DAQ_CLK_MAIN_CLK_TO_SELECT_NEXT_PIXEL 0x00010000
|
||||
#define DAQ_SEND_N_TEST_PULSES 0x00020000
|
||||
|
||||
#define DAQ_CHIP_CONTROLLER_HALF_SPEED 0x00040000 //everything at 100 MHz (50MHz ddr readout)
|
||||
#define DAQ_CHIP_CONTROLLER_QUARTER_SPEED 0x00080000 //everything at 50 MHz (25MHz ddr readout)
|
||||
#define DAQ_CHIP_CONTROLLER_SUPER_SLOW_SPEED 0x000c0000 //everything at ~200 kHz (200 kHz MHz ddr readout)
|
||||
|
||||
#define DAQ_FIFO_ENABLE 0x00100000
|
||||
|
||||
//direct chip commands to the DAQ_REG_CHIP_CMDS register
|
||||
#define DAQ_NEXPOSURERS_SAFEST_MODE_ROW_CLK_BEFORE_MODE 0x00200000 //row clk is before main clk readout sequence
|
||||
#define DAQ_NEXPOSURERS_NORMAL_NONPARALLEL_MODE 0x00400000 //expose ->readout ->expose -> ..., with store is always closed
|
||||
#define DAQ_NEXPOSURERS_PARALLEL_MODE 0x00600000 //parallel acquire/read mode
|
||||
|
||||
//DAQ_NEXPOSURERS_READOUT_COMPLETE_IMAGES is old now hard-wired in the firmware that every image comes with a header
|
||||
//#define DAQ_NEXPOSURERS_READOUT_COMPLETE_IMAGES 0x00800000 //DAQ_IGNORE_INITIAL_CRAP and DAQ_CLKOUT_LAST_4_BITS_AND_RETURN_TO_START
|
||||
|
||||
#define DAQ_NEXPOSURERS_EXTERNAL_ENABLING 0x01000000
|
||||
#define DAQ_NEXPOSURERS_EXTERNAL_ENABLING_POLARITY 0x02000000
|
||||
#define DAQ_NEXPOSURERS_EXTERNAL_TRIGGER_POLARITY 0x04000000
|
||||
|
||||
#define DAQ_NEXPOSURERS_INTERNAL_ACQUISITION 0x00000000 //internally controlled
|
||||
#define DAQ_NEXPOSURERS_EXTERNAL_ACQUISITION_START 0x08000000 //external acquisition start
|
||||
#define DAQ_NEXPOSURERS_EXTERNAL_IMAGE_START 0x10000000 //external image start
|
||||
#define DAQ_NEXPOSURERS_EXTERNAL_IMAGE_START_AND_STOP 0x18000000 //externally controlly, external image start and stop
|
||||
|
||||
#define DAQ_NEXPOSURERS_ACTIVATE_AUTO_SUBIMAGING 0x20000000
|
||||
#define DAQ_NEXPOSURERS_ACTIVATE_RATE_CORRECTION 0x40000000
|
||||
|
||||
//#define DAQ_MASTER_HALF_MODULE 0x80000000 currently not used
|
||||
|
||||
|
||||
//chips static bits
|
||||
#define DAQ_STATIC_BIT_PROGRAM 0x00000001
|
||||
#define DAQ_STATIC_BIT_M4 0x00000002 //these are the status bits, not bit mode
|
||||
#define DAQ_STATIC_BIT_M8 0x00000004 //these are the status bits, not bit mode
|
||||
#define DAQ_STATIC_BIT_M12 0x00000000 //these are the status bits, not bit mode, ie. "00" is 12 bit mode
|
||||
#define DAQ_STATIC_BIT_CHIP_TEST 0x00000008
|
||||
#define DAQ_STATIC_BIT_ROTEST 0x00000010
|
||||
#define DAQ_CS_BAR_LEFT 0x00000020
|
||||
#define DAQ_CS_BAR_RIGHT 0x00000040
|
||||
|
||||
|
||||
//status flags
|
||||
#define DAQ_STATUS_DAQ_RUNNING 0x01
|
||||
#define DAQ_DATA_COLLISION_ERROR 0x02
|
||||
|
||||
#define DAQ_STATUS_CURRENT_M4 0x04
|
||||
#define DAQ_STATUS_CURRENT_M8 0x08
|
||||
#define DAQ_STATUS_CURRENT_M12 0x00 //in 12 bit mode both are cleared
|
||||
#define DAQ_STATUS_CURRENT_TESTMODE 0x10
|
||||
#define DAQ_STATUS_TOKEN_OUT 0x20
|
||||
#define DAQ_STATUS_SERIAL_OUT 0x40
|
||||
#define DAQ_STATUS_PIXELS_ARE_ENABLED 0x80
|
||||
#define DAQ_STATUS_DAQ_RUN_TOGGLE 0x200
|
||||
|
||||
//data delay registers
|
||||
#define CHIP_DATA_OUT_DELAY_REG_CTRL 1
|
||||
#define CHIP_DATA_OUT_DELAY_REG2 2
|
||||
#define CHIP_DATA_OUT_DELAY_REG3 3
|
||||
#define CHIP_DATA_OUT_DELAY_REG4 4
|
||||
#define CHIP_DATA_OUT_DELAY_SET 0x20000000
|
||||
|
||||
|
||||
//module configuration
|
||||
#define TOP_BIT_MASK 0x00f
|
||||
#define MASTER_BIT_MASK 0x200
|
||||
@@ -1,38 +0,0 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "Eiger.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char* argv[]){
|
||||
|
||||
cout<<"\n\n\n\n\n\n\n\n\n\n"<<endl;
|
||||
int n = (argc>1) ? atoi(argv[1]):5;
|
||||
|
||||
//Feb *f = new Feb();
|
||||
// f->Test();
|
||||
//delete f;
|
||||
//return 0;
|
||||
|
||||
Eiger* e = new Eiger();
|
||||
e->SetNImages(n);
|
||||
e->SetDynamicRange(32);
|
||||
e->SetExposureTime(0.02);
|
||||
e->SetExposurePeriod(0.050);
|
||||
e->StartAcquisition();
|
||||
|
||||
delete e;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,326 +0,0 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
|
||||
//return reversed 1 means good, 0 means failed
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
//#include <unistd.h>
|
||||
//#include <string.h>
|
||||
//#include <sys/mman.h>
|
||||
//#include <fcntl.h>
|
||||
|
||||
#include "xparameters.h"
|
||||
|
||||
#include "Feb.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
Feb::Feb(){
|
||||
|
||||
nfebs = 0;
|
||||
feb_numb = 0;
|
||||
|
||||
send_ndata = 0;
|
||||
send_buffer_size = 1026;
|
||||
send_data_raw = new unsigned int [send_buffer_size+1];
|
||||
send_data = &send_data_raw[1];
|
||||
|
||||
recv_ndata = 0;
|
||||
recv_buffer_size = 1026;
|
||||
recv_data_raw = new unsigned int [recv_buffer_size+1];
|
||||
recv_data = &recv_data_raw[1];
|
||||
|
||||
ll = new LocalLinkInterface(XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT_BASEADDR);
|
||||
|
||||
}
|
||||
|
||||
Feb::~Feb(){
|
||||
delete ll;
|
||||
if(feb_numb) delete [] feb_numb;
|
||||
delete [] send_data_raw;
|
||||
delete [] recv_data_raw;
|
||||
}
|
||||
|
||||
void Feb::SendCompleteFebList(unsigned int n,unsigned int* list){
|
||||
if(feb_numb) delete [] feb_numb;
|
||||
nfebs = n;
|
||||
feb_numb = new unsigned int [n];
|
||||
for(unsigned int i=0;i<n;i++) feb_numb[i] = list[i];
|
||||
}
|
||||
|
||||
bool Feb::WriteTo(unsigned int ch){
|
||||
if(ch>0xfff) return 0;
|
||||
|
||||
send_data_raw[0] = 0x90000000 | (ch<<16); //we
|
||||
if(ll->Write(4,send_data_raw)!=4) return 0;
|
||||
|
||||
send_data_raw[0] = 0xc0000000; //data
|
||||
return ((send_ndata+1)*4==ll->Write((send_ndata+1)*4,send_data_raw));
|
||||
}
|
||||
|
||||
bool Feb::ReadFrom(unsigned int ch, unsigned int ntrys){
|
||||
if(ch>=0xfff) return 0;
|
||||
|
||||
recv_data_raw[0] = 0xa0000000 | (ch<<16); //read data
|
||||
ll->Write(4,recv_data_raw);
|
||||
usleep(20);
|
||||
|
||||
recv_ndata=-1;
|
||||
for(unsigned int t=0;t<ntrys;t++){
|
||||
if((recv_ndata=ll->Read(recv_buffer_size*4,recv_data_raw)/4)>0){
|
||||
recv_ndata--;
|
||||
break;
|
||||
}
|
||||
cout<<"\t Read try number: "<<t<<endl;
|
||||
usleep(1000);
|
||||
}
|
||||
|
||||
return (recv_ndata>=0);
|
||||
}
|
||||
|
||||
void Feb::PrintData(){
|
||||
cout<<"Sent data: "<<send_ndata<<endl;
|
||||
for(int i=0;i<send_ndata;i++) cout<<"\t"<<i<<")"<<setw(14)<<send_data[i]<<" ("<<hex<<send_data[i]<<")"<<dec<<endl;
|
||||
cout<<"Receive data: "<<recv_ndata<<endl;
|
||||
for(int i=0;i<recv_ndata;i++) cout<<"\t"<<i<<")"<<setw(14)<<recv_data[i]<<" ("<<hex<<recv_data[i]<<")"<<dec<<endl;
|
||||
cout<<endl<<endl;
|
||||
}
|
||||
|
||||
|
||||
bool Feb::CheckHeader(unsigned int valid_bit_mask, bool print_error_info){
|
||||
|
||||
bool header_returned_is_ok = (send_data[0] & valid_bit_mask)==(recv_data[0] & valid_bit_mask);
|
||||
|
||||
if(print_error_info && !header_returned_is_ok){
|
||||
cout<<"Error: Command received not the same as command recieved."<<endl;
|
||||
cout<<"\t\t Header sent: "<<dec<<send_data[0]<<" ("<<hex<<send_data[0]<<") recieved: "<<dec<<recv_data[0]<<" ("<<hex<<recv_data[0]<<")"<<dec<<endl;
|
||||
if(send_ndata>1&&recv_ndata>1){
|
||||
cout<<"\t\t Tail sent: "<<dec<<send_data[send_ndata-1]<<" ("<<hex<<send_data[send_ndata-1]<<") recieved: "<<dec<<recv_data[recv_ndata-1]<<" ("<<hex<<recv_data[recv_ndata-1]<<")"<<dec<<endl;
|
||||
}else{
|
||||
cout<<"Error printing tail, too little data nsent = "<<send_ndata<<", nrecv = "<<recv_ndata<<"."<<endl;
|
||||
}
|
||||
PrintData();
|
||||
}
|
||||
return header_returned_is_ok;
|
||||
}
|
||||
|
||||
|
||||
bool Feb::CheckTail(unsigned int valid_bit_mask){
|
||||
if(send_ndata<=1&&recv_ndata<=1){
|
||||
cout<<"Error checking tail, too little data nsent = "<<send_ndata<<", nrecv = "<<recv_ndata<<"."<<endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int the_tail = recv_data[recv_ndata-1]&valid_bit_mask;
|
||||
if(the_tail!=0){
|
||||
cout<<"Error returned in tail: "<<hex<<the_tail<<" "<<dec<<"("<<the_tail<<")"<<endl;
|
||||
if(the_tail&0x10000000) cout<<"\t\tBusy flag address error."<<endl;
|
||||
if(the_tail&0x20000000) cout<<"\t\tRead register address error."<<endl;
|
||||
if(the_tail&0x40000000) cout<<"\t\tWrite register address error."<<endl;
|
||||
if(the_tail&0x80000000) cout<<"\t\tBram number error."<<endl;
|
||||
if(the_tail&0x08000000) cout<<"\t\tFifo to read from error."<<endl;
|
||||
if(the_tail&0x3ff) cout<<"\t\tNumber of data send error."<<endl;
|
||||
return 0; //error
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
bool Feb::CheckCommunication(){
|
||||
send_data_raw[0] = 0x8fff0000; //rst-all serial coms and lls
|
||||
if(ll->Write(4,send_data_raw)!=4) return 0;
|
||||
|
||||
cout<<"Feb::CheckingCommunication ...."<<endl;
|
||||
while((ll->Read(recv_buffer_size*4,recv_data_raw)/4)>0) cout<<"\t) Cleanning buffer ..."<<endl;
|
||||
|
||||
return SetByteOrder();
|
||||
}
|
||||
|
||||
|
||||
bool Feb::SetByteOrder(){
|
||||
|
||||
send_ndata = 2;
|
||||
send_data[0] = 0; //header
|
||||
send_data[1] = 0; //tail
|
||||
|
||||
unsigned int dst = 0xff;
|
||||
for(unsigned int i=0;i<nfebs;i++) dst = (dst | feb_numb[i]); //get sub dst bits (left right in this case)
|
||||
bool passed = WriteTo(dst);
|
||||
|
||||
for(unsigned int i=0;i<nfebs;i++){
|
||||
cout<<"\t"<<i<<") Set Byte Order .............. ";
|
||||
unsigned int current_passed = ReadFrom(feb_numb[i])&&(recv_ndata==2)&&CheckHeader();
|
||||
if(current_passed) cout<<"passed."<<endl;
|
||||
else cout<<"failed."<<endl;
|
||||
passed&=current_passed;
|
||||
}
|
||||
cout<<endl;
|
||||
|
||||
return passed;
|
||||
}
|
||||
|
||||
/*
|
||||
bool Feb::CheckSubNumber(unsigned int sub_num){
|
||||
if(sub_num>=nfebs){
|
||||
cout<<"Error invalid sub number "<<sub_num<<" must be less than "<<nfebs<<"."<<endl;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool Feb::SetStartOnEndOnFebs(int sub_num_s, unsigned int& start_on, unsigned int& end_on){
|
||||
// -1 means write to all
|
||||
|
||||
if(sub_num_s<=-2){
|
||||
cout<<"Error bad subnumber "<<sub_num_s<<"."<<endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
start_on = sub_num_s!=-1 ? sub_num_s : 0;
|
||||
end_on = sub_num_s!=-1 ? sub_num_s : nfebs - 1;
|
||||
|
||||
return CheckSubNumber(start_on);
|
||||
}
|
||||
*/
|
||||
|
||||
bool Feb::ReadRegister(unsigned int sub_num, unsigned int reg_num,unsigned int& value_read){
|
||||
return ReadRegisters(sub_num,1,®_num,&value_read);
|
||||
}
|
||||
|
||||
|
||||
bool Feb::ReadRegisters(unsigned int sub_num, unsigned int nreads, unsigned int* reg_nums,unsigned int* values_read){
|
||||
//here cout<<"Reading Register ...."<<endl;
|
||||
|
||||
nreads &= 0x3ff; //10 bits
|
||||
if(!nreads||nreads>send_buffer_size-2) return 0;
|
||||
|
||||
send_ndata = nreads+2;
|
||||
send_data[0] = 0x20000000 | nreads << 14; //cmd -> read "00" , nreads
|
||||
|
||||
for(unsigned int i=0;i<nreads;i++) send_data[i+1]=reg_nums[i];
|
||||
send_data[nreads+1] = 0; //tail
|
||||
|
||||
if(!WriteTo(sub_num)||!ReadFrom(sub_num)||recv_ndata!=int(nreads+2)||!CheckHeader()||!CheckTail()){
|
||||
PrintData();
|
||||
cout<<"Error reading register."<<endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
for(unsigned int i=0;i<nreads;i++) values_read[i] = recv_data[i+1];
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool Feb::WriteRegister(unsigned int sub_num, unsigned int reg_num,unsigned int value, bool wait_on, unsigned int wait_on_address){
|
||||
return WriteRegisters(sub_num,1,®_num,&value,&wait_on,&wait_on_address);
|
||||
}
|
||||
|
||||
bool Feb::WriteRegisters(unsigned int sub_num, unsigned int nwrites, unsigned int* reg_nums, unsigned int* values, bool* wait_ons, unsigned int* wait_on_addresses){
|
||||
|
||||
// sub_num == 0xfff means write to all
|
||||
|
||||
nwrites &= 0x3ff; //10 bits
|
||||
if(!nwrites||nwrites>send_buffer_size-2) return 0;
|
||||
|
||||
//cout<<"Write register : "<<this<<" "<<s_num<<" "<<nwrites<<" "<<reg_nums<<" "<<values<<" "<<wait_ons<<" "<<wait_on_addresses<<endl;
|
||||
send_ndata = 2*nwrites+2;
|
||||
send_data[0] = 0x80000000 | nwrites << 14; //cmd -> write nwrites and how many
|
||||
send_data[2*nwrites+1] = 0; //tail
|
||||
|
||||
for(unsigned int i=0;i<nwrites;i++) send_data[2*i+1] = 0x3fff®_nums[i]; // register address data_in(13 downto 0)
|
||||
for(unsigned int i=0;i<nwrites;i++) send_data[2*i+2] = values[i]; // value is data_in(31 downto 0)
|
||||
// wait on busy data(28), address of busy flag data(27 downto 14)
|
||||
if(wait_ons&&wait_on_addresses) for(unsigned int i=0;i<nwrites;i++) send_data[2*i+1] |= (wait_ons[i]<<28 | (0x3fff&wait_on_addresses[i])<<14);
|
||||
|
||||
if(!WriteTo(sub_num)){
|
||||
cout<<sub_num<<") Error writing register(s)."<<endl;
|
||||
PrintData();
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool passed = 1;
|
||||
unsigned int n = (sub_num&0xff)==0xff ? nfebs : 1;
|
||||
unsigned int* nums = (sub_num&0xff)==0xff ? feb_numb : &sub_num;
|
||||
for(unsigned int i=0;i<n;i++){
|
||||
if((sub_num&0xf00&(nums[i]))==0) continue;
|
||||
if(!ReadFrom(nums[i])||recv_ndata!=2||!CheckHeader()){
|
||||
cout<<nums[i]<<") Error writing register(s) response."<<endl;
|
||||
PrintData();
|
||||
passed = 0;
|
||||
}else{
|
||||
passed = passed && CheckTail();
|
||||
}
|
||||
}
|
||||
|
||||
return passed;
|
||||
}
|
||||
|
||||
|
||||
bool Feb::WriteMemory(unsigned int sub_num, unsigned int mem_num, unsigned int start_address, unsigned int nwrites, unsigned int *values){
|
||||
// -1 means write to all
|
||||
|
||||
mem_num &= 0x3f; //6 bits
|
||||
start_address &= 0x3fff; //14 bits
|
||||
nwrites &= 0x3ff; //10 bits
|
||||
if(!nwrites||nwrites>send_buffer_size-2) return 0;
|
||||
|
||||
send_ndata = nwrites+2;
|
||||
send_data[0] = 0xc0000000 | mem_num << 24 | nwrites << 14 | start_address; //cmd -> write to memory, nwrites, mem number, start address
|
||||
send_data[nwrites+1] = 0; //tail
|
||||
for(unsigned int i=0;i<nwrites;i++) send_data[i+1] = values[i];
|
||||
|
||||
|
||||
if(!WriteTo(sub_num)){
|
||||
cout<<sub_num<<") Error writing memory."<<endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool passed = 1;
|
||||
unsigned int n = (sub_num&0xff)==0xff ? nfebs : 1;
|
||||
unsigned int* nums = (sub_num&0xff)==0xff ? feb_numb : &sub_num;
|
||||
for(unsigned int i=0;i<n;i++){
|
||||
if((sub_num&0xf00&(nums[i]))==0) continue;
|
||||
if(!ReadFrom(nums[i])||recv_ndata!=2||!CheckHeader()){
|
||||
cout<<nums[i]<<") Error writing memory response."<<endl;
|
||||
PrintData();
|
||||
passed = 0;
|
||||
}else{
|
||||
passed = passed && CheckTail();
|
||||
}
|
||||
}
|
||||
// unsigned int n = sub_num==0xfff ? nfebs : 1;
|
||||
// unsigned int* nums = sub_num==0xfff ? feb_numb : &sub_num;
|
||||
// for(unsigned int i=0;i<n;i++){
|
||||
|
||||
return passed;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Feb::Test(){//int sub_num_s, unsigned int mem_num, unsigned int start_address, unsigned int nwrites, unsigned int *values){
|
||||
// -1 means write to all
|
||||
|
||||
unsigned int reg_nums[10]={0,1,2,3,1,2,3,1,2,3};
|
||||
|
||||
cout<<"Test"<<endl<<endl<<endl<<endl;
|
||||
|
||||
unsigned int value = 0;
|
||||
for(unsigned int i=0;i<10;i++){
|
||||
WriteRegister(0xfff,reg_nums[i%10],i);
|
||||
ReadRegister(256,reg_nums[i%10],value);
|
||||
cout<<i<<" "<<value<<endl;
|
||||
ReadRegister(512,reg_nums[i%10],value);
|
||||
cout<<i<<" "<<value<<endl;
|
||||
WriteMemory(0xfff,0,0,10,reg_nums);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -607,14 +607,22 @@ int Feb_Control_SendHighVoltage(int dacvalue){
|
||||
char buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE];
|
||||
buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-2]='\0';
|
||||
buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-1]='\n';
|
||||
int n = 0;
|
||||
int n;
|
||||
sprintf(buffer,"p%d ",dacvalue);
|
||||
n = write(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
||||
if (n < 0) {
|
||||
cprintf(RED,"\nWarning: Error writing to i2c bus\n");
|
||||
return 0;
|
||||
}
|
||||
#ifdef VERBOSEI
|
||||
cprintf(BLUE,"Sent %d Bytes\n", n);
|
||||
#endif
|
||||
//ok/fail
|
||||
n = read(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
||||
if (n < 0) {
|
||||
cprintf(RED,"\nWarning: Error reading from i2c bus\n");
|
||||
return 0;
|
||||
}
|
||||
#ifdef VERBOSEI
|
||||
cprintf(BLUE,"Received %d Bytes\n", n);
|
||||
#endif
|
||||
@@ -686,12 +694,20 @@ int Feb_Control_ReceiveHighVoltage(unsigned int* value){
|
||||
//request
|
||||
strcpy(buffer,"g ");
|
||||
n = write(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
||||
if (n < 0) {
|
||||
cprintf(RED,"\nWarning: Error writing to i2c bus\n");
|
||||
return 0;
|
||||
}
|
||||
#ifdef VERBOSEI
|
||||
cprintf(BLUE,"Sent %d Bytes\n", n);
|
||||
#endif
|
||||
|
||||
//ok/fail
|
||||
n = read(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
||||
if (n < 0) {
|
||||
cprintf(RED,"\nWarning: Error reading from i2c bus\n");
|
||||
return 0;
|
||||
}
|
||||
#ifdef VERBOSEI
|
||||
cprintf(BLUE,"Received %d Bytes\n", n);
|
||||
#endif
|
||||
@@ -701,6 +717,10 @@ int Feb_Control_ReceiveHighVoltage(unsigned int* value){
|
||||
}
|
||||
|
||||
n = read(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
||||
if (n < 0) {
|
||||
cprintf(RED,"\nWarning: Error reading from i2c bus\n");
|
||||
return 0;
|
||||
}
|
||||
#ifdef VERBOSEI
|
||||
cprintf(BLUE,"Received %d Bytes\n", n);
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,175 +0,0 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
//#include <unistd.h>
|
||||
//#include <string.h>
|
||||
//#include <sys/mman.h>
|
||||
//#include <fcntl.h>
|
||||
|
||||
#include "xparameters.h"
|
||||
|
||||
#include "FebInterface.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
FebInterface::FebInterface(){
|
||||
|
||||
nfebs = 0;
|
||||
feb_numb = 0;
|
||||
|
||||
send_ndata = 0;
|
||||
send_buffer_size = 1026;
|
||||
send_data_raw = new unsigned int [send_buffer_size+1];
|
||||
send_data = &send_data_raw[1];
|
||||
|
||||
recv_ndata = 0;
|
||||
recv_buffer_size = 1026;
|
||||
recv_data_raw = new unsigned int [recv_buffer_size+1];
|
||||
recv_data = &recv_data_raw[1];
|
||||
|
||||
ll = new LocalLinkInterface(XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT_BASEADDR);
|
||||
|
||||
}
|
||||
|
||||
FebInterface::~FebInterface(){
|
||||
delete ll;
|
||||
if(feb_numb) delete [] feb_numb;
|
||||
delete [] send_data_raw;
|
||||
delete [] recv_data_raw;
|
||||
}
|
||||
|
||||
void FebInterface::SendCompleteList(unsigned int n,unsigned int* list){
|
||||
if(feb_numb) delete [] feb_numb;
|
||||
nfebs = n;
|
||||
feb_numb = new unsigned int [n];
|
||||
for(unsigned int i=0;i<n;i++) feb_numb[i] = list[i];
|
||||
}
|
||||
|
||||
bool FebInterface::WriteTo(unsigned int ch){
|
||||
if(ch>0xfff) return 0;
|
||||
|
||||
send_data_raw[0] = 0x8fff0000;
|
||||
if(ll->Write(4,send_data_raw)!=4) return 0;
|
||||
|
||||
send_data_raw[0] = 0x90000000 | (ch<<16);
|
||||
if(ll->Write(4,send_data_raw)!=4) return 0;
|
||||
|
||||
send_data_raw[0] = 0xc0000000;
|
||||
return ((send_ndata+1)*4==ll->Write((send_ndata+1)*4,send_data_raw));
|
||||
}
|
||||
|
||||
bool FebInterface::ReadFrom(unsigned int ch, unsigned int ntrys){
|
||||
if(ch>=0xfff) return 0;
|
||||
|
||||
recv_data_raw[0] = 0xa0000000 | (ch<<16);
|
||||
ll->Write(4,recv_data_raw);
|
||||
usleep(20);
|
||||
|
||||
recv_ndata=-1;
|
||||
for(unsigned int t=0;t<ntrys;t++){
|
||||
if((recv_ndata=ll->Read(recv_buffer_size*4,recv_data_raw)/4)>0){
|
||||
recv_ndata--;
|
||||
break;
|
||||
}
|
||||
usleep(1000);
|
||||
}
|
||||
|
||||
return (recv_ndata>=0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool FebInterface::SetByteOrder(){
|
||||
|
||||
send_data_raw[0] = 0x8fff0000;
|
||||
if(ll->Write(4,send_data_raw)!=4) return 0;
|
||||
|
||||
send_ndata = 2;
|
||||
send_data[0] = 0;
|
||||
send_data[1] = 0;
|
||||
|
||||
unsigned int dst = 0xff;
|
||||
for(unsigned int i=0;i<nfebs;i++) dst = (dst | feb_numb[i]);
|
||||
bool passed = WriteTo(dst);
|
||||
|
||||
return passed;
|
||||
}
|
||||
|
||||
|
||||
bool FebInterface::ReadRegister(unsigned int sub_num, unsigned int reg_num,unsigned int& value_read){
|
||||
return ReadRegisters(sub_num,1,®_num,&value_read);
|
||||
}
|
||||
|
||||
|
||||
bool FebInterface::ReadRegisters(unsigned int sub_num, unsigned int nreads, unsigned int* reg_nums,unsigned int* values_read){
|
||||
//here cout<<"Reading Register ...."<<endl;
|
||||
|
||||
nreads &= 0x3ff;
|
||||
if(!nreads||nreads>send_buffer_size-2) return 0;
|
||||
|
||||
send_ndata = nreads+2;
|
||||
send_data[0] = 0x20000000 | nreads << 14;
|
||||
|
||||
for(unsigned int i=0;i<nreads;i++) send_data[i+1]=reg_nums[i];
|
||||
send_data[nreads+1] = 0;
|
||||
|
||||
if(!WriteTo(sub_num)||!ReadFrom(sub_num)||recv_ndata!=int(nreads+2)) return 0;
|
||||
|
||||
for(unsigned int i=0;i<nreads;i++) values_read[i] = recv_data[i+1];
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool FebInterface::WriteRegister(unsigned int sub_num, unsigned int reg_num,unsigned int value, bool wait_on, unsigned int wait_on_address){
|
||||
return WriteRegisters(sub_num,1,®_num,&value,&wait_on,&wait_on_address);
|
||||
}
|
||||
|
||||
bool FebInterface::WriteRegisters(unsigned int sub_num, unsigned int nwrites, unsigned int* reg_nums, unsigned int* values, bool* wait_ons, unsigned int* wait_on_addresses){
|
||||
|
||||
nwrites &= 0x3ff; //10 bits
|
||||
if(!nwrites||2*nwrites>send_buffer_size-2) return 0;
|
||||
|
||||
//cout<<"Write register : "<<this<<" "<<s_num<<" "<<nwrites<<" "<<reg_nums<<" "<<values<<" "<<wait_ons<<" "<<wait_on_addresses<<endl;
|
||||
send_ndata = 2*nwrites+2;
|
||||
send_data[0] = 0x80000000 | nwrites << 14;
|
||||
send_data[2*nwrites+1] = 0;
|
||||
|
||||
for(unsigned int i=0;i<nwrites;i++) send_data[2*i+1] = 0x3fff®_nums[i];
|
||||
for(unsigned int i=0;i<nwrites;i++) send_data[2*i+2] = values[i];
|
||||
// wait on busy data(28), address of busy flag data(27 downto 14)
|
||||
if(wait_ons&&wait_on_addresses) for(unsigned int i=0;i<nwrites;i++) send_data[2*i+1] |= (wait_ons[i]<<28 | (0x3fff&wait_on_addresses[i])<<14);
|
||||
|
||||
if(!WriteTo(sub_num)) return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
bool FebInterface::WriteMemory(unsigned int sub_num, unsigned int mem_num, unsigned int start_address, unsigned int nwrites, unsigned int *values){
|
||||
// -1 means write to all
|
||||
|
||||
mem_num &= 0x3f;
|
||||
start_address &= 0x3fff;
|
||||
nwrites &= 0x3ff;
|
||||
if(!nwrites||nwrites>send_buffer_size-2) {cout<<"error herer: nwrites:"<<nwrites<<endl;return 0;}//*d-1026
|
||||
|
||||
send_ndata = nwrites+2;//*d-1025
|
||||
send_data[0] = 0xc0000000 | mem_num << 24 | nwrites << 14 | start_address; //cmd -> write to memory, nwrites, mem number, start address
|
||||
send_data[nwrites+1] = 0;
|
||||
for(unsigned int i=0;i<nwrites;i++) send_data[i+1] = values[i];
|
||||
|
||||
|
||||
if(!WriteTo(sub_num)) return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -156,27 +156,27 @@
|
||||
#define FEB_REG_STATUS 0xa
|
||||
|
||||
//1g counters
|
||||
#define ONE_GIGA_LEFT_FRAME_SEND_COUNTER 0x04
|
||||
#define ONE_GIGA_LEFT_PKT_SEND_COUNTER 0x24
|
||||
#define ONE_GIGA_LEFT_INDEX_LSB_COUNTER 0x04
|
||||
#define ONE_GIGA_LEFT_INDEX_MSB_COUNTER 0x24
|
||||
|
||||
#define ONE_GIGA_LEFT_TXN_DELAY_COUNTER 0x104
|
||||
#define ONE_GIGA_LEFT_FRAME_DELAY_COUNTER 0x124
|
||||
|
||||
#define ONE_GIGA_RIGHT_FRAME_SEND_COUNTER 0x44
|
||||
#define ONE_GIGA_RIGHT_PKT_SEND_COUNTER 0x64
|
||||
#define ONE_GIGA_RIGHT_INDEX_LSB_COUNTER 0x44
|
||||
#define ONE_GIGA_RIGHT_INDEX_MSB_COUNTER 0x64
|
||||
|
||||
#define ONE_GIGA_RIGHT_TXN_DELAY_COUNTER 0x144
|
||||
#define ONE_GIGA_RIGHT_FRAME_DELAY_COUNTER 0x164
|
||||
|
||||
//10g counters
|
||||
#define TEN_GIGA_LEFT_FRAME_SEND_COUNTER 0x84
|
||||
#define TEN_GIGA_LEFT_PKT_SEND_COUNTER 0xa4
|
||||
#define TEN_GIGA_LEFT_INDEX_LSB_COUNTER 0x84
|
||||
#define TEN_GIGA_LEFT_INDEX_MSB_COUNTER 0xa4
|
||||
|
||||
#define TEN_GIGA_LEFT_TXN_DELAY_COUNTER 0x184
|
||||
#define TEN_GIGA_LEFT_FRAME_DELAY_COUNTER 0x1a4
|
||||
|
||||
#define TEN_GIGA_RIGHT_FRAME_SEND_COUNTER 0xc4
|
||||
#define TEN_GIGA_RIGHT_PKT_SEND_COUNTER 0xe4
|
||||
#define TEN_GIGA_RIGHT_INDEX_LSB_COUNTER 0xc4
|
||||
#define TEN_GIGA_RIGHT_INDEX_MSB_COUNTER 0xe4
|
||||
|
||||
#define TEN_GIGA_RIGHT_TXN_DELAY_COUNTER 0x1c4
|
||||
#define TEN_GIGA_RIGHT_FRAME_DELAY_COUNTER 0x1e4
|
||||
|
||||
@@ -1,604 +0,0 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
* @developed for running Eiger at cSAXS
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <algorithm> // std::remove_if
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "FebControl.h"
|
||||
#include "slsDetectorServer_defs.h" //include port number
|
||||
|
||||
using namespace std;
|
||||
|
||||
enum cmd_string {evNotFound,
|
||||
evReinitialize,evReset,
|
||||
|
||||
evSetInputDelays,
|
||||
evSetDACValue,evGetDACValue,evSetDACVoltage,evGetDACVoltage,evSetHighVoltage,//evGetHighVoltage,
|
||||
|
||||
evSetTrimBits,
|
||||
evSetAllTrimBits,
|
||||
evGetTrimBits,
|
||||
//evLoadTrimBitFile,
|
||||
|
||||
evSetBitMode,
|
||||
evSetPhotonEnergy,
|
||||
// evSetPhotonEnergyCalibrationParameters,evActivateRateCorrection,evDeactivateRateCorrection,evSetRateCorrectionTau,
|
||||
|
||||
evSetReadoutSpeed,evSetReadoutMode,
|
||||
|
||||
//temp solution
|
||||
// evNotFound1,evNotFound2,evNotFound3,
|
||||
|
||||
evSetNumberOfExposures,evSetExposureTime,evSetExposurePeriod,
|
||||
// evSetTriggerPolarityToPositive,evSetTriggerPolarityToNegative,
|
||||
evSetTriggerMode,
|
||||
evSetExternalGating,
|
||||
evStartAcquisition,evStopAcquisition,evIsDaqStillRunning,
|
||||
evWaitUntilDaqFinished,
|
||||
evExitServer
|
||||
};
|
||||
|
||||
map<string, cmd_string> enum_map;
|
||||
|
||||
void init(){
|
||||
|
||||
enum_map["reinitialize"] = evReinitialize;
|
||||
enum_map["reset"] = evReset;
|
||||
enum_map["setinputdelays"] = evSetInputDelays;
|
||||
enum_map["setdacvalue"] = evSetDACValue;
|
||||
enum_map["getdacvalue"] = evGetDACValue;
|
||||
enum_map["setdacvoltage"] = evSetDACVoltage;
|
||||
enum_map["getdacvoltage"] = evGetDACVoltage;
|
||||
enum_map["sethighvoltage"] = evSetHighVoltage;
|
||||
enum_map["settrimbits"] = evSetTrimBits;
|
||||
enum_map["setalltrimbits"] = evSetAllTrimBits;
|
||||
enum_map["gettrimbits"] = evGetTrimBits;
|
||||
// enum_map["loadtrimbitfile"] = evLoadTrimBitFile;
|
||||
enum_map["setbitmode"] = evSetBitMode;
|
||||
enum_map["setphotonenergy"] = evSetPhotonEnergy;
|
||||
// enum_map["setphotonenergycalibrationparameters"] = evSetPhotonEnergyCalibrationParameters;
|
||||
// enum_map["activateratecorrection"] = evActivateRateCorrection;
|
||||
// enum_map["deactivateratecorrection"] = evDeactivateRateCorrection;
|
||||
// enum_map["setratecorrectiontau"] = evSetRateCorrectionTau;
|
||||
enum_map["setreadoutspeed"] = evSetReadoutSpeed;
|
||||
enum_map["setreadoutmode"] = evSetReadoutMode;
|
||||
enum_map["setnumberofexposures"] = evSetNumberOfExposures;
|
||||
enum_map["setexposuretime"] = evSetExposureTime;
|
||||
enum_map["setexposureperiod"] = evSetExposurePeriod;
|
||||
// enum_map["settriggerpolaritytopositive"] = evSetTriggerPolarityToPositive;
|
||||
// enum_map["settriggerpolaritytonegative"] = evSetTriggerPolarityToNegative;
|
||||
enum_map["settriggermode"] = evSetTriggerMode;
|
||||
enum_map["setexternalgating"] = evSetExternalGating;
|
||||
enum_map["startacquisition"] = evStartAcquisition;
|
||||
enum_map["stopacquisition"] = evStopAcquisition;
|
||||
enum_map["isdaqstillrunning"] = evIsDaqStillRunning;
|
||||
enum_map["waituntildaqfinished"] = evWaitUntilDaqFinished;
|
||||
enum_map["exitserver"] = evExitServer;
|
||||
}
|
||||
|
||||
int server_list_s;
|
||||
int server_conn_s;
|
||||
int AccpetConnectionAndWaitForData(char* buffer, int maxlength);
|
||||
bool WriteNClose(const char* buffer, int length);
|
||||
bool SetupListenSocket(unsigned short int port);
|
||||
|
||||
|
||||
string LowerCase(string str);
|
||||
string GetNextString(string str,bool start_from_beginning=0);
|
||||
void AddNumber(string& str, int n, int location=-1, bool space_after=0);//-1 means append
|
||||
void AddNumber(string& str, float v, int location=-1, bool space_after=0);//-1 means append
|
||||
|
||||
int main(int argc, char* argv[]){
|
||||
cout<<endl<<endl;
|
||||
|
||||
/*
|
||||
if(argc<2){
|
||||
cout<<"Usage: feb_server port_number"<<endl<<endl;
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
|
||||
init();
|
||||
|
||||
FebControl *feb_controler = new FebControl();
|
||||
|
||||
unsigned short int port_number = FEB_PORT;
|
||||
if(!SetupListenSocket(port_number)) return 1;
|
||||
|
||||
|
||||
int length=270000;
|
||||
char data[270000];
|
||||
|
||||
int stop = 0;
|
||||
time_t rawtime;
|
||||
struct tm *timeinfo;
|
||||
|
||||
|
||||
while(!stop){
|
||||
|
||||
/*cout<<"Waiting for command -> "<<flush;*/
|
||||
int nread = AccpetConnectionAndWaitForData(data,length);
|
||||
|
||||
if(nread<=0) return 0;
|
||||
|
||||
time(&rawtime); timeinfo=localtime(&rawtime);
|
||||
cout<<asctime(timeinfo);
|
||||
/*cout<<" Command received: "<<data<<endl;*/
|
||||
|
||||
|
||||
|
||||
string tmp_str[5];
|
||||
float v[4];//,v2,v3,v4,v5;
|
||||
int n[5];
|
||||
|
||||
|
||||
|
||||
string cmd = GetNextString(data,1);
|
||||
int ret_val = 1;
|
||||
|
||||
string return_message = "";/*\n\n\tCommand recieved: ";
|
||||
return_message.append(data);
|
||||
return_message.append("\n");
|
||||
*/
|
||||
int return_start_pos;
|
||||
while(cmd.length()>0){
|
||||
int ret_parameter = 0;
|
||||
return_start_pos = return_message.length();
|
||||
|
||||
switch(enum_map.find(LowerCase(cmd))->second){
|
||||
|
||||
case evReinitialize :
|
||||
if(feb_controler->Init()){
|
||||
return_message.append("\tExecuted: Reinitialize\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: Reinitialize\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evReset :
|
||||
if(feb_controler->Reset()){
|
||||
return_message.append("\tExecuted: Reset\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: Reset\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case evSetInputDelays :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
n[0] = atoi(tmp_str[0].data());
|
||||
|
||||
if(tmp_str[0].length()>0&&feb_controler->SetIDelays(0,n[0])){
|
||||
return_message.append("\tExecuted: SetInputDelays "); AddNumber(return_message,n[0]); return_message.append("\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetInputDelays <delay>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case evSetDACValue :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
tmp_str[1] = GetNextString(data);
|
||||
n[0] = atoi(tmp_str[1].data());
|
||||
|
||||
if(tmp_str[0].length()>0&&tmp_str[1].length()>0&&feb_controler->SetDAC(tmp_str[0],n[0])){
|
||||
return_message.append("\tExecuted: SetDACValue "); return_message.append(tmp_str[0]+" "); AddNumber(return_message,n[0]); return_message.append("\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetDACValue <dac_name> <value>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evGetDACValue :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
|
||||
if(tmp_str[0].length()>0&&feb_controler->GetDAC(tmp_str[0],ret_parameter)){
|
||||
return_message.append("\tExecuted: GetDACValue "); return_message.append(tmp_str[0]+" -> ");AddNumber(return_message,ret_parameter); return_message.append("\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: GetDACValue <dac_name>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evSetDACVoltage :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
tmp_str[1] = GetNextString(data);
|
||||
n[0] = atoi(tmp_str[1].data());
|
||||
|
||||
if(tmp_str[0].length()>0&&tmp_str[1].length()>0&&feb_controler->SetDAC(tmp_str[0],n[0],1)){
|
||||
return_message.append("\tExecuted: SetDACVoltage "); return_message.append(tmp_str[0]+" "); AddNumber(return_message,n[0]); return_message.append("\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetDACVoltage <dac_name> <voltage_mV>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evGetDACVoltage :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
|
||||
if(tmp_str[0].length()>0&&feb_controler->GetDAC(tmp_str[0],ret_parameter,1)){
|
||||
return_message.append("\tExecuted: GetDACVoltage "); return_message.append(tmp_str[0]+" -> ");AddNumber(return_message,ret_parameter); return_message.append(" mV\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: GetDACVoltage <dac_name>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evSetHighVoltage :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
v[0] = atof(tmp_str[0].data());
|
||||
|
||||
if(tmp_str[0].length()>0&&feb_controler->SetHighVoltage(v[0])){
|
||||
return_message.append("\tExecuted: SetHighVoltage "); AddNumber(return_message,v[0]); return_message.append("\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetHighVoltage <voltage>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evSetTrimBits :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
if(feb_controler->LoadTrimbitFile()){
|
||||
/* if(1){*/
|
||||
/*tmp_str[0] = GetNextString(data);
|
||||
feb_controler->SetTrimbits(0,(unsigned char*)(tmp_str[0].c_str()));*/
|
||||
return_message.append("\tExecuted: SetTrimBits\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetTrimBits \n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evSetAllTrimBits :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
n[0] = atoi(tmp_str[0].data());
|
||||
if(feb_controler->SaveAllTrimbitsTo(n[0])){
|
||||
/*feb_controler->SetTrimbits(0,(unsigned char*)(tmp_str[0].c_str()));*/
|
||||
/*if(1){*/
|
||||
return_message.append("\tExecuted: SetAllTrimBits\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetAllTrimBits \n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case evGetTrimBits :
|
||||
if(feb_controler->SaveTrimbitFile()){
|
||||
/*if(1){*/
|
||||
/*tmp_str[0] = GetNextString(data);
|
||||
feb_controler->GetTrimbits();*/
|
||||
return_message.append("\tExecuted: GetTrimBits\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: GetTrimBits \n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
// case evLoadTrimBitFile :
|
||||
|
||||
case evSetBitMode :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
n[0] = atoi(tmp_str[0].data());
|
||||
|
||||
if(tmp_str[0].length()>0&&feb_controler->SetDynamicRange(n[0])){
|
||||
return_message.append("\tExecuted: SetBitMode "); AddNumber(return_message,n[0]); return_message.append("\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetBitMode <mode 4,8,16,32>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evSetPhotonEnergy :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
n[0] = atoi(tmp_str[0].data());
|
||||
if(tmp_str[0].length()>0&&feb_controler->SetPhotonEnergy(n[0])){
|
||||
return_message.append("\tExecuted: SetPhotonEnergy "); AddNumber(return_message,n[0]); return_message.append("\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetPhotonEnergy <energy eV>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
// case evSetPhotonEnergyCalibrationParameters :
|
||||
// case evActivateRateCorrection :
|
||||
// case evDeactivateRateCorrection :
|
||||
// case evSetRateCorrectionTau :
|
||||
|
||||
|
||||
case evSetReadoutSpeed :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
n[0] = atoi(tmp_str[0].data());
|
||||
if(tmp_str[0].length()>0&&feb_controler->SetReadoutSpeed(n[0])){
|
||||
return_message.append("\tExecuted: SetReadoutSpeed "); AddNumber(return_message,n[0]); return_message.append("\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetReadoutSpeed <speed 0-full 1-half 2-quarter 3-super_slow>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evSetReadoutMode :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
n[0] = atoi(tmp_str[0].data());
|
||||
if(tmp_str[0].length()>0&&feb_controler->SetReadoutMode(n[0])){
|
||||
return_message.append("\tExecuted: SetReadoutMode "); AddNumber(return_message,n[0]); return_message.append("\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetReadoutMode <mode 0->parallel,1->non-parallel,2-> safe_mode>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evSetNumberOfExposures :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
n[0] = atoi(tmp_str[0].data());
|
||||
if(tmp_str[0].length()>0&&feb_controler->SetNExposures(n[0])){
|
||||
return_message.append("\tExecuted: SetNumberOfExposures "); AddNumber(return_message,n[0]); return_message.append("\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetNumberOfExposures <n>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evSetExposureTime :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
v[0] = atof(tmp_str[0].data());
|
||||
if(tmp_str[0].length()>0&&feb_controler->SetExposureTime(v[0])){
|
||||
return_message.append("\tExecuted: SetExposureTime "); AddNumber(return_message,v[0]); return_message.append("\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetExposureTime <t_seconds>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evSetExposurePeriod :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
v[0] = atof(tmp_str[0].data());
|
||||
if(tmp_str[0].length()>0&&feb_controler->SetExposurePeriod(v[0])){
|
||||
return_message.append("\tExecuted: SetExposurePeriod "); AddNumber(return_message,v[0]); return_message.append("\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetExposurePeriod <t_seconds>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
// case evSetTriggerPolarityToPositive :
|
||||
// case evSetTriggerPolarityToNegative :
|
||||
case evSetTriggerMode :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
n[0] = atoi(tmp_str[0].data());
|
||||
if(tmp_str[0].length()>0&&feb_controler->SetTriggerMode(n[0])){
|
||||
return_message.append("\tExecuted: SetTriggerMode "); AddNumber(return_message,n[0]); return_message.append("\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: SetTriggerMode <n>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evSetExternalGating :
|
||||
tmp_str[0] = GetNextString(data);
|
||||
tmp_str[1] = GetNextString(data);
|
||||
n[0] = atoi(tmp_str[0].data());
|
||||
n[1] = atoi(tmp_str[1].data());
|
||||
if(tmp_str[0].length()<1 || tmp_str[1].length()<1 || (n[0]!=0&&n[0]!=1) || (n[1]!=0&&n[1]!=1)){
|
||||
return_message.append("\tError executing: setexternalgating <enable> <polarity>\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
feb_controler->SetExternalEnableMode(n[0],n[1]);
|
||||
ret_val = 0;
|
||||
break;
|
||||
|
||||
case evStartAcquisition :
|
||||
if(feb_controler->StartAcquisition()){
|
||||
return_message.append("\tExecuted: StartAcquisition\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: StartAcquisition\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case evStopAcquisition :
|
||||
if(feb_controler->StopAcquisition()){
|
||||
return_message.append("\tExecuted: StopAcquisition\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: StopAcquisition\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case evIsDaqStillRunning :
|
||||
return_message.append("\tExecuted: evIsDaqStillRunning\n");
|
||||
ret_parameter = feb_controler->AcquisitionInProgress();
|
||||
ret_val = 0;
|
||||
break;
|
||||
|
||||
|
||||
case evWaitUntilDaqFinished :
|
||||
if(feb_controler->WaitForFinishedFlag()){
|
||||
return_message.append("\tExecuted: WaitUntilDaqFinished\n");
|
||||
ret_val = 0;
|
||||
}else{
|
||||
return_message.append("\tError executing: WaitUntilDaqFinished\n");
|
||||
ret_val = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case evExitServer :
|
||||
return_message.append("\tExiting Server ....\n");
|
||||
stop = 1;
|
||||
ret_val = -200;
|
||||
break;
|
||||
|
||||
|
||||
default :
|
||||
return_message.append("\tWarning command \"");
|
||||
return_message.append(cmd);
|
||||
return_message.append("\" not found.\n");
|
||||
return_message.append("\t\tValid commands: ");
|
||||
map<string, cmd_string>::iterator it = enum_map.begin();
|
||||
while(it!=enum_map.end()){
|
||||
return_message.append((it++)->first);
|
||||
return_message.append(" ");
|
||||
}
|
||||
|
||||
ret_val=-100;
|
||||
break;
|
||||
}
|
||||
|
||||
// return_message.append("\n");
|
||||
//AddNumber(return_message,ret_parameter,return_start_pos);
|
||||
AddNumber(return_message,ret_val,return_start_pos,1);
|
||||
AddNumber(return_message,ret_parameter,0,1);
|
||||
if(ret_val!=0) break;
|
||||
|
||||
cmd = GetNextString(data);
|
||||
}
|
||||
/*return_message.append("\n\n\n");*/
|
||||
|
||||
AddNumber(return_message,ret_val,0,1);
|
||||
cout<<return_message.c_str()<<"\t\t";
|
||||
cout<<"return: "<<ret_val<<endl;
|
||||
|
||||
if(!WriteNClose(return_message.c_str(),return_message.length())) return 0;
|
||||
}
|
||||
|
||||
|
||||
delete feb_controler;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
string LowerCase(string str){
|
||||
string s = str;
|
||||
string::iterator i = s.begin();
|
||||
while(i!=s.end()) *i=tolower(*(i++));
|
||||
return s;
|
||||
}
|
||||
|
||||
string GetNextString(string str,bool start_from_beginning){
|
||||
static string::size_type start_pos = 0;
|
||||
if(start_from_beginning) start_pos = 0;
|
||||
|
||||
while(start_pos != string::npos){
|
||||
string::size_type found = str.find_first_of(" ",start_pos);
|
||||
string sub = str.substr(start_pos,found-start_pos);
|
||||
|
||||
start_pos = found;
|
||||
if(start_pos != string::npos) start_pos+=1;
|
||||
|
||||
sub.erase(remove_if(sub.begin(),sub.end(), ::isspace ),sub.end());
|
||||
|
||||
if(sub.length()>0) return sub;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
void AddNumber(string& str, int n, int location, bool space_after){
|
||||
static char retval_st[100];
|
||||
if(space_after) sprintf(retval_st,"%d ",n);
|
||||
else sprintf(retval_st,"%d",n);
|
||||
|
||||
if(location<0) str.append(retval_st);
|
||||
else str.insert(location,retval_st);
|
||||
}
|
||||
|
||||
void AddNumber(string& str, float v, int location, bool space_after){
|
||||
static char retval_st[100];
|
||||
if(space_after) sprintf(retval_st,"%f ",v);
|
||||
else sprintf(retval_st,"%f",v);
|
||||
|
||||
if(location<0) str.append(retval_st);
|
||||
else str.insert(location,retval_st);
|
||||
}
|
||||
|
||||
|
||||
bool SetupListenSocket(unsigned short int port){
|
||||
server_list_s=0;
|
||||
server_conn_s=0;
|
||||
|
||||
if((server_list_s = socket(AF_INET, SOCK_STREAM, 0))<0) return 0;
|
||||
|
||||
struct sockaddr_in servaddr; /* socket address structure */
|
||||
memset(&servaddr, 0, sizeof(servaddr));
|
||||
servaddr.sin_family = AF_INET;
|
||||
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
servaddr.sin_port = htons(port);
|
||||
|
||||
if(bind(server_list_s,(struct sockaddr *) &servaddr,sizeof(servaddr))<0) return 0;
|
||||
|
||||
if(listen(server_list_s,32) < 0){ // 1024 /* Backlog for listen() */
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int AccpetConnectionAndWaitForData(char* buffer, int maxlength){
|
||||
if(server_list_s==0||maxlength<=0) return 0;
|
||||
|
||||
if((server_conn_s = accept(server_list_s,NULL,NULL))< 0) return 0;
|
||||
|
||||
int nread = read(server_conn_s,buffer,maxlength-1);
|
||||
|
||||
if(nread<0) return 0;
|
||||
|
||||
buffer[nread]='\0';
|
||||
return nread;
|
||||
}
|
||||
|
||||
bool WriteNClose(const char* buffer, int length){
|
||||
if(server_conn_s==0||length<=0) return 0;
|
||||
|
||||
int nsent = write(server_conn_s,buffer,length);
|
||||
if(close(server_conn_s)<0) return 0;
|
||||
|
||||
server_conn_s=0;
|
||||
return (nsent==length);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
|
||||
//Class initially from Gerd and was called mmap_test.c
|
||||
//return reversed 1 means good, 0 means failed
|
||||
|
||||
|
||||
//#include <stdio.h>
|
||||
//#include <unistd.h>
|
||||
//#include <string.h>
|
||||
//#include <sys/mman.h>
|
||||
//#include <fcntl.h>
|
||||
|
||||
#include "HardwareIO.h"
|
||||
|
||||
xfs_u8 HardwareIO::xfs_in8(xfs_u32 InAddress)
|
||||
{
|
||||
/* read the contents of the I/O location and then synchronize the I/O
|
||||
* such that the I/O operation completes before proceeding on
|
||||
*/
|
||||
|
||||
xfs_u8 IoContents;
|
||||
__asm__ volatile ("eieio; lbz %0,0(%1)":"=r" (IoContents):"b"
|
||||
(InAddress));
|
||||
return IoContents;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
xfs_u16 HardwareIO::xfs_in16(xfs_u32 InAddress)
|
||||
{
|
||||
/* read the contents of the I/O location and then synchronize the I/O
|
||||
* such that the I/O operation completes before proceeding on
|
||||
*/
|
||||
|
||||
xfs_u16 IoContents;
|
||||
__asm__ volatile ("eieio; lhz %0,0(%1)":"=r" (IoContents):"b"
|
||||
(InAddress));
|
||||
return IoContents;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
xfs_u32 HardwareIO::xfs_in32(xfs_u32 InAddress)
|
||||
{
|
||||
/* read the contents of the I/O location and then synchronize the I/O
|
||||
* such that the I/O operation completes before proceeding on
|
||||
*/
|
||||
|
||||
xfs_u32 IoContents;
|
||||
__asm__ volatile ("eieio; lwz %0,0(%1)":"=r" (IoContents):"b"
|
||||
(InAddress));
|
||||
return IoContents;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void HardwareIO::xfs_out8(xfs_u32 OutAddress, xfs_u8 Value)
|
||||
{
|
||||
/* write the contents of the I/O location and then synchronize the I/O
|
||||
* such that the I/O operation completes before proceeding on
|
||||
*/
|
||||
|
||||
__asm__ volatile ("stb %0,0(%1); eieio"::"r" (Value), "b"(OutAddress));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void HardwareIO::xfs_out16(xfs_u32 OutAddress, xfs_u16 Value)
|
||||
{
|
||||
/* write the contents of the I/O location and then synchronize the I/O
|
||||
* such that the I/O operation completes before proceeding on
|
||||
*/
|
||||
|
||||
__asm__ volatile ("sth %0,0(%1); eieio"::"r" (Value), "b"(OutAddress));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void HardwareIO::xfs_out32(xfs_u32 OutAddress, xfs_u32 Value)
|
||||
{
|
||||
/* write the contents of the I/O location and then synchronize the I/O
|
||||
* such that the I/O operation completes before proceeding on
|
||||
*/
|
||||
|
||||
__asm__ volatile ("stw %0,0(%1); eieio"::"r" (Value), "b"(OutAddress));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,277 +0,0 @@
|
||||
|
||||
//Class initially from Gerd and was called mmap_test.c
|
||||
//return reversed 1 means good, 0 means failed
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
//#include <string.h>
|
||||
|
||||
|
||||
#include "HardwareMMappingDefs.h"
|
||||
|
||||
#include "LocalLinkInterface.h"
|
||||
|
||||
|
||||
|
||||
LocalLinkInterface::LocalLinkInterface(unsigned int ll_fifo_badr){
|
||||
// printf("\n v 1 \n");
|
||||
printf("Initialize PLB LL FIFOs\n");
|
||||
ll_fifo_base=0;
|
||||
ll_fifo_ctrl_reg=0;
|
||||
if(Init(ll_fifo_badr)){
|
||||
Reset();
|
||||
printf("\tFIFO Status : 0x%08x\n",StatusVector());
|
||||
}else printf("\tError LocalLink Mappping : 0x%08x\n",ll_fifo_badr);
|
||||
|
||||
printf("\n\n");
|
||||
}
|
||||
|
||||
LocalLinkInterface::~LocalLinkInterface(){};
|
||||
|
||||
LocalLinkInterface::LocalLinkInterface(){
|
||||
printf("Initialize new memory\n");
|
||||
}
|
||||
|
||||
int LocalLinkInterface::InitNewMemory (unsigned int addr, int ifg){
|
||||
unsigned int CSP0BASE;
|
||||
int fd;
|
||||
|
||||
/*fd = open("/dev/mem", O_RDWR | O_SYNC, 0);
|
||||
if (fd == -1) {
|
||||
printf("\nCan't find /dev/mem!\n");
|
||||
return 0;
|
||||
}
|
||||
printf("/dev/mem opened\n");
|
||||
|
||||
|
||||
CSP0BASE = (u_int32_t)mmap(0, 0x1000, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, addr);
|
||||
if (CSP0BASE == (u_int32_t)MAP_FAILED) {
|
||||
printf("\nCan't map memmory area!!\n");
|
||||
return 0;
|
||||
}
|
||||
printf("CSP0 mapped\n");
|
||||
|
||||
|
||||
volatile u_int8_t *ptr1;
|
||||
|
||||
ptr1=(u_int8_t*)(CSP0BASE);
|
||||
|
||||
printf("pointer val=%x\n",(void*)ptr1);
|
||||
|
||||
printf("ifg_control=%02x\n",*ptr1);
|
||||
|
||||
*ptr1=ifg;
|
||||
|
||||
printf("ifg_control new=%02x\n",*ptr1);
|
||||
|
||||
close(fd);
|
||||
*/
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool LocalLinkInterface::Init(unsigned int ll_fifo_badr){
|
||||
int fd;
|
||||
void *plb_ll_fifo_ptr;
|
||||
|
||||
if ((fd=open("/dev/mem", O_RDWR)) < 0){
|
||||
fprintf(stderr, "Could not open /dev/mem\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
plb_ll_fifo_ptr = mmap(0, getpagesize(), PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, fd, ll_fifo_badr);
|
||||
close(fd);
|
||||
|
||||
if (plb_ll_fifo_ptr == MAP_FAILED){
|
||||
perror ("mmap");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ll_fifo_base = (xfs_u32) plb_ll_fifo_ptr;
|
||||
ll_fifo_ctrl_reg = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool LocalLinkInterface::Reset(){
|
||||
return Reset(PLB_LL_FIFO_CTRL_RESET_STD);
|
||||
}
|
||||
|
||||
bool LocalLinkInterface::Reset(unsigned int rst_mask){
|
||||
ll_fifo_ctrl_reg |= rst_mask;
|
||||
printf("\tCTRL Register bits: 0x%08x\n",ll_fifo_ctrl_reg);
|
||||
|
||||
xfs_out32(ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll_fifo_ctrl_reg);
|
||||
xfs_out32(ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll_fifo_ctrl_reg);
|
||||
xfs_out32(ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll_fifo_ctrl_reg);
|
||||
xfs_out32(ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll_fifo_ctrl_reg);
|
||||
|
||||
ll_fifo_ctrl_reg &= (~rst_mask);
|
||||
|
||||
xfs_out32(ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll_fifo_ctrl_reg);
|
||||
// printf("FIFO CTRL Address: 0x%08x\n FIFO CTRL Register: 0x%08x\n",PLB_LL_FIFO_REG_CTRL,plb_ll_fifo[PLB_LL_FIFO_REG_CTRL]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
unsigned int LocalLinkInterface::StatusVector(){
|
||||
return xfs_in32(ll_fifo_base+4*PLB_LL_FIFO_REG_STATUS);
|
||||
}
|
||||
|
||||
int LocalLinkInterface::Write(unsigned int buffer_len, void *buffer){
|
||||
// note: buffer must be word (4 byte) aligned
|
||||
// frame_len in byte
|
||||
int vacancy=0;
|
||||
int i;
|
||||
int words_send = 0;
|
||||
int last_word;
|
||||
unsigned int *word_ptr;
|
||||
unsigned int fifo_ctrl;
|
||||
xfs_u32 status;
|
||||
|
||||
if (buffer_len < 1) return -1;
|
||||
|
||||
last_word = (buffer_len-1)/4;
|
||||
word_ptr = (unsigned int *)buffer;
|
||||
|
||||
while (words_send <= last_word)
|
||||
{
|
||||
while (!vacancy)//wait for Fifo to be empty again
|
||||
{
|
||||
status = xfs_in32(ll_fifo_base+4*PLB_LL_FIFO_REG_STATUS);
|
||||
if((status & PLB_LL_FIFO_STATUS_ALMOSTFULL) == 0) vacancy = 1;
|
||||
}
|
||||
|
||||
//Just to know: #define PLB_LL_FIFO_ALMOST_FULL_THRESHOLD_WORDS 100
|
||||
for (i=0; ((i<PLB_LL_FIFO_ALMOST_FULL_THRESHOLD_WORDS) && (words_send <= last_word)); i++)
|
||||
{
|
||||
fifo_ctrl = 0;
|
||||
if (words_send == 0)
|
||||
{
|
||||
fifo_ctrl = PLB_LL_FIFO_CTRL_LL_SOF;//announce the start of file
|
||||
}
|
||||
|
||||
if (words_send == last_word)
|
||||
{
|
||||
fifo_ctrl |= (PLB_LL_FIFO_CTRL_LL_EOF | (( (buffer_len-1)<<PLB_LL_FIFO_CTRL_LL_REM_SHIFT) & PLB_LL_FIFO_CTRL_LL_REM) );
|
||||
}
|
||||
ctrl_reg_write_mask(PLB_LL_FIFO_CTRL_LL_MASK,fifo_ctrl);
|
||||
xfs_out32(ll_fifo_base+4*PLB_LL_FIFO_REG_FIFO,word_ptr[words_send++]);
|
||||
}
|
||||
}
|
||||
return buffer_len;
|
||||
}
|
||||
|
||||
|
||||
int LocalLinkInterface::Read(unsigned int buffer_len, void *buffer){
|
||||
static unsigned int buffer_ptr = 0;
|
||||
// note: buffer must be word (4 byte) aligned
|
||||
// frame_len in byte
|
||||
int len;
|
||||
unsigned int *word_ptr;
|
||||
unsigned int status;
|
||||
volatile unsigned int fifo_val;
|
||||
int sof = 0;
|
||||
|
||||
word_ptr = (unsigned int *)buffer;
|
||||
do
|
||||
{
|
||||
status = xfs_in32(ll_fifo_base+4*PLB_LL_FIFO_REG_STATUS);
|
||||
|
||||
if (!(status & PLB_LL_FIFO_STATUS_EMPTY))
|
||||
{
|
||||
if (status & PLB_LL_FIFO_STATUS_LL_SOF)
|
||||
{
|
||||
if (buffer_ptr)
|
||||
{
|
||||
buffer_ptr = 0;
|
||||
return -1; // buffer overflow
|
||||
}
|
||||
// printf(">>>> SOF\n\r");
|
||||
buffer_ptr = 0;
|
||||
sof = 1;
|
||||
}
|
||||
|
||||
fifo_val = xfs_in32(ll_fifo_base+4*PLB_LL_FIFO_REG_FIFO); //read from fifo
|
||||
|
||||
if ((buffer_ptr > 0) || sof)
|
||||
{
|
||||
if ( (buffer_len >> 2) > buffer_ptr)
|
||||
{
|
||||
word_ptr[buffer_ptr++] = fifo_val; //write to buffer
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer_ptr = 0;
|
||||
return -2; // buffer overflow
|
||||
}
|
||||
|
||||
if (status & PLB_LL_FIFO_STATUS_LL_EOF)
|
||||
{
|
||||
len = (buffer_ptr << 2) -3 + ( (status & PLB_LL_FIFO_STATUS_LL_REM)>>PLB_LL_FIFO_STATUS_LL_REM_SHIFT );
|
||||
// printf(">>>>status=0x%08x EOF len = %d \n\r\n\r",status, len);
|
||||
buffer_ptr = 0;
|
||||
return len;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
while(!(status & PLB_LL_FIFO_STATUS_EMPTY));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool LocalLinkInterface::ctrl_reg_write_mask(unsigned int mask, unsigned int val){
|
||||
// printf("Fifo CTRL Reg(1): 0x%08x\n",plb_ll_fifo_ctrl_reg);
|
||||
ll_fifo_ctrl_reg &= (~mask);
|
||||
//printf("Fifo CTRL Reg(2): 0x%08x\n",plb_ll_fifo_ctrl_reg);
|
||||
ll_fifo_ctrl_reg |= ( mask & val);
|
||||
// printf("Fifo CTRL Reg: 0x%08x\n",plb_ll_fifo_ctrl_reg);
|
||||
xfs_out32(ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll_fifo_ctrl_reg);
|
||||
// printf("Fifo STAT Reg: 0x%08x\n", plb_ll_fifo[PLB_LL_FIFO_REG_STATUS]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int LocalLinkInterface::Test(unsigned int buffer_len, void *buffer){
|
||||
|
||||
int len;
|
||||
unsigned int rec_buff_len = 4096;
|
||||
unsigned int rec_buffer[4097];
|
||||
|
||||
|
||||
Write(buffer_len,buffer);
|
||||
usleep(10000);
|
||||
|
||||
do{
|
||||
len = Read(rec_buff_len,rec_buffer);
|
||||
printf("receive length: %i\n",len);
|
||||
|
||||
if (len > 0){
|
||||
rec_buffer[len]=0;
|
||||
printf((char*) rec_buffer);
|
||||
printf("\n");
|
||||
}
|
||||
} while(len > 0);
|
||||
|
||||
printf("\n\n\n\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
void LocalLinkInterface::llfifo_print_frame(unsigned char* fbuff, int len){
|
||||
printf("\n\r----Frame of len : %d Byte\n\r",len);
|
||||
for(int i=0;i<len;i++){
|
||||
printf("0x%02x ",fbuff[i] );
|
||||
if ((i&0xf) == 0x7) printf(" ");
|
||||
if ((i&0xf) == 0xf) printf("\n\r");
|
||||
}
|
||||
printf("\n\r");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "xparameters.h"
|
||||
|
||||
#include "LocalLinkInterface.h"
|
||||
|
||||
int main(){
|
||||
|
||||
char s[2000];
|
||||
sprintf(s,"papamama");
|
||||
|
||||
LocalLinkInterface* l0 = new LocalLinkInterface(XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR);
|
||||
l0->Test(8,s);
|
||||
LocalLinkInterface* l1 = new LocalLinkInterface(XPAR_PLB_LL_FIFO_AURORA_RX4_TX1_LEFT_BASEADDR);
|
||||
l1->Test(8,s);
|
||||
LocalLinkInterface* l2 = new LocalLinkInterface(XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT_BASEADDR);
|
||||
l2->Test(8,s);
|
||||
LocalLinkInterface* l3 = new LocalLinkInterface(XPAR_PLB_LL_FIFO_AURORA_RX4_TX1_RIGHT_BASEADDR);
|
||||
l3->Test(8,s);
|
||||
|
||||
delete l0;
|
||||
delete l1;
|
||||
delete l2;
|
||||
delete l3;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
CC = powerpc-4xx-softfloat-gcc
|
||||
CCX = powerpc-4xx-softfloat-g++
|
||||
BLACKFIN_CC = bfin-uclinux-gcc
|
||||
CFLAGS += -Wall -DDACS_INT -DEIGERD -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE #-DVIRTUAL -DPCCOMPILE -DMARTIN
|
||||
LDLIBS += -lm -lstdc++
|
||||
@@ -10,13 +9,10 @@ INSTMODE = 0777
|
||||
|
||||
|
||||
SRC_CLNT = communication_funcs.c slsDetectorServer.c slsDetectorServer_funcs.c slsDetectorFunctionList.c FebControl.c Beb.c HardwareIO.c LocalLinkInterface.c Feb.c FebInterface.c
|
||||
#SRC_CLNT2 = FebServer.cxx FebControl.cxx FebInterface.cxx LocalLinkInterface.cxx HardwareIO.cxx
|
||||
#SRC_CLNT3 = BebServer.cxx Beb.cxx LocalLinkInterface.cxx HardwareIO.cxx
|
||||
|
||||
OBJS = $(SRC_CLNT:.c=.o)
|
||||
|
||||
|
||||
all: clean $(PROGS) hv9m_blackfin_server #feb_debug beb_debug
|
||||
all: clean $(PROGS) #hv9m_blackfin_server
|
||||
|
||||
|
||||
boot: $(OBJS)
|
||||
@@ -27,13 +23,6 @@ $(PROGS):
|
||||
$(CC) -o $@ $(SRC_CLNT) $(CFLAGS) $(LDLIBS)
|
||||
mv $(PROGS) $(DESTDIR)
|
||||
|
||||
feb_debug:$(SRC_CLNT2)
|
||||
$(CCX) -o feb_debug $(SRC_CLNT2) -I.
|
||||
mv feb_debug $(DESTDIR)
|
||||
|
||||
beb_debug:$(SRC_CLNT3)
|
||||
$(CCX) -o beb_debug $(SRC_CLNT3) -I.
|
||||
mv beb_debug $(DESTDIR)
|
||||
|
||||
hv9m_blackfin_server:9mhvserial_bf.c
|
||||
$(BLACKFIN_CC) -o hv9m_blackfin_server 9mhvserial_bf.c -Wall #-DVERBOSE
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "xparameters.h"
|
||||
|
||||
#include "Feb.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
|
||||
cout<<"\n\n\n\n\n\n\n\n\n\n"<<endl;
|
||||
|
||||
|
||||
char s[2000];
|
||||
sprintf(s,"papamama");
|
||||
|
||||
Feb* feb = new Feb();
|
||||
|
||||
unsigned int v=22;
|
||||
feb->ReadRegister(0,0,v);
|
||||
feb->ReadRegister(0,0xffffffff,v);
|
||||
cout<<endl<<endl;
|
||||
feb->ReadRegister(1,0,v);
|
||||
feb->ReadRegister(1,0xffffffff,v);
|
||||
|
||||
delete feb;
|
||||
|
||||
return 1;
|
||||
}
|
||||
Binary file not shown.
BIN
slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv3.0.0.16.0
Executable file
BIN
slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv3.0.0.16.0
Executable file
Binary file not shown.
Binary file not shown.
@@ -1,19 +0,0 @@
|
||||
|
||||
echo -e "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
|
||||
|
||||
. /opt/eldk-5.1/powerpc-4xx-softfloat/environment-setup-ppc440-linux
|
||||
|
||||
#powerpc-4xx-softfloat-g++ -Wall -o test Test.cxx HardwareIO.cxx LocalLinkInterface.cxx Feb.cxx -I .
|
||||
#powerpc-4xx-softfloat-g++ -Wall -o hardware_interface_test HardwareInterfaceTest.cxx HardwareInterface.cxx HardwareMMapping.cxx -I .
|
||||
|
||||
|
||||
#powerpc-4xx-softfloat-g++ -Wall -o eiger_test EigerTest.cxx Eiger.cxx HardwareIO.cxx LocalLinkInterface.cxx Feb.cxx -I .
|
||||
|
||||
powerpc-4xx-softfloat-g++ -Wall -o feb_debug FebServer.cxx FebControl.cxx FebInterface.cxx LocalLinkInterface.cxx HardwareIO.cxx -I .
|
||||
|
||||
powerpc-4xx-softfloat-g++ -Wall -o beb_debug BebServer.cxx Beb.cxx LocalLinkInterface.cxx HardwareIO.cxx -I .
|
||||
|
||||
|
||||
cp eiger_test rootfs_executables/.
|
||||
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
|
||||
# documentation are documented, even if no documentation was available.
|
||||
# Private class members and static file members will be hidden unless
|
||||
# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
|
||||
|
||||
EXTRACT_ALL = YES
|
||||
|
||||
# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
|
||||
# will be included in the documentation.
|
||||
|
||||
EXTRACT_PRIVATE = NO
|
||||
|
||||
|
||||
|
||||
# If the EXTRACT_STATIC tag is set to YES all static members of a file
|
||||
# will be included in the documentation.
|
||||
|
||||
EXTRACT_STATIC = YES
|
||||
|
||||
# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
|
||||
# defined locally in source files will be included in the documentation.
|
||||
# If set to NO only classes defined in header files are included.
|
||||
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
|
||||
# This flag is only useful for Objective-C code. When set to YES local
|
||||
# methods, which are defined in the implementation section but not in
|
||||
# the interface are included in the documentation.
|
||||
# If set to NO (the default) only methods in the interface are included.
|
||||
|
||||
EXTRACT_LOCAL_METHODS = YES
|
||||
|
||||
# If this flag is set to YES, the members of anonymous namespaces will be
|
||||
# extracted and appear in the documentation as a namespace called
|
||||
# 'anonymous_namespace{file}', where file will be replaced with the base
|
||||
# name of the file that contains the anonymous namespace. By default
|
||||
# anonymous namespace are hidden.
|
||||
|
||||
EXTRACT_ANON_NSPACES = NO
|
||||
|
||||
# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
|
||||
# undocumented members of documented classes, files or namespaces.
|
||||
# If set to NO (the default) these members will be included in the
|
||||
# various overviews, but no documentation section is generated.
|
||||
# This option has no effect if EXTRACT_ALL is enabled.
|
||||
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
|
||||
# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
|
||||
# undocumented classes that are normally visible in the class hierarchy.
|
||||
# If set to NO (the default) these classes will be included in the various
|
||||
# overviews. This option has no effect if EXTRACT_ALL is enabled.
|
||||
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
|
||||
# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
|
||||
# friend (class|struct|union) declarations.
|
||||
# If set to NO (the default) these declarations will be included in the
|
||||
# documentation.
|
||||
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
|
||||
INTERNAL_DOCS = NO
|
||||
|
||||
SHOW_INCLUDE_FILES = NO
|
||||
|
||||
SHOW_FILES = NO
|
||||
|
||||
SHOW_NAMESPACES = NO
|
||||
|
||||
COMPACT_LATEX = YES
|
||||
|
||||
PAPER_TYPE = a4
|
||||
|
||||
PDF_HYPERLINKS = YES
|
||||
|
||||
USE_PDFLATEX = YES
|
||||
|
||||
LATEX_HIDE_INDICES = YES
|
||||
|
||||
PREDEFINED = __cplusplus
|
||||
|
||||
HAVE_DOT = YES
|
||||
CALL_GRAPH = YES
|
||||
CALLER_GRAPH = YES
|
||||
|
||||
|
||||
INPUT = Beb.h Eiger.h FebControl.h FebInterface.h gitInfoEiger.h HardwareIO.h LocalLinkInterface.h sls_detector_funcs.h slsDetectorServer_defs.h sls_receiver_defs.h xfs_types.h communication_funcs.h EigerRegisterDefs.h Feb.h FebRegisterDefs.h gitInfoEigerTmp.h HardwareMMappingDefs.h sls_detector_defs.h slsDetectorFunctionList.h slsDetectorServer_funcs.h sls_receiver_funcs.h xparameters.h Beb.cxx BebServer.cxx Eiger.cxx EigerTest.cxx FebControl.cxx Feb.cxx FebInterface.cxx FebServer.cxx HardwareIO.cxx LocalLinkInterface.cxx LocalLinkTest.cxx Test.cxx
|
||||
|
||||
|
||||
|
||||
|
||||
OUTPUT_DIRECTORY = docs
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
Path: slsDetectorsPackage/slsDetectorSoftware/eigerDetectorServer
|
||||
URL: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git/eigerDetectorServer
|
||||
Repository Root: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git
|
||||
Repsitory UUID: 230d6b36e9852214f4ba5ae7c92647f35000b24d
|
||||
Revision: 263
|
||||
Repsitory UUID: 6d38c0622a2936f70345e7d53aaf1c9e2de4cbd6
|
||||
Revision: 285
|
||||
Branch: developer
|
||||
Last Changed Author: Dhanya_Maliakal
|
||||
Last Changed Rev: 1313
|
||||
Last Changed Date: 2016-11-30 10:36:34 +0100
|
||||
Last Changed Rev: 1401
|
||||
Last Changed Date: 2017-06-12 18:53:18 +0200
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
//#define SVNPATH ""
|
||||
#define SVNURL "git@git.psi.ch:sls_detectors_software/sls_detector_software.git/eigerDetectorServer"
|
||||
//#define SVNREPPATH ""
|
||||
#define SVNREPUUID "230d6b36e9852214f4ba5ae7c92647f35000b24d"
|
||||
//#define SVNREV 0x1313
|
||||
#define SVNREPUUID "6d38c0622a2936f70345e7d53aaf1c9e2de4cbd6"
|
||||
//#define SVNREV 0x1401
|
||||
//#define SVNKIND ""
|
||||
//#define SVNSCHED ""
|
||||
#define SVNAUTH "Dhanya_Maliakal"
|
||||
#define SVNREV 0x1313
|
||||
#define SVNDATE 0x20161130
|
||||
#define SVNREV 0x1401
|
||||
#define SVNDATE 0x20170612
|
||||
//
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
mv bin/eigerDetectorServer bin/$2
|
||||
cp bin/$2 /tftpboot
|
||||
git rm -f bin/$1
|
||||
git add bin/$2
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
|
||||
|
||||
#detector setup
|
||||
#add_module module_number base_address_top (for half module)
|
||||
#add_module module_number base_address_top base_address_bottom (for full module)
|
||||
add_half_module 17 0
|
||||
#add_half_module 17 1 for bottom
|
||||
#add_module 18 10 12
|
||||
#add_module 2 13 15
|
||||
#add_module 1 120 22
|
||||
|
||||
|
||||
#default setting
|
||||
photon_energy 8000
|
||||
dynamic_range 16
|
||||
readout_speed 1 #(0-full,1-half,2-quarter and 3-superslow)
|
||||
readout_mode 0 #(0-parallel,1-non_parallel,2-safe_mode)
|
||||
|
||||
|
||||
#default dacs
|
||||
SvP 0
|
||||
Vtr 1280
|
||||
Vrf 1550
|
||||
Vrs 700
|
||||
SvN 2000
|
||||
Vtgstv 1278
|
||||
Vcmp_ll 750
|
||||
Vcmp_lr 750
|
||||
cal 2000
|
||||
Vcmp_rl 750
|
||||
rxb_rb 600
|
||||
rxb_lb 600
|
||||
Vcmp_rr 750
|
||||
Vcp 100
|
||||
Vcn 1000
|
||||
Vis 775
|
||||
|
||||
#default high_voltage
|
||||
high_voltage 152
|
||||
|
||||
#default iodelays
|
||||
iodelay 675
|
||||
|
||||
#newgoodiodelay 643
|
||||
#halfspeed_add_about 32
|
||||
#goodiodelay 1467
|
||||
#goodiodelay 1550
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
|
||||
|
||||
#detector setup
|
||||
#add_beb base_address mac_1GBE ip_1GBE mac_10GBE ip_10GBE
|
||||
|
||||
add_beb 26 0 00:50:c2:46:d9:34 129.129.205.78 00:50:c2:46:d9:35 10.0.26.1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -8,46 +8,81 @@
|
||||
#ifndef SLSDETECTORSERVER_DEFS_H_
|
||||
#define SLSDETECTORSERVER_DEFS_H_
|
||||
|
||||
//#include "sls_detector_defs.h"
|
||||
#include "sls_detector_defs.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#define GOODBYE -200
|
||||
#define GOODBYE (-200)
|
||||
#define REQUIRED_FIRMWARE_VERSION (16)
|
||||
|
||||
#define FEB_PORT 43210
|
||||
#define BEB_PORT 43212
|
||||
|
||||
#define REQUIRED_FIRMWARE_VERSION 16
|
||||
|
||||
#define FIRMWAREREV 0xcaba //temporary should be in firmware
|
||||
/* Enums */
|
||||
enum CLK_SPEED_INDEX {FULL_SPEED, HALF_SPEED, QUARTER_SPEED};
|
||||
enum DACINDEX {SVP,VTR,VRF,VRS,SVN,VTGSTV,VCMP_LL,VCMP_LR,CAL,VCMP_RL,RXB_RB,RXB_LB,VCMP_RR,VCP,VCN,VIS,VTHRESHOLD};
|
||||
#define DEFAULT_DAC_VALS { \
|
||||
0, /* SvP */ \
|
||||
2480, /* Vtr */ \
|
||||
3300, /* Vrf */ \
|
||||
1400, /* Vrs */ \
|
||||
4000, /* SvN */ \
|
||||
2556, /* Vtgstv */ \
|
||||
1000, /* Vcmp_ll */ \
|
||||
1000, /* Vcmp_lr */ \
|
||||
4000, /* cal */ \
|
||||
1000, /* Vcmp_rl */ \
|
||||
1100, /* rxb_rb */ \
|
||||
1100, /* rxb_lb */ \
|
||||
1000, /* Vcmp_rr */ \
|
||||
1000, /* Vcp */ \
|
||||
2000, /* Vcn */ \
|
||||
1550 /* Vis */ \
|
||||
};
|
||||
enum ADCINDEX {TEMP_FPGAEXT, TEMP_10GE, TEMP_DCDC, TEMP_SODL, TEMP_SODR, TEMP_FPGA, TEMP_FPGAFEBL, TEMP_FPGAFEBR};
|
||||
enum NETWORKINDEX {TXN_LEFT, TXN_RIGHT, TXN_FRAME,FLOWCTRL_10G};
|
||||
|
||||
|
||||
#define NCHAN 256*256
|
||||
#define NCHIP 4
|
||||
#define NDAC 16
|
||||
#define NADC 0
|
||||
#define NGAIN 4
|
||||
#define NOFFSET 4
|
||||
|
||||
#define NMAXMODX 1
|
||||
#define NMAXMODY 1
|
||||
#define NMAXMOD NMAXMODX*NMAXMODY
|
||||
#define NCHANS NCHAN*NCHIP*NMAXMOD
|
||||
#define NDACS NDAC*NMAXMOD
|
||||
/* Hardware Definitions */
|
||||
#define NMAXMOD (1)
|
||||
#define NMOD (1)
|
||||
#define NCHAN (256 * 256)
|
||||
#define NCHIP (4)
|
||||
#define NADC (0)
|
||||
#define NDAC (16)
|
||||
#define NGAIN (0)
|
||||
#define NOFFSET (0)
|
||||
|
||||
|
||||
#define DYNAMIC_RANGE 16
|
||||
|
||||
|
||||
enum detDacIndex{SVP,VTR,VRF,VRS,SVN,VTGSTV,VCMP_LL,VCMP_LR,CAL,VCMP_RL,RXB_RB,RXB_LB,VCMP_RR,VCP,VCN,VIS,VTHRESHOLD};
|
||||
|
||||
enum detAdcIndex{TEMP_FPGAEXT, TEMP_10GE, TEMP_DCDC, TEMP_SODL, TEMP_SODR, TEMP_FPGA, TEMP_FPGAFEBL, TEMP_FPGAFEBR};
|
||||
|
||||
enum detNetworkParameter{TXN_LEFT, TXN_RIGHT, TXN_FRAME,FLOWCTRL_10G};
|
||||
|
||||
#define TEN_GIGA_BUFFER_SIZE (4112)
|
||||
#define ONE_GIGA_BUFFER_SIZE (1040)
|
||||
#define TEN_GIGA_CONSTANT (4)
|
||||
#define ONE_GIGA_CONSTANT (16)
|
||||
#define NORMAL_HIGHVOLTAGE_INPUTPORT "/sys/class/hwmon/hwmon5/device/in0_input"
|
||||
#define NORMAL_HIGHVOLTAGE_OUTPUTPORT "/sys/class/hwmon/hwmon5/device/out0_output"
|
||||
#define SPECIAL9M_HIGHVOLTAGE_PORT "/dev/ttyS1"
|
||||
#define SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE 16
|
||||
#define SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE (16)
|
||||
|
||||
/** Default Parameters */
|
||||
#define DEFAULT_MOD_INDEX (0)
|
||||
#define DEFAULT_NUM_FRAMES (1)
|
||||
#define DEFAULT_NUM_CYCLES (1)
|
||||
#define DEFAULT_EXPTIME (1E9) //ns
|
||||
#define DEFAULT_PERIOD (1E9) //ns
|
||||
#define DEFAULT_DELAY (0)
|
||||
#define DEFAULT_HIGH_VOLTAGE (0)
|
||||
#define DEFAULT_SETTINGS (DYNAMICGAIN)
|
||||
#define DEFAULT_SUBFRAME_EXPOSURE_VAL (2621440) // 2.6ms
|
||||
#define DEFAULT_DYNAMIC_RANGE (16)
|
||||
#define DEFAULT_READOUT_FLAG (NONPARALLEL)
|
||||
#define DEFAULT_CLK_SPEED (HALF_SPEED)
|
||||
#define DEFAULT_IO_DELAY (650)
|
||||
#define DEFAULT_TIMING_MODE (AUTO_TIMING)
|
||||
#define DEFAULT_PHOTON_ENERGY (-1)
|
||||
#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 */
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
Path: slsDetectorsPackage/slsDetectorSoftware
|
||||
URL: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git
|
||||
Repository Root: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git
|
||||
Repsitory UUID: 230d6b36e9852214f4ba5ae7c92647f35000b24d
|
||||
Revision: 1313
|
||||
Repsitory UUID: 6d38c0622a2936f70345e7d53aaf1c9e2de4cbd6
|
||||
Revision: 1401
|
||||
Branch: developer
|
||||
Last Changed Author: Dhanya_Maliakal
|
||||
Last Changed Rev: 1313
|
||||
Last Changed Date: 2016-11-30 10:36:34 +0100
|
||||
Last Changed Rev: 1401
|
||||
Last Changed Date: 2017-06-12 18:53:18 +0200
|
||||
|
||||
@@ -189,8 +189,8 @@ int function_table() {
|
||||
flist[F_SET_SYNCHRONIZATION_MODE]=&set_synchronization;
|
||||
flist[F_READ_COUNTER_BLOCK]=&read_counter_block;
|
||||
flist[F_RESET_COUNTER_BLOCK]=&reset_counter_block;
|
||||
flist[F_START_RECEIVER]=&start_receiver;
|
||||
flist[F_STOP_RECEIVER]=&stop_receiver;
|
||||
flist[F_PREPARE_ACQUISITION]=&start_receiver;
|
||||
flist[F_CLEANUP_ACQUISITION]=&stop_receiver;
|
||||
flist[F_CALIBRATE_PEDESTAL]=&calibrate_pedestal;
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
*.gdb
|
||||
@@ -1 +0,0 @@
|
||||
AXIS_BUILDTYPE ?= cris-axis-linux-gnu
|
||||
@@ -1,57 +1,26 @@
|
||||
# $Id: Makefile,v 1.1.1.1 2006/02/04 03:35:01 freza Exp $
|
||||
# first compile
|
||||
# make cris-axis-linux-gnu
|
||||
|
||||
|
||||
CROSS = bfin-uclinux-
|
||||
CC = $(CROSS)gcc
|
||||
|
||||
CFLAGS += -Wall -DJUNGFRAUD -DMCB_FUNCS -DDACS_INT -DDEBUG -DV1 #-DVERBOSE #-DVERYVERBOSE #-DVIRTUAL
|
||||
|
||||
CFLAGS += -Wall -DJUNGFRAUD -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE
|
||||
LDLIBS += -lm -lstdc++
|
||||
|
||||
PROGS = jungfrauDetectorServer
|
||||
INSTDIR= /tftpboot
|
||||
DESTDIR ?= bin
|
||||
INSTMODE = 0777
|
||||
|
||||
|
||||
|
||||
BINS = testlib_sharedlibc
|
||||
SRCS = server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c
|
||||
OBJS = $(SRCS:%.c=%.o)
|
||||
|
||||
|
||||
SRC_CLNT = communication_funcs.c slsDetectorServer.c slsDetectorServer_funcs.c slsDetectorFunctionList.c
|
||||
OBJS = $(SRC_CLNT:.c=.o)
|
||||
|
||||
all: clean $(PROGS)
|
||||
|
||||
test: clean jungfrauADCTEst
|
||||
|
||||
boot: $(OBJS)
|
||||
|
||||
jungfrauDetectorServer: $(OBJS)
|
||||
$(PROGS): $(OBJS)
|
||||
echo $(OBJS)
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@)
|
||||
|
||||
|
||||
jungfrauADCTEst: $(OBJS)
|
||||
echo $(OBJS)
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@) -DTESTADC
|
||||
|
||||
|
||||
|
||||
|
||||
install: $(PROGS)
|
||||
$(INSTALL) -d $(INSTDIR)
|
||||
$(INSTALL) -m $(INSTMODE) $(PROGS) $(INSTDIR)
|
||||
|
||||
|
||||
romfs:
|
||||
$(ROMFSINST) /bin/$(PROGS)
|
||||
mkdir -p $(DESTDIR)
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
|
||||
mv $(PROGS) $(DESTDIR)
|
||||
rm *.gdb
|
||||
|
||||
clean:
|
||||
rm -rf $(PROGS) *.o *.gdb
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
rm -rf $(DESTDIR)/$(PROGS) *.o
|
||||
|
||||
|
||||
33
slsDetectorSoftware/jungfrauDetectorServer/Makefile.virtual
Executable file → Normal file
33
slsDetectorSoftware/jungfrauDetectorServer/Makefile.virtual
Executable file → Normal file
@@ -1,30 +1,25 @@
|
||||
|
||||
DESTDIR ?= ./
|
||||
|
||||
CC = gcc
|
||||
CFLAGS += -Wall -DMOENCHD -DMCB_FUNCS -DDACS_INT -DDEBUG -DVIRTUAL
|
||||
CFLAGS += -Wall -DJUNGFRAUD -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE
|
||||
LDLIBS += -lm -lstdc++
|
||||
|
||||
PROGS = jungfrauDetectorServer
|
||||
DESTDIR ?= bin
|
||||
INSTMODE = 0777
|
||||
|
||||
PROGS= $(DESTDIR)/moenchVirtualServer
|
||||
|
||||
|
||||
SRCS = server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c trimming_funcs.c sharedmemory.c
|
||||
OBJS = $(SRCS:%.c=%.o)
|
||||
|
||||
moenchVirtualServer = $(PROGS)
|
||||
SRC_CLNT = communication_funcs.c slsDetectorServer.c slsDetectorServer_funcs.c slsDetectorFunctionList.c
|
||||
OBJS = $(SRC_CLNT:.c=.o)
|
||||
|
||||
all: clean $(PROGS)
|
||||
|
||||
boot: $(OBJS)
|
||||
|
||||
$(PROGS): $(OBJS)
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@)
|
||||
|
||||
echo $(OBJS)
|
||||
mkdir -p $(DESTDIR)
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
|
||||
mv $(PROGS) $(DESTDIR)
|
||||
rm *.gdb
|
||||
|
||||
clean:
|
||||
rm -rf $(PROGS) *.o *.gdb
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
rm -rf $(DESTDIR)/$(PROGS) *.o
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
add the following to /etc/rc before using programfpga command before cat motd
|
||||
|
||||
|
||||
#registering 7th and 9th pin to linux kernel
|
||||
echo 7 > /sys/class/gpio/export
|
||||
echo 9 > /sys/class/gpio/export
|
||||
#define direction for the linux kernel
|
||||
echo in > /sys/class/gpio/gpio7/direction
|
||||
echo out > /sys/class/gpio/gpio9/direction
|
||||
#needed, else all write errors when server starts up, because linux tries to take control fof gpio
|
||||
echo 1 > /sys/class/gpio/gpio9/value
|
||||
338
slsDetectorSoftware/jungfrauDetectorServer/RegisterDefs.h
Normal file
338
slsDetectorSoftware/jungfrauDetectorServer/RegisterDefs.h
Normal file
@@ -0,0 +1,338 @@
|
||||
#ifndef REGISTER_DEFS_H
|
||||
#define REGISTER_DEFS_H
|
||||
|
||||
/* Definitions for FPGA*/
|
||||
#define CSP0 0x20200000
|
||||
#define MEM_SIZE 0x100000
|
||||
|
||||
/* FPGA Version register */
|
||||
#define FPGA_VERSION_REG (0x00 << 11)
|
||||
|
||||
#define BOARD_REVISION_OFST (0)
|
||||
#define BOARD_REVISION_MSK (0x00FFFFFF << BOARD_REVISION_OFST)
|
||||
#define DETECTOR_TYPE_OFST (24)
|
||||
#define DETECTOR_TYPE_MSK (0x000000FF << DETECTOR_TYPE_OFST)
|
||||
|
||||
|
||||
|
||||
/* Fix pattern register */
|
||||
#define FIX_PATT_REG (0x01 << 11)
|
||||
|
||||
/* Status register */
|
||||
#define STATUS_REG (0x02 << 11)
|
||||
|
||||
#define RUN_BUSY_OFST (0)
|
||||
#define RUN_BUSY_MSK (0x00000001 << RUN_BUSY_OFST)
|
||||
#define WAITING_FOR_TRIGGER_OFST (3)
|
||||
#define WAITING_FOR_TRIGGER_MSK (0x00000001 << WAITING_FOR_TRIGGER_OFST)
|
||||
#define DELAYBEFORE_OFST (4) //Not used in software
|
||||
#define DELAYBEFORE_MSK (0x00000001 << DELAYBEFORE_OFST) //Not used in software
|
||||
#define DELAYAFTER_OFST (5) //Not used in software
|
||||
#define DELAYAFTER_MSK (0x00000001 << DELAYAFTER_OFST) //Not used in software
|
||||
#define STOPPED_OFST (15)
|
||||
#define STOPPED_MSK (0x00000001 << STOPPED_OFST)
|
||||
#define RUNMACHINE_BUSY_OFST (17)
|
||||
#define RUNMACHINE_BUSY_MSK (0x00000001 << RUNMACHINE_BUSY_OFST)
|
||||
|
||||
|
||||
/* Look at me register */
|
||||
#define LOOK_AT_ME_REG (0x03 << 11) //Not used in firmware or software
|
||||
|
||||
/* System Status register */
|
||||
#define SYSTEM_STATUS_REG (0x04 << 11) //Not used in software
|
||||
|
||||
#define DDR3_CAL_DONE_OFST (0) //Not used in software
|
||||
#define DDR3_CAL_DONE_MSK (0x00000001 << DDR3_CAL_DONE_OFST) //Not used in software
|
||||
#define DDR3_CAL_FAIL_OFST (1) //Not used in software
|
||||
#define DDR3_CAL_FAIL_MSK (0x00000001 << DDR3_CAL_FAIL_OFST) //Not used in software
|
||||
#define DDR3_INIT_DONE_OFST (2) //Not used in software
|
||||
#define DDR3_INIT_DONE_MSK (0x00000001 << DDR3_INIT_DONE_OFST) //Not used in software
|
||||
#define RECONFIG_PLL_LCK_OFST (3) //Not used in software
|
||||
#define RECONFIG_PLL_LCK_MSK (0x00000001 << RECONFIG_PLL_LCK_OFST) //Not used in software
|
||||
#define PLL_A_LCK_OFST (4) //Not used in software
|
||||
#define PLL_A_LCK_MSK (0x00000001 << PLL_A_LCK_OFST) //Not used in software
|
||||
#define DD3_PLL_LCK_OFST (5) //Not used in software
|
||||
#define DD3_PLL_LCK_MSK (0x00000001 << DD3_PLL_LCK_OFST) //Not used in software
|
||||
|
||||
|
||||
/* Module Control Board Serial Number Register */
|
||||
#define MOD_SERIAL_NUM_REG (0x0A << 11) //Not used in software
|
||||
|
||||
#define HARDWARE_SERIAL_NUM_OFST (0) //Not used in software
|
||||
#define HARDWARE_SERIAL_NUM_MSK (0x000000FF << HARDWARE_SERIAL_NUM_OFST) //Not used in software
|
||||
#define HARDWARE_VERSION_NUM_OFST (16) //Not used in software
|
||||
#define HARDWARE_VERSION_NUM_MSK (0x0000003F << HARDWARE_VERSION_NUM_OFST) //Not used in software
|
||||
|
||||
|
||||
/* Time from Start 64 bit register */
|
||||
#define TIME_FROM_START_LSB_REG (0x10 << 11)
|
||||
#define TIME_FROM_START_MSB_REG (0x11 << 11)
|
||||
|
||||
/* Get Delay 64 bit register */
|
||||
#define GET_DELAY_LSB_REG (0x12 << 11)
|
||||
#define GET_DELAY_MSB_REG (0x13 << 11)
|
||||
|
||||
/* Get Cycles 64 bit register */
|
||||
#define GET_CYCLES_LSB_REG (0x14 << 11)
|
||||
#define GET_CYCLES_MSB_REG (0x15 << 11)
|
||||
|
||||
/* Get Frames 64 bit register */
|
||||
#define GET_FRAMES_LSB_REG (0x16 << 11)
|
||||
#define GET_FRAMES_MSB_REG (0x17 << 11)
|
||||
|
||||
/* Get Period 64 bit register */
|
||||
#define GET_PERIOD_LSB_REG (0x18 << 11)
|
||||
#define GET_PERIOD_MSB_REG (0x19 << 11)
|
||||
|
||||
/** Get Temperature Carlos, incorrectl as get gates */
|
||||
#define GET_TEMPERATURE_TMP112_REG (0x1c << 11) // in 10ths of millidegrees of TMP112
|
||||
|
||||
/* Get Frames from Start 64 bit register (frames from start Run Control) */
|
||||
#define FRAMES_FROM_START_PG_LSB_REG (0x24 << 11)
|
||||
#define FRAMES_FROM_START_PG_MSB_REG (0x25 << 11)
|
||||
|
||||
/* Measurement Time 64 bit register (timestamp at a frame start until reset)*/
|
||||
#define START_FRAME_TIME_LSB_REG (0x26 << 11)
|
||||
#define START_FRAME_TIME_MSB_REG (0x27 << 11)
|
||||
|
||||
/* SPI (Serial Peripheral Interface) Register */
|
||||
#define SPI_REG (0x40 << 11)
|
||||
|
||||
#define DAC_SERIAL_DIGITAL_OUT_OFST (0)
|
||||
#define DAC_SERIAL_DIGITAL_OUT_MSK (0x00000001 << DAC_SERIAL_DIGITAL_OUT_OFST)
|
||||
#define DAC_SERIAL_CLK_OUT_OFST (1)
|
||||
#define DAC_SERIAL_CLK_OUT_MSK (0x00000001 << DAC_SERIAL_CLK_OUT_OFST)
|
||||
#define DAC_SERIAL_CS_OUT_OFST (2)
|
||||
#define DAC_SERIAL_CS_OUT_MSK (0x00000001 << DAC_SERIAL_CS_OUT_OFST)
|
||||
#define HV_SERIAL_DIGITAL_OUT_OFST (8)
|
||||
#define HV_SERIAL_DIGITAL_OUT_MSK (0x00000001 << HV_SERIAL_DIGITAL_OUT_OFST)
|
||||
#define HV_SERIAL_CLK_OUT_OFST (9)
|
||||
#define HV_SERIAL_CLK_OUT_MSK (0x00000001 << HV_SERIAL_CLK_OUT_OFST)
|
||||
#define HV_SERIAL_CS_OUT_OFST (10)
|
||||
#define HV_SERIAL_CS_OUT_MSK (0x00000001 << HV_SERIAL_CS_OUT_OFST)
|
||||
|
||||
|
||||
/* ADC SPI (Serial Peripheral Interface) Register */
|
||||
#define ADC_SPI_REG (0x41 << 11)
|
||||
|
||||
#define ADC_SERIAL_CLK_OUT_OFST (0)
|
||||
#define ADC_SERIAL_CLK_OUT_MSK (0x00000001 << ADC_SERIAL_CLK_OUT_OFST)
|
||||
#define ADC_SERIAL_DATA_OUT_OFST (1)
|
||||
#define ADC_SERIAL_DATA_OUT_MSK (0x00000001 << ADC_SERIAL_DATA_OUT_OFST)
|
||||
#define ADC_SERIAL_CS_OUT_OFST (2)
|
||||
#define ADC_SERIAL_CS_OUT_MSK (0x0000000F << ADC_SERIAL_CS_OUT_OFST)
|
||||
|
||||
/* ADC offset Register */
|
||||
#define ADC_OFST_REG (0x42 << 11)
|
||||
|
||||
/* ADC Port Invert Register */
|
||||
#define ADC_PORT_INVERT_REG (0x43 << 11)
|
||||
|
||||
/* Receiver IP Address Register */
|
||||
#define RX_IP_REG (0x45 << 11)
|
||||
|
||||
/* UDP Port */
|
||||
#define UDP_PORT_REG (0x46 << 11)
|
||||
|
||||
#define UDP_PORT_RX_OFST (0)
|
||||
#define UDP_PORT_RX_MSK (0x0000FFFF << UDP_PORT_RX_OFST)
|
||||
#define UDP_PORT_TX_OFST (16)
|
||||
#define UDP_PORT_TX_MSK (0x0000FFFF << UDP_PORT_TX_OFST)
|
||||
|
||||
/* Receiver Mac Address 64 bit Register */
|
||||
#define RX_MAC_LSB_REG (0x47 << 11)
|
||||
#define RX_MAC_MSB_REG (0x48 << 11)
|
||||
|
||||
#define RX_MAC_LSB_OFST (0)
|
||||
#define RX_MAC_LSB_MSK (0xFFFFFFFF << RX_MAC_LSB_OFST)
|
||||
#define RX_MAC_MSB_OFST (0)
|
||||
#define RX_MAC_MSB_MSK (0x0000FFFF << RX_MAC_MSB_OFST)
|
||||
|
||||
/* Detector/ Transmitter Mac Address 64 bit Register */
|
||||
#define TX_MAC_LSB_REG (0x49 << 11)
|
||||
#define TX_MAC_MSB_REG (0x4A << 11)
|
||||
|
||||
#define TX_MAC_LSB_OFST (0)
|
||||
#define TX_MAC_LSB_MSK (0xFFFFFFFF << TX_MAC_LSB_OFST)
|
||||
#define TX_MAC_MSB_OFST (0)
|
||||
#define TX_MAC_MSB_MSK (0x0000FFFF << TX_MAC_MSB_OFST)
|
||||
|
||||
/* Detector/ Transmitter IP Address Register */
|
||||
#define TX_IP_REG (0x4B << 11)
|
||||
|
||||
/* Detector/ Transmitter IP Checksum Register */
|
||||
#define TX_IP_CHECKSUM_REG (0x4C << 11)
|
||||
|
||||
#define TX_IP_CHECKSUM_OFST (0)
|
||||
#define TX_IP_CHECKSUM_MSK (0x0000FFFF << TX_IP_CHECKSUM_OFST)
|
||||
|
||||
/* Configuration Register */
|
||||
#define CONFIG_REG (0x4D << 11)
|
||||
|
||||
#define CONFIG_OPERATION_MODE_OFST (16)
|
||||
#define CONFIG_OPERATION_MODE_MSK (0x00000001 << CONFIG_OPERATION_MODE_OFST)
|
||||
#define CONFIG_MODE_1_X_10GBE_VAL ((0x0 << CONFIG_OPERATION_MODE_OFST) & CONFIG_OPERATION_MODE_MSK)
|
||||
#define CONFIG_MODE_2_X_10GBE_VAL ((0x1 << CONFIG_OPERATION_MODE_OFST) & CONFIG_OPERATION_MODE_MSK)
|
||||
#define CONFIG_READOUT_SPEED_OFST (20)
|
||||
#define CONFIG_READOUT_SPEED_MSK (0x00000003 << CONFIG_READOUT_SPEED_OFST)
|
||||
#define CONFIG_QUARTER_SPEED_10MHZ_VAL ((0x0 << CONFIG_READOUT_SPEED_OFST) & CONFIG_READOUT_SPEED_MSK)
|
||||
#define CONFIG_HALF_SPEED_20MHZ_VAL ((0x1 << CONFIG_READOUT_SPEED_OFST) & CONFIG_READOUT_SPEED_MSK)
|
||||
#define CONFIG_FULL_SPEED_40MHZ_VAL ((0x2 << CONFIG_READOUT_SPEED_OFST) & CONFIG_READOUT_SPEED_MSK)
|
||||
#define CONFIG_TDMA_OFST (24)
|
||||
#define CONFIG_TDMA_MSK (0x00000001 << CONFIG_TDMA_OFST)
|
||||
#define CONFIG_TDMA_DISABLE_VAL ((0x0 << CONFIG_TDMA_OFST) & CONFIG_TDMA_MSK)
|
||||
#define CONFIG_TDMA_ENABLE_VAL ((0x1 << CONFIG_TDMA_OFST) & CONFIG_TDMA_MSK)
|
||||
#define CONFIG_TDMA_TIMESLOT_OFST (25)
|
||||
#define CONFIG_TDMA_TIMESLOT_MSK (0x0000001F << CONFIG_TDMA_TIMESLOT_OFST)
|
||||
#define CONFIG_TDMA_TIMESLOT_0_VAL ((0x0 << CONFIG_TDMA_TIMESLOT_OFST) & CONFIG_TDMA_TIMESLOT_MSK)
|
||||
|
||||
/* External Signal Register */
|
||||
#define EXT_SIGNAL_REG (0x4E << 11)
|
||||
|
||||
#define EXT_SIGNAL_OFST (0)
|
||||
#define EXT_SIGNAL_MSK (0x00000003 << EXT_SIGNAL_OFST) //enabled when both bits high
|
||||
|
||||
/* Control Register */
|
||||
#define CONTROL_REG (0x4F << 11)
|
||||
|
||||
#define CONTROL_START_ACQ_OFST (0)
|
||||
#define CONTROL_START_ACQ_MSK (0x00000001 << CONTROL_START_ACQ_OFST)
|
||||
#define CONTROL_STOP_ACQ_OFST (1)
|
||||
#define CONTROL_STOP_ACQ_MSK (0x00000001 << CONTROL_STOP_ACQ_OFST)
|
||||
#define CONTROL_CORE_RST_OFST (10)
|
||||
#define CONTROL_CORE_RST_MSK (0x00000001 << CONTROL_CORE_RST_OFST)
|
||||
#define CONTROL_PERIPHERAL_RST_OFST (11) //DDR3 HMem Ctrlr, GBE, Temp
|
||||
#define CONTROL_PERIPHERAL_RST_MSK (0x00000001 << CONTROL_PERIPHERAL_RST_OFST) //DDR3 HMem Ctrlr, GBE, Temp
|
||||
#define CONTROL_DDR3_MEM_RST_OFST (12) //only PHY, not DDR3 PLL ,Not used in software
|
||||
#define CONTROL_DDR3_MEM_RST_MSK (0x00000001 << CONTROL_DDR3_MEM_RST_OFST) //only PHY, not DDR3 PLL ,Not used in software
|
||||
#define CONTROL_ACQ_FIFO_CLR_OFST (14)
|
||||
#define CONTROL_ACQ_FIFO_CLR_MSK (0x00000001 << CONTROL_ACQ_FIFO_CLR_OFST)
|
||||
|
||||
/* Reconfiguratble PLL Paramater Register */
|
||||
#define PLL_PARAM_REG (0x50 << 11)
|
||||
|
||||
/* Reconfiguratble PLL Control Regiser */
|
||||
#define PLL_CONTROL_REG (0x51 << 11)
|
||||
|
||||
#define PLL_CTRL_RECONFIG_RST_OFST (0) //parameter reset
|
||||
#define PLL_CTRL_RECONFIG_RST_MSK (0x00000001 << PLL_CTRL_RECONFIG_RST_OFST) //parameter reset
|
||||
#define PLL_CTRL_WR_PARAMETER_OFST (2)
|
||||
#define PLL_CTRL_WR_PARAMETER_MSK (0x00000001 << PLL_CTRL_WR_PARAMETER_OFST)
|
||||
#define PLL_CTRL_RST_OFST (3)
|
||||
#define PLL_CTRL_RST_MSK (0x00000001 << PLL_CTRL_RST_OFST)
|
||||
#define PLL_CTRL_ADDR_OFST (16)
|
||||
#define PLL_CTRL_ADDR_MSK (0x0000003F << PLL_CTRL_ADDR_OFST)
|
||||
|
||||
/* Sample Register (Obsolete) */
|
||||
#define SAMPLE_REG (0x59 << 11)
|
||||
|
||||
#define SAMPLE_ADC_SAMPLE_SEL_OFST (0)
|
||||
#define SAMPLE_ADC_SAMPLE_SEL_MSK (0x00000007 << SAMPLE_ADC_SAMPLE_SEL_OFST)
|
||||
#define SAMPLE_ADC_SAMPLE_0_VAL ((0x0 << SAMPLE_ADC_SAMPLE_SEL_OFST) & SAMPLE_ADC_SAMPLE_SEL_MSK)
|
||||
#define SAMPLE_ADC_SAMPLE_1_VAL ((0x1 << SAMPLE_ADC_SAMPLE_SEL_OFST) & SAMPLE_ADC_SAMPLE_SEL_MSK)
|
||||
#define SAMPLE_ADC_SAMPLE_2_VAL ((0x2 << SAMPLE_ADC_SAMPLE_SEL_OFST) & SAMPLE_ADC_SAMPLE_SEL_MSK)
|
||||
#define SAMPLE_ADC_SAMPLE_3_VAL ((0x3 << SAMPLE_ADC_SAMPLE_SEL_OFST) & SAMPLE_ADC_SAMPLE_SEL_MSK)
|
||||
#define SAMPLE_ADC_SAMPLE_4_VAL ((0x4 << SAMPLE_ADC_SAMPLE_SEL_OFST) & SAMPLE_ADC_SAMPLE_SEL_MSK)
|
||||
#define SAMPLE_ADC_SAMPLE_5_VAL ((0x5 << SAMPLE_ADC_SAMPLE_SEL_OFST) & SAMPLE_ADC_SAMPLE_SEL_MSK)
|
||||
#define SAMPLE_ADC_SAMPLE_6_VAL ((0x6 << SAMPLE_ADC_SAMPLE_SEL_OFST) & SAMPLE_ADC_SAMPLE_SEL_MSK)
|
||||
#define SAMPLE_ADC_SAMPLE_7_VAL ((0x7 << SAMPLE_ADC_SAMPLE_SEL_OFST) & SAMPLE_ADC_SAMPLE_SEL_MSK)
|
||||
|
||||
#define SAMPLE_ADC_DECMT_FACTOR_OFST (4)
|
||||
#define SAMPLE_ADC_DECMT_FACTOR_MSK (0x00000007 << SAMPLE_ADC_DECMT_FACTOR_OFST)
|
||||
#define SAMPLE_ADC_DECMT_FACTOR_0_VAL ((0x0 << SAMPLE_ADC_DECMT_FACTOR_OFST) & SAMPLE_ADC_DECMT_FACTOR_MSK)
|
||||
#define SAMPLE_ADC_DECMT_FACTOR_1_VAL ((0x1 << SAMPLE_ADC_DECMT_FACTOR_OFST) & SAMPLE_ADC_DECMT_FACTOR_MSK)
|
||||
#define SAMPLE_ADC_DECMT_FACTOR_2_VAL ((0x2 << SAMPLE_ADC_DECMT_FACTOR_OFST) & SAMPLE_ADC_DECMT_FACTOR_MSK)
|
||||
#define SAMPLE_ADC_DECMT_FACTOR_3_VAL ((0x3 << SAMPLE_ADC_DECMT_FACTOR_OFST) & SAMPLE_ADC_DECMT_FACTOR_MSK)
|
||||
#define SAMPLE_ADC_DECMT_FACTOR_4_VAL ((0x4 << SAMPLE_ADC_DECMT_FACTOR_OFST) & SAMPLE_ADC_DECMT_FACTOR_MSK)
|
||||
#define SAMPLE_ADC_DECMT_FACTOR_5_VAL ((0x5 << SAMPLE_ADC_DECMT_FACTOR_OFST) & SAMPLE_ADC_DECMT_FACTOR_MSK)
|
||||
#define SAMPLE_ADC_DECMT_FACTOR_6_VAL ((0x6 << SAMPLE_ADC_DECMT_FACTOR_OFST) & SAMPLE_ADC_DECMT_FACTOR_MSK)
|
||||
#define SAMPLE_ADC_DECMT_FACTOR_7_VAL ((0x7 << SAMPLE_ADC_DECMT_FACTOR_OFST) & SAMPLE_ADC_DECMT_FACTOR_MSK)
|
||||
|
||||
#define SAMPLE_DGTL_SAMPLE_SEL_OFST (8)
|
||||
#define SAMPLE_DGTL_SAMPLE_SEL_MSK (0x0000000F << SAMPLE_DGTL_SAMPLE_SEL_OFST)
|
||||
#define SAMPLE_DGTL_SAMPLE_0_VAL ((0x0 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
|
||||
#define SAMPLE_DGTL_SAMPLE_1_VAL ((0x1 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
|
||||
#define SAMPLE_DGTL_SAMPLE_2_VAL ((0x2 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
|
||||
#define SAMPLE_DGTL_SAMPLE_3_VAL ((0x3 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
|
||||
#define SAMPLE_DGTL_SAMPLE_4_VAL ((0x4 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
|
||||
#define SAMPLE_DGTL_SAMPLE_5_VAL ((0x5 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
|
||||
#define SAMPLE_DGTL_SAMPLE_6_VAL ((0x6 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
|
||||
#define SAMPLE_DGTL_SAMPLE_7_VAL ((0x7 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
|
||||
#define SAMPLE_DGTL_SAMPLE_8_VAL ((0x8 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
|
||||
#define SAMPLE_DGTL_SAMPLE_9_VAL ((0x9 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
|
||||
#define SAMPLE_DGTL_SAMPLE_10_VAL ((0xa << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
|
||||
#define SAMPLE_DGTL_SAMPLE_11_VAL ((0xb << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
|
||||
#define SAMPLE_DGTL_SAMPLE_12_VAL ((0xc << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
|
||||
#define SAMPLE_DGTL_SAMPLE_13_VAL ((0xd << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
|
||||
#define SAMPLE_DGTL_SAMPLE_14_VAL ((0xe << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
|
||||
#define SAMPLE_DGTL_SAMPLE_15_VAL ((0xf << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
|
||||
|
||||
#define SAMPLE_DGTL_DECMT_FACTOR_OFST (12)
|
||||
#define SAMPLE_DGTL_DECMT_FACTOR_MSK (0x00000003 << SAMPLE_DGTL_DECMT_FACTOR_OFST)
|
||||
#define SAMPLE_DECMT_FACTOR_1_VAL ((0x0 << SAMPLE_DGTL_DECMT_FACTOR_OFST) & SAMPLE_DGTL_DECMT_FACTOR_MSK)
|
||||
#define SAMPLE_DECMT_FACTOR_2_VAL ((0x1 << SAMPLE_DGTL_DECMT_FACTOR_OFST) & SAMPLE_DGTL_DECMT_FACTOR_MSK)
|
||||
#define SAMPLE_DECMT_FACTOR_4_VAL ((0x2 << SAMPLE_DGTL_DECMT_FACTOR_OFST) & SAMPLE_DGTL_DECMT_FACTOR_MSK)
|
||||
|
||||
/** Vref Comp Mod Register */
|
||||
#define VREF_COMP_MOD_REG (0x5C << 11) //Not used in software, TBD in firmware
|
||||
|
||||
/** DAQ Register */
|
||||
#define DAQ_REG (0x5D << 11) //TBD in firmware
|
||||
|
||||
/** Chip Power Register */
|
||||
#define CHIP_POWER_REG (0x5E << 11)
|
||||
|
||||
#define CHIP_POWER_ENABLE_OFST (0)
|
||||
#define CHIP_POWER_ENABLE_MSK (0x00000001 << CHIP_POWER_ENABLE_OFST)
|
||||
|
||||
/* Set Delay 64 bit register */
|
||||
#define SET_DELAY_LSB_REG (0x60 << 11)
|
||||
#define SET_DELAY_MSB_REG (0x61 << 11)
|
||||
|
||||
/* Set Cycles 64 bit register */
|
||||
#define SET_CYCLES_LSB_REG (0x62 << 11)
|
||||
#define SET_CYCLES_MSB_REG (0x63 << 11)
|
||||
|
||||
/* Set Frames 64 bit register */
|
||||
#define SET_FRAMES_LSB_REG (0x64 << 11)
|
||||
#define SET_FRAMES_MSB_REG (0x65 << 11)
|
||||
|
||||
/* Set Period 64 bit register */
|
||||
#define SET_PERIOD_LSB_REG (0x66 << 11)
|
||||
#define SET_PERIOD_MSB_REG (0x67 << 11)
|
||||
|
||||
/* Set Period 64 bit register */
|
||||
#define SET_EXPTIME_LSB_REG (0x68 << 11)
|
||||
#define SET_EXPTIME_MSB_REG (0x69 << 11)
|
||||
|
||||
/* Module Coordinates Register 0 */
|
||||
#define COORD_0 (0x7C << 11)
|
||||
|
||||
#define COORD_0_Y_OFST (0)
|
||||
#define COORD_0_Y_MSK (0x0000FFFF << COORD_0_Y_OFST)
|
||||
#define COORD_0_X_OFST (16)
|
||||
#define COORD_0_X_MSK (0x0000FFFF << COORD_0_X_OFST)
|
||||
|
||||
/* Module Coordinates Register 1 */
|
||||
#define COORD_1 (0x7D << 11)
|
||||
|
||||
#define COORD_0_Z_OFST (0)
|
||||
#define COORD_0_Z_MSK (0x0000FFFF << COORD_0_Z_OFST)
|
||||
|
||||
|
||||
#endif //REGISTERS_G_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
/afs/psi.ch/project/sls_det_software/dhanya_softwareDevelopment/mySoft/slsDetectorsPackage/slsReceiverSoftware/include/ansi.h
|
||||
../../slsReceiverSoftware/include/ansi.h
|
||||
BIN
slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServerv3.0.0.1.1
Executable file
BIN
slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServerv3.0.0.1.1
Executable file
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -1,226 +0,0 @@
|
||||
#ifndef FIRMWARE_FUNCS_H
|
||||
#define FIRMWARE_FUNCS_H
|
||||
|
||||
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
//#include <asm/page.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
int mapCSP0(void);
|
||||
void defineGPIOpins();
|
||||
void resetFPGA();
|
||||
void FPGAdontTouchFlash();
|
||||
void FPGATouchFlash();
|
||||
int powerChip (int on);
|
||||
void initializeDetector();
|
||||
|
||||
u_int16_t bus_r16(u_int32_t offset);
|
||||
u_int16_t bus_w16(u_int32_t offset, u_int16_t data);//aldos function
|
||||
u_int32_t bus_w(u_int32_t offset, u_int32_t data);
|
||||
u_int32_t bus_r(u_int32_t offset);
|
||||
|
||||
int setPhaseShiftOnce();
|
||||
int adcPhase(int st);
|
||||
int getPhase();
|
||||
int cleanFifo();
|
||||
int setDAQRegister();
|
||||
|
||||
u_int32_t putout(char *s, int modnum);
|
||||
u_int32_t readin(int modnum);
|
||||
u_int32_t setClockDivider(int d);
|
||||
u_int32_t getClockDivider();
|
||||
|
||||
void resetPLL();
|
||||
u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val, int trig);
|
||||
u_int32_t getPllReconfigReg(u_int32_t reg, int trig);
|
||||
|
||||
u_int32_t setSetLength(int d);
|
||||
u_int32_t getSetLength();
|
||||
u_int32_t setWaitStates(int d);
|
||||
u_int32_t getWaitStates();
|
||||
u_int32_t setTotClockDivider(int d);
|
||||
u_int32_t getTotClockDivider();
|
||||
u_int32_t setTotDutyCycle(int d);
|
||||
u_int32_t getTotDutyCycle();
|
||||
u_int32_t setOversampling(int d);
|
||||
u_int32_t adcPipeline(int d);
|
||||
u_int32_t dbitPipeline(int d);
|
||||
|
||||
u_int32_t setExtSignal(int d, enum externalSignalFlag mode);
|
||||
int getExtSignal(int d);
|
||||
|
||||
u_int32_t setFPGASignal(int d, enum externalSignalFlag mode);
|
||||
int getFPGASignal(int d);
|
||||
|
||||
int setTiming(int t);
|
||||
|
||||
|
||||
int setConfigurationRegister(int d);
|
||||
int setToT(int d);
|
||||
int setContinousReadOut(int d);
|
||||
|
||||
int setDACRegister(int idac, int val, int imod);
|
||||
int getDacRegister(int dacnum);
|
||||
|
||||
|
||||
int getTemperature(int tempSensor,int imod);
|
||||
int initHighVoltage(int val,int imod);
|
||||
int initConfGain(int isettings,int val,int imod);
|
||||
int initSpeedConfGain(int val);
|
||||
|
||||
int setADC(int adc);
|
||||
//int configureMAC(int ipad, long long int macad, long long int detectormacadd, int detipad, int ival, int udpport);
|
||||
int configureMAC(uint32_t destip,uint64_t destmac,uint64_t sourcemac,int detipad,int ival,uint32_t destport);
|
||||
int getAdcConfigured();
|
||||
|
||||
|
||||
u_int64_t getDetectorNumber();
|
||||
u_int32_t getFirmwareVersion();
|
||||
u_int32_t getFirmwareSVNVersion();
|
||||
|
||||
int testFifos(void);
|
||||
u_int32_t testFpga(void);
|
||||
u_int32_t testRAM(void);
|
||||
int testBus(void);
|
||||
int setDigitalTestBit(int ival);
|
||||
|
||||
int64_t set64BitReg(int64_t value, int aLSB, int aMSB);
|
||||
int64_t get64BitReg(int aLSB, int aMSB);
|
||||
|
||||
int64_t setFrames(int64_t value);
|
||||
int64_t getFrames();
|
||||
|
||||
int64_t setExposureTime(int64_t value);
|
||||
int64_t getExposureTime();
|
||||
|
||||
int64_t setGates(int64_t value);
|
||||
int64_t getGates();
|
||||
|
||||
int64_t setDelay(int64_t value);
|
||||
int64_t getDelay();
|
||||
|
||||
int64_t setPeriod(int64_t value);
|
||||
int64_t getPeriod();
|
||||
|
||||
int64_t setTrains(int64_t value);
|
||||
int64_t getTrains();
|
||||
|
||||
|
||||
int64_t setProbes(int64_t value);
|
||||
int64_t getProbes();
|
||||
|
||||
int64_t setSamples(int64_t value);
|
||||
int64_t getSamples();
|
||||
|
||||
int64_t getProgress();
|
||||
int64_t setProgress();
|
||||
|
||||
int64_t getActualTime();
|
||||
int64_t getMeasurementTime();
|
||||
int64_t getFramesFromStart();
|
||||
|
||||
u_int32_t runBusy(void);
|
||||
u_int32_t runState(void);
|
||||
u_int32_t dataPresent(void);
|
||||
|
||||
|
||||
int startStateMachine();
|
||||
int stopStateMachine();
|
||||
int startReadOut();
|
||||
u_int32_t fifoReset(void);
|
||||
u_int32_t fifoReadCounter(int fifonum);
|
||||
u_int32_t fifoReadStatus();
|
||||
|
||||
|
||||
u_int32_t fifo_full(void);
|
||||
|
||||
|
||||
void waitForAcquisitionEnd();
|
||||
u_int32_t* decode_data(int* datain);
|
||||
//u_int32_t move_data(u_int64_t* datain, u_int64_t* dataout);
|
||||
int setDynamicRange(int dr);
|
||||
int getDynamicRange();
|
||||
int getNModBoard();
|
||||
int setNMod(int n);
|
||||
int getNMod();
|
||||
|
||||
int setStoreInRAM(int b);
|
||||
int allocateRAM();
|
||||
|
||||
|
||||
int writeADC(int addr, int val);
|
||||
int prepareADC();
|
||||
|
||||
|
||||
int clearRAM();
|
||||
|
||||
|
||||
int setMaster(int f);
|
||||
int setSynchronization(int s);
|
||||
|
||||
int loadImage(int index, short int ImageVals[]);
|
||||
int readCounterBlock(int startACQ, short int CounterVals[]);
|
||||
int resetCounterBlock(int startACQ);
|
||||
|
||||
int calibratePedestal(int frames);
|
||||
|
||||
uint64_t writePatternWord(int addr, uint64_t word);
|
||||
uint64_t writePatternIOControl(uint64_t word);
|
||||
uint64_t writePatternClkControl(uint64_t word);
|
||||
int setPatternLoop(int level, int *start, int *stop, int *n);
|
||||
int setPatternWaitAddress(int level, int addr);
|
||||
uint64_t setPatternWaitTime(int level, uint64_t t);
|
||||
|
||||
|
||||
void initDac(int dacnum);
|
||||
int setDac(int dacnum,int dacvalue);
|
||||
|
||||
ROI *setROI(int nroi,ROI* arg,int *retvalsize, int *ret);
|
||||
int getChannels();
|
||||
|
||||
void eraseFlash();
|
||||
int startWritingFPGAprogram(FILE** filefp);
|
||||
int stopWritingFPGAprogram(FILE* filefp);
|
||||
int writeFPGAProgram(char* fpgasrc, size_t fsize, FILE* filefp);
|
||||
|
||||
/*
|
||||
|
||||
u_int32_t setNBits(u_int32_t);
|
||||
u_int32_t getNBits();
|
||||
*/
|
||||
|
||||
/*
|
||||
//move to mcb_funcs?
|
||||
|
||||
int readOutChan(int *val);
|
||||
u_int32_t getModuleNumber(int modnum);
|
||||
int testShiftIn(int imod);
|
||||
int testShiftOut(int imod);
|
||||
int testShiftStSel(int imod);
|
||||
int testDataInOut(int num, int imod);
|
||||
int testExtPulse(int imod);
|
||||
int testExtPulseMux(int imod, int ow);
|
||||
int testDataInOutMux(int imod, int ow, int num);
|
||||
int testOutMux(int imod);
|
||||
int testFpgaMux(int imod);
|
||||
int calibration_sensor(int num, int *values, int *dacs) ;
|
||||
int calibration_chip(int num, int *values, int *dacs);
|
||||
*/
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,9 +1,9 @@
|
||||
Path: slsDetectorsPackage/slsDetectorSoftware/jungfrauDetectorServer
|
||||
URL: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git/jungfrauDetectorServer
|
||||
Repository Root: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git
|
||||
Repsitory UUID: 230d6b36e9852214f4ba5ae7c92647f35000b24d
|
||||
Revision: 56
|
||||
Repsitory UUID: 6d38c0622a2936f70345e7d53aaf1c9e2de4cbd6
|
||||
Revision: 75
|
||||
Branch: developer
|
||||
Last Changed Author: Dhanya_Maliakal
|
||||
Last Changed Rev: 1313
|
||||
Last Changed Date: 2016-11-30 10:36:34 +0100
|
||||
Last Changed Rev: 1401
|
||||
Last Changed Date: 2017-06-12 18:53:18 +0200
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
//#define SVNPATH ""
|
||||
#define SVNURL "git@git.psi.ch:sls_detectors_software/sls_detector_software.git/jungfrauDetectorServer"
|
||||
//#define SVNREPPATH ""
|
||||
#define SVNREPUUID "230d6b36e9852214f4ba5ae7c92647f35000b24d"
|
||||
//#define SVNREV 0x1313
|
||||
#define SVNREPUUID "6d38c0622a2936f70345e7d53aaf1c9e2de4cbd6"
|
||||
//#define SVNREV 0x1401
|
||||
//#define SVNKIND ""
|
||||
//#define SVNSCHED ""
|
||||
#define SVNAUTH "Dhanya_Maliakal"
|
||||
#define SVNREV 0x1313
|
||||
#define SVNDATE 0x20161130
|
||||
#define SVNREV 0x1401
|
||||
#define SVNDATE 0x20170612
|
||||
//
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -1,174 +0,0 @@
|
||||
#ifdef MCB_FUNCS
|
||||
|
||||
#ifndef MCB_FUNCS_H
|
||||
#define MCB_FUNCS_H
|
||||
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
#define RGPRVALS {100,50,200}
|
||||
#define RGSH1VALS {300,200,400}
|
||||
#define RGSH2VALS {260,300,260}
|
||||
|
||||
|
||||
#define DEFAULTGAIN {11.66,9.32,14.99}
|
||||
#define DEFAULTOFFSET {817.5,828.6,804.2}
|
||||
|
||||
// DAC definitions
|
||||
enum dacsVal{VDAC0, VDAC1, VDAC2, VDAC3, VDAC4, VDAC5, VDAC6, VDAC7, HIGH_VOLTAGE, CONFGAIN};
|
||||
|
||||
/* DAC adresses */
|
||||
#define DACCS {0,0,1,1,2,2,3,3,4,4,5,5,6,6}
|
||||
#define DACADDR {0,1,0,1,0,1,0,1,0,1,0,1,0,1}
|
||||
|
||||
//Register Definitions for temp,hv,dac gain
|
||||
enum adcVals{TEMP_FPGA, TEMP_ADC};
|
||||
|
||||
//dynamic range
|
||||
/*
|
||||
#define MAX5523 commented out by dhanya
|
||||
#ifndef MAX5523
|
||||
#define MAX5533
|
||||
#endif
|
||||
#ifdef MAX5533
|
||||
#define DAC_DR 4096
|
||||
#endif
|
||||
#ifdef MAX5523
|
||||
*/
|
||||
#define DAC_DR 1024
|
||||
//#endif
|
||||
|
||||
|
||||
//reference voltage
|
||||
#define DAC_REFOUT1
|
||||
#ifdef DAC_REFOUT2
|
||||
#define DAC_MAX 2.425
|
||||
#define DAC_REFOUT 2
|
||||
#define DAC_REFOUT1
|
||||
#endif
|
||||
#ifdef DAC_REFOUT3
|
||||
#define DAC_MAX 3.885
|
||||
#define DAC_REFOUT 3
|
||||
#define DAC_REFOUT1
|
||||
#endif
|
||||
#ifdef DAC_REFOUT0
|
||||
#define DAC_MAX 1.214
|
||||
#define DAC_REFOUT 0
|
||||
#endif
|
||||
#ifdef DAC_REFOUT1
|
||||
#define DAC_MAX 1.940
|
||||
#define DAC_REFOUT 1
|
||||
#endif
|
||||
|
||||
/* dac calibration constants */
|
||||
|
||||
#define VA 1.11
|
||||
|
||||
#define CVTRIM 52.430851
|
||||
#define BVTRIM -0.102022
|
||||
#define AVTRIM 0.000050
|
||||
|
||||
#define PARTREF {100,1.55,-2.5,-2.5,0,-2.5}
|
||||
#define PARTR1 {78,10,10,10,10,10}
|
||||
#define PARTR2 {0,4.7,27,47,22,47}
|
||||
|
||||
|
||||
//chip shiftin register meaning
|
||||
#define OUTMUX_OFFSET 20
|
||||
#define PROBES_OFFSET 4
|
||||
#define OUTBUF_OFFSET 0
|
||||
|
||||
|
||||
void showbits(int h);
|
||||
|
||||
int initDetector();
|
||||
int copyChannel(sls_detector_channel *destChan, sls_detector_channel *srcChan);
|
||||
int copyChip(sls_detector_chip *destChip, sls_detector_chip *srcChip);
|
||||
int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod);
|
||||
|
||||
/* Register commands */
|
||||
/* int clearDACSregister(int imod ); */
|
||||
/* int nextDAC(int imod ); */
|
||||
int clearCSregister(int imod );
|
||||
int setCSregister(int imod );
|
||||
int nextChip(int imod );
|
||||
int firstChip(int imod );
|
||||
int clearSSregister(int imod );
|
||||
int setSSregister(int imod );
|
||||
int nextStrip(int imod );
|
||||
int selChannel(int strip,int imod );
|
||||
int selChip(int chip,int imod );
|
||||
int selMod(int mod,int imod );
|
||||
|
||||
/* DACs routines */
|
||||
/* int program_one_dac(int addr, int value,int imod ); */
|
||||
/* int set_one_dac(int imod); */
|
||||
/* int initDAC(int dac_addr, int value,int imod ); */
|
||||
/* int initDACs(int* v,int imod ); */
|
||||
/* int initDACbyIndex(int ind,int val, int imod); */
|
||||
/* int initDACbyIndexDACU(int ind,int val, int imod); */
|
||||
/* int getDACbyIndexDACU(int ind, int imod); */
|
||||
/* int getThresholdEnergy(); */
|
||||
/* int setThresholdEnergy(int ethr); */
|
||||
|
||||
|
||||
int setSettings(int i,int imod);
|
||||
|
||||
|
||||
/* Other DAC index routines*/
|
||||
int getTemperatureByModule(int tempSensor, int imod);
|
||||
int initHighVoltageByModule(int val, int imod);
|
||||
int initConfGainByModule(int isettings,int val,int imod);
|
||||
|
||||
/* Initialization*/
|
||||
int initChannel(int ft,int cae, int ae, int coe, int ocoe, int counts,int imod );
|
||||
int initChannelbyNumber(sls_detector_channel myChan);
|
||||
int getChannelbyNumber(sls_detector_channel*);
|
||||
|
||||
int getTrimbit(int imod, int ichip, int ichan);
|
||||
|
||||
int initChip(int obe, int ow,int imod );
|
||||
|
||||
int initChipWithProbes(int obe, int ow,int nprobes, int imod);
|
||||
//int getNProbes();
|
||||
|
||||
int initChipbyNumber(sls_detector_chip myChip);
|
||||
int getChipbyNumber(sls_detector_chip*);
|
||||
int initMCBregisters(int cm,int imod );
|
||||
int initModulebyNumber(sls_detector_module);
|
||||
int getModulebyNumber(sls_detector_module*);
|
||||
|
||||
/* To chips */
|
||||
int clearCounter(int imod );
|
||||
int clearOutReg(int imod);
|
||||
int setOutReg(int imod );
|
||||
int extPulse(int ncal,int imod );
|
||||
int calPulse(int ncal,int imod );
|
||||
int counterClear(int imod );
|
||||
int countEnable(int imod );
|
||||
int counterSet(int imod );
|
||||
|
||||
|
||||
/* moved from firmware_funcs */
|
||||
|
||||
int readOutChan(int *val);
|
||||
|
||||
int getModuleNumber(int modnum);
|
||||
int testShiftIn(int imod);
|
||||
int testShiftOut(int imod);
|
||||
int testShiftStSel(int imod);
|
||||
int testDataInOut(int num, int imod);
|
||||
int testExtPulse(int imod);
|
||||
int testExtPulseMux(int imod, int ow);
|
||||
int testDataInOutMux(int imod, int ow, int num);
|
||||
int testOutMux(int imod);
|
||||
int testFpgaMux(int imod);
|
||||
int calibration_sensor(int num, int *values, int *dacs) ;
|
||||
int calibration_chip(int num, int *values, int *dacs);
|
||||
|
||||
|
||||
|
||||
//ROI* setROI(int n, ROI arg[], int *retvalsize, int *ret);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,534 +0,0 @@
|
||||
#ifndef REGISTERS_G_H
|
||||
#define REGISTERS_G_H
|
||||
|
||||
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
|
||||
/* Definitions for FPGA*/
|
||||
#define CSP0 0x20200000
|
||||
#define MEM_SIZE 0x100000
|
||||
|
||||
|
||||
//Constants
|
||||
#define HALFSPEED_DBIT_PIPELINE 0x7f7c
|
||||
#define QUARTERSPEED_DBIT_PIPELINE 0x8981
|
||||
#define HALFSPEED_ADC_PIPELINE 0x20
|
||||
#define QUARTERSPEED_ADC_PIPELINE 0x10
|
||||
#define HALFSPEED_CONF 0x0
|
||||
#define QUARTERSPEED_CONF 0xf
|
||||
#define HALFSPEED_ADC_PHASE 65
|
||||
#define QUARTERSPEED_ADC_PHASE 25
|
||||
|
||||
/* values defined for FPGA */
|
||||
#define MCSNUM 0x0
|
||||
#define FIXED_PATT_VAL 0xacdc1980
|
||||
|
||||
|
||||
#define FPGA_INIT_PAT 0x60008
|
||||
#define FPGA_INIT_ADDR 0xb0000000
|
||||
|
||||
//#ifdef JUNGFRAU_DHANYA
|
||||
#define POWER_ON_REG 0x5e<<11
|
||||
#define ADCREG1 0x8 //same as PLL_BANDWIDTH_REG
|
||||
#define ADCREG2 0x14
|
||||
#define ADCREG3 0x4 //same as PLL_M_COUNTER_REG
|
||||
#define ADCREG4 0x5 //same as PLL_C_COUNTER_REG
|
||||
#define ADCREG_VREFS 0x18
|
||||
#define DBIT_PIPELINE_REG 0x59<<11 //same PATTERN_N_LOOP2_REG
|
||||
#define MEM_MACHINE_FIFOS_REG 0x4f<<11 //same as CONTROL_REG
|
||||
#define CONFGAIN_REG 0x5d<<11 //same as DAQ_REG
|
||||
#define ADC_PIPELINE_REG 0x42<<11 //same as ADC_OFFSET_REG
|
||||
//#endif
|
||||
|
||||
//#define ADC_OFFSET_REG 66<<11 //same as CONFGAIN_REG
|
||||
#define ADC_INVERSION_REG 0x43<<11
|
||||
|
||||
#define DAC_REG 64<<11//0x17<<11// control the dacs
|
||||
//ADC
|
||||
#define ADC_WRITE_REG 65<<11//0x18<<11
|
||||
//#define ADC_SYNC_REG 66<<11//0x19<<11
|
||||
//#define HV_REG 67<<11//0x20<<11
|
||||
|
||||
|
||||
|
||||
|
||||
//#define MUTIME_REG 0x1a<<11
|
||||
//temperature
|
||||
#define TEMP_IN_REG 0x1b<<11
|
||||
#define TEMP_OUT_REG 0x1c<<11
|
||||
//configure MAC
|
||||
#define TSE_CONF_REG 0x1d<<11
|
||||
#define ENET_CONF_REG 0x1e<<11
|
||||
//#define WRTSE_SHAD_REG 0x1f<<11
|
||||
//HV
|
||||
|
||||
|
||||
#define DUMMY_REG 0x44<<11
|
||||
#define FPGA_VERSION_REG 0<<11 //0x22<<11
|
||||
#define PCB_REV_REG 0<<11
|
||||
#define FIX_PATT_REG 1<<11 //0x23<<11
|
||||
#define CONTROL_REG 79<<11//0x24<<11
|
||||
#define STATUS_REG 2<<11 //0x25<<11
|
||||
#define CONFIG_REG 77<<11//0x26<<11
|
||||
#define EXT_SIGNAL_REG 78<<11// 0x4E<<11
|
||||
#define FPGA_SVN_REG 0x29<<11
|
||||
|
||||
|
||||
#define CHIP_OF_INTRST_REG 0x2A<<11
|
||||
|
||||
//FIFO
|
||||
#define LOOK_AT_ME_REG 3<<11 //0x28<<11
|
||||
#define SYSTEM_STATUS_REG 4<<11
|
||||
|
||||
#define FIFO_DATA_REG 6<<11
|
||||
#define FIFO_STATUS_REG 7<<11
|
||||
|
||||
|
||||
#define FIFO_DATA_REG_OFF 0x50<<11 ///////
|
||||
//to read back dac registers
|
||||
#define MOD_DACS1_REG 0x65<<11
|
||||
#define MOD_DACS2_REG 0x66<<11
|
||||
#define MOD_DACS3_REG 0x67<<11
|
||||
|
||||
//user entered
|
||||
|
||||
|
||||
#define NSAMPLES_REG 95<<11
|
||||
|
||||
|
||||
|
||||
|
||||
#define GET_ACTUAL_TIME_LSB_REG 16<<11
|
||||
#define GET_ACTUAL_TIME_MSB_REG 17<<11
|
||||
|
||||
#define GET_MEASUREMENT_TIME_LSB_REG 38<<11
|
||||
#define GET_MEASUREMENT_TIME_MSB_REG 38<<11
|
||||
|
||||
|
||||
#define SET_DELAY_LSB_REG 96<<11 //0x68<<11
|
||||
#define SET_DELAY_MSB_REG 97<<11 //0x69<<11
|
||||
#define GET_DELAY_LSB_REG 18<<11//0x6a<<11
|
||||
#define GET_DELAY_MSB_REG 19<<11//0x6b<<11
|
||||
|
||||
#define SET_CYCLES_LSB_REG 98<<11//0x6c<<11
|
||||
#define SET_CYCLES_MSB_REG 99<<11//0x6d<<11
|
||||
#define GET_CYCLES_LSB_REG 20<<11//0x6e<<11
|
||||
#define GET_CYCLES_MSB_REG 21<<11//0x6f<<11
|
||||
|
||||
#define SET_FRAMES_LSB_REG 100<<11//0x70<<11
|
||||
#define SET_FRAMES_MSB_REG 101<<11//0x71<<11
|
||||
#define GET_FRAMES_LSB_REG 22<<11//0x72<<11
|
||||
#define GET_FRAMES_MSB_REG 23<<11//0x73<<11
|
||||
|
||||
#define SET_PERIOD_LSB_REG 102<<11//0x74<<11
|
||||
#define SET_PERIOD_MSB_REG 103<<11//0x75<<11
|
||||
#define GET_PERIOD_LSB_REG 24<<11//0x76<<11
|
||||
#define GET_PERIOD_MSB_REG 25<<11//0x77<<11
|
||||
|
||||
#define SET_EXPTIME_LSB_REG 104<<11//0x78<<11
|
||||
#define SET_EXPTIME_MSB_REG 105<<11//0x79<<11
|
||||
#define GET_EXPTIME_LSB_REG 26<<11//0x7a<<11
|
||||
#define GET_EXPTIME_MSB_REG 27<<11//0x7b<<11
|
||||
|
||||
#define SET_GATES_LSB_REG 106<<11//0x7c<<11
|
||||
#define SET_GATES_MSB_REG 107<<11//0x7d<<11
|
||||
#define GET_GATES_LSB_REG 28<<11//0x7e<<11
|
||||
#define GET_GATES_MSB_REG 29<<11//0x7f<<11
|
||||
|
||||
#define DATA_IN_LSB_REG 30<<11
|
||||
#define DATA_IN_MSB_REG 31<<11
|
||||
|
||||
#define PATTERN_OUT_LSB_REG 32<<11
|
||||
#define PATTERN_OUT_MSB_REG 33<<11
|
||||
|
||||
#define FRAMES_FROM_START_LSB_REG 34<<11
|
||||
#define FRAMES_FROM_START_MSB_REG 35<<11
|
||||
|
||||
#define FRAMES_FROM_START_PG_LSB_REG 36<<11
|
||||
#define FRAMES_FROM_START_PG_MSB_REG 37<<11
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define PLL_PARAM_REG 80<<11//0x37<<11
|
||||
#define PLL_PARAM_OUT_REG 5<<11 //0x38<<11
|
||||
#define PLL_CNTRL_REG 81<<11//0x34<<11
|
||||
|
||||
|
||||
#ifdef NEW_GBE_INTERFACE
|
||||
#define GBE_PARAM_OUT_REG 40<<11
|
||||
#define GBE_PARAM_REG 69<<11
|
||||
#define GBE_CNTRL_REG 70<<11
|
||||
#else
|
||||
#define RX_UDP_AREG 69<<11 //rx_udpip_AReg_c : integer:= 69; *\/
|
||||
#define UDPPORTS_AREG 70<<11// udpports_AReg_c : integer:= 70; *\/
|
||||
#define RX_UDPMACL_AREG 71<<11//rx_udpmacL_AReg_c : integer:= 71; *\/
|
||||
#define RX_UDPMACH_AREG 72<<11//rx_udpmacH_AReg_c : integer:= 72; *\/
|
||||
#define DETECTORMACL_AREG 73<<11//detectormacL_AReg_c : integer:= 73; *\/
|
||||
#define DETECTORMACH_AREG 74<<11//detectormacH_AReg_c : integer:= 74; *\/
|
||||
#define DETECTORIP_AREG 75<<11//detectorip_AReg_c : integer:= 75; *\/
|
||||
#define IPCHKSUM_AREG 76<<11//ipchksum_AReg_c : integer:= 76; *\/ */
|
||||
#endif
|
||||
|
||||
|
||||
#define PATTERN_CNTRL_REG 82<<11
|
||||
#define PATTERN_LIMITS_AREG 83<<11
|
||||
|
||||
#define PATTERN_LOOP0_AREG 84<<11
|
||||
#define PATTERN_N_LOOP0_REG 85<<11
|
||||
|
||||
#define PATTERN_LOOP1_AREG 86<<11
|
||||
#define PATTERN_N_LOOP1_REG 87<<11
|
||||
|
||||
#define PATTERN_LOOP2_AREG 88<<11
|
||||
#define PATTERN_N_LOOP2_REG 89<<11
|
||||
|
||||
#define PATTERN_WAIT0_AREG 90<<11
|
||||
#define PATTERN_WAIT1_AREG 91<<11
|
||||
#define PATTERN_WAIT2_AREG 92<<11
|
||||
|
||||
|
||||
|
||||
//#define DAQ_REG 0x5d<<11 //same as CONFGAIN_REG
|
||||
#define ADC_LATCH_DISABLE_REG 94<<11
|
||||
|
||||
#define HV_REG 95<<11
|
||||
|
||||
#define PATTERN_IOCTRL_REG_LSB 108<<11
|
||||
#define PATTERN_IOCTRL_REG_MSB 109<<11
|
||||
|
||||
#define PATTERN_IOCLKCTRL_REG_LSB 110<<11
|
||||
#define PATTERN_IOCLKCTRL_REG_MSB 111<<11
|
||||
#define PATTERN_IN_REG_LSB 112<<11
|
||||
#define PATTERN_IN_REG_MSB 113<<11
|
||||
#define PATTERN_WAIT0_TIME_REG_LSB 114<<11
|
||||
#define PATTERN_WAIT0_TIME_REG_MSB 115<<11
|
||||
#define PATTERN_WAIT1_TIME_REG_LSB 116<<11
|
||||
#define PATTERN_WAIT1_TIME_REG_MSB 117<<11
|
||||
#define PATTERN_WAIT2_TIME_REG_LSB 118<<11
|
||||
#define PATTERN_WAIT2_TIME_REG_MSB 119<<11
|
||||
|
||||
#define DAC_REG_OFF 120
|
||||
#define DAC_0_1_VAL_REG 120<<11
|
||||
#define DAC_2_3_VAL_REG 121<<11
|
||||
#define DAC_4_5_VAL_REG 122<<11
|
||||
#define DAC_6_7_VAL_REG 123<<11
|
||||
#define DAC_8_9_VAL_REG 124<<11
|
||||
#define DAC_10_11_VAL_REG 125<<11
|
||||
#define DAC_12_13_VAL_REG 126<<11
|
||||
#define DAC_14_15_VAL_REG 127<<11
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* registers defined in FPGA */
|
||||
#define GAIN_REG 0
|
||||
//#define FLOW_CONTROL_REG 0x11<<11
|
||||
//#define FLOW_STATUS_REG 0x12<<11
|
||||
//#define FRAME_REG 0x13<<11
|
||||
#define MULTI_PURPOSE_REG 0
|
||||
//#define TIME_FROM_START_REG 0x16<<11
|
||||
|
||||
|
||||
#define ROI_REG 0 // 0x35<<11
|
||||
#define OVERSAMPLING_REG 0 // 0x36<<11
|
||||
#define MOENCH_CNTR_REG 0 // 0x31<<11
|
||||
#define MOENCH_CNTR_OUT_REG 0 // 0x33<<11
|
||||
#define MOENCH_CNTR_CONF_REG 0 // 0x32<<11
|
||||
|
||||
|
||||
|
||||
//image
|
||||
#define DARK_IMAGE_REG 0 // 0x81<<11
|
||||
#define GAIN_IMAGE_REG 0 // 0x82<<11
|
||||
|
||||
//counter block memory
|
||||
#define COUNTER_MEMORY_REG 0 // 0x85<<11
|
||||
|
||||
|
||||
//not used
|
||||
//#define MCB_DOUT_REG_OFF 0 // 0x200000
|
||||
//#define FIFO_CNTRL_REG_OFF 0 // 0x300000
|
||||
//#define FIFO_COUNTR_REG_OFF 0 // 0x400000
|
||||
//not used so far
|
||||
//#define SPEED_REG 0 // 0x006000
|
||||
//#define SET_NBITS_REG 0 // 0x008000
|
||||
//not used
|
||||
//#define GET_SHIFT_IN_REG 0 // 0x022000
|
||||
|
||||
|
||||
|
||||
#define SHIFTMOD 2
|
||||
#define SHIFTFIFO 9
|
||||
|
||||
/** for PCB_REV_REG */
|
||||
#define DETECTOR_TYPE_MASK 0xFF000000
|
||||
#define DETECTOR_TYPE_OFFSET 24
|
||||
#define BOARD_REVISION_MASK 0xFFFFFF
|
||||
#define MOENCH03_MODULE_ID 2
|
||||
#define JUNGFRAU_MODULE_ID 1
|
||||
#define JUNGFRAU_CTB_ID 3
|
||||
|
||||
|
||||
|
||||
|
||||
/* for control register (16bit only)*/
|
||||
#define START_ACQ_BIT 0x0001
|
||||
#define STOP_ACQ_BIT 0x0002
|
||||
#define START_FIFOTEST_BIT 0x0004 // ?????
|
||||
#define STOP_FIFOTEST_BIT 0x0008 // ??????
|
||||
#define START_READOUT_BIT 0x0010
|
||||
#define STOP_READOUT_BIT 0x0020
|
||||
#define START_EXPOSURE_BIT 0x0040
|
||||
#define STOP_EXPOSURE_BIT 0x0080
|
||||
#define START_TRAIN_BIT 0x0100
|
||||
#define STOP_TRAIN_BIT 0x0200
|
||||
#define FIFO_RESET_BIT 0x8000
|
||||
#define SYNC_RESET 0x0400
|
||||
#define GB10_RESET_BIT 0x0800
|
||||
#define MEM_RESET_BIT 0x1000
|
||||
|
||||
/* for status register */
|
||||
#define RUN_BUSY_BIT 0x00000001
|
||||
#define READOUT_BUSY_BIT 0x00000002
|
||||
#define FIFOTEST_BUSY_BIT 0x00000004 //????
|
||||
#define WAITING_FOR_TRIGGER_BIT 0x00000008
|
||||
#define DELAYBEFORE_BIT 0x00000010
|
||||
#define DELAYAFTER_BIT 0x00000020
|
||||
#define EXPOSING_BIT 0x00000040
|
||||
#define COUNT_ENABLE_BIT 0x00000080
|
||||
#define READSTATE_0_BIT 0x00000100
|
||||
#define READSTATE_1_BIT 0x00000200
|
||||
#define READSTATE_2_BIT 0x00000400
|
||||
#define SOME_FIFO_FULL_BIT 0x00000800 // error!
|
||||
|
||||
#define RUNSTATE_0_BIT 0x00001000
|
||||
#define RUNSTATE_1_BIT 0x00002000
|
||||
#define RUNSTATE_2_BIT 0x00004000
|
||||
#define STOPPED_BIT 0x00008000 // stopped!
|
||||
#define ALL_FIFO_EMPTY_BIT 0x00010000 // data ready
|
||||
#define RUNMACHINE_BUSY_BIT 0x00020000
|
||||
#define READMACHINE_BUSY_BIT 0x00040000
|
||||
#define PLL_RECONFIG_BUSY 0x00100000
|
||||
|
||||
|
||||
|
||||
/* for fifo status register */
|
||||
#define FIFO_ENABLED_BIT 0x80000000
|
||||
#define FIFO_DISABLED_BIT 0x01000000
|
||||
#define FIFO_ERROR_BIT 0x08000000
|
||||
#define FIFO_EMPTY_BIT 0x04000000
|
||||
#define FIFO_DATA_READY_BIT 0x02000000
|
||||
#define FIFO_COUNTER_MASK 0x000001ff
|
||||
#define FIFO_NM_MASK 0x00e00000
|
||||
#define FIFO_NM_OFF 21
|
||||
#define FIFO_NC_MASK 0x001ffe00
|
||||
#define FIFO_NC_OFF 9
|
||||
|
||||
/* for config register *///not really used yet
|
||||
#define TOT_ENABLE_BIT 0x00000002
|
||||
#define TIMED_GATE_BIT 0x00000004
|
||||
#define CONT_RO_ENABLE_BIT 0x00080000
|
||||
#define GB10_NOT_CPU_BIT 0x00001000
|
||||
|
||||
|
||||
|
||||
/* for speed register */
|
||||
#define CLK_DIVIDER_MASK 0x000000ff
|
||||
#define CLK_DIVIDER_OFFSET 0
|
||||
#define SET_LENGTH_MASK 0x00000f00
|
||||
#define SET_LENGTH_OFFSET 8
|
||||
#define WAIT_STATES_MASK 0x0000f000
|
||||
#define WAIT_STATES_OFFSET 12
|
||||
#define TOTCLK_DIVIDER_MASK 0xff000000
|
||||
#define TOTCLK_DIVIDER_OFFSET 24
|
||||
#define TOTCLK_DUTYCYCLE_MASK 0x00ff0000
|
||||
#define TOTCLK_DUTYCYCLE_OFFSET 16
|
||||
|
||||
/* for external signal register */
|
||||
#define SIGNAL_OFFSET 4
|
||||
#define SIGNAL_MASK 0xF
|
||||
#define EXT_SIG_OFF 0x0
|
||||
#define EXT_GATE_IN_ACTIVEHIGH 0x1
|
||||
#define EXT_GATE_IN_ACTIVELOW 0x2
|
||||
#define EXT_TRIG_IN_RISING 0x3
|
||||
#define EXT_TRIG_IN_FALLING 0x4
|
||||
#define EXT_RO_TRIG_IN_RISING 0x5
|
||||
#define EXT_RO_TRIG_IN_FALLING 0x6
|
||||
#define EXT_GATE_OUT_ACTIVEHIGH 0x7
|
||||
#define EXT_GATE_OUT_ACTIVELOW 0x8
|
||||
#define EXT_TRIG_OUT_RISING 0x9
|
||||
#define EXT_TRIG_OUT_FALLING 0xA
|
||||
#define EXT_RO_TRIG_OUT_RISING 0xB
|
||||
#define EXT_RO_TRIG_OUT_FALLING 0xC
|
||||
|
||||
|
||||
|
||||
/* for temperature register */
|
||||
#define T1_CLK_BIT 0x00000001
|
||||
#define T1_CS_BIT 0x00000002
|
||||
#define T2_CLK_BIT 0x00000004
|
||||
#define T2_CS_BIT 0x00000008
|
||||
|
||||
|
||||
|
||||
/* fifo control register */
|
||||
//#define FIFO_RESET_BIT 0x00000001
|
||||
//#define FIFO_DISABLE_TOGGLE_BIT 0x00000002
|
||||
|
||||
|
||||
//chip shiftin register meaning
|
||||
#define OUTMUX_OFF 20
|
||||
#define OUTMUX_MASK 0x1f
|
||||
#define PROBES_OFF 4
|
||||
#define PROBES_MASK 0x7f
|
||||
#define OUTBUF_OFF 0
|
||||
#define OUTBUF_MASK 1
|
||||
|
||||
|
||||
/* multi purpose register */
|
||||
#define PHASE_STEP_BIT 0x00000001
|
||||
#define PHASE_STEP_OFFSET 0
|
||||
// #define xxx_BIT 0x00000002
|
||||
#define RESET_COUNTER_BIT 0x00000004
|
||||
#define RESET_COUNTER_OFFSET 2
|
||||
//#define xxx_BIT 0x00000008
|
||||
//#define xxx_BIT 0x00000010
|
||||
#define SW1_BIT 0x00000020
|
||||
#define SW1_OFFSET 5
|
||||
#define WRITE_BACK_BIT 0x00000040
|
||||
#define WRITE_BACK_OFFSET 6
|
||||
#define RESET_BIT 0x00000080
|
||||
#define RESET_OFFSET 7
|
||||
#define ENET_RESETN_BIT 0x00000800
|
||||
#define ENET_RESETN_OFFSET 11
|
||||
#define INT_RSTN_BIT 0x00002000
|
||||
#define INT_RSTN_OFFSET 13
|
||||
#define DIGITAL_TEST_BIT 0x00004000
|
||||
#define DIGITAL_TEST_OFFSET 14
|
||||
//#define CHANGE_AT_POWER_ON_BIT 0x00008000
|
||||
//#define CHANGE_AT_POWER_ON_OFFSET 15
|
||||
|
||||
|
||||
/* settings/conf gain register */
|
||||
#define GAIN_MASK 0x0000ffff
|
||||
#define GAIN_OFFSET 0
|
||||
#define SPEED_GAIN_MASK 0xf0000000
|
||||
#define SPEED_GAIN_OFFSET 28
|
||||
|
||||
|
||||
|
||||
/* CHIP_OF_INTRST_REG */
|
||||
#define CHANNEL_MASK 0xffff0000
|
||||
#define CHANNEL_OFFSET 16
|
||||
#define ACTIVE_ADC_MASK 0x0000001f
|
||||
|
||||
|
||||
|
||||
/**ADC SYNC CLEAN FIFO*/
|
||||
#define ADCSYNC_CLEAN_FIFO_BITS 0x300000
|
||||
#define CLEAN_FIFO_MASK 0x0fffff
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define PLL_CNTR_ADDR_OFF 16 //PLL_CNTR_REG bits 21 downto 16 represent the counter address
|
||||
|
||||
#define PLL_CNTR_RECONFIG_RESET_BIT 0
|
||||
#define PLL_CNTR_READ_BIT 1
|
||||
#define PLL_CNTR_WRITE_BIT 2
|
||||
#define PLL_CNTR_PLL_RESET_BIT 3
|
||||
|
||||
|
||||
#define PLL_CNTR_PHASE_EN_BIT 8
|
||||
#define PLL_CNTR_UPDN_BIT 9
|
||||
#define PLL_CNTR_CNTSEL_OFF 10
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define PLL_MODE_REG 0x0
|
||||
#define PLL_STATUS_REG 0x1
|
||||
#define PLL_START_REG 0x2
|
||||
#define PLL_N_COUNTER_REG 0x3
|
||||
#define PLL_M_COUNTER_REG 0x4
|
||||
#define PLL_C_COUNTER_REG 0x5 //which ccounter stands in param 22:18; 7:0 lowcount 15:8 highcount; 16 bypassenable; 17 oddivision
|
||||
#define PLL_PHASE_SHIFT_REG 0x6 // which ccounter stands in param 16:20; 21 updown (1 up, 0 down)
|
||||
#define PLL_K_COUNTER_REG 0x7
|
||||
#define PLL_BANDWIDTH_REG 0x8
|
||||
#define PLL_CHARGEPUMP_REG 0x9
|
||||
#define PLL_VCO_DIV_REG 0x1c
|
||||
#define PLL_MIF_REG 0x1f
|
||||
|
||||
#define PPL_M_CNT_PARAM_DEFAULT 0x4040
|
||||
#define PPL_N_CNT_PARAM_DEFAULT 0x20D0C
|
||||
#define PPL_C0_CNT_PARAM_DEFAULT 0x20D0C
|
||||
#define PPL_C1_CNT_PARAM_DEFAULT 0xA0A0
|
||||
#define PPL_C2_CNT_PARAM_DEFAULT 0x20D0C
|
||||
#define PPL_C3_CNT_PARAM_DEFAULT 0x0808
|
||||
#define PPL_BW_PARAM_DEFAULT 0x2EE0
|
||||
#define PPL_VCO_PARAM_DEFAULT 0x1
|
||||
|
||||
#define NEW_PLL_RECONFIG
|
||||
|
||||
#ifdef NEW_PLL_RECONFIG
|
||||
#define PLL_VCO_FREQ_MHZ 400//480//800
|
||||
#else
|
||||
#define PLL_VCO_FREQ_MHZ 480//800
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
GBE parameter and control registers definitions
|
||||
*/
|
||||
|
||||
#define GBE_CTRL_WSTROBE 0
|
||||
#define GBE_CTRL_VAR_OFFSET 16
|
||||
#define GBE_CTRL_VAR_MASK 0XF
|
||||
#define GBE_CTRL_RAMADDR_OFFSET 24
|
||||
#define GBE_CTRL_RAMADDR_MASK 0X3F
|
||||
#define GBE_CTRL_INTERFACE 23
|
||||
|
||||
#define RX_UDP_IP_ADDR 0
|
||||
#define RX_UDP_PORTS_ADDR 1
|
||||
#define RX_UDP_MAC_L_ADDR 2
|
||||
#define RX_UDP_MAC_H_ADDR 3
|
||||
#define IPCHECKSUM_ADDR 4
|
||||
#define GBE_DELAY_ADDR 5
|
||||
#define GBE_RESERVED1_ADDR 6
|
||||
#define GBE_RESERVED2_ADDR 7
|
||||
#define DETECTOR_MAC_L_ADDR 8
|
||||
#define DETECTOR_MAC_H_ADDR 9
|
||||
#define DETECTOR_IP_ADDR 10
|
||||
|
||||
|
||||
|
||||
/**------------------
|
||||
-- pattern registers definitions
|
||||
--------------------------------------------- */
|
||||
#define IOSIGNALS_MASK 0xfffffffffffff
|
||||
#define ADC_ENABLE_BIT 63
|
||||
#define APATTERN_MASK 0xffff
|
||||
#define ASTART_OFFSET 0
|
||||
#define ASTOP_OFFSET 16
|
||||
#define PATTERN_CTRL_WRITE_BIT 0
|
||||
#define PATTERN_CTRL_READ_BIT 1
|
||||
#define PATTERN_CTRL_ADDR_OFFSET 16
|
||||
#define MAX_PATTERN_LENGTH 1024
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
/* A simple server in the internet domain using TCP
|
||||
The port number is passed as an argument */
|
||||
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "communication_funcs.h"
|
||||
#include "server_funcs.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
||||
extern int sockfd;
|
||||
extern int phase_shift;
|
||||
|
||||
|
||||
|
||||
void error(char *msg)
|
||||
{
|
||||
perror(msg);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int portno, b;
|
||||
char cmd[500];
|
||||
int retval=OK;
|
||||
int sd, fd;
|
||||
int iarg;
|
||||
|
||||
|
||||
for(iarg=1; iarg<argc; iarg++){
|
||||
|
||||
if(!strcasecmp(argv[iarg],"-phaseshift")){
|
||||
if(argc==iarg+1){
|
||||
printf("No phaseshift given. Exiting.\n");
|
||||
return 1;
|
||||
}
|
||||
if ( sscanf(argv[iarg+1],"%d",&phase_shift)==0) {
|
||||
printf("could not decode phase shift\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
else if(!strcasecmp(argv[iarg],"-test")){
|
||||
if(argc==iarg+1){
|
||||
printf("No test condition given. Exiting.\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//stop server
|
||||
if ((argc > 2) && (!strcasecmp(argv[2],"stopserver"))){
|
||||
portno = DEFAULT_PORTNO+1;
|
||||
if ( sscanf(argv[1],"%d",&portno) ==0) {
|
||||
printf("could not open stop server: unknown port\n");
|
||||
return 1;
|
||||
}
|
||||
b=0;
|
||||
printf("\n\nStop Server\nOpening stop server on port %d\n",portno);
|
||||
}
|
||||
|
||||
//control server
|
||||
else {
|
||||
portno = DEFAULT_PORTNO;
|
||||
sprintf(cmd,"%s %d stopserver &",argv[0],DEFAULT_PORTNO+1);
|
||||
printf("\n\nControl Server\nOpening control server on port %d\n",portno );
|
||||
//printf("\n\ncmd:%s\n",cmd);
|
||||
system(cmd);
|
||||
b=1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
init_detector(b);
|
||||
|
||||
|
||||
sd=bindSocket(portno);
|
||||
sockfd=sd;
|
||||
if (getServerError(sd)) {
|
||||
printf("server error!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* assign function table */
|
||||
function_table();
|
||||
#ifdef VERBOSE
|
||||
printf("function table assigned \n");
|
||||
#endif
|
||||
|
||||
|
||||
/* waits for connection */
|
||||
while(retval!=GOODBYE) {
|
||||
#ifdef VERBOSE
|
||||
printf("\n");
|
||||
#endif
|
||||
#ifdef VERY_VERBOSE
|
||||
printf("Waiting for client call\n");
|
||||
#endif
|
||||
fd=acceptConnection(sockfd);
|
||||
#ifdef VERY_VERBOSE
|
||||
printf("Conenction accepted\n");
|
||||
#endif
|
||||
retval=decode_function(fd);
|
||||
#ifdef VERY_VERBOSE
|
||||
printf("function executed\n");
|
||||
#endif
|
||||
closeConnection(fd);
|
||||
#ifdef VERY_VERBOSE
|
||||
printf("connection closed\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
exitServer(sockfd);
|
||||
printf("Goodbye!\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
#ifndef SERVER_DEFS_H
|
||||
#define SERVER_DEFS_H
|
||||
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
// Hardware definitions
|
||||
#define NMAXMODY 1
|
||||
#define NMAXMODX 1
|
||||
#define NMAXMOD (NMAXMODX*NMAXMODY)
|
||||
#define NCHAN (256*256)
|
||||
#define NCHIP 8
|
||||
#define NADC 0
|
||||
#define NDAC 16
|
||||
#define NCHANS (NCHAN*NCHIP*NMAXMOD)
|
||||
#define NDACS (NDAC*NMAXMOD)
|
||||
|
||||
|
||||
/**when moench readout tested with gotthard module*/
|
||||
#define GOTTHARDNCHAN 128
|
||||
#define GOTTHARDNCHIP 10
|
||||
|
||||
|
||||
#define NTRIMBITS 6
|
||||
#define NCOUNTBITS 24
|
||||
|
||||
#define NCHIPS_PER_ADC 2
|
||||
|
||||
//#define TRIM_DR ((2**NTRIMBITS)-1)
|
||||
//#define COUNT_DR ((2**NCOUNTBITS)-1)
|
||||
#define TRIM_DR (((int)pow(2,NTRIMBITS))-1)
|
||||
#define COUNT_DR (((int)pow(2,NCOUNTBITS))-1)
|
||||
|
||||
|
||||
#define ALLMOD 0xffff
|
||||
#define ALLFIFO 0xffff
|
||||
|
||||
#define GOTTHARD_ADCSYNC_VAL 0x32214
|
||||
#define ADCSYNC_VAL 0x02111
|
||||
#define TOKEN_RESTART_DELAY 0x88000000
|
||||
#define TOKEN_RESTART_DELAY_ROI 0x1b000000
|
||||
#define TOKEN_TIMING_REV1 0x1f16
|
||||
#define TOKEN_TIMING_REV2 0x1f0f
|
||||
|
||||
#define DEFAULT_PHASE_SHIFT 0 // 120
|
||||
#define DEFAULT_IP_PACKETSIZE 0x0522
|
||||
#define DEFAULT_UDP_PACKETSIZE 0x050E
|
||||
#define ADC1_IP_PACKETSIZE 256*2+14+20
|
||||
#define ADC1_UDP_PACKETSIZE 256*2+4+8+2
|
||||
|
||||
#ifdef VIRTUAL
|
||||
#define DEBUGOUT
|
||||
#endif
|
||||
|
||||
#define CLK_FREQ 156.25E+6
|
||||
#define ADC_CLK_FREQ 32E+6
|
||||
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,102 +0,0 @@
|
||||
#ifndef SERVER_FUNCS_H
|
||||
#define SERVER_FUNCS_H
|
||||
|
||||
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
/*
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
*/
|
||||
#include "communication_funcs.h"
|
||||
|
||||
|
||||
|
||||
|
||||
#define GOODBYE -200
|
||||
|
||||
int sockfd;
|
||||
|
||||
int function_table();
|
||||
|
||||
int decode_function(int);
|
||||
int init_detector(int);
|
||||
|
||||
int M_nofunc(int);
|
||||
int exit_server(int);
|
||||
|
||||
|
||||
|
||||
|
||||
// General purpose functions
|
||||
int get_detector_type(int);
|
||||
int set_number_of_modules(int);
|
||||
int get_max_number_of_modules(int);
|
||||
|
||||
|
||||
int exec_command(int);
|
||||
int set_external_signal_flag(int);
|
||||
int set_external_communication_mode(int);
|
||||
int get_id(int);
|
||||
int digital_test(int);
|
||||
int write_register(int);
|
||||
int read_register(int);
|
||||
int set_dac(int);
|
||||
int get_adc(int);
|
||||
int set_channel(int);
|
||||
int set_chip(int);
|
||||
int set_module(int);
|
||||
int get_channel(int);
|
||||
int get_chip(int);
|
||||
int get_module(int);
|
||||
|
||||
int get_threshold_energy(int);
|
||||
int set_threshold_energy(int);
|
||||
int set_settings(int);
|
||||
int start_acquisition(int);
|
||||
int stop_acquisition(int);
|
||||
int start_readout(int);
|
||||
int get_run_status(int);
|
||||
int read_frame(int);
|
||||
int read_all(int);
|
||||
int start_and_read_all(int);
|
||||
int set_timer(int);
|
||||
int get_time_left(int);
|
||||
int set_dynamic_range(int);
|
||||
int set_roi(int);
|
||||
int get_roi(int);
|
||||
int set_speed(int);
|
||||
int set_readout_flags(int);
|
||||
int execute_trimming(int);
|
||||
int lock_server(int);
|
||||
int set_port(int);
|
||||
int get_last_client_ip(int);
|
||||
int set_master(int);
|
||||
int set_synchronization(int);
|
||||
|
||||
int update_client(int);
|
||||
int send_update(int);
|
||||
int configure_mac(int);
|
||||
|
||||
int load_image(int);
|
||||
int read_counter_block(int);
|
||||
int reset_counter_block(int);
|
||||
|
||||
int start_receiver(int);
|
||||
int stop_receiver(int);
|
||||
|
||||
|
||||
int calibrate_pedestal(int);
|
||||
|
||||
int set_roi(int);
|
||||
int set_ctb_pattern(int);
|
||||
|
||||
int write_adc_register(int);;
|
||||
|
||||
int program_fpga(int);
|
||||
int reset_fpga(int);
|
||||
int power_chip(int);
|
||||
#endif
|
||||
1691
slsDetectorSoftware/jungfrauDetectorServer/slsDetectorFunctionList.c
Normal file
1691
slsDetectorSoftware/jungfrauDetectorServer/slsDetectorFunctionList.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
../slsDetectorServer/slsDetectorFunctionList.h
|
||||
1
slsDetectorSoftware/jungfrauDetectorServer/slsDetectorServer.c
Symbolic link
1
slsDetectorSoftware/jungfrauDetectorServer/slsDetectorServer.c
Symbolic link
@@ -0,0 +1 @@
|
||||
../slsDetectorServer/slsDetectorServer.c
|
||||
@@ -0,0 +1,252 @@
|
||||
#ifndef SLSDETECTORSERVER_DEFS_H
|
||||
#define SLSDETECTORSERVER_DEFS_H
|
||||
|
||||
#include "sls_detector_defs.h" //default dynamicgain in settings
|
||||
#include "RegisterDefs.h"
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
|
||||
#define GOODBYE (-200)
|
||||
#define CTRL_SRVR_INIT_TIME_US (300 * 1000)
|
||||
//#define REQUIRED_FIRMWARE_VERSION 16
|
||||
|
||||
|
||||
/* Struct Definitions */
|
||||
typedef struct ip_header_struct {
|
||||
uint16_t ip_len;
|
||||
uint8_t ip_tos;
|
||||
uint8_t ip_ihl:4 ,ip_ver:4;
|
||||
uint16_t ip_offset:13,ip_flag:3;
|
||||
uint16_t ip_ident;
|
||||
uint16_t ip_chksum;
|
||||
uint8_t ip_protocol;
|
||||
uint8_t ip_ttl;
|
||||
uint32_t ip_sourceip;
|
||||
uint32_t ip_destip;
|
||||
} ip_header;
|
||||
|
||||
/* Enums */
|
||||
enum CLK_SPEED_INDEX {FULL_SPEED, HALF_SPEED, QUARTER_SPEED};
|
||||
enum ADCINDEX {TEMP_FPGA, TEMP_ADC};
|
||||
enum DACINDEX {VB_COMP, VDD_PROT, VIN_COM, VREF_PRECH, VB_PIXBUF, VB_DS, VREF_DS, VREF_COMP };
|
||||
#define DEFAULT_DAC_VALS { 1220, /* VB_COMP */ \
|
||||
3000, /* VDD_PROT */ \
|
||||
1053, /* VIN_COM */ \
|
||||
1450, /* VREF_PRECH */ \
|
||||
750, /* VB_PIXBUF */ \
|
||||
1000, /* VB_DS */ \
|
||||
480, /* VREF_DS */ \
|
||||
420 /* VREF_COMP */ \
|
||||
};
|
||||
|
||||
#define NUM_SETTINGS 6
|
||||
#define DEFAULT_SETT_INDX {DYNAMICGAIN, DYNAMICHG0, FIXGAIN1, FIXGAIN2, FORCESWITCHG1, FORCESWITCHG2};
|
||||
#define DEFAULT_SETT_VALS { 0x0f00, /* DYNAMICGAIN */ \
|
||||
0x0f01, /* DYNAMICHG0 */ \
|
||||
0x0f02, /* FIXGAIN1 */ \
|
||||
0x0f06, /* FIXGAIN2 */ \
|
||||
0x1f00, /* FORCESWITCHG1 */ \
|
||||
0x3f00 /* FORCESWITCHG2 */ \
|
||||
};
|
||||
#define DEFAULT_SETT_NAMES { "Dynamic Gain", /* DYNAMICGAIN */ \
|
||||
"Dynamic High Gain 0", /* DYNAMICHG0 */ \
|
||||
"Fix Gain 1", /* FIXGAIN1 */ \
|
||||
"Fix Gain 2", /* FIXGAIN2 */ \
|
||||
"Force Switch Gain 1", /* FORCESWITCHG1*/ \
|
||||
"Force Switch Gain 2" /* FORCESWITCHG2*/ \
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* Hardware Definitions */
|
||||
#define NMAXMOD (1)
|
||||
#define NMOD (1)
|
||||
#define NCHAN (256 * 256)
|
||||
#define NCHIP (8)
|
||||
#define NADC (0)
|
||||
#define NDAC (8)
|
||||
#define NDAC_OLDBOARD (16)
|
||||
#define DYNAMIC_RANGE (16)
|
||||
#define NUM_BITS_PER_PIXEL (DYNAMIC_RANGE / 8)
|
||||
#define DATA_BYTES (NCHIP * NCHAN * NUM_BITS_PER_PIXEL)
|
||||
#define IP_PACKETSIZE (0x2052)
|
||||
#define CLK_RUN (40) /* MHz */
|
||||
#define CLK_SYNC (20) /* MHz */
|
||||
|
||||
|
||||
/** Default Parameters */
|
||||
#define DEFAULT_NUM_FRAMES (100*1000*1000)
|
||||
#define DEFAULT_NUM_CYCLES (1)
|
||||
#define DEFAULT_EXPTIME (10*1000) //ns
|
||||
#define DEFAULT_PERIOD (2*1000*1000) //ns
|
||||
#define DEFAULT_DELAY (0)
|
||||
#define DEFAULT_HIGH_VOLTAGE (0)
|
||||
#define DEFAULT_TIMING_MODE (AUTO_TIMING)
|
||||
#define DEFAULT_SETTINGS (DYNAMICGAIN)
|
||||
#define DEFAULT_TX_UDP_PORT (0x7e9a)
|
||||
|
||||
/* Defines in the Firmware */
|
||||
#define FIX_PATT_VAL (0xACDC2014)
|
||||
#define ADC_PORT_INVERT_VAL (0x453b2a9c)
|
||||
|
||||
|
||||
#define SAMPLE_ADC_HALF_SPEED (SAMPLE_DECMT_FACTOR_2_VAL + SAMPLE_DGTL_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_0_VAL + SAMPLE_ADC_SAMPLE_0_VAL) /* 0x1000 */
|
||||
#define SAMPLE_ADC_QUARTER_SPEED (SAMPLE_DECMT_FACTOR_4_VAL + SAMPLE_DGTL_SAMPLE_8_VAL + SAMPLE_ADC_DECMT_FACTOR_1_VAL + SAMPLE_ADC_SAMPLE_0_VAL) /* 0x2810 */
|
||||
#define CONFIG_HALF_SPEED (CONFIG_TDMA_TIMESLOT_0_VAL + CONFIG_TDMA_DISABLE_VAL + CONFIG_HALF_SPEED_20MHZ_VAL + CONFIG_MODE_1_X_10GBE_VAL)
|
||||
#define CONFIG_QUARTER_SPEED (CONFIG_TDMA_TIMESLOT_0_VAL + CONFIG_TDMA_DISABLE_VAL + CONFIG_QUARTER_SPEED_10MHZ_VAL + CONFIG_MODE_1_X_10GBE_VAL)
|
||||
#define ADC_OFST_HALF_SPEED_VAL (0x20) //adc pipeline
|
||||
#define ADC_OFST_QUARTER_SPEED_VAL (0x0f)
|
||||
#define ADC_PHASE_HALF_SPEED (0x41)
|
||||
#define ADC_PHASE_QUARTER_SPEED (0x19)
|
||||
|
||||
/* Maybe not required for jungfrau */
|
||||
#define NTRIMBITS (6)
|
||||
#define NCOUNTBITS (24)
|
||||
#define NCHIPS_PER_ADC (2)
|
||||
#define TRIM_DR (((int)pow(2,NTRIMBITS))-1)
|
||||
#define COUNT_DR (((int)pow(2,NCOUNTBITS))-1)
|
||||
#define ALLMOD (0xffff)
|
||||
#define ALLFIFO (0xffff)
|
||||
|
||||
/* MSB & LSB DEFINES */
|
||||
#define MSB_OF_64_BIT_REG_OFST (32)
|
||||
#define LSB_OF_64_BIT_REG_OFST (0)
|
||||
#define BIT_32_MSK (0xFFFFFFFF)
|
||||
|
||||
/* LTC2620 DAC DEFINES */
|
||||
#define LTC2620_DAC_CMD_OFST (20)
|
||||
#define LTC2620_DAC_CMD_MSK (0x0000000F << LTC2620_DAC_CMD_OFST)
|
||||
#define LTC2620_DAC_ADDR_OFST (16)
|
||||
#define LTC2620_DAC_ADDR_MSK (0x0000000F << LTC2620_DAC_ADDR_OFST)
|
||||
#define LTC2620_DAC_DATA_OFST (4)
|
||||
#define LTC2620_DAC_DATA_MSK (0x00000FFF << LTC2620_DAC_DATA_OFST)
|
||||
|
||||
#define LTC2620_DAC_CMD_WRITE (0x00000000 << LTC2620_DAC_CMD_OFST)
|
||||
#define LTC2620_DAC_CMD_SET (0x00000003 << LTC2620_DAC_CMD_OFST)
|
||||
#define LTC2620_DAC_CMD_POWER_DOWN (0x00000004 << LTC2620_DAC_CMD_OFST)
|
||||
#define LTC2620_DAC_NUMBITS (24)
|
||||
|
||||
|
||||
/* MAX1932 HV DEFINES */
|
||||
#define MAX1932_HV_NUMBITS (8)
|
||||
#define MAX1932_HV_DATA_OFST (0)
|
||||
#define MAX1932_HV_DATA_MSK (0x000000FF << MAX1932_HV_DATA_OFST)
|
||||
|
||||
/* AD9257 ADC DEFINES */
|
||||
#define AD9257_ADC_NUMBITS (24)
|
||||
|
||||
#define AD9257_DEV_IND_2_REG (0x04)
|
||||
#define AD9257_CHAN_H_OFST (0)
|
||||
#define AD9257_CHAN_H_MSK (0x00000001 << AD9257_CHAN_H_OFST)
|
||||
#define AD9257_CHAN_G_OFST (1)
|
||||
#define AD9257_CHAN_G_MSK (0x00000001 << AD9257_CHAN_G_OFST)
|
||||
#define AD9257_CHAN_F_OFST (2)
|
||||
#define AD9257_CHAN_F_MSK (0x00000001 << AD9257_CHAN_F_OFST)
|
||||
#define AD9257_CHAN_E_OFST (3)
|
||||
#define AD9257_CHAN_E_MSK (0x00000001 << AD9257_CHAN_E_OFST)
|
||||
|
||||
#define AD9257_DEV_IND_1_REG (0x05)
|
||||
#define AD9257_CHAN_D_OFST (0)
|
||||
#define AD9257_CHAN_D_MSK (0x00000001 << AD9257_CHAN_D_OFST)
|
||||
#define AD9257_CHAN_C_OFST (1)
|
||||
#define AD9257_CHAN_C_MSK (0x00000001 << AD9257_CHAN_C_OFST)
|
||||
#define AD9257_CHAN_B_OFST (2)
|
||||
#define AD9257_CHAN_B_MSK (0x00000001 << AD9257_CHAN_B_OFST)
|
||||
#define AD9257_CHAN_A_OFST (3)
|
||||
#define AD9257_CHAN_A_MSK (0x00000001 << AD9257_CHAN_A_OFST)
|
||||
#define AD9257_CLK_CH_DCO_OFST (4)
|
||||
#define AD9257_CLK_CH_DCO_MSK (0x00000001 << AD9257_CLK_CH_DCO_OFST)
|
||||
#define AD9257_CLK_CH_IFCO_OFST (5)
|
||||
#define AD9257_CLK_CH_IFCO_MSK (0x00000001 << AD9257_CLK_CH_IFCO_OFST)
|
||||
|
||||
#define AD9257_POWER_MODE_REG (0x08)
|
||||
#define AD9257_POWER_INTERNAL_OFST (0)
|
||||
#define AD9257_POWER_INTERNAL_MSK (0x00000003 << AD9257_POWER_INTERNAL_OFST)
|
||||
#define AD9257_INT_RESET_VAL (0x3)
|
||||
#define AD9257_INT_CHIP_RUN_VAL (0x0)
|
||||
#define AD9257_POWER_EXTERNAL_OFST (5)
|
||||
#define AD9257_POWER_EXTERNAL_MSK (0x00000001 << AD9257_POWER_EXTERNAL_OFST)
|
||||
#define AD9257_EXT_FULL_POWER_VAL (0x0)
|
||||
#define AD9257_EXT_STANDBY_VAL (0x1)
|
||||
|
||||
#define AD9257_OUT_MODE_REG (0x14)
|
||||
#define AD9257_OUT_FORMAT_OFST (0)
|
||||
#define AD9257_OUT_FORMAT_MSK (0x00000001 << AD9257_OUT_FORMAT_OFST)
|
||||
#define AD9257_OUT_BINARY_OFST_VAL (0)
|
||||
#define AD9257_OUT_TWOS_COMPL_VAL (1)
|
||||
#define AD9257_OUT_LVDS_OPT_OFST (6)
|
||||
#define AD9257_OUT_LVDS_OPT_MSK (0x00000001 << AD9257_OUT_LVDS_OPT_OFST)
|
||||
#define AD9257_OUT_LVDS_ANSI_VAL (0)
|
||||
#define AD9257_OUT_LVDS_IEEE_VAL (1)
|
||||
|
||||
#define AD9257_OUT_PHASE_REG (0x16)
|
||||
#define AD9257_OUT_CLK_OFST (0)
|
||||
#define AD9257_OUT_CLK_MSK (0x0000000F << AD9257_OUT_CLK_OFST)
|
||||
#define AD9257_OUT_CLK_60_VAL (0x1)
|
||||
#define AD9257_IN_CLK_OFST (4)
|
||||
#define AD9257_IN_CLK_MSK (0x00000007 << AD9257_IN_CLK_OFST)
|
||||
#define AD9257_IN_CLK_0_VAL (0x0)
|
||||
|
||||
#define AD9257_VREF_REG (0x18)
|
||||
#define AD9257_VREF_OFST (0)
|
||||
#define AD9257_VREF_MSK (0x00000003 << AD9257_VREF_OFST)
|
||||
#define AD9257_VREF_1_33_VAL (0x2)
|
||||
|
||||
#define AD9257_TEST_MODE_REG (0x0D)
|
||||
#define AD9257_OUT_TEST_OFST (0)
|
||||
#define AD9257_OUT_TEST_MSK (0x0000000F << AD9257_OUT_TEST_OFST)
|
||||
#define AD9257_NONE_VAL (0x0)
|
||||
#define AD9257_MIXED_BIT_FREQ_VAL (0xC)
|
||||
#define AD9257_TEST_RESET_SHORT_GEN (4)
|
||||
#define AD9257_TEST_RESET_LONG_GEN (5)
|
||||
#define AD9257_USER_IN_MODE_OFST (6)
|
||||
#define AD9257_USER_IN_MODE_MSK (0x00000003 << AD9257_USER_IN_MODE_OFST)
|
||||
|
||||
/** PLL Reconfiguration Registers */
|
||||
//https://www.altera.com/documentation/mcn1424769382940.html
|
||||
#define PLL_MODE_REG (0x00)
|
||||
#define PLL_STATUS_REG (0x01)
|
||||
#define PLL_START_REG (0x02)
|
||||
#define PLL_N_COUNTER_REG (0x03)
|
||||
#define PLL_M_COUNTER_REG (0x04)
|
||||
#define PLL_C_COUNTER_REG (0x05)
|
||||
#define PLL_PHASE_SHIFT_REG (0x06)
|
||||
|
||||
#define PLL_SHIFT_NUM_SHIFTS_OFST (0)
|
||||
#define PLL_SHIFT_NUM_SHIFTS_MSK (0x0000FFFF << PLL_SHIFT_NUM_SHIFTS_OFST)
|
||||
|
||||
#define PLL_SHIFT_CNT_SELECT_OFST (16)
|
||||
#define PLL_SHIFT_CNT_SELECT_MSK (0x0000001F << PLL_SHIFT_CNT_SELECT_OFST)
|
||||
#define PLL_SHIFT_CNT_SLCT_C0_VAL ((0x0 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
|
||||
#define PLL_SHIFT_CNT_SLCT_C1_VAL ((0x1 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
|
||||
#define PLL_SHIFT_CNT_SLCT_C2_VAL ((0x2 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
|
||||
#define PLL_SHIFT_CNT_SLCT_C3_VAL ((0x3 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
|
||||
#define PLL_SHIFT_CNT_SLCT_C4_VAL ((0x4 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
|
||||
#define PLL_SHIFT_CNT_SLCT_C5_VAL ((0x5 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
|
||||
#define PLL_SHIFT_CNT_SLCT_C6_VAL ((0x6 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
|
||||
#define PLL_SHIFT_CNT_SLCT_C7_VAL ((0x7 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
|
||||
#define PLL_SHIFT_CNT_SLCT_C8_VAL ((0x8 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
|
||||
#define PLL_SHIFT_CNT_SLCT_C9_VAL ((0x9 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
|
||||
#define PLL_SHIFT_CNT_SLCT_C10_VAL ((0x10 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
|
||||
#define PLL_SHIFT_CNT_SLCT_C11_VAL ((0x11 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
|
||||
#define PLL_SHIFT_CNT_SLCT_C12_VAL ((0x12 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
|
||||
#define PLL_SHIFT_CNT_SLCT_C13_VAL ((0x13 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
|
||||
#define PLL_SHIFT_CNT_SLCT_C14_VAL ((0x14 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
|
||||
#define PLL_SHIFT_CNT_SLCT_C15_VAL ((0x15 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
|
||||
#define PLL_SHIFT_CNT_SLCT_C16_VAL ((0x16 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
|
||||
#define PLL_SHIFT_CNT_SLCT_C17_VAL ((0x17 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK)
|
||||
|
||||
#define PLL_SHIFT_UP_DOWN_OFST (21)
|
||||
#define PLL_SHIFT_UP_DOWN_MSK (0x00000001 << PLL_SHIFT_UP_DOWN_OFST)
|
||||
#define PLL_SHIFT_UP_DOWN_NEG_VAL ((0x0 << PLL_SHIFT_UP_DOWN_OFST) & PLL_SHIFT_UP_DOWN_MSK)
|
||||
#define PLL_SHIFT_UP_DOWN_POS_VAL ((0x1 << PLL_SHIFT_UP_DOWN_OFST) & PLL_SHIFT_UP_DOWN_MSK)
|
||||
|
||||
#define PLL_K_COUNTER_REG (0x07)
|
||||
#define PLL_BANDWIDTH_REG (0x08)
|
||||
#define PLL_CHARGEPUMP_REG (0x09)
|
||||
#define PLL_VCO_DIV_REG (0x1c)
|
||||
#define PLL_MIF_REG (0x1f)
|
||||
|
||||
|
||||
#endif /* SLSDETECTORSERVER_DEFS_H */
|
||||
@@ -0,0 +1 @@
|
||||
../slsDetectorServer/slsDetectorServer_funcs.c
|
||||
@@ -0,0 +1 @@
|
||||
../slsDetectorServer/slsDetectorServer_funcs.h
|
||||
@@ -1,46 +0,0 @@
|
||||
/* A simple server in the internet domain using TCP
|
||||
The port number is passed as an argument */
|
||||
|
||||
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
|
||||
#include "communication_funcs.h"
|
||||
#include "firmware_funcs.h"
|
||||
|
||||
|
||||
int sockfd;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int portno;
|
||||
int retval=0;
|
||||
|
||||
portno = DEFAULT_PORTNO;
|
||||
|
||||
|
||||
bindSocket(portno);
|
||||
if (getServerError())
|
||||
return -1;
|
||||
|
||||
|
||||
|
||||
/* waits for connection */
|
||||
while(retval!=GOODBYE) {
|
||||
#ifdef VERBOSE
|
||||
printf("\n");
|
||||
#endif
|
||||
#ifdef VERY_VERBOSE
|
||||
printf("Stop server: waiting for client call\n");
|
||||
#endif
|
||||
acceptConnection();
|
||||
retval=stopStateMachine();
|
||||
closeConnection();
|
||||
}
|
||||
|
||||
exitServer();
|
||||
printf("Goodbye!\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -17,14 +17,13 @@ ID: $Id$
|
||||
#include "postProcessingFuncs.h"
|
||||
#include "usersFunctions.h"
|
||||
#include "ThreadPool.h"
|
||||
#include "ZmqSocket.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <zmq.h>
|
||||
#include <rapidjson/document.h> //to scan json header in zmq stream
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -140,6 +139,8 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1)
|
||||
thisMultiDetector->fileIndex=0;
|
||||
/** set frames per file to default to 1*/
|
||||
thisMultiDetector->framesPerFile=1;
|
||||
/** set fileFormat to default to ascii*/
|
||||
thisMultiDetector->fileFormatType=ASCII;
|
||||
|
||||
/** set progress Index to default to 0*/
|
||||
thisMultiDetector->progressIndex=0;
|
||||
@@ -245,6 +246,7 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1)
|
||||
fileName=thisMultiDetector->fileName;
|
||||
fileIndex=&thisMultiDetector->fileIndex;
|
||||
framesPerFile=&thisMultiDetector->framesPerFile;
|
||||
fileFormatType=&thisMultiDetector->fileFormatType;
|
||||
|
||||
|
||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
||||
@@ -269,11 +271,8 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1)
|
||||
getNMods();
|
||||
getMaxMods();
|
||||
dataSocketsStarted = false;
|
||||
for(int i=0;i<MAXDET;++i){
|
||||
context[i] = NULL;
|
||||
zmqsocket[i] = NULL;
|
||||
strcpy(dataSocketServerDetails[i],"");
|
||||
}
|
||||
for(int i=0;i<MAXDET;++i)
|
||||
zmqSocket[i] = 0;
|
||||
threadpool = 0;
|
||||
if(createThreadPool() == FAIL)
|
||||
exit(-1);
|
||||
@@ -282,6 +281,11 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1)
|
||||
|
||||
multiSlsDetector::~multiSlsDetector() {
|
||||
//removeSlsDetector();
|
||||
for(int i=0;i<MAXDET;++i) {
|
||||
if (zmqSocket[i]) {
|
||||
delete zmqSocket[i];
|
||||
}
|
||||
}
|
||||
destroyThreadPool();
|
||||
}
|
||||
|
||||
@@ -289,7 +293,6 @@ multiSlsDetector::~multiSlsDetector() {
|
||||
int multiSlsDetector::createThreadPool(){
|
||||
if(threadpool){
|
||||
threadpool->destroy_threadpool();
|
||||
threadpool=0;
|
||||
}
|
||||
if(thisMultiDetector->numberOfDetectors < 1){
|
||||
cout << "No detectors attached to create threadpool" << endl;
|
||||
@@ -317,6 +320,7 @@ int multiSlsDetector::createThreadPool(){
|
||||
void multiSlsDetector::destroyThreadPool(){
|
||||
if(threadpool){
|
||||
threadpool->destroy_threadpool();
|
||||
delete threadpool;
|
||||
threadpool=0;
|
||||
#ifdef VERBOSE
|
||||
cout<<"Destroyed Threadpool "<< threadpool << endl;
|
||||
@@ -773,7 +777,21 @@ int multiSlsDetector::addSlsDetector(detectorType t, int pos) {
|
||||
|
||||
|
||||
|
||||
void multiSlsDetector::getNumberOfDetectors(int& nx, int& ny) {
|
||||
nx = 0; ny = 0;
|
||||
|
||||
int offsetx = -1, offsety = -1;
|
||||
for (int i = 0; i < thisMultiDetector->numberOfDetectors; ++i) {
|
||||
if (thisMultiDetector->offsetX[i] > offsetx) {
|
||||
nx++;
|
||||
offsetx = thisMultiDetector->offsetX[i];
|
||||
}
|
||||
if (thisMultiDetector->offsetY[i] > offsety) {
|
||||
ny++;
|
||||
offsety = thisMultiDetector->offsetY[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1141,9 +1159,8 @@ int multiSlsDetector::getThresholdEnergy(int pos) {
|
||||
|
||||
int multiSlsDetector::setThresholdEnergy(int e_eV, int pos, detectorSettings isettings) {
|
||||
|
||||
int i, posmin, posmax;
|
||||
int ret1=-100, ret;
|
||||
|
||||
int posmin, posmax;
|
||||
int ret=-100;
|
||||
if (pos<0) {
|
||||
posmin=0;
|
||||
posmax=thisMultiDetector->numberOfDetectors;
|
||||
@@ -1152,33 +1169,47 @@ int multiSlsDetector::setThresholdEnergy(int e_eV, int pos, detectorSettings ise
|
||||
posmax=pos+1;
|
||||
}
|
||||
|
||||
for (i=posmin; i<posmax; i++) {
|
||||
if (detectors[i]) {
|
||||
ret=detectors[i]->setThresholdEnergy(e_eV,-1,isettings);
|
||||
if(detectors[i]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<i));
|
||||
#ifdef VERBOSE
|
||||
cout << "detetcor " << i << " threshold " << ret << endl;
|
||||
#endif
|
||||
if (ret1==-100)
|
||||
ret1=ret;
|
||||
else if (ret<(ret1-200) || ret>(ret1+200))
|
||||
ret1=FAIL;
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "return value " << ret1 << endl;
|
||||
#endif
|
||||
if(!threadpool){
|
||||
cout << "Error in creating threadpool. Exiting" << endl;
|
||||
return -1;
|
||||
}else{
|
||||
//return storage values
|
||||
int* iret[posmax-posmin];
|
||||
for(int idet=posmin; idet<posmax; idet++){
|
||||
if(detectors[idet]){
|
||||
iret[idet]= new int(-1);
|
||||
Task* task = new Task(new func3_t<int,slsDetector,int,int,detectorSettings,int>(&slsDetector::setThresholdEnergy,
|
||||
detectors[idet],e_eV,-1,isettings,iret[idet]));
|
||||
threadpool->add_task(task);
|
||||
}
|
||||
}
|
||||
threadpool->startExecuting();
|
||||
threadpool->wait_for_tasks_to_complete();
|
||||
for(int idet=posmin; idet<posmax; idet++){
|
||||
if(detectors[idet]){
|
||||
if(iret[idet] != NULL){
|
||||
if (ret==-100)
|
||||
ret=*iret[idet];
|
||||
else if (ret<(*iret[idet]-200) || ret>(*iret[idet]+200))
|
||||
ret=-1;
|
||||
}else ret=-1;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
delete iret[idet];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
thisMultiDetector->currentThresholdEV=ret;
|
||||
return ret;
|
||||
}
|
||||
thisMultiDetector->currentThresholdEV=ret1;
|
||||
return ret1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
slsDetectorDefs::detectorSettings multiSlsDetector::getSettings(int pos) {
|
||||
|
||||
int i, posmin, posmax;
|
||||
int posmin, posmax;
|
||||
int ret=-100;
|
||||
|
||||
if (pos<0) {
|
||||
@@ -1212,10 +1243,10 @@ slsDetectorDefs::detectorSettings multiSlsDetector::getSettings(int pos) {
|
||||
ret=*iret[idet];
|
||||
else if (ret!=*iret[idet])
|
||||
ret=GET_SETTINGS;
|
||||
delete iret[idet];
|
||||
}else ret=GET_SETTINGS;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
delete iret[idet];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1260,10 +1291,10 @@ slsDetectorDefs::detectorSettings multiSlsDetector::setSettings(detectorSettings
|
||||
ret=*iret[idet];
|
||||
else if (ret!=*iret[idet])
|
||||
ret=GET_SETTINGS;
|
||||
delete iret[idet];
|
||||
}else ret=GET_SETTINGS;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
delete iret[idet];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1423,7 +1454,7 @@ int* multiSlsDetector::getDataFromDetector() {
|
||||
int n = 0;
|
||||
int* retval= NULL;
|
||||
int *retdet, *p=retval;
|
||||
int nodata=1, nodatadet=-1;
|
||||
int nodatadet=-1;
|
||||
int nodatadetectortype = false;
|
||||
detectorType types = getDetectorsType();
|
||||
if(types == EIGER || types == JUNGFRAU){
|
||||
@@ -1442,8 +1473,7 @@ int* multiSlsDetector::getDataFromDetector() {
|
||||
setErrorMask(getErrorMask()|(1<<id));
|
||||
if(!nodatadetectortype){
|
||||
n=detectors[id]->getDataBytes();
|
||||
if (retdet) {
|
||||
nodata=0;
|
||||
if (retdet) {;
|
||||
#ifdef VERBOSE
|
||||
cout << "Detector " << id << " returned " << n << " bytes " << endl;
|
||||
#endif
|
||||
@@ -1650,10 +1680,10 @@ int multiSlsDetector::startAndReadAllNoWait(){
|
||||
if(iret[idet] != NULL){
|
||||
if(*iret[idet] != OK)
|
||||
ret = FAIL;
|
||||
delete iret[idet];
|
||||
}else ret = FAIL;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
delete iret[idet];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2095,7 +2125,6 @@ slsDetectorDefs::ROI* multiSlsDetector::getROI(int &n){
|
||||
n = 0;
|
||||
int num = 0,i,j;
|
||||
int ndet = thisMultiDetector->numberOfDetectors;
|
||||
int nroi[ndet];
|
||||
int maxroi = ndet*MAX_ROIS;
|
||||
ROI temproi;
|
||||
ROI roiLimits[maxroi];
|
||||
@@ -2110,7 +2139,6 @@ slsDetectorDefs::ROI* multiSlsDetector::getROI(int &n){
|
||||
if(detectors[i]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<i));
|
||||
|
||||
nroi[i] = index;
|
||||
if(temp){
|
||||
//#ifdef VERBOSE
|
||||
if(index)
|
||||
@@ -2333,7 +2361,7 @@ int multiSlsDetector::setFlatFieldCorrection(string fname){
|
||||
char ffffname[MAX_STR_LENGTH*2];
|
||||
int nch;//nbad=0,
|
||||
//int badlist[MAX_BADCHANS];
|
||||
int im=0;
|
||||
//int im=0;
|
||||
|
||||
if (fname=="default") {
|
||||
fname=string(thisMultiDetector->flatFieldFile);
|
||||
@@ -2605,7 +2633,7 @@ int multiSlsDetector::setRateCorrection(double t){
|
||||
ret=detectors[idet]->setRateCorrection(t);
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
if (ret1 != OK)
|
||||
if (ret != OK)
|
||||
ret1=FAIL;
|
||||
}
|
||||
}
|
||||
@@ -3335,8 +3363,6 @@ char* multiSlsDetector::setNetworkParameter(networkParameter p, string s){
|
||||
|
||||
if (s.find('+')==string::npos) {
|
||||
|
||||
int posmin=0, posmax=thisMultiDetector->numberOfDetectors;
|
||||
|
||||
if(!threadpool){
|
||||
cout << "Error in creating threadpool. Exiting" << endl;
|
||||
return getNetworkParameter(p);
|
||||
@@ -4002,10 +4028,10 @@ int multiSlsDetector::executeTrimming(trimMode mode, int par1, int par2, int imo
|
||||
ret=*iret[idet];
|
||||
else if (ret!=*iret[idet])
|
||||
ret=-1;
|
||||
delete iret[idet];
|
||||
}else ret=-1;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
delete iret[idet];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4100,10 +4126,10 @@ int multiSlsDetector::loadSettingsFile(string fname, int imod) {
|
||||
if(iret[idet] != NULL){
|
||||
if(*iret[idet] != OK)
|
||||
ret = FAIL;
|
||||
delete iret[idet];
|
||||
}else ret = FAIL;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
delete iret[idet];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4177,10 +4203,10 @@ int multiSlsDetector::setAllTrimbits(int val, int imod){
|
||||
ret=*iret[idet];
|
||||
else if (ret!=*iret[idet])
|
||||
ret=-1;
|
||||
delete iret[idet];
|
||||
}else ret=-1;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
delete iret[idet];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4225,10 +4251,10 @@ int multiSlsDetector::loadCalibrationFile(string fname, int imod) {
|
||||
if(iret[idet] != NULL){
|
||||
if(*iret[idet] != OK)
|
||||
ret = FAIL;
|
||||
delete iret[idet];
|
||||
}else ret = FAIL;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
delete iret[idet];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4513,9 +4539,7 @@ int multiSlsDetector::writeConfigurationFile(string const fname){
|
||||
|
||||
|
||||
ofstream outfile;
|
||||
#ifdef VERBOSE
|
||||
int ret;
|
||||
#endif
|
||||
int iline = 0;
|
||||
|
||||
outfile.open(fname.c_str(),ios_base::out);
|
||||
if (outfile.is_open()) {
|
||||
@@ -4528,7 +4552,7 @@ int multiSlsDetector::writeConfigurationFile(string const fname){
|
||||
cout << iv << " " << names[iv] << endl;
|
||||
strcpy(args[0],names[iv].c_str());
|
||||
outfile << names[iv] << " " << cmd->executeLine(1,args,GET_ACTION) << std::endl;
|
||||
|
||||
iline++;
|
||||
// single detector configuration
|
||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
||||
// sprintf(ext,".det%d",i);
|
||||
@@ -4546,6 +4570,7 @@ int multiSlsDetector::writeConfigurationFile(string const fname){
|
||||
cout << iv << " " << names[iv] << endl;
|
||||
strcpy(args[0],names[iv].c_str());
|
||||
outfile << names[iv] << " " << cmd->executeLine(1,args,GET_ACTION) << std::endl;
|
||||
iline++;
|
||||
}
|
||||
|
||||
|
||||
@@ -4557,7 +4582,7 @@ int multiSlsDetector::writeConfigurationFile(string const fname){
|
||||
return FAIL;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "wrote " <<ret << " lines to configuration file " << std::endl;
|
||||
std::cout<< "wrote " <<iline << " lines to configuration file " << std::endl;
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
@@ -4840,6 +4865,25 @@ string multiSlsDetector::setFileName(string s) {
|
||||
|
||||
|
||||
|
||||
slsReceiverDefs::fileFormat multiSlsDetector::setFileFormat(fileFormat f) {
|
||||
int ret=-100, ret1;
|
||||
|
||||
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
|
||||
if (detectors[idet]) {
|
||||
ret1=(int)detectors[idet]->setFileFormat(f);
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
if (ret==-100)
|
||||
ret=ret1;
|
||||
else if (ret!=ret1)
|
||||
ret=-1;
|
||||
}
|
||||
}
|
||||
return (fileFormat)ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int multiSlsDetector::setFileIndex(int i) {
|
||||
int ret=-100, ret1;
|
||||
|
||||
@@ -4884,10 +4928,10 @@ int multiSlsDetector::startReceiver(){
|
||||
if(iret[idet] != NULL){
|
||||
if(*iret[idet] != OK)
|
||||
ret = FAIL;
|
||||
delete iret[idet];
|
||||
}else ret = FAIL;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
delete iret[idet];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4946,10 +4990,10 @@ int multiSlsDetector::stopReceiver(){
|
||||
if(iret[idet] != NULL){
|
||||
if(*iret[idet] != OK)
|
||||
ret = FAIL;
|
||||
delete iret[idet];
|
||||
}else ret = FAIL;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
delete iret[idet];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5100,17 +5144,12 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy){
|
||||
if(destroy){
|
||||
cprintf(MAGENTA,"Going to destroy data sockets\n");
|
||||
//close socket
|
||||
for(int i=0;i<numSockets; ++i){
|
||||
if(strlen(dataSocketServerDetails[i])){
|
||||
zmq_disconnect(zmqsocket[i], dataSocketServerDetails[i]);
|
||||
zmq_close(zmqsocket[i]);
|
||||
zmq_ctx_destroy(context[i]);
|
||||
context[i] = NULL;
|
||||
zmqsocket[i] = NULL;
|
||||
strcpy(dataSocketServerDetails[i],"");
|
||||
for(int i=0;i<MAXDET;++i) {
|
||||
if (zmqSocket[i]) {
|
||||
delete zmqSocket[i];
|
||||
zmqSocket[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
dataSocketsStarted = false;
|
||||
cout << "Destroyed Receiving Data Socket(s)" << endl;
|
||||
return OK;
|
||||
@@ -5119,36 +5158,15 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy){
|
||||
cprintf(MAGENTA,"Going to create data sockets\n");
|
||||
|
||||
for(int i=0;i<numSockets; ++i){
|
||||
//get name of rx_hostname
|
||||
char rx_hostname[100];
|
||||
strcpy(dataSocketServerDetails[i],"tcp://");
|
||||
strcpy(rx_hostname, detectors[i/numSocketsPerDetector]->getReceiver());
|
||||
cout<<"rx_hostname:"<<rx_hostname<<endl;
|
||||
//append it (first into ip) to tcp://
|
||||
if(strchr(rx_hostname,'.')!=NULL)
|
||||
strcat(dataSocketServerDetails[i],rx_hostname);
|
||||
else{
|
||||
//convert hostname to ip
|
||||
struct hostent *he = gethostbyname(rx_hostname);
|
||||
if (he == NULL){
|
||||
cprintf(RED,"ERROR: could not convert receiver hostname to ip\n");
|
||||
exit(-1);
|
||||
}else
|
||||
strcat(dataSocketServerDetails[i],inet_ntoa(*(struct in_addr*)he->h_addr));
|
||||
uint32_t portnum = DEFAULT_ZMQ_PORTNO +
|
||||
(i/numSocketsPerDetector)*numSocketsPerDetector + (i%numSocketsPerDetector);
|
||||
zmqSocket[i] = new ZmqSocket(detectors[i/numSocketsPerDetector]->getReceiver(), portnum);
|
||||
if (zmqSocket[i]->IsError()) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d\n", portnum);
|
||||
createReceivingDataSockets(true);
|
||||
return FAIL;
|
||||
}
|
||||
//add port
|
||||
sprintf(dataSocketServerDetails[i],"%s:%d",dataSocketServerDetails[i],DEFAULT_ZMQ_PORTNO +
|
||||
(i/numSocketsPerDetector)*numSocketsPerDetector + (i%numSocketsPerDetector));//using this instead of i in the offchance, detid doesnt start at 0 (shmget error)
|
||||
|
||||
//create context
|
||||
context[i] = zmq_ctx_new();
|
||||
//create socket
|
||||
zmqsocket[i] = zmq_socket(context[i], ZMQ_PULL);
|
||||
//connect socket
|
||||
zmq_connect(zmqsocket[i], dataSocketServerDetails[i]);
|
||||
//int hwmval = 10;
|
||||
//zmq_setsockopt(zmqsocket[i],ZMQ_RCVHWM,&hwmval,sizeof(hwmval)); //set receive HIGH WATER MARK (8-9ms slower//should not drop last packets)
|
||||
cout << "ZMQ Client[" << i << "] from " << dataSocketServerDetails[i] << endl;
|
||||
printf("Zmq Client[%d] at %s\n",i, zmqSocket[i]->GetZmqServerAddress());
|
||||
}
|
||||
|
||||
dataSocketsStarted = true;
|
||||
@@ -5164,90 +5182,23 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy){
|
||||
|
||||
|
||||
|
||||
int multiSlsDetector::getData(const int isocket, const bool masking, int* image, const int size, int &acqIndex, int &frameIndex, int &subframeIndex, string &filename){
|
||||
int multiSlsDetector::getData(const int isocket, const bool masking, int* image, const int size,
|
||||
uint64_t &acqIndex, uint64_t &frameIndex, uint32_t &subframeIndex, string &filename) {
|
||||
|
||||
zmq_msg_t message;
|
||||
|
||||
//scan header-------------------------------------------------------------------
|
||||
zmq_msg_init (&message);
|
||||
int len = zmq_msg_recv(&message, zmqsocket[isocket], 0);
|
||||
if (len == -1) {
|
||||
cprintf(BG_RED,"Could not read header for socket %d\n",isocket);
|
||||
zmq_msg_close(&message);
|
||||
cprintf(RED, "%d message null\n",isocket);
|
||||
//fail is on parse error or end of acquisition
|
||||
if (!zmqSocket[isocket]->ReceiveHeader(isocket, acqIndex, frameIndex, subframeIndex, filename))
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
|
||||
// error if you print it
|
||||
// cout << isocket << " header len:"<<len<<" value:"<< (char*)zmq_msg_data(&message)<<endl;
|
||||
//cprintf(BLUE,"%d header %d\n",isocket,len);
|
||||
rapidjson::Document d;
|
||||
d.Parse( (char*)zmq_msg_data(&message), zmq_msg_size(&message));
|
||||
#ifdef VERYVERBOSE
|
||||
// htype is an array of strings
|
||||
rapidjson::Value::Array htype = d["htype"].GetArray();
|
||||
for(int i=0; i< htype.Size(); i++)
|
||||
std::cout << isocket << "htype: " << htype[i].GetString() << std::endl;
|
||||
// shape is an array of ints
|
||||
rapidjson::Value::Array shape = d["shape"].GetArray();
|
||||
cout << isocket << "shape: ";
|
||||
for(int i=0; i< shape.Size(); i++)
|
||||
cout << isocket << shape[i].GetInt() << " ";
|
||||
cout << endl;
|
||||
|
||||
cout << isocket << "type: " << d["type"].GetString() << endl;
|
||||
|
||||
#endif
|
||||
if(d["acqIndex"].GetInt()!=-9){ //!isocket &&
|
||||
acqIndex = d["acqIndex"].GetInt();
|
||||
frameIndex = d["fIndex"].GetInt();
|
||||
subframeIndex = d["subfnum"].GetInt();
|
||||
filename = d["fname"].GetString();
|
||||
#ifdef VERYVERBOSE
|
||||
cout << "Acquisition index: " << acqIndex << endl;
|
||||
cout << "Frame index: " << frameIndex << endl;
|
||||
cout << "Subframe index: " << subframeIndex << endl;
|
||||
cout << "File name: " << filename << endl;
|
||||
#endif
|
||||
if(frameIndex ==-1) cprintf(RED,"multi frame index -1!!\n");
|
||||
}
|
||||
// close the message
|
||||
zmq_msg_close(&message);
|
||||
|
||||
|
||||
//scan data-------------------------------------------------------------------
|
||||
zmq_msg_init (&message);
|
||||
len = zmq_msg_recv(&message, zmqsocket[isocket], 0);
|
||||
//cprintf(BLUE,"%d data %d\n",isocket,len);
|
||||
|
||||
//end of socket ("end")
|
||||
if(len == 3){
|
||||
//cprintf(RED,"%d Received end of acquisition\n", isocket);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
//crappy image
|
||||
if (len < size ) {
|
||||
cprintf(RED,"Received weird packet size %d in socket for %d\n", len, isocket);
|
||||
memset((char*)image,0xFF,size);
|
||||
}
|
||||
//actual image
|
||||
else{
|
||||
//actual data
|
||||
//cprintf(BLUE,"%d actual dataaa\n",isocket);
|
||||
memcpy((char*)image,(char*)zmq_msg_data(&message),size);
|
||||
//receiving incorrect size is replaced by 0xFF
|
||||
zmqSocket[isocket]->ReceiveData(isocket, image, size);
|
||||
|
||||
//jungfrau masking adcval
|
||||
if(masking){
|
||||
int snel = size/sizeof(int);
|
||||
unsigned int snel = size/sizeof(int);
|
||||
for(unsigned int i=0;i<snel;++i){
|
||||
image[i] = (image[i] & 0x3FFF3FFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
zmq_msg_close(&message); // close the message
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -5278,17 +5229,18 @@ void multiSlsDetector::readFrameFromReceiver(){
|
||||
}
|
||||
|
||||
//gui variables
|
||||
int currentAcquisitionIndex = -1;
|
||||
int currentFrameIndex = -1;
|
||||
int currentSubFrameIndex = -1;
|
||||
uint64_t currentAcquisitionIndex = -1;
|
||||
uint64_t currentFrameIndex = -1;
|
||||
uint32_t currentSubFrameIndex = -1;
|
||||
string currentFileName = "";
|
||||
|
||||
//getting sls values
|
||||
int slsdatabytes = 0, slsmaxchannels = 0, bytesperchannel = 0, slsmaxX = 0, slsmaxY=0, nx=0, ny=0;
|
||||
int slsdatabytes = 0, slsmaxchannels = 0, slsmaxX = 0, slsmaxY=0, nx=0, ny=0;
|
||||
double bytesperchannel = 0;
|
||||
if(detectors[0]){
|
||||
slsdatabytes = detectors[0]->getDataBytes();
|
||||
slsmaxchannels = detectors[0]->getMaxNumberOfChannels();
|
||||
bytesperchannel = slsdatabytes/slsmaxchannels;
|
||||
bytesperchannel = (double)slsdatabytes/(double)slsmaxchannels;
|
||||
slsmaxX = detectors[0]->getTotalNumberOfChannels(X);
|
||||
slsmaxY = detectors[0]->getTotalNumberOfChannels(Y);
|
||||
}
|
||||
@@ -5355,17 +5307,17 @@ void multiSlsDetector::readFrameFromReceiver(){
|
||||
if(bottom[isocket]){
|
||||
//if((((isocket/numSocketsPerSLSDetector)+1)%2) == 0){
|
||||
for(int i=0;i<slsmaxY;++i){
|
||||
memcpy(((char*)multiframe) + offsetY[isocket] + offsetX[isocket] + ((slsmaxY-1-i)*maxX*bytesperchannel),
|
||||
(char*)image+ i*(slsmaxX/numSocketsPerSLSDetector)*bytesperchannel,
|
||||
(slsmaxX/numSocketsPerSLSDetector)*bytesperchannel);
|
||||
memcpy(((char*)multiframe) + offsetY[isocket] + offsetX[isocket] + (int)((slsmaxY-1-i)*maxX*bytesperchannel),
|
||||
(char*)image+ (int)(i*(slsmaxX/numSocketsPerSLSDetector)*bytesperchannel),
|
||||
(int)(slsmaxX/numSocketsPerSLSDetector)*bytesperchannel);
|
||||
}
|
||||
}
|
||||
//top
|
||||
else{
|
||||
for(int i=0;i<slsmaxY;++i){
|
||||
memcpy(((char*)multiframe) + offsetY[isocket] + offsetX[isocket] + (i*maxX*bytesperchannel),
|
||||
(char*)image+ i*(slsmaxX/numSocketsPerSLSDetector)*bytesperchannel,
|
||||
(slsmaxX/numSocketsPerSLSDetector)*bytesperchannel);
|
||||
memcpy(((char*)multiframe) + offsetY[isocket] + offsetX[isocket] + (int)(i*maxX*bytesperchannel),
|
||||
(char*)image+ (int)(i*(slsmaxX/numSocketsPerSLSDetector)*bytesperchannel),
|
||||
(int)(slsmaxX/numSocketsPerSLSDetector)*bytesperchannel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5567,7 +5519,7 @@ string multiSlsDetector::getErrorMessage(int &critical){
|
||||
slsMask=detectors[idet]->getErrorMask();
|
||||
#ifdef VERYVERBOSE
|
||||
//append sls det error mask
|
||||
sprintf(sNumber,"0x%x",slsMask);
|
||||
sprintf(sNumber,"0x%lx",slsMask);
|
||||
retval.append("Error Mask " + string(sNumber)+string("\n"));
|
||||
#endif
|
||||
//get the error critical level
|
||||
@@ -5800,10 +5752,10 @@ uint64_t multiSlsDetector::setCTBWord(int addr,uint64_t word) {
|
||||
ret1=detectors[idet]->setCTBWord(addr, word);
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
if(ret==-100)
|
||||
if(ret==(long long unsigned int)-100)
|
||||
ret=ret1;
|
||||
else if (ret!=ret1)
|
||||
ret=-1;
|
||||
ret=(long long unsigned int)-1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -5914,10 +5866,10 @@ int multiSlsDetector::pulsePixel(int n,int x,int y) {
|
||||
ret=*iret[idet];
|
||||
else if (ret!=*iret[idet])
|
||||
ret=-1;
|
||||
delete iret[idet];
|
||||
}else ret=-1;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
delete iret[idet];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5951,10 +5903,10 @@ int multiSlsDetector::pulsePixelNMove(int n,int x,int y) {
|
||||
ret=*iret[idet];
|
||||
else if (ret!=*iret[idet])
|
||||
ret=-1;
|
||||
delete iret[idet];
|
||||
}else ret=-1;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
delete iret[idet];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5988,10 +5940,10 @@ int multiSlsDetector::pulseChip(int n) {
|
||||
ret=*iret[idet];
|
||||
else if (ret!=*iret[idet])
|
||||
ret=-1;
|
||||
delete iret[idet];
|
||||
}else ret=-1;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
delete iret[idet];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ ID: $Id$
|
||||
|
||||
class slsDetector;
|
||||
class ThreadPool;
|
||||
class ZmqSocket;
|
||||
|
||||
//#include "sls_detector_defs.h"
|
||||
|
||||
@@ -121,6 +122,8 @@ class multiSlsDetector : public slsDetectorUtils {
|
||||
char filePath[MAX_STR_LENGTH];
|
||||
/** max frames per file */
|
||||
int framesPerFile;
|
||||
/** file format*/
|
||||
fileFormat fileFormatType;
|
||||
|
||||
/** corrections to be applied to the data \see ::correctionFlags */
|
||||
int correctionMask;
|
||||
@@ -198,7 +201,7 @@ class multiSlsDetector : public slsDetectorUtils {
|
||||
/** flag for acquiring */
|
||||
bool acquiringFlag;
|
||||
|
||||
};
|
||||
} sharedMultiSlsDetector;
|
||||
|
||||
|
||||
|
||||
@@ -320,6 +323,12 @@ class multiSlsDetector : public slsDetectorUtils {
|
||||
\returns number of detectors */
|
||||
int getNumberOfDetectors() {return thisMultiDetector->numberOfDetectors;};
|
||||
|
||||
/** returns the number of detectors in each direction
|
||||
\param nx number of detectors in x direction
|
||||
\param ny number of detectors in y direction
|
||||
*/
|
||||
void getNumberOfDetectors(int& nx, int& ny);
|
||||
|
||||
int getMaxMods();
|
||||
int getNMods();
|
||||
int getMaxMod(dimension d);
|
||||
@@ -1149,6 +1158,13 @@ class multiSlsDetector : public slsDetectorUtils {
|
||||
*/
|
||||
string setFileName(string s="");
|
||||
|
||||
/**
|
||||
Sets up the file format
|
||||
@param f file format
|
||||
\returns file format
|
||||
*/
|
||||
fileFormat setFileFormat(fileFormat f=GET_FILE_FORMAT);
|
||||
|
||||
/**
|
||||
Sets up the file index
|
||||
@param i file index
|
||||
@@ -1166,6 +1182,11 @@ class multiSlsDetector : public slsDetectorUtils {
|
||||
*/
|
||||
string getFileName(){return setFileName();};
|
||||
|
||||
/**
|
||||
\returns file name
|
||||
*/
|
||||
fileFormat getFileFormat(){return setFileFormat();};
|
||||
|
||||
/**
|
||||
\returns file index
|
||||
*/
|
||||
@@ -1408,14 +1429,23 @@ private:
|
||||
|
||||
/**
|
||||
* Gets data from socket
|
||||
* @param isocket socket index
|
||||
* @param masking if masking required (jungfrau)
|
||||
* @param image image buffer
|
||||
* @param size size of image
|
||||
* @param acqIndex address of acquisition index
|
||||
* @param frameIndex address of frame index
|
||||
* @param subframeIndex address of subframe index
|
||||
* @param filename address of file name
|
||||
*/
|
||||
int getData(const int isocket, const bool masking, int* image, const int size, int &acqIndex, int &frameIndex, int &subframeIndex, string &filename);
|
||||
int getData(const int isocket, const bool masking, int* image, const int size, uint64_t &acqIndex, uint64_t &frameIndex, uint32_t &subframeIndex, string &filename);
|
||||
|
||||
|
||||
/** Ensures if sockets created successfully */
|
||||
bool dataSocketsStarted;
|
||||
void *context[MAXDET];
|
||||
void *zmqsocket[MAXDET];
|
||||
char dataSocketServerDetails[MAXDET][100];
|
||||
|
||||
/** ZMQ Socket - Receiver to Client */
|
||||
ZmqSocket* zmqSocket[MAXDET];
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
//#define SVNPATH ""
|
||||
#define SVNURLLIB "git@git.psi.ch:sls_detectors_software/sls_detector_software.git"
|
||||
//#define SVNREPPATH ""
|
||||
#define SVNREPUUIDLIB "230d6b36e9852214f4ba5ae7c92647f35000b24d"
|
||||
//#define SVNREV 0x1313
|
||||
#define SVNREPUUIDLIB "6d38c0622a2936f70345e7d53aaf1c9e2de4cbd6"
|
||||
//#define SVNREV 0x1401
|
||||
//#define SVNKIND ""
|
||||
//#define SVNSCHED ""
|
||||
#define SVNAUTHLIB "Dhanya_Maliakal"
|
||||
#define SVNREVLIB 0x1313
|
||||
#define SVNDATELIB 0x20161130
|
||||
#define SVNREVLIB 0x1401
|
||||
#define SVNDATELIB 0x20170612
|
||||
//
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -270,6 +270,7 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
/** flipped data across x or y axis */
|
||||
int flippedData[2];
|
||||
|
||||
|
||||
} sharedSlsDetector;
|
||||
|
||||
|
||||
@@ -506,11 +507,12 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
\param fname name of the file to be written
|
||||
\param imod module number
|
||||
\param iodelay io delay (detector specific)
|
||||
\param tau tau (detector specific)
|
||||
\returns OK or FAIL if the file could not be written
|
||||
\sa ::sls_detector_module sharedSlsDetector mythenDetector::writeSettingsFile(string, int)
|
||||
*/
|
||||
using energyConversion::writeSettingsFile;
|
||||
int writeSettingsFile(string fname, int imod, int* iodelay=0);
|
||||
int writeSettingsFile(string fname, int imod, int iodelay, int tau);
|
||||
|
||||
|
||||
/**
|
||||
@@ -958,14 +960,15 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
/**
|
||||
configure chip
|
||||
\param module module to be set - must contain correct module number and also channel and chip registers
|
||||
\param gainval pointer to extra gain values
|
||||
\param offsetval pointer to extra offset values
|
||||
\param iodelay iodelay (detector specific)
|
||||
\param tau tau (detector specific)
|
||||
\param e_eV threashold in eV (detector specific)
|
||||
\param gainval pointer to extra gain values
|
||||
\param offsetval pointer to extra offset values
|
||||
\returns current register value
|
||||
\sa ::sls_detector_module
|
||||
*/
|
||||
int setModule(sls_detector_module module, int* gainval, int* offsetval,int* iodelay, int64_t tau);
|
||||
int setModule(sls_detector_module module, int iodelay, int tau, int e_eV, int* gainval=0, int* offsetval=0);
|
||||
//virtual int setModule(sls_detector_module module);
|
||||
|
||||
/**
|
||||
@@ -1000,6 +1003,14 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
*/
|
||||
int setThresholdEnergy(int e_eV, int imod=-1, detectorSettings isettings=GET_SETTINGS);
|
||||
|
||||
/**
|
||||
set threshold energy
|
||||
\param e_eV threshold in eV
|
||||
\param isettings ev. change settings
|
||||
\returns OK if successful, else FAIL
|
||||
*/
|
||||
int setThresholdEnergyAndSettings(int e_eV, detectorSettings isettings);
|
||||
|
||||
/**
|
||||
get detector settings
|
||||
\param imod module number (-1 all)
|
||||
@@ -1548,6 +1559,13 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
*/
|
||||
string setFileName(string s="");
|
||||
|
||||
/**
|
||||
Sets up the file format
|
||||
@param f file format
|
||||
\returns file format
|
||||
*/
|
||||
fileFormat setFileFormat(fileFormat f=GET_FILE_FORMAT);
|
||||
|
||||
/**
|
||||
Sets up the file index
|
||||
@param i file index
|
||||
@@ -1565,6 +1583,11 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
*/
|
||||
string getFileName(){return setFileName();};
|
||||
|
||||
/**
|
||||
\returns file name
|
||||
*/
|
||||
fileFormat getFileFormat(){return setFileFormat();};
|
||||
|
||||
/**
|
||||
\returns file index
|
||||
*/
|
||||
@@ -1742,7 +1765,17 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
*/
|
||||
int enableReceiverCompression(int i = -1);
|
||||
|
||||
/** send the detector host name to the eiger receiver
|
||||
/**
|
||||
* Send the multi detector size to the detector
|
||||
*/
|
||||
void sendMultiDetectorSize();
|
||||
|
||||
/** send the detector pos id to the receiver
|
||||
* for various file naming conventions for multi detectors in receiver
|
||||
*/
|
||||
void setDetectorId();
|
||||
|
||||
/** send the detector host name to the receiver
|
||||
* for various handshaking required with the detector
|
||||
*/
|
||||
void setDetectorHostname();
|
||||
|
||||
@@ -75,10 +75,10 @@ int slsDetectorActions::setActionScript(int iaction, string fname) {
|
||||
|
||||
|
||||
int slsDetectorActions::setActionParameter(int iaction, string par) {
|
||||
int am;
|
||||
//int am;
|
||||
|
||||
if (iaction>=0 && iaction<MAX_ACTIONS) {
|
||||
am= 1& ( (*actionMask) << iaction);
|
||||
// am= 1& ( (*actionMask) << iaction);
|
||||
|
||||
if (par!="") {
|
||||
strcpy(actionParameter[iaction],par.c_str());
|
||||
|
||||
@@ -433,10 +433,6 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
|
||||
int setThresholdEnergy(int e_eV){return setThresholdEnergy(e_eV,-1);};
|
||||
|
||||
|
||||
// int getBeamEnergy(){return 2*getThresholdEnergy();};
|
||||
//int setBeamEnergy(int e){return 2*setThresholdEnergy(e/2);};
|
||||
|
||||
|
||||
/**
|
||||
Prints receiver configuration
|
||||
\returns OK or FAIL
|
||||
@@ -743,6 +739,18 @@ virtual void readFrameFromReceiver()=0;
|
||||
default: return string("idle"); \
|
||||
}};
|
||||
|
||||
/** returns string from file format index
|
||||
\param s can be RAW, HDF5
|
||||
\returns string raw, hdf5
|
||||
*/
|
||||
static string fileFormats(fileFormat f){\
|
||||
switch (f) { \
|
||||
case BINARY: return string("binary"); \
|
||||
case ASCII: return string("ascii"); \
|
||||
case HDF5: return string("hdf5"); \
|
||||
default: return string("unknown"); \
|
||||
}};
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -184,7 +184,7 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="trimen";
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdUnderDevelopment;
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTrimEn;
|
||||
i++;
|
||||
|
||||
|
||||
@@ -226,6 +226,10 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdFileName;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="fileformat"; //OK
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdFileName;
|
||||
i++;
|
||||
|
||||
/* Acquisition actions */
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="positions"; //
|
||||
@@ -656,10 +660,6 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="ib_test_c"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="dac0"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
|
||||
i++;
|
||||
@@ -957,6 +957,10 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimeLeft;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="probesl"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimeLeft;
|
||||
i++;
|
||||
|
||||
// descrToFuncMap[i].m_pFuncName="progress";
|
||||
// descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimer;
|
||||
// i++;
|
||||
@@ -1959,7 +1963,18 @@ string slsDetectorCommand::cmdFileName(int narg, char *args[], int action){
|
||||
myDet->setFileName(string(args[1]));
|
||||
|
||||
return string(myDet->getFileName());
|
||||
} else
|
||||
} else if(cmd=="fileformat") {
|
||||
if (action==PUT_ACTION){
|
||||
if (string(args[1])=="binary")
|
||||
myDet->setFileFormat(BINARY);
|
||||
else if (string(args[1])=="ascii")
|
||||
myDet->setFileFormat(ASCII);
|
||||
else if (string(args[1])=="hdf5")
|
||||
myDet->setFileFormat(HDF5);
|
||||
else return string("could not scan file format mode\n");
|
||||
}
|
||||
return myDet->fileFormats(myDet->getFileFormat());
|
||||
}
|
||||
return string(myDet->getCurrentFileName());
|
||||
|
||||
}
|
||||
@@ -1968,10 +1983,14 @@ string slsDetectorCommand::cmdFileName(int narg, char *args[], int action){
|
||||
|
||||
string slsDetectorCommand::helpFileName(int narg, char *args[], int action){
|
||||
ostringstream os;
|
||||
if (action==GET_ACTION || action==HELP_ACTION)
|
||||
if (action==GET_ACTION || action==HELP_ACTION){
|
||||
os << string("fname \t gets the filename for the data without index and extension\n");
|
||||
if (action==PUT_ACTION || action==HELP_ACTION)
|
||||
os << string("fileformat \t gets the file format for data\n");
|
||||
}
|
||||
if (action==PUT_ACTION || action==HELP_ACTION){
|
||||
os << string("fname s \t sets the filename for the data (index and extension will be automatically appended)\n");
|
||||
os << string("fname s \t sets the file format for the data (binary, ascii, hdf5)\n");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
@@ -2002,9 +2021,9 @@ string slsDetectorCommand::cmdEnablefwrite(int narg, char *args[], int action){
|
||||
string slsDetectorCommand::helpEnablefwrite(int narg, char *args[], int action){
|
||||
ostringstream os;
|
||||
if (action==GET_ACTION || action==HELP_ACTION)
|
||||
os << string("When Enabled writes the data into the file\n");
|
||||
os << string("enablefwrite \t When Enabled writes the data into the file\n");
|
||||
if (action==PUT_ACTION || action==HELP_ACTION)
|
||||
os << string(" i \t should be 1 or 0 or -1\n");
|
||||
os << string("enablefwrite i \t should be 1 or 0 or -1\n");
|
||||
return os.str();
|
||||
}
|
||||
|
||||
@@ -2034,9 +2053,9 @@ string slsDetectorCommand::cmdOverwrite(int narg, char *args[], int action){
|
||||
string slsDetectorCommand::helpOverwrite(int narg, char *args[], int action){
|
||||
ostringstream os;
|
||||
if (action==GET_ACTION || action==HELP_ACTION)
|
||||
os << string("When Enabled overwrites files\n");
|
||||
os << string("overwrite \t When Enabled overwrites files\n");
|
||||
if (action==PUT_ACTION || action==HELP_ACTION)
|
||||
os << string(" i \t should be 1 or 0 or -1\n");
|
||||
os << string("overwrite i \t should be 1 or 0 or -1\n");
|
||||
return os.str();
|
||||
}
|
||||
|
||||
@@ -2066,7 +2085,7 @@ string slsDetectorCommand::helpFileIndex(int narg, char *args[], int action){
|
||||
if (action==GET_ACTION || action==HELP_ACTION)
|
||||
os << string("index \t gets the file index for the next the data file\n");
|
||||
if (action==PUT_ACTION || action==HELP_ACTION)
|
||||
os << string("fname i \t sets the fileindex for the next data file\n");
|
||||
os << string("index i \t sets the fileindex for the next data file\n");
|
||||
return os.str();
|
||||
}
|
||||
|
||||
@@ -2942,7 +2961,7 @@ string slsDetectorCommand::helpNetworkParameter(int narg, char *args[], int acti
|
||||
os << "txndelay_left \n gets detector transmission delay of the left port"<< std::endl;
|
||||
os << "txndelay_right \n gets detector transmission delay of the right port"<< std::endl;
|
||||
os << "txndelay_frame \n gets detector transmission delay of the entire frame"<< std::endl;
|
||||
os << "flowcontrol_10g \n sets flow control for 10g for eiger"<< std::endl;
|
||||
os << "flowcontrol_10g \n gets flow control for 10g for eiger"<< std::endl;
|
||||
}
|
||||
return os.str();
|
||||
|
||||
@@ -3354,15 +3373,28 @@ string slsDetectorCommand::cmdSettings(int narg, char *args[], int action) {
|
||||
myDet->setOnline(ONLINE_FLAG);
|
||||
|
||||
if (cmd=="settings") {
|
||||
if (action==PUT_ACTION)
|
||||
myDet->setSettings(myDet->getDetectorSettings(string(args[1])));
|
||||
detectorSettings sett = GET_SETTINGS;
|
||||
if (action==PUT_ACTION) {
|
||||
sett = myDet->setSettings(myDet->getDetectorSettings(string(args[1])));
|
||||
if (myDet->getDetectorsType() == EIGER) {
|
||||
return myDet->getDetectorSettings(sett);
|
||||
}
|
||||
}
|
||||
return myDet->getDetectorSettings(myDet->getSettings());
|
||||
} else if (cmd=="threshold") {
|
||||
if (action==PUT_ACTION) {
|
||||
if (sscanf(args[1],"%d",&val))
|
||||
detectorType type = myDet->getDetectorsType();
|
||||
if (!sscanf(args[1],"%d",&val)) {
|
||||
return string("invalid threshold value");
|
||||
}
|
||||
if (type != EIGER || (type == EIGER && narg<=2)) {
|
||||
myDet->setThresholdEnergy(val);
|
||||
else
|
||||
return string("invalid threshold value ")+cmd;
|
||||
} else {
|
||||
detectorSettings sett= myDet->getDetectorSettings(string(args[2]));
|
||||
if(sett == -1)
|
||||
return string("invalid settings value");
|
||||
myDet->setThresholdEnergy(val, -1, sett);
|
||||
}
|
||||
}
|
||||
sprintf(ans,"%d",myDet->getThresholdEnergy());
|
||||
return string(ans);
|
||||
@@ -3489,7 +3521,11 @@ string slsDetectorCommand::cmdSN(int narg, char *args[], int action) {
|
||||
|
||||
|
||||
if (cmd=="thisversion"){
|
||||
sprintf(answer,"%llx",myDet->getId(THIS_SOFTWARE_VERSION));
|
||||
int64_t retval = myDet->getId(THIS_SOFTWARE_VERSION);
|
||||
if (retval < 0)
|
||||
sprintf(answer, "%d", -1);
|
||||
else
|
||||
sprintf(answer,"%lx", retval);
|
||||
return string(answer);
|
||||
}
|
||||
|
||||
@@ -3499,37 +3535,61 @@ string slsDetectorCommand::cmdSN(int narg, char *args[], int action) {
|
||||
if (cmd=="moduleversion") {
|
||||
int ival=-1;
|
||||
if (sscanf(args[0],"moduleversion:%d",&ival)) {
|
||||
sprintf(answer,"%llx",myDet->getId(MODULE_FIRMWARE_VERSION,ival));
|
||||
int64_t retval = myDet->getId(MODULE_FIRMWARE_VERSION, ival);
|
||||
if (retval < 0)
|
||||
sprintf(answer, "%d", -1);
|
||||
else
|
||||
sprintf(answer,"%lx", retval);
|
||||
return string(answer);
|
||||
} else
|
||||
return string("undefined module number");
|
||||
}
|
||||
if (cmd=="detectornumber") {
|
||||
sprintf(answer,"%llx",myDet->getId(DETECTOR_SERIAL_NUMBER));
|
||||
int64_t retval = myDet->getId(DETECTOR_SERIAL_NUMBER);
|
||||
if (retval < 0)
|
||||
sprintf(answer, "%d", -1);
|
||||
else
|
||||
sprintf(answer,"%lx", retval);
|
||||
return string(answer);
|
||||
}
|
||||
if (cmd.find("modulenumber")!=string::npos) {
|
||||
int ival=-1;
|
||||
if (sscanf(args[0],"modulenumber:%d",&ival)) {
|
||||
sprintf(answer,"%llx",myDet->getId(MODULE_SERIAL_NUMBER,ival));
|
||||
int64_t retval = myDet->getId(MODULE_SERIAL_NUMBER, ival);
|
||||
if (retval < 0)
|
||||
sprintf(answer, "%d", -1);
|
||||
else
|
||||
sprintf(answer,"%lx", retval);
|
||||
return string(answer);
|
||||
} else
|
||||
return string("undefined module number");
|
||||
}
|
||||
|
||||
if (cmd=="detectorversion") {
|
||||
sprintf(answer,"%llx",myDet->getId(DETECTOR_FIRMWARE_VERSION));
|
||||
int64_t retval = myDet->getId(DETECTOR_FIRMWARE_VERSION);
|
||||
if (retval < 0)
|
||||
sprintf(answer, "%d", -1);
|
||||
else
|
||||
sprintf(answer,"%lx", retval);
|
||||
return string(answer);
|
||||
}
|
||||
|
||||
if (cmd=="softwareversion") {
|
||||
sprintf(answer,"%llx",myDet->getId(DETECTOR_SOFTWARE_VERSION));
|
||||
int64_t retval = myDet->getId(DETECTOR_SOFTWARE_VERSION);
|
||||
if (retval < 0)
|
||||
sprintf(answer, "%d", -1);
|
||||
else
|
||||
sprintf(answer,"%lx", retval);
|
||||
return string(answer);
|
||||
}
|
||||
|
||||
if (cmd=="receiverversion") {
|
||||
myDet->setReceiverOnline(ONLINE_FLAG);
|
||||
sprintf(answer,"%llx",myDet->getId(RECEIVER_VERSION));
|
||||
int64_t retval = myDet->getId(RECEIVER_VERSION);
|
||||
if (retval < 0)
|
||||
sprintf(answer, "%d", -1);
|
||||
else
|
||||
sprintf(answer,"%lx", retval);
|
||||
return string(answer);
|
||||
}
|
||||
return string("unknown id mode ")+cmd;
|
||||
@@ -4022,13 +4082,13 @@ string slsDetectorCommand::helpDAC(int narg, char *args[], int action) {
|
||||
|
||||
|
||||
os << "dac0 " << "\t gets dac 0" << std::endl;
|
||||
os << "dac1 " << "\t gets dac 0" << std::endl;
|
||||
os << "dac2 " << "\t gets dac 0" << std::endl;
|
||||
os << "dac3 " << "\t gets dac 0" << std::endl;
|
||||
os << "dac4 " << "\t gets dac 0" << std::endl;
|
||||
os << "dac5 " << "\t gets dac 0" << std::endl;
|
||||
os << "dac6 " << "\t gets dac 0" << std::endl;
|
||||
os << "dac7 " << "\t gets dac 0" << std::endl;
|
||||
os << "dac1 " << "\t gets dac 1" << std::endl;
|
||||
os << "dac2 " << "\t gets dac 2" << std::endl;
|
||||
os << "dac3 " << "\t gets dac 3" << std::endl;
|
||||
os << "dac4 " << "\t gets dac 4" << std::endl;
|
||||
os << "dac5 " << "\t gets dac 5" << std::endl;
|
||||
os << "dac6 " << "\t gets dac 6" << std::endl;
|
||||
os << "dac7 " << "\t gets dac 7" << std::endl;
|
||||
|
||||
os << "vsvp" << "dacu\t gets vsvp" << std::endl;
|
||||
os << "vsvn" << "dacu\t gets vsvn" << std::endl;
|
||||
@@ -4221,12 +4281,16 @@ string slsDetectorCommand::cmdTimer(int narg, char *args[], int action) {
|
||||
|
||||
if (action==PUT_ACTION) {
|
||||
if (sscanf(args[1],"%lf", &val))
|
||||
;
|
||||
;//printf("value:%0.9lf\n",val);
|
||||
else
|
||||
return string("cannot scan timer value ")+string(args[1]);
|
||||
if (index==ACQUISITION_TIME || index==SUBFRAME_ACQUISITION_TIME || index==FRAME_PERIOD || index==DELAY_AFTER_TRIGGER)
|
||||
t=(int64_t)(val*1E+9);
|
||||
else t=(int64_t)val;
|
||||
if (index==ACQUISITION_TIME || index==SUBFRAME_ACQUISITION_TIME || index==FRAME_PERIOD || index==DELAY_AFTER_TRIGGER) {
|
||||
// t=(int64_t)(val*1E+9); for precision of eg.0.0000325, following done
|
||||
val*=1E9;
|
||||
t = (int64_t)val;
|
||||
if(fabs(val-t)) // to validate precision loss
|
||||
t = t + val - t; //even t += vak-t loses precision
|
||||
}else t=(int64_t)val;
|
||||
}
|
||||
|
||||
|
||||
@@ -4595,7 +4659,7 @@ string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action) {
|
||||
if (action==GET_ACTION)
|
||||
return string("cannot get");
|
||||
#ifdef VERBOSE
|
||||
std::cout<< " resetting fpga " << sval << std::endl;
|
||||
std::cout<< " resetting fpga " << std::endl;
|
||||
#endif
|
||||
myDet->setOnline(ONLINE_FLAG);
|
||||
if(myDet->resetFPGA() == OK)
|
||||
@@ -4645,13 +4709,18 @@ string slsDetectorCommand::helpAdvanced(int narg, char *args[], int action) {
|
||||
|
||||
os << "programfpga f \t programs the fpga with file f (with .pof extension)." << std::endl;
|
||||
os << "resetfpga f \t resets fpga, f can be any value" << std::endl;
|
||||
|
||||
os << "led s \t sets led status (0 off, 1 on)" << std::endl;
|
||||
os << "powerchip i \t powers on or off the chip. i = 1 for on, i = 0 for off" << std::endl;
|
||||
}
|
||||
if (action==GET_ACTION || action==HELP_ACTION) {
|
||||
|
||||
os << "extsig:i \t gets the mode of the external signal i. can be \n \t \t \t off, \n \t \t \t gate_in_active_high, \n \t \t \t gate_in_active_low, \n \t \t \t trigger_in_rising_edge, \n \t \t \t trigger_in_falling_edge, \n \t \t \t ro_trigger_in_rising_edge, \n \t \t \t ro_trigger_in_falling_edge, \n \t \t \t gate_out_active_high, \n \t \t \t gate_out_active_low, \n \t \t \t trigger_out_rising_edge, \n \t \t \t trigger_out_falling_edge, \n \t \t \t ro_trigger_out_rising_edge, \n \t \t \t ro_trigger_out_falling_edge" << std::endl;
|
||||
|
||||
os << "flags \t gets the readout flags. can be none, storeinram, tot, continous, parallel, nonparallel, safe, digital, analog_digital, unknown" << std::endl;
|
||||
os << "led \t returns led status (0 off, 1 on)" << std::endl;
|
||||
os << "flags \t gets the readout flags. can be none, storeinram, tot, continous, parallel, nonparallel, safe, unknown" << std::endl;
|
||||
os << "powerchip \t gets if the chip has been powered on or off" << std::endl;
|
||||
|
||||
}
|
||||
return os.str();
|
||||
@@ -4988,7 +5057,7 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) {
|
||||
else
|
||||
return string("Could not scan address (hexadecimal fomat) ")+string(args[1]);
|
||||
|
||||
if (sscanf(args[2],"%llx",&word))
|
||||
if (sscanf(args[2],"%lx",&word))
|
||||
;
|
||||
else
|
||||
return string("Could not scan value (hexadecimal fomat) ")+string(args[2]);
|
||||
@@ -5004,7 +5073,7 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) {
|
||||
|
||||
if (action==PUT_ACTION) {
|
||||
|
||||
if (sscanf(args[1],"%llx",&word))
|
||||
if (sscanf(args[1],"%lx",&word))
|
||||
;
|
||||
else
|
||||
return string("Could not scan value (hexadecimal fomat) ")+string(args[1]);
|
||||
@@ -5021,7 +5090,7 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) {
|
||||
|
||||
if (action==PUT_ACTION) {
|
||||
|
||||
if (sscanf(args[1],"%llx",&word))
|
||||
if (sscanf(args[1],"%lx",&word))
|
||||
;
|
||||
else
|
||||
return string("Could not scan value (hexadecimal fomat) ")+string(args[1]);
|
||||
@@ -5292,7 +5361,7 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) {
|
||||
|
||||
if (action==PUT_ACTION) {
|
||||
|
||||
if (sscanf(args[1],"%lld",&t))
|
||||
if (sscanf(args[1],"%ld",&t))
|
||||
;
|
||||
else
|
||||
return string("Could not scan wait time")+string(args[1]);
|
||||
@@ -5315,7 +5384,7 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) {
|
||||
|
||||
if (action==PUT_ACTION) {
|
||||
|
||||
if (sscanf(args[1],"%lld",&t))
|
||||
if (sscanf(args[1],"%ld",&t))
|
||||
;
|
||||
else
|
||||
return string("Could not scan wait time ")+string(args[1]);
|
||||
@@ -5333,7 +5402,7 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) {
|
||||
} else if (cmd=="patwaittime2") {
|
||||
if (action==PUT_ACTION) {
|
||||
|
||||
if (sscanf(args[1],"%lld",&t))
|
||||
if (sscanf(args[1],"%ld",&t))
|
||||
;
|
||||
else
|
||||
return string("Could not scan wait time ")+string(args[1]);
|
||||
@@ -5521,13 +5590,12 @@ string slsDetectorCommand::cmdPulse(int narg, char *args[], int action) {
|
||||
|
||||
}
|
||||
|
||||
return string("");
|
||||
/*
|
||||
|
||||
if(retval == OK)
|
||||
return string(" successful");
|
||||
else
|
||||
return string(" failed");
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -147,14 +147,6 @@ int slsDetectorUsers::setThresholdEnergy(int e_eV){
|
||||
return myDetector->setThresholdEnergy(e_eV);
|
||||
}
|
||||
|
||||
int slsDetectorUsers::getBeamEnergy(){
|
||||
return 2*myDetector->getThresholdEnergy();
|
||||
}
|
||||
|
||||
int slsDetectorUsers::setBeamEnergy(int e_eV){
|
||||
return 2*myDetector->setThresholdEnergy(e_eV/2);
|
||||
}
|
||||
|
||||
double slsDetectorUsers::setExposureTime(double t, bool inseconds){
|
||||
int64_t tms = (int64_t)(t * (1E+9));
|
||||
if (t < 0) tms = -1;
|
||||
|
||||
@@ -302,19 +302,6 @@ class slsDetectorUsers
|
||||
*/
|
||||
int setThresholdEnergy(int e_eV);
|
||||
|
||||
/**
|
||||
@short get beam energy -- only for dectris!
|
||||
\returns current beam energy
|
||||
*/
|
||||
int getBeamEnergy();
|
||||
|
||||
|
||||
/**
|
||||
@short set beam energy -- only for dectris!
|
||||
\param e_eV beam in eV
|
||||
\returns current beam energyin ev (-1 failed)
|
||||
*/
|
||||
int setBeamEnergy(int e_eV);
|
||||
|
||||
/**
|
||||
@short set/get exposure time value
|
||||
|
||||
@@ -226,9 +226,6 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
|
||||
for (int ip=0; ip<np; ip++) {
|
||||
|
||||
//let processing thread listen to these packets
|
||||
sem_post(&sem_newRTAcquisition);
|
||||
|
||||
// cout << "positions " << endl;
|
||||
if (*stoppedFlag==0) {
|
||||
if (getNumberOfPositions()>0) {
|
||||
@@ -304,14 +301,21 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
pthread_mutex_unlock(&mg);//cout << "unlock"<< endl;
|
||||
break;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
cout << "Receiver started " << endl;
|
||||
#endif
|
||||
pthread_mutex_unlock(&mg);//cout << "unlock"<< endl;
|
||||
|
||||
//let processing thread listen to these packets
|
||||
sem_post(&sem_newRTAcquisition);
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
cout << "Acquiring " << endl;
|
||||
#endif
|
||||
startAndReadAll();
|
||||
#ifdef VERBOSE
|
||||
cout << "detector finished " << endl;
|
||||
#endif
|
||||
#ifdef VERBOSE
|
||||
cout << "returned! " << endl;
|
||||
#endif
|
||||
@@ -802,7 +806,6 @@ int slsDetectorUtils::dumpDetectorSetup(string const fname, int level){
|
||||
slsDetectorCommand *cmd;
|
||||
string names[100];
|
||||
int nvar=0;
|
||||
int nvar1=0;
|
||||
|
||||
names[nvar++]="fname";
|
||||
names[nvar++]="index";
|
||||
@@ -882,6 +885,9 @@ int slsDetectorUtils::dumpDetectorSetup(string const fname, int level){
|
||||
names[nvar++]="patnloop2";
|
||||
names[nvar++]="patwait2";
|
||||
names[nvar++]="patwaittime2";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -912,7 +918,8 @@ int slsDetectorUtils::dumpDetectorSetup(string const fname, int level){
|
||||
names[nvar++]="flatfield";
|
||||
names[nvar++]="badchannels";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (getDetectorsType()) {
|
||||
@@ -920,7 +927,8 @@ int slsDetectorUtils::dumpDetectorSetup(string const fname, int level){
|
||||
case MYTHEN:
|
||||
names[nvar++]="trimbits";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// char ext[100];
|
||||
|
||||
@@ -642,6 +642,13 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
||||
*/
|
||||
virtual string setFileName(string s="")=0;
|
||||
|
||||
/**
|
||||
Sets up the file format
|
||||
@param f file format
|
||||
\returns file format
|
||||
*/
|
||||
virtual fileFormat setFileFormat(fileFormat f=GET_FILE_FORMAT)=0;
|
||||
|
||||
/**
|
||||
\returns file dir
|
||||
*/
|
||||
@@ -652,6 +659,11 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
||||
*/
|
||||
virtual string getFileName()=0;
|
||||
|
||||
/**
|
||||
\returns file name
|
||||
*/
|
||||
virtual fileFormat getFileFormat()=0;
|
||||
|
||||
/**
|
||||
\returns frames caught by receiver
|
||||
*/
|
||||
|
||||
@@ -255,8 +255,8 @@ int angularConversionStatic::readAngularConversion( ifstream& infile, int nmod,
|
||||
angOff[nm].etilt=epitch;
|
||||
|
||||
}
|
||||
// cout << angOff[nm].center << " " << \
|
||||
// angOff[nm].r_conversion << " " << \
|
||||
// cout << angOff[nm].center << " " <<
|
||||
// angOff[nm].r_conversion << " " <<
|
||||
// angOff[nm].offset << endl;
|
||||
|
||||
} else
|
||||
|
||||
@@ -69,19 +69,12 @@ int energyConversion::writeCalibrationFile(string fname, double gain, double off
|
||||
};
|
||||
|
||||
|
||||
int energyConversion::readCalibrationFile(string fname, int *gain, int *offset, int64_t &tau, detectorType myDetectorType){
|
||||
|
||||
|
||||
int energyConversion::readCalibrationFile(string fname, int *gain, int *offset){
|
||||
|
||||
string str;
|
||||
ifstream infile;
|
||||
double o,g;
|
||||
int ig=0;
|
||||
switch (myDetectorType) {
|
||||
case EIGER:
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Opening file "<< fname << std::endl;
|
||||
#endif
|
||||
@@ -102,16 +95,6 @@ int energyConversion::readCalibrationFile(string fname, int *gain, int *offset,
|
||||
if (ig>=4)
|
||||
break;
|
||||
}
|
||||
//get tau
|
||||
if (myDetectorType == EIGER) {
|
||||
if(getline(infile,str)){
|
||||
istringstream ssstr(str);
|
||||
ssstr >> tau;
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "tau:" << tau << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
infile.close();
|
||||
cout << "Calibration file loaded: " << fname << endl;
|
||||
} else {
|
||||
@@ -127,27 +110,17 @@ int energyConversion::readCalibrationFile(string fname, int *gain, int *offset,
|
||||
return OK;
|
||||
#endif
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
std::cout<< "Writing Calibration Files for this detector not defined\n" << std::endl;
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
int energyConversion::writeCalibrationFile(string fname, int *gain, int *offset, int64_t tau, detectorType myDetectorType){
|
||||
int energyConversion::writeCalibrationFile(string fname, int *gain, int *offset){
|
||||
//std::cout<< "Function not yet implemented " << std::endl;
|
||||
ofstream outfile;
|
||||
switch (myDetectorType) {
|
||||
case EIGER:
|
||||
|
||||
outfile.open (fname.c_str());
|
||||
|
||||
// >> i/o operations here <<
|
||||
if (outfile.is_open()) {
|
||||
for (int ig=0; ig<4; ig++)
|
||||
outfile << ((double)offset[ig]/1000) << " " << ((double)gain[ig]/1000) << std::endl;
|
||||
outfile << tau << std::endl;
|
||||
} else {
|
||||
std::cout<< "Could not open calibration file "<< fname << " for writing" << std::endl;
|
||||
#ifndef MYROOT
|
||||
@@ -161,13 +134,45 @@ int energyConversion::writeCalibrationFile(string fname, int *gain, int *offset,
|
||||
return OK;
|
||||
#endif
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
std::cout<< "Writing Calibration Files for this detector not defined\n" << std::endl;
|
||||
return FAIL;
|
||||
};
|
||||
|
||||
|
||||
|
||||
slsDetectorDefs::sls_detector_module* energyConversion::interpolateTrim(detectorType myDetectorType, sls_detector_module* a, sls_detector_module* b, const int energy, const int e1, const int e2){
|
||||
// only implemented for eiger currently (in terms of which dacs)
|
||||
if(myDetectorType != EIGER) {
|
||||
printf("Interpolation of Trim values not implemented for this detector!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sls_detector_module* myMod = createModule(myDetectorType);
|
||||
enum eiger_DacIndex{SVP,VTR,VRF,VRS,SVN,VTGSTV,VCMP_LL,VCMP_LR,CAL,VCMP_RL,RXB_RB,RXB_LB,VCMP_RR,VCP,VCN,VIS};
|
||||
|
||||
//Copy other dacs
|
||||
int num_dacs_to_copy = 10;
|
||||
int dacs_to_copy[] = {SVP,VTR,VRS,SVN,VTGSTV,CAL,RXB_RB,RXB_LB,VCN,VIS};
|
||||
for (int i = 0; i < num_dacs_to_copy; ++i) {
|
||||
if(a->dacs[dacs_to_copy[i]] != b->dacs[dacs_to_copy[i]]) {
|
||||
deleteModule(myMod);
|
||||
return NULL;
|
||||
}
|
||||
myMod->dacs[dacs_to_copy[i]] = a->dacs[dacs_to_copy[i]];
|
||||
}
|
||||
|
||||
//Interpolate vrf, vcmp, vcp
|
||||
int num_dacs_to_interpolate = 6;
|
||||
int dacs_to_interpolate[] = {VRF,VCMP_LL,VCMP_LR,VCMP_RL,VCMP_RR,VCP};
|
||||
for (int i = 0; i < num_dacs_to_interpolate; ++i) {
|
||||
myMod->dacs[dacs_to_interpolate[i]] = linearInterpolation(energy, e1, e2,
|
||||
a->dacs[dacs_to_interpolate[i]], b->dacs[dacs_to_interpolate[i]]);
|
||||
}
|
||||
|
||||
//Interpolate all trimbits
|
||||
for (int i = 0; i<myMod->nchan; i++)
|
||||
myMod->chanregs[i] = linearInterpolation(energy, e1, e2, a->chanregs[i], b->chanregs[i]);
|
||||
return myMod;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#ifndef MYROOT
|
||||
@@ -175,7 +180,7 @@ int energyConversion::writeCalibrationFile(string fname, int *gain, int *offset,
|
||||
/* I/O */
|
||||
|
||||
|
||||
slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string fname, detectorType myDetectorType, sls_detector_module *myMod, int* iodelay){
|
||||
slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string fname, detectorType myDetectorType, int& iodelay, int& tau, sls_detector_module* myMod){
|
||||
|
||||
|
||||
|
||||
@@ -353,7 +358,7 @@ slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string
|
||||
|
||||
infile.close();
|
||||
strcpy(settingsFile,fname.c_str());
|
||||
cout << "Settings file loaded: " << settingsFile << endl;
|
||||
printf("Settings file loaded: %s\n",settingsFile);
|
||||
return myMod;
|
||||
|
||||
}
|
||||
@@ -365,12 +370,14 @@ slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string
|
||||
infile.open(myfname.c_str(),ifstream::binary);
|
||||
if (infile.is_open()) {
|
||||
infile.read((char*) myMod->dacs,sizeof(dacs_t)*(myMod->ndac));
|
||||
infile.read((char*) iodelay,sizeof(*iodelay));
|
||||
infile.read((char*)&iodelay,sizeof(iodelay));
|
||||
infile.read((char*)&tau,sizeof(tau));
|
||||
infile.read((char*) myMod->chanregs,sizeof(int)*(myMod->nchan));
|
||||
#ifdef VERBOSE
|
||||
for(int i=0;i<myMod->ndac;i++)
|
||||
std::cout << "dac " << i << ":" << myMod->dacs[i] << std::endl;
|
||||
std::cout << "iodelay:" << *iodelay << std::endl;
|
||||
std::cout << "iodelay:" << iodelay << std::endl;
|
||||
std::cout << "tau:" << tau << std::endl;
|
||||
#endif
|
||||
if(infile.eof()){
|
||||
cout<<endl<<"Error, could not load trimbits end of file, "<<myfname<<", reached."<<endl<<endl;
|
||||
@@ -381,7 +388,7 @@ slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string
|
||||
}
|
||||
infile.close();
|
||||
strcpy(settingsFile,fname.c_str());
|
||||
cout << "Settings file loaded: " << settingsFile << endl;
|
||||
printf("Settings file loaded: %s\n",settingsFile);
|
||||
return myMod;
|
||||
|
||||
}
|
||||
@@ -423,7 +430,7 @@ slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string
|
||||
|
||||
infile.close();
|
||||
strcpy(settingsFile,fname.c_str());
|
||||
cout << "Settings file loaded: " << settingsFile << endl;
|
||||
printf("Settings file loaded: %s\n",settingsFile);
|
||||
return myMod;
|
||||
|
||||
}
|
||||
@@ -439,7 +446,7 @@ slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string
|
||||
|
||||
}
|
||||
|
||||
std::cout<< "Error: Could not open settings file " << myfname << std::endl;
|
||||
printf("Error: Could not open settings file %s\n", myfname.c_str());
|
||||
if (nflag)
|
||||
deleteModule(myMod);
|
||||
|
||||
@@ -450,7 +457,7 @@ slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string
|
||||
};
|
||||
|
||||
|
||||
int energyConversion::writeSettingsFile(string fname, detectorType myDetectorType, sls_detector_module mod, int* iodelay){
|
||||
int energyConversion::writeSettingsFile(string fname, detectorType myDetectorType, sls_detector_module mod, int iodelay, int tau){
|
||||
|
||||
ofstream outfile;
|
||||
|
||||
@@ -526,17 +533,19 @@ int energyConversion::writeSettingsFile(string fname, detectorType myDetectorTyp
|
||||
#ifdef VERBOSE
|
||||
for(int i=0;i<mod.ndac;i++)
|
||||
std::cout << "dac " << i << ":" << mod.dacs[i] << std::endl;
|
||||
std::cout << "iodelay: " << *iodelay << std::endl;
|
||||
std::cout << "iodelay: " << iodelay << std::endl;
|
||||
std::cout << "tau: " << tau << std::endl;
|
||||
#endif
|
||||
outfile.write((char*)mod.dacs, sizeof(dacs_t)*(mod.ndac));
|
||||
outfile.write((char*)iodelay, sizeof(*iodelay));
|
||||
outfile.write(reinterpret_cast<char*>(&iodelay), sizeof(iodelay));
|
||||
outfile.write(reinterpret_cast<char*>(&tau), sizeof(tau));
|
||||
outfile.write((char*)mod.chanregs, sizeof(int)*(mod.nchan));
|
||||
|
||||
outfile.close();
|
||||
return slsDetectorDefs::OK;
|
||||
}
|
||||
|
||||
std::cout<< "could not open SETTINGS file " << fname << std::endl;
|
||||
printf("Could not open Settings file %s\n", fname.c_str());
|
||||
return slsDetectorDefs::FAIL;
|
||||
default:
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
//#include "sls_receiver_defs.h"
|
||||
#include "sls_detector_defs.h"
|
||||
//#endif
|
||||
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
@@ -35,7 +35,9 @@ class energyConversion
|
||||
reads a calibration file
|
||||
\param fname file to be read
|
||||
\param gain reference to the gain variable
|
||||
\offset reference to the offset variable
|
||||
\param offset reference to the offset variable
|
||||
\returns OK if successful, else FAIL or -1
|
||||
|
||||
*/
|
||||
static int readCalibrationFile(string fname, double &gain, double &offset);
|
||||
|
||||
@@ -44,36 +46,51 @@ class energyConversion
|
||||
\param fname file to be written
|
||||
\param gain
|
||||
\param offset
|
||||
\returns OK if successful, else FAIL or -1
|
||||
*/
|
||||
static int writeCalibrationFile(string fname, double gain, double offset);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
reads a calibration file
|
||||
\param fname file to be read
|
||||
\param gain reference to the gain variable
|
||||
\offset reference to the offset variable
|
||||
\tau tau
|
||||
\tau tau
|
||||
\param offset reference to the offset variable
|
||||
\returns OK if successful, else FAIL or -1
|
||||
*/
|
||||
static int readCalibrationFile(string fname, int *gain, int *offset, int64_t &tau, detectorType myDetectorType);
|
||||
static int readCalibrationFile(string fname, int *gain, int *offset);
|
||||
|
||||
/**
|
||||
writes a calibration file
|
||||
\param fname file to be written
|
||||
\param gain
|
||||
\param offset
|
||||
\param tau
|
||||
\param gain reference to the gain variable
|
||||
\param offset reference to the offset variable
|
||||
\returns OK if successful, else FAIL or -1
|
||||
*/
|
||||
static int writeCalibrationFile(string fname, int *gain, int *offset, int64_t tau, detectorType myDetectorType);
|
||||
|
||||
static int writeCalibrationFile(string fname, int *gain, int *offset);
|
||||
|
||||
|
||||
|
||||
//Template function to do linear interpolation between two points
|
||||
template <typename E, typename V>
|
||||
V linearInterpolation(const E x, const E x1, const E x2, const V y1, const V y2){
|
||||
double k = static_cast<double>(y2-y1)/(x2-x1);
|
||||
double m = y1-k*x1;
|
||||
int y = round( k*x+m );
|
||||
return static_cast<V>(y);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* interpolates dacs and trimbits between 2 trim files
|
||||
\param myDetectorType detector type (needed for which dacs that neeeds to be interpolated & which kept same)
|
||||
\param a first module structure
|
||||
\param b second module structure
|
||||
\param energy energy to trim at
|
||||
\param e1 reference trim value
|
||||
\param e2 reference trim value
|
||||
\returns the pointer to the module structure with interpolated values or NULL if error
|
||||
*/
|
||||
sls_detector_module* interpolateTrim(detectorType myDetectorType, sls_detector_module* a, sls_detector_module* b, const int energy, const int e1, const int e2);
|
||||
|
||||
|
||||
|
||||
@@ -83,12 +100,13 @@ class energyConversion
|
||||
reads a trim/settings file
|
||||
\param fname name of the file to be read
|
||||
\param myDetectorType detector type (needed for number of channels, chips, dacs etc.)
|
||||
\param myMod pointer to the module structure which has to be set. <BR> If it is NULL a new module structure will be created
|
||||
\param iodelay io delay (detector specific)
|
||||
\param tau tau (detector specific)
|
||||
\param myMod pointer to the module structure which has to be set. <BR> If it is NULL a new module structure will be created
|
||||
\returns the pointer to myMod or NULL if reading the file failed
|
||||
*/
|
||||
|
||||
sls_detector_module* readSettingsFile(string fname, detectorType myDetectorType, sls_detector_module* myMod=NULL, int* iodelay=0);
|
||||
sls_detector_module* readSettingsFile(string fname, detectorType myDetectorType, int& iodelay, int& tau, sls_detector_module* myMod=NULL);
|
||||
|
||||
/**
|
||||
writes a trim/settings file
|
||||
@@ -96,11 +114,12 @@ class energyConversion
|
||||
\param myDetectorType detector type (needed for number of channels, chips, dacs etc.)
|
||||
\param mod module structure which has to be written to file
|
||||
\param iodelay io delay (detector specific)
|
||||
\param tau tau (detector specific)
|
||||
\returns OK or FAIL if the file could not be written
|
||||
|
||||
\sa ::sls_detector_module mythenDetector::writeSettingsFile(string, sls_detector_module)
|
||||
*/
|
||||
int writeSettingsFile(string fname, detectorType myDetectorType, sls_detector_module mod, int* iodelay=0);
|
||||
int writeSettingsFile(string fname, detectorType myDetectorType, sls_detector_module mod, int iodelay, int tau);
|
||||
|
||||
/** allocates the momery for a detector module structure
|
||||
\param myDetectorType detector type (needed for number of channels, chips, dacs etc.)
|
||||
@@ -114,6 +133,7 @@ class energyConversion
|
||||
*/
|
||||
virtual void deleteModule(sls_detector_module *myMod)=0;
|
||||
|
||||
|
||||
protected:
|
||||
/** pointer to settings file name */
|
||||
char *settingsFile;
|
||||
|
||||
@@ -92,6 +92,15 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
|
||||
*/
|
||||
virtual int setDetectorIndex(int i) {detIndex=i;return detIndex;};
|
||||
|
||||
/**
|
||||
sets the default file format
|
||||
\param i file format to be set
|
||||
\returns actual file frame format
|
||||
*/
|
||||
virtual fileFormat setFileFormat(int i) {*fileFormatType=(fileFormat)i; return *fileFormatType;};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\returns the output files path
|
||||
|
||||
@@ -127,6 +136,11 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
|
||||
*/
|
||||
virtual int getFramesPerFile() {return *framesPerFile;};
|
||||
|
||||
/**
|
||||
\returns the max frames per file
|
||||
*/
|
||||
virtual fileFormat getFileFormat() {return *fileFormatType;};
|
||||
|
||||
|
||||
string createFileName();
|
||||
|
||||
@@ -306,8 +320,8 @@ yes */
|
||||
int detIndex;
|
||||
/** frames per file */
|
||||
int *framesPerFile;
|
||||
|
||||
// int *fileFormat;
|
||||
/** file format */
|
||||
fileFormat *fileFormatType;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -534,9 +534,7 @@ class fileIOStatic {
|
||||
static int readDataFile(int nch, string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f') { \
|
||||
ifstream infile; \
|
||||
int iline=0; \
|
||||
int maxchans; \
|
||||
string str; \
|
||||
maxchans=nch; \
|
||||
infile.open(fname.c_str(), ios_base::in); \
|
||||
if (infile.is_open()) { \
|
||||
iline=readDataFile(nch, infile, data, err, ang, dataformat, 0); \
|
||||
|
||||
@@ -38,7 +38,7 @@ int postProcessing::kbhit(){
|
||||
}
|
||||
|
||||
|
||||
postProcessing::postProcessing(): expTime(NULL), ang(NULL), val(NULL), err(NULL), numberOfChannels(0), badChannelMask(NULL){
|
||||
postProcessing::postProcessing(): expTime(NULL), badChannelMask(NULL), ang(NULL), val(NULL), err(NULL), numberOfChannels(0) {
|
||||
pthread_mutex_t mp1 = PTHREAD_MUTEX_INITIALIZER;
|
||||
mp=mp1;
|
||||
pthread_mutex_init(&mp, NULL);
|
||||
@@ -433,10 +433,9 @@ void* postProcessing::processData(int delflag) {
|
||||
|
||||
|
||||
int *myData;
|
||||
char *p;
|
||||
int dum=1;
|
||||
int nf=1, ii, nch;
|
||||
int jctb=0;
|
||||
// int nf=1, ii, nch;
|
||||
// int jctb=0;
|
||||
|
||||
|
||||
// if (getDetectorsType()==JUNGFRAUCTB) {
|
||||
@@ -467,7 +466,7 @@ void* postProcessing::processData(int delflag) {
|
||||
|
||||
|
||||
// if (jctb) {
|
||||
// p=(char*)myData;
|
||||
// char* p=(char*)myData;
|
||||
// for (ii=0; ii<nf; ii++) {
|
||||
// processFrame((int*)p,delflag, 1);
|
||||
// p+=2*nch;
|
||||
@@ -779,6 +778,14 @@ void postProcessing::initDataset(int r) {
|
||||
cout << "done" << endl;
|
||||
#endif
|
||||
|
||||
delete [] chPM;
|
||||
delete [] mM;
|
||||
if (ffcoeff != NULL) delete [] ffcoeff;
|
||||
if (fferr != NULL) delete [] fferr;
|
||||
if (angRad != NULL) delete [] angRad;
|
||||
if (angOff != NULL) delete [] angOff;
|
||||
if (angCenter != NULL) delete [] angCenter;
|
||||
|
||||
|
||||
if (*correctionMask&(1<< ANGULAR_CONVERSION)) {
|
||||
arraySize=getNumberOfAngularBins();
|
||||
@@ -891,6 +898,9 @@ void postProcessing::startThread(int delflag) {
|
||||
else
|
||||
ret = pthread_create(&dataProcessingThread, &tattr,startProcessDataNoDelete, (void*)this);
|
||||
|
||||
if (ret)
|
||||
printf("ret %d\n", ret);
|
||||
|
||||
pthread_attr_destroy(&tattr);
|
||||
|
||||
// scheduling parameters of target thread
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
#define BUF_SIZE (16*1024*1024) //16mb
|
||||
#define FILE_BUF_SIZE (16*1024*1024) //16mb
|
||||
#define HEADER_SIZE_NUM_FRAMES 2
|
||||
#define HEADER_SIZE_NUM_PACKETS 1
|
||||
|
||||
@@ -206,7 +206,7 @@ int singlePhotonFilter::initTree(){
|
||||
closeFile();
|
||||
sprintf(savefilename, "%s/%s_f%012d_%d.raw", filePath,fileName,nTotalHits,fileIndex);
|
||||
myFile = fopen(savefilename, "w");
|
||||
setvbuf(myFile,NULL,_IOFBF,BUF_SIZE);
|
||||
setvbuf(myFile,NULL,_IOFBF,FILE_BUF_SIZE);
|
||||
cout<<"File created: "<<savefilename<<endl;
|
||||
nHitsPerFile = 0;
|
||||
#endif
|
||||
|
||||
@@ -13,7 +13,7 @@ INCLUDES?= -I../commonFiles -I../slsDetector -I ../MySocketTCP -I../usersFuncti
|
||||
LIBDIR?=../
|
||||
LIBS?= -L$(LIBDIR) -lSlsDetector
|
||||
|
||||
LDFLAG= -L/usr/lib64/ -lpthread
|
||||
LDFLAG= -L/usr/lib64/ -pthread
|
||||
|
||||
|
||||
DESTDIR ?= bin
|
||||
|
||||
@@ -2,7 +2,7 @@ CFLAGS= -DC_ONLY
|
||||
FLAGS=-DVERBOSE
|
||||
INCLUDES= -I../slsDetectorSoftware/commonFiles -I../slsDetectorSoftware/slsDetector -I ../slsDetectorSoftware/MySocketTCP -I../slsDetectorSoftware/usersFunctions -I../slsDetectorSoftware/multiSlsDetector -I../slsDetectorSoftware/slsDetectorAnalysis
|
||||
LIBS= -L../slsDetectorSoftware/
|
||||
LDFLAG= -lSlsDetector -lpthread
|
||||
LDFLAG= -lSlsDetector -pthread
|
||||
|
||||
EPICSFLAGS=-DEPICS -I/usr/local/epics/base/include/ -I /usr/local/epics/base/include/os/Linux/ -L /usr/local/epics/base/lib/SL5-x86/ -Wl,-R/usr/local/epics/base/lib/SL5-x86 -lca -lCom
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "slsDetectorServer_defs.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h> //FILE
|
||||
|
||||
|
||||
|
||||
@@ -18,33 +19,176 @@ Here are the definitions, but the actual implementation should be done for each
|
||||
****************************************************/
|
||||
|
||||
|
||||
|
||||
void getModuleConfiguration();
|
||||
int initDetector();
|
||||
int initDetectorStop();
|
||||
|
||||
int setNMod(int nm, enum dimension dim);
|
||||
int getNModBoard(enum dimension arg);
|
||||
|
||||
int64_t getModuleId(enum idMode arg, int imod);
|
||||
int64_t getDetectorId(enum idMode arg);
|
||||
int getDetectorNumber();
|
||||
u_int64_t getDetectorMAC();
|
||||
int getDetectorIP();
|
||||
|
||||
int moduleTest( enum digitalTestMode arg, int imod);
|
||||
int detectorTest( enum digitalTestMode arg);
|
||||
|
||||
|
||||
void setDAC(enum detDacIndex ind, int val, int imod, int mV, int retval[]);
|
||||
int getADC(enum detAdcIndex ind, int imod);
|
||||
|
||||
|
||||
#if defined(EIGERD) || defined(GOTTHARD)
|
||||
int setHighVoltage(int val, int imod);
|
||||
// basic tests
|
||||
void checkFirmwareCompatibility();
|
||||
#ifdef JUNGFRAUD
|
||||
int checkType();
|
||||
u_int32_t testFpga(void);
|
||||
int testBus(void);
|
||||
#endif
|
||||
|
||||
#if defined(MYTHEND) || defined(JUNGFRAUD)
|
||||
int moduleTest( enum digitalTestMode arg, int imod);
|
||||
int detectorTest( enum digitalTestMode arg);
|
||||
#endif
|
||||
|
||||
// Ids
|
||||
int64_t getDetectorId(enum idMode arg);
|
||||
u_int64_t getFirmwareVersion();
|
||||
#ifdef MYTHEND
|
||||
int64_t getModuleId(enum idMode arg, int imod);
|
||||
#elif JUNGFRAUD
|
||||
u_int16_t getHardwareVersionNumber();
|
||||
u_int16_t getHardwareSerialNumber();
|
||||
#endif
|
||||
u_int32_t getDetectorNumber();
|
||||
u_int64_t getDetectorMAC();
|
||||
u_int32_t getDetectorIP();
|
||||
|
||||
|
||||
// initialization
|
||||
void initControlServer();
|
||||
void initStopServer();
|
||||
#ifdef EIGERD
|
||||
void getModuleConfiguration();
|
||||
#endif
|
||||
#ifdef JUNGFRAUD
|
||||
int mapCSP0(void);
|
||||
void bus_w16(u_int32_t offset, u_int16_t data);
|
||||
u_int16_t bus_r16(u_int32_t offset);
|
||||
void bus_w(u_int32_t offset, u_int32_t data);
|
||||
u_int32_t bus_r(u_int32_t offset);
|
||||
int64_t set64BitReg(int64_t value, int aLSB, int aMSB);
|
||||
int64_t get64BitReg(int aLSB, int aMSB);
|
||||
void defineGPIOpins();
|
||||
void resetFPGA();
|
||||
void FPGAdontTouchFlash();
|
||||
void FPGATouchFlash();
|
||||
#endif
|
||||
|
||||
// set up detector
|
||||
void allocateDetectorStructureMemory();
|
||||
void setupDetector();
|
||||
|
||||
|
||||
// advanced read/write reg
|
||||
#ifndef EIGERD
|
||||
u_int32_t writeRegister(u_int32_t offset, u_int32_t data);
|
||||
u_int32_t readRegister(u_int32_t offset);
|
||||
#endif
|
||||
|
||||
|
||||
// firmware functions (resets)
|
||||
#ifdef JUNGFRAUD
|
||||
int powerChip (int on);
|
||||
void cleanFifos();
|
||||
void resetCore();
|
||||
void resetPeripheral();
|
||||
int adcPhase(int st);
|
||||
int getPhase();
|
||||
#endif
|
||||
|
||||
// parameters - nmod, dr, roi
|
||||
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 setDynamicRange(int dr);
|
||||
#ifdef GOTTHARD
|
||||
int setROI(int n, ROI arg[], int *retvalsize, int *ret);
|
||||
#endif
|
||||
|
||||
// parameters - readout
|
||||
int setSpeed(enum speedVariable arg, int val);
|
||||
#if defined(EIGERD) || defined(MYTHEND)
|
||||
enum readOutFlags setReadOutFlags(enum readOutFlags val);
|
||||
#endif
|
||||
#ifdef MYTHEND
|
||||
int executeTrimming(enum trimMode mode, int par1, int par2, int imod);
|
||||
#endif
|
||||
|
||||
// parameters - timer
|
||||
int64_t setTimer(enum timerIndex ind, int64_t val);
|
||||
#ifndef EIGERD
|
||||
int64_t getTimeLeft(enum timerIndex ind);
|
||||
#endif
|
||||
|
||||
|
||||
// parameters - channel, chip, module, settings
|
||||
#ifdef MYTHEND
|
||||
int setChannel(sls_detector_channel myChan);
|
||||
int getChannel(sls_detector_channel *myChan);
|
||||
int setChip(sls_detector_chip myChip);
|
||||
int getChip(sls_detector_chip *myChip);
|
||||
#endif
|
||||
#ifdef EIGERD
|
||||
int setModule(sls_detector_module myMod, int delay);
|
||||
#else
|
||||
int setModule(sls_detector_module myMod);
|
||||
#endif
|
||||
int getModule(sls_detector_module *myMod);
|
||||
enum detectorSettings setSettings(enum detectorSettings sett, int imod);
|
||||
enum detectorSettings getSettings();
|
||||
|
||||
|
||||
// parameters - threshold
|
||||
#if defined(MYTHEND) || defined(EIGERD)
|
||||
int getThresholdEnergy(int imod);
|
||||
int setThresholdEnergy(int ev, int imod);
|
||||
#endif
|
||||
|
||||
// parameters - dac, adc, hv
|
||||
#ifdef JUNGFRAUD
|
||||
void serializeToSPI(u_int32_t addr, u_int32_t val, u_int16_t csmask, int numbitstosend, u_int16_t clkmask, u_int16_t digoutmask, int digofset);
|
||||
void initDac(int dacnum);
|
||||
void prepareADC();
|
||||
void setAdc(int addr, int val);
|
||||
int voltageToDac(int value);
|
||||
int dacToVoltage(unsigned int digital);
|
||||
#endif
|
||||
void setDAC(enum DACINDEX ind, int val, int imod, int mV, int retval[]);
|
||||
int getADC(enum ADCINDEX ind, int imod);
|
||||
#ifndef MYTHEND
|
||||
int setHighVoltage(int val);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// parameters - timing, extsig
|
||||
#ifdef MYTHEND
|
||||
enum externalSignalFlag getExtSignal(int signalindex);
|
||||
enum externalSignalFlag setExtSignal(int signalindex, enum externalSignalFlag flag);
|
||||
#endif
|
||||
enum externalCommunicationMode setTiming( enum externalCommunicationMode arg);
|
||||
|
||||
// configure mac
|
||||
#ifdef JUNGFRAUD
|
||||
long int calcChecksum(int sourceip, int destip);
|
||||
#endif
|
||||
#ifndef MYTHEND
|
||||
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2, int ival);
|
||||
#endif
|
||||
|
||||
|
||||
// very detector specific
|
||||
|
||||
// gotthard specific - image, pedestal
|
||||
#ifdef GOTTHARDD
|
||||
int loadImage(enum imageType index, char *imageVals);
|
||||
int readCounterBlock(int startACQ, char *counterVals);
|
||||
int resetCounterBlock(int startACQ);
|
||||
int calibratePedestal(int frames);
|
||||
|
||||
// jungfrau specific - pll, flashing firmware
|
||||
#elif JUNGFRAUD
|
||||
void resetPLL();
|
||||
u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val);
|
||||
void configurePll();
|
||||
void eraseFlash();
|
||||
int startWritingFPGAprogram(FILE** filefp);
|
||||
int stopWritingFPGAprogram(FILE* filefp);
|
||||
int writeFPGAProgram(char* fpgasrc, size_t fsize, FILE* filefp);
|
||||
|
||||
// eiger specific - iodelay, 10g, pulse, rate, temp, activate, delay nw parameter
|
||||
#elif EIGERD
|
||||
int setIODelay(int val, int imod);
|
||||
int enableTenGigabitEthernet(int val);
|
||||
int setCounterBit(int val);
|
||||
@@ -56,82 +200,39 @@ int getRateCorrectionEnable();
|
||||
int getDefaultSettingsTau_in_nsec();
|
||||
void setDefaultSettingsTau_in_nsec(int t);
|
||||
int64_t getCurrentTau();
|
||||
#endif
|
||||
|
||||
#if defined(MYTHEND) || defined(GOTTHARDD)
|
||||
u_int32_t writeRegister(u_int32_t offset, u_int32_t data);
|
||||
u_int32_t readRegister(u_int32_t offset);
|
||||
#endif
|
||||
|
||||
#ifdef MYTHEND
|
||||
int setChannel(sls_detector_channel myChan);
|
||||
int getChannel(sls_detector_channel *myChan);
|
||||
int setChip(sls_detector_chip myChip);
|
||||
int getChip(sls_detector_chip *myChip);
|
||||
void setExternalGating(int enable[]);
|
||||
int setAllTrimbits(int val);
|
||||
int getAllTrimbits();
|
||||
int getBebFPGATemp();
|
||||
int activate(int enable);
|
||||
int setNetworkParameter(enum NETWORKINDEX mode, int value);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef EIGERD
|
||||
int setModule(sls_detector_module myMod, int* gain, int* offset,int* delay);
|
||||
int getModule(sls_detector_module *myMod, int* gain, int* offset);
|
||||
#else
|
||||
int setModule(sls_detector_module myMod);
|
||||
int getModule(sls_detector_module *myMod);
|
||||
|
||||
|
||||
// aquisition
|
||||
#if defined(EIGERD) || defined(GOTTHARD)
|
||||
int prepareAcquisition();
|
||||
#endif
|
||||
|
||||
|
||||
enum detectorSettings setSettings(enum detectorSettings sett, int imod);
|
||||
enum detectorSettings getSettings();
|
||||
|
||||
#if defined(MYTHEND) || defined(EIGERD)
|
||||
int getThresholdEnergy(int imod);
|
||||
int setThresholdEnergy(int ev, int imod);
|
||||
#endif
|
||||
|
||||
int startStateMachine();
|
||||
int stopStateMachine();
|
||||
#ifndef JUNGFRAUD
|
||||
int startReadOut();
|
||||
#endif
|
||||
enum runStatus getRunStatus();
|
||||
void readFrame(int *ret, char *mess);
|
||||
|
||||
|
||||
int64_t setTimer(enum timerIndex ind, int64_t val);
|
||||
int64_t getTimeLeft(enum timerIndex ind);
|
||||
|
||||
|
||||
int setDynamicRange(int dr);
|
||||
int setROI(int n, ROI arg[], int *retvalsize, int *ret);
|
||||
|
||||
|
||||
#if defined(EIGERD) || defined(MYTHEND)
|
||||
enum readOutFlags setReadOutFlags(enum readOutFlags val);
|
||||
int setSpeed(enum speedVariable arg, int val);
|
||||
int executeTrimming(enum trimMode mode, int par1, int par2, int imod);
|
||||
#ifdef JUNGFRAUD
|
||||
u_int32_t runBusy(void);
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef MYTHEND
|
||||
int configureMAC(int ipad, long long int macad, long long int detectormacadd, int detipad, int udpport, int udpport2, int ival);
|
||||
#endif
|
||||
|
||||
#ifdef GOTTHARDD
|
||||
int loadImage(enum imageType index, char *imageVals);
|
||||
int readCounterBlock(int startACQ, char *counterVals);
|
||||
int resetCounterBlock(int startACQ);
|
||||
int startReceiver(int d);
|
||||
int calibratePedestal(int frames);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
//common
|
||||
int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod);
|
||||
|
||||
int calculateDataBytes();
|
||||
int getTotalNumberOfChannels();
|
||||
int getTotalNumberOfChips();
|
||||
int getTotalNumberOfModules();
|
||||
int getNumberOfChannelsPerChip();
|
||||
int getNumberOfChannelsPerModule();
|
||||
int getNumberOfChipsPerModule();
|
||||
int getNumberOfDACsPerModule();
|
||||
@@ -140,26 +241,13 @@ int getNumberOfADCsPerModule();
|
||||
int getNumberOfGainsPerModule();
|
||||
int getNumberOfOffsetsPerModule();
|
||||
#endif
|
||||
int getNumberOfChannelsPerChip();
|
||||
|
||||
enum externalSignalFlag getExtSignal(int signalindex);
|
||||
enum externalSignalFlag setExtSignal(int signalindex, enum externalSignalFlag flag);
|
||||
enum externalCommunicationMode setTiming( enum externalCommunicationMode arg);
|
||||
// sync
|
||||
enum masterFlags setMaster(enum masterFlags arg);
|
||||
enum synchronizationMode setSynchronization(enum synchronizationMode arg);
|
||||
|
||||
#ifdef EIGERD
|
||||
int startReceiver(int d);
|
||||
void setExternalGating(int enable[]);
|
||||
void setAllTrimbits(int val);
|
||||
int getAllTrimbits();
|
||||
int getBebFPGATemp();
|
||||
int activate(int enable);
|
||||
int setNetworkParameter(enum detNetworkParameter mode, int value);
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
|
||||
|
||||
extern int sockfd;
|
||||
@@ -23,16 +24,23 @@ int main(int argc, char *argv[]){
|
||||
int retval=OK;
|
||||
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
|
||||
char cmd[100];
|
||||
#endif
|
||||
if (argc==1) {
|
||||
|
||||
checkFirmwareCompatibility();
|
||||
//#endif
|
||||
portno = DEFAULT_PORTNO;
|
||||
printf("opening control server on port %d\n",portno );
|
||||
cprintf(BLUE,
|
||||
"********************************************************\n"
|
||||
"********* opening control server on port %d **********\n"
|
||||
"********************************************************\n\n"
|
||||
, portno);
|
||||
b=1;
|
||||
basictests();
|
||||
#ifdef STOP_SERVER
|
||||
sprintf(cmd,"%s %d &",argv[0],DEFAULT_PORTNO+1);
|
||||
system(cmd);
|
||||
@@ -43,18 +51,18 @@ int main(int argc, char *argv[]){
|
||||
printf("could not open stop server: unknown port\n");
|
||||
return 1;
|
||||
}
|
||||
printf("opening stop server on port %d\n",portno);
|
||||
cprintf(BLUE,
|
||||
"********************************************************\n"
|
||||
"*********** opening stop server on port %d ***********\n"
|
||||
"********************************************************\n\n"
|
||||
, portno);
|
||||
b=0;
|
||||
}
|
||||
//#endif
|
||||
|
||||
|
||||
init_detector(b); //defined in slsDetectorServer_funcs
|
||||
|
||||
sd=bindSocket(portno); //defined in communication_funcs
|
||||
|
||||
sockfd=sd;
|
||||
|
||||
if (getServerError(sd)) { //defined in communication_funcs
|
||||
printf("server error!\n");
|
||||
return -1;
|
||||
|
||||
@@ -11,27 +11,21 @@
|
||||
#include "sls_detector_defs.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#define GOODBYE -200
|
||||
/** This is only an example file!!! */
|
||||
|
||||
/*
|
||||
#define GOODBYE (-200)
|
||||
enum DAC_INDEX {examplesdac}
|
||||
|
||||
/* examples*/
|
||||
#ifdef JUNGFRAU_DHANYA
|
||||
Hardware Definitions
|
||||
#define NMAXMOD (1)
|
||||
#define NMOD (1)
|
||||
#define NCHAN (256 * 256)
|
||||
#define NCHIP 8
|
||||
#define NADC 0
|
||||
#else
|
||||
#define NCHAN 1
|
||||
#define NCHIP 1
|
||||
#define NDAC 1
|
||||
#define NADC 1
|
||||
#endif
|
||||
|
||||
#define NMAXMODX 1
|
||||
#define NMAXMODY 1
|
||||
#define NMAXMOD NMAXMODX*NMAXMODY
|
||||
#define NCHANS NCHAN*NCHIP*NMAXMOD
|
||||
#define NDACS NDAC*NMAXMOD
|
||||
|
||||
|
||||
#define NCHIP (4)
|
||||
#define NADC (0)
|
||||
#define NDAC (16)
|
||||
#define NGAIN (0)
|
||||
#define NOFFSET (0)
|
||||
*/
|
||||
|
||||
#endif /* SLSDETECTORSERVER_DEFS_H_ */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,37 +1,21 @@
|
||||
#ifndef SERVER_FUNCS_H
|
||||
#define SERVER_FUNCS_H
|
||||
|
||||
#include "sls_detector_defs.h"
|
||||
#include "slsDetectorServer_defs.h"
|
||||
|
||||
#include "sls_receiver_defs.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//basic server functions
|
||||
void checkFirmwareCompatibility();
|
||||
int init_detector(int);
|
||||
// initialization functions
|
||||
int printSocketReadError();
|
||||
void basictests();
|
||||
void init_detector(int);
|
||||
int decode_function(int);
|
||||
int function_table();
|
||||
//int swap_int32(int val);
|
||||
//int64_t swap_int64(int64_t val);
|
||||
const char* getFunctionName(enum detFuncs func);
|
||||
void function_table();
|
||||
int M_nofunc(int);
|
||||
int exit_server(int);
|
||||
|
||||
// functions called by client
|
||||
int exec_command(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_error(int);
|
||||
int get_detector_type(int);
|
||||
int set_number_of_modules(int);
|
||||
int get_max_number_of_modules(int);
|
||||
@@ -39,24 +23,24 @@ int set_external_signal_flag(int);
|
||||
int set_external_communication_mode(int);
|
||||
int get_id(int);
|
||||
int digital_test(int);
|
||||
//F_ANALOG_TEST
|
||||
//F_ENABLE_ANALOG_OUT
|
||||
//F_CALIBRATION_PULSE
|
||||
int analog_test(int);
|
||||
int enable_analog_out(int);
|
||||
int calibration_pulse(int);
|
||||
int set_dac(int);
|
||||
int get_adc(int);
|
||||
int write_register(int);
|
||||
int read_register(int);
|
||||
//F_WRITE_MEMORY
|
||||
//F_READ_MEMORY
|
||||
int write_memory(int);
|
||||
int read_memory(int);
|
||||
int set_channel(int);
|
||||
int get_channel(int);
|
||||
//F_SET_ALL_CHANNELS
|
||||
int set_all_channels(int);
|
||||
int set_chip(int);
|
||||
int get_chip(int);
|
||||
//F_SET_ALL_CHIPS
|
||||
int set_all_chips(int);
|
||||
int set_module(int);
|
||||
int get_module(int);
|
||||
//F_SET_ALL_MODULES
|
||||
int set_all_modules(int);
|
||||
int set_settings(int);
|
||||
int get_threshold_energy(int);
|
||||
int set_threshold_energy(int);
|
||||
@@ -74,22 +58,36 @@ int set_readout_flags(int);
|
||||
int set_roi(int);
|
||||
int set_speed(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 load_image(int);
|
||||
int set_master(int);
|
||||
int set_synchronization(int);
|
||||
int read_counter_block(int);
|
||||
int reset_counter_block(int);
|
||||
int start_receiver(int);
|
||||
int stop_receiver(int);
|
||||
int calibrate_pedestal(int);
|
||||
int enable_ten_giga(int);
|
||||
int set_all_trimbits(int);
|
||||
int set_ctb_pattern(int);
|
||||
int write_adc_register(int);
|
||||
int set_counter_bit(int);
|
||||
int pulse_pixel(int);
|
||||
int pulse_pixel_and_move(int);
|
||||
int pulse_chip(int);
|
||||
int set_rate_correct(int);
|
||||
int get_rate_correct(int);
|
||||
int set_activate(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);
|
||||
int cleanup_acquisition(int);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,20 +2,20 @@ OBJPATH=bin/obj
|
||||
EXAMPLEPATH=bin/example
|
||||
|
||||
all:
|
||||
g++ CondVar.cpp -lpthread -c -g -o $(OBJPATH)/CondVar.o
|
||||
g++ Mutex.cpp -lpthread -c -g -o $(OBJPATH)/Mutex.o
|
||||
#g++ Task.cpp -lpthread -c -g -o $(OBJPATH)/Task.o
|
||||
g++ ThreadPool.cpp -lpthread -c -g -o $(OBJPATH)/ThreadPool.o
|
||||
g++ Multi.cpp -lpthread -c -g -o $(OBJPATH)/Multi.o
|
||||
#g++ $(OBJPATH)/CondVar.o $(OBJPATH)/Mutex.o $(OBJPATH)/Task.o $(OBJPATH)/ThreadPool.o threadpool_test.cpp Single.cpp Multi.cpp -lpthread -I . -g -o $(EXAMPLEPATH)threadpool_test
|
||||
g++ $(OBJPATH)/CondVar.o $(OBJPATH)/Mutex.o $(OBJPATH)/ThreadPool.o threadpool_test.cpp Single.cpp Multi.cpp -lpthread -I . -g -o $(EXAMPLEPATH)threadpool_test
|
||||
g++ CondVar.cpp -pthread -c -g -o $(OBJPATH)/CondVar.o
|
||||
g++ Mutex.cpp -pthread -c -g -o $(OBJPATH)/Mutex.o
|
||||
#g++ Task.cpp -pthread -c -g -o $(OBJPATH)/Task.o
|
||||
g++ ThreadPool.cpp -pthread -c -g -o $(OBJPATH)/ThreadPool.o
|
||||
g++ Multi.cpp -pthread -c -g -o $(OBJPATH)/Multi.o
|
||||
#g++ $(OBJPATH)/CondVar.o $(OBJPATH)/Mutex.o $(OBJPATH)/Task.o $(OBJPATH)/ThreadPool.o threadpool_test.cpp Single.cpp Multi.cpp -pthread -I . -g -o $(EXAMPLEPATH)threadpool_test
|
||||
g++ $(OBJPATH)/CondVar.o $(OBJPATH)/Mutex.o $(OBJPATH)/ThreadPool.o threadpool_test.cpp Single.cpp Multi.cpp -pthread -I . -g -o $(EXAMPLEPATH)threadpool_test
|
||||
|
||||
#all:
|
||||
# g++ threadpool.cpp -lpthread -fpic -c -o bin/obj/threadpool.o
|
||||
# g++ -L./bin bin/obj/threadpool.o -lpthread threadpool_test.cpp -o bin/example/threadpool_test
|
||||
# g++ threadpool.cpp -pthread -fpic -c -o bin/obj/threadpool.o
|
||||
# g++ -L./bin bin/obj/threadpool.o -pthread threadpool_test.cpp -o bin/example/threadpool_test
|
||||
|
||||
#threadpool:
|
||||
# g++ threadpool.cpp -lpthread -fpic -c -o bin/obj/threadpool.o
|
||||
# g++ threadpool.cpp -pthread -fpic -c -o bin/obj/threadpool.o
|
||||
# g++ -shared -fPIC bin/obj/threadpool.o -o bin/lib/libthreadpool.so
|
||||
#example:
|
||||
# g++ -L./bin/lib -lthreadpool threadpool_test.cpp -o threadpool_test
|
||||
|
||||
@@ -24,8 +24,8 @@ public:
|
||||
~func00_t() {}
|
||||
void operator()() const {((m_ptr->*m_fn)());}
|
||||
private:
|
||||
_Class* m_ptr;
|
||||
_Ret (_Class::*m_fn)();
|
||||
_Class* m_ptr;
|
||||
};
|
||||
|
||||
template<typename _Ret, typename _Class, typename _Store>
|
||||
@@ -36,8 +36,8 @@ public:
|
||||
~func0_t() {}
|
||||
void operator()() const {*m_store = ((m_ptr->*m_fn)());}
|
||||
private:
|
||||
_Class* m_ptr;
|
||||
_Ret (_Class::*m_fn)();
|
||||
_Class* m_ptr;
|
||||
_Store* m_store;
|
||||
};
|
||||
|
||||
@@ -49,8 +49,8 @@ public:
|
||||
~func1_t() {}
|
||||
void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1));}
|
||||
private:
|
||||
_Class* m_ptr;
|
||||
_Ret (_Class::*m_fn)(_Arg1);
|
||||
_Class* m_ptr;
|
||||
_Arg1 m_arg1;
|
||||
_Store* m_store;
|
||||
};
|
||||
@@ -63,8 +63,8 @@ public:
|
||||
~func2_t() {}
|
||||
void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1,m_arg2));}
|
||||
private:
|
||||
_Class* m_ptr;
|
||||
_Ret (_Class::*m_fn)(_Arg1,_Arg2);
|
||||
_Class* m_ptr;
|
||||
_Arg1 m_arg1;
|
||||
_Arg2 m_arg2;
|
||||
_Store* m_store;
|
||||
@@ -78,8 +78,8 @@ public:
|
||||
~func3_t() {}
|
||||
void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1,m_arg2,m_arg3));}
|
||||
private:
|
||||
_Class* m_ptr;
|
||||
_Ret (_Class::*m_fn)(_Arg1,_Arg2,_Arg3);
|
||||
_Class* m_ptr;
|
||||
_Arg1 m_arg1;
|
||||
_Arg2 m_arg2;
|
||||
_Arg3 m_arg3;
|
||||
@@ -94,8 +94,8 @@ public:
|
||||
~func4_t() {}
|
||||
void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1,m_arg2,m_arg3,m_arg4));}
|
||||
private:
|
||||
_Class* m_ptr;
|
||||
_Ret (_Class::*m_fn)(_Arg1,_Arg2,_Arg3,_Arg4);
|
||||
_Class* m_ptr;
|
||||
_Arg1 m_arg1;
|
||||
_Arg2 m_arg2;
|
||||
_Arg3 m_arg3;
|
||||
@@ -106,29 +106,31 @@ private:
|
||||
class Task: public virtual slsDetectorDefs{
|
||||
public:
|
||||
/* Return: int, Param: int */
|
||||
Task(func1_t <int,slsDetector,int,int>* t): m1(t),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0){};
|
||||
Task(func1_t <int,slsDetector,int,int>* t): m1(t),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0){};
|
||||
/* Return: int, Param: string,int */
|
||||
Task(func2_t <int,slsDetector,string,int,int>* t): m1(0),m2(t),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0){};
|
||||
Task(func2_t <int,slsDetector,string,int,int>* t): m1(0),m2(t),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0){};
|
||||
/* Return: string, Param: string */
|
||||
Task(func1_t <string,slsDetector,string,string>* t): m1(0),m2(0),m3(t),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0){};
|
||||
Task(func1_t <string,slsDetector,string,string>* t): m1(0),m2(0),m3(t),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0){};
|
||||
/* Return: char*, Param: char* */
|
||||
Task(func1_t <char*,slsDetector,char*,string>* t): m1(0),m2(0),m3(0),m4(t),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0){};
|
||||
Task(func1_t <char*,slsDetector,char*,string>* t): m1(0),m2(0),m3(0),m4(t),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0){};
|
||||
/* Return: detectorSettings, Param: int */
|
||||
Task(func1_t <detectorSettings,slsDetector,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(t),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0){};
|
||||
Task(func1_t <detectorSettings,slsDetector,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(t),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0){};
|
||||
/* Return: detectorSettings, Param: detectorSettings,int */
|
||||
Task(func2_t <detectorSettings,slsDetector,detectorSettings,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(t),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0){};
|
||||
Task(func2_t <detectorSettings,slsDetector,detectorSettings,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(t),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0){};
|
||||
/* Return: int, Param: int,int */
|
||||
Task(func2_t <int,slsDetector,int,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(t),m8(0),m9(0),m10(0),m11(0),m12(0){};
|
||||
/* Return: int, Param: int,int */
|
||||
Task(func3_t <int,slsDetector,int,int,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(t),m9(0),m10(0),m11(0),m12(0){};
|
||||
Task(func2_t <int,slsDetector,int,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(t),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0){};
|
||||
/* Return: int, Param: int,int,int */
|
||||
Task(func3_t <int,slsDetector,int,int,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(t),m9(0),m10(0),m11(0),m12(0),m13(0){};
|
||||
/* Return: int, Param: trimMode,int,int,int */
|
||||
Task(func4_t <int,slsDetector,trimMode,int,int,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(t),m10(0),m11(0),m12(0){};
|
||||
Task(func4_t <int,slsDetector,trimMode,int,int,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(t),m10(0),m11(0),m12(0),m13(0){};
|
||||
/* Return: int, Param: none */
|
||||
Task(func0_t <int,slsDetector,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(t),m11(0),m12(0){};
|
||||
/* Return: char*, Param: networkParameter,string,string */
|
||||
Task(func2_t <char*,slsDetector,networkParameter,string,string>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(t),m12(0){};
|
||||
Task(func0_t <int,slsDetector,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(t),m11(0),m12(0),m13(0){};
|
||||
/* Return: char*, Param: networkParameter,string */
|
||||
Task(func2_t <char*,slsDetector,networkParameter,string,string>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(t),m12(0),m13(0){};
|
||||
/* Return: void, Param: none */
|
||||
Task(func00_t <void,slsDetector>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(t){};
|
||||
Task(func00_t <void,slsDetector>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(t),m13(0){};
|
||||
/* Return: int, Param: int,int,detectorSettings */
|
||||
Task(func3_t <int,slsDetector,int,int,detectorSettings,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(t){};
|
||||
|
||||
|
||||
|
||||
@@ -147,6 +149,7 @@ public:
|
||||
else if(m10) (*m10)();
|
||||
else if(m11) (*m11)();
|
||||
else if(m12) (*m12)();
|
||||
else if(m13) (*m13)();
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -164,16 +167,18 @@ private:
|
||||
func2_t <detectorSettings,slsDetector,detectorSettings,int,int>* m6;
|
||||
/* Return: int, Param: int,int */
|
||||
func2_t <int,slsDetector,int,int,int>* m7;
|
||||
/* Return: int, Param: int,int */
|
||||
/* Return: int, Param: int,int,int */
|
||||
func3_t <int,slsDetector,int,int,int,int>* m8;
|
||||
/* Return: int, Param: trimMode,int,int,int */
|
||||
func4_t <int,slsDetector,trimMode,int,int,int,int>* m9;
|
||||
/* Return: int, Param: int */
|
||||
func0_t <int,slsDetector,int>* m10;
|
||||
/* Return: char*, Param: networkParameter,string,string */
|
||||
/* Return: char*, Param: networkParameter,string */
|
||||
func2_t <char*,slsDetector,networkParameter,string,string>* m11;
|
||||
/* Return: void, Param: none */
|
||||
func00_t <void,slsDetector>* m12;
|
||||
/* Return: int, Param: int,int,detectorSettings */
|
||||
func3_t <int,slsDetector,int,int,detectorSettings,int>* m13;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -67,12 +67,13 @@ int ThreadPool::destroy_threadpool(){
|
||||
/*cout << "Broadcasting STOP signal to all threads..." << endl;*/
|
||||
m_task_cond_var.broadcast(); // notify all threads we are shttung down
|
||||
|
||||
int ret = -1;
|
||||
// int ret = -1;
|
||||
for (int i = 0; i < m_pool_size; i++) {
|
||||
void* result;
|
||||
sem_post(&semStart);
|
||||
sem_post(&semDone);
|
||||
ret = pthread_join(m_threads[i], &result);
|
||||
//ret =
|
||||
pthread_join(m_threads[i], &result);
|
||||
/*cout << "pthread_join() returned " << ret << ": " << strerror(errno) << endl;*/
|
||||
m_task_cond_var.broadcast(); // try waking up a bunch of threads that are still waiting
|
||||
}
|
||||
@@ -85,7 +86,8 @@ int ThreadPool::destroy_threadpool(){
|
||||
}
|
||||
|
||||
void* ThreadPool::execute_thread(){
|
||||
int ithread = current_thread_number;
|
||||
//for debugging seting ithread value
|
||||
// int ithread = current_thread_number;
|
||||
thread_started = true;
|
||||
Task* task = NULL;
|
||||
m_tasks_loaded = false;
|
||||
@@ -125,6 +127,9 @@ void* ThreadPool::execute_thread(){
|
||||
(*task)(); // could also do task->run(arg);
|
||||
/*cout << ithread <<" Done executing thread " << pthread_self() << endl;*/
|
||||
|
||||
delete task;
|
||||
/*cout << ithread << " task deleted" << endl;*/
|
||||
|
||||
m_task_mutex.lock();
|
||||
number_of_ongoing_tasks--;
|
||||
m_task_mutex.unlock();
|
||||
@@ -136,9 +141,10 @@ void* ThreadPool::execute_thread(){
|
||||
m_tasks_loaded = false;
|
||||
}
|
||||
//if(zmqthreadpool) cout<<"***"<<ithread<<" semaphore done address post:"<<&semDone<<endl;
|
||||
|
||||
|
||||
sem_post(&semDone);
|
||||
delete task;
|
||||
/*cout << ithread << " task deleted" << endl;*/
|
||||
//removed deleteing task to earlier
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -38,8 +38,8 @@ private:
|
||||
std::deque<Task*> m_tasks;
|
||||
volatile int m_pool_state;
|
||||
|
||||
bool m_tasks_loaded;
|
||||
bool thread_started;
|
||||
volatile bool m_tasks_loaded;
|
||||
volatile bool thread_started;
|
||||
int current_thread_number;
|
||||
|
||||
//volatile uint64_t tasks_done_mask;
|
||||
|
||||
Reference in New Issue
Block a user