00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
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 
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  
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 
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 
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         
00083         char* Info (int data){ return InfoString; }; 
00084         gchar* GetStatusInfo () { return AddStatusString; }; 
00085 
00086         
00087         virtual long GetMaxPointsPerLine (){ return 1L<<16; };
00088         virtual long GetMaxLines (){ return -1L; }; 
00089         virtual long GetMaxChannels (){ return 1L; }; 
00090 
00091         
00092         
00093 
00094 
00095 
00096 
00097 
00098 
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         
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 
00114 
00115 
00116 
00117         
00118         virtual void SetOffset(long x, long y);
00119 
00120         
00121         virtual void SetDxDy(int dx, int dy=0);
00122 
00123         
00124         virtual void SetNxNy(long nx, long ny=0L);
00125 
00126         
00127         virtual void SetAlpha(double alpha);
00128 
00129         
00130         virtual void MovetoXY (long x, long y);
00131 
00132         
00133         virtual int ScanDirection (int dir);
00134 
00135         
00136         virtual void StartScan2D(){;};
00137 
00138         
00139         virtual void ScanLineM(int yindex, int xdir, int muxmode, Mem2d *Mob[MAX_SRCS_CHANNELS], int ix0=0 );
00140 
00141         
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