mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-21 09:08:00 +02:00
Added common socket interface for the server
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@174 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
1
slsDetectorSoftware/slsDetectorServer/communication_funcs.c
Symbolic link
1
slsDetectorSoftware/slsDetectorServer/communication_funcs.c
Symbolic link
@ -0,0 +1 @@
|
||||
../commonFiles/communication_funcs.c
|
1
slsDetectorSoftware/slsDetectorServer/communication_funcs.h
Symbolic link
1
slsDetectorSoftware/slsDetectorServer/communication_funcs.h
Symbolic link
@ -0,0 +1 @@
|
||||
../commonFiles/communication_funcs.h
|
121
slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h
Normal file
121
slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h
Normal file
@ -0,0 +1,121 @@
|
||||
#ifndef SLS_DETECTOR_FUNCTION_LIST
|
||||
#define SLS_DETECTOR_FUNCTION_LIST
|
||||
|
||||
#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>
|
||||
|
||||
/****************************************************
|
||||
This functions are used by the slsDetectroServer_funcs interface.
|
||||
Here are the definitions, but the actual implementation should be done for each single detector.
|
||||
|
||||
****************************************************/
|
||||
|
||||
//if b>0 all the detector must be initialized, otherwise it is just the stop server
|
||||
int initializeDetector(int b);
|
||||
|
||||
/**
|
||||
sets number of modules
|
||||
\param nm number of modules (-1 gets)
|
||||
\param dim dimension
|
||||
\returns number of modules
|
||||
|
||||
will probably be changed in set ROI mask
|
||||
*/
|
||||
int setNMod(int nm, enum dimension dim);
|
||||
|
||||
/**
|
||||
returns the maximum number of modules in one dimension
|
||||
\param arg dimension
|
||||
\returns max number of modules of the baord
|
||||
*/
|
||||
int getNModBoard(enum dimension arg);
|
||||
|
||||
enum externalSignalFlag getExtSignal(int signalindex);
|
||||
enum externalSignalFlag setExtSignal(int signalindex, enum externalSignalFlag flag);
|
||||
enum externalCommunicationMode setTiming( enum externalCommunicationMode arg);
|
||||
int64_t getModuleId(enum idMode arg, int imod);
|
||||
int64_t getDetectorId(enum idMode arg);
|
||||
|
||||
|
||||
int moduleTest( enum digitalTestMode arg, int imod);
|
||||
int detectorTest( enum digitalTestMode arg);
|
||||
|
||||
//write register
|
||||
int bus_w(int addr,int val);
|
||||
//read register
|
||||
int bus_r(int addr);
|
||||
|
||||
float setDAC(enum dacIndex ind, float val, int imod);
|
||||
float getADC(enum dacIndex ind, int imod);
|
||||
|
||||
int setChannel(sls_detector_channel myChan);
|
||||
int getChannel(sls_detector_channel *myChan);
|
||||
|
||||
int setChip(sls_detector_chip myChip);
|
||||
int getChip(sls_detector_chip *myChip);
|
||||
|
||||
int setModule(sls_detector_module myChan);
|
||||
int getModule(sls_detector_module *myChan);
|
||||
int getThresholdEnergy(int imod);
|
||||
int setThresholdEnergy(int thr, int imod);
|
||||
|
||||
enum detectorSettings setSettings(enum detectorSettings sett, int imod);
|
||||
|
||||
int startAcquisition();
|
||||
int stopAcquisition();
|
||||
int startReadOut();
|
||||
|
||||
|
||||
enum runStatus getRunStatus();
|
||||
char *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 mask); //////?????????????????
|
||||
int getROI(int *mask); //////////?????????????????????
|
||||
|
||||
|
||||
int setSpeed(enum speedVariable arg, int val);
|
||||
enum readOutFlags setReadOutFlags(enum readOutFlags val);
|
||||
|
||||
|
||||
int executeTrimming(enum trimMode mode, int par1, int par2, int imod);
|
||||
enum masterFlags setMaster(enum masterFlags arg);
|
||||
enum synchronizationMode setSynchronization(enum synchronizationMode arg);
|
||||
|
||||
|
||||
|
||||
int configureMAC(int ipad, long long int imacadd, long long int iservermacadd, int dtb);
|
||||
int loadImage(enum imageType index, char *imageVals);
|
||||
int readCounterBlock(int startACQ, char *counterVals);
|
||||
int resetCounterBlock(int startACQ);
|
||||
|
||||
int calculateDataBytes();
|
||||
|
||||
int getTotalNumberOfChannels();
|
||||
int getTotalNumberOfChips();
|
||||
int getTotalNumberOfModules();
|
||||
int getNumberOfChannelsPerChip();
|
||||
int getNumberOfChannelsPerChip();
|
||||
int getNumberOfChannelsPerModule();
|
||||
int getNumberOfChipsPerModule();
|
||||
int getNumberOfDACsPerModule();
|
||||
int getNumberOfADCsPerModule();
|
||||
|
||||
|
||||
#endif
|
91
slsDetectorSoftware/slsDetectorServer/slsDetectorServer.c
Executable file
91
slsDetectorSoftware/slsDetectorServer/slsDetectorServer.c
Executable file
@ -0,0 +1,91 @@
|
||||
/* A simple server in the internet domain using TCP
|
||||
The port number is passed as an argument */
|
||||
#include "communication_funcs.h"
|
||||
#include "server_funcs.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
extern int sockfd;
|
||||
|
||||
|
||||
void error(char *msg)
|
||||
{
|
||||
perror(msg);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int portno, b;
|
||||
char cmd[100];
|
||||
int retval=OK;
|
||||
int sd, fd;
|
||||
|
||||
|
||||
if (argc==1) {
|
||||
portno = DEFAULT_PORTNO;
|
||||
sprintf(cmd,"%s %d &",argv[0],DEFAULT_PORTNO+1);
|
||||
printf("opening control server on port %d\n",portno );
|
||||
system(cmd);
|
||||
b=1;
|
||||
} else {
|
||||
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("opening stop server on port %d\n",portno);
|
||||
}
|
||||
|
||||
|
||||
|
||||
init_detector(b); //defined in server_funcs
|
||||
|
||||
|
||||
sd=bindSocket(portno); //defined in communication_funcs
|
||||
|
||||
sockfd=sd;
|
||||
|
||||
|
||||
if (getServerError(sd)) { //defined in communication_funcs
|
||||
printf("server error!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* assign function table */
|
||||
function_table(); //defined in server_funcs
|
||||
#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); //defined in communication_funcs
|
||||
#ifdef VERY_VERBOSE
|
||||
printf("Conenction accepted\n");
|
||||
#endif
|
||||
if (fd>0) {
|
||||
retval=decode_function(fd); //defined in server_funcs
|
||||
#ifdef VERY_VERBOSE
|
||||
printf("function executed\n");
|
||||
#endif
|
||||
closeConnection(fd); //defined in communication_funcs
|
||||
#ifdef VERY_VERBOSE
|
||||
printf("connection closed\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
exitServer(sockfd); //defined in communication_funcs
|
||||
printf("Goodbye!\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
2777
slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c
Executable file
2777
slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c
Executable file
File diff suppressed because it is too large
Load Diff
82
slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.h
Executable file
82
slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.h
Executable file
@ -0,0 +1,82 @@
|
||||
#ifndef SERVER_FUNCS_H
|
||||
#define SERVER_FUNCS_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 configure_mac(int);
|
||||
int load_image(int);
|
||||
int read_counter_block(int);
|
||||
int reset_counter_block(int);
|
||||
int update_client(int);
|
||||
int send_update(int);
|
||||
|
||||
#endif
|
1
slsDetectorSoftware/slsDetectorServer/sls_detector_defs.h
Symbolic link
1
slsDetectorSoftware/slsDetectorServer/sls_detector_defs.h
Symbolic link
@ -0,0 +1 @@
|
||||
../commonFiles/sls_detector_defs.h
|
1
slsDetectorSoftware/slsDetectorServer/sls_detector_funcs.h
Symbolic link
1
slsDetectorSoftware/slsDetectorServer/sls_detector_funcs.h
Symbolic link
@ -0,0 +1 @@
|
||||
../commonFiles/sls_detector_funcs.h
|
Reference in New Issue
Block a user