mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-11 04:17:15 +02:00
Raw data file write/read now uses absolute channel values in multidetector systems. Flat field and bad channel corrections and angular conversion debugged
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@135 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
@ -3,6 +3,8 @@
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
float pos;
|
||||
float i0=0;
|
||||
#ifdef EPICS
|
||||
|
||||
#include <cadef.h>
|
||||
@ -10,6 +12,11 @@
|
||||
|
||||
static double timeout = 3.0;
|
||||
|
||||
chid ch_pos,ch_i0, ch_getpos;
|
||||
|
||||
|
||||
|
||||
|
||||
/* connect to a PV */
|
||||
int connect_channel(const char *name, chid *ch_id) {
|
||||
int status = ECA_NORMAL;
|
||||
@ -88,44 +95,12 @@ int caput(chid ch_id, double value) {
|
||||
return status;
|
||||
}
|
||||
|
||||
/* int main(int argc, char *argv[]) { */
|
||||
/* double value = 256; */
|
||||
/* /\* channel name *\/ */
|
||||
/* const char *name = "ARIDI-PCT:CURRENT"; */
|
||||
/* /\* channel id *\/ */
|
||||
/* chid ch_id; */
|
||||
/* /\* status code *\/ */
|
||||
/* int status; */
|
||||
//int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
|
||||
|
||||
/* /\* init channel access context before any caget/put *\/ */
|
||||
/* ca_context_create(ca_enable_preemptive_callback); */
|
||||
|
||||
/* /\* open the channel by name and return ch_id *\/ */
|
||||
/* status = connect_channel(name, &ch_id); */
|
||||
/* if (status == ECA_NORMAL) */
|
||||
/* printf("channel connected %s\n", name); */
|
||||
/* else { */
|
||||
/* printf(ca_message(status)); */
|
||||
/* return -1; */
|
||||
/* } */
|
||||
/* /\* caput and wait until done *\/ */
|
||||
/* if ((status = caput(ch_id, value)) == ECA_NORMAL) */
|
||||
/* printf("caput: success\n"); */
|
||||
/* else */
|
||||
/* printf(ca_message(status)); */
|
||||
|
||||
/* /\* caget *\/ */
|
||||
/* if (caget(ch_id, &value) == ECA_NORMAL) */
|
||||
/* printf("caget: %f\n", value); */
|
||||
/* else */
|
||||
/* printf(ca_message(status)); */
|
||||
|
||||
/* /\* close channel connect *\/ */
|
||||
/* disconnect_channel(ch_id); */
|
||||
|
||||
/* /\* delete channel access context before program exits *\/ */
|
||||
/* ca_context_destroy(); */
|
||||
/* } */
|
||||
|
||||
|
||||
|
||||
@ -137,10 +112,6 @@ int caput(chid ch_id, double value) {
|
||||
|
||||
|
||||
|
||||
|
||||
float pos;
|
||||
float i0=0;
|
||||
|
||||
/*
|
||||
contains the conversion channel-angle for a module channel
|
||||
conv_r=pitch/radius
|
||||
@ -149,11 +120,11 @@ float i0=0;
|
||||
|
||||
float angle(int ichan, float encoder, float totalOffset, float conv_r, float center, float offset, float tilt, int direction) {
|
||||
|
||||
(void) offset; /* to avoid warning: unused parameter */
|
||||
|
||||
(void) tilt; /* to avoid warning: unused parameter */
|
||||
float ang;
|
||||
|
||||
ang=180./PI*(center*conv_r+atan((float)(ichan-center)*conv_r))+encoder+totalOffset;
|
||||
ang=180./PI*(center*conv_r+atan((float)(ichan-center)*conv_r))+encoder+totalOffset+offset;
|
||||
|
||||
return direction*ang;
|
||||
|
||||
@ -165,17 +136,55 @@ float get_position() {
|
||||
#ifdef VERBOSE
|
||||
printf("Getting motor position \n");
|
||||
#endif
|
||||
// caget X04SA-ES2-TH2:RO.RBV
|
||||
|
||||
#ifdef EPICS
|
||||
int status;
|
||||
|
||||
double value = 256;
|
||||
if (ch_getpos<0) return -1;
|
||||
|
||||
/* /\* caget *\/ */
|
||||
if (caget(ch_getpos, &value) == ECA_NORMAL) {
|
||||
#ifdef VERBOSE
|
||||
printf("caget: %f\n", value);
|
||||
#endif
|
||||
pos=value;
|
||||
} else
|
||||
printf(ca_message(status));
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
/* moves the encoder to position p */
|
||||
|
||||
|
||||
int go_to_position(float p) {
|
||||
#ifdef VERBOSE
|
||||
printf("Setting motor position \n");
|
||||
#endif
|
||||
pos=p;
|
||||
return pos;
|
||||
|
||||
#ifdef EPICS
|
||||
int status;
|
||||
if (ch_pos<0) return -1;
|
||||
/* /\* caput and wait until done *\/ */
|
||||
if ((status = caput(ch_pos, p)) == ECA_NORMAL) {
|
||||
;
|
||||
#ifdef VERBOSE
|
||||
printf("caput: success\n");
|
||||
#endif
|
||||
} else
|
||||
printf(ca_message(status));
|
||||
#else
|
||||
pos=p;
|
||||
#endif
|
||||
//"caputq X04SA-ES2-TH2:RO p"
|
||||
//cawait -nounit -timeout 3600 X04SA-ES2-TH2:RO.DMOV '==1'
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/* moves the encoder to position p without waiting */
|
||||
@ -184,6 +193,29 @@ int go_to_position_no_wait(float p) {
|
||||
#ifdef VERBOSE
|
||||
printf("Setting motor position no wait \n");
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef EPICS
|
||||
int status;
|
||||
if (ch_pos<0) return -1;
|
||||
/* /\* caput and wait until done *\/ */
|
||||
if ((status = caputq(ch_pos, p)) == ECA_NORMAL) {
|
||||
;
|
||||
#ifdef VERBOSE
|
||||
printf("caputq: success\n");
|
||||
#endif
|
||||
} else
|
||||
printf(ca_message(status));
|
||||
#else
|
||||
pos=p;
|
||||
#endif
|
||||
//"caputq X04SA-ES2-TH2:RO p"
|
||||
|
||||
return p;
|
||||
|
||||
|
||||
|
||||
|
||||
pos=p;
|
||||
return pos;
|
||||
}
|
||||
@ -195,8 +227,92 @@ float get_i0() {
|
||||
#ifdef VERBOSE
|
||||
printf("Getting I0 readout \n");
|
||||
#endif
|
||||
return i0++;
|
||||
|
||||
#ifdef EPICS
|
||||
int status;
|
||||
|
||||
double value = 256;
|
||||
/* /\* caget *\/ */
|
||||
if (ch_i0<0) return -1;
|
||||
if (caget(ch_i0, &value) == ECA_NORMAL) {
|
||||
#ifdef VERBOSE
|
||||
printf("caget: %f\n", value);
|
||||
#endif
|
||||
i0=value;
|
||||
} else
|
||||
printf(ca_message(status));
|
||||
#else
|
||||
i0++;
|
||||
#endif
|
||||
|
||||
//"ca_get X04SA-ES2-SC:CH6"
|
||||
return i0;
|
||||
}
|
||||
|
||||
int disconnect_channels() { }
|
||||
int connect_channels() {}
|
||||
|
||||
int connect_channels() {
|
||||
#ifdef EPICS
|
||||
//double value = 256;
|
||||
/* channel name */
|
||||
//const char *name = "ARIDI-PCT:CURRENT";
|
||||
/* channel id */
|
||||
/* status code */
|
||||
int status;
|
||||
|
||||
printf("starting...\n");
|
||||
|
||||
/* init channel access context before any caget/put */
|
||||
ca_context_create(ca_enable_preemptive_callback);
|
||||
|
||||
printf("context created\n");
|
||||
|
||||
//"caputq X04SA-ES2-TH2:RO p"
|
||||
|
||||
//"ca_get X04SA-ES2-SC:CH6"
|
||||
|
||||
/* open the channel by name and return ch_id */
|
||||
status = connect_channel("X04SA-ES2-SC:CH6", &ch_i0);
|
||||
if (status == ECA_NORMAL)
|
||||
printf("I0 channel connected \n");
|
||||
else {
|
||||
printf(ca_message(status));
|
||||
//ch_i0=-1;;
|
||||
}
|
||||
status = connect_channel("X04SA-ES2-TH2:RO", &ch_pos);
|
||||
if (status == ECA_NORMAL)
|
||||
printf("Detector position channel connected \n");
|
||||
else {
|
||||
printf(ca_message(status));
|
||||
//ch_i0=-1;;
|
||||
}
|
||||
status = connect_channel("X04SA-ES2-TH2:RO.RBV", &ch_getpos);
|
||||
if (status == ECA_NORMAL)
|
||||
printf("Detector get position channel connected \n");
|
||||
else {
|
||||
printf(ca_message(status));
|
||||
//ch_getpos=-1;;
|
||||
}
|
||||
|
||||
// caget X04SA-ES2-TH2:RO.RBV
|
||||
|
||||
//cawait -nounit -timeout 3600 X04SA-ES2-TH2:RO.DMOV '==1'
|
||||
#endif
|
||||
}
|
||||
|
||||
int disconnect_channels() {
|
||||
#ifdef EPICS
|
||||
/* close channel connect */
|
||||
disconnect_channel(ch_i0);
|
||||
disconnect_channel(ch_pos);
|
||||
disconnect_channel(ch_getpos);
|
||||
|
||||
/* delete channel access context before program exits */
|
||||
ca_context_destroy();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -26,7 +26,6 @@ extern "C" {
|
||||
int caputq(chid ch_id, double value);
|
||||
void put_callback(struct event_handler_args args);
|
||||
int caput(chid ch_id, double value);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -34,11 +33,9 @@ extern "C" {
|
||||
float get_position();
|
||||
int go_to_position(float p);
|
||||
int go_to_position_no_wait(float p);
|
||||
|
||||
int connect_channels();
|
||||
int disconnect_channels();
|
||||
|
||||
|
||||
float get_i0();
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user