innovative_dsp_hwi_spa.C

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 /* irnore this module for docuscan
00029 % PlugInModuleIgnore
00030  */
00031 
00032 
00033 #include <locale.h>
00034 #include <libintl.h>
00035 
00036 
00037 #include "glbvars.h"
00038 #include "plug-ins/hard/modules/dsp.h"
00039 #include <fcntl.h>
00040 #include <sys/ioctl.h>
00041 
00042 #include "dsp-pci32/spa/spacmd.h"
00043 #include "innovative_dsp_hwi.h"
00044 
00045 /* ============================================================
00046  * Hardwareimplementation hilevel DSP:
00047  * Virtuelle Funktionen der Basisklasse werden überschrieben
00048  * ============================================================ 
00049  */
00050 
00051 innovative_dsp_hwi_spa::innovative_dsp_hwi_spa():innovative_dsp_hwi_dev(){
00052   ScanningFlg=0;
00053 }
00054 
00055 innovative_dsp_hwi_spa::~innovative_dsp_hwi_spa(){
00056 }
00057 
00058 /* Übergeordnete Parameterübergabefunktionen PC => PC31/DSP
00059  * ========================================================
00060  * virtual !
00061  */
00062 void innovative_dsp_hwi_spa::PutParameter(void *src, int grp){ // Parameterstruktur kopieren
00063   if(src)
00064     memcpy(&dspPar, src, sizeof(DSP_Param));
00065   switch(ScanningFlg){
00066   case 0:
00067     DSP_SpaWerte();
00068     break;
00069   case 1:
00070     ScanningFlg=2;
00071     break;
00072   case 3:
00073     DSP_SpaWerte();
00074     break;
00075   }
00076 }
00077 
00078 void innovative_dsp_hwi_spa::StoreParameter(){
00079 }
00080 
00081 void innovative_dsp_hwi_spa::RestoreParameter(){
00082   DSP_SpaWerte(TRUE);
00083 }
00084 
00085 
00086 void innovative_dsp_hwi_spa::StartScan2D(){
00087   ScanningFlg=1; KillFlg=FALSE;
00088 }
00089 
00090 void innovative_dsp_hwi_spa::EndScan2D(){ 
00091   if(ScanningFlg>1){
00092     ScanningFlg=0; 
00093     PutParameter(NULL);
00094   }
00095   else
00096     ScanningFlg=0; 
00097 }
00098 
00099 void innovative_dsp_hwi_spa::MovetoXY(long x, long y){
00100   rx=x;
00101   ry=y;
00102 }
00103 void innovative_dsp_hwi_spa::SetDxDy(int dx, int dy){
00104   Dx = dx; 
00105   Dy = dy;
00106   dspPar.LS_dnx = dx;
00107 }
00108 void innovative_dsp_hwi_spa::SetOffset(long x, long y){
00109   rotoffx = x; rotoffy = y;
00110   DSP_SpaWerte();
00111 }
00112 void innovative_dsp_hwi_spa::SetAlpha(double alpha){ 
00113   Alpha=M_PI*alpha/180.;
00114   rotmyy = rotmxx = cos(Alpha);
00115   rotmyx = -(rotmxy = sin(Alpha));
00116   DSP_SpaWerte();
00117 }
00118 
00119 void innovative_dsp_hwi_spa::SetNx(long nx){ 
00120   Nx=nx; 
00121   dspPar.LS_nx2scan = nx;
00122 }
00123 
00124 /* Parameterübergabefunktionen PC => PC31/DSP
00125  * ==================================================
00126  *
00127  */
00128 
00129 void innovative_dsp_hwi_spa::DSP_SpaWerte(int flg){
00130   static double sum=1234e100;
00131   double nowsum;
00132   nowsum = rotoffx+rotoffx+dspPar.SPA_Length+dspPar.LS_nx2scan+Alpha+dspPar.SPA_Gatetime+dspPar.SPA_EnergyVolt;
00133   if(sum != nowsum || flg){
00134     PARAMETER_SET hardpar;
00135     sum = nowsum;
00136     XSM_DEBUG (DBG_L4, "DSP_SpaWerte");
00137 
00138     hardpar.N   = DSP_MYY+1;
00139     hardpar.Cmd = DSP_CMD_SCAN_PARAM;
00140     hardpar.hp[DSP_X0   ].value = rotoffx;
00141     hardpar.hp[DSP_Y0   ].value = rotoffy;
00142     hardpar.hp[DSP_len  ].value = dspPar.SPA_Length;
00143     hardpar.hp[DSP_N    ].value = dspPar.LS_nx2scan;
00144     hardpar.hp[DSP_alpha].value = Alpha;
00145     hardpar.hp[DSP_ms   ].value = 1000.*dspPar.SPA_Gatetime;
00146     hardpar.hp[DSP_E    ].value = dspPar.SPA_EnergyVolt;
00147     hardpar.hp[DSP_MXX  ].value = cos (Alpha);
00148     hardpar.hp[DSP_MXY  ].value = sin (Alpha);
00149     hardpar.hp[DSP_MYX  ].value = -sin (Alpha);
00150     hardpar.hp[DSP_MYY  ].value = cos (Alpha);
00151     SetParameter(hardpar);
00152   }
00153 }
00154 
00155 /*
00156  * Do ScanLine in multiple Channels Mode
00157  *
00158  * yindex:  Index of Line
00159  * xdir:    Scanning Direction (1:+X / -1:-X) eg. for/back scan
00160  * lsscrs:  LineScan Sources, MUX/Channel Configuration
00161  * PC31 has can handle 2 Channels of 16bit data simultan, using 4-fold Mux each
00162  *      additional the PID-Outputvalue can be used and the PID Src is set by MUXA
00163  *      it may be possible to switch MUXB while scanning -- test it !!!
00164  * bit     0 1 2 3  4 5 6 7  8 9 10 11  12 13 14 15 ...
00165  * PC31:   ==PID==  =MUX-A=  ==MUX-B==  
00166  * PCI32:  ==PID==  A======  B========  C==== D====
00167  *    eg.  Z-Value  Fz/I     Fric...
00168  * example:
00169  * value   1 0 0 0  1 0 0 0  1 0  0  0  0...
00170  * buffers B0       B1       B2
00171  * 3 buffers used for transfer (B0:Z, B1:Force, B2:Friction)
00172  *
00173  * Mob:     List of MemObjs. to store Data
00174  *
00175  * with maximized DPRAM usage: [DPRAM] [DSPMEM1] [DSPMEM2] ... (Blocks of same size)
00176  *                              B0,B1,  B2, B3,   B4,..
00177  * nach DSP_CMD_SWAPDPRAM:      B2,B3,  -------   B4,..
00178  * nach DSP_CMD_SWAPDPRAM:      B4,..   -------   -------
00179  * ...
00180  * 
00181  */
00182 void innovative_dsp_hwi_spa::ScanLineM(int yindex, int xdir, int lssrcs, Mem2d *Mob[MAX_SRCS_CHANNELS], int ix0){
00183         if (yindex < 0) return;
00184 
00185         int i, bi, bi2, bin;
00186         size_t elem_size=sizeof(long);
00187         size_t bsz;
00188         size_t sz;
00189         static long linebuffer[DSP_DATA_REG_LEN]; // Max Size for LineData "at once"
00190         PARAMETER_SET hardpar;
00191 
00192         hardpar.N   = DSP_E+1;
00193         hardpar.Cmd = DSP_CMD_SCAN_START;
00194         hardpar.hp[DSP_Y0   ].value = ry;
00195         hardpar.hp[DSP_len  ].value = dspPar.SPA_Length; // !!! LS_dnx*dspPar.LS_nx2scan;
00196         hardpar.hp[DSP_E    ].value = dspPar.SPA_EnergyVolt;
00197         SetParameter(hardpar, TRUE);
00198 
00199         // Setup MUX, #-Buffers
00200         // 
00201 
00202         /* Daten übertragen */
00203         bsz=(dspPar.LS_nx2scan*elem_size);
00204         bi=i=0;
00205         do{
00206                 bin=sz=0;
00207                 do{
00208                         if(lssrcs & (1<<bi++)){
00209                                 sz += bsz; ++bin;
00210                         }
00211                         if((sz+bsz) > (DSP_DATA_REG_LEN<<2)) 
00212                                 break;
00213                 }while(bi<16);
00214                 if(bin){
00215                         // read data buffer(s)
00216                         ReadData(linebuffer, sz);
00217                         bi2=0;
00218                         do{
00219                                 //      XSM_DEBUG(DBG_L2, "PDL:" << i << " " << bi2 << " " << bsz );
00220                                 Mob[i++]->PutDataLine(yindex, linebuffer+(bi2++)*dspPar.LS_nx2scan, scanmode);
00221                         }while(--bin && (i < MAX_SRCS_CHANNELS) ? Mob[i]!=NULL : FALSE);
00222                 }
00223                 else 
00224                         break;
00225                 // Swap DPRAM Buffers...
00226                 ExecCmd(DSP_CMD_SWAPDPRAM);
00227         }while((i < MAX_SRCS_CHANNELS) ? Mob[i]!=NULL : FALSE);
00228 }

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