Exemple #1
0
DllExport long
SfMcaCalib ( SpecFile *sf, long index, double **calib, int *error )
{

     long   nb_lines;
     char **retline;
     char  *strptr;

     double val1,val2,val3;

     double *retdata;

     nb_lines   = SfHeader(sf,index,"@CALIB",&retline,error);

     if (nb_lines > 0) {
          strptr = retline[0] + 8;
          sscanf(strptr,"%lf %lf %lf",&val1,&val2,&val3);
     }  else {
         *calib = (double *)NULL;
          return(-1);
     }

     retdata = (double *) malloc(sizeof(double) * 3 );
     retdata[0] = val1; retdata[1] = val2; retdata[2] = val3;

     *calib = retdata;
     return(0);
}
Exemple #2
0
DllExport long
SfGeometry ( SpecFile *sf, long index, char ***lines, int *error)
{
    char string[] = " \0";

    string[0] = SF_GEOMETRY;

    return(SfHeader(sf,index,string,lines,error));
}
Exemple #3
0
DllExport long   
SfAllMotorPos ( SpecFile *sf, long index, double **retpos, int *error )
{
     char **lines;
     char  *thisline,
           *endline;

     double *posarr;

     static double pos[200];
     static char   posstr[40];

     char  *ptr;

     long      motct = 0;
     long      no_lines;
     short     i,j;

#ifndef _GNU_SOURCE
#ifdef PYMCA_POSIX
	char *currentLocaleBuffer;
	char localeBuffer[21];
#endif
#endif

     if (sfSetCurrent(sf,index,error) == -1) {
         *retpos = (double *) NULL;
          return(0);
     }

    /*
     * if motors position for this scan have already been read
     */
     if (sf->motor_pos != (double *)NULL) {
         posarr = (double *)malloc(sizeof(double) * sf->no_motor_pos);
         for (i=0;i<sf->no_motor_pos;i++) {
             posarr[i] = sf->motor_pos[i];
         }
        *retpos = posarr;
         return(sf->no_motor_pos);
     }

    /*
     * else
     */
     no_lines =  SfHeader(sf, index,"P",&lines,error);

     if (no_lines == -1 || no_lines == 0 ) {
         *retpos = (double *) NULL;
          return(-1);
     }

     motct = 0;
#ifndef _GNU_SOURCE
#ifdef PYMCA_POSIX
	currentLocaleBuffer = setlocale(LC_NUMERIC, NULL);
	strcpy(localeBuffer, currentLocaleBuffer);
	setlocale(LC_NUMERIC, "C\0");
#endif
#endif
     for (j=0;j<no_lines;j++) {
         thisline = lines[j] + 4;
         endline  = thisline + strlen(thisline);
         for(ptr=thisline;*ptr == ' ';ptr++);
         for (i=0;ptr < endline -1;ptr++,i++) {
            if (*ptr==' ') { 
               posstr[i] = '\0';

               pos[motct]  = PyMcaAtof(posstr);

               motct++; 
               i=-1; 
               for(;*(ptr+1) == ' ' && ptr < endline -1;ptr++);
            } else {
               posstr[i] = *ptr;
            }
         }
         if (*ptr != ' ') {
            posstr[i]   = *ptr; 
            i++;
         }
         posstr[i]   = '\0';
         pos[motct]  = PyMcaAtof(posstr);

         motct++; 

	 }

#ifndef _GNU_SOURCE
#ifdef PYMCA_POSIX
	setlocale(LC_NUMERIC, localeBuffer);
#endif
#endif

     /*
      * Save in specfile structure
      */
      sf->no_motor_pos = motct;
      sf->motor_pos    = (double *)malloc(sizeof(double) * motct);
      memcpy(sf->motor_pos,pos,motct * sizeof(double));

     /*
      * and return
      */
      posarr = (double *) malloc ( sizeof(double) * motct ) ;
      memcpy(posarr,pos,motct * sizeof(double));

     *retpos = posarr;

      return( motct );
}