mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 13:27:14 +02:00
void pointers added to callback functions
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@199 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
@ -80,7 +80,7 @@ LATEX_HIDE_INDICES = YES
|
|||||||
|
|
||||||
PREDEFINED = __cplusplus
|
PREDEFINED = __cplusplus
|
||||||
|
|
||||||
INPUT = slsDetector/slsDetectorBase.h commonFiles/sls_detector_defs.h slsDetector/slsDetector.h MySocketTCP/MySocketTCP.h usersFunctions/usersFunctions.h multiSlsDetector/multiSlsDetector.h commonFiles/sls_detector_defs.h slsDetector/slsDetectorUtils.h slsDetector/slsDetectorBase.h slsDetector/slsDetectorCommand.h slsDetector/slsDetectorActions.h multiSlsDetector/multiSlsDetector.h slsDetectorAnalysis/detectorData.h slsDetectorAnalysis/energyConversion.h slsDetectorAnalysis/postProcessing.h slsDetectorAnalysis/angularConversion.h slsDetectorAnalysis/fileIO.h
|
INPUT = slsDetector/slsDetectorUsers.h slsDetector/slsDetectorBase.h commonFiles/sls_detector_defs.h slsDetector/slsDetector.h MySocketTCP/MySocketTCP.h usersFunctions/usersFunctions.h multiSlsDetector/multiSlsDetector.h commonFiles/sls_detector_defs.h slsDetector/slsDetectorUtils.h slsDetector/slsDetectorBase.h slsDetector/slsDetectorCommand.h slsDetector/slsDetectorActions.h multiSlsDetector/multiSlsDetector.h slsDetectorAnalysis/detectorData.h slsDetectorAnalysis/energyConversion.h slsDetectorAnalysis/postProcessing.h slsDetectorAnalysis/angularConversion.h slsDetectorAnalysis/fileIO.h multiSlsDetector/multiSlsDetectorClient.h multiSlsDetector/multiSlsDetectorCommand.h
|
||||||
|
|
||||||
OUTPUT_DIRECTORY = docs
|
OUTPUT_DIRECTORY = docs
|
||||||
|
|
||||||
|
@ -99,6 +99,7 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1)
|
|||||||
id++;
|
id++;
|
||||||
}
|
}
|
||||||
id--;
|
id--;
|
||||||
|
|
||||||
if (thisMultiDetector->alreadyExisting==0) {
|
if (thisMultiDetector->alreadyExisting==0) {
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@ class multiSlsDetectorClient {
|
|||||||
};
|
};
|
||||||
del=1;
|
del=1;
|
||||||
} \
|
} \
|
||||||
|
cout << "multislsdetector id "<< id << endl; \
|
||||||
iv=sscanf(argv[0],"%d:%s",&pos, cmd); \
|
iv=sscanf(argv[0],"%d:%s",&pos, cmd); \
|
||||||
if (iv==2 && pos>=0) { \
|
if (iv==2 && pos>=0) { \
|
||||||
argv[0]=cmd; \
|
argv[0]=cmd; \
|
||||||
|
@ -30,13 +30,15 @@ class multiSlsDetectorCommand : public slsDetectorCommand {
|
|||||||
|
|
||||||
string executeLine(int narg, char *args[], int action, int id=-1) { \
|
string executeLine(int narg, char *args[], int action, int id=-1) { \
|
||||||
string s; \
|
string s; \
|
||||||
|
printf("mess %d of %d\n",id, myDet->getNumberOfDetectors()); \
|
||||||
if (id>=0) {
|
if (id>=0) {
|
||||||
slsDetector *d=myDet->getSlsDetector(id); \
|
slsDetector *d=myDet->getSlsDetector(id); \
|
||||||
if (d) { \
|
if (d) { \
|
||||||
slsDetectorCommand *cmd=new slsDetectorCommand(d); \
|
slsDetectorCommand *cmd=new slsDetectorCommand(d); \
|
||||||
s=cmd->executeLine(narg, args, action); \
|
s=cmd->executeLine(narg, args, action); \
|
||||||
delete cmd;
|
delete cmd;
|
||||||
} else s=string("detector does no exist"); \
|
} else
|
||||||
|
s=string("detector does no exist"); \
|
||||||
} else \
|
} else \
|
||||||
s=slsDetectorCommand::executeLine(narg,args,action); \
|
s=slsDetectorCommand::executeLine(narg,args,action); \
|
||||||
return s;
|
return s;
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
#ifndef SLS_DETECTOR_USERS_H
|
#ifndef SLS_DETECTOR_USERS_H
|
||||||
#define SLS_DETECTOR_USERS_H
|
#define SLS_DETECTOR_USERS_H
|
||||||
|
|
||||||
@ -354,32 +353,32 @@ class slsDetectorUsers
|
|||||||
\param func function for reading the detector position
|
\param func function for reading the detector position
|
||||||
*/
|
*/
|
||||||
|
|
||||||
virtual void registerGetPositionCallback( float (*func)(void))=0;
|
virtual void registerGetPositionCallback( float (*func)(void*),void *arg)=0;
|
||||||
/**
|
/**
|
||||||
@short register callback for connecting to the epics channels
|
@short register callback for connecting to the epics channels
|
||||||
\param func function for connecting to the epics channels
|
\param func function for connecting to the epics channels
|
||||||
*/
|
*/
|
||||||
virtual void registerConnectChannelsCallback( int (*func)(void))=0;
|
virtual void registerConnectChannelsCallback( int (*func)(void*),void *arg)=0;
|
||||||
/**
|
/**
|
||||||
@short register callback to disconnect the epics channels
|
@short register callback to disconnect the epics channels
|
||||||
\param func function to disconnect the epics channels
|
\param func function to disconnect the epics channels
|
||||||
*/
|
*/
|
||||||
virtual void registerDisconnectChannelsCallback( int (*func)(void))=0;
|
virtual void registerDisconnectChannelsCallback( int (*func)(void*),void *arg)=0;
|
||||||
/**
|
/**
|
||||||
@short register callback for moving the detector
|
@short register callback for moving the detector
|
||||||
\param func function for moving the detector
|
\param func function for moving the detector
|
||||||
*/
|
*/
|
||||||
virtual void registerGoToPositionCallback( int (*func)(float))=0;
|
virtual void registerGoToPositionCallback( int (*func)(float,void*),void *arg)=0;
|
||||||
/**
|
/**
|
||||||
@short register callback for moving the detector without waiting
|
@short register callback for moving the detector without waiting
|
||||||
\param func function for moving the detector
|
\param func function for moving the detector
|
||||||
*/
|
*/
|
||||||
virtual void registerGoToPositionNoWaitCallback( int (*func)(float))=0;
|
virtual void registerGoToPositionNoWaitCallback( int (*func)(float,void*),void *arg)=0;
|
||||||
/**
|
/**
|
||||||
@short register calbback reading to I0
|
@short register calbback reading to I0
|
||||||
\param func function for reading the I0 (called with parameter 0 before the acquisition, 1 after and the return value used as I0)
|
\param func function for reading the I0 (called with parameter 0 before the acquisition, 1 after and the return value used as I0)
|
||||||
*/
|
*/
|
||||||
virtual void registerGetI0Callback( float (*func)(int))=0;
|
virtual void registerGetI0Callback( float (*func)(int,void*),void *arg)=0;
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
|
|
||||||
|
@ -11,18 +11,18 @@ slsDetectorUtils::slsDetectorUtils() {
|
|||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "setting callbacks" << endl;
|
cout << "setting callbacks" << endl;
|
||||||
#endif
|
#endif
|
||||||
registerGetPositionCallback(&defaultGetPosition);
|
registerGetPositionCallback(&defaultGetPosition, NULL);
|
||||||
registerConnectChannelsCallback(&defaultConnectChannels);
|
registerConnectChannelsCallback(&defaultConnectChannels,NULL);
|
||||||
registerDisconnectChannelsCallback(&defaultDisconnectChannels);
|
registerDisconnectChannelsCallback(&defaultDisconnectChannels,NULL);
|
||||||
registerGoToPositionCallback(&defaultGoToPosition);
|
registerGoToPositionCallback(&defaultGoToPosition,NULL);
|
||||||
registerGoToPositionNoWaitCallback(&defaultGoToPositionNoWait);
|
registerGoToPositionNoWaitCallback(&defaultGoToPositionNoWait,NULL);
|
||||||
registerGetI0Callback(&defaultGetI0);
|
registerGetI0Callback(&defaultGetI0,NULL);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "done " << endl;
|
cout << "done " << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -45,8 +45,7 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
|
|
||||||
|
|
||||||
if ((*correctionMask&(1<< ANGULAR_CONVERSION)) || (*correctionMask&(1<< I0_NORMALIZATION))) {
|
if ((*correctionMask&(1<< ANGULAR_CONVERSION)) || (*correctionMask&(1<< I0_NORMALIZATION))) {
|
||||||
if (connect_channels())
|
connect_channels(NULL);
|
||||||
connect_channels();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -132,7 +131,7 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
if (*stoppedFlag==0) {
|
if (*stoppedFlag==0) {
|
||||||
if (*numberOfPositions>0) {
|
if (*numberOfPositions>0) {
|
||||||
if (go_to_position)
|
if (go_to_position)
|
||||||
go_to_position (detPositions[ip]);
|
go_to_position (detPositions[ip],NULL);
|
||||||
currentPositionIndex=ip+1;
|
currentPositionIndex=ip+1;
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "moving to position" << std::endl;
|
std::cout<< "moving to position" << std::endl;
|
||||||
@ -159,21 +158,21 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
if (*correctionMask&(1<< ANGULAR_CONVERSION)) {
|
if (*correctionMask&(1<< ANGULAR_CONVERSION)) {
|
||||||
pthread_mutex_lock(&mp);
|
pthread_mutex_lock(&mp);
|
||||||
if (get_position)
|
if (get_position)
|
||||||
currentPosition=get_position();
|
currentPosition=get_position(NULL);
|
||||||
posfinished=0;
|
posfinished=0;
|
||||||
pthread_mutex_unlock(&mp);
|
pthread_mutex_unlock(&mp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*correctionMask&(1<< I0_NORMALIZATION)) {
|
/* if (*correctionMask&(1<< I0_NORMALIZATION)) {
|
||||||
if (get_i0)
|
if (get_i0)
|
||||||
get_i0(0);
|
get_i0(0);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
startAndReadAll();
|
startAndReadAll();
|
||||||
|
|
||||||
if (*correctionMask&(1<< I0_NORMALIZATION)) {
|
if (*correctionMask&(1<< I0_NORMALIZATION)) {
|
||||||
if (get_i0)
|
if (get_i0)
|
||||||
currentI0=get_i0(1); // this is the correct i0!!!!!
|
currentI0=get_i0(1,NULL); // this is the correct i0!!!!!
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&mp);
|
pthread_mutex_lock(&mp);
|
||||||
@ -271,7 +270,7 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
|
|
||||||
if ((*correctionMask&(1<< ANGULAR_CONVERSION)) || (*correctionMask&(1<< I0_NORMALIZATION))) {
|
if ((*correctionMask&(1<< ANGULAR_CONVERSION)) || (*correctionMask&(1<< I0_NORMALIZATION))) {
|
||||||
if (disconnect_channels)
|
if (disconnect_channels)
|
||||||
disconnect_channels();
|
disconnect_channels(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,13 +520,13 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void registerGetPositionCallback( float (*func)(void)){get_position=func;};
|
void registerGetPositionCallback( float (*func)(void*),void *arg){get_position=func; POarg=arg;};
|
||||||
void registerConnectChannelsCallback( int (*func)(void)){connect_channels=func;};
|
void registerConnectChannelsCallback( int (*func)(void*),void *arg){connect_channels=func; CCarg=arg;};
|
||||||
void registerDisconnectChannelsCallback( int (*func)(void)){disconnect_channels=func;};
|
void registerDisconnectChannelsCallback(int (*func)(void*),void*arg){disconnect_channels=func;DCarg=arg;};
|
||||||
|
|
||||||
void registerGoToPositionCallback( int (*func)(float)){go_to_position=func;};
|
void registerGoToPositionCallback( int (*func)(float, void*),void *arg){go_to_position=func;GTarg=arg;};
|
||||||
void registerGoToPositionNoWaitCallback( int (*func)(float)){go_to_position_no_wait=func;};
|
void registerGoToPositionNoWaitCallback(int (*func)(float, void*),void*arg){go_to_position_no_wait=func;GTNarg=arg;};
|
||||||
void registerGetI0Callback( float (*func)(int)){get_i0=func;};
|
void registerGetI0Callback( float (*func)(int, void*),void *arg){get_i0=func;IOarg=arg;};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Saves the detector setup to file
|
Saves the detector setup to file
|
||||||
@ -565,12 +565,13 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
|||||||
|
|
||||||
int progressIndex;
|
int progressIndex;
|
||||||
|
|
||||||
float (*get_position)(void);
|
float (*get_position)(void*);
|
||||||
int (*go_to_position)(float);
|
int (*go_to_position)(float, void*);
|
||||||
int (*go_to_position_no_wait)(float);
|
int (*go_to_position_no_wait)(float, void*);
|
||||||
int (*connect_channels)(void);
|
int (*connect_channels)(void*);
|
||||||
int (*disconnect_channels)(void);
|
int (*disconnect_channels)(void*);
|
||||||
float (*get_i0)(int);
|
float (*get_i0)(int, void*);
|
||||||
|
void *POarg,*CCarg,*DCarg,*GTarg,*GTNarg,*IOarg;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ float i0=0;
|
|||||||
static double timeout = 3.0;
|
static double timeout = 3.0;
|
||||||
|
|
||||||
chid ch_pos,ch_i0, ch_getpos;
|
chid ch_pos,ch_i0, ch_getpos;
|
||||||
|
void *ch_arg,*ch_darg,*ch_parg,*ch_poarg,*ch_ioarg;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -138,7 +139,7 @@ float angle(int ichan, float encoder, float totalOffset, float conv_r, float cen
|
|||||||
|
|
||||||
/* reads the encoder and returns the position */
|
/* reads the encoder and returns the position */
|
||||||
|
|
||||||
float get_position() {
|
float get_position(void *ch_poarg) {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("Getting motor position \n");
|
printf("Getting motor position \n");
|
||||||
#endif
|
#endif
|
||||||
@ -168,7 +169,7 @@ float get_position() {
|
|||||||
/* moves the encoder to position p */
|
/* moves the encoder to position p */
|
||||||
|
|
||||||
|
|
||||||
int go_to_position(float p) {
|
int go_to_position(float p,void *ch_parg) {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("Setting motor position \n");
|
printf("Setting motor position \n");
|
||||||
#endif
|
#endif
|
||||||
@ -230,7 +231,7 @@ int go_to_position_no_wait(float p) {
|
|||||||
|
|
||||||
/* reads I0 and returns the intensity */
|
/* reads I0 and returns the intensity */
|
||||||
|
|
||||||
float get_i0() {
|
float get_i0(void *ch_ioarg) {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("Getting I0 readout \n");
|
printf("Getting I0 readout \n");
|
||||||
#endif
|
#endif
|
||||||
@ -257,7 +258,7 @@ float get_i0() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int connect_channels() {
|
int connect_channels(void *ch_arg) {
|
||||||
#ifdef EPICS
|
#ifdef EPICS
|
||||||
//double value = 256;
|
//double value = 256;
|
||||||
/* channel name */
|
/* channel name */
|
||||||
@ -278,7 +279,7 @@ int connect_channels() {
|
|||||||
//"ca_get X04SA-ES2-SC:CH6"
|
//"ca_get X04SA-ES2-SC:CH6"
|
||||||
|
|
||||||
/* open the channel by name and return ch_id */
|
/* open the channel by name and return ch_id */
|
||||||
status = connect_channel("X04SA-ES2-SC:CH6", &ch_i0);
|
status = connect_channel("NULLX04SA-ES2-SC:CH6", &ch_i0);
|
||||||
if (status == ECA_NORMAL)
|
if (status == ECA_NORMAL)
|
||||||
printf("I0 channel connected \n");
|
printf("I0 channel connected \n");
|
||||||
else {
|
else {
|
||||||
@ -307,7 +308,7 @@ int connect_channels() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int disconnect_channels() {
|
int disconnect_channels(void *ch_darg) {
|
||||||
#ifdef EPICS
|
#ifdef EPICS
|
||||||
/* close channel connect */
|
/* close channel connect */
|
||||||
disconnect_channel(ch_i0);
|
disconnect_channel(ch_i0);
|
||||||
|
@ -134,7 +134,7 @@ float defaultAngleFunction(float ichan, float encoder, float totalOffset, float
|
|||||||
|
|
||||||
/* reads the encoder and returns the position */
|
/* reads the encoder and returns the position */
|
||||||
|
|
||||||
float defaultGetPosition() {
|
float defaultGetPosition(void *d) {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("Getting motor position \n");
|
printf("Getting motor position \n");
|
||||||
#endif
|
#endif
|
||||||
@ -158,13 +158,14 @@ float defaultGetPosition() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
return pos;
|
return pos
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* moves the encoder to position p */
|
/* moves the encoder to position p */
|
||||||
|
|
||||||
|
|
||||||
int defaultGoToPosition(float p) {
|
int defaultGoToPosition(float p,void *d) {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("Setting motor position \n");
|
printf("Setting motor position \n");
|
||||||
#endif
|
#endif
|
||||||
@ -191,7 +192,7 @@ int defaultGoToPosition(float p) {
|
|||||||
|
|
||||||
/* moves the encoder to position p without waiting */
|
/* moves the encoder to position p without waiting */
|
||||||
|
|
||||||
int defaultGoToPositionNoWait(float p) {
|
int defaultGoToPositionNoWait(float p,void *d) {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("Setting motor position no wait \n");
|
printf("Setting motor position no wait \n");
|
||||||
#endif
|
#endif
|
||||||
@ -222,7 +223,7 @@ int defaultGoToPositionNoWait(float p) {
|
|||||||
|
|
||||||
/* reads I0 and returns the intensity */
|
/* reads I0 and returns the intensity */
|
||||||
|
|
||||||
float defaultGetI0(int t) {
|
float defaultGetI0(int t,void *d) {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("Getting I0 readout \n");
|
printf("Getting I0 readout \n");
|
||||||
#endif
|
#endif
|
||||||
@ -258,7 +259,7 @@ float defaultGetI0(int t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int defaultConnectChannels() {
|
int defaultConnectChannels(void*d) {
|
||||||
#ifdef EPICS
|
#ifdef EPICS
|
||||||
//double value = 256;
|
//double value = 256;
|
||||||
/* channel name */
|
/* channel name */
|
||||||
@ -308,7 +309,7 @@ int defaultConnectChannels() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int defaultDisconnectChannels() {
|
int defaultDisconnectChannels(void *d) {
|
||||||
#ifdef EPICS
|
#ifdef EPICS
|
||||||
/* close channel connect */
|
/* close channel connect */
|
||||||
disconnect_channel(ch_i0);
|
disconnect_channel(ch_i0);
|
||||||
|
@ -30,12 +30,12 @@ extern "C" {
|
|||||||
|
|
||||||
|
|
||||||
float defaultAngleFunction(float ichan, float encoder, float totalOffset, float conv_r, float center, float offset, float tilt, int direction);
|
float defaultAngleFunction(float ichan, float encoder, float totalOffset, float conv_r, float center, float offset, float tilt, int direction);
|
||||||
float defaultGetPosition();
|
float defaultGetPosition(void *d);
|
||||||
int defaultGoToPosition(float p);
|
int defaultGoToPosition(float p,void *d);
|
||||||
int defaultGoToPositionNoWait(float p);
|
int defaultGoToPositionNoWait(float p,void *d);
|
||||||
int defaultConnectChannels();
|
int defaultConnectChannels(void *d);
|
||||||
int defaultDisconnectChannels();
|
int defaultDisconnectChannels(void *d);
|
||||||
float defaultGetI0(int t);
|
float defaultGetI0(int t,void *d);
|
||||||
|
|
||||||
int defaultDataReadyFunc(detectorData* d, void* p);
|
int defaultDataReadyFunc(detectorData* d, void* p);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user