probe_scan.C

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 /* ignore tag evaluated by for docuscangxsmplugins.pl -- this is no main plugin file
00026 % PlugInModuleIgnore
00027 */
00028 
00029 #include <config.h>
00030 
00031 #include "probe_scan.h"
00032 #include "gxsm/regress.h"
00033 #include "gxsm/scan.h"
00034 #include "gxsm/dataio.h"
00035 
00036 #include "gxsm/surface.h"
00037 #include "gxsm/glbvars.h"
00038 #include "gxsm/xsmtypes.h"
00039 
00040 #include "gxsm/action_id.h"
00041 
00042 #define L_NULL  0
00043 #define L_START 1
00044 #define L_MOVE  2
00045 #define L_END   3
00046 
00047 #define QSIZE   5  // Size of Line-Handles (Squares)
00048 #define QSIZE1  QSIZE // Anfang
00049 #define QSIZE2  (QSIZE-2) // Ende
00050 
00051 ProbeScan::ProbeScan()
00052   :Scan(ID_CH_V_NO, SCAN_V_DIRECT, -1, NULL, ZD_DOUBLE){
00053   PI_DEBUG (DBG_L2, "ProbeScan::ProbeScan");
00054   StopProbeFlg=TRUE;
00055   data.Xunit = NULL;
00056   data.Yunit = NULL;
00057   data.Zunit  = NULL;
00058   data.LoadValues(NULL, NULL, "SPM_Probe_Set");
00059   data.ui.SetTitle("SPM Probe");
00060   data.s.dz = 1.;
00061 }
00062 
00063 ProbeScan::~ProbeScan(){
00064   data.SaveValues("SPM_Probe_Set");
00065 }
00066 
00067 int ProbeScan::Save(gchar *fname){
00068   const char *ret;
00069   Dataio *Dio;
00070   Dio = new NetCDF(this, fname);
00071   
00072   Dio->Write();
00073   ret = Dio->ioStatus();
00074   delete Dio;
00075   return(ret?1:0);
00076 }
00077 
00078 int ProbeScan::Load(gchar *fname){
00079   const char *ret;
00080   Dataio *Dio;
00081   
00082   Dio = new NetCDF(this, fname); // NetCDF File
00083   
00084   Dio->Read();
00085   ret = Dio->ioStatus();
00086   delete Dio;
00087   return(ret?1:0);
00088 }
00089 
00090 int ProbeScan::Probe(XSM_Hardware *hw, SPM_Probe_p *prbp){
00091         static SPM_Probe_p *lastprbp=NULL;
00092         static int count=0;
00093         PI_DEBUG (DBG_L2, "ProbeScan::Probe");
00094         if(!prbp){ 
00095                 PI_DEBUG (DBG_L2, "ProbeScan::Probe Probe start ERROR prbp object is a zero pointer");
00096                 return -1;
00097         }
00098 
00099         data.ui.SetTitle (prbp->resTitle);
00100 
00101         if (strncmp (data.ui.originalname, gapp->xsm->data.ui.originalname, strlen(gapp->xsm->data.ui.originalname)))
00102                 count = 0;
00103         gchar *s;
00104         data.ui.SetOriginalName (s=g_strdup_printf("%s-%s%03d", gapp->xsm->data.ui.originalname, prbp->resName, ++count));
00105         g_free (s);
00106 
00107         data.SetXUnit(prbp->XUnit);
00108         data.SetZUnit(prbp->ZUnit);
00109 
00110         StopProbeFlg=FALSE;
00111         data.s.nx = prbp->nx; 
00112         data.s.ny = prbp->nsrcs;
00113         prbp->Resize();
00114         mem2d->Resize(data.s.nx, data.s.ny);
00115         mem2d->data->MkXLookup( (double)prbp->xS, (double)prbp->xE );
00116         PI_DEBUG (DBG_L2, "ProbeScan::Probe start");
00117         data.s.tStart=time(0);
00118 
00119         // do probing...
00120 
00121         // here DSP-Access!!
00122         // no longer this way    hw->Action(ACTION_SPM_PROBE, (void *)prbp);
00123 
00124         PARAMETER_SET hardpar;
00125 
00126         PI_DEBUG (DBG_L2, "PRB scan start * Normal" );
00127 
00128         hardpar.N   = DSP_PRBPANZ;
00129         hardpar.Cmd = DSP_CMD_PROBESCAN;
00130         hardpar.hp[DSP_PRBSRCS    ].value = prbp->srcs; // Codierte MUX/Srcs Configuration
00131         hardpar.hp[DSP_PRBOUTP    ].value = prbp->outp; // Channel to Probe
00132         hardpar.hp[DSP_PRBNX      ].value = prbp->nx;
00133         hardpar.hp[DSP_PRBXS      ].value = prbp->xS;
00134         hardpar.hp[DSP_PRBXE      ].value = prbp->xE;
00135         hardpar.hp[DSP_PRBACAMP   ].value = prbp->ACAmp;
00136         hardpar.hp[DSP_PRBACFRQ   ].value = prbp->ACFrq;
00137         hardpar.hp[DSP_PRBACPHASE ].value = prbp->ACPhase;
00138         hardpar.hp[DSP_PRBACMULT  ].value = prbp->ACMultiplier;
00139         hardpar.hp[DSP_PRBDELAY   ].value = prbp->delay;
00140         hardpar.hp[DSP_PRBCIVAL   ].value = prbp->CIval;
00141         hardpar.hp[DSP_PRBNAVE    ].value = prbp->nAve;
00142         hardpar.hp[DSP_PRBGAPADJ  ].value = prbp->GapAdj/gapp->xsm->Inst->ZResolution(); // convert to DigUnits!!!!
00143         hw->SetParameter(hardpar, FALSE);
00144         prbp->ACMultiplier = hardpar.hp[DSP_PRBACMULT].value;
00145         prbp->ACFrq        = hardpar.hp[DSP_PRBACFRQ].value;
00146 
00147         data.s.tEnd=time(0);
00148 
00149         PI_DEBUG (DBG_L2, "PRB scan: done" );
00150 
00151         hw->ReadProbeData (prbp->nsrcs, prbp->nx, -1, -1, prbp->scan, 1./prbp->ACMultiplier);
00152 
00153         mem2d->CopyFrom(prbp->scan, 0, 0, 0, 0, data.s.nx, data.s.ny);
00154 
00155         PI_DEBUG (DBG_L2, "ProbeScan::Probe SetVM");
00156 
00157         if(!view || lastprbp!=prbp)
00158                 SetView(ID_CH_V_PROFILE);
00159         else
00160                 draw();
00161 
00162         lastprbp=prbp;
00163 
00164         return 0;
00165 }
00166 
00167 int ProbeScan::Stop(){
00168         StopProbeFlg=TRUE; 
00169         return 0;
00170 }
00171 
00172 
00173 // SPM_Probe_p parameter storage class constructor
00174 SPM_Probe_p::SPM_Probe_p(gchar *SetName, gchar *SetTitle)
00175 {
00176   resName = g_strdup(SetName);
00177   resTitle = g_strdup(SetTitle);
00178   // get default values using the resource manager
00179   XsmRescourceManager xrm(resName);
00180   xrm.Get("xS", &xS, "-2.0");
00181   xrm.Get("xE", &xE, "2.0");
00182   xrm.Get("GapAdj", &GapAdj, "0.0");
00183   xrm.Get("ACAmp", &ACAmp, "0.0");
00184   xrm.Get("ACFrq", &ACFrq, "0.0");
00185   xrm.Get("Phase", &ACPhase, "0.0");
00186   xrm.Get("Multi", &ACMultiplier, "1.0");
00187   xrm.Get("nx", &nx, "512");
00188   xrm.Get("delay", &delay, "0");
00189   xrm.Get("channels", &channels, "1");
00190   xrm.Get("nAve", &nAve, "33");
00191   xrm.Get("nRep", &nRep, "1");
00192   xrm.Get("CIval", &CIval, "0.0");
00193   xrm.Get("srcs", &srcs, "16");
00194   xrm.Get("outp", &outp, "2");
00195 
00196   nsrcs=1;
00197   scan = new Mem2d(nx, nsrcs, ZD_DOUBLE);
00198 }
00199 
00200 // SPM_Probe_p parameter storage class destructor
00201 SPM_Probe_p::~SPM_Probe_p()
00202 {
00203   // save the actual values in resources
00204   XsmRescourceManager xrm(resName);
00205   xrm.Put("xS", xS);
00206   xrm.Put("xE", xE);
00207   xrm.Put("ACAmp", ACAmp);
00208   xrm.Put("ACFrq", ACFrq);
00209   xrm.Put("nx", nx);
00210   xrm.Put("delay", delay);
00211   xrm.Put("nAve", nAve);
00212   xrm.Put("nRep", nRep);
00213   xrm.Put("CIval", CIval);
00214   xrm.Put("srcs", srcs);
00215   xrm.Put("outp", outp);
00216 
00217   g_free(resName);
00218   delete scan;
00219 }

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