xsmtypes.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 __XSMTYPES_H
00029 #define __XSMTYPES_H
00030 
00031 // "C" headers
00032 #include <cstring>
00033 
00034 // system headers
00035 #include <unistd.h>
00036 
00037 // Gxsm headers
00038 #ifndef __XSMDEBUG_H
00039 #include "xsmdebug.h"
00040 #endif
00041 
00042 #ifndef __UNIT_H
00043 #include "unit.h"
00044 #endif
00045 
00046 #ifndef __XSMCLASSES_H
00047 #include "xsmclasses.h"
00048 #endif
00049 
00050 #ifndef __GXSM_CONF_H
00051 #include "gxsm_conf.h"
00052 #endif
00053 
00054 class XSM_Instrument;
00055 class XSM_Hardware;
00056 
00057 
00058 #define USHORT unsigned short
00059 #define SHT    short
00060 #define LNG    long
00061 #define CNT    unsigned long
00062 
00063 #define R2INT(X)  (int)(rint(X))
00064 #define R2LONG(X) (long)(rint(X))
00065 
00066 #define G_FREE_STRDUP(X,T)        { g_free(X); X=g_strdup(T); }
00067 #define G_NEWSIZE(X,N)            { g_free(X); X=g_new(gchar,N); }
00068 #define SUI_GFREEANDNEWCPY(X)     { G_FREE_STRDUP(X,t); }
00069 #define G_FREE_STRDUP_PRINTF(X,format,args...) { g_free(X); X=g_strdup_printf(format,##args); }
00070 
00071 typedef struct { int x,y; } Point2D;
00072 
00073 /*
00074  * X Resources
00075  * für Geräteparameter, etc.
00076  */
00077 
00078 #define PIDCHMAX 4
00079 #define DAQCHMAX 10
00080 #define CHLABELLEN 32
00081 
00082 #define GRIMAX 6
00083 
00084 #define GAIN_POSITIONS 9
00085 
00086 #define PATHSIZE 256
00087 #define STRSIZE  256
00088 #define MAXPALANZ 32
00089 
00090 // Gxsm rescources -- all set via Preferences, Name/Paths are similar to var name! See help there!
00091 typedef struct{
00092         gchar *HardwareTypeCmd;
00093         gchar HardwareType[32];
00094         gchar DSPDev[PATHSIZE];
00095         gchar InstrumentType[32];
00096         gchar InstrumentName[32];
00097         gchar SPort[8];
00098         gchar SMmap[10];
00099         gchar DataPath[PATHSIZE];
00100         gchar ProgHome[PATHSIZE];
00101         gchar UserPluginPath[PATHSIZE];
00102         gchar GxsmPalettePath[PATHSIZE];
00103         gchar UserPalettePath[PATHSIZE];
00104         gchar *PalPathList[MAXPALANZ];
00105         gchar LogFilePath[PATHSIZE];
00106         float DigRangeIn, AnalogVMaxIn;
00107         float DigRangeOut, AnalogVMaxOut;
00108         float V[GAIN_POSITIONS];
00109         int   VXdefault, VYdefault, VZdefault;
00110         int   VX0default, VY0default, VZ0default;
00111         int   AnalogOffsetAdding;
00112         float XPiezoAV,YPiezoAV,ZPiezoAV;
00113         gint  ScanOrgCenter;
00114         float XCalibVA,YCalibVA;
00115         float Sensitivity;
00116         float EnergyCalibVeV;
00117         float ThetaChGunInt;
00118         float ThetaChGunExt;
00119         float SampleLayerDist;
00120         float SampleUnitLen;
00121         float BiasGain;
00122         float nAmpere2Volt;
00123         float nNewton2Volt;
00124         float dHertz2Volt;
00125         int   HiLoDelta;
00126         // Adjustment: Limits, Step (Min,Max,Step,Page)
00127         float ProfileLogLimit;
00128         gchar pidsrc[PIDCHMAX][CHLABELLEN];
00129         gchar pidsrcZunit[PIDCHMAX][8];
00130         gchar pidsrcZlabel[PIDCHMAX][CHLABELLEN];
00131         int  pidchno[PIDCHMAX]; 
00132         int  piddefault;
00133         gchar daqsrc[DAQCHMAX][CHLABELLEN];
00134         int  daqchno[DAQCHMAX]; 
00135         gchar daqZunit[DAQCHMAX][8];
00136         gchar daqZlabel[DAQCHMAX][CHLABELLEN];
00137         int  daqdefault;
00138         //
00139         gchar *UnitCmd;
00140         gchar Unit[8];
00141         gchar FileNameConvention[12]; // digit, alpha
00142         gchar SliderControlType[12];     // omicron, sicaf
00143         gchar SPALEEDCrtl[12];        // unused
00144         gchar RemoteFifo[PATHSIZE];
00145         gchar RemoteFifoOut[PATHSIZE];
00146         gchar Palette[PATHSIZE];
00147         gchar griplottitle[STRSIZE];
00148         gchar gricmd1d[GRIMAX][PATHSIZE];
00149         gchar gricmd2d[GRIMAX][PATHSIZE];
00150         gchar XSM_Version[STRSIZE];
00151         gchar ProfileTicFont[STRSIZE];
00152         gchar ProfileLabFont[STRSIZE];
00153         gchar AutosaveUnit[12];         // storing Autosaveunit = percent, seconds, lines
00154         gchar AutosaveOverwritemode[8];
00155         gint  LineProfileOrgMode;
00156         gint  geomsave;
00157         gint  datnullok;
00158         gint  menutooltips;
00159         gint  antialiascanvas;
00160         gint  disableplugins;
00161         gint  force_config;
00162         gint  AutosaveValue;            //storing AutosaveValue for repetition of autosave
00163         gint  gui_layerfields;
00164         float HandleActBgColor[4];
00165         float HandleInActBgColor[4];
00166         gchar HandleType[32];
00167         gint  HandleLineWidth;
00168         gint  ObjectLineWidth;
00169         gchar ObjectLabFont[STRSIZE];
00170         float ObjectLabColor[4];
00171         gint  LoadDelay;
00172 } XSMRESOURCES;
00173 
00174 #define IS_FILENAME_CONVENTION_DIGIT  (!strncasecmp(xsmres.FileNameConvention,"digit",5))
00175 #define IS_FILENAME_CONVENTION_ALPHA  (!strncasecmp(xsmres.FileNameConvention,"alpha",5))
00176 #define IS_FILENAME_CONVENTION_DTIME  (!strncasecmp(xsmres.FileNameConvention,"date-time",9))
00177 
00178 #define IS_FILE_TYPE_NC               (!strncasecmp(xsmres.FileType,"nc",2))
00179 #define IS_FILE_TYPE_DAT              (!strncasecmp(xsmres.FileType,"dat",3))
00180 
00181 #define IS_MOVER_CTRL                 (!strncasecmp(xsmres.SliderControlType, "mover",5))
00182 #define IS_SLIDER_CTRL                (!strncasecmp(xsmres.SliderControlType, "slider",6))
00183 
00184 #define IS_SPALEED_CTRL               (!strncasecmp(xsmres.InstrumentType, "SPALEED",7))
00185 #define IS_SPM_CTRL                   (!strncasecmp(xsmres.InstrumentType, "STM",3) || !strncasecmp(xsmres.InstrumentType, "AFM",3) || !strncasecmp(xsmres.InstrumentType, "SNOM",4) || !strncasecmp(xsmres.InstrumentType, "SARLS",5))
00186 #define IS_AFM_CTRL                   (!strncasecmp(xsmres.InstrumentType, "AFM",3))
00187 #define IS_NOCARD                     (!strncasecmp(xsmres.HardwareType, "no",2))
00188 
00189 typedef struct UnitsTable{ 
00190   gchar *alias; gchar *s; gchar *pss; double fac; gchar *prec1; gchar *prec2; 
00191 };
00192 
00193 
00194 /*
00195  * Class: Display_Param
00196  * Display Parameter, set by user
00197  */
00198 
00199 class Display_Param{
00200 public:
00201         Display_Param(){ vframe = 0; vlayer = 0; };
00202         ~Display_Param(){};
00203 
00204         void copy(Display_Param &src){
00205                 contrast = src.contrast;
00206                 bright   = src.bright;
00207                 cpshigh  = src.cpshigh;
00208                 cpslow   = src.cpslow;
00209                 cnttime  = src.cnttime;
00210                 vrange_z = src.vrange_z;
00211                 voffset_z= src.voffset_z;
00212                 vframe   = src.vframe;
00213                 vlayer   = src.vlayer;
00214                 ViewFlg  = src.ViewFlg;
00215         };
00216 
00217         double ContrastBrightFkt(double x){
00218                 return x*contrast+bright;
00219         };
00220         double ContrastBright_from_HiLow(double range = 64.){
00221                 contrast = (cpshigh-cpslow)*cnttime/range;
00222                 bright   = range/2. - GetCntLow();
00223                 return 0.;
00224         };
00225         double GetCntHigh(){ return cpshigh*cnttime; };
00226         double GetCntLow(){ return cpslow*cnttime; };
00227 
00228         double contrast, bright;            /* for Scaling by Contrast/Bright */
00229         double vrange_z;                    /* for Scaling by Range and Offset from "Z-Center" */
00230         double voffset_z;                   /* for Scaling by Range and Offset from "Z-Center" */
00231         double cpshigh, cpslow, cnttime;    /* for Scaling by CPShi/low */
00232         int    vframe;                      /* Frame (in Time dimension) to view */
00233         int    vlayer;                      /* Layer (in Value dimension) to view */
00234 
00235         int    ViewFlg;                     /* View Mode */
00236 };
00237 
00238 
00239 /*
00240  * Struct: Scan_Param
00241  * Description: contains generic XSM Scan Parameters
00242  * xsm core internal base unit for all space dimensions is Angstroems
00243  */
00244 typedef struct Scan_Param{
00245 
00246 // scan data dimensions (quantization)
00247         int    ntimes;             /* Numer of Frames -- for future use, must be 1 so far */
00248         int    nvalues;            /* Numer of Values -- for varing one parameter scans */
00249         int    nx ,ny;             /* Number of data points in X and Y */
00250 
00251 // scan data real world dimensions (scale)
00252         double rx, ry, rz;         /* Scan Ranges [Ang] */
00253         double dx, dy, dz, dl;     /* Step Width  [Ang] */
00254         double alpha;              /* Scan Angle [deg] */
00255         double x0,y0;              /* Offset [Ang] */
00256 
00257 // generic and often used parameters, handy to have in the main window -- mirrored to main by HwI PlugIns, not essential --
00258 // IMPORTANT: DO NOT USE FOR ANY HARDWARE EXCEPT FOR WRITING/SHOWING TO THE USER!
00259         double SPA_OrgX, SPA_OrgY; /* secondary (used SPA-LEED only) Offset relativ to (0,0) [V] */
00260         double Energy;             /* Energy (if applicable) [eV], set to negative if not relevant */
00261         double GateTime;           /* GateTime (if applicable) [ms], set to negative if not relevant */
00262         double Bias;               /* some Bias (if applicable) [V], set to < -9.999e10 if not relevant */
00263         double Current;            /* some Curren (if applicable) [nA], set to < -9.999e10 if not relevant */
00264         double SetPoint;           /* some AFM SetPoint (if applicable) [V], set to < -9.999e10 if not relevant */
00265 
00266 // real time window of scan frame
00267         time_t tStart, tEnd;       /* Scan Start and end time, [UNIX time] */
00268 };
00269 
00270 // ** NOW 100% OBSOLETE AND REMOVED FROM CORE -- must now be handled independently by all HwI PlugIns. **
00271 // **
00272 // ** /* Parameter für DSP Programm (Regler etc. ...) */
00273 // ** /* 
00274 // **    *** THIS "DSP_Param" struct will become obsolete ASAP --
00275 // **        i.e. all HwIs and other PIs are independent of it!! 
00276 // **    *** 
00277 // ** */
00278 // ** typedef struct DSP_Param{
00279 //
00280 // ... all removed from GXSM core ... -- if you need the old struct, look at code before CVS tag "Expr2DSP-OldCore-Cleanup":
00281 //
00282 //   Repository revision: 1.17    /cvsroot/gxsm/Gxsm-2.0/src/xsmtypes.h,v
00283 //   Sticky Tag:          Expr2DSP-OldCore-Cleanup (branch: 1.17.4)
00284 //
00285 // ** };
00286 
00287 
00288 /*
00289  * User Info Fields
00290  * totally dynamically allocated - no length limit
00291  */
00292 class Scan_UserInfo{
00293 public:
00294         Scan_UserInfo(){
00295                 dateofscan = g_strdup("date");
00296                 user       = g_strdup("user");
00297                 host       = g_strdup("host");
00298                 comment    = g_strdup("empty");
00299                 title      = g_strdup("title not set");
00300                 name       = g_strdup("nobody");
00301                 basename   = g_strdup("specify_one");
00302                 originalname = g_strdup("unknown (not saved)");
00303                 type       = g_strdup("not set");
00304                 MakeUIdefaults();
00305         };
00306         ~Scan_UserInfo(){
00307                 XsmRescourceManager xrm("UI_remember");
00308                 xrm.Put("basename", basename);
00309                 g_free(dateofscan);
00310                 g_free(user);
00311                 g_free(host);
00312                 g_free(comment);
00313                 g_free(title);
00314                 g_free(name);
00315                 g_free(basename);
00316                 g_free(originalname);
00317                 g_free(type);
00318         };
00319 
00320         void MakeUIdefaults(){
00321                 char hn[256];
00322                 time_t t;
00323                 time(&t);
00324                 SetDateOfScan ("-- no scan --");
00325                 if(getlogin()){
00326                         G_FREE_STRDUP(user, getlogin());
00327                 }else{
00328                         G_FREE_STRDUP(user, "Nobody");
00329                 }
00330                 gethostname(hn, 256);
00331                 G_FREE_STRDUP(host, hn);
00332                 XsmRescourceManager xrm("UI_remember");
00333                 gchar *tmp;
00334                 xrm.Get("basename", &tmp, user);
00335                 G_FREE_STRDUP(basename, tmp);
00336                 g_free(comment); comment=g_strconcat(user, "@", hn, "\nSession Date: ", ctime(&t), NULL);
00337                 G_FREE_STRDUP(type, "not set");
00338         };
00339 
00340         void SetDateOfScan(const gchar *t){ SUI_GFREEANDNEWCPY(dateofscan); g_strdelimit (dateofscan, "\n", ' '); };
00341         void SetDateOfScanNow(){ 
00342                 time_t t;
00343                 time(&t);
00344                 SetDateOfScan (ctime(&t));
00345         };
00346         void SetUser(const gchar *t){ SUI_GFREEANDNEWCPY(user); };
00347         void SetHost(const gchar *t){ SUI_GFREEANDNEWCPY(host); };
00348         void SetComment(const gchar *t){ SUI_GFREEANDNEWCPY(comment); };
00349         void SetTitle(const gchar *t){ SUI_GFREEANDNEWCPY(title); };
00350         void SetName(const gchar *t){ SUI_GFREEANDNEWCPY(name); };
00351         void SetBaseName(const gchar *t){ SUI_GFREEANDNEWCPY(basename); };
00352         void SetOriginalName(const gchar *t){ SUI_GFREEANDNEWCPY(originalname); };
00353         void SetType(const gchar *t){ SUI_GFREEANDNEWCPY(type); };
00354 
00355         void copy(Scan_UserInfo &ui){
00356                 SetDateOfScan(ui.dateofscan);
00357                 SetUser(ui.user);
00358                 SetHost(ui.host);
00359                 SetComment(ui.comment);
00360                 SetTitle(ui.title);
00361                 SetName(ui.name);
00362                 SetBaseName(ui.basename);
00363                 SetOriginalName(ui.originalname);
00364                 SetType(ui.type);
00365         };
00366 
00367         gchar   *dateofscan;    /* time of measurement */
00368         gchar   *user;          /* Username */
00369         gchar   *host;          /* Hostname */
00370         gchar   *comment;       /* Kommentar */
00371         gchar   *title;         /* Scan/Profile Title */
00372         gchar   *name;          /* filename */
00373         gchar   *basename;      /* filename of the original data */
00374         gchar   *originalname;  /* ur-name */
00375         gchar   *type;          /* Scantype, DataSource-ScanDir ("X+ Topo") coding */
00376 };
00377 
00378 /* typedef struct{ */
00379 extern int scandatacount;
00380 
00381 typedef enum SCAN_ORIGIN { SCAN_ORG_MIDDLETOP, SCAN_ORG_CENTER };
00382 typedef enum SCAN_MODE { SCAN_MODE_SINGLE_DSPSET, SCAN_MODE_DUAL_DSPSET };
00383 typedef enum SCAN_TYPE { SCAN_TYPE_NORMAL, SCAN_TYPE_MULTILAYER };
00384 typedef enum SCAN_REPEAT_MODE { SCAN_REPEAT_MODE_UNIDIR, SCAN_REPEAT_MODE_BIDIR };
00385 
00386 
00387 class SCAN_DATA{
00388         int cnt;
00389 public:
00390         SCAN_DATA();
00391         virtual ~SCAN_DATA();
00392   
00393         SCAN_ORIGIN orgmode;
00394         SCAN_MODE scan_mode;
00395         SCAN_REPEAT_MODE scan_repeat_mode;
00396         SCAN_TYPE scan_type;
00397   
00398         int UnitsAlloc;
00399         UnitObj *Xunit, *Yunit, *Zunit, *Vunit;
00400         UnitObj *CurrentUnit, *VoltUnit, *TimeUnit, *TimeUnitms;
00401         UnitObj *CPSUnit, *EnergyUnit;
00402 
00403         void UpdateUnits(){
00404                 display.cnttime = s.GateTime;
00405                 //    CPSUnit->Change(display.cnttime); ... now dz is used !
00406         };
00407 
00408         void CpUnits(SCAN_DATA &src);
00409 
00410         void SetXUnit(UnitObj *u);
00411         void SetYUnit(UnitObj *u);
00412         void SetVUnit(UnitObj *u);
00413         void SetZUnit(UnitObj *u);
00414 
00415         /* Update Functions */
00416         void GetScan_Param(SCAN_DATA &src){ 
00417 //        XSMDEBUG("SCAN_DATA: GetScan #" << cnt);
00418                 scan_mode = src.scan_mode;
00419                 scan_repeat_mode = src.scan_repeat_mode;
00420                 memcpy((void*)&s, (void*)&src.s, sizeof(Scan_Param)); 
00421         };
00422 
00423 // **   void GetLayer_Param(SCAN_DATA &src){ 
00424 //    XSMDEBUG("SCAN_DATA: GetLayer #" << cnt);
00425 // **           lp.copy(src.lp); 
00426 // **   };
00427 
00428         void GetUser_Info(SCAN_DATA &src){
00429 //    XSMDEBUG("SCAN_DATA: GetUI #" << cnt);
00430                 ui.copy(src.ui);
00431         };
00432 
00433 // ** NOW 100% OBSOLETE AND REMOVED FROM CORE **
00434 // **
00435 // **  void GetDSP_Param(SCAN_DATA &src){ 
00436 // --     XSMDEBUG("SCAN_DATA: GetDSP #" << cnt);
00437 // **     memcpy((void*)&hardpars, (void*)&src.hardpars, sizeof(DSP_Param)); 
00438 // **     memcpy((void*)&hardpars_dual, (void*)&src.hardpars_dual, sizeof(DSP_Param)); 
00439 // **  };
00440 
00441         void GetDisplay_Param(SCAN_DATA &src){ 
00442 //    XSMDEBUG("SCAN_DATA: GetDisplay #" << cnt);
00443                 display.copy(src.display); 
00444         };
00445 
00446         /* Save / Retrive Values from Rescource */
00447         void SaveValues(gchar *SetName=NULL);
00448         void LoadValues(XSM_Instrument *Inst, XSM_Hardware *hardware, gchar *SetName=NULL);
00449 
00450         /* Data */
00451         Scan_Param      s;              /* Scan Parameter */
00452         Scan_UserInfo   ui;             /* User Informations */
00453         Display_Param   display;        /* Display */
00454 
00455 // ** NOW 100% OBSOLETE AND REMOVED FROM CORE -- must now be handled independently by all HwI PlugIns. **
00456 // **   Layer_Param     lp;             /* Scan Layer Parameter */
00457 
00458 // ** NOW 100% OBSOLETE AND REMOVED FROM CORE -- must now be handled independently by all HwI PlugIns. **
00459 // **   AntiDrift_Param ad;             /* Anti Drift Params */
00460 
00461 // ** NOW 100% OBSOLETE AND REMOVED FROM CORE -- must now be handled independently by all HwI PlugIns. **
00462 // **  DSP_Param       hardpars;       /* Hardware Control */
00463 // **  DSP_Param       hardpars_dual;  /* Hardware Control, 2nd Parameter Set for return Scan in Dual Mode  */
00464 };
00465 
00466 
00467 
00468 #endif
00469 
00470 
00471 

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