peakfind_scan.h

Go to the documentation of this file.
00001 /* Gnome gxsm - Gnome X Scanning Microscopy
00002  * universal STM/AFM/SARLS/SPALEED/... controlling and
00003  * data analysis software
00004  * 
00005  * Copyright (C) 1999 The Free Software Foundation
00006  *
00007  * Authors: Percy Zahl <zahl@fkp.uni-hannover.de>
00008  * additional features: Andreas Klust <klust@fkp.uni-hannover.de>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
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 // special Actions
00056 #define ACTION_SPM_PROBE      1
00057 #define ACTION_SPA_PF_FIT     2
00058 
00059 /* SPM Hardware auf /dev/dspdev -- xafm.out running on dsp 
00060  * used by AFM, STM, SARLS
00061  */
00062 
00063 // Probe: Peak Finder Class
00064 #define PF_FITMODE_FIT2ND    1
00065 #define PF_FITMODE_FITGAUS   2
00066 #define PF_FITMODE_FITLORENZ 3
00067 
00068 //template <class FPIXTYP> class Focus;
00069 class Focus;
00070 
00071 /*
00072  * Probe (Force/Dist, STS, Oszi...)) Ableitung
00073  * this "scan" is handled seperatly by ProbeControl
00074  * e.g. is not managed by the "surface-channel-system"
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     // hold x and y scans here
00100     Mem2d *xyscans;
00101     //    Focus<long> *focview;
00102     Focus *focview;
00103 
00104     // hold 2d FocusViewData
00105     long *buffer;
00106     int buffersize;
00107     
00108     // new position, shiftdistance
00109     double xnew,ynew,shift;
00110     // found Intensity
00111     double I0x, I0y;
00112     
00113     // probe at
00114     double xorg, yorg; // initial point
00115     double x0, y0; // new start at
00116     double rellim, abslim;
00117     double xsig, ysig;
00118 
00119     // with radius
00120     double radius;
00121     // and num points of
00122     int    npkte, npkte2d;
00123     // and scan with gatetime [s]
00124     double gate, gate2d;
00125     double energy;
00126     // use kovergenz factor
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     // calculated stuff
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     // Fit and return poly´s maximum
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); // run Peak Find: XY-scans
00182     int PFrunI0(XSM_Hardware *hw, SPA_PeakFind_p *pfp); // Peak Find, Log Ixy0
00183     int PFhwrun(XSM_Hardware *hw, SPA_PeakFind_p *pfp); // HardCalls, used by PFrun() and PFrunI0()
00184     int PFget2d(XSM_Hardware *hw, SPA_PeakFind_p *pfp); // Run small and fastest 2d Scan
00185     long PFget0d(XSM_Hardware *hw, SPA_PeakFind_p *pfp); // Get Counts at Position
00186     
00187  private:
00188     int StopPeakFindFlg;
00189 };
00190 
00191 #endif

Generated on Sat Apr 1 09:04:13 2006 for GXSM by  doxygen 1.4.6