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 __XSMTYPES_H
00029 #define __XSMTYPES_H
00030
00031
00032 #include <cstring>
00033
00034
00035 #include <unistd.h>
00036
00037
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
00075
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
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
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];
00142 gchar SliderControlType[12];
00143 gchar SPALEEDCrtl[12];
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];
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;
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
00196
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;
00229 double vrange_z;
00230 double voffset_z;
00231 double cpshigh, cpslow, cnttime;
00232 int vframe;
00233 int vlayer;
00234
00235 int ViewFlg;
00236 };
00237
00238
00239
00240
00241
00242
00243
00244 typedef struct Scan_Param{
00245
00246
00247 int ntimes;
00248 int nvalues;
00249 int nx ,ny;
00250
00251
00252 double rx, ry, rz;
00253 double dx, dy, dz, dl;
00254 double alpha;
00255 double x0,y0;
00256
00257
00258
00259 double SPA_OrgX, SPA_OrgY;
00260 double Energy;
00261 double GateTime;
00262 double Bias;
00263 double Current;
00264 double SetPoint;
00265
00266
00267 time_t tStart, tEnd;
00268 };
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
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;
00368 gchar *user;
00369 gchar *host;
00370 gchar *comment;
00371 gchar *title;
00372 gchar *name;
00373 gchar *basename;
00374 gchar *originalname;
00375 gchar *type;
00376 };
00377
00378
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
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
00416 void GetScan_Param(SCAN_DATA &src){
00417
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
00424
00425
00426
00427
00428 void GetUser_Info(SCAN_DATA &src){
00429
00430 ui.copy(src.ui);
00431 };
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441 void GetDisplay_Param(SCAN_DATA &src){
00442
00443 display.copy(src.display);
00444 };
00445
00446
00447 void SaveValues(gchar *SetName=NULL);
00448 void LoadValues(XSM_Instrument *Inst, XSM_Hardware *hardware, gchar *SetName=NULL);
00449
00450
00451 Scan_Param s;
00452 Scan_UserInfo ui;
00453 Display_Param display;
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464 };
00465
00466
00467
00468 #endif
00469
00470
00471