xsmhard.h

Go to the documentation of this file.
00001 /* Gxsm - Gnome X Scanning Microscopy
00002  * universal STM/AFM/SARLS/SPALEED/... controlling and
00003  * data analysis software
00004  * 
00005  * Copyright (C) 1999,2000,2001,2002,2003 Percy Zahl
00006  *
00007  * Authors: Percy Zahl <zahl@users.sf.net>
00008  * additional features: Andreas Klust <klust@users.sf.net>
00009  * WWW Home: http://gxsm.sf.net
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00024  */
00025 
00026 /* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 8 c-style: "K&R" -*- */
00027 
00028 #ifndef __XSMHARD_H
00029 #define __XSMHARD_H
00030 
00031 #include <cstdio>
00032 #include <cstdlib>
00033 #include <ctime>
00034 #include <cmath>
00035 
00036 #include <unistd.h>
00037 #include <sys/mman.h>
00038 #include <sys/types.h>
00039 #include <sys/stat.h>
00040 //#include <asm/page.h>
00041 #include <fcntl.h>
00042 
00043 #include "mem2d.h"
00044 #include "xsmtypes.h"
00045 #include "xsm_limits.h"
00046 
00047 #include "include/dsp-pci32/xsm/dpramdef.h"
00048 
00049 #define DSP_TIMEOUT     20  /* Zeit [s] für Automatisches Timeout */
00050 
00051 #define MAXHP DSP_CTRL_REG_LEN
00052 
00053 typedef enum PROBE_DATA_MODE { PRB_SHORT, PRB_FLOAT };
00054 typedef enum SCAN_DATA_MODE { SCAN_DATA_SWAP_SHORT, SCAN_DATA_MOVE2DPRAM_SHORT };
00055 
00056 /* Daten Übergabe Kontrollstruktur */
00057 
00058 typedef struct{
00059         char   *name;
00060         double value;
00061 } HARDWARE_PARAMETER;
00062 
00063 typedef struct{
00064         int N;
00065         unsigned short Cmd;
00066         HARDWARE_PARAMETER hp[MAXHP];
00067 } PARAMETER_SET;
00068 
00069 /*
00070  * ============================================================
00071  * Allgemeines Basis Objekt zur Bedienung der XSM-HARDWARE 
00072  * ============================================================
00073  */
00074 
00075 class XSM_Hardware{
00076  public:
00077         XSM_Hardware();
00078         virtual ~XSM_Hardware();
00079 
00080         virtual long GetPreScanLineOffset (){ return 0L; };
00081 
00082         /* query Hardware description and features */
00083         char* Info (int data){ return InfoString; }; /* Info */
00084         gchar* GetStatusInfo () { return AddStatusString; }; /* Status */
00085 
00086         /* Hardware Limits */
00087         virtual long GetMaxPointsPerLine (){ return 1L<<16; };
00088         virtual long GetMaxLines (){ return -1L; }; /* -1: no limit */
00089         virtual long GetMaxChannels (){ return 1L; }; /* not used, may be obsoleted */
00090 
00091         /* Hardware realtime monitoring -- all optional */
00092         /* default properties are
00093          * "X" -> current realtime tip position in X, inclusive rotation and offset
00094          * "Y" -> current realtime tip position in Y, inclusive rotation and offset
00095          * "Z" -> current realtime tip position in Z
00096          * "xy" -> X and Y
00097          * "zxy" -> Z, X, Y
00098          * "U" -> current bias
00099          */
00100         virtual gint RTQuery (gchar *property, double &val) { return FALSE; };
00101         virtual gint RTQuery (gchar *property, double &val1, double &val2) { return FALSE; };
00102         virtual gint RTQuery (gchar *property, double &val1, double &val2, double &val3) { return FALSE; };
00103         virtual gint RTQuery (gchar *property, gchar **val) { return FALSE; };
00104 
00105         /* Methods for future use */
00106         virtual gchar* InqeueryUserParamId (gint n) { return NULL; };
00107         virtual gchar* InqeueryUserParamDescription (gint n) { return NULL; };
00108         virtual gchar* InqeueryUserParamUnit (gint n) { return NULL; };
00109         virtual double GetUserParam (gint n, gchar *id=NULL) { return 0.; };
00110         virtual gint   SetUserParam (gint n, gchar *id=NULL, double value=0.) { return FALSE; };
00111         
00112         /* 
00113          * Generic scan parameters and scanhead controls
00114          * All integer values are in DAC units
00115          */
00116 
00117         /* set scan offset, HwI should move detector to this position, absolute coordinates, not rotated */
00118         virtual void SetOffset(long x, long y);
00119 
00120         /* set scan step sizes, if dy is 0 or not given dy=dx is assumed */
00121         virtual void SetDxDy(int dx, int dy=0);
00122 
00123         /* set scan dimensions, if ny not given or 0 ny=nx is assumed */
00124         virtual void SetNxNy(long nx, long ny=0L);
00125 
00126         /* set scan angle in degree, this affects the scan-coordinate system */
00127         virtual void SetAlpha(double alpha);
00128 
00129         /* perform a moveto aktion within the scan-coordinate system (rotated by alpha) */
00130         virtual void MovetoXY (long x, long y);
00131 
00132         /* set/get scan direction, +1: Top-Down, -1: Bottom-Up */
00133         virtual int ScanDirection (int dir);
00134 
00135         /* prepare to Start Scan */
00136         virtual void StartScan2D(){;};
00137 
00138         /* Scan a Line, negative yindex: scan initialization phase in progress... */
00139         virtual void ScanLineM(int yindex, int xdir, int muxmode, Mem2d *Mob[MAX_SRCS_CHANNELS], int ix0=0 );
00140 
00141         /* End,Pause,Resume,Kill/Cancel Scan */
00142         virtual void EndScan2D(){;};
00143         virtual void PauseScan2D(){;};
00144         virtual void ResumeScan2D(){;};
00145         virtual void KillScan2D(){;};
00146 
00147         virtual void EventCheckOn(){;};
00148         virtual void EventCheckOff(){;};
00149 
00150         virtual size_t ReadData(void *buf, size_t count) { 
00151                 return 0; 
00152         };
00153         virtual int ReadScanData(int y_index, int num_srcs, Mem2d *m[MAX_SRCS_CHANNELS]) {
00154                 return 0; 
00155         };
00156         virtual int ReadProbeData(int nsrcs, int nprobe, int kx, int ky, Mem2d *m, double scale=1.) { 
00157                 return 0; 
00158         };
00159         virtual gchar* get_info(){ 
00160                 return g_strdup("*--GXSM XSM_Hardware base class --*\n"
00161                                 "This is just providing a simple emulation mode.\n"
00162                                 "No Hardware is connected!\n"
00163                                 "*--Features--*\n"
00164                                 "SCAN: Yes\n"
00165                                 "PROBE: No\n"
00166                                 "ACPROBE: No\n"
00167                                 "*--EOF--*\n"
00168                         ); 
00169         };
00170 
00171         void SetScanMode(int ssm=MEM_SET){ scanmode=ssm; };
00172         int  FreeOldData(){ return (scanmode == MEM_SET); };
00173         void Transform(double *x, double *y);
00174         void SetIdleFunc ( void (*ifunc)(gpointer), gpointer id){
00175                 idlefunc_data = id;
00176                 idlefunc = ifunc;
00177         };
00178 
00179         void CallIdleFunc(){ if (idlefunc) (*idlefunc)(idlefunc_data); };
00180 
00181         gpointer idlefunc_data;
00182         void (*idlefunc)(gpointer);
00183 
00184         gchar *InfoString;
00185         gchar *AddStatusString;
00186 
00187  private:
00188         double  Simulate(double x, double y);
00189 
00190  protected:
00191         long   rx, ry, XAnz, Dx, Dy, Nx, Ny;
00192         double Alpha;
00193         double rotmxx,rotmxy,rotmyx,rotmyy,rotoffx,rotoffy;
00194 
00195         int    scanmode;
00196         int    scan_direction;
00197 };
00198 
00199 
00200 #endif
00201 

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