sranger_hwi.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 __SRANGER_HWI_H
00029 #define __SRANGER_HWI_H
00030 
00031 //#include "include/dsp-pci32/xsm/dpramdef.h"
00032 #include "FB_spm_dataexchange.h" // SRanger data exchange structs and consts
00033 #include "sranger_hwi_control.h"
00034 
00035 
00036 /*
00037  * general hardware abstraction class for Signal Ranger compatible hardware
00038  * - instrument independent device support part
00039  * =================================================================
00040  */
00041 class sranger_hwi_dev : public XSM_Hardware{
00042 
00043 public: 
00044         friend class DSPControl;
00045 
00046         sranger_hwi_dev();
00047         virtual ~sranger_hwi_dev();
00048 
00049         /* Parameter  */
00050         virtual long GetMaxPointsPerLine(){ return  AIC_max_points; };
00051         virtual long GetMaxLines(){ return  AIC_max_points; };
00052 
00053         virtual int ReadScanData(int y_index, int num_srcs, Mem2d *m[MAX_SRCS_CHANNELS]);
00054         virtual int ReadProbeData(int nsrcs, int nprobe, int kx, int ky,
00055                                   Mem2d *m, double scale=1.);
00056         virtual gchar* get_info();
00057 
00058         /* Hardware realtime monitoring -- all optional */
00059         /* default properties are
00060          * "X" -> current realtime tip position in X, inclusive rotation and offset
00061          * "Y" -> current realtime tip position in Y, inclusive rotation and offset
00062          * "Z" -> current realtime tip position in Z
00063          * "xy" -> X and Y
00064          * "zxy" -> Z, X, Y
00065          * "U" -> current bias
00066          */
00067         virtual gint RTQuery (gchar *property, double &val) { return FALSE; };
00068         virtual gint RTQuery (gchar *property, double &val1, double &val2) { return FALSE; };
00069         virtual gint RTQuery (gchar *property, double &val1, double &val2, double &val3) { return FALSE; };
00070         virtual gint RTQuery (gchar *property, gchar **val) { return FALSE; };
00071 
00072         virtual void ExecCmd(int Cmd) {};
00073 
00074 // SRanger format conversions and endianess adaptions
00075         void swap (unsigned short *addr);
00076         void swap (short *addr);
00077         void swap (long *addr);
00078         void check_and_swap (short &data) {
00079                 if (swap_flg)
00080                         swap (&data);
00081         };
00082         void check_and_swap (unsigned short &data) {
00083                 if (swap_flg)
00084                         swap (&data);
00085         };
00086         void check_and_swap (long &data) {
00087                 if (swap_flg)
00088                         swap (&data);
00089         };
00090         int float_2_sranger_q15 (double x);
00091         int int_2_sranger_int (int x);
00092         long long_2_sranger_long (long x);
00093 
00094         int is_scanning() { return ScanningFlg; };
00095         int start_fifo_read (int y_start, 
00096                              int num_srcs0, int num_srcs1, int num_srcs2, int num_srcs3, 
00097                              Mem2d **Mob0, Mem2d **Mob1, Mem2d **Mob2, Mem2d **Mob3);
00098 
00099         int ReadLineFromFifo (int y_index);
00100 
00101         int ReadProbeFifo (int dspdev, int control=0);
00102 
00103         int probe_fifo_thread_active;
00104         int probe_time_estimate;
00105         int fifo_data_y_index;
00106         int fifo_data_num_srcs[4]; // 0: XP, 1: XM, 2: 2ND_XP, 3: 2ND_XM
00107         Mem2d **fifo_data_Mobp[4]; // 0: XP, 1: XM, 2: 2ND_XP, 3: 2ND_XM
00108 
00109         int probe_thread_dsp; // connection to SRanger used by probe thread
00110 protected:
00111         int ScanningFlg;
00112         int KillFlg;
00113         int dsp; // connection to SRanger
00114         int dsp_alternative; // 2nd connection to SRanger
00115         int thread_dsp; // connection to SRanger used by thread
00116         // add data shared w upper spm class here
00117         SPM_MAGIC_DATA_LOCATIONS magic_data;
00118         int swap_flg;
00119 
00120 private:
00121         GThread *fifo_read_thread;
00122         GThread *probe_fifo_read_thread;
00123         int FifoRead (int start, int end, int &xi, int num_srcs, int len, short *buffer, short *fifo);
00124         int FifoRead (int start, int end, int &xi, int num_srcs, int len, long *buffer, long *fifo);
00125         gchar *productid;
00126         int AIC_max_points;
00127 };
00128 
00129 
00130 /*
00131  * SPM hardware abstraction class for use with Signal Ranger compatible hardware
00132  * ======================================================================
00133  */
00134 class sranger_hwi_spm : public sranger_hwi_dev{
00135  public:
00136         sranger_hwi_spm();
00137         virtual ~sranger_hwi_spm();
00138 
00139         /* Hardware realtime monitoring -- all optional */
00140         /* default properties are
00141          * "X" -> current realtime tip position in X, inclusive rotation and offset
00142          * "Y" -> current realtime tip position in Y, inclusive rotation and offset
00143          * "Z" -> current realtime tip position in Z
00144          * "xy" -> X and Y
00145          * "zxy" -> Z, X, Y
00146          * "U" -> current bias
00147          */
00148         virtual gint RTQuery (gchar *property, double &val) { return FALSE; };
00149         virtual gint RTQuery (gchar *property, double &val1, double &val2) { return FALSE; };
00150         virtual gint RTQuery (gchar *property, double &val1, double &val2, double &val3);
00151         virtual gint RTQuery (gchar *property, gchar **val) { return FALSE; };
00152 
00153         virtual void SetOffset(long x, long y);
00154         virtual void StartScan2D();
00155         virtual void ScanLineM(int yindex, int xdir, int muxmode,
00156                                Mem2d *Mob[MAX_SRCS_CHANNELS], int ix0=0 );
00157         virtual void EndScan2D();
00158         virtual void PauseScan2D();
00159         virtual void ResumeScan2D();
00160         virtual void KillScan2D(){ KillFlg=TRUE; };
00161 
00162         virtual void ExecCmd(int Cmd);
00163  protected:
00164 
00165  private:
00166         DSPControl *dc;
00167 };
00168 
00169 #endif
00170 

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