00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef __PEAKFIND_SCAN_H
00026 #define __PEAKFIND_SCAN_H
00027
00028 #include <gtk/gtk.h>
00029 #include "config.h"
00030
00031 #include <stdio.h>
00032 #include <stdlib.h>
00033 #include <time.h>
00034 #include <unistd.h>
00035 #include <math.h>
00036 #include <sys/mman.h>
00037 #include <sys/types.h>
00038 #include <sys/stat.h>
00039 #include <asm/page.h>
00040 #include <fcntl.h>
00041 #include <iostream.h>
00042
00043 #include "gxsm/mem2d.h"
00044 #include "gxsm/scan.h"
00045 #include "gxsm/xsmhard.h"
00046 #include "gxsm/glbvars.h"
00047 #include "gxsm/plugin.h"
00048 #include "gxsm/regress.h"
00049 #include "include/dsp-pci32/spa/spacmd.h"
00050
00051 extern GxsmPlugin DSPPeakFind_pi;
00052
00053 #include "probe_base.h"
00054
00055
00056 #define ACTION_SPM_PROBE 1
00057 #define ACTION_SPA_PF_FIT 2
00058
00059
00060
00061
00062
00063
00064 #define PF_FITMODE_FIT2ND 1
00065 #define PF_FITMODE_FITGAUS 2
00066 #define PF_FITMODE_FITLORENZ 3
00067
00068
00069 class Focus;
00070
00071
00072
00073
00074
00075
00076
00077
00078 class SPA_PeakFind_p : public ProbeBase {
00079 public:
00080 SPA_PeakFind_p(int idx=0, gchar *SetName = "PeakFindCntrl");
00081 virtual ~SPA_PeakFind_p();
00082
00083 void SetFitMode(int m){ fitmode = m; };
00084 int Resize(){
00085 xyscans->Resize(npkte_alloc=npkte, 4);
00086 return 0;
00087 };
00088 double skltr(double &x){ x -= (double)npkte/2.; x *= radius/(npkte/2.); return 0.; };
00089 double skl(double &x){ x *= radius/(npkte/2.); return 0.; };
00090 int DoFit();
00091 int Mode(void){ return fitmode; };
00092
00093
00094 void ResizeBuffer(){
00095 if(buffer) g_free(buffer);
00096 buffer = g_new(long, buffersize=npkte2d*npkte2d);
00097 };
00098
00099
00100 Mem2d *xyscans;
00101
00102 Focus *focview;
00103
00104
00105 long *buffer;
00106 int buffersize;
00107
00108
00109 double xnew,ynew,shift;
00110
00111 double I0x, I0y;
00112
00113
00114 double xorg, yorg;
00115 double x0, y0;
00116 double rellim, abslim;
00117 double xsig, ysig;
00118
00119
00120 double radius;
00121
00122 int npkte, npkte2d;
00123
00124 double gate, gate2d;
00125 double energy;
00126
00127 double konvfac;
00128 double sleeptime;
00129 int enabled;
00130 int maxloops;
00131 double offsetcorrection;
00132
00133 time_t ptime;
00134 int count;
00135
00136 int number;
00137 int index;
00138 gchar *name;
00139
00140 int follow;
00141
00142
00143 double fwhm, xfwhm, yfwhm;
00144 double I0, xI0, yI0;
00145 double xf0, xxf0, yxf0;
00146
00147 private:
00148 gchar *resName;
00149 int npkte_alloc;
00150 int fitmode;
00151
00152
00153 int FitFind(int xy, double &m){
00154 switch(fitmode){
00155 case PF_FITMODE_FIT2ND: return FitFind2nd(xy, m);
00156 case PF_FITMODE_FITGAUS: return FitFindGaus(xy, m);
00157 case PF_FITMODE_FITLORENZ: return FitFindLorenz(xy, m);
00158 }
00159 return 0;
00160 };
00161 int FitFind2nd(int xy, double &m);
00162 int FitFindGaus(int xy, double &m);
00163 int FitFindLorenz(int xy, double &m);
00164 };
00165
00166
00167 #include "app_databox.h"
00168
00169 class PeakFindScan : public Scan{
00170 public:
00171 PeakFindScan();
00172 ~PeakFindScan();
00173
00174 int Save(gchar *fname);
00175 int Load(gchar *fname);
00176
00177 int Stop(){
00178 StopPeakFindFlg=TRUE;
00179 return 0;
00180 };
00181 int PFrun(XSM_Hardware *hw, SPA_PeakFind_p *pfp);
00182 int PFrunI0(XSM_Hardware *hw, SPA_PeakFind_p *pfp);
00183 int PFhwrun(XSM_Hardware *hw, SPA_PeakFind_p *pfp);
00184 int PFget2d(XSM_Hardware *hw, SPA_PeakFind_p *pfp);
00185 long PFget0d(XSM_Hardware *hw, SPA_PeakFind_p *pfp);
00186
00187 private:
00188 int StopPeakFindFlg;
00189 };
00190
00191 #endif