got rid of extra servers for eiger, converted to c and it works

This commit is contained in:
Maliakal Dhanya 2014-08-29 16:41:19 +02:00
parent 10ca7c10e8
commit c5a4f357bf
31 changed files with 662 additions and 720 deletions

View File

@ -8,98 +8,81 @@
#ifndef BEB_H
#define BEB_H
#include <string>
#include <vector>
#include "LocalLinkInterface.h"
class BebInfo{
private:
struct BebInfo{
unsigned int beb_number;
unsigned int serial_address;
std::string src_mac_1GbE;
std::string src_mac_10GbE;
std::string src_ip_1GbE;
std::string src_ip_10GbE;
char src_mac_1GbE[50];
char src_mac_10GbE[50];
char src_ip_1GbE[50];
char src_ip_10GbE[50];
unsigned int src_port_1GbE;
unsigned int src_port_10GbE;
public:
BebInfo(unsigned int beb_num);
~BebInfo(){};
bool SetSerialAddress(unsigned int add);
bool SetHeaderInfo(bool ten_gig, std::string src_mac, std::string src_ip, unsigned int src_port);//src_port fixed 42000+beb_number or 52000 + beb_number);
unsigned int GetBebNumber() {return beb_number;}
unsigned int GetSerialAddress() {return serial_address;}
std::string GetSrcMAC(bool ten_gig) {return ten_gig ? src_mac_10GbE : src_mac_1GbE;}
std::string GetSrcIP(bool ten_gig) {return ten_gig ? src_ip_10GbE : src_ip_1GbE;}
unsigned int GetSrcPort(bool ten_gig) {return ten_gig ? src_port_10GbE : src_port_1GbE;}
void Print();
};
class Beb{ //
private:
std::vector<BebInfo*> beb_infos;
void ClearBebInfos();
bool InitBebInfos();
bool ReadSetUpFromFile(std::string file_name);
bool CheckSourceStuffBebInfo();
unsigned int GetBebInfoIndex(unsigned int beb_numb);
LocalLinkInterface* ll;
LocalLinkInterface* new_memory;
int send_ndata;
unsigned int send_buffer_size;
unsigned int* send_data_raw;
unsigned int* send_data;
int recv_ndata;
unsigned int recv_buffer_size;
unsigned int* recv_data_raw;
unsigned int* recv_data;
bool WriteTo(unsigned int index);
bool SetMAC(std::string mac, unsigned char* dst_ptr);
bool SetIP(std::string ip, unsigned char* dst_ptr);
bool SetPortNumber(unsigned int port_number, unsigned char* dst_ptr);
void AdjustIPChecksum(udp_header_type *ip);
bool SetHeaderData(unsigned int beb_number, bool ten_gig, std::string dst_mac, std::string dst_ip, unsigned int dst_port);
bool SetHeaderData(std::string src_mac, std::string src_ip, unsigned int src_port, std::string dst_mac, std::string dst_ip, unsigned int dst_port);
void SwapDataFun(bool little_endian, unsigned int n, unsigned int *d);
bool SetByteOrder();
short bit_mode;
public:
Beb(int arg1);
virtual ~Beb();
bool SetBebSrcHeaderInfos(unsigned int beb_number, bool ten_gig, std::string src_mac, std::string src_ip, unsigned int src_port);
bool SetUpUDPHeader(unsigned int beb_number, bool ten_gig, unsigned int header_number, std::string dst_mac, std::string dst_ip, unsigned int dst_port);
bool 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);
void BebInfo_BebInfo(struct BebInfo* bebInfo, unsigned int beb_num);
int BebInfo_SetSerialAddress(struct BebInfo* bebInfo, unsigned int add);
int BebInfo_SetHeaderInfo(struct BebInfo* bebInfo, int ten_gig, char* src_mac, char* src_ip, unsigned int src_port);//src_port fixed 42000+beb_number or 52000 + beb_number);
unsigned int BebInfo_GetBebNumber(struct BebInfo* bebInfo);
unsigned int BebInfo_GetSerialAddress(struct BebInfo* bebInfo);
char* BebInfo_GetSrcMAC(struct BebInfo* bebInfo, int ten_gig);
char* BebInfo_GetSrcIP(struct BebInfo* bebInfo, int ten_gig);
unsigned int BebInfo_GetSrcPort(struct BebInfo* bebInfo, int ten_gig);
void BebInfo_Print(struct BebInfo* bebInfo);
bool SetUpTransferParameters(short the_bit_mode);
bool 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=0); //all images go to the same destination!
bool Test(unsigned int beb_number);
};
void Beb_ClearBebInfos();
int Beb_InitBebInfos();
int Beb_ReadSetUpFromFile(char* file_name);
int Beb_CheckSourceStuffBebInfo();
unsigned int Beb_GetBebInfoIndex(unsigned int beb_numb);
int Beb_WriteTo(unsigned int index);
int Beb_SetMAC(char* mac, uint8_t* dst_ptr);
int Beb_SetIP(char* ip, uint8_t* dst_ptr);
int Beb_SetPortNumber(unsigned int port_number, uint8_t* dst_ptr);
void Beb_AdjustIPChecksum(struct udp_header_type *ip);
int Beb_SetHeaderData(unsigned int beb_number, int ten_gig, char* dst_mac, char* dst_ip, unsigned int dst_port);
int Beb_SetHeaderData1(char* src_mac, char* src_ip, unsigned int src_port, char* dst_mac, char* dst_ip, unsigned int dst_port);
void Beb_SwapDataFun(int little_endian, unsigned int n, unsigned int *d);
int Beb_SetByteOrder();
void Beb_Beb(int arg1);
int Beb_SetBebSrcHeaderInfos(unsigned int beb_number, int ten_gig, char* src_mac, char* src_ip, unsigned int src_port);
int Beb_SetUpUDPHeader(unsigned int beb_number, int ten_gig, unsigned int header_number, char* dst_mac, char* dst_ip, unsigned int dst_port);
/*int Beb_SendMultiReadRequest(unsigned int beb_number, unsigned int left_right, int ten_gig, unsigned int dst_number, unsigned int npackets, unsigned int packet_size, int stop_read_when_fifo_empty=1);*/
int Beb_SendMultiReadRequest(unsigned int beb_number, unsigned int left_right, int ten_gig, unsigned int dst_number, unsigned int npackets, unsigned int packet_size, int stop_read_when_fifo_empty);
int Beb_SetUpTransferParameters(short the_bit_mode);
/*int Beb_RequestNImages(unsigned int beb_number, unsigned int left_right, int ten_gig, unsigned int dst_number, unsigned int nimages, int test_just_send_out_packets_no_wait=0); //all images go to the same destination!*/
int Beb_RequestNImages(unsigned int beb_number, unsigned int left_right, int ten_gig, unsigned int dst_number, unsigned int nimages, int test_just_send_out_packets_no_wait);
int Beb_Test(unsigned int beb_number);
#endif

View File

@ -11,11 +11,7 @@
#include "slsDetectorServer_defs.h" //include port number
struct sockaddr_in eiger_socket_addr;
int eiger_max_message_length = 270000;//263681
char eiger_message[270000];//263681
int eiger_message_length = 0;
int eiger_ret_val=0;
int eiger_nexposures = 1;
float eiger_exposuretime = 0;
@ -56,25 +52,7 @@ int EigerGetExternalGatingPolarity(){return eiger_extgatingpolarity;}
int EigerInit(){
saved_trimbits[0] = -1;
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_socket_addr;
int port = FEB_PORT;
bzero((char *) &eiger_socket_addr, sizeof(eiger_socket_addr));
eiger_socket_addr.sin_family = AF_INET;
bcopy((char *)dst_host->h_addr,(char *)&eiger_socket_addr.sin_addr.s_addr,dst_host->h_length);
eiger_socket_addr.sin_port = htons(port);
passed = 1;
}
}
return passed;
}

View File

@ -10,53 +10,50 @@
#include "LocalLinkInterface.h"
class Feb{ //
private:
LocalLinkInterface* ll;
struct LocalLinkInterface* ll;
unsigned int nfebs;
unsigned int* feb_numb;
unsigned int Feb_nfebs;
unsigned int* Feb_feb_numb;
int send_ndata;
unsigned int send_buffer_size;
unsigned int* send_data_raw;
unsigned int* send_data;
int Feb_send_ndata;
unsigned int Feb_send_buffer_size;
unsigned int* Feb_send_data_raw;
unsigned int* Feb_send_data;
int recv_ndata;
unsigned int recv_buffer_size;
unsigned int* recv_data_raw;
unsigned int* recv_data;
int Feb_recv_ndata;
unsigned int Feb_recv_buffer_size;
unsigned int* Feb_recv_data_raw;
unsigned int* Feb_recv_data;
bool WriteTo(unsigned int ch);
bool ReadFrom(unsigned int ch, unsigned int ntrys=20);
bool CheckHeader(unsigned int valid_bit_mask=0xffffffff, bool print_error_info=1);
bool CheckTail(unsigned int valid_bit_mask=0xffffffff);
int Feb_WriteTo(unsigned int ch);
/*int Feb_ReadFrom(unsigned int Feb_ch, unsigned int Feb_ntrys=20);*/
int Feb_ReadFrom(unsigned int ch, unsigned int ntrys);
/* int Feb_CheckHeader(unsigned int Feb_valid_bit_mask=0xffffffff, int Feb_print_error_info=1);*/
int Feb_CheckHeader(unsigned int valid_bit_mask, int print_error_info);
/*int Feb_CheckTail(unsigned int Feb_valid_bit_mask=0xffffffff);*/
int Feb_CheckTail(unsigned int valid_bit_mask);
int Feb_SetByteOrder();
//int Feb_CheckSubNumber(unsigned int Feb_sub_num);
//int Feb_SetStartOnEndOnFebs(int Feb_sub_num_s, unsigned int& Feb_start_on, unsigned int& Feb_end_on);
void Feb_PrintData();
bool SetByteOrder();
//bool CheckSubNumber(unsigned int sub_num);
//bool SetStartOnEndOnFebs(int sub_num_s, unsigned int& start_on, unsigned int& end_on);
void PrintData();
Feb_Feb();
/*virtual ~Feb();*/
void Feb_SendCompleteFebList(unsigned int n,unsigned int* list);
int Feb_CheckCommunication();
/*int Feb_ReadRegister(unsigned int Feb_sub_num, unsigned int Feb_reg_num,unsigned int& Feb_value_read);*/
int Feb_ReadRegister(unsigned int sub_num, unsigned int reg_num,unsigned int* value_read);
int Feb_ReadRegisters(unsigned int sub_num, unsigned int nreads, unsigned int* reg_nums,unsigned int* values_read);
/*int WriteRegister(unsigned int sub_num, unsigned int reg_num,unsigned int value, int wait_on=0, unsigned int wait_on_address=0);*/
int Feb_WriteRegister(unsigned int sub_num, unsigned int reg_num,unsigned int value, int wait_on, unsigned int wait_on_address);
/*int WriteRegisters(unsigned int sub_num, unsigned int nwrites, unsigned int* reg_nums, unsigned int* values, int* wait_ons=0, unsigned int* wait_on_addresses=0);*/
int Feb_WriteRegisters(unsigned int sub_num, unsigned int nwrites, unsigned int* reg_nums, unsigned int* values, int* wait_ons, unsigned int* wait_on_addresses);
int Feb_WriteMemory(unsigned int sub_num, unsigned int mem_num, unsigned int start_address, unsigned int nwrites, unsigned int *values);
int Feb_Test();
public:
Feb();
virtual ~Feb();
void SendCompleteFebList(unsigned int n,unsigned int* list);
bool CheckCommunication();
bool ReadRegister(unsigned int sub_num, unsigned int reg_num,unsigned int& value_read);
bool ReadRegisters(unsigned int sub_num, unsigned int nreads, unsigned int* reg_nums,unsigned int* values_read);
bool WriteRegister(unsigned int sub_num, unsigned int reg_num,unsigned int value, bool wait_on=0, unsigned int wait_on_address=0);
bool WriteRegisters(unsigned int sub_num, unsigned int nwrites, unsigned int* reg_nums, unsigned int* values, bool* wait_ons=0, unsigned int* wait_on_addresses=0);
bool WriteMemory(unsigned int sub_num, unsigned int mem_num, unsigned int start_address, unsigned int nwrites, unsigned int *values);
bool Test();
};
#endif

View File

@ -9,186 +9,176 @@
#define FEBCONTROL_H
#include <netinet/in.h>
#include <string>
#include <vector>
#include <stdlib.h>
//#include <string>
//#include <vector>
#include "FebInterface.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;
int* top_dac;
int* 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;}
int SetTopDACValue(unsigned int i, int value) { return (i<ndacs && TopAddressIsValid()) ? (top_dac[i]=value) : -1;}
int GetTopDACValue(unsigned int i) { return (i<ndacs) ? top_dac[i]:-1;}
int SetBottomDACValue(unsigned int i, int value) { return (i<ndacs && BottomAddressIsValid()) ? (bottom_dac[i]=value) : -1;}
int GetBottomDACValue(unsigned int i) { return (i<ndacs) ? bottom_dac[i]:-1;}
struct Module{
unsigned int module_number;
int top_address_valid;
unsigned int top_left_address;
unsigned int top_right_address;
int 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;
int* top_dac;
int* bottom_dac;
};
void Module_Module(struct Module* mod,unsigned int number, unsigned int address_top);
void Module_Module1(struct Module* mod,unsigned int number, unsigned int address_top, unsigned int address_bottom);
unsigned int Module_GetModuleNumber(struct Module* mod);
int Module_TopAddressIsValid(struct Module* mod);
unsigned int Module_GetTopBaseAddress(struct Module* mod);
unsigned int Module_GetTopLeftAddress(struct Module* mod) ;
unsigned int Module_GetTopRightAddress(struct Module* mod);
unsigned int Module_GetBottomBaseAddress(struct Module* mod);
int Module_BottomAddressIsValid(struct Module* mod);
unsigned int Module_GetBottomLeftAddress(struct Module* mod);
unsigned int Module_GetBottomRightAddress(struct Module* mod);
unsigned int Module_SetTopIDelay(struct Module* mod,unsigned int chip,unsigned int value);
unsigned int Module_GetTopIDelay(struct Module* mod,unsigned int chip) ;
unsigned int Module_SetBottomIDelay(struct Module* mod,unsigned int chip,unsigned int value);
unsigned int Module_GetBottomIDelay(struct Module* mod,unsigned int chip);
float Module_SetHighVoltage(struct Module* mod,float value);
float Module_GetHighVoltage(struct Module* mod);
int Module_SetTopDACValue(struct Module* mod,unsigned int i, int value);
int Module_GetTopDACValue(struct Module* mod,unsigned int i);
int Module_SetBottomDACValue(struct Module* mod,unsigned int i, int value);
int Module_GetBottomDACValue(struct Module* mod,unsigned int i);
class FebControl:private FebInterface{
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 int* last_downloaded_trimbits;
void PrintModuleList();
bool GetModuleIndex(unsigned int module_number, unsigned int& module_index);
bool CheckModuleAddresses(Module* m);
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, unsigned int& 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);
bool SendBitModeToBebServer();
unsigned int ConvertTimeToRegister(float time_in_sec);
unsigned int AddressToAll();
bool SetCommandRegister(unsigned int cmd);
bool GetDAQStatusRegister(unsigned int dst_address, unsigned int &ret_status);
bool StartDAQOnlyNWaitForFinish(int sleep_time_us=5000);
bool ResetChipCompletely();
struct sockaddr_in serv_addr;
bool SetupSendToSocket(const char* ip_address_hostname, unsigned short int port);
int WriteNRead(char* message, int length, int max_length);
void Feb_Control_ClearModules();
public:
FebControl();
virtual ~FebControl();
void Feb_Control_PrintModuleList();
int Feb_Control_GetModuleIndex(unsigned int module_number, unsigned int* module_index);
int Feb_Control_CheckModuleAddresses(struct Module* m);
int Feb_Control_AddModule(unsigned int module_number, unsigned int top_address);
/*int Feb_Control_AddModule(unsigned int module_number, unsigned int top_address, unsigned int bottom_address, int half_module=0);*/
int Feb_Control_AddModule1(unsigned int module_number, unsigned int top_address, unsigned int bottom_address, int half_module);
bool Init();
bool ReadSetUpFileToAddModules(std::string file_name);
bool ReadSetUpFile(unsigned int module_num, std::string file_name);
bool CheckSetup();
int Feb_Control_GetDACNumber(char* s, unsigned int* n);
int Feb_Control_SendDACValue(unsigned int dst_num, unsigned int ch, unsigned int* value);
int Feb_Control_VoltageToDAC(float value, unsigned int* digital, unsigned int nsteps, float vmin, float vmax);
float Feb_Control_DACToVoltage(unsigned int digital,unsigned int nsteps,float vmin,float vmax);
unsigned int GetNModules();
unsigned int GetNHalfModules();
int Feb_Control_SendHighVoltage(unsigned int module_index, float* value);
bool SetHighVoltage(float value);
bool SetHighVoltage(unsigned int module_num,float value);
int Feb_Control_SendIDelays(unsigned int dst_num, int chip_lr, unsigned int channels, unsigned int ndelay_units);
bool SetPhotonEnergy(unsigned int full_energy_eV);
unsigned int GetPhotonEnergy(){return photon_energy_eV;}
int Feb_Control_SetStaticBits();
int Feb_Control_SetStaticBits1(unsigned int the_static_bits);
bool SetIDelays(unsigned int module_num, unsigned int ndelay_units);
bool SetIDelays(unsigned int module_num, unsigned int chip_pos, unsigned int ndelay_units);
int Feb_Control_SendBitModeToBebServer();
unsigned int Feb_Control_ConvertTimeToRegister(float time_in_sec);
unsigned int Feb_Control_AddressToAll();
int Feb_Control_SetCommandRegister(unsigned int cmd);
int Feb_Control_GetDAQStatusRegister(unsigned int dst_address, unsigned int* ret_status);
/*int Feb_Control_StartDAQOnlyNWaitForFinish(int sleep_time_us=5000);*/
int Feb_Control_StartDAQOnlyNWaitForFinish(int sleep_time_us);
int Feb_Control_ResetChipCompletely();
struct sockaddr_in Feb_Control_serv_addr;
/*
int Feb_Control_SetupSendToSocket(const char* ip_address_hostname, unsigned short int port);
int Feb_Control_WriteNRead(char* message, int length, int max_length);
*/
void Feb_Control_FebControl();
int Feb_Control_Init();
int Feb_Control_ReadSetUpFileToAddModules(char* file_name);
int Feb_Control_ReadSetUpFile(unsigned int module_num, char* file_name);
int Feb_Control_CheckSetup();
unsigned int Feb_Control_GetNModules();
unsigned int Feb_Control_GetNHalfModules();
int Feb_Control_SetHighVoltage(float value);
int Feb_Control_SetHighVoltage1(unsigned int module_num,float value);
int Feb_Control_SetPhotonEnergy(unsigned int full_energy_eV);
unsigned int Feb_Control_GetPhotonEnergy();
int Feb_Control_SetIDelays(unsigned int module_num, unsigned int ndelay_units);
int Feb_Control_SetIDelays1(unsigned int module_num, unsigned int chip_pos, unsigned int ndelay_units);
bool DecodeDACString(std::string dac_str, unsigned int& module_index, bool& top, bool& bottom, unsigned int& dac_ch);
bool SetDAC(std::string s, int value, bool is_a_voltage_mv=0);
bool GetDAC(std::string s, int& ret_value, bool voltage_mv=0);
bool GetDACName(unsigned int dac_num, std::string &s);
int Feb_Control_DecodeDACString(char* dac_str, unsigned int* module_index, int* top, int* bottom, unsigned int* dac_ch);
/*int Feb_Control_SetDAC(string s, int value, int is_a_voltage_mv=0);*/
int Feb_Control_SetDAC(char* s, int value, int is_a_voltage_mv);
/* int Feb_Control_GetDAC(string s, int* ret_value, int voltage_mv=0);*/
int Feb_Control_GetDAC(char* s, int* ret_value, int voltage_mv);
int Feb_Control_GetDACName(unsigned int dac_num,char* s);
bool SetTrimbits(unsigned int module_num, unsigned int* trimbits);
unsigned int* GetTrimbits();
int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int* trimbits);
unsigned int* Feb_Control_GetTrimbits();
/**Added by Dhanya */
bool LoadTrimbitFile();
bool SaveTrimbitFile();
bool SaveAllTrimbitsTo(int value);
int Feb_Control_LoadTrimbitFile();
int Feb_Control_SaveTrimbitFile();
int Feb_Control_SaveAllTrimbitsTo(int value);
bool Reset();
bool StartAcquisition();
bool StopAcquisition();
bool AcquisitionInProgress();
bool WaitForFinishedFlag(int sleep_time_us=5000);
int Feb_Control_Reset();
int Feb_Control_StartAcquisition();
int Feb_Control_StopAcquisition();
int Feb_Control_AcquisitionInProgress();
/*int Feb_Control_WaitForFinishedFlag(int sleep_time_us=5000);*/
int Feb_Control_WaitForFinishedFlag(int sleep_time_us);
//functions for setting up exposure
void PrintAcquisitionSetup();
bool SetNExposures(unsigned int n_images);
unsigned int GetNExposures();
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);
void Feb_Control_PrintAcquisitionSetup();
int Feb_Control_SetNExposures(unsigned int n_images);
unsigned int Feb_Control_GetNExposures();
int Feb_Control_SetExposureTime(double the_exposure_time_in_sec);
double Feb_Control_GetExposureTime();
int Feb_Control_SetExposurePeriod(double the_exposure_period_in_sec);
double Feb_Control_GetExposurePeriod();
int Feb_Control_SetDynamicRange(unsigned int four_eight_sixteen_or_thirtytwo);
unsigned int Feb_Control_GetDynamicRange();
/*int Feb_Control_SetReadoutSpeed(unsigned int readout_speed=0); //0->full,1->half,2->quarter or 3->super_slow*/
int Feb_Control_SetReadoutSpeed(unsigned int readout_speed); //0->full,1->half,2->quarter or 3->super_slow
/* int Feb_Control_SetReadoutMode(unsigned int readout_mode=0); //0->parallel,1->non-parallel,2-> safe_mode*/
int Feb_Control_SetReadoutMode(unsigned int readout_mode); //0->parallel,1->non-parallel,2-> safe_mode
/* int Feb_Control_SetTriggerMode(unsigned int trigger_mode=0, int polarity=1);*/
int Feb_Control_SetTriggerMode(unsigned int trigger_mode, int polarity);
/*int Feb_Control_SetExternalEnableMode(int use_external_enable=0, int polarity=1);*/
int Feb_Control_SetExternalEnableMode(int use_external_enable, int polarity);
//functions for testing
bool SetTestModeVariable(bool on=1);
bool GetTestModeVariable();
/*int Feb_Control_SetTestModeVariable(int on=1);*/
int Feb_Control_SetTestModeVariable(int on);
int Feb_Control_GetTestModeVariable();
};
#endif

View File

@ -10,44 +10,31 @@
#include "LocalLinkInterface.h"
class FebInterface{ //
private:
LocalLinkInterface* ll;
int Feb_Interface_WriteTo(unsigned int ch);
/*int Feb_Interface_ReadFrom(unsigned int ch, unsigned int ntrys=20);*/
int Feb_Interface_ReadFrom(unsigned int ch, unsigned int ntrys);
void Feb_Interface_SendCompleteList(unsigned int n,unsigned int* list);
int Feb_Interface_SetByteOrder();
int Feb_Interface_ReadRegister(unsigned int sub_num, unsigned int reg_num,unsigned int* value_read);
int Feb_Interface_ReadRegisters(unsigned int sub_num, unsigned int nreads, unsigned int* reg_nums,unsigned int* values_read);
/*int Feb_Interface_WriteRegister(unsigned int sub_num, unsigned int reg_num,unsigned int value, int wait_on=0, unsigned int wait_on_address=0);*/
int Feb_Interface_WriteRegister(unsigned int sub_num, unsigned int reg_num,unsigned int value, int wait_on, unsigned int wait_on_address);
/*int Feb_Interface_WriteRegisters(unsigned int sub_num, unsigned int nwrites, unsigned int* reg_nums, unsigned int* values, int* wait_ons=0, unsigned int* wait_on_addresses=0);*/
int Feb_Interface_WriteRegisters(unsigned int sub_num, unsigned int nwrites, unsigned int* reg_nums, unsigned int* values, int* wait_ons, unsigned int* wait_on_addresses);
int Feb_Interface_WriteMemory(unsigned int sub_num, unsigned int mem_num, unsigned int start_address, unsigned int nwrites, unsigned int *values);
unsigned int nfebs;
unsigned int* feb_numb;
int send_ndata;
unsigned int send_buffer_size;
unsigned int* send_data_raw;
unsigned int* send_data;
int recv_ndata;
unsigned int recv_buffer_size;
unsigned int* recv_data_raw;
unsigned int* recv_data;
bool WriteTo(unsigned int ch);
bool ReadFrom(unsigned int ch, unsigned int ntrys=20);
public:
FebInterface();
virtual ~FebInterface();
void SendCompleteList(unsigned int n,unsigned int* list);
bool SetByteOrder();
bool ReadRegister(unsigned int sub_num, unsigned int reg_num,unsigned int& value_read);
bool ReadRegisters(unsigned int sub_num, unsigned int nreads, unsigned int* reg_nums,unsigned int* values_read);
bool WriteRegister(unsigned int sub_num, unsigned int reg_num,unsigned int value, bool wait_on=0, unsigned int wait_on_address=0);
bool WriteRegisters(unsigned int sub_num, unsigned int nwrites, unsigned int* reg_nums, unsigned int* values, bool* wait_ons=0, unsigned int* wait_on_addresses=0);
bool WriteMemory(unsigned int sub_num, unsigned int mem_num, unsigned int start_address, unsigned int nwrites, unsigned int *values);
};
#endif

View File

@ -7,24 +7,20 @@
#include "xfs_types.h"
class HardwareIO{ //
protected:
xfs_u8 xfs_in8(xfs_u32 InAddress);
xfs_u16 xfs_in16(xfs_u32 InAddress);
xfs_u32 xfs_in32(xfs_u32 InAddress);
void xfs_out8(xfs_u32 OutAddress, xfs_u8 Value);
void xfs_out16(xfs_u32 OutAddress, xfs_u16 Value);
void xfs_out32(xfs_u32 OutAddress, xfs_u32 Value);
public:
HardwareIO(){};
virtual ~HardwareIO(){};
xfs_u8 HWIO_xfs_in8(xfs_u32 InAddress);
xfs_u16 HWIO_xfs_in16(xfs_u32 InAddress);
xfs_u32 HWIO_xfs_in32(xfs_u32 InAddress);
void HWIO_xfs_out8(xfs_u32 OutAddress, xfs_u8 Value);
void HWIO_xfs_out16(xfs_u32 OutAddress, xfs_u16 Value);
void HWIO_xfs_out32(xfs_u32 OutAddress, xfs_u32 Value);
};
#endif

View File

@ -7,41 +7,44 @@
#include "xfs_types.h"
#include "HardwareIO.h"
class LocalLinkInterface: public HardwareIO{ //
/*class LocalLinkInterface: public HardwareIO{ //*/
private:
struct LocalLinkInterface{
xfs_u32 ll_fifo_base;
unsigned int ll_fifo_ctrl_reg;
};
bool Init(unsigned int ll_fifo_badr);
bool Reset(unsigned int rst_mask);
bool ctrl_reg_write_mask(unsigned int mask, unsigned int val);
void llfifo_print_frame(unsigned char* fbuff, int len);
public:
LocalLinkInterface(unsigned int ll_fifo_badr);
virtual ~LocalLinkInterface();
int Local_Init(struct LocalLinkInterface* ll,unsigned int ll_fifo_badr);
int Local_Reset1(struct LocalLinkInterface* ll,unsigned int rst_mask);
unsigned int StatusVector();
bool Reset();
int Write(unsigned int buffer_len, void *buffer);
int Read(unsigned int buffer_len, void *buffer);
int Local_ctrl_reg_write_mask(struct LocalLinkInterface* ll,unsigned int mask, unsigned int val);
void Local_llfifo_print_frame(struct LocalLinkInterface* ll,unsigned char* fbuff, int len);
int Test(unsigned int buffer_len, void *buffer);
LocalLinkInterface();
int InitNewMemory (unsigned int addr, int ifg);
void Local_LocalLinkInterface1(struct LocalLinkInterface* ll,unsigned int ll_fifo_badr);
/* virtual ~LocalLinkInterface();*/
unsigned int Local_StatusVector(struct LocalLinkInterface* ll);
int Local_Reset(struct LocalLinkInterface* ll);
int Local_Write(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buffer);
int Local_Read(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buffer);
int Local_Test(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buffer);
void Local_LocalLinkInterface(struct LocalLinkInterface* ll);
int Local_InitNewMemory (struct LocalLinkInterface* ll,unsigned int addr, int ifg);
/*
bool FiFoReset(unsigned int numb);
int FiFoReset(unsigned int numb);
int FifoSend(unsigned int numb, unsigned int frame_len, void *buffer);
int FifoReceive(unsigned int numb, unsigned int frame_len, void *buffer);
int FifoTest(unsigned int numb,unsigned int send_len, char *send_str);
*/
};
#endif

10
slsDetectorSoftware/eigerDetectorServer/Makefile Normal file → Executable file
View File

@ -1,6 +1,6 @@
CC = powerpc-4xx-softfloat-gcc
CCX = powerpc-4xx-softfloat-g++
CFLAGS += -Wall -DDACS_INT -DEIGERD -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSE #-DVIRTUAL -DPCCOMPILE
CFLAGS += -Wall -DDACS_INT -DEIGERD -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT #-DSTOP_SERVER #-DVERBOSE #-DVIRTUAL -DPCCOMPILE
LDLIBS += -lm -lstdc++
PROGS = eigerDetectorServer
@ -8,14 +8,14 @@ DESTDIR ?= bin
INSTMODE = 0777
SRC_CLNT = communication_funcs.c slsDetectorServer.c slsDetectorServer_funcs.c slsDetectorFunctionList.c
SRC_CLNT2 = FebServer.cxx FebControl.cxx FebInterface.cxx LocalLinkInterface.cxx HardwareIO.cxx
SRC_CLNT3 = BebServer.cxx Beb.cxx LocalLinkInterface.cxx HardwareIO.cxx
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) feb_debug beb_debug
all: clean $(PROGS) #feb_debug beb_debug
boot: $(OBJS)

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/eigerDetectorServer
URL: origin git@gitorious.psi.ch:sls_det_software/sls_detector_software.git/eigerDetectorServer
Repository Root: origin git@gitorious.psi.ch:sls_det_software/sls_detector_software.git
Repsitory UUID: 046a469b1e6582c4c55bd6eaeb4818b618d0a9a9
Revision: 75
Branch: separate_receiver
Repsitory UUID: 8c994ea0d538628b36a9497508960388816749fa
Revision: 87
Branch: master
Last Changed Author: Maliakal_Dhanya
Last Changed Rev: 14
Last Changed Date: 2014-06-03 12:26:45 +0200
Last Changed Rev: 278
Last Changed Date: 2014-08-08 14:03:30 +0200

View File

@ -1,11 +1,11 @@
//#define SVNPATH ""
#define SVNURL "git@gitorious.psi.ch:sls_det_software/sls_detector_software.git/eigerDetectorServer"
//#define SVNREPPATH ""
#define SVNREPUUID "046a469b1e6582c4c55bd6eaeb4818b618d0a9a9"
//#define SVNREV 0x14
#define SVNREPUUID "8c994ea0d538628b36a9497508960388816749fa"
//#define SVNREV 0x278
//#define SVNKIND ""
//#define SVNSCHED ""
#define SVNAUTH "Maliakal_Dhanya"
#define SVNREV 0x14
#define SVNDATE 0x20140603
#define SVNREV 0x278
#define SVNDATE 0x20140808
//

View File

@ -8,11 +8,15 @@
#include "slsDetectorFunctionList.h"
#include "gitInfoEiger.h"
#include "EigerHighLevelFunctions.c"
#include "EigerBackEndFunctions.c"
/*#include "EigerHighLevelFunctions.c"
#include "EigerBackEndFunctions.c"*/
#include "FebControl.h"
#include "Beb.h"
enum detectorSettings thisSettings;
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"};
//static const string dacNames[16] = {"Svp","Svn","Vtr","Vrf","Vrs","Vtgstv","Vcmp_ll","Vcmp_lr","Cal","Vcmp_rl","Vcmp_rr","Rxb_rb","Rxb_lb","Vcp","Vcn","Vis"};
sls_detector_module *detectorModules=NULL;
@ -22,6 +26,29 @@ dacs_t *detectorDacs=NULL;
dacs_t *detectorAdcs=NULL;
int eiger_highvoltage = 0;
int eiger_iodelay = 0;
int eiger_photonenergy = 0;
int eiger_dynamicrange = 0;
int eiger_readoutmode = 0;
int eiger_readoutspeed = 0;
int eiger_triggermode = 0;
int eiger_extgating = 0;
int eiger_extgatingpolarity = 0;
int eiger_nexposures = 1;
int eiger_ncycles = 1;
int send_to_ten_gig = 0;
int ndsts_in_use=32;
unsigned int nimages_per_request=1;
int on_dst=0;
int 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};
int initDetector(){
int imod,i,n;
@ -70,6 +97,12 @@ int initDetector(){
sAdc=noneSelected;
*/
Feb_Interface_FebInterface();
Feb_Control_FebControl();
printf("FEb control constructor done\n");
Beb_Beb(-1);
printf("BEB constructor done\n");
//get dac values
int retval[2];
for(i=0;i<(detectorModules)->ndac;i++){
@ -83,7 +116,7 @@ int initDetector(){
//set number of frames to 1
setTimer(FRAME_NUMBER,1);
setTimer(ACQUISITION_TIME,1E9);
setTimer(ACQUISITION_TIME,1E9);
setTimer(FRAME_PERIOD,1E9);
setDynamicRange(16);
setThresholdEnergy(8000,0);
setReadOutFlags(PARALLEL);
@ -227,7 +260,13 @@ int detectorTest( enum digitalTestMode arg){
void setDAC(enum detDacIndex ind, int val, int imod, int mV, int retval[]){
char iname[10];
strcpy(iname,EigerGetDACName((int)ind));
if(((int)ind>=0)&&((int)ind<NDAC))
strcpy(iname,dac_names[(int)ind]);
else{
printf("dac value outside range:%d\n",(int)ind);
strcpy(iname,dac_names[0]);
}
#ifdef VERBOSE
if(val >= 0)
printf("Setting dac %d: %s to %d ",ind, iname,val);
@ -239,9 +278,12 @@ void setDAC(enum detDacIndex ind, int val, int imod, int mV, int retval[]){
printf("in dac units\n");
#endif
if(val >= 0)
EigerSetDAC(iname,val,mV);
retval[0] = EigerGetDAC(iname);
retval[1] = EigerGetDACmV(iname);
Feb_Control_SetDAC(iname,val,mV);
int k;
Feb_Control_GetDAC(iname, &k,0);
retval[0] = k;
Feb_Control_GetDAC(iname,&k,1);
retval[1] = k;
(detectorModules)->dacs[ind] = retval[0];
@ -251,9 +293,10 @@ void setDAC(enum detDacIndex ind, int val, int imod, int mV, int retval[]){
int setHighVolage(int val, int imod){
if(val!=-1){
printf(" Setting High Voltage: %d\n",val);
EigerSetHighVoltage(val);
if(Feb_Control_SetHighVoltage(val))
eiger_highvoltage = val;
}
return EigerGetHighVoltage();
return eiger_highvoltage;
}
@ -266,21 +309,25 @@ int getADC(enum detDacIndex ind, int imod){
int setIODelay(int val, int imod){
if(val!=-1){
printf(" Setting IO Delay: %d\n",val);
EigerSetIODelay(val);
if(Feb_Control_SetIDelays(0,val))
eiger_iodelay = val;
}
return EigerGetIODelay();
return eiger_iodelay;
}
int enableTenGigabitEthernet(int val){
if(val!=-1){
if(val>0)
SetTenGigbaBitEthernet(1);
send_to_ten_gig = 1;
else
SetTenGigbaBitEthernet(0);
send_to_ten_gig = 0;
//configuremac called from client
}
return GetTenGigbaBitEthernet();
//#ifdef VERBOSE
printf("10Gbe:%d\n",send_to_ten_gig);
//#endif
return send_to_ten_gig;
}
@ -297,11 +344,13 @@ int setModule(sls_detector_module myMod){
// thisSettings = (enum detectorSettings)myMod.reg;
// thisSettings = 0;
setSettings( (enum detectorSettings)myMod.reg,-1); // put the settings in the module register?!?!?
EigerSetTrimbits(myMod.chanregs);
if (detectorModules)
copyModule(detectorModules,&myMod);
setSettings( (enum detectorSettings)myMod.reg,-1); // put the settings in the module register?!?!?
Feb_Control_SetTrimbits(0,myMod.chanregs);
return 0;
}
@ -312,10 +361,10 @@ int retval[2];
for(i=0;i<NDAC;i++)
setDAC((enum detDacIndex)i,-1,-1,0,retval);
EigerGetTrimbits(myMod->chanregs);
myMod->chanregs = Feb_Control_GetTrimbits();
if (detectorModules)
copyModule(myMod,detectorModules);/*copyModule(myMod,detectorModules+iMod);*/
copyModule(myMod,detectorModules);
else
return FAIL;
return OK;
@ -328,14 +377,15 @@ int retval[2];
int getThresholdEnergy(int imod){
printf(" Getting Threshold energy\n");
return EigerGetPhotonEnergy();
return eiger_photonenergy;
}
int setThresholdEnergy(int thr, int imod){
printf(" Setting threshold energy:%d\n",thr);
EigerSetPhotonEnergy(thr);
return EigerGetPhotonEnergy();
if(Feb_Control_SetPhotonEnergy(thr))
eiger_photonenergy = thr;
return getThresholdEnergy(imod);
}
@ -352,27 +402,61 @@ enum detectorSettings setSettings(enum detectorSettings sett, int imod){
int startStateMachine(){
printf("Going to start acquisition\n");
EigerStartAcquisition();
RequestImages();
return OK;
if(Feb_Control_StartAcquisition()){
//RequestImages();
int ret_val = 0;
dst_requested[0] = 1;
while(dst_requested[on_dst]){
//waits on data
if((ret_val = (!Beb_RequestNImages(0,1,send_to_ten_gig,on_dst,nimages_per_request,0)||
!Beb_RequestNImages(0,2,send_to_ten_gig,0x20|on_dst,nimages_per_request,0))))
break;
dst_requested[on_dst++]=0;
on_dst%=ndsts_in_use;
}
if(ret_val)
return FAIL;
else
return OK;
}
return FAIL;
}
int stopStateMachine(){
printf("Going to stop acquisition\n");
EigerStopAcquisition();
return OK;
if(Feb_Control_StopAcquisition())
return OK;
return FAIL;
}
int startReadOut(){
RequestImages();
//RequestImages();
int ret_val = 0;
dst_requested[0] = 1;
while(dst_requested[on_dst]){
//waits on data
if((ret_val = (!Beb_RequestNImages(0,1,send_to_ten_gig,on_dst,nimages_per_request,0)||
!Beb_RequestNImages(0,2,send_to_ten_gig,0x20|on_dst,nimages_per_request,0))))
break;
dst_requested[on_dst++]=0;
on_dst%=ndsts_in_use;
}
if(ret_val)
return FAIL;
else
return OK;
return OK;
}
enum runStatus getRunStatus(){
int i = EigerRunStatus();
int i = Feb_Control_AcquisitionInProgress();
if(i== 0){
printf("IDLE\n");
return IDLE;
@ -385,13 +469,8 @@ enum runStatus getRunStatus(){
char *readFrame(int *ret, char *mess){
EigerWaitForAcquisitionFinish();
/*
int i = EigerRunStatus();
while(i){
i = EigerRunStatus();
usleep(1000);
}*/
if(!Feb_Control_WaitForFinishedFlag(5000))
printf("error in waiting for finished flag\n");
*ret = (int)FINISHED;
return NULL;
}
@ -408,19 +487,27 @@ int64_t setTimer(enum timerIndex ind, int64_t val){
case FRAME_NUMBER:
if(val >= 0){
printf(" Setting number of frames: %d\n",(unsigned int)val);
EigerSetNumberOfExposures((unsigned int)val);
SetDestinationParameters(EigerGetNumberOfExposures()*EigerGetNumberOfCycles());
}return EigerGetNumberOfExposures();
if(Feb_Control_SetNExposures((unsigned int)val)*eiger_ncycles){
eiger_nexposures = val;
//SetDestinationParameters(EigerGetNumberOfExposures()*EigerGetNumberOfCycles());
on_dst = 0;
int i;
for(i=0;i<32;i++) dst_requested[i] = 0; //clear dst requested
ndsts_in_use = 1;
nimages_per_request = eiger_nexposures * eiger_ncycles;
}
}return eiger_nexposures;
case ACQUISITION_TIME:
if(val >= 0){
printf(" Setting exp time: %fs\n",val/(1E9));
EigerSetExposureTime(val/(1E9));
}return (EigerGetExposureTime()*(1E9));
Feb_Control_SetExposureTime(val/(1E9));
}
return (Feb_Control_GetExposureTime()*(1E9));
case FRAME_PERIOD:
if(val >= 0){
printf(" Setting acq period: %fs\n",val/(1E9));
EigerSetExposurePeriod(val/(1E9));
}return (EigerGetExposurePeriod()*(1E9));
Feb_Control_SetExposurePeriod(val/(1E9));
}return (Feb_Control_GetExposurePeriod()*(1E9));
/* case DELAY_AFTER_TRIGGER:
if(val >= 0)
EigerSetNumberOfExposures((unsigned int)val);
@ -438,9 +525,15 @@ int64_t setTimer(enum timerIndex ind, int64_t val){
case CYCLES_NUMBER:
if(val >= 0){
printf(" Setting number of triggers: %d\n",(unsigned int)val);
EigerSetNumberOfCycles((unsigned int)val);
SetDestinationParameters(EigerGetNumberOfExposures()*EigerGetNumberOfCycles());
}return EigerGetNumberOfCycles();
if(Feb_Control_SetNExposures((unsigned int)val*eiger_nexposures)){
eiger_ncycles = val;
//SetDestinationParameters(EigerGetNumberOfExposures()*EigerGetNumberOfCycles());
on_dst = 0;
int i;
for(i=0;i<32;i++) dst_requested[i] = 0; //clear dst requested
nimages_per_request = eiger_nexposures * eiger_ncycles;
}
}return eiger_ncycles;
default:
printf("unknown timer index: %d\n",ind);
break;
@ -460,18 +553,22 @@ int64_t getTimeLeft(enum timerIndex ind){
int setDynamicRange(int dr){
int r;
if(dr > 0){
printf(" Setting dynamic range: %d\n",dr);
EigerSetDynamicRange(dr);
EigerSetBitMode(dr);
if(Feb_Control_SetDynamicRange(dr)){
//EigerSetBitMode(dr);
on_dst = 0;
int i;
for(i=0;i<32;i++) dst_requested[i] = 0; //clear dst requested
if(Beb_SetUpTransferParameters(dr))
eiger_dynamicrange = dr;
}
}
//make sure back end and front end have the same bit mode
r= EigerGetDynamicRange();
if(r != EigerGetBitMode())
EigerSetBitMode(r);
dr= Feb_Control_GetDynamicRange();
return r;
return dr;
}
@ -486,9 +583,10 @@ enum readOutFlags setReadOutFlags(enum readOutFlags val){
default: val=0; break;
}
printf(" Setting Read out Flag: %d\n",val);
EigerSetReadoutMode(val);
if(Feb_Control_SetReadoutMode(val))
eiger_readoutmode = val;
}
switch(EigerGetReadoutMode()){
switch(eiger_readoutmode){
case 0: ret=PARALLEL; break;
case 1: ret=NONPARALLEL; break;
case 2: ret=SAFE; break;
@ -510,9 +608,10 @@ int setROI(int n, ROI arg[], int *retvalsize, int *ret){
int setSpeed(enum speedVariable arg, int val){
if(val != -1){
printf(" Setting Read out Speed: %d\n",val);
EigerSetReadoutSpeed(val);
if(Feb_Control_SetReadoutSpeed(val))
eiger_readoutspeed = val;
}
return EigerGetReadoutSpeed();
return eiger_readoutspeed;
}
@ -523,9 +622,58 @@ int executeTrimming(enum trimMode mode, int par1, int par2, int imod){
int configureMAC(int ipad, long long int macad, long long int detectormacadd, int detipad, int udpport, int ival){
EigerSetupTableEntryLeft(ipad, macad, detectormacadd, detipad, udpport);
EigerSetupTableEntryRight(ipad, macad, detectormacadd, detipad, udpport);
SetDestinationParameters(EigerGetNumberOfExposures()*EigerGetNumberOfCycles());
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);
int beb_num = 34;
int header_number = 0;
int i=0;
//EigerSetupTableEntryLeft(ipad, macad, detectormacadd, detipad, udpport);
/* for(i=0;i<32;i++){/** modified for Aldo*/
if(Beb_SetBebSrcHeaderInfos(beb_num,send_to_ten_gig,src_mac,src_ip,src_port) &&
Beb_SetUpUDPHeader(beb_num,send_to_ten_gig,header_number+i,dst_mac,dst_ip, dst_port))
printf("set up left ok\n");
else return -1;
/*}*/
//EigerSetupTableEntryRight(ipad, macad, detectormacadd, detipad, udpport);
header_number = 32;
dst_port = udpport +1;
/*for(i=0;i<32;i++){*//** modified for Aldo*/
if(Beb_SetBebSrcHeaderInfos(beb_num,send_to_ten_gig,src_mac,src_ip,src_port) &&
Beb_SetUpUDPHeader(beb_num,send_to_ten_gig,header_number+i,dst_mac,dst_ip, dst_port))
printf("set up right ok\n");
else return -1;
/*}*/
//SetDestinationParameters(EigerGetNumberOfExposures()*EigerGetNumberOfCycles());
on_dst = 0;
for(i=0;i<32;i++) dst_requested[i] = 0; //clear dst requested
nimages_per_request=eiger_nexposures * eiger_ncycles;
return 0;
}
@ -655,10 +803,11 @@ enum externalCommunicationMode setTiming( enum externalCommunicationMode arg){
case GATE_FIX_NUMBER: ret = 3; break;
}
printf(" Setting Triggering Mode: %d\n",(int)ret);
EigerSetTriggerMode(ret);
if(Feb_Control_SetTriggerMode(ret,1))
eiger_triggermode = ret;
}
ret = EigerGetTriggerMode();
ret = eiger_triggermode;
switch((int)ret){
case 0: ret = AUTO_TIMING; break;
case 2: ret = TRIGGER_EXPOSURE; break;
@ -673,10 +822,13 @@ enum externalCommunicationMode setTiming( enum externalCommunicationMode arg){
void setExternalGating(int enable[]){
if(enable>=0)
EigerSetExternalGating(enable[0], enable[1]);//enable = 0 or 1, polarity = 0 or 1 , where 1 is positive
enable[0] = EigerGetExternalGatingPolarity();
enable[1] = EigerGetExternalGating();
if(enable>=0){
Feb_Control_SetExternalEnableMode(enable[0], enable[1]);//enable = 0 or 1, polarity = 0 or 1 , where 1 is positive
eiger_extgating = enable[0];
eiger_extgatingpolarity = enable[1];
}
enable[0] = eiger_extgating;
enable[1] = eiger_extgatingpolarity;
}
@ -692,15 +844,16 @@ enum synchronizationMode setSynchronization(enum synchronizationMode arg){
void setAllTrimbits(int val){
int ichan;
EigerSetAllTrimbits(val);
if(Feb_Control_SaveAllTrimbitsTo(val)){
#ifdef VERBOSE
printf("Copying register %x value %d\n",destMod->reg,val);
printf("Copying register %x value %d\n",destMod->reg,val);
#endif
if (detectorModules){
for (ichan=0; ichan<(detectorModules->nchan); ichan++) {
if (detectorModules){
for (ichan=0; ichan<(detectorModules->nchan); ichan++) {
*((detectorModules->chanregs)+ichan)=val;
}
}
}
}else printf("error in setting all trimbits to value\n");
}
int getAllTrimbits(){

View File

@ -1,6 +1,8 @@
#ifndef __XFS_TYPES_H__
#define __XFS_TYPES_H__
//#include "types.h"
#include <stdint.h>
/******************************************************************************/
/* types */
/******************************************************************************/
@ -15,33 +17,33 @@ typedef signed char xfs_i8;
// UDP Header
typedef struct
struct udp_header_type
{
// ethternet frame (14 byte)
unsigned char dst_mac[6];
unsigned char src_mac[6];
unsigned char len_type[2];
uint8_t dst_mac[6];
uint8_t src_mac[6];
uint8_t len_type[2];
// ip header (20 byte)
unsigned char ver_headerlen[1];
unsigned char service_type[1];
unsigned char total_length[2];
unsigned char identification[2];
unsigned char flags[1];
unsigned char frag_offset[1];
unsigned char time_to_live[1];
unsigned char protocol[1];
unsigned char ip_header_checksum[2];
unsigned char src_ip[4];
unsigned char dst_ip[4];
uint8_t ver_headerlen[1];
uint8_t service_type[1];
uint8_t total_length[2];
uint8_t identification[2];
uint8_t flags[1];
uint8_t frag_offset[1];
uint8_t time_to_live[1];
uint8_t protocol[1];
uint8_t ip_header_checksum[2];
uint8_t src_ip[4];
uint8_t dst_ip[4];
// udp header (8 byte)
unsigned char src_port[2];
unsigned char dst_port[2];
unsigned char udp_message_len[2];
unsigned char udp_checksum[2];
uint8_t src_port[2];
uint8_t dst_port[2];
uint8_t udp_message_len[2];
uint8_t udp_checksum[2];
} udp_header_type;
};

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware
URL: origin git@gitorious.psi.ch:sls_det_software/sls_detector_software.git
Repository Root: origin git@gitorious.psi.ch:sls_det_software/sls_detector_software.git
Repsitory UUID: 046a469b1e6582c4c55bd6eaeb4818b618d0a9a9
Revision: 833
Branch: separate_receiver
Repsitory UUID: 8c994ea0d538628b36a9497508960388816749fa
Revision: 848
Branch: master
Last Changed Author: Maliakal_Dhanya
Last Changed Rev: 833
Last Changed Date: 2014-06-03 12:26:45 +0200
Last Changed Rev: 848
Last Changed Date: 2014-08-08 14:03:30 +0200

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/gotthardDetectorServer
URL: origin git@gitorious.psi.ch:sls_det_software/sls_detector_software.git/gotthardDetectorServer
Repository Root: origin git@gitorious.psi.ch:sls_det_software/sls_detector_software.git
Repsitory UUID: 046a469b1e6582c4c55bd6eaeb4818b618d0a9a9
Revision: 169
Branch: separate_receiver
Repsitory UUID: 8c994ea0d538628b36a9497508960388816749fa
Revision: 172
Branch: master
Last Changed Author: Maliakal_Dhanya
Last Changed Rev: 14
Last Changed Date: 2014-06-03 12:26:45 +0200
Last Changed Rev: 278
Last Changed Date: 2014-08-08 14:03:30 +0200

View File

@ -1,11 +1,11 @@
//#define SVNPATH ""
#define SVNURL "git@gitorious.psi.ch:sls_det_software/sls_detector_software.git/gotthardDetectorServer"
//#define SVNREPPATH ""
#define SVNREPUUID "046a469b1e6582c4c55bd6eaeb4818b618d0a9a9"
//#define SVNREV 0x14
#define SVNREPUUID "8c994ea0d538628b36a9497508960388816749fa"
//#define SVNREV 0x278
//#define SVNKIND ""
//#define SVNSCHED ""
#define SVNAUTH "Maliakal_Dhanya"
#define SVNREV 0x14
#define SVNDATE 0x20140603
#define SVNREV 0x278
#define SVNDATE 0x20140808
//

View File

@ -1012,7 +1012,7 @@ int set_dac(int file_des) {
n = sendDataOnly(file_des,&ret,sizeof(ret));
if (ret!=FAIL) {
/* send return argument */
n += sendDataOnly(file_des,&retval,sizeof(retval));
n += sendDataOnly(file_des,retval,sizeof(retval));
} else {
n += sendDataOnly(file_des,mess,sizeof(mess));
}

View File

@ -51,7 +51,6 @@ int masterMode=NO_MASTER, syncMode=NO_SYNCHRONIZATION, timingMode=AUTO_TIMING;
enum externalSignalFlag signals[4]={EXT_SIG_OFF, EXT_SIG_OFF, EXT_SIG_OFF, EXT_SIG_OFF};
int withGotthard = 0;
#ifdef MCB_FUNCS
extern const int nChans;
@ -286,10 +285,7 @@ int cleanFifo(){
printf("Cleaning FIFO\n");
addr=ADC_SYNC_REG;
if(withGotthard)
adc_sync = GOTTHARD_ADCSYNC_VAL;
else
adc_sync = ADCSYNC_VAL;
adc_sync = ADCSYNC_VAL;
reg = bus_r(addr) & CLEAN_FIFO_MASK;
@ -1404,19 +1400,7 @@ int setADC(int adc){
setDAQRegister();//token timing
cleanFifo();//adc sync
//with gotthard module
if(withGotthard){
//set packet size
ipPacketSize= DEFAULT_IP_PACKETSIZE;
udpPacketSize=DEFAULT_UDP_PACKETSIZE;
//set channel mask
nchips = GOTTHARDNCHIP;
nchans = GOTTHARDNCHAN;
mask = ACTIVE_ADC_MASK;
}
//with moench module all adc
else{/* if(adc==-1){*/
/* if(adc==-1){*/
//set packet size
ipPacketSize= DEFAULT_IP_PACKETSIZE;
udpPacketSize=DEFAULT_UDP_PACKETSIZE;
@ -1424,7 +1408,7 @@ int setADC(int adc){
nchips = NCHIP;
nchans = NCHANS;
mask = ACTIVE_ADC_MASK;
}/*
/*
//with moench module 1 adc -- NOT IMPLEMENTED
else{
ipPacketSize= ADC1_IP_PACKETSIZE;

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/moenchDetectorServer
URL: origin git@gitorious.psi.ch:sls_det_software/sls_detector_software.git/moenchDetectorServer
Repository Root: origin git@gitorious.psi.ch:sls_det_software/sls_detector_software.git
Repsitory UUID: 046a469b1e6582c4c55bd6eaeb4818b618d0a9a9
Revision: 55
Branch: separate_receiver
Repsitory UUID: 8c994ea0d538628b36a9497508960388816749fa
Revision: 57
Branch: master
Last Changed Author: Maliakal_Dhanya
Last Changed Rev: 14
Last Changed Date: 2014-06-03 12:26:45 +0200
Last Changed Rev: 278
Last Changed Date: 2014-08-08 14:03:30 +0200

View File

@ -1,11 +1,11 @@
//#define SVNPATH ""
#define SVNURL "git@gitorious.psi.ch:sls_det_software/sls_detector_software.git/moenchDetectorServer"
//#define SVNREPPATH ""
#define SVNREPUUID "046a469b1e6582c4c55bd6eaeb4818b618d0a9a9"
//#define SVNREV 0x14
#define SVNREPUUID "8c994ea0d538628b36a9497508960388816749fa"
//#define SVNREV 0x278
//#define SVNKIND ""
//#define SVNSCHED ""
#define SVNAUTH "Maliakal_Dhanya"
#define SVNREV 0x14
#define SVNDATE 0x20140603
#define SVNREV 0x278
#define SVNDATE 0x20140808
//

View File

@ -513,7 +513,6 @@ int set_one_dac(int imod) {
bit=value & (1<<(15-ibit));
if (bit) {
putout("0000010001000000",imod);
putout("0000011001000000",imod);
putout("0000010001000000",imod);
#ifdef DEBUGOUT
fprintf(stdout,"1");
@ -551,15 +550,15 @@ int initDACbyIndex(int ind,int val, int imod) {
int ref=partref[ind];
int r1=partr1[ind];
int r2=partr2[ind];
int retval[2];
v=(val+(val-ref)*r1/r2)*DAC_DR/DAC_MAX;
v=initDACbyIndexDACU(ind,v,imod);
v=initDACbyIndexDACU(ind,v,imod,0,retval);
return (v*DAC_MAX/DAC_DR+ref*r1/r2)/(1+r1/r2);
}
int initDACbyIndexDACU(int ind, int val, int imod) {
int initDACbyIndexDACU(int ind, int val, int imod, int mV, int retval[]) {
// const double daccs[NDAC]=DACCS;
// const double dacaddr[NDAC]=DACADDR;
@ -568,6 +567,8 @@ int initDACbyIndexDACU(int ind, int val, int imod) {
// int addr=dacaddr[ind];
// int iv;
int im;
if(mV)
val = (val*4096)/2500;
if (val>=0)
initDAC(ind,val, imod);
@ -598,124 +599,12 @@ int initDACbyIndexDACU(int ind, int val, int imod) {
#ifdef VERBOSE
printf("returning %d\n",setDACRegister(ind, -1, 0));
#endif
return setDACRegister(ind, -1, 0);
retval[0] = setDACRegister(ind, -1, 0);
retval[1] = (retval[0]*2500)/4096;
return retval[0];
}
}
int getThresholdEnergy() {
double g[3]=DEFAULTGAIN;
double o[3]=DEFAULTOFFSET;
double myg=-1, myo=-1;
// int dacu;
int imod;
int ethr=-1;
int ret=FAIL;
if (detectorModules) {
// for (imod=0; imod<getNModBoard(); imod++) {
for (imod=0; imod<nModX; imod++) {
#ifdef VERBOSE
printf("module=%d settings=%d, gain=%f, offset=%f\n",imod,thisSettings, (detectorModules+imod)->gain,(detectorModules+imod)->offset);
#endif
if ((detectorModules+imod)->gain>0)
myg=(detectorModules+imod)->gain;
else {
if (thisSettings>=0 && thisSettings<3)
myg=g[thisSettings];
// else
//myg=-1;
}
if ((detectorModules+imod)->offset>0)
myo=(detectorModules+imod)->offset;
else {
if (thisSettings>=0 && thisSettings<3)
myo=o[thisSettings];
// else
//myo=-1;
}
if (myg>0 && myo>0) {
//ethr=(myo-detectorDacs[VTHRESH+imod*NDAC])*1000/myg;
ethr=(myo-setDACRegister(VDAC0,-1,imod))*1000/myg;//edited by dhanya
// else
// ethr=-1;
}
#ifdef VERBOSE
//printf("module=%d gain=%f, offset=%f, dacu=%f\n",imod, myg, myo, detectorDacs[VTHRESH+imod*NDAC]);
printf("module=%d gain=%f, offset=%f, dacu=%d\n",imod, myg, myo,(int)(setDACRegister(VDAC0,-1,imod)));//edited by dhanya
printf("Threshold energy of module %d is %d eV\n", imod, ethr);
#endif
if (imod==0)
ret=ethr;
else {
if (ethr>(ret+100) || ethr<(ret-100))
return FAIL;
}
}
}
return ret;
}
int setThresholdEnergy(int ethr) {
double g[3]=DEFAULTGAIN;
double o[3]=DEFAULTOFFSET;
double myg=-1, myo=-1;
int dacu;
int imod;
int ret=ethr;
setSettings(GET_SETTINGS,-1);//-1 added by dhanya
if (thisSettings>=0 || thisSettings<3){
myg=g[thisSettings];
myo=o[thisSettings];
}
for (imod=0; imod<nModX; imod++) {
if (detectorModules) {
if ((detectorModules+imod)->gain>0)
myg=(detectorModules+imod)->gain;
else
if (thisSettings>=0 && thisSettings<3)
myg=g[thisSettings];
else
myg=-1;
if ((detectorModules+imod)->offset>0)
myo=(detectorModules+imod)->offset;
else
if (thisSettings>=0 && thisSettings<3)
myo=o[thisSettings];
else
myo=-1;
} else {
if (thisSettings>=0 && thisSettings<3)
myo=o[thisSettings];
else
myo=-1;
if (thisSettings>=0 && thisSettings<3)
myg=g[thisSettings];
else
myg=-1;
}
if (myg>0 && myo>0) {
dacu=myo-myg*((double)ethr)/1000.;
#ifdef VERBOSE
printf("module %d (%x): gain %f, off %f, energy %d eV, dac %d\n",imod,(unsigned int)((detectorModules+imod)),(detectorModules+imod)->gain,(detectorModules+imod)->offset, ethr,dacu);
#endif
} else {
dacu=ethr;
#ifdef VERBOSE
printf("could not set threshold energy for module %d, settings %d (offset is %f; gain is %f)\n",imod,thisSettings,myo,myg);
#endif
}
initDACbyIndexDACU(VDAC0, dacu, imod); ///needs to be fixed dhanya
}
return ret;
}
int getDACbyIndexDACU(int ind, int imod) {
/*
@ -2585,19 +2474,9 @@ ROI* setROI(int n, ROI arg[], int *retvalsize, int *ret){
int i,adc;
ROI temp;
/*
if(n>=0){
//clear rois
for(i=0;i<MAX_ROIS;i++)
rois[i]=temp;
/*ideal way to set roi
for(i=0;i<n;i++)
rois[i]=arg[i];
nROI = n;
*/
if(n==0)
adc=-1;
else{
@ -2633,7 +2512,7 @@ ROI* setROI(int n, ROI arg[], int *retvalsize, int *ret){
//set adc of interest
setADC(adc);
}
}*/
//#ifdef VERBOSE
printf("Rois:\n");

View File

@ -109,10 +109,9 @@ int initDAC(int dac_addr, int value,int imod );
int initDACs(int* v,int imod );
int setSettings(int i,int imod);
int initDACbyIndex(int ind,int val, int imod);
int initDACbyIndexDACU(int ind,int val, int imod);
int initDACbyIndexDACU(int ind,int val, int imod, int mV, int retval[]);
int getDACbyIndexDACU(int ind, int imod);
int getThresholdEnergy();
int setThresholdEnergy(int ethr);
/* Other DAC index routines*/
int getTemperatureByModule(int tempSensor, int imod);

View File

@ -25,7 +25,6 @@ int main(int argc, char *argv[])
int retval=OK;
int sd, fd;
int iarg;
int checkType = 1;
for(iarg=1; iarg<argc; iarg++){
@ -40,20 +39,6 @@ int main(int argc, char *argv[])
return 1;
}
}
else if(!strcasecmp(argv[iarg],"-test")){
if(argc==iarg+1){
printf("No test condition given. Exiting.\n");
return 1;
}
if(!strcasecmp(argv[iarg+1],"with_gotthard")){
checkType = 0;
}else{
printf("could not decode test condition. Possible arguments: with_gotthard. Exiting\n");
return 1;
}
}
}
@ -71,10 +56,7 @@ int main(int argc, char *argv[])
//control server
else {
portno = DEFAULT_PORTNO;
if(checkType)
sprintf(cmd,"%s %d stopserver &",argv[0],DEFAULT_PORTNO+1);
else
sprintf(cmd,"%s %d stopserver -test with_gotthard &",argv[0],DEFAULT_PORTNO+1);
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);
@ -83,7 +65,7 @@ int main(int argc, char *argv[])
}
init_detector(b, checkType);
init_detector(b);
sd=bindSocket(portno);

View File

@ -16,9 +16,7 @@
#define NDAC 8
#define NADC 1
/**when moench readout tested with gotthard module*/
#define GOTTHARDNCHAN 128
#define GOTTHARDNCHIP 10

View File

@ -54,10 +54,8 @@ char mess[1000];
int digitalTestBit = 0;
extern int withGotthard;
int init_detector(int b, int checkType) {
int init_detector(int b) {
if (mapCSP0()==FAIL) { printf("Could not map memory\n");
exit(1);
}
@ -69,21 +67,13 @@ int init_detector(int b, int checkType) {
//confirm if it is really moench
if(((bus_r(PCB_REV_REG) & DETECTOR_TYPE_MASK)>>DETECTOR_TYPE_OFFSET) != MOENCH_MODULE ){
if(checkType){
printf("This is a Gotthard detector. Exiting Moench Server.\n\n");
exit(-1);
}
//no check required as specified in command line arguments
else if(b){
printf("***This is a GOTTHARD detector with %d chips per module***\n",GOTTHARDNCHIP);
printf("***Assuming this to be a MOENCH detector***\n");
}
withGotthard = 1;
} else if(b){
printf("***This is a MOENCH detector with %d chips per module***\n",NCHIP);
printf("This is a Gotthard detector. Exiting Moench Server.\n\n");
exit(-1);
}
if (b) {
printf("***This is a MOENCH detector with %d chips per module***\n",NCHIP);
#ifdef MCB_FUNCS
printf("\nBoard Revision:0x%x\n",(bus_r(PCB_REV_REG)&BOARD_REVISION_MASK));
initDetector();
@ -914,13 +904,15 @@ int read_register(int file_des) {
int set_dac(int file_des) {
//default:all mods
int retval;
int retval[2];retval[1]=-1;
int temp;
int ret=OK;
int arg[3];
enum dacIndex ind;
int imod;
int n;
int val;
int mV;
int idac=0;
sprintf(mess,"Can't set DAC\n");
@ -932,6 +924,7 @@ int set_dac(int file_des) {
}
ind=arg[0];
imod=arg[1];
mV=arg[2];
n = receiveDataOnly(file_des,&val,sizeof(val));
if (n < 0) {
@ -990,45 +983,50 @@ int set_dac(int file_des) {
ret=FAIL;
sprintf(mess,"Detector locked by %s\n",lastClientIP);
} else{
if(idac==HIGH_VOLTAGE)
retval=initHighVoltageByModule(val,imod);
else
retval=initDACbyIndexDACU(idac,val,imod);
if(idac==HIGH_VOLTAGE){
retval[0]=initHighVoltageByModule(val,imod);
ret=FAIL;
if(retval[0]==-2)
strcpy(mess,"Invalid Voltage.Valid values are 0,90,110,120,150,180,200");
else if(retval[0]==-3)
strcpy(mess,"Weird value read back or it has not been set yet\n");
else
ret=OK;
}else{
initDACbyIndexDACU(idac,val,imod,mV,retval);
ret=FAIL;
if(mV)
temp = retval[1];
else
temp = retval[0];
if ((abs(temp-val)<=3) || val==-1) {
ret=OK;
#ifdef VERBOSE
printf("DAC set to %d in dac units and %d mV\n", retval[0],retval[1]);
#endif
}
}
}
}
if(ret==OK){
ret=FAIL;
if(idac==HIGH_VOLTAGE){
if(retval==-2)
strcpy(mess,"Invalid Voltage.Valid values are 0,90,110,120,150,180,200");
else if(retval==-3)
strcpy(mess,"Weird value read back or it has not been set yet\n");
else
ret=OK;
}//since v r saving only msb
else if ((retval-val)<=3 || val==-1)
ret=OK;
}
#endif
#ifdef VERBOSE
printf("DAC set to %d V\n", retval);
#endif
if(ret==FAIL)
printf("Setting dac %d of module %d: wrote %d but read %d\n", ind, imod, val, retval);
printf("Setting dac %d of module %d: wrote %d but read %d\n", ind, imod, val, temp);
else{
if (differentClients)
ret=FORCE_UPDATE;
}
/* send answer */
/* send OK/failed */
n = sendDataOnly(file_des,&ret,sizeof(ret));
if (ret!=FAIL) {
/* send return argument */
n += sendDataOnly(file_des,&retval,sizeof(retval));
n += sendDataOnly(file_des,retval,sizeof(retval));
} else {
n += sendDataOnly(file_des,mess,sizeof(mess));
}
@ -1610,7 +1608,7 @@ int get_threshold_energy(int file_des) {
n += sendDataOnly(file_des,mess,sizeof(mess));
/*return ok/fail*/
return OK;
return ret;
}
@ -1631,7 +1629,7 @@ int set_threshold_energy(int file_des) {
n += sendDataOnly(file_des,mess,sizeof(mess));
/*return ok/fail*/
return OK;
return ret;
}

View File

@ -23,7 +23,7 @@ int sockfd;
int function_table();
int decode_function(int);
int init_detector(int,int);
int init_detector(int);
int M_nofunc(int);
int exit_server(int);

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/mythenDetectorServer
URL: origin git@gitorious.psi.ch:sls_det_software/sls_detector_software.git/mythenDetectorServer
Repository Root: origin git@gitorious.psi.ch:sls_det_software/sls_detector_software.git
Repsitory UUID: 046a469b1e6582c4c55bd6eaeb4818b618d0a9a9
Revision: 87
Branch: separate_receiver
Repsitory UUID: 8c994ea0d538628b36a9497508960388816749fa
Revision: 89
Branch: master
Last Changed Author: Maliakal_Dhanya
Last Changed Rev: 14
Last Changed Date: 2014-06-03 12:26:45 +0200
Last Changed Rev: 278
Last Changed Date: 2014-08-08 14:03:30 +0200

View File

@ -1,11 +1,11 @@
//#define SVNPATH ""
#define SVNURL "git@gitorious.psi.ch:sls_det_software/sls_detector_software.git/mythenDetectorServer"
//#define SVNREPPATH ""
#define SVNREPUUID "046a469b1e6582c4c55bd6eaeb4818b618d0a9a9"
//#define SVNREV 0x14
#define SVNREPUUID "8c994ea0d538628b36a9497508960388816749fa"
//#define SVNREV 0x278
//#define SVNKIND ""
//#define SVNSCHED ""
#define SVNAUTH "Maliakal_Dhanya"
#define SVNREV 0x14
#define SVNDATE 0x20140603
#define SVNREV 0x278
#define SVNDATE 0x20140808
//

View File

@ -1,11 +1,11 @@
//#define SVNPATH ""
#define SVNURLLIB "git@gitorious.psi.ch:sls_det_software/sls_detector_software.git"
//#define SVNREPPATH ""
#define SVNREPUUIDLIB "046a469b1e6582c4c55bd6eaeb4818b618d0a9a9"
//#define SVNREV 0x833
#define SVNREPUUIDLIB "8c994ea0d538628b36a9497508960388816749fa"
//#define SVNREV 0x848
//#define SVNKIND ""
//#define SVNSCHED ""
#define SVNAUTHLIB "Maliakal_Dhanya"
#define SVNREVLIB 0x833
#define SVNDATELIB 0x20140603
#define SVNREVLIB 0x848
#define SVNDATELIB 0x20140808
//

View File

@ -24,14 +24,16 @@ int main(int argc, char *argv[]){
int sd, fd;
#ifdef STOP_SERVER
char cmd[100];
if (argc==1) {
#endif
if (argc==1) {
//#endif
portno = DEFAULT_PORTNO;
printf("opening control server on port %d\n",portno );
b=1;
#ifdef STOP_SERVER
sprintf(cmd,"%s %d &",argv[0],DEFAULT_PORTNO+1);
system(cmd);
#endif
} else {
portno = DEFAULT_PORTNO+1;
if ( sscanf(argv[1],"%d",&portno) ==0) {
@ -41,7 +43,7 @@ int main(int argc, char *argv[]){
printf("opening stop server on port %d\n",portno);
b=0;
}
#endif
//#endif
init_detector(b); //defined in slsDetectorServer_funcs

View File

@ -52,6 +52,12 @@ int init_detector(int b) {
#ifdef SLS_DETECTOR_FUNCTION_LIST
initDetector();
#endif
}else{
Feb_Interface_FebInterface();
Feb_Control_FebControl();
printf("FEb control constructor done\n");
/* Beb_Beb(-1);
printf("BEB constructor done\n");*/
}
strcpy(mess,"dummy message");
strcpy(lastClientIP,"none");
@ -1970,8 +1976,9 @@ int set_settings(int file_des) {
}
imod=arg[1];
isett=arg[0];
printf("isett:%d, imod =%d\n",isett,imod);
#ifdef VERBOSE
printf("In set_settings, isett:%d, imod =%d\n",isett,imod);
#endif
#ifdef SLS_DETECTOR_FUNCTION_LIST
if (imod>=getTotalNumberOfModules()) {
ret=FAIL;
@ -2262,11 +2269,11 @@ int get_run_status(int file_des) {
enum runStatus s;
sprintf(mess,"getting run status\n");
#ifdef VERBOSE
//#ifdef VERBOSE
printf("Getting status\n");
#endif
//#endif
#ifdef SLS_DETECTOR_FUNCTION_LIST
s= getRunStatus();
s= getRunStatus();printf("status:%d\n");
#endif
if (ret!=OK) {
@ -2452,6 +2459,7 @@ int set_timer(int file_des) {
sprintf(mess, "could not allocate RAM for %lld frames\n", tns);
}
#endif
if (differentClients)
ret=FORCE_UPDATE;
}
@ -2709,6 +2717,7 @@ int set_roi(int file_des) {
#ifndef GOTTHARDD
ret = FAIL;
strcpy(mess,"Not applicable/implemented for this detector\n");
printf("Error:Set ROI-%s",mess);
#else
#ifdef VERBOSE
printf("Setting ROI to:");
@ -3007,11 +3016,13 @@ int configure_mac(int file_des) {
printf("\n");
printf("Configuring MAC of module %d at port %x\n", imod, udpport);
#endif
printf("ret:%d\n",ret);
#ifdef SLS_DETECTOR_FUNCTION_LIST
if (ret==OK) {
if(getRunStatus() == RUNNING)
if(getRunStatus() == RUNNING){
stopStateMachine();
}
retval=configureMAC(ipad,imacadd,idetectormacadd,detipad,udpport,0); /*digitalTestBit);*/
if(retval==-1) ret=FAIL;
}
@ -3396,9 +3407,9 @@ int enable_ten_giga(int file_des) {
}
/* execute action */
if(ret != FAIL){
//#ifdef VERBOSE
#ifdef VERBOSE
printf("Enabling 10Gbe :%d \n",arg);
//#endif
#endif
#ifdef SLS_DETECTOR_FUNCTION_LIST
retval=enableTenGigabitEthernet(arg);
if((arg != -1) && (retval != arg))