DAS  3.1.6 - 18/09/2017
DAS_Spat.c
Go to the documentation of this file.
1 
9 #include <windows.h>
10 #include <math.h>
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include <winioctl.h>
15 #include <direct.h>
16 #include <io.h>
17 #include <fcntl.h>
18 #include <sys/types.h>
19 #include <sys/stat.h>
20 #include "mgui.h"
21 #include "DAS_Spatram.h"
22 #include "dcl.h"
23 #include "dil.h"
24 #include "dscud.h"
25 #include "wsc.h"
26 #include "dxl.h"
27 #include "solpos.h"
28 #include "bil.h"
29 #include "DOAS.h"
30 #include "nrutil.h"
31 #include "Marq.h"
32 #include "portio32.h"
33 #include "ISMMDLL.h"
34 #include "wdt.h"
35 
36 
37 
38 
39 //extern short _stdcall Inp32(short PortAddress);
40 //extern void _stdcall Out32(short PortAddress, short data);
41 
42 
43 // CCD & Camera vars
47 //lis LIS; ///< LIS
48 //pbutt PBUTT; ///< Command Button
56 //db_options DB_O; ///< Options
59 
64 //confp CONFP;
66 //omu OMU;
69 //hrizmeas HMEAS;
70 ZenithSt ZST; //Zenith
71 AzimuthSt AST; //Azimuth
74 bil BIL; //Bortul Library Structure
78 //mige MIGE;
79 
80 //das *pdas;
81 //das DAS;
82 //struct das *pdas;
83 //struct marconi *pmarconi;
84 
86 
87 
88 
89 
90 char *Program;
92 
93 long PrgCnt;
94 long PrgSiz;
96 int PrgNum = 0;
97 int PrgNumInM = 0;
98 int PrgNumExe = 0;
99 
100 int Master = 0;
102 
103 
104 
108 int Mode;
109 int on = 0;
110 int FirstTime = 1;
112 //int Offset[16];
113 int N_AVG = 25;
114 int N_RM = 0;
115 int TOTTEXP = 5;
116 int SZAMax = 100;
118 int IDX;
119 int IDY;
120 int BlindPix = 0;
121 
123 int ContFP = 0;
124 long REL_FILE_POS[51];
125 
126 unsigned int LevelDefPix = 100;
127 
128 unsigned int *mattempbuff;
129 
130 double TExp;
131 
132 
133 unsigned long countsopsh;
134 
135 int WlSet;// = 3; // Posizione di Home a 4358
136 
137 //FLAGS
138 int CCD_SetupFlg = 0;
139 //int ADTestFlg = 0;
140 int FlgSM_Stop = 1;
141 //int FlgNoAMS = 0;
142 
143 int ExeREM = 1;
144 
145 unsigned char WDT_Timeout = 100; //Initial WatchDog Timeout
147 
148 
149 /***************************************/
150 /*
151  * Color Identifiers
152  */
153 /*
154 MTColor black, white, darkblue, cadetblue, seagreen;
155 MTColor vmbg, green, red, orange;
156 MTColor darkvmbg, darkorange, darkred, darkgreen;
157 */
158 int PaletteMode; /* True if the system allows color animation */
159 
160 
161 
162 /***************************************/
163 /* Key Words definition*/
164 const char *KeyCode[] = {{"AUTORNG"}, {"AVGCCD"}, {"BEGIN"}, {"CALIBRA"}, {"DARKC"}, {"EXPO"},
165  {"FILTER"}, {"GETCCD"}, {"H_FILTER"}, {"H_GRAT"}, {"H_MIRROR"}, {"HG_OFF"},
166  {"HG_ON"}, {"LABEL"}, {"MEASURE"}, {"MIRROR"}, {"PLOT"},{"QJ_OFF"},
167  {"QJ_ON"}, {"RADIO"}, {"REM"}, {"SAVE"}, {"WAIT"}, {"WAVELEN"}, {"XEND"},
168  {"MEASHOR"}, {"ELAMPON"}, {"ELAMPOFF"}, {"ESHUTOP"}, {"ESHUTCL"},
169  {"H_ZEN"}, {"H_AZI"}, {"ZENITH"}, {"AZIMUTH"}, {"AAMEASURE"}, {"AVGCCDHOR"},
170  {"CHKEXLAMP"}, {"AAPOSIT"}, {"IREFSUN"}, {"MEASHOR2"},{"SETCCDTEMP"},{"SETCCDVBIN"},
171  {"SETCCDPOW"}, {"NDFILTER"}, {"H_NDFW"}, {"DFMEASURE"}, {"SETCCDOFFS"}, {"QJSCAN"},
172  {"H_GRAT_CAL"}, {"HGSCAN"}, {"ALMUCANTAR"}, {"DIRECTSUN"} };
173 
174 /***************************************/
175 /* WaveLength Code definition - for Wl_Buttons*/
176 //const char *Wl_Code[] = {{"2823"}, {"3337"}, {"3850"}, {"4358"}, {"4861"}, {"5332"}, {"5814"},
177 // {"6282"}, {"6734"}, {"7201"}, {"7677"}, {"8195"}, {"8622"}, {"9023"},
178 // {"9405"}, {"9758"}, {"10066"}, {"10358"}};
179 
180 /***************************************/
181 /* WaveLength definition - for SD_Grating*/
182  int wl[] = { 2823, 3337, 3850, 4358, 4861, 5332, 5814,
183  6282, 6734, 7201, 7677, 8195, 8622, 9023,
184  9405, 9758, 10066, 10358 };
185 
186 
187 /***************************************/
188 /* Step Number definition - for SD_Grating*/
189 // Calculated in Evora 13/11/2003 by DanBo; Excel File: Dispersione SPATRAM.xls
190 // This values were calculated assuming 3200 s/r for motor SM2.
191 // Now (07/11/2005) the SD_Grating procedure can be used also for other s/r parameters.
192 // i.e. - if SM2 is setted for 6400 s/r the values are doubled (X 2)
193 // i.e. - if SM2 is setted for 1600 s/r the values are divided for 2.
194 
195  long wav[] = { 36803, 24479, 12180, 0, -12238, -24031, -35587,
196  -46808, -57645, -68842, -80254, -92674, -102911, -112526,
197  -121684, -130148, -137532, -144533};
198 
199  /*****************************************************************************/
200  /*****************************************************************************/
201  // FILTER WHEEL CODES
202  /*****************************************************************************/
203  //Filter wheel with 8 position - only LIS
204  char *Fil_Code8H[] = {{"NULL"}, {"UG5"}, {"UG11"}, {"BG23"}, {"NULL"}, {"NULL"}, {"LPAS"}, {"NULL"}};
205 
206  //Filter wheel with 6 position -
207  char *Fil_Code[] = {{"NULL"}, {"UG11"}, {"UG1 "}, {"BG12"}, {"BG25"}, {"H475"}};
208 
209  //Filter wheel with 6 position - TROPOGAS
210  char *Fil_CodeTropo[] = {{"NULL"}, {"BG28"}, {"UG11"}, {"BG12"}, {"BG23"}, {"HPas"}};
211 
212  //Filter wheel with 6 position GASCOD NG1
213  char *Fil_CodeNG1[] = {{"NULL"}, {"B12 "}, {"S400"}, {"B39 "}, {"S500"}, {"UG5 "}};
214 
215  //Filter wheel with 6 position GASCOD NG2 and NG3
216  char *Fil_CodeNG[] = {{"NULL"}, {"B12 "}, {"B12F"}, {"B39 "}, {"B39F"}, {"UG5 "}};
217 
218  //Neutral Density Filter wheel with 6 position (SPATRAMPLUS and SPATRAM2
219  char *NDFil_Code[] = {{"NULL"}, {"ND1"}, {"ND2"}, {"ND3"}, {"ND4"}, {"H645"}};
220  /*****************************************************************************/
221  /*****************************************************************************/
222  // END OF FILTER WHEEL CODES
223  /*****************************************************************************/
224 
225 
226  //per Reference position of the Devices
227  char *HomePosition[] = {{"H_Mir"}, {"H_Grat"}, {"H_Filt"}, {"H_NDFilt"}, {"H_Zen"}, {"H_Azi"}, {"Close"}};
228 
229 
230  //Attenzione!!!! DEVONO ESSERE 8 CARATTERI
231  const char *Mir_Code[] = {{"Zenith "}, {"HorizDX"}, {"Calibra"}, {"HorizSX"}, {""}, {""}, {""}, {""}};
232 
233  //
234  const char *Mir_CodeTropo[] = {{"Calibra "}, {"HorizDX"}, {"NULL "}, {"HorizSX"}, {""}, {""}, {""}, {""}};
235 
236 // const char *MeasType[] = {{"Vertical"}, {"HorExtLamp ON"}, {"Calibration"}, {"Off-Axis"}, {"HorExtLamp OFF"}, {"Hor Diff Rad"}, {""}, {""}};
237  // To the Spectrometer inputs can be connected several devices:
238  // ZENITH --> the Zenith input can only perform vertical measurement (Direct)
239  // CALIBRA --> the calibration input can only be used with the integration sphere containing the calibration lamps
240  // HORIZDX and HORIZSX --> the 2 optic fibre input can be connected to:
241  // 1) TelesExtLamp --> Cassegrain Telescope with remote External lamp and shutter for horizontal measurements
242  // 2) AltAzimuth platform for vertical, horizontal with external lamp and shutter, off-axis measurements
243  // 3) Radiometer --> Spectral radiometer
244  // 4) TelesIntLamp --> Telescope3 with internal lamp and remote retroreflector mirror
245  // 5) TelescopeV --> optic system for vertical measurements
246 
247  const char *DeviceTypeInput[] = {{"Direct"}, {"TelesExtLamp"}, {"Calib Lamps"}, {"Alt-Az Platf"}, {"Radiometer"}, {"TelesIntLamp"}, {"TelescopeV"}, {""}};
248 
249 /***************************************/
250 
251 unsigned long *PLColor[]= {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
252 
253 int Server = 0;
254 
258 int LoadWlstep(void)
259 {
260  FILE *fs;
261  char str[80];
262  int c, i;
263  char buff[_MAX_PATH];
264 
265  sprintf(buff, "%s\\wlstep.ini",BIL.DFILEM.CONFIGDIREQUIPMENT);
266 
267 
268  fs = fopen(buff, "r");
269  if(fs == NULL) return 1;
270 
271  //
272  ReadLine(str, 80, fs); //###############################################
273  ReadLine(str, 80, fs); //# Param.INI #
274  ReadLine(str, 80, fs); //# Main configuration file for SPATRAM #
275  ReadLine(str, 80, fs); //# equipment #
276  ReadLine(str, 80, fs); //###############################################
277  ReadLine(str, 80, fs); //# ------------------------------------------- #
278  ReadLine(str, 80, fs); //# by DanBo Date at Time #
279 
280  fscanf(fs, "%d", &c); //Number of items
281  FlushLine(str, 80, fs);
282 
283  for (i=0;i<c;i++)
284  {
285  fscanf(fs, "%d %d", &wl[i], &wav[i]);
286 
287 
288  }
289  fclose(fs);
290 
291 
292  return 0;
293 }
294 
295 
296 
297 
298 int Fetch()
299 {
300  //Read the key-word
301  char cmd[16];
302  char buf[16];
303  int c;
304  int lencmd = 0;
305  int NumCommands;
306  int PosComm = 0;
307 
308 
309 
310  //if (Program[PrgCnt]!= 10)
311  //0x0a = line feed
312  //0x0d = carriage return
313  if (Program[PrgCnt]!= 10)
314  {
315  sscanf(&Program[PrgCnt], "%s", cmd);
316  sprintf (buf, "%s", cmd);
317 // Status(buf);
318 
319  //******************************
320  //Added on 15/01/2005 Remember to remove the commands
321  // "PrgCnt += X" in the E_xxxxxx Functions
322  lencmd =strlen(cmd);
323  PrgCnt += lencmd;
324  NumCommands = sizeof(KeyCode)/sizeof (KeyCode[0]);
325  //****************************
326  for(c = 0; c < NumCommands; c++)
327  {
328  if(strcmp(cmd, KeyCode[c]) == 0)
329  {
330  PosComm = c + 1;
331  break;
332  }
333  else
334  PosComm = 0;
335 
336  }
337  return PosComm;
338 
339  }
340  else
341  {
342 
343  return 2000;
344  }
345 
346 }
347 
348 int PRG_ChkKeyW(int line, char *fname)
349 {
350 
351 
352  return 0;
353 }
354 
355 int PRG_ChkMirror(int mod,char *filename, int record, int par)
356 {
357 
358  int ferr, er = 0;
359  char buff[_MAX_PATH];
360 
361  if ((par < 0) | (par > 3)) //error on mirror position
362  {
363  //OpenFile for Writing errors
364  ferr = open(filename, O_WRONLY | O_APPEND | O_TEXT| O_CREAT, S_IWRITE);
365  sprintf(buff, "Error at line %d: Mirror Position Current value %d. Allowed values 0 to 3\n", record,par);
366  write(ferr, buff, strlen(buff));
367  close(ferr);
368  //sprintf(buff,"Error in file:%s\nLine:%d\nMirror position: \nCurrent value %d\nAllowed values 0 to 3",PrgFile, line,m);
369  //MMessageDialog("DAS Inf.", buff,"OK", NULL);
370  er = 1;
371  }
372 
373  return er;
374 }
375 
376 int PRG_ChkGrating(int mod,char *filename, int record, int par)
377 {
378 
379  int ferr, er = 0;
380  char buff[_MAX_PATH];
381  int l;
382 
383  l= LookforWl_X(par);
384  if (l> 18 ) //error on grating position
385  {
386  //OpenFile for Writing errors
387  ferr = open(filename, O_WRONLY | O_APPEND | O_TEXT| O_CREAT, S_IWRITE);
388  sprintf(buff, "Error at line %d: Grating Position Current value %d. Allowed values 0 to 13\n", record, l);
389  write(ferr, buff, strlen(buff));
390  close(ferr);
391  //sprintf(buff,"Error in file:%s\nLine:%d\nMirror position: \nCurrent value %d\nAllowed values 0 to 3",PrgFile, line,m);
392  //MMessageDialog("DAS Inf.", buff,"OK", NULL);
393  er = 1;
394  }
395  else if (l<0)
396  {
397  //OpenFile for Writing errors
398  ferr = open(filename, O_WRONLY | O_APPEND | O_TEXT| O_CREAT, S_IWRITE);
399  sprintf(buff, "Error at line %d: Wavelength value %d not encounterd in the wlstep.ini file\n", record, par);
400  write(ferr, buff, strlen(buff));
401  close(ferr);
402  //sprintf(buff,"Error in file:%s\nLine:%d\nMirror position: \nCurrent value %d\nAllowed values 0 to 3",PrgFile, line,m);
403  //MMessageDialog("DAS Inf.", buff,"OK", NULL);
404  er = 1;
405  }
406 
407 
408 
409 
410 
411  return er;
412 }
413 
414 int PRG_ChkMeasAvg(int line, char *fname)
415 {
416 
417  int er = 0, eracc = 0;
418  int f, m, a, d, s, g, ferr,wl;
419  double t;
420  char buff[_MAX_PATH];
421 
422 
423  sscanf(&Program[PrgCnt], "%d%d%d%d%lf%d%d%d", &m, &wl, &f, &a, &t, &d, &s, &g);
424 
425  er = PRG_ChkMirror(0,fname, line, m);
426  eracc = eracc + er;
427 
428  er = PRG_ChkGrating(0,fname, line, wl);
429  eracc = eracc + er;
430 
431  if ((f < 0) | (f > 6)) //error on filter position
432  {
433  //OpenFile for Writing errors
434  ferr = open(fname, O_WRONLY | O_APPEND | O_TEXT| O_CREAT, S_IWRITE);
435  sprintf(buff, "Error at line %d: Filter Position Current value %d. Allowed values 0 to 6\n", line,f);
436  write(ferr, buff, strlen(buff));
437  close(ferr);
438  //sprintf(buff,"Error in file:%s\nLine:%d\nMirror position: \nCurrent value %d\nAllowed values 0 to 3",PrgFile, line,m);
439  //MMessageDialog("DAS Inf.", buff,"OK", NULL);
440  er = 1;
441 
442  }
443 
444  if ((a < 0) | (a > 1)) //error on autoranging
445  {
446  //OpenFile for Writing errors
447  ferr = open(fname, O_WRONLY | O_APPEND | O_TEXT| O_CREAT, S_IWRITE);
448  sprintf(buff, "Error at line %d: Autoranging Mode, Current value %d. Allowed values 0 to 1\n", line,a);
449  write(ferr, buff, strlen(buff));
450  close(ferr);
451  //sprintf(buff,"Error in file:%s\nLine:%d\nMirror position: \nCurrent value %d\nAllowed values 0 to 3",PrgFile, line,m);
452  //MMessageDialog("DAS Inf.", buff,"OK", NULL);
453  er = 1;
454 
455  }
456 
457  if ((t < 0) | (t > 45)) //error on exposure time
458  {
459  //OpenFile for Writing errors
460  ferr = open(fname, O_WRONLY | O_APPEND | O_TEXT| O_CREAT, S_IWRITE);
461  sprintf(buff, "Error at line %d: Exposure Time Current value %f. Allowed values 0 to 45 sec\n", line,t);
462  write(ferr, buff, strlen(buff));
463  close(ferr);
464  //sprintf(buff,"Error in file:%s\nLine:%d\nMirror position: \nCurrent value %d\nAllowed values 0 to 3",PrgFile, line,m);
465  //MMessageDialog("DAS Inf.", buff,"OK", NULL);
466  er = 1;
467 
468  }
469 
470  if ((d < 0) | (d > 1)) //error on dark or light
471  {
472  //OpenFile for Writing errors
473  ferr = open(fname, O_WRONLY | O_APPEND | O_TEXT| O_CREAT, S_IWRITE);
474  sprintf(buff, "Error at line %d: type of Measurements Current value %d. Allowed values 0 (Dark) to 1 (Light)\n", line,d);
475  write(ferr, buff, strlen(buff));
476  close(ferr);
477  //sprintf(buff,"Error in file:%s\nLine:%d\nMirror position: \nCurrent value %d\nAllowed values 0 to 3",PrgFile, line,m);
478  //MMessageDialog("DAS Inf.", buff,"OK", NULL);
479  er = 1;
480 
481  }
482 
483  if ((s < 0) | (s > 1)) //error on saving file parameter
484  {
485  //OpenFile for Writing errors
486  ferr = open(fname, O_WRONLY | O_APPEND | O_TEXT| O_CREAT, S_IWRITE);
487  sprintf(buff, "Error at line %d: Saving on file, Current value %d. Allowed values 0 (NO SAVE) to 1 (SAVE)\n", line,s);
488  write(ferr, buff, strlen(buff));
489  close(ferr);
490  //sprintf(buff,"Error in file:%s\nLine:%d\nMirror position: \nCurrent value %d\nAllowed values 0 to 3",PrgFile, line,m);
491  //MMessageDialog("DAS Inf.", buff,"OK", NULL);
492  er = 1;
493 
494  }
495 
496  if ((g < 0) | (g > 1)) //error on plot display
497  {
498  //OpenFile for Writing errors
499  ferr = open(fname, O_WRONLY | O_APPEND | O_TEXT| O_CREAT, S_IWRITE);
500  sprintf(buff, "Error at line %d: Plot Display Current value %d. Allowed values 0 (NO PLOT) to 1 (SHOW PLOT)\n", line,g);
501  write(ferr, buff, strlen(buff));
502  close(ferr);
503  //sprintf(buff,"Error in file:%s\nLine:%d\nMirror position: \nCurrent value %d\nAllowed values 0 to 3",PrgFile, line,m);
504  //MMessageDialog("DAS Inf.", buff,"OK", NULL);
505  er = 1;
506 
507  }
508 
509 
510  return eracc;
511 }
512 
513 
514 
515 int PRG_ChKBegin(int line, char *fname)
516 {
517  int er = 0, eracc = 0;
518 // int l, m, g;
519 // double t;
520 // char buff[_MAX_PATH];
521 
522 
523 
524 
525  return er;
526 }
527 
528 
529 //mod = 0: procedure called at DAS Boot ( no status message)
530 //mod = 1: procedure called from the TOOLS keyboard ( Message dialog displayed)
531 int PRG_Check(int mod, char *prgname)
532 {
533  int er = 0, flin = 0, ls, ferr;
534  int inf = 0, error = 0 ;
535  long siz = 0;
536  long accbyte = 0;
537  long tmp;
538  char buff[32], str[_MAX_PATH], fname[32],ffnerr[_MAX_PATH];
539  int m ;
540 
541  //sprintf(buff,"\0");
542 
543  er = LoadExec(prgname);
544 
545  DI_SplitName(prgname, str, buff);
546 
547 
548  ls = strlen(buff);
549  sprintf(fname,"\0");
550  sprintf(ffnerr,"\0");
551  strncat(fname, buff, ls-3);
552  strcat(fname,"err");
553  strcat(str,fname);
554  strcat(ffnerr,str);
555 
556 /**********************/
557  if(DI_FileExist(ffnerr)) // DI_FileExist --> Return: 1 if PATH exist, else return 0
558  {
559  //Delete the old err file
560  remove(ffnerr);
561  }
562 
563 
564 /**********************/
565  if (er)
566  {
567  do
568  {
569  flin ++;
570  er = Fetch();
571  switch(er)
572  {
573  case AUTORNG: while(Program[PrgCnt++] != 10); break; // 1
574  case AVGCCD:
575  error = PRG_ChkMeasAvg(flin, ffnerr);
576  while(Program[PrgCnt++] != 10);
577  break; // 2
578  case BEGIN:
579  error = PRG_ChKBegin(flin, ffnerr);
580  while(Program[PrgCnt++] != 10);
581  break; // 3
582 
583  case CALIBRA: while(Program[PrgCnt++] != 10); break; // 4
584  case DARKC: while(Program[PrgCnt++] != 10); break; // 5
585  case EXPO: while(Program[PrgCnt++] != 10); break; // 6
586  case FILTER: while(Program[PrgCnt++] != 10); break; // 7
587  case GETCCD: while(Program[PrgCnt++] != 10); break; // 8
588  case H_FILTER: while(Program[PrgCnt++] != 10); break; // 9
589  case H_GRAT: while(Program[PrgCnt++] != 10); break; // 10
590  case H_MIRROR: while(Program[PrgCnt++] != 10); break; // 11
591  case HG_OFF: while(Program[PrgCnt++] != 10); break; // 12
592  case HG_ON: while(Program[PrgCnt++] != 10); break; // 13
593  case LABEL: while(Program[PrgCnt++] != 10); break; // 14
594  case MEASURE:
595  error = PRG_ChkMeasAvg(flin, ffnerr);
596  while(Program[PrgCnt++] != 10);
597  break; // 15
598  case MEASHOR:
599  error = PRG_ChkMeasAvg(flin, ffnerr);
600  while(Program[PrgCnt++] != 10);
601  break; // 16
602  case MIRROR:
603  sscanf(&Program[PrgCnt], "%d", &m);
604  error = PRG_ChkMirror(0, ffnerr, flin, m);
605  while(Program[PrgCnt++] != 10);
606  break; // 17
607  case PLOT: while(Program[PrgCnt++] != 10); break; // 18
608  case QJ_OFF: while(Program[PrgCnt++] != 10); break; // 19
609  case QJ_ON: while(Program[PrgCnt++] != 10); break; // 20
610  case RADIO: while(Program[PrgCnt++] != 10); break; // 21
611  case REM: while(Program[PrgCnt++] != 10); break; // 22
612  case SAVE: while(Program[PrgCnt++] != 10); break; // 23
613  case WAIT: while(Program[PrgCnt++] != 10); break; // 24
614  case WAVELEN:
615  sscanf(&Program[PrgCnt], "%d", &m);
616  error = PRG_ChkGrating(0, ffnerr, flin, m);
617  while(Program[PrgCnt++] != 10); break; // 25
618  case XEND: PrgCnt = PrgSiz; break; // 26
619 
620  case ELAMPON: while(Program[PrgCnt++] != 10); break; // 27
621  case ELAMPOFF: while(Program[PrgCnt++] != 10); break; // 28
622  case ESHUTOP: while(Program[PrgCnt++] != 10); break; // 29
623  case ESHUTCL: while(Program[PrgCnt++] != 10); break; // 30
624 
625  case H_ZEN: while(Program[PrgCnt++] != 10); break; // 31
626  case H_AZI: while(Program[PrgCnt++] != 10); break; // 32
627  case ZENITH: while(Program[PrgCnt++] != 10); break; // 33
628  case AZIMUTH: while(Program[PrgCnt++] != 10); break; // 34
629  case AAMEASURE:while(Program[PrgCnt++] != 10); break; // 35
630  case AVGCCDHOR:while(Program[PrgCnt++] != 10); break; // 36
631  case CHKEXLAMP:while(Program[PrgCnt++] != 10); break; // 37
632  case AAPOSIT :while(Program[PrgCnt++] != 10); break; // 38
633  case IREFSUN :while(Program[PrgCnt++] != 10); break; // 39
634  case MEASHOR2 :while(Program[PrgCnt++] != 10); break; // 40
635  case SETCCDTEMP :while(Program[PrgCnt++] != 10); break; // 41
636  case SETCCDVBIN :while(Program[PrgCnt++] != 10); break; // 42
637  case SETCCDPOW :while(Program[PrgCnt++] != 10); break; // 43
638  case NDFILTER :while(Program[PrgCnt++] != 10); break; // 44
639  case DFMEASURE:while(Program[PrgCnt++] != 10); break; // 44
640  case H_NDFW :while(Program[PrgCnt++] != 10); break; // 45
641  case SETCCDOFFS :while(Program[PrgCnt++] != 10); break; // 47
642  case QJSCAN :while(Program[PrgCnt++] != 10); break; // 48
643  case H_GRAT_CAL :while(Program[PrgCnt++] != 10); break; // 49
644  case HGSCAN :while(Program[PrgCnt++] != 10); break; // 50
645  case ALMUCANTAR :while(Program[PrgCnt++] != 10); break; // 51
646  case DIRECTSUN :while(Program[PrgCnt++] != 10); break; // 52
647 
648  case 0:
649  while(Program[PrgCnt++] != 10);
650  inf = 1;
651  //OpenFile for Writing errors
652  ferr = open(ffnerr, O_WRONLY | O_APPEND | O_TEXT| O_CREAT, S_IWRITE);
653  sprintf(buff, "Error at line %d: Command NOT FOUND\n", flin);
654  write(ferr, buff, strlen(buff));
655  close(ferr);
656  //sprintf(buff,"Command not found at line %d ", flin );
657  //MMessageDialog("DAS Inf.", buff,"OK", NULL);
658 
659  break;
660  case 2000:
661  PrgCnt = PrgSiz;
662  inf = 1;
663  //OpenFile for Writing errors
664  ferr = open(ffnerr, O_WRONLY | O_APPEND | O_TEXT| O_CREAT, S_IWRITE);
665  sprintf(buff, "Error at line %d: XEND NOT FOUND\n", flin);
666  write(ferr, buff, strlen(buff));
667  close(ferr);
668  //sprintf(buff,"Command not found at line %d ", flin );
669  //MMessageDialog("DAS Inf.", buff,"OK", NULL);
670 
671 
672 
673 
674  }
675  inf = inf + error;
676  tmp = (PrgCnt + 2) - (accbyte);
677  accbyte= accbyte + tmp;
678  // accbyte= PrgCnt;
679 
680  //}while (accbyte < PrgSiz );
681  }while (PrgCnt < PrgSiz );
682  if (inf == 0)
683  {
684  //DI_SplitName(PrgFile, str, buff);
685  sprintf(str, "File:%s correctely Compiled",prgname);
686  if (mod)
687  MMessageDialog("DAS Inf.", str,"OK", NULL);
688  //Status (str);
689  delay(1000);
690  return 0;
691 
692  }
693  else
694  {
695  //DI_SplitName(PrgFile, str, buff);
696 // sprintf(str, "PRG File:\n%s\ncontains error/s\nThe DAS will close!!!!\n Retry with other PRG.",PrgFile);
697 // MMessageDialog("DAS Inf.", str,"OK", NULL);
698  sprintf(str, "PRG File:\n%s\ncontains error/s\nYou can:\n Close DAS\nView the errors\n ",prgname);
699  er = MMessageDialog("DAS Inf. - PRG Errors", str,"Close", "View err",NULL);
700  if (er)
701  {
702  sprintf(str,"%s\\MEDIT.EXE %s", BIL.DFILEM.HOMEDIRECTORY, ffnerr);
703  er = WinExec(str, SW_SHOW);
704  sprintf(str,"%s\\MEDIT.EXE %s", BIL.DFILEM.HOMEDIRECTORY, prgname);
705  er = WinExec(str, SW_SHOW);
706  //exit(0);
707  return 1;
708 
709  }
710  else
711  {
712  MGUITerm();
713  exit(0);
714  }
715 
716  }
717  }
718  else
719  {
720  sprintf(buff,"Problem in opening the PRG file!!!!");
721  MMessageDialog("DAS Inf.", buff,"OK", NULL);
722  return 2;
723  }
724 
725 }
726 
727 
728 void MGUIQuitCB(MOBJECT shell, void *od, void *ad)
729 {
730  if (MMessageDialog("DAS Exit Message", "Do you really want to quit ?", " Yes ", " No ", NULL))
731  return;
732  MShellUnrealize(shell);
733  MShellDestroy(shell);
734  MGUITerm();
735  exit(0);
736 }
737 
738 
739 int ExMaster(int m, int mode)
740 {
741  FILE *fd;
742  char buf[MAX_PATH];
743  int i,fn, er;
744 
745  if(m == 0) return 0;
746 
747  if (mode == TEMPORIZED)
748  {
749  fd = fopen("MASTER", "rt");
750  if(fd == NULL) return -1;
751  //Read 3 line of comments
752  ReadLine(buf, 80, fd);
753  ReadLine(buf, 80, fd);
754  ReadLine(buf, 80, fd);
755  do
756  {
757  //Read the start time (hour and minutes), the end time and the PRG file to be executed -
758  //format:HHs MMs HHe MMe filename.PRG (es. 15 45 16 45 Test.prg)
759  fscanf(fd, "%d%d%d%d%d%d%s", &ExMast[PrgNumInM].sora, &ExMast[PrgNumInM].smin,&ExMast[PrgNumInM].ssec,
760  &ExMast[PrgNumInM].eora, &ExMast[PrgNumInM].emin, &ExMast[PrgNumInM].esec,
761  &ExMast[PrgNumInM].prg);
762 
763  //PrgNum++;
764  PrgNumInM++;
765  SaveCnt = 1;
766  fgets(buf, 80, fd);
767 
768  }while(!feof(fd) && PrgNumInM < PRGMAXNUM);
769  fclose(fd);
770  }
771  if (mode == SZAMASTERM)
772  {
773  fd = fopen("MASTERSZA", "rt");
774  if(fd == NULL) return -2;
775  do
776  {
777  //Read the start and end values for SZA and the PRG file to be executed
778  //format:SZAs SZAe filename.PRG (es. 85.00 95.00 Test.prg
779  fscanf(fd, "%f %f %s", &ExMast[PrgNumInM].ssza, &ExMast[PrgNumInM].esza, &ExMast[PrgNumInM].prg);
780 
781  PrgNumInM++;
782  SaveCnt = 1;
783  fgets(buf, 80, fd);
784 
785  }while(!feof(fd) && PrgNumInM < PRGMAXNUM);
786  fclose(fd);
787  }
788 
789  if (mode == SZAMODE)
790  {
791  fd = fopen("SZAPRG", "rt");
792  if(fd == NULL) return -3;
793  do
794  {
795  //Read the Min and Max SZA and the PRG file to be executed
796  //format:MinSZA (xxx.xx) MaxSZA (yyy.yy) filename.PRG (es. 85.00 95.00 Test.prg)
797  fscanf(fd, "%f %f %s", &ExMast[PrgNumInM].minsza, &ExMast[PrgNumInM].maxsza, &ExMast[PrgNumInM].prg);
798 
799  PrgNumInM++;
800  SaveCnt = 1;
801  fgets(buf, 80, fd);
802 
803  } while(!feof(fd) && PrgNumInM < PRGMAXNUM);
804  fclose(fd);
805 
806  }
807  if (mode == TESTSZAMODE)
808  {
809  fd = fopen("SZAPRG", "rt");
810  if(fd == NULL) return -3;
811  do
812  {
813  //Read the Min and Max SZA and the PRG file to be executed
814  //format:MinSZA (xxx.xx) MaxSZA (yyy.yy) filename.PRG (es. 85.00 95.00 Test.prg)
815  fscanf(fd, "%f %f %s", &ExMast[PrgNumInM].minsza, &ExMast[PrgNumInM].maxsza, &ExMast[PrgNumInM].prg);
816 
817  PrgNumInM++;
818  SaveCnt = 1;
819  fgets(buf, 80, fd);
820 
821  } while(!feof(fd) && PrgNumInM < PRGMAXNUM);
822 
823 
824  fclose(fd);
825 
826  }
827 
828  //Check Existence of all PRG files
829  for (i=0; i<PrgNumInM; i++)
830  {
831  sprintf(buf, "%s\\%s",BIL.DFILEM.HOMEDIRECTORY, ExMast[i].prg);
832  fn = access(buf, 0);
833  if (fn == -1)
834  {
835  sprintf(buf, "File %s\\%s NOT Encountred.\n Please Check!!!!!",BIL.DFILEM.HOMEDIRECTORY, ExMast[i].prg);
836  MMessageDialog("DAS Information", buf, " Ok ", NULL);
837 
838  }
839  else
840  {
841  Status("PRG Files encountered");
842  delay(1000);
843  }
844 
845  }
846 
847  //Check the é.PRGs Syntax
848  for (i=0; i<PrgNumInM; i++)
849  {
850  er = PRG_Check(0, ExMast[i].prg);
851  }
852 
853 
854 
855  return 1;
856 }
857 
858 void DB_SelButt_CB(MOBJECT obj, MKeyEvent *pe, void *a_data)
859 {
860  int c = (int) a_data;
861  switch (pe->keycode)
862  {
863 
864  case ESC:
865  on = 0;
866  Status("PROGRAM HALTED");
867  break;
868 
869 
870  case SPACEBAR:
871  on = 1;
872  Status(" ");
873 
874  break;
875 
876 
877  }
878 
879 }
880 
881 int DB_HelpCB(MOBJECT o, void *od, void *ad)
882 {
883  int er;
884  char str[_MAX_PATH];
885  char buf[_MAX_PATH];
886 /* er = MMessageDialog("?", "Informations ?", "Yes", "No", NULL);
887  if (!er)
888  return 1;
889  return 0;
890 */
891  //build the help file name
892  sprintf(str, "%s\\Help\\html\\chm\\DAS.chm",BIL.DFILEM.HOMEDIRECTORY);
893 
894  //check for the existence of the hh.exe int the winnt dir
895  if(DI_FileExist("C:\\WINNT\\hh.exe")) // DI_FileExist --> Return: 1 if PATH exist, else return 0
896  {
897  sprintf(buf, "C:\\WINNT\\hh.exe %s",str);
898  er = WinExec(buf, SW_SHOWMAXIMIZED);
899  }
900  else if(DI_FileExist("C:\\Windows\\hh.exe"))
901  {
902  sprintf(buf, "C:\\Windows\\hh.exe %s",str);
903  er = WinExec(buf, SW_SHOWMAXIMIZED);
904  }
905  else
906  {
907  sprintf(buf, "%s\\Help\\html\\index.html",BIL.DFILEM.HOMEDIRECTORY);
908  system(buf);
909  }
910 
911  return 0;
912 
913 }
914 
915 int DB_InfCB(MOBJECT o, void *od, void *ad)
916 {
917  int er;
918  char str[_MAX_PATH];
919  char buf[_MAX_PATH];
920 /* er = MMessageDialog("?", "Informations ?", "Yes", "No", NULL);
921  if (!er)
922  return 1;
923  return 0;
924 */
925  //build the help file name
926  sprintf(str, "%s\\Help\\html\\chm\\DAS.chm",BIL.DFILEM.HOMEDIRECTORY);
927 
928  //check for the existence of the hh.exe int the winnt dir
929  if(DI_FileExist("C:\\WINNT\\hh.exe")) // DI_FileExist --> Return: 1 if PATH exist, else return 0
930  {
931  sprintf(buf, "C:\\WINNT\\hh.exe %s",str);
932  er = WinExec(buf, SW_SHOWMAXIMIZED);
933  }
934  else if(DI_FileExist("C:\\Windows\\hh.exe"))
935  {
936  sprintf(buf, "C:\\Windows\\hh.exe %s",str);
937  er = WinExec(buf, SW_SHOWMAXIMIZED);
938  }
939  else
940  {
941  sprintf(buf, "%s\\Help\\html\\index.html",BIL.DFILEM.HOMEDIRECTORY);
942  system(buf);
943  }
944 
945  return 0;
946 
947 }
948 
949 
950 
951 
952 void InitFlags(void)
953 {
954 
955 
956 
957  ZST.Pos = 0;
958 
959 
960  FLAG.ADPC104 = 0; //Flag for PC104 Presence
961 
962  DPWD.FlgSh_PWD = 1; //PassWord Flag
963 
964  PrgFile[0] = 0; //PRG File
965 
966  DAS.Marconi.ReachTemp = 0;
967 
968  GRS.dp = 1500; //dead pulse for grating backlash recovery
969 
970 
971  ADTESTER.OutputMode = 0; // for the AD Converter
972 
973  BIL.BLENS.Pix = 1; // for the lens tool
974 
975  MIS.Pos = 0; //Init Mirror Position
976  MIS.Dir = 0; //Init Mirror Direction
977  MIS.Off = 0; //Init Mirror Offset
978 
979  DAS.StepM.SM_A = 0;
980  DAS.StepM.SM_B = 1;
981  DAS.StepM.Addr[AMS1] = 0;
982  DAS.StepM.Addr[AMS2] = 1;
983  DAS.StepM.Addr[AMS3] = 2;
984 /*
985  DAS.StepM.SM1 = 0; //Motor A (su Y11) InputMirror
986  DAS.StepM.SM2 = 1; //Motor B (su Y12) Grating
987  DAS.StepM.SM3 = 2; //Motor A (su Y11) FilterWheel
988  DAS.StepM.SM4 = 3; //Not Available
989  DAS.StepM.SM5 = 4; //Motor A (su Y11) Zenith
990  DAS.StepM.SM6 = 5; //Motor B (su Y12) Azimuth
991 */
992  FLAG.sza = 0;
993  FLAG.exec = 1;
994  FLAG.settemp8095 = 1;
995  FLAG.settemp7080 = 1;
996  FLAG.settemp070 = 1;
997 
998  FLAG.fileprg = 0; //Flag indicating the execution of a PRG file: = 0 --> No PRG File; = 1 --> PRG file in execution
999  FLAG.ADTempTest = 0;
1000  FLAG.VMRsf = 0;
1001 
1002  TOOLS.FlagFilter = 0;
1003  TOOLS.FlagSpikes = 0;
1004  TOOLS.FlagDisplay = 2;
1005 
1006  DOAS.FFTFilter = 5;
1007 
1008  FLAG.OMU_TempReached = 0;
1009 
1010 
1011 // pdas->pOMUTHR.->CoolCnt = 1;
1012 // pdas->pOMUTHR.->PID_On = 1;
1013 
1014  OMUTHR.CoolCnt = 1;
1015  OMUTHR.PID_On = 1;
1016 
1017  OMUTHR.PID_kp = 38;
1018  OMUTHR.PID_ki = 5;
1019  OMUTHR.PID_kd = (float) 0.008;
1020 
1021  FLAG.extshutter = 0; // 0 = external shutter open; 1 = external shutter closed
1022 
1023  //on 15/06/2005 only the shutter channel is used
1024  FLAG.extlamp = 0; // 0 = external lamp OFF; 1 = external lamp ON
1025  FLAG.manhormeas = 0;
1026  FLAG.AMS_H = 0;
1027  DAS.DOption.amsprogbar =0;
1028  DAS.Nova.DigOut = 0;
1029  DAS.Nova.DigIn = 0;
1030  DAS.Tools.FlagShutter = 0;
1031 
1032  DAS.Marconi.Offset = 270;
1033 
1034  DAS.Flag.UPS_Battery = 0;
1035 
1036  DAS.Nova.WDT_TOUT = 250;
1037  DAS.DOption.resetEnabled = 1;
1038  DAS.DOption.resetType = 1; //Reset period type 1=day(s), 0=hour(s)
1039  DAS.DOption.resetFreq = 7; //Reset period interval
1040  DAS.Flag.WindowsReboot = 0; //Flag that became 1 when Windows reboot is setted (\ref SetWinowsReset)
1041 
1042 
1043 
1044 }
1045 
1046 
1047 void DemoInitMotor(void)
1048 {
1049 
1050  char buf[80];
1051  unsigned long st;
1052 
1053 
1054  //Simulate home mirror
1055  /*************************************************/
1056  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[0][0], "SYS\\ledoff.bmp");
1057  sprintf(buf, "%s", "Homing");
1058  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[0], buf);
1059  Status("Home for Mirror...");
1060 
1061  st = GetTickCount();
1062 
1063  if(DAS.DOption.amsprogbar)
1064  D_VRange("Homing Mirror",0, 255, 0, 0);
1065 
1066  D_Positioning(DAS.Gui.ContrPanel.Albl_LS[0], 1, 1000);
1067 
1068  if(DAS.DOption.amsprogbar)
1069  D_VRange(NULL, 100, 0,0,0);
1070 
1071  MIS.Pos = 0;
1072  if (DAS.Paramini.EqType == TROPOGAS || DAS.Paramini.EqType == SPATRAM3 || DAS.Paramini.EqType == GASCODNG4 )
1073  sprintf(buf, "%s",Mir_CodeTropo[MIS.Pos]);
1074  else
1075  sprintf(buf, "%s",Mir_Code[MIS.Pos]);
1076 
1077  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[0], buf);
1078  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[0][0], "SYS\\ledGreen.bmp");
1079  Status("Home for Mirror..DONE");
1080  /**************************************************/
1081  //Simulate home grating
1082  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[0][1], "SYS\\ledoff.bmp");
1083  sprintf(buf, "%s", "Homing");
1084  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[1], buf);
1085  Status("Home for Grating...");
1086 
1087  st = GetTickCount();
1088 
1089  if(DAS.DOption.amsprogbar)
1090  D_VRange("Homing Grating",0, 255, 255, 0);
1091 
1092  D_Positioning(DAS.Gui.ContrPanel.Albl_LS[1], 1, 1000);
1093 
1094  if(DAS.DOption.amsprogbar)
1095  D_VRange(NULL, 100, 0,0,0);
1096 
1097  GRS.Wl = LookforWl_X(4358);//Lookfor4358();
1098  sprintf(buf, "%d", 4358);
1099  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[1], buf);
1100  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[0][1], "SYS\\ledGreen.bmp");
1101  Status("Home for Grating..DONE");
1102 
1103  /**************************************************/
1104  //Simulate home filter wheel
1105  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[1][0], "SYS\\ledoff.bmp");
1106  sprintf(buf, "%s", "Homing");
1107  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[2], buf);
1108  Status("Home for Filter Wheel...");
1109 
1110  st = GetTickCount();
1111 
1112  if(DAS.DOption.amsprogbar)
1113  D_VRange("Homing Filter Wheel",0, 0, 0, 255);
1114 
1115  D_Positioning(DAS.Gui.ContrPanel.Albl_LS[2], 1, 1000);
1116 
1117  if(DAS.DOption.amsprogbar)
1118  D_VRange(NULL, 100, 0,0,0);
1119 
1120  FWS.Pos = 0;
1121  sprintf(buf, "%s", "NULL");
1122  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[2], buf);
1123  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[1][0], "SYS\\ledGreen.bmp");
1124  Status("Home for Filter Wheel..DONE");
1125 
1126  if(DAS.Paramini.EqType == TROPOGAS||
1127  DAS.Paramini.EqType == SPATRAMPLUS ||
1128  DAS.Paramini.EqType == GASCODNG1 ||
1129  DAS.Paramini.EqType == GASCODNG2 ||
1130  DAS.Paramini.EqType == GASCODNG3 ||
1131  DAS.Paramini.EqType == GASCODNG4 ||
1132  DAS.Paramini.EqType == SPATRAM2 ||
1133  DAS.Paramini.EqType == SPATRAM3)
1134  {
1135  if(DAS.MIGE.linked == 1)
1136  {
1137  /**************************************************/
1138  //Simulate home Zenith
1139  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[2][0], "SYS\\ledoff.bmp");
1140  sprintf(buf, "%s", "Homing");
1141  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[4], buf);
1142  Status("Home for Zenith Axis...");
1143 
1144  st = GetTickCount();
1145 
1146  if(DAS.DOption.amsprogbar)
1147  D_VRange("Homing Zenit Axis",0, 0, 128, 255);
1148 
1149  D_Positioning(DAS.Gui.ContrPanel.Albl_LS[4], 1, 1000);
1150 
1151  if(DAS.DOption.amsprogbar)
1152  D_VRange(NULL, 100, 0,0,0);
1153 
1154  ZST.Pos = 0;
1155  sprintf(buf, "%s", "0");
1156  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[4], buf);
1157  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[2][0], "SYS\\ledGreen.bmp");
1158  Status("Home for Zenith Wheel..DONE");
1159 
1160  /**************************************************/
1161  //Simulate home Azimuth
1162  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[2][1], "SYS\\ledoff.bmp");
1163  sprintf(buf, "%s", "Homing");
1164  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[5], buf);
1165  Status("Home for Azimuth Axis...");
1166 
1167  st = GetTickCount();
1168 
1169  if(DAS.DOption.amsprogbar)
1170  D_VRange("Homing Azimuth Axis",0, 128, 128, 255);
1171 
1172  D_Positioning(DAS.Gui.ContrPanel.Albl_LS[5], 1, 1000);
1173 
1174  if(DAS.DOption.amsprogbar)
1175  D_VRange(NULL, 100, 0,0,0);
1176 
1177  AST.Pos = 0;
1178  sprintf(buf, "%s", "0");
1179  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[5], buf);
1180  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[2][1], "SYS\\ledGreen.bmp");
1181  Status("Home for Azimuth..DONE");
1182  }
1183  else
1184  {
1185  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[2][1], "SYS\\ledoffg.bmp");
1186  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[2][0], "SYS\\ledoffg.bmp");
1187  }
1188  }
1189  else
1190  {
1191  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[2][1], "SYS\\ledoffg.bmp");
1192  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[2][0], "SYS\\ledoffg.bmp");
1193 
1194 
1195  }
1196 
1197 }
1198 
1199 //MOBJECT Mshell;
1200 
1201 int LoadAMS(void)
1202 {
1203 
1204  FILE *fs;
1205  char str[80];
1206  int c, i, k;
1207 
1208  char buff[_MAX_PATH];
1209 
1210  sprintf(buff, "%s\\AMS.INI", BIL.DFILEM.CONFIGDIREQUIPMENT);
1211 
1212 
1213  fs = fopen(buff, "r");
1214  if(fs == NULL) return 1;
1215 
1216  // Header
1217  ReadLine(str, 80, fs); //###############################################
1218  ReadLine(str, 80, fs); //# AMS.INI #
1219  ReadLine(str, 80, fs); //# Main configuration file for AMS Devices #
1220  ReadLine(str, 80, fs); //###############################################
1221  ReadLine(str, 80, fs); //# ------------------------------------------- #
1222  ReadLine(str, 80, fs); //# by DanBo Date at Time #
1223  ReadLine(str, 80, fs); //# ------------------------------------------- #
1224 
1225  // Number of AMS
1226  ReadLine(str, 80, fs);//# Number of AMS #
1227  fscanf(fs, "%d", &DAS.StepM.NAMS);
1228  FlushLine(str, 80, fs);
1229 
1230 
1231  for (i = 0; i < DAS.StepM.NAMS; i++)
1232  {
1233  for (k=0; k<2; k++)
1234  {
1235  ReadLine(str, 80, fs);//# Input Mirror Stepper Motor - SM1 #
1236  ReadLine(str, 80, fs);//# SM1 Power (0 = 0A - 76 = 1.52A) #
1237 
1238  fscanf(fs, "%d", &DAS.StepM.power[i][k]);
1239  if((DAS.StepM.power[i][k] < 0) | (DAS.StepM.power[i][k] > 76))
1240  return 2;
1241 
1242  FlushLine(str, 80, fs);
1243  ReadLine(str, 80, fs);//# SM1 Step (0=400s/r, 1=800s/r,2=1000/sr) #
1244 
1245  fscanf(fs, "%d", &DAS.StepM.step[i][k]);
1246  if((DAS.StepM.step[i][k] < 0) | (DAS.StepM.step[i][k] > 14))
1247  return 3;
1248 
1249  FlushLine(str, 80, fs);
1250  ReadLine(str, 80, fs);//# SM1 Slope (0 - 255) #
1251 
1252  fscanf(fs, "%d", &DAS.StepM.slope[i][k]);
1253  if((DAS.StepM.slope[i][k] < 0) | (DAS.StepM.slope[i][k] > 255))
1254  return 4;
1255 
1256  FlushLine(str, 80, fs);
1257  ReadLine(str, 80, fs);//# SM1 Speed Hz (PS = 125*(n+1), n=0,1..255) #
1258 
1259  fscanf(fs, "%d", &DAS.StepM.speed[i][k]);
1260  if((DAS.StepM.speed[i][k] < 0) | (DAS.StepM.speed[i][k] > 255))
1261  return 5;
1262 
1263  FlushLine(str, 80, fs);
1264  ReadLine(str, 80, fs);//# SM1 Multiplier #
1265 
1266  fscanf(fs, "%f", &DAS.StepM.multiplier[i][k]);
1267  FlushLine(str, 80, fs);
1268 
1269 
1270  }
1271  }
1272 
1273 
1274 
1275  // Legge gli offset dei vari stepper
1276  // ad oggi 9 valori
1277  ReadLine(str, 80, fs);
1278  ReadLine(str, 80, fs);
1279  for(c = 0; c < 9; c++)
1280  fscanf(fs,"%d" , &DAS.Paramini.Offset[c]);
1281  FlushLine(str, 80, fs);
1282 
1283  ReadLine(str, 80, fs);
1284  ReadLine(str, 80, fs);
1285 
1286  for(i = 0; i < DAS.StepM.NAMS; i++)
1287  {
1288  for(k = 0; k < 2; k++)
1289  {
1290  fscanf(fs,"%d" , &DAS.StepM.hometype[i][k]);
1291  }
1292  }
1293 
1294  FlushLine(str, 80, fs);
1295 
1296 
1297  ReadLine(str, 80, fs);
1298  fclose(fs);
1299 
1300  return 0;
1301 
1302 
1303 
1304 }
1305 
1306 int NOVA_In(int novatype, unsigned int DigIn)
1307 {
1308 
1309  int er=0;
1310 
1311 
1312 
1313  if(novatype == NOVA7892)
1314  {
1315  er=InByte(0x240, &DigIn);
1316  return er;
1317  }
1318  if(novatype == NOVA945GSE)
1319  {
1320 
1321  //Definition for NOVA945GSE I/O (IT8712F)
1322  HANDLE hIsmm;
1323 // HWM_DATA gHwmData;
1324 // UCHAR szBuf[32];
1325 // WORD wNodeCount, wBufSize, ii;
1326 // FLOAT *pfValue;
1327 // ULONG *plValue;
1328  //DIO Var
1329 // WORD wDioConfig;
1330 // WORD wDioOut;
1331 
1332 
1333 
1334  hIsmm = ISMM_Open();
1335  if (hIsmm == INVALID_HANDLE_VALUE)
1336  {
1337  //printf("Can not open iSMM device\n");
1338  if (DAS.Flag.exemode == DBDEMO)
1339  return 0;
1340  else
1341  {
1342  MMessageDialog("I/O Tester", "Can not open iSMM device", "OK", NULL);
1343  return -1;
1344  }
1345  }
1346  // get DIO Config
1347  //if ( DIO_GetConfig(hIsmm, &wDioConfig) )
1348 // er = DIO_GetConfig(hIsmm, &wDioConfig) ;
1349 // if ( er )
1350 // { MMessageDialog("Super I/O Tester", "DIO Found", "OK", NULL);
1351 // }
1352 
1353  // get DIO Input
1354  if ( DIO_GetInput(hIsmm, &(unsigned short) DigIn))
1355  {
1356 
1357  }
1358 
1359  // set DIO OutPut
1360  //if ( DIO_SetOutput(hIsmm, (WORD) &DigIn) )
1361  //{
1362 
1363  //}
1364 
1365 
1366 
1367  ISMM_Close(hIsmm);
1368  return er;
1369  }
1370  return er;
1371 
1372 }
1373 
1374 
1375 int NOVA_Out(int novatype, unsigned int out)
1376 {
1377 
1378  int er=0;
1379 
1380 
1381 
1382  if(novatype == NOVA7892)
1383  {
1384  er=OutByte(0x240, out);
1385  return er;
1386  }
1387 
1388  if(novatype == NOVA6612G2)
1389  {
1390 
1391  //Definition for NOVA6612G2 I/O (W83697HF)
1392  HANDLE hndFile; // Handle to device, obtain from CreateFile
1393 // UCHAR data_b;
1394  WDTPARAM cParam;
1395  DWORD nReturn;
1396 
1397  hndFile = CreateFile(WDT_DEVICE, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE,
1398  NULL, OPEN_EXISTING, 0, NULL);
1399 
1400  cParam.data_b=out;
1401  DeviceIoControl(hndFile, IOCTL_SYS_DIO_WRITE,
1402  &cParam, sizeof(WDTPARAM), 0, 0, &nReturn, NULL);
1403 
1404  CloseHandle(hndFile);
1405  return er;
1406  }
1407 
1408 
1409  if(novatype == NOVA945GSE)
1410  {
1411 
1412  //Definition for NOVA945GSE I/O (IT8712F)
1413  HANDLE hIsmm;
1414 // HWM_DATA gHwmData;
1415 // UCHAR szBuf[32];
1416 // WORD wNodeCount, wBufSize, ii;
1417 // FLOAT *pfValue;
1418 // ULONG *plValue;
1419  //DIO Var
1420  WORD wDioConfig;
1421  WORD wDioOut;
1422 
1423 
1424 
1425  hIsmm = ISMM_Open();
1426  if (hIsmm == INVALID_HANDLE_VALUE)
1427  {
1428  //printf("Can not open iSMM device\n");
1429  if (DAS.Flag.exemode == DBDEMO)
1430  return 0;
1431  else
1432  {
1433 
1434  MMessageDialog("I/O Tester", "Can not open iSMM device", "OK", NULL);
1435  return -1;
1436  }
1437  }
1438  // get DIO Config
1439  if ( DIO_GetConfig(hIsmm, &wDioConfig) )
1440  er = DIO_GetConfig(hIsmm, &wDioConfig) ;
1441 // if ( er )
1442 // { MMessageDialog("Super I/O Tester", "DIO Found", "OK", NULL);
1443 // }
1444 
1445  // get DIO Output
1446  if ( DIO_GetOutput(hIsmm, &wDioOut) )
1447  {
1448  }
1449 
1450  // set DIO OutPut
1451  if ( DIO_SetOutput(hIsmm, (WORD) out) )
1452  {
1453 
1454  }
1455 
1456 
1457  ISMM_Close(hIsmm);
1458  return er;
1459  }
1460 
1461  return er;
1462 
1463 }
1464 
1465 
1466 /********************************************/
1467 /*---------------------------------------------------------------------*/
1468 /********************************************
1469  WATCH DOG TIMER
1470 */
1471 
1472 /********************************************/
1473 /*---------------------------------------------------------------------*/
1474 /********************************************
1475 
1476 */
1477 int D_Timing(int id, long tout)
1478 {
1479  unsigned long st, et, x;
1480  char buf[80];
1481 
1482  st = GetTickCount();
1483  do
1484  {
1485  et = GetTickCount();
1486  x = labs(et - st);
1487  MLoopWhileEvents(0);
1488  if((x % 10) == 0 && x > 0)
1489  {
1490  sprintf(buf, "%.1lf", (double)fabs((tout-(double)(labs(et - st) ))/1000.0 ));
1492  }
1493  if (WDT_flagstop)
1494  {
1495  WDT_func(0);
1496  return 0;
1497  }
1498  }while((labs(et - st) < tout) && (WDT_flagstop == 0));
1499  return 0;
1500 }
1501 
1502 /********************************************/
1503 /*---------------------------------------------------------------------*/
1504 /********************************************
1505 
1506 */
1507 void WDT_CB(MOBJECT p, void *od, void *ad)
1508 {
1509  int c = (int) ad, er;
1510  char buf[80];
1511  long timeout;
1512 
1513  MObjectGetText(p, buf);
1514  er = strcmp(buf, "Start");
1515  if (er==0)
1516  {
1517  MObjectSetText(p, "Stop");
1519  DAS.Nova.WDT_TOUT = atoi(buf);
1520 
1521  timeout = (long) (DAS.Nova.WDT_TOUT) * 1000;
1522  WDT_flagstop = 0;
1523 
1524  WDT_func(1); //1 --> Start WDT
1525  D_Timing(0, timeout);
1526  }
1527  else
1528  {
1529  WDT_flagstop = 1;
1530  MObjectSetText(p, "Start");
1531  WDT_func(0); //0 --> Stop WDT
1533  }
1534 }
1535 
1536 /********************************************/
1537 /*---------------------------------------------------------------------*/
1538 /********************************************
1539 
1540 */
1541 
1542 /*---------------------------------------------------------------------*/
1543 /********************************************
1544 
1545 */
1546 
1547 void WDT_Task_CB(MOBJECT o, void *od, void *ad)
1548 {
1549 
1550  int er;
1551  char buf[80];
1552 
1553  MObjectGetText(o, buf);
1554  er = strcmp(buf, "Launch Task");
1555  if (er==0)
1556  {
1557  MObjectSetText(o, "Task in Exec.");
1558  MRefreshTimeout(&IDS.WDT, WDT_TASK_TIME, TaskWDT, NULL);
1559  }
1560  else
1561  {
1562  MObjectSetText(o, "Launch Task");
1563  WDT_func(0);
1564  }
1565 }
1566 
1567 /********************************************/
1568 /*---------------------------------------------------------------------*/
1569 
1570 // mod = 1 --> Start Watch Dog Timer
1571 // mod = 0 --> STOP Watch Dog Timer
1572 void WDT_func(int mod)
1573 {
1574 
1575  int er;
1576 
1577 
1578  if (mod) //Start WDT
1579  {
1580  if(DAS.Nova.type == NOVA7892)
1581  {
1582  er = OutByte(0x443, WDT_TASK_TIME);
1583  er = InByteR(0x443);
1584  }
1585  if(DAS.Nova.type == NOVA6612G2)
1586  {
1587 
1588  // The following parameters are used in the IOCTL call
1589  HANDLE hndFile; // Handle to device, obtain from CreateFile
1590 // UCHAR data_b;
1591  WDTPARAM cParam;
1592  DWORD nReturn;
1593 
1594 
1595 
1596  hndFile = CreateFile(WDT_DEVICE, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE,
1597  NULL, OPEN_EXISTING, 0, NULL);
1598 
1599  cParam.timeout=(unsigned char) WDT_TASK_TIME;
1600  DeviceIoControl(hndFile, IOCTL_SYS_WDT_SET_TIMEOUT,
1601  &cParam, sizeof(WDTPARAM), NULL, 0, &nReturn, NULL);
1602  DeviceIoControl(hndFile, IOCTL_SYS_WDT_START,
1603  NULL, 0, NULL, 0, &nReturn, NULL);
1604 
1605  CloseHandle(hndFile);
1606  }
1607  if(DAS.Nova.type == NOVA945GSE)
1608  {
1609 
1610  //Definition for NOVA945GSE I/O (IT8712F)
1611  HANDLE hIsmm;
1612 // HWM_DATA gHwmData;
1613 // UCHAR szBuf[32];
1614 // WORD wNodeCount, wBufSize, ii;
1615 // FLOAT *pfValue;
1616 // ULONG *plValue;
1617  //DIO Var
1618 // WORD wDioConfig;
1619 // WORD wDioOut;
1620 
1621 
1622 
1623 
1624  hIsmm = ISMM_Open();
1625  if (hIsmm == INVALID_HANDLE_VALUE)
1626  {
1627  printf("Can not open iSMM device\n");
1628  }
1629 
1631 
1632  WDT_Start(hIsmm,1);
1633 
1634  ISMM_Close(hIsmm);
1635  }
1636 
1637 
1638 
1639  }
1640  else //STOP WDT
1641  {
1642  if(DAS.Nova.type == NOVA7892)
1643  {
1644  er = InByteR(0x843);
1645  }
1646  if(DAS.Nova.type == NOVA6612G2)
1647  {
1648 
1649  // The following parameters are used in the IOCTL call
1650  HANDLE hndFile; // Handle to device, obtain from CreateFile
1651 // UCHAR data_b;
1652 // WDTPARAM cParam;
1653  DWORD nReturn;
1654 
1655 
1656  hndFile = CreateFile(WDT_DEVICE, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE,
1657  NULL, OPEN_EXISTING, 0, NULL);
1658 
1659  DeviceIoControl(hndFile, IOCTL_SYS_WDT_STOP,
1660  NULL, 0, NULL, 0, &nReturn, NULL);
1661 
1662  CloseHandle(hndFile);
1663  }
1664  if(DAS.Nova.type == NOVA945GSE)
1665  {
1666  //Definition for NOVA945GSE I/O (IT8712F)
1667  HANDLE hIsmm;
1668 // HWM_DATA gHwmData;
1669 // UCHAR szBuf[32];
1670 // WORD wNodeCount, wBufSize, ii;
1671 // FLOAT *pfValue;
1672 // ULONG *plValue;
1673  //DIO Var
1674 // WORD wDioConfig;
1675 // WORD wDioOut;
1676 
1677  hIsmm = ISMM_Open();
1678  if (hIsmm == INVALID_HANDLE_VALUE)
1679  {
1680  printf("Can not open iSMM device\n");
1681  }
1682 
1683  WDT_Start(hIsmm,0);
1684 
1685  ISMM_Close(hIsmm);
1686  }
1687 
1688  }
1689 }
1690 /********************************************/
1691 /*---------------------------------------------------------------------*/
1692 /********************************************
1693 
1694 
1695 /********************************************/
1696 /*---------------------------------------------------------------------*/
1697 /********************************************
1698 
1699 */
1700 // Restart Watch DOG Timer
1701 void WDTRefresh(void)
1702 {
1703  int er=0;
1704 
1705  // The following parameters are used in the IOCTL call
1706 // HANDLE hndFile; // Handle to device, obtain from CreateFile
1707 // UCHAR data_b;
1708 // WDTPARAM cParam;
1709 // DWORD nReturn;
1710  if(DAS.Nova.type == NOVA7892)
1711  {
1712  er = InByteR(0x843); //TIMER STOP
1713 
1714  er = InByteR(0x443); //TIMER START
1715  }
1716  if(DAS.Nova.type == NOVA6612G2)
1717  {
1718 
1719  // The following parameters are used in the IOCTL call
1720  HANDLE hndFile; // Handle to device, obtain from CreateFile
1721 // UCHAR data_b;
1722  WDTPARAM cParam;
1723  DWORD nReturn;
1724 
1725 
1726  hndFile = CreateFile(WDT_DEVICE, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE,
1727  NULL, OPEN_EXISTING, 0, NULL);
1728  cParam.timeout=(unsigned char) WDT_TASK_TIME;
1729  DeviceIoControl(hndFile, IOCTL_SYS_WDT_SET_TIMEOUT,
1730  &cParam, sizeof(WDTPARAM), NULL, 0, &nReturn, NULL);
1731  CloseHandle(hndFile);
1732  }
1733  if(DAS.Nova.type == NOVA945GSE)
1734  {
1735  //Definition for NOVA945GSE I/O (IT8712F)
1736  HANDLE hIsmm;
1737 // HWM_DATA gHwmData;
1738 // UCHAR szBuf[32];
1739 // WORD wNodeCount, wBufSize, ii;
1740 // FLOAT *pfValue;
1741 // ULONG *plValue;
1742  //DIO Var
1743 // WORD wDioConfig;
1744 // WORD wDioOut;
1745 
1746  hIsmm = ISMM_Open();
1747  if (hIsmm == INVALID_HANDLE_VALUE)
1748  {
1749  printf("Can not open iSMM device\n");
1750  }
1751 
1753 
1754  WDT_Start(hIsmm,1);
1755 
1756  ISMM_Close(hIsmm);
1757  }
1758 
1759 
1760 }
1761 
1762 /********************************************/
1763 /*---------------------------------------------------------------------*/
1764 /********************************************
1765 
1766 */
1767 void TaskWDT(TIMEOUT_ID id, void *data)
1768 {
1769 
1770  WDTRefresh();
1771 
1772  // Refresh the WDT tineout (if this instruction is not executed
1773  //after 250 sec the PC reboot!!!)
1774 
1775  MRefreshTimeout(&IDS.WDT, WDT_TASK_TIME, TaskWDT, NULL);
1776 }
1777 
1778 /********************************************/
1779 /*---------------------------------------------------------------------*/
1780 /********************************************
1781 
1782 /*
1783  In the last realise of the ECU, 2 relais were added:
1784  the first for the activation of the Hires's Power supply
1785  the second for the activation of the Peltier's Power Supply (24V)
1786  For this reason the first initialization has to be done for
1787  the AMSs device (that drive the relais via the ROI and the AMS OPTOInsulated port)
1788  and after the Hires can be initialized
1789 */
1790 
1791 //mod = Equipment type
1792 //emode = execution mode
1793 int InitCCD_AMS(int mod, int emode)
1794 {
1795 
1796  int er;
1797  char buf[1024];
1798 
1799 
1800  ShutterOpening(0);
1801 
1802  if(mod == TROPOGAS )
1803  {
1804 
1805  //1) Init AMS
1806  //2) Switch-on Power Supply for CCD Camera
1807  //3) Init Camera
1808  //4) Switch-on Power Supply for OMU Peltier (24V)
1809 
1810  /********************************************************
1811  ***************** INIT AMS *********************
1812  *********************************************************/
1813 
1814  if ((emode == TEMPORIZED) | (emode == PRGFILE) | (emode == TESTAMS) | (emode == MANUAL) | (emode == SZAMASTERM)| (emode == SZAMODE))
1815  //if ((emode == TEMPORIZED) | (emode == PRGFILE) | (emode == TESTAMS) | (emode == MANUAL) )
1816  {
1817  //Disattiva i pulsanti sulla keyboard
1818  DB_KB_ButtonActive(0);
1819  // Inizializza ed esegue l'home per i motori
1820  er = DB_InitMotor(1);
1821  //Attiva i pulsanti sulla keyboard
1822  DB_KB_ButtonActive(1);
1823  }
1824  else if((emode == DBDEMO) || (emode == TESTSZAMODE ))
1825  {
1826  DemoInitMotor();
1827  }
1828 
1829  //Switch on the HIRES Power supply
1830  if (emode != TESTAMS)
1831  {
1832  if(!FLAG.AMSPres)
1833  HiresPS(1);
1834 
1835  Status ("Waiting 1 Sec.");
1836  delay(1000);
1837  Status("Init CCD Camera");
1838  //Init Camera
1839  /********************************************************
1840  ***************** INIT CAMERA *********************
1841  *********************************************************/
1842  DB_KB_ButtonActive(0);
1843  // Init HIRES_IV and MARCONI CCD sensor
1844  er = DB_InitCamera(0);
1845  if(er)
1846  {
1847  if ((er > 0) & (er < 50))
1848  {
1849  sprintf(buf,DC_ErrorMessage(er));
1850  CCD_Error(buf);
1851  }
1852  else
1853  sprintf(buf,"Error %d in DB_InitCamera", er);
1854 
1855  Status(buf);
1856  //sprintf(buf," Camera NOT Found");
1857  D_WriteInitLog(buf);
1858  }
1859  else
1860  {
1861  sprintf(buf," Camera found");
1862  D_WriteInitLog(buf);
1863  }
1864  }
1865  DB_KB_ButtonActive(1);
1866 
1867  //The focus is taken by the Control Panel
1869  /******************************************************/
1870  // Load the dispersion coefficient for DOAS Use
1871  er = LoadDB_DispCoeff();
1872  /*******************************************************/
1873 
1874  //Switch on the 24V Power Supply
1875  if (emode != TESTAMS)
1876  if(!FLAG.AMSPres)
1877  {
1878  PeltierPS(1);
1879  Status ("Waiting 1 Sec.");
1880  delay(1000);
1881  }
1882  }
1883  else if((mod == LIS_) | (mod == SPATRAM))// for SPATRAM, LIS
1884  {
1885  //1) Init Camera
1886  //2) Init AMS
1887  /********************************************************
1888  ***************** INIT CAMERA *********************
1889  *********************************************************/
1890  DB_KB_ButtonActive(0);
1891  // Init HIRES_IV and MARCONI CCD sensor
1892  er = DB_InitCamera(0);
1893  if(er)
1894  {
1895  if ((er > 0) & (er < 50))
1896  {
1897  sprintf(buf,DC_ErrorMessage(er));
1898  CCD_Error(buf);
1899  }
1900  else
1901  sprintf(buf,"Error %d in DB_InitCamera", er);
1902 
1903  Status(buf);
1904  //sprintf(buf," Camera NOT Found");
1905  D_WriteInitLog(buf);
1906  }
1907  else
1908  {
1909  sprintf(buf," Camera found");
1910  D_WriteInitLog(buf);
1911  }
1912  DB_KB_ButtonActive(1);
1913 
1914  //The focus taken by the CP shell
1916  /******************************************************/
1917  // Load the dispersion coefficient for DOAS Use
1918  er = LoadDB_DispCoeff();
1919  /*******************************************************/
1920  /********************************************************
1921  ***************** INIT AMS *********************
1922  *********************************************************/
1923  if ((emode == TEMPORIZED) | (emode == PRGFILE) | (emode == TESTAMS) | (emode == MANUAL)| (emode == SZAMASTERM)| (emode == SZAMODE))
1924  {
1925  //Disattiva i pulsanti sulla keyboard
1926  DB_KB_ButtonActive(0);
1927  // Inizializza ed esegue l'home per i 3 motori
1928  er = DB_InitMotor(1);
1929  //Attiva i pulsanti sulla keyboard
1930  DB_KB_ButtonActive(1);
1931  }
1932  else if((emode == DBDEMO)||(emode == TESTSZAMODE))
1933  {
1934  DemoInitMotor();
1935  }
1936  }
1937  else if(mod == GASCODNG2 ||
1938  mod == GASCODNG3 ||
1939  mod == GASCODNG4 ||
1940  mod == SPATRAM3 ||
1941  mod == SPATRAM2 ||
1942  mod == SPATRAMPLUS ||
1943  mod == GASCODNG1 )// for GASCODNG1, NG2, NG3, SPATRAM2, SPATRAMPLUS
1944  {
1945  //0) Switch ON Hires and AMS Power supply through the NOVA Digital Output port
1946  //1) Init Camera
1947  //2) Init AMS
1948  //3) Switch ON 24V Power supply (for Peltier) through the NOVA Digital Output port
1949 
1950  /*********************************************************/
1951  //switch on the 12 Volt and Hires Power Supply
1952  /*********************************************************/
1953  if (DAS.Nova.type == NOVA7892)
1954  {
1955  er = NOVA_Out(DAS.Nova.type, 6); //0110 bin
1956  delay(1000);
1957  }
1958  if (DAS.Nova.type == NOVA945GSE)
1959  {
1960  er = NOVA_Out(DAS.Nova.type, 9); //1001 bin
1961  delay(3000);
1962  }
1963 /*
1964  nb = 2;
1965  er = ChkDigIO(DAS.Nova.DigOut, nb);
1966  if (er == 1)
1967  DAS.Nova.DigOut &= ~((unsigned char) pow(2,(double)(nb)));
1968  else if (er == 0)
1969  DAS.Nova.DigOut |= (unsigned char) pow(2,(double)(nb));
1970 
1971  er = NOVA_Out(DAS.Nova.type, DAS.Nova.DigOut);
1972 */
1973  //OutByte(576, DAS.Nova.DigOut);
1974 
1975  if(mod == SPATRAM2 || mod == GASCODNG4 || mod== SPATRAM3)
1977  /********************************************************
1978  ***************** INIT CAMERA *********************
1979  *********************************************************/
1980  DB_KB_ButtonActive(0);
1981  // Init HIRES_IV and MARCONI CCD sensor
1982  er = DB_InitCamera(0);
1983  if(er)
1984  {
1985  if ((er > 0) & (er < 50))
1986  {
1987  sprintf(buf,DC_ErrorMessage(er));
1988  CCD_Error(buf);
1989  }
1990  else
1991  sprintf(buf,"Error %d in DB_InitCamera", er);
1992 
1993  Status(buf);
1994  //sprintf(buf," Camera NOT Found");
1995  D_WriteInitLog(buf);
1996  }
1997  else
1998  {
1999  sprintf(buf," Camera found");
2000  D_WriteInitLog(buf);
2001  }
2002  DB_KB_ButtonActive(1);
2003 
2004  //The focus taken by the CP shell
2006  /******************************************************/
2007  // Load the dispersion coefficient for DOAS Use
2008  er = LoadDB_DispCoeff();
2009  /*******************************************************/
2010  /********************************************************
2011  ***************** INIT AMS *********************
2012  *********************************************************/
2013  if ((emode == TEMPORIZED) | (emode == PRGFILE) | (emode == TESTAMS) | (emode == MANUAL)| (emode == SZAMASTERM)| (emode == SZAMODE))
2014  {
2015  //Disattiva i pulsanti sulla keyboard
2016  DB_KB_ButtonActive(0);
2017  // Inizializza ed esegue l'home per i 3 motori
2018  er = DB_InitMotor(1);
2019  //Attiva i pulsanti sulla keyboard
2020  DB_KB_ButtonActive(1);
2021  }
2022  else if((emode == DBDEMO) | (emode == TESTSZAMODE))
2023  {
2024  DemoInitMotor();
2025  }
2026 
2027  /*********************************************************/
2028  //switch on the 24 Volt Power Supply
2029  /*********************************************************/
2030 /* nb = 1;
2031 
2032  er = ChkDigIO(DAS.Nova.DigOut, nb);
2033  if (er == 1)
2034  DAS.Nova.DigOut &= ~((unsigned char) pow(2,(double)(nb)));
2035  else if (er == 0)
2036  DAS.Nova.DigOut |= (unsigned char) pow(2,(double)(nb));
2037  er = NOVA_Out(DAS.Nova.type, DAS.Nova.DigOut);
2038 */
2039  //OutByte(576, DAS.Nova.DigOut);
2040  delay(1000);
2041 
2042  }
2043  //return er;
2044  return 0;
2045 }
2046 
2047 
2048 void ChkDASInstance(int etype)
2049 {
2050 
2051  HWND das;
2052  char buff[1024], str[32];
2053  int c = etype;
2054 
2055 
2056  switch (c)
2057  {
2058  case TROPOGAS:
2059  sprintf(str,"TROPOGAS");
2060  break;
2061  case SPATRAM:
2062  sprintf(str,"SPATRAM");
2063  break;
2064  case LIS_:
2065  sprintf(str,"LIS");
2066  break;
2067  case SPATRAMPLUS:
2068  sprintf(str,"SPATRAMPLUS");
2069  break;
2070  case GASCODNG1:
2071  sprintf(str,"GASCODNG1");
2072  break;
2073  case GASCODNG2:
2074  sprintf(str,"GASCODNG2");
2075  break;
2076  case GASCODNG3:
2077  sprintf(str,"GASCODNG3");
2078  break;
2079  case GASCODNG4:
2080  sprintf(str,"GASCODNG4");
2081  break;
2082  case SPATRAM3:
2083  sprintf(str,"SPATRAM3");
2084  break;
2085  case SPATRAM2:
2086  sprintf(str,"SPATRAM2");
2087  break;
2088 
2089  default:
2090  sprintf(str,"UNKNOWN");
2091  break;
2092  }
2093 
2094  sprintf(buff,"DAS Release %d.%.1lf (%s) - [Setting for %s]", DASREL, DASREV, DASREVDATE, str);
2095 
2096 
2097  das = FindWindow(NULL, buff);
2098  if(das != NULL)
2099  {
2100  sprintf(buff,"A copy of DAS is already running\nIn this execution mode \
2101 you can't execute more than 1 DAS instance at the same time !!!\n\
2102 Please contact DanBo for more information's \n\n\
2103 If you are Dr. G. Giovanelli please press the GG button\n\n");
2104 
2105 /* sprintf(buff,"A copy of DAS is already running\nIn this execution mode \
2106 you can't execute more than 1 DAS instance at the same time !!!\n\
2107 Please contact DanBo for more information's \n\n\
2108 if you are Dr. G. Giovanelli please press the GG button\n\n");
2109 */
2110  MMessageDialog("DAS Info", buff, "OK","GG",NULL);
2111 
2112 // MMessageDialog("DAS Info", buff, "OK",NULL);
2113 
2114  sprintf(buff,"CAZZO Giorgio ti ho detto N+1 volte che ne puoi \
2115 avviare uno solo alla volta\n\n\
2116 Domina il tuo dito indice!!!\n\n ");
2117  MMessageDialog("DAS Info", buff, "OK",NULL);
2118 
2119  MGUITerm();
2120  exit(0);
2121  }
2122 
2123 
2124 }
2125 
2126 //return 0 --> OK open a new das config
2127 //return 1 --> Das config window already open
2129 {
2130 
2131  HWND wconfig;
2132  char buff[1024];
2133 
2134  sprintf(buff,"DAS Config");
2135 
2136 
2137  wconfig = FindWindow(NULL, buff);
2138  if(wconfig != NULL)
2139  {
2140  sprintf(buff,"'DAS Config' window is already open!!!!");
2141  MMessageDialog("DAS Info", buff, "OK",NULL);
2142  return 1;
2143 
2144  }
2145  else
2146  return 0;
2147 
2148 
2149 }
2150 
2151 //return 0 --> NO "buff" window open
2152 //return 1 --> "buff" window already open
2153 int ChkWinInstance(char *buff, MOBJECT obj)
2154 {
2155 
2156  HWND wtest;
2157 // char str[1024];
2158 
2159  wtest = FindWindow(NULL, buff);
2160  if(wtest != NULL)
2161  {
2162  //sprintf(str,"'%s' window is already open!!!!", buff);
2163  //MMessageDialog("DAS Info", str, "OK",NULL);
2164  MShellRaise(obj);
2165  return 1;
2166 
2167  }
2168  else
2169  return 0;
2170 
2171 
2172 }
2173 
2174 
2175 
2176 void WriteShellTitle(MOBJECT o, int eqt)
2177 {
2178 
2179  int c = eqt;
2180  char buf[128], str[16];
2181 
2182  switch (c)
2183  {
2184  case TROPOGAS:
2185  sprintf(str,"TROPOGAS");
2186  break;
2187  case SPATRAM:
2188  sprintf(str,"SPATRAM");
2189  break;
2190  case LIS_:
2191  sprintf(str,"LIS");
2192  break;
2193  case SPATRAMPLUS:
2194  sprintf(str,"SPATRAMPLUS");
2195  break;
2196  case GASCODNG1:
2197  sprintf(str,"GASCODNG1");
2198  break;
2199  case GASCODNG2:
2200  sprintf(str,"GASCODNG2");
2201  break;
2202  case GASCODNG3:
2203  sprintf(str,"GASCODNG3");
2204  break;
2205  case GASCODNG4:
2206  sprintf(str, "GASCODNG4");
2207  break;
2208  case SPATRAM3:
2209  sprintf(str,"SPATRAM3");
2210  break;
2211  case SPATRAM2:
2212  sprintf(str,"SPATRAM2");
2213  break;
2214 
2215  default:
2216  sprintf(str,"UNKNOWN");
2217  break;
2218  }
2219  sprintf(buf,"DAS Release %d.%.1lf (%s) - [Setting for %s]", DASREL, DASREV, DASREVDATE, str);
2220  MShellSetTitle(o, buf);
2221 
2222 }
2223 
2224 void ManualModeCB(MOBJECT p, void *od, void *ad)
2225 {
2226 
2227 
2228  MOBJECT c = (void *)ad;
2229 
2230 
2231  if (c==0)
2232  {
2233  DAS.Flag.exemode = MANUAL;
2234  Master=0;
2235  PrgFile[0] = 0;
2236  MObjectSetBackgroundRGB(p, 1, 255, 0);
2237  }
2238  else
2239  {
2240  MObjectSetBackgroundRGB(p, 1, 255, 0);
2241  MGUITerm();
2242  exit(0);
2243 
2244  }
2245 // MShellUnrealize(c);
2246 // MShellDestroy(c);
2247 }
2248 
2250 
2251 void NoWaitSplashCB(MOBJECT p, void *od, void *ad)
2252 {
2253 
2254 
2255  MOBJECT c = (void *)ad;
2256 
2257  nowaitsplash = 0;
2258 
2259 
2260 
2261 }
2262 
2263 
2264 
2265 
2266 
2268 {
2269 
2270 
2271  MOBJECT _colform000;
2272  MOBJECT _rowform000;
2273  MOBJECT lbl;
2274  MOBJECT lbl1;
2275  MOBJECT sh1;
2276  MOBJECT px1;
2277  MOBJECT pbutt1;
2278  char buff[128];
2279 
2280  unsigned long st, et, x;
2281  char buf[80];
2282  double tout;
2283  int er;
2284 
2285 
2286 
2287 
2288  sh1 = MCreateShell("About DAS Execution", SF_MODAL);
2289 
2290  _colform000 = MCreateColForm(sh1);
2291  MObjectSetBackgroundRGB(_colform000, DPAL.DB_BG[0], DPAL.DB_BG[1], DPAL.DB_BG[2]);
2292 
2293  px1 = MCreatePixmapFromFile(_colform000, "sys\\info1.bmp");
2295  MObjectSetShadow(px1, WS_NONE, 0, 0);
2296  MObjectSetCompositeWidth(px1, 32);
2297  MObjectSetCompositeHeight(px1, 32);
2298 
2299  _rowform000 = MCreateRowForm(_colform000);
2300  MObjectSetResize(_rowform000, True, True);
2301  MObjectSetBackgroundRGB(_rowform000, DPAL.DB_BG[0], DPAL.DB_BG[1], DPAL.DB_BG[2]);
2302 
2303  sprintf(buff, "%s","DAS Info");
2304  lbl = MCreateLabel(_rowform000, buff, HELV_LARGE);
2305  MObjectSetForegroundRGB(lbl, DPAL.DB_FG_Plbl[0], DPAL.DB_FG_Plbl[1], DPAL.DB_FG_Plbl[2]);
2306  MObjectSetBackgroundRGB(lbl, DPAL.DB_BG_Albl[0], DPAL.DB_BG_Albl[1], DPAL.DB_BG_Albl[2]);
2307  MObjectSetShadow(lbl, WS_ETCHED_IN, 3, 0);
2308  MObjectSetTransparency(lbl, 0);
2309 
2310  sprintf(buff, "%s"," DAS is setted for automatic execution ");
2311  lbl = MCreateLabel(_rowform000, buff, HELV_MEDIUM);
2312  MObjectSetForegroundRGB(lbl, DPAL.DB_FG_Plbl[0], DPAL.DB_FG_Plbl[1], DPAL.DB_FG_Plbl[2]);
2313  MObjectSetShadow(lbl, WS_ETCHED_IN, 3, 0);
2314 
2315  sprintf(buff, "%s", " The program will start in %.1lf seconds ");
2316  lbl1 = MCreateLabel(_rowform000, buff, HELV_MEDIUM);
2317  MObjectSetForegroundRGB(lbl1, DPAL.DB_FG_Plbl[0], DPAL.DB_FG_Plbl[1], DPAL.DB_FG_Plbl[2]);
2318  MObjectSetShadow(lbl1, WS_ETCHED_IN, 3, 0);
2319 
2320 
2321  sprintf(buff, "%s"," You can select the 'Manual mode' or to Quit the DAS with the buttons on the right! ");
2322  lbl = MCreateLabel(_rowform000, buff, HELV_MEDIUM);
2323  MObjectSetForegroundRGB(lbl, DPAL.DB_FG_Plbl[0], DPAL.DB_FG_Plbl[1], DPAL.DB_FG_Plbl[2]);
2324  MObjectSetShadow(lbl, WS_ETCHED_IN, 3, 0);
2325 
2326 
2327  _rowform000 = MCreateRowForm(_colform000);
2328  MObjectSetResize(_rowform000, False, False);
2329  MObjectAlign(_rowform000, CENTER_ALIGN, BOTTOM_ALIGN);
2330  MObjectSetBackgroundRGB(_rowform000, DPAL.DB_BG[0], DPAL.DB_BG[1], DPAL.DB_BG[2]);
2331 
2332 
2333 
2334  pbutt1 = MCreatePButton(_rowform000, "MANUAL MODE", HELV_MEDIUM);
2335  MPButtonSetCallback(pbutt1, ManualModeCB, (void *) 0);
2337  MObjectSetShadow(pbutt1, WS_SHADOW_OUT, 3, 0);
2338 
2339  pbutt1 = MCreatePButton(_rowform000, "QUIT", HELV_MEDIUM);
2340  MPButtonSetCallback(pbutt1, ManualModeCB, (void *) 1);
2342  MObjectSetShadow(pbutt1, WS_SHADOW_OUT, 3, 0);
2343 
2344  pbutt1 = MCreatePButton(_rowform000, "Skip Wait", HELV_MEDIUM);
2345  MPButtonSetCallback(pbutt1, NoWaitSplashCB, (void *) 0);
2347  MObjectSetShadow(pbutt1, WS_SHADOW_OUT, 3, 0);
2348 
2349 
2350  MShellRealize(sh1);
2351 
2352  //Switch on 12 V, Hires, 24V
2353  if(DAS.Paramini.EqType == GASCODNG1)
2354  er = NOVA_Out(DAS.Nova.type, 9); //1001 bin
2355 
2356 
2357  tout = 30000;
2358  st = GetTickCount();
2359 
2360  do
2361  {
2362  et = GetTickCount();
2363  x = labs(et - st);
2364  //g = x % 10;
2365  //sprintf(buf, " %u %u", x, g);
2366  //Status (buf);
2367  MLoopWhileEvents(0);
2368  if((x % 100 == 0) && (x > 0))
2369  //if(x > 0)
2370  {
2371 
2372 // if(DAS.DOption.amsprogbar)
2373 // {
2374  //D_VRange(NULL, (long) x * 100 / tout, 255, 0, 0 );
2375 
2376  sprintf(buf, "The program will start in %.1lf seconds ", fabs(((double)(labs(et - st) - tout))/1000.0 ));
2377  MObjectSetText(lbl1,buf);
2378 
2379 // }
2380  }
2381  }while((labs(et - st) < tout) & (DAS.Flag.exemode != MANUAL) & nowaitsplash == 1);
2382 
2383  MShellUnrealize(sh1);
2384  MShellDestroy(sh1);
2385 
2386 
2387 }
2388 
2389 int nowait = 1;
2390 
2391 
2392 
2393 void NoWaitCB(MOBJECT p, void *od, void *ad)
2394 {
2395 
2396 
2397  MOBJECT c = (void *)ad;
2398 
2399  nowait = 0;
2400 
2401 
2402 
2403 }
2404 
2405 
2406 
2407 
2409 {
2410 
2411 
2412  MOBJECT _colform000;
2413  MOBJECT _rowform000;
2414  MOBJECT lbl;
2415  MOBJECT lbl1;
2416  MOBJECT sh1;
2417  MOBJECT px1;
2418  MOBJECT pbutt1;
2419  char buff[128];
2420 
2421  unsigned long st, et, x;
2422  char buf[80];
2423  double tout;
2424 
2425 
2426 
2427  sh1 = MCreateShell("DAS Procedure", SF_MODAL);
2428 
2429  _colform000 = MCreateColForm(sh1);
2430  MObjectSetBackgroundRGB(_colform000, DPAL.DB_BG[0], DPAL.DB_BG[1], DPAL.DB_BG[2]);
2431 
2432  px1 = MCreatePixmapFromFile(_colform000, "sys\\info1.bmp");
2434  MObjectSetShadow(px1, WS_NONE, 0, 0);
2435  MObjectSetCompositeWidth(px1, 32);
2436  MObjectSetCompositeHeight(px1, 32);
2437 
2438  _rowform000 = MCreateRowForm(_colform000);
2439  MObjectSetResize(_rowform000, True, True);
2440  MObjectSetBackgroundRGB(_rowform000, DPAL.DB_BG[0], DPAL.DB_BG[1], DPAL.DB_BG[2]);
2441 
2442  sprintf(buff, "%s","DAS Info");
2443  lbl = MCreateLabel(_rowform000, buff, HELV_LARGE);
2444  MObjectSetForegroundRGB(lbl, DPAL.DB_FG_Plbl[0], DPAL.DB_FG_Plbl[1], DPAL.DB_FG_Plbl[2]);
2445  MObjectSetBackgroundRGB(lbl, DPAL.DB_BG_Albl[0], DPAL.DB_BG_Albl[1], DPAL.DB_BG_Albl[2]);
2446  MObjectSetShadow(lbl, WS_ETCHED_IN, 3, 0);
2447  MObjectSetTransparency(lbl, 0);
2448 
2449  sprintf(buff, "%s"," DAS is waiting for the identification of the USB driver for Hires V ");
2450  lbl = MCreateLabel(_rowform000, buff, HELV_MEDIUM);
2451  MObjectSetForegroundRGB(lbl, DPAL.DB_FG_Plbl[0], DPAL.DB_FG_Plbl[1], DPAL.DB_FG_Plbl[2]);
2452  MObjectSetShadow(lbl, WS_ETCHED_IN, 3, 0);
2453 
2454  sprintf(buff, "%s", " The program will start in %.1lf seconds ");
2455  lbl1 = MCreateLabel(_rowform000, buff, HELV_MEDIUM);
2456  MObjectSetForegroundRGB(lbl1, DPAL.DB_FG_Plbl[0], DPAL.DB_FG_Plbl[1], DPAL.DB_FG_Plbl[2]);
2457  MObjectSetShadow(lbl1, WS_ETCHED_IN, 3, 0);
2458 
2459 
2460  sprintf(buff, "%s"," You can continue DAS (if the driver is already loaded!!! )selecting \n the button on the right! ");
2461  lbl = MCreateLabel(_rowform000, buff, HELV_MEDIUM);
2462  MObjectSetForegroundRGB(lbl, DPAL.DB_FG_Plbl[0], DPAL.DB_FG_Plbl[1], DPAL.DB_FG_Plbl[2]);
2463  MObjectSetShadow(lbl, WS_ETCHED_IN, 3, 0);
2464 
2465 
2466  _rowform000 = MCreateRowForm(_colform000);
2467  MObjectSetResize(_rowform000, False, False);
2468  MObjectAlign(_rowform000, CENTER_ALIGN, BOTTOM_ALIGN);
2469  MObjectSetBackgroundRGB(_rowform000, DPAL.DB_BG[0], DPAL.DB_BG[1], DPAL.DB_BG[2]);
2470 
2471 
2472 
2473  pbutt1 = MCreatePButton(_rowform000, "Skip Wait", HELV_MEDIUM);
2474  MPButtonSetCallback(pbutt1, NoWaitCB, (void *) 0);
2476  MObjectSetShadow(pbutt1, WS_SHADOW_OUT, 3, 0);
2477 
2478  MShellRealize(sh1);
2479 
2480 
2481 
2482  tout = 20000;
2483  st = GetTickCount();
2484 
2485  do
2486  {
2487  et = GetTickCount();
2488  x = labs(et - st);
2489  MLoopWhileEvents(0);
2490  if((x % 100 == 0) && (x > 0))
2491  {
2492 // if(DAS.DOption.amsprogbar)
2493 // {
2494 
2495  sprintf(buf, "The program will start in %.1lf seconds ", fabs(((double)(labs(et - st) - tout))/1000.0 ));
2496  MObjectSetText(lbl1,buf);
2497 
2498 // }
2499  }
2500  }while(labs(et - st) < tout && nowait == 1);
2501 
2502  MShellUnrealize(sh1);
2503  MShellDestroy(sh1);
2504 
2505 
2506 }
2507 
2508 
2509 void SetScriptUseLabel(int master, char *prgf, int emode, MOBJECT lbl)
2510 {
2511 
2512  char buf[32];
2513  char str[255];
2514  int er=0;
2515 
2516 
2517 
2518 
2519  //If the program started in temporized mode write MASTER on the label on the control panel
2520  if(master)
2521  {
2522  if (emode == SZAMASTERM)
2523  sprintf(buf,"MASTER SZA" );
2524  if (emode == TEMPORIZED)
2525  sprintf(buf,"MASTER" );
2526  if ((emode == SZAMODE))
2527  sprintf(buf,"SZAMODE" );
2528  if ((emode == TESTSZAMODE))
2529  sprintf(buf,"TESTSZAMODE" );
2530 
2531  MObjectSetText(lbl, buf);
2532  }
2533  // altrimenti scrive il nome della tabella da eseguire
2534  else if(emode == PRGFILE)
2535  {
2536  //Devo mettere qualcosa che costruisca solo il nome del file
2537  //(devo leggere il file al contrario fino a che trovo "\")
2538  DI_SplitName(prgf, str, buf);
2539  //sprintf(buf,"%s",PrgFile );
2540  MObjectSetText(lbl, buf);
2541 
2542  }
2543  else
2544  {
2545  switch (emode)
2546  {
2547  case DBDEMO:
2548  sprintf(buf,"DEMO Use" );
2549  MObjectSetText(lbl, buf);
2550  AboutCB(NULL, NULL, (void *)1); //with 1 is a Modal Shell
2551  break;
2552  case TESTAMS:
2553  sprintf(buf,"TEST AMS Use" );
2554  MObjectSetText(lbl, buf);
2555  break;
2556  case TESTCCD:
2557  sprintf(buf,"TEST CCD Use" );
2558  MObjectSetText(lbl, buf);
2559  break;
2560  case TESTAD:
2561  sprintf(buf,"TEST AD Use" );
2562  MObjectSetText(lbl, buf);
2563  break;
2564  default:
2565  sprintf(buf,"Man Use" );
2566  MObjectSetText(lbl, buf);
2567  break;
2568  }
2569  }
2570 
2571 }
2572 
2573 void AMSINI_Err(int c)
2574 {
2575  char buf[512];
2576  char str[_MAX_PATH];
2577 
2578  switch (c)
2579  {
2580  case 1:
2581  sprintf(str,"File %s\\AMS.ini not found,\nThe program will be closed.\n ", BIL.DFILEM.CONFIGDIREQUIPMENT);
2582  MMessageDialog ("DAS ERROR ", str, "OK",NULL);
2583  sprintf(buf,"File 'AMS.INI' not found");
2584  D_WriteInitLog(buf);
2585  exit(0);
2586  break;
2587  case 2:
2588  MMessageDialog ("DAS ERROR ", "Error in reading the AMS Power in file '.\\Config\\AMS.INI',\n\
2589 The program will be closed.\n ", "OK",NULL);
2590  sprintf(buf,"Bad AMS Power read");
2591  D_WriteInitLog(buf);
2592  exit(0);
2593  break;
2594  }
2595 }
2596 
2597 void BuildMainShell(void)
2598 {
2599  int WSc, WSh,HSc, HSh;
2600 
2601  DAS.Gui.Shells.Sh_Main = MDCreate_CP();
2602  WSc = MGetScreenWidth();
2603  HSc = MGetScreenHeight();
2604  MShellRealizeXY( DAS.Gui.Shells.Sh_Main, (WSc-901)/2, 0);
2605  WSh = MObjectGetWidth(DAS.Gui.Shells.Sh_Main);
2606  HSh = MObjectGetHeight(DAS.Gui.Shells.Sh_Main);
2608 
2609 }
2610 
2611 
2624 void LaunchBackTask(void)
2625 {
2626  //Timer Task
2628 
2629  //Home Grating Task
2631 
2632  //Log Task
2633  MRefreshTimeout(&IDS.LOG, LOG_TASK_TIME, Task_LOG, NULL);
2634 
2635  //Refresh Temperatures Task
2636  if ((DAS.Flag.exemode == TEMPORIZED)|
2637  (DAS.Flag.exemode == PRGFILE) |
2638  (DAS.Flag.exemode == TESTAD) |
2639  (DAS.Flag.exemode == MANUAL) |
2640  (DAS.Flag.exemode == SZAMASTERM)|
2641  (DAS.Flag.exemode == SZAMODE))
2642  {
2643  if(FLAG.ADTempTest == 0)
2645  }
2646 
2647  if ((DAS.Flag.exemode == TEMPORIZED)|
2648  (DAS.Flag.exemode == PRGFILE) |
2649  (DAS.Flag.exemode == TESTCCD) |
2650  (DAS.Flag.exemode == MANUAL) |
2651  (DAS.Flag.exemode == SZAMASTERM)|
2652  (DAS.Flag.exemode == SZAMODE) )
2653  {
2654  // CCDTemp Task
2656 
2657  // PeltierTemp Task
2658  if((FLAG.ADPC104 == 0) | (FLAG.ADTempTest == 1))
2659  {
2661  }
2662 
2663  // Automatic Execution
2665 
2666  }
2667 
2668  if (DAS.Flag.exemode == TESTSZAMODE)
2669  {
2670  // Automatic Execution
2672 
2673  }
2674 
2675  //WDT (Watch Dog Timer) task
2676  //MRefreshTimeout(&IDS.WDT, WDT_TASK_TIME, TaskWDT, NULL);
2677 
2678 }
2679 
2680 
2681 int InitTempAD(int mod)
2682 {
2683 
2684  int er = 0;
2685  char buf[64];
2686  int adsts;
2687 
2688  if ((mod == TEMPORIZED) |
2689  (mod == PRGFILE) |
2690  (mod == TESTAD) |
2691  (mod == MANUAL) |
2692  (mod == SZAMASTERM) |
2693  (mod == SZAMODE))
2694  {
2695  er = D_InitPC104();
2696  if(er)
2697  {
2698  sprintf(buf," DMM NOT Found");
2699  D_WriteInitLog(buf);
2700 
2701  adsts = 1;
2702 
2703  //Pause Execution
2704  DB_Pause();
2705  //Windows reset
2706  WinRes();
2707 
2708  }
2709  else
2710  {
2711  sprintf(buf," DMM Found");
2712  D_WriteInitLog(buf);
2713  OMUTHR.Temptemp = AllocFloatMat(16, 4096);//buffer per la normalizzazione delle temperature
2714  OMUTHR.CoolPT = (float)DAS.Paramini.TPelt * 10;
2715  adsts = 0;
2716 
2717  }
2718  }
2719  else
2720  adsts = 1;
2721 
2722 
2723  return adsts;
2724 }
2725 
2726 
2727 //mod = 0 --> Temporized
2728 //mod = 1 --> MASTERSZAM
2729 //Mod = 2 --> SZAMODE
2730 int ChkMaster(int mod)
2731 {
2732 
2733  int i, c = mod;
2734  struct time RTime;
2735  struct date RDate;
2736  struct tm today;
2737  float DecActTime, DecTimeStart, DecTimeStop;
2738 
2739  switch (c)
2740  {
2741  case 0: // Temporized Mode (DAS argument MASTER)
2742 
2743  //gettime(&RTime);
2744  GetDateTime(&RDate, &RTime, &today);
2745 
2746  // Time to decimal time
2747  DecActTime = RTime.ti_hour + ((float) RTime.ti_min / 60) + ((float) RTime.ti_sec / 3600);
2748 
2749  for (i=0;i<PrgNumInM; i++)
2750  {
2751  DecTimeStart = ExMast[i].sora + ((float)ExMast[i].smin / 60) + ((float)ExMast[i].ssec / 3600);
2752  DecTimeStop = ExMast[i].eora + ((float)ExMast[i].emin / 60) + ((float)ExMast[i].esec / 3600);
2753  if((DecActTime > DecTimeStart) && (DecActTime < DecTimeStop))
2754  //if(ExMast[i].sora == (int) RTime.ti_hour &&
2755  //ExMast[i].smin <= (int) RTime.ti_min)
2756  {
2757 
2758  PrgNumExe = i;
2759  }
2760  }
2761 
2762  break;
2763 
2764  case 1: // MASTERSZA Mode 1
2765  /************************************************************************/
2766  GetDateTime(&RDate, &RTime, &today);
2767 
2768 // gettime(&RTime);
2769  for (i=0;i<PrgNumInM; i++)
2770  {
2771  if((int) RTime.ti_hour <= 12)
2772  {
2773  //Actual SZA between Start SZA and End SZA
2774  if ( ((int)(S_zenetr * 100) < (int)(ExMast[i].ssza * 100))
2775  && ((int)(S_zenetr * 100) > (int)(ExMast[i].esza * 100)) )
2776  PrgNumExe = i;
2777 
2778  }
2779  if((int) RTime.ti_hour > 12)
2780  {
2781  if ( ((int)(S_zenetr * 100) > (int)(ExMast[i].ssza * 100))
2782  && ((int)(S_zenetr * 100) < (int)(ExMast[i].esza * 100)) )
2783  {
2784  PrgNumExe = i;
2785  }
2786  }
2787  }
2788  break;
2789  /************************************************************************/
2790  case 2: // SZAMODE
2791  for (i=0;i<PrgNumInM; i++)
2792  {
2793  if ( ((int)(S_zenetr * 100) > (int)(ExMast[i].minsza * 100))
2794  && ((int)(S_zenetr * 100) < (int)(ExMast[i].maxsza * 100)) )
2795  {
2796  PrgNumExe = i;
2797  }
2798  }
2799  break;
2800 
2801  }
2802 
2803  return PrgNumExe;
2804 }
2805 
2806 
2807 
2809 {
2810 
2811  struct tm *newtime;
2812  long ltime;
2813  int h, m, t, er;
2814  float SZA[1440];
2815  float min = 360.0;
2816  float max= 0.0;
2817 
2818 
2819  time( &ltime );
2820  newtime = localtime( &ltime );
2821 
2822 
2823  t=0;
2824  for(h=0;h<24;h++)
2825  {
2826  for(m=0;m<60;m++)
2827  {
2828 
2829  newtime ->tm_hour = h;
2830  newtime ->tm_min = m;
2831  newtime ->tm_sec = 0;
2832 
2833  er = SZACalc(DAS.DGeo.latitude, DAS.DGeo.longitude,
2834  (float) DAS.DGeo.timezone, newtime ->tm_year + 1900,
2835  newtime -> tm_yday, newtime ->tm_hour, newtime ->tm_min,
2836  newtime ->tm_sec, 0, 1024, 0, 0);
2837 
2838  SZA[t] = (float)S_zenetr;
2839  t++;
2840 
2841  }
2842  }
2843 
2844 
2845  for(h = 0; h< t; h++)
2846  {
2847  if(SZA[h] < min) min = SZA[h];
2848  if(SZA[h] > max) max = SZA[h];
2849  }
2850  // return the minimum element in the Numbers
2851  SZADelta.Dailyminsza = min;
2852  SZADelta.Dailymaxsza = max;
2853 
2854 }
2855 
2856 
2857 
2858 void SZA_FirstCalc(void)
2859 {
2860 
2861  char str[80];
2862  int er;
2863 // char timebuf[9];
2864 // char datebuf[9];
2865 // long dp = 500;
2866  struct tm newtime;
2867  struct time RTime;
2868  struct date RDate;
2869 // long ltime;
2870  float t_acc = 0;
2871  int mode;
2872 // _strdate(datebuf);
2873 
2874 // time( &ltime );
2875 // _strtime(timebuf);
2876  //time( &ltime );
2877 
2878  //newtime = localtime( &ltime );
2879 
2880  GetDateTime(&RDate, &RTime, &newtime);
2881 
2882 
2883  /**************************************************************/
2884  // Check if daylight saving time is in effect
2885  // tm_isdst > 0 if daylight saving time is in effect
2886  // tm_isdst = 0 if daylight saving time is not in effect
2887  // tm_isdst < 0 if status of daylight saving time is unknown.
2888  //if (newtime ->tm_isdst)
2889  // newtime ->tm_hour = newtime ->tm_hour - 1;
2890  //NOTE - In Daylight saving period on midnight the hours became -1 so...
2891  //if((newtime -> tm_hour) == -1)
2892  //{
2893  // Necessary for measurements performed at high latitude in summer seasons
2894  // newtime->tm_hour = 23;
2895  // newtime -> tm_yday = newtime -> tm_yday - 1;
2896  //}
2897 
2898  /**************************************************************/
2899 
2900  /**************************************************************/
2901  // Calc solar Zenith Angle (SZA)
2902  er = SZACalc(DAS.DGeo.latitude, DAS.DGeo.longitude, (float) DAS.DGeo.timezone,
2903  newtime.tm_year + 1900,
2904  newtime.tm_yday,
2905  newtime.tm_hour,
2906  newtime.tm_min,
2907  newtime .tm_sec,
2908  0, 1024, 0, 0);
2909  /**************************************************************/
2910  sprintf(str, "%.01lf", 90 - S_zenetr); //S_elevref = elevation refracted
2912 
2913  sprintf(str, "%.01lf", S_azim);
2915 
2916 
2917  sprintf(str, "%.02lf", S_sunrise); //S_elevref = elevation refracted
2919 
2920  sprintf(str, "%.02lf", S_sunset);
2922 
2923 // S_sunrise = 720.0 - 4.0 * S_ssha - S_tstfix;
2924 // S_sunset = 720.0 + 4.0 * S_ssha - S_tstfix;
2925 
2926  /**************************************************************/
2927  // Set FLAG.sza
2928  // FLAG.sza = 1 --> perform measurements
2929  // FLAG.sza = 0 --> waiting mode
2930  if(S_zenetr < SZAMax)
2931  {
2932  FLAG.sza =1;
2933  FLAG.ftpstatus = 0; // back-up that will be performed when FLAG.sza = 0
2934  }
2935  else
2936  {
2937  FLAG.sza =0;
2938  if(FLAG.ftpstatus == 1) //Back-up performed
2939  FLAG.ftpstatus = 2; //Wait until the next sunset
2940 
2941  }
2942  /**************************************************************/
2943 
2944  /**************************************************************/
2945  // write on the STATUS label
2946  sprintf(str, "Station: %s, Date: %d/%02d/%02d, Time: %02d:%02d:%02d, SolarZenithAngle:%.02lf",
2947  DAS.DGeo.s_name, newtime.tm_year + 1900, newtime.tm_mon + 1,newtime.tm_mday,
2948  newtime.tm_hour, newtime.tm_min, newtime.tm_sec, S_zenetr);
2950  /**************************************************************/
2951 
2952  if (DAS.Flag.exemode == TEMPORIZED)
2953  mode = 0;
2954  else if (DAS.Flag.exemode == SZAMASTERM)
2955  mode = 1;
2956  else if(DAS.Flag.exemode == SZAMODE)
2957  mode = 2;
2958  else if(DAS.Flag.exemode == TESTSZAMODE)
2959  mode = 2;
2960 
2961  er = ChkMaster(mode);
2962 
2963  SZA_FindMin();
2964 }
2965 
2966 
2967 
2968  void RunFULL(void)
2995 {
2996 
2997  char str[_MAX_PATH];
2998 // struct time RTime;
2999  int er = 0;
3000  long np;
3001 
3002  // Load Param.ini
3003  er = LoadParam();
3004  if (er) //Param.ini not found
3005  {
3006  sprintf(str,"File %s\\Param.ini not found,\nPlease supply a valid 'Param.ini' file in the %s forlder\n\
3007 or contact Danbo - db@uevora.pt\nNow DAS will quit!! ", BIL.DFILEM.CONFIGDIREQUIPMENT,BIL.DFILEM.CONFIGDIREQUIPMENT);
3008  MMessageDialog ("DAS ERROR ", str, "OK",NULL);
3009  DAS_Error(2);
3010  exit(0);
3011  }
3012 
3013  DAS.Flag.ExeDSZA = 1; //To enable the SZAPRG measurement mode
3014 
3015  DAS_Error(0); //Write on LOG "Param.ini Loaded OK"
3016 
3017  //check if more than 1 instance of DAS is running
3019 
3020  //Load AMS.ini
3021  er = LoadAMS(); //AMS.ini not found
3022  if(er)
3023  {
3024  if (er == 1)
3025  {
3026  sprintf(str,"File %s\\Param.ini not found,\nPlease supply a valid 'Param.ini' file in the %s forlder\n\
3027  or contact Danbo - db@uevora.pt\nNow DAS will quit!! ", BIL.DFILEM.CONFIGDIREQUIPMENT,BIL.DFILEM.CONFIGDIREQUIPMENT);
3028  MMessageDialog ("DAS ERROR ", str, "OK",NULL);
3029  exit(0);
3030 
3031  }
3032  else
3033  //Error in reading AMS.ini
3034  AMSINI_Err(er);
3035  }
3036 
3037  DAS_Error(1); //Write on LOG "AMS.ini Loaded OK"
3038 
3039  // CREATE the MAIN SHELL (Control Panel)
3040  BuildMainShell();
3041 
3042  //Write the Parameters on the appropriate labels in the control Panel
3043  AssignParam(0);
3044 
3045  //Write the title of the Main Shell depending on the Equipment
3047 
3048  // Write in the Script-Use Label the execution mode or the PRG file or MASTER
3050 
3051  //Start WDT
3052 // WDT_func(1);
3053 
3054  //Init CCD and AMS
3055  er = InitCCD_AMS(DAS.Paramini.EqType, DAS.Flag.exemode);
3056 
3057  //Stop WDT
3058 // WDT_func(0);
3059 
3060  if (er)
3061  {
3062  DAS_Error(3);
3063  }
3064 
3065 
3066  // Init AD Converter - PC_104 device.
3067  //if DMM NOT Found the InitTempAD function return 1
3069 
3070  // choose the sensitive Keyboard buttons ( checking the DAS.Flag.exemode status)
3072 
3073  // Read the PRG file if not in TEMPORIZED or SZAMASTERM or SZAMODE modes
3074  //if(PrgFile[0] != 0 && Master == 0)
3075  if(DAS.Flag.exemode == PRGFILE && Master == 0)
3076  {
3077  DB_KB_ButtonActive(0);
3080  FLAG.fileprg = 1;
3081  on = LoadExec(PrgFile);
3082  }
3083  else on = 0;
3084 
3085 
3086  //DAS.Marconi.AVGmat = AllocLongMat(IDX, IDY);
3087 
3088 
3089 
3090  //Read the MASTER or the MASTERSZA or SZAPRG projects or the *.prg file and check the syntax of the *.PRG
3091  Master = ExMaster(Master, DAS.Flag.exemode);
3092 
3093  //Check the "Master" value
3095 
3096  PrgNum = 0;
3097 
3098  //first SZA Calculation
3099  SZA_FirstCalc();
3100 
3101 
3102  // Launch background tasks
3103  LaunchBackTask();
3104 
3105  OMU_HC();
3106 
3107 
3108  // Now DAS transfer the control to MGUI library and gains control only through
3109  // callbacks (as button press) or events generated by the background's tasks
3110  MMainLoop();
3111 
3112 }
3113 
3114 void RunOLP(char *fname)
3115 {
3116 
3117  int er = 0, l;
3118  char buff[32];
3119 
3120  er = LoadParam();
3121 
3122  /******************************************************/
3123  // Load the dispersion coefficient for DOAS Use
3124  er = LoadDB_DispCoeff();
3125  /*******************************************************/
3126 
3127 
3128  // Create Command KeyBoard
3129 // MDCreateLISC(0, 0);
3130 /**********************************************************************/
3131  // choose the sensitive Keyboard buttons ( checking the DAS.Flag.exemode status)
3132 // DB_ChooseButtons(DAS.Flag.exemode);
3133 /**********************************************************************/
3134 
3135  ViewPlot(0); //OffLine Plot
3136 
3137 // Server = DI_Init(0); //0=No Pop-Up Menu, 1=Yes Pop-Up Menu
3138 
3139  if(fname != 0)
3140  {
3141  sprintf(BIL.DFILEM.DBFILENAME,"%s",fname);
3142  l = strlen(BIL.DFILEM.DBFILENAME);
3143  sprintf(buff,"%s", "xxxx");
3144  strncpy(buff, BIL.DFILEM.DBFILENAME+l-4, 4);
3145 
3146  if( (strcmp(buff,".dat") == 0) |(strcmp(buff,".Dat") == 0) )
3147  {
3148  BIL.DFILEM.FKIND = FDAT;
3150  }
3151  else if( (strcmp(buff,".bif") == 0) | (strcmp(buff,".Bif") == 0) )
3152  {
3153  BIL.DFILEM.FKIND = FBIF;
3155  }
3156  else if( (strcmp(buff,".bhg") == 0) | (strcmp(buff,".Bhg") == 0) )
3157  {
3158  BIL.DFILEM.FKIND = FBIF;
3160  }
3161  else
3162  {
3163  MMessageDialog("DAS information", "Unsupported format!!", " Ok ", NULL);
3164 // break;
3165  }
3166 
3167  }
3168 
3169 
3171  MMainLoop();
3172 
3173 
3174 }
3175 
3176 
3177 void ChkExeMode(int mod, char **p)
3178 {
3179 
3180  char buff[_MAX_PATH], str[_MAX_PATH];
3181  int er, l;
3182 
3183  if(mod > 1)
3184  {
3185  if((strcmp(p[1], "MASTER") == 0)) // MASTER
3186  {
3187  Master = 1;
3188  DAS.Flag.exemode = TEMPORIZED;
3189 
3190  }
3191  else if ((strcmp(p[1], "MASTERSZA") == 0)) // MASTERSZA
3192  {
3193  Master = 1;
3194  DAS.Flag.exemode = SZAMASTERM;
3195  //Effemeridis Computation
3196 
3197  }
3198  else if ((strcmp(p[1], "SZAPRG") == 0)) // SZAPRG
3199  {
3200  Master = 1;
3201  DAS.Flag.exemode = SZAMODE;
3202  }
3203  else if ((strcmp(p[1], "TESTSZAPRG") == 0)) // STESTZAPRG
3204  {
3205  Master = 1;
3206  DAS.Flag.exemode = TESTSZAMODE;
3207  }
3208 
3209  else if( (strcmp(p[1], "TESTAMS") == 0) | (strcmp(p[1], "testams") == 0)| (strcmp(p[1], "TestAMS") == 0)) //si vogliono testare i motori e i rele'
3210  {
3211  DAS.Flag.exemode = TESTAMS;
3212 
3213  }
3214  else if( (strcmp(p[1], "OFFLINEPLOT") == 0) | (strcmp(p[1], "offlineplot") == 0) )//si vuole utilizzare il PLOT offline
3215  {
3216  DAS.Flag.exemode = OFFLINEPLOT;
3217 
3218 
3219  }
3220  else if( (strcmp(p[1], "TESTCCD") == 0) | (strcmp(p[1], "testccd") == 0) | (strcmp(p[1], "TestCCD") == 0)) //si vuole testare la camera a CCD
3221  {
3222  DAS.Flag.exemode = TESTCCD;
3223 
3224  }
3225  else if( (strcmp(p[1], "TESTAD") == 0) | (strcmp(p[1], "testad") == 0)| (strcmp(p[1], "TestAD") == 0)) //si vuole testare il convAD delle temp
3226  {
3227  DAS.Flag.exemode = TESTAD;
3228 
3229  }
3230  else if( (strcmp(p[1], "?") == 0) | (strcmp(p[1], "help") == 0) | (strcmp(p[1], "HELP") == 0)) // ovvio
3231  {
3232  DAS.Flag.exemode = HELP;
3233 // er = DB_HelpCB(NULL, NULL, NULL);
3234 // if (er)
3235 // exit(0);
3236 
3237  }
3238  else if( (strcmp(p[1], "demo") == 0) | (strcmp(p[1], "DEMO") == 0) | (strcmp(p[1], "Demo") == 0)) // ovvio
3239  {
3240 // FLAG.demo = 1;
3241 // FLAG.testams = 1;
3242 // FLAG.testccd = 1;
3243 // FLAG.plotoffline = 1;
3244  DAS.Flag.exemode = DBDEMO;
3245 
3246 
3247  }
3248  else if( (strcmp(p[1], "DOAS") == 0) | (strcmp(p[1], "doas") == 0)| (strcmp(p[1], "Doas") == 0)) //si vuole testare il convAD delle temp
3249  {
3250  DAS.Flag.exemode = DOASMODE;
3251 
3252  }
3253 
3254  else
3255  {
3256  //Check if the argument is a valid PRG file or LOG files
3257  sprintf(str,"%s",p[1]);
3258  l = strlen(str);
3259  sprintf(buff,"%s", "xxxx");
3260  strncpy(buff, str+l-4, 4);
3261 
3262  if( (strcmp(buff,".prg") == 0) |(strcmp(buff,".PRG") == 0) |(strcmp(buff,".Prg") == 0) )
3263  {
3264 
3265  if(DI_FileExist(p[1])) // DI_FileExist --> Return: 1 if PATH exist, else return 0
3266  {
3267  strcpy(PrgFile, p[1]);
3268  //Check the syntax of the PRG file
3269  er = PRG_Check(0, PrgFile);
3270 // if er
3271 // //SET Execution Mode
3272  DAS.Flag.exemode = PRGFILE;
3273  }
3274  else
3275  {
3276  sprintf(str, "PRG file:\n'%s'\n not encountred.\n Please check the name of the file\n Now the program will be terminated", p[1]);
3277  MMessageDialog("DAS information", str, " Ok ", NULL);
3278  MGUITerm();
3279  exit(0);
3280  }
3281 
3282  }
3283  else if( (strcmp(buff,".log") == 0) |(strcmp(buff,".LOG") == 0) |(strcmp(buff,".Log") == 0) )
3284  {
3285 
3286  DAS.Flag.exemode = LOGMODE;
3287 
3288 
3289  }
3290  else
3291  {
3292  sprintf(str, "'%s'\nUnrecognized Argument \n The Program will be terminated", p[1]);
3293  if(MMessageDialog("DAS inf.", str, " Ok ", "Quick Help", NULL))
3294  {
3295  sprintf(str, "'Allowed Arguments:\n\n\
3296 1) DEMO\n\
3297 2) DOAS\n\
3298 3) TESTAD\n\
3299 4) TESTCCD\n\
3300 5) TESTAMS\n\
3301 6) MASTER\n\
3302 7) SZAPRG\n\
3303 8) OFFLINEPLOT\n\
3304 9) OFFLINEPLOT Valid *.bif (dat) file\n\
3305 10) Valid *.LOG file\n\
3306 11) Valid *.PRG file\n");
3307  if(!MMessageDialog("DAS information", str, " Ok ", NULL))
3308  MGUITerm();
3309  exit(0);
3310 
3311 
3312  }
3313  else
3314  {
3315  MGUITerm();
3316  exit(0);
3317  }
3318  }
3319 
3320  }
3321  }
3322  else
3323  DAS.Flag.exemode = MANUAL;
3324 
3325 
3326 
3327  // If DAS executed in one of the automatic modes,
3328  // a Splash window is created allowing the user to select
3329  // to start the program in MANUAL mode or let it continue
3330  // Usefull when DAS is automatically loaded at the BOOT of the instrument!!!!!
3331  if ((DAS.Flag.exemode == SZAMASTERM) |
3332  (DAS.Flag.exemode == TEMPORIZED) |
3333  (DAS.Flag.exemode == SZAMODE) |
3334  (DAS.Flag.exemode == TESTSZAMODE) |
3335  (DAS.Flag.exemode == PRGFILE) )
3336  {
3338  }
3339 
3340 
3341 
3342 
3343 
3344 
3345 }
3346  int SetWorkDirMGUIenv(char *buff)
3354 {
3355  int s, er;
3356 
3357  // Sets the DAS Working Directory
3358  s = DI_FindDrive(buff);
3359  er = _chdrive(s);
3360  DI_FindDirName(buff, env);
3361  er = _chdir(env);
3362 
3363  // Set MGUI path
3364  sprintf(env, "MGUIDIR=%sSYS", MGetCurrentDirectory());
3365  er = putenv(env);
3366 
3367  return er;
3368 
3369 }
3370 
3371 void InitColors(void)
3372 {
3373 
3375  DIL.Cfg.NColors = MGetNColors();
3376 
3377  // Colors allocation ( for compatibility with old version)
3378  BIL.DPLOT.DrawBG = MAllocColor(220, 220, 220);
3379  MTCL.PLColor[0] = MTCL.black;
3380  MTCL.PLColor[1] = MTCL.white;
3381 }
3382 
3383 
3384 void LoadSetDirs(void)
3385 {
3386 
3387 
3388  int er;
3389  char buf[_MAX_PATH];
3390 
3391  /**********************************************************************/
3392  //Load home Directory
3393  _getcwd( BIL.DFILEM.HOMEDIRECTORY, _MAX_PATH );
3394  /**********************************************************************/
3395  /**********************************************************************/
3396  //Set LOG Directory
3397  sprintf(BIL.DFILEM.LOGDIR, "%s\\%s", BIL.DFILEM.HOMEDIRECTORY, "Log" );
3398  sprintf(buf, "%s\\", BIL.DFILEM.LOGDIR );
3399  // Check Path Existence
3400  // Return: 1 if PATH exist, else return 0
3401  er = DI_PathExist(buf);
3402  if (!er)
3403  {
3404  sprintf(buf,"Path '%s' deos not exist,\nDAS will create the requested folder ", BIL.DFILEM.LOGDIR);
3405  DAS_Message(buf, 0);
3406  //er = MMessageDialog ("DAS ERROR ", buf, "OK",NULL);
3407  if( _mkdir( BIL.DFILEM.LOGDIR ) == 0 ) //Create LOG Folder
3408  {
3409  sprintf(buf,"Path '%s' created ", BIL.DFILEM.LOGDIR);
3410  DAS_Message(buf, 0);
3411  //MMessageDialog ("DAS inf ", "Path created", "OK",NULL);
3412  }
3413  }
3414  /**********************************************************************/
3415  /**********************************************************************/
3416  //Set Data Directory
3417  sprintf(BIL.DFILEM.DATADIRECTORY, "%s\\%s", BIL.DFILEM.HOMEDIRECTORY, "Data" );
3418  sprintf(buf, "%s\\", BIL.DFILEM.DATADIRECTORY );
3419  // Check Path Existence
3420  // Return: 1 if PATH exist, else return 0
3421  er = DI_PathExist(buf);
3422  if (!er)
3423  {
3424  sprintf(buf,"Path '%s' deos not exist,\nDAS will create the requested folder ", BIL.DFILEM.DATADIRECTORY);
3425  DAS_Message(buf, 0);
3426  //er = MMessageDialog ("DAS ERROR ", buf, "OK",NULL);
3427  if( _mkdir( BIL.DFILEM.DATADIRECTORY ) == 0 ) //Create DATA Folder
3428  {
3429  sprintf(buf,"Path '%s' created ", BIL.DFILEM.DATADIRECTORY);
3430  DAS_Message(buf, 0);
3431  //MMessageDialog ("DAS inf ", "Path created", "OK",NULL);
3432  }
3433  }
3434 
3435  /**********************************************************************/
3436  //Set Common Config Directory
3437  sprintf(BIL.DFILEM.CONFIGDIRCOMMON, "%s\\%s", BIL.DFILEM.HOMEDIRECTORY, "Config" );
3438  /**********************************************************************/
3439  /**********************************************************************/
3440  //Set Camera Select Config Directory
3441  sprintf(BIL.DFILEM.DIRDCL, "%s\\%s", BIL.DFILEM.HOMEDIRECTORY, "dcl");
3442  /**********************************************************************/
3443 
3444 
3445 }
3446 
3447 
3449 {
3450 
3451  // Assign the default values
3452  DAS.DOption.savingmode = 1; //Flag to set saving mode: 0=ASCII, 1=Binary
3453  DAS.DOption.filename = 1; //Flag to set file name mode 0=free choice, 1 = automatic file names
3454  DAS.DOption.imgtype = 0; //Flag to set image mode 0=Mono, 1 = RGB
3455  DAS.DOption.pixcorr = 1; //Flag to set defective pixel correction: 0=NOT Corrected, 1=Corrected
3456  DAS.DOption.avgmode = 1;//Flag to set Averaging mode: 0 = Repeat measurements for fixed number,
3457  // 1 = Repeat measurements for fixed time
3458  DAS.DOption.darkremove = 1; // Flag to set Dark Removal from measurements; 0 = No Dark Removal
3459  // 1 = Dark Removal
3460  DAS.DOption.darksource = 1; //Flag to set Dark source: 0 = Blind Pixels
3461  // 1 = Full Frame
3462  FLAG.Wl = 1; //Flag for X scale: 0 = Pixel;1 = WL [A]; 2 = WL [nm]
3463  DAS.Flag.plotW = 0;
3464  //FLAG.plotW = 0; //Flag for the plot display: 0 = NO Plot; 1 = PLOT
3465  FLAG.plotYRange = 1; //0 = full range; 1 = min/max
3466  FLAG.settempvar = 0; //0 = Fixed CCD Temp, 1 = CCD Temp VS sza
3467  DAS.DOption.hlinebefore = 1; //Number of HiddenLines before the central line in Plot
3468  DAS.DOption.hlineafter = 1; //Number of HiddenLines after the central line in Plot
3469  DAS.DOption.ftpbackup = 0;
3470  DAS.Flag.DeltaSZA = 0; //flag for continuos measurements (0) or delta sza meas (1)
3471  DAS.Flag.ExeDSZA = 1;//flag for the activation of measurement in case of DeltaSZA measurements
3472  DAS.DOption.resetType = 1; //Reset type 1=day(s), 0=hour(s)
3473  DAS.DOption.resetFreq = 7; //Reset frequency
3474  DAS.Flag.WindowsReboot = 0; //Flag that became 1 when Windows reboot is setted (\ref SetWinowsReset)
3475 
3476 }
3477 
3478 void RunLogMode(int mod, char *p)
3479 {
3480 
3481  char buff[128], str[_MAX_PATH];
3482  unsigned long lx;
3483  int tiy = OMUTEMP.dimy = 16;
3484 
3485 
3486  DI_SplitName(p, str, buff);
3487  OMUTEMP.dimx = ReadLogFile(0, str, buff, 0, 0, OMUTEMP);
3488  if (OMUTEMP.dimx >=5)
3489  {
3490  //Remenber to de-alloc theese arrays
3491  OMUTEMP.pTempMat = AllocFloatMat(OMUTEMP.dimx, OMUTEMP.dimy);
3492  lx = (unsigned long) OMUTEMP.dimx;
3493  OMUTEMP.ptimeMat = (struct dtime *) calloc( lx, sizeof(struct dtime ));
3494  OMUTEMP.CCDTemp = (float *) calloc( lx, sizeof(float));
3495  OMUTEMP.CCDPwr = (float *) calloc( lx, sizeof(float));
3496  OMUTEMP.PltPwr = (float *) calloc( lx, sizeof(float));
3497  }
3498  else
3499  {
3500  sprintf(str, "'%s'\nUnrecognized Argument \n The Program will be terminated", p);
3501  MMessageDialog("DAS information", str, " Ok ", NULL);
3502  MGUITerm();
3503  exit(0);
3504  }
3505  ReadLogFile(1, str, buff, OMUTEMP.dimx, OMUTEMP.dimy, OMUTEMP);
3506  sprintf(str,"TEMPERATURE HISTORY - File:%s", p);
3507 
3508  DB_2DPlot(str, OMUTEMP.dimx, OMUTEMP.dimy, 512, 256, SET2D_GRID);
3509 
3510  MShellSetWMCloseCallback(OMUTEMP.sh, MGUIQuitCB, 0L);
3511  MMainLoop();
3512 
3513 }
3514 
3515 
3516 void BuildShell(int emode, char **argum)
3517 {
3518 
3519  int c = emode;
3520  int er = 0;
3521  switch (c)
3522  {
3523  case OFFLINEPLOT:
3524  if(argum[2] != 0)
3525  RunOLP(argum[2]);
3526  else
3527  RunOLP(NULL);
3528  break;
3529  case HELP:
3530  er = DB_HelpCB(NULL, NULL, NULL);
3531  break;
3532  case DOASMODE:
3533  MDCreateDOAS_MainSh(&DOAS);
3534  break;
3535  case LOGMODE:
3536  RunLogMode(0, argum[1]);
3537  break;
3538  default:
3539  RunFULL();
3540  break;
3541  }
3542 
3543 }
3544 
3545 
3546 void MGUIMain(int argc, char **argv)
3547 {
3548 
3549 // int mrun = 0;
3550  int er;
3551 // time_t ltime;
3552  struct tm today;
3553  char buff[128], str[_MAX_PATH];
3554 
3555  struct date RDate;
3556  struct time RTime;
3557 
3558 
3559 
3560 
3562 
3563 
3564 
3565 
3566  /**********************************************************************/
3567  /**********************************************************************/
3568  // DAS Working directory and MGUI Environment
3569  er = SetWorkDirMGUIenv(argv[0]);
3570  if (er == -1)
3571  {
3572  //Unable to set the enviromental variable
3573  }
3574 
3575  /**********************************************************************/
3576  /**********************************************************************/
3577 
3578  InitFlags();// For Flags and structure initialization
3579  /**********************************************************************/
3580  /**********************************************************************/
3581  // For Color and palette init
3582  InitColors();
3583  /**********************************************************************/
3584 
3585  /**********************************************************************/
3586  //Load home dir. and set Data, Config and Log Dirs
3587  LoadSetDirs();
3588  /**********************************************************************/
3589 
3590  /**********************************************************************/
3591  // Load Equipment.ini
3592  er = LoadEquipment(); //In order to know wich instrument will be used
3593  if(er == 1)
3594  {
3595  sprintf(str,"File %s\\Equipment.ini not found,\nThe program will be closed.\n ", BIL.DFILEM.CONFIGDIRCOMMON);
3596  MMessageDialog ("DAS ERROR ", str, "OK",NULL);
3597  exit(0);
3598  }
3599  if(er > 1)
3600  {
3601  sprintf(str,"Equipment with code '%d' not recognized!!!!\nCheck the '%s\\Equipment.ini' file\nor\nConsulte the DAS Help\nThe program will be closed.\n ", er, BIL.DFILEM.CONFIGDIRCOMMON);
3602  MMessageDialog ("DAS ERROR ", str, "OK",NULL);
3603  exit(0);
3604  }
3605  /**********************************************************************/
3606  //Set path for the DCL
3607  sprintf(buff, "%s", BIL.DFILEM.CONFIGDIREQUIPMENT );
3608  // Return: 1 if PATH exist, else return 0
3609  er = DI_PathExist(buff);
3610  if (er)
3611  {
3612  //Set path for the DCL
3613 // DC_SetPathName(buff);
3614  }
3615 
3616  /**********************************************************************/
3617  er = LoadWlstep();
3618  if(er)
3619  {
3620  sprintf(str,"File '%s\\WlStep.ini' not found,\nThe program will be closed.\n ", BIL.DFILEM.CONFIGDIREQUIPMENT);
3621  MMessageDialog ("DAS ERROR ", str, "OK",NULL);
3622  exit(0);
3623  }
3624 
3625  er = LoadHardware();
3626  if(er)
3627  {
3628  sprintf(str,"File %s\\Hardware.ini not found,\nThe program will be closed.\n ", BIL.DFILEM.CONFIGDIREQUIPMENT);
3629  MMessageDialog ("DAS ERROR ", str, "OK",NULL);
3630  exit(0);
3631  }
3632 
3633 
3634  /**********************************************************************/
3635  //Load the actual date of program start
3636 
3637  GetDateTime(&RDate, &RTime, &today);
3638  /* Get UNIX-style time */
3639  //time( &ltime );
3640  /* Use time structure to build a customized time string. */
3641  //today = localtime( &ltime );
3642  /* Use strftime to build a customized time string. */
3643  strftime( DLOG.odate, 7,"%y%m%d", &today );
3644  strftime( DLOG.otime, 9,"%H:%M:%S", &today );
3645  sprintf(BIL.SPH.olddate, "%s",DLOG.odate);
3646  DAS_StartHour = (int)(((double)today.tm_hour + 30.0/60.0) * 10);
3647  DAS_StartDOY = (int)(((double)today.tm_yday + 12.0/24.0) * 10); //next reset at StartDay + DAS.DOption.resetFreq
3648 
3649 
3650  sprintf(buff, "*******************************************************");
3651  D_WriteInitLog(buff);
3652  sprintf(buff, "DAS Started on %s at %s", DLOG.odate, DLOG.otime );
3653  D_WriteInitLog(buff);
3654 
3655  /**********************************************************************/
3656 
3657  /**********************************************************************/
3658  //Load the color table for the MGUI objects
3659  er = LoadDasSysCol();
3660  if(er)
3661  {
3662  LoadDefaultDPAL();
3663  sprintf(str,"File %s\\DASSysColor.INI not found,\nThe default DAS colors will be used.\n ", BIL.DFILEM.CONFIGDIREQUIPMENT);
3664  MMessageDialog ("DAS ERROR ", str, "OK",NULL);
3665 
3666  LoadDefaultDPAL();
3667  }
3668  /**********************************************************************/
3669  /**********************************************************************/
3670  // Load the palette for data visualization
3671  er = LoadTruePalette();
3672  if(er)
3673  {
3674  sprintf(str,"File '%s\\PALETTES\\DANBOMAP1.MAP' not found,\n", BIL.DFILEM.HOMEDIRECTORY);
3675  MMessageDialog ("DAS ERROR ", str, "OK",NULL);
3676 
3677  }
3678 
3679  /**********************************************************************/
3680 
3681  /**********************************************************************/
3682  //Load Geo coordinates of the station
3683  er = LoadGeoCoord();
3684  if(er)
3685  {
3686  sprintf(str,"File '%s\\GeoCoord.INI' not found,\nPlease supply a valid GeoCoord.INI file for the computation of the SZA and Sun Position", BIL.DFILEM.CONFIGDIREQUIPMENT);
3687  MMessageDialog ("DAS ERROR ", str, "OK",NULL);
3688  }
3689  /**********************************************************************/
3690  //Load Database of stations Geo coordinates
3691  er = LoadGeoDB();
3692  /**********************************************************************/
3693  //Load dispersion Parameters
3694  er = LoadDB_DispCoeff();
3695 
3696 
3697  /**********************************************************************/
3698  /**********************************************************************/
3699  //Log File
3700  WriteInit(DAS.DGeo.s_name, DLOG.odate,DLOG.otime);
3701  /**********************************************************************/
3702  /**********************************************************************/
3703  //Load Fonts
3704  // er = LoadDFONT();
3705  // if(er)
3706  // {
3707  // LoadDefaultDFONT();
3708  // }
3709  /**********************************************************************/
3710  /**********************************************************************/
3711  //Load options from file .\config\'Instrument'\options.ini
3712 
3713 
3714  er = LoadDB_Options();
3715  if(er)
3716  {
3717  if (er == 1)
3718  {
3719  sprintf(str, "%s\nPlease supply a valid %s\\Option.INI file or contact Danbo - db@uevora.pt\nNow DAS will quit!!", ERR_Option(er), BIL.DFILEM.CONFIGDIREQUIPMENT );
3720  MMessageDialog("DAS Inf. - Errors in OPTION.INI file", str, "OK", NULL);
3721  exit(0);
3722 
3723  }
3724  if (er > 1 && er < 40)
3725  {
3726  //Errors for OPTION.INI files
3727  sprintf(str, "Err.: %d - %s\nEdit %s\\Option.INI file and correct or contact Danbo - db@uevora.pt\nNow DAS will quit!!",er, ERR_Option(er), BIL.DFILEM.CONFIGDIREQUIPMENT );
3728  MMessageDialog("DAS Inf. - Errors in OPTION.INI file", str, "OK", NULL);
3729  exit(0);
3730 
3731 
3732  //Init Default Options
3733  //InitDefaultOptions();
3734  }
3735  if (er == 999)
3736  {
3737  sprintf(str, "The %s\\Option.INI file is present but not valid.\nProbably the file is from a previous DAS realise\nPlease supply a valid %s\\Option.INI file or contact Danbo - db@uevora.pt\nDAS can NOT continue the execution and it will quit!!", BIL.DFILEM.CONFIGDIREQUIPMENT,BIL.DFILEM.CONFIGDIREQUIPMENT );
3738  MMessageDialog("DAS Inf. - Errors in OPTION.INI file", str, "OK", NULL);
3739  exit(0);
3740 
3741  }
3742 
3743  }
3744  /**********************************************************************/
3745  /**********************************************************************/
3746  // Load the FTP settings for the data backup via FTP
3747  if(DAS.DOption.ftpbackup)
3748  {
3749  er = LoadFTPSetting();
3750  if (er)
3751  {
3752  sprintf(str, "The %s\\FTP.INI file not found.\n The Data back-up can not be done!\nPlease supply a valid %s\\FTP.INI file or contact Danbo - db@uevora.pt\nNow DAS will quit!!", BIL.DFILEM.CONFIGDIREQUIPMENT,BIL.DFILEM.CONFIGDIREQUIPMENT );
3753  MMessageDialog("DAS Inf. - Errors in FTP.INI file", str, "OK", NULL);
3754 
3755  DAS.DOption.ftpbackup = 0;
3756  }
3757  }
3758  /**********************************************************************/
3759  /**********************************************************************/
3760  // Check the execution mode (TEMPORIZED, TESTAMS, OFFLINEPLOT, TESTCCD,
3761  // TESTAD, DEMO, ?, PrgFile, MANUAL)
3762  ChkExeMode(argc, argv);
3763  /**********************************************************************/
3764 
3765 
3766  /**********************************************************************/
3767 
3768  /**********************************************************************/
3769  /* Build and Execute the shell depending on the execution mode*/
3770  /**********************************************************************/
3771  BuildShell(DAS.Flag.exemode, argv);
3772 
3773 }
3774 
int settemp070
int PaletteMode
Definition: DAS_Spat.c:158
flag FLAG
Definition: CreateForms.c:84
stepm StepM
Stepper motors parameters structure.
#define ELAMPOFF
External Lamp OFF.
cfg Cfg
Definition: Dildef.h:678
#define SPATRAM
SPectrometer for Atmospheric TRAcers Measurements - CGE-UE Portugal.
Status of the Zenith .
#define H_NDFW
Home for ND FilterWheel.
NDFilterWheelSt NDFWS
ND Filter Wheel.
Definition: DAS_Spat.c:58
char prg[16]
PRG Filename.
void MObjectSetBackgroundRGB(MOBJECT obj, int r, int g, int b)
gui Gui
Graphic User Interface Structure.
void DB_KB_ButtonActive(int mod)
Enable/Disable Push buttons on the Control Panel.
Definition: CreateForms.c:3810
int hometype[AMSMAX][2]
#define WS_NONE
Definition: Mguidefs.h:956
int AUTOEX
Automatic Execution ID.
MOBJECT LedSM[AMSMAX][2]
Leds for stepper motors status.
int WDT_flagstop
Definition: DAS_Spat.c:146
char env[_MAX_PATH]
Environment path.
Definition: DAS_Spatram.h:3075
void MRefreshTimeout(TIMEOUT_ID *pid, CARD32 msec, TIMEOUT_CB cb, void *ud)
int settemp7080
char odate[10]
Old Date.
int IDX
Number of sensible horizontal pixels.
Definition: DAS_Spat.c:118
shells Shells
Shells structure.
int DB_InitMotor(int mod)
Initialize AMS. Procedure that initialize the parameters for the AMS&#39;s devices.
Definition: Init.c:1584
MOBJECT Albl_LS[8]
Active Control Panel Labels for LIS status.
MOBJECT MCreatePixmapFromFile(MOBJECT parent, const char *fname)
unsigned int keycode
Code for the pressed key.
Definition: Mguidefs.h:541
void ManualModeCB(MOBJECT p, void *od, void *ad)
Definition: DAS_Spat.c:2224
MOBJECT lbl
Definition: DFileMan.c:42
void SZA_FirstCalc(void)
Definition: DAS_Spat.c:2858
void InitDefaultOptions(void)
Definition: DAS_Spat.c:3448
double S_zenetr
Definition: SOLPOS.C:92
unsigned long * PLColor[]
Definition: DAS_Spat.c:251
void InitFlags(void)
Definition: DAS_Spat.c:952
int Server
Definition: DAS_Spat.c:253
#define LABEL
text after this command is displayed in the status label
int DB_InitCamera(int mod)
Initialize Camera Parameters. Procedure that initialize the CCD Camera.
Definition: Init.c:170
Definition: DOASdef.h:16
C_DEF int DI_FindDrive(char *fullname)
short DB_FG_Plbl[3]
Foreground PASSIVE Label Colors.
void MLoopWhileEvents(int discard)
optionini DOption
Options for DAS execution.
int extlamp
0 = external lamp OFF; 1 = external lamp ON
Status of the ND Filter wheel .
int savingmode
Flag to set saving mode: 0=ASCII, 1=Binary.
#define AMS2
AMS2 address.
void MObjectSetShadow(MOBJECT obj, int type, int in, int out)
const char * Mir_Code[]
const char array for the realisation of the Mirrors buttons in the Mirror shell
Definition: DAS_Spat.c:231
#define TESTCCD
execution for testing CCD Camera
#define SETCCDVBIN
SET the CCD vertical Binning.
ptf DC_HP
Platform settings.
Definition: DAS_Spat.c:45
void MShellRealize(MOBJECT obj)
void D_VRange(char *str, int val, int, int g, int b)
Create and display the status bar.
Definition: Utils.c:206
int LoadHardware(void)
Definition: Load.c:1170
void ChkDASInstance(int etype)
Definition: DAS_Spat.c:2048
int InitCCD_AMS(int mod, int emode)
Definition: DAS_Spat.c:1793
dsza SZADelta
Definition: DAS_Spat.c:76
int InitTempAD(int mod)
Definition: DAS_Spat.c:2681
#define H_GRAT_CAL
Perform home for the grating and executa a calibration.
#define H_ZEN
Home for zenith Axis.
int LoadWlstep(void)
load the file of the wavelength vs steps
Definition: DAS_Spat.c:258
tools TOOLS
tools structure
Definition: DAS_Spat.c:51
MOBJECT KeyB[28]
Keyboard Buttons.
int NAMS
Number of AMSs Devices.
MOBJECT Albl_sunr
Active Control Panel Labels for Sunrise.
int Master
Definition: DAS_Spat.c:100
double Dailymaxsza
Daily maximum SZA.
PREFUNCTION int MIDFUNCTION OutByte(unsigned short Port, int Data)
void WDT_CB(MOBJECT p, void *od, void *ad)
Definition: DAS_Spat.c:1507
#define ESC
Definition: KEYCODES.H:265
char LOGDIR[_MAX_PATH]
Definition: bildef.h:209
Stepper motors parameters structure .
dlog DLOG
Definition: DAS_Spat.c:52
double S_azim
O: Solar azimuth angle: N=0, E=90, S=180, W=270.
Definition: SOLPOS.C:45
int ContFP
Counter for File position.
Definition: DAS_Spat.c:123
int Wl
Flag for the units on the X scale plot.
int SM_A
Motor A (su Y11) respectively: ID=0->InputMirror,ID=1->FilterWheel,ID=2->Zenith.
char * HomePosition[]
const char array for the realisation of the Filters buttons in the ND Filter shell ...
Definition: DAS_Spat.c:227
#define AAMEASURE
Measuremets with Alt Azimut platform (stepper motors positioning simoultaneously) ...
#define AAPOSIT
Position the Alt Azimuth Platform.
struct dtime * ptimeMat
Definition: bildef.h:101
int FirstTime
Definition: DAS_Spat.c:110
U8 ti_sec
Definition: Dildef.h:238
int plotW
Flag for the plot display.
int sza
= 1 -> perform measurements; = 0 -> waiting mode
MTColor DrawBG
Definition: bildef.h:184
void MPixmapSetImageFile(MOBJECT pixmap, const char *fname)
das structure (contain all the previous structures) .
int PrgNumExe
number of PRG file in execution
Definition: DAS_Spat.c:98
Definition: DSCUD.H:340
#define DASREV
DAS Revision Number.
d_geo DGEO
geographical coordinates structure
Definition: DAS_Spat.c:53
int VMRsf
ViewModifyReloadsystemfile: 0 = ViewModify, 1 = Reload.
MTColor black
#define QJ_ON
QJ lamp on.
int MObjectGetHeight(MOBJECT obj)
#define TESTSZAMODE
execution driven by SZAPRG file
MOBJECT MCreateLabel(MOBJECT parent, const char *text, MTFont font)
Control Panel and push buttons colors .
int SaveCnt
Definition: Procedures.c:49
long Total_Spec
Definition: DAS_Spat.c:95
double latitude
Station latitude.
#define PRGMAXNUM
Maximum number of PRG File in MASTER or MASTERSZA File.
void MObjectSetResize(MOBJECT obj, int resize_w, int resize_h)
int OMU_HC(void)
Definition: Chktemp.c:597
MTColor white
int eora
End hour.
#define WAIT
stop the program execution for xx millisec
void ChkExeMode(int mod, char **p)
Definition: DAS_Spat.c:3177
#define DOASMODE
execution for DOAS Processing
const char * DeviceTypeInput[]
const char array for the Device type <-> Input association
Definition: DAS_Spat.c:247
short OMU_TempReached
OMU presetted temperature reached -> = 1.
int ReadLogFile(int mod, char *dir, char *filename, int nx, int ny, struct omutemp datatemp)
Read DAS LOG File. .
int Pos
Mirror Current Position.
#define PLOT
display plot
void WinRes(void)
Definition: RTC_Time.c:1067
flag Flag
Structure for different flags.
#define AUTOEX_TASK_TIME
Autoexecution.
MOBJECT Sh_Main
Main shell for control panel.
int D_Timing(int id, long tout)
Definition: DAS_Spat.c:1477
MOBJECT MDCreate_CP(void)
Create Spectrometer Control Panel. Procedure that build the Control Panel for checking the spectromet...
Definition: CreateForms.c:1143
int darkremove
Flag to set Dark Removal from measurements; motors0 = No Dark Removal, 1 = Dark Removal.
#define HELP
Help mode.
void MMainLoop(void)
void LoadDefaultDPAL(void)
Load Default system colors. Procedure that load the DAS colors if the file {homedir}/config/DASSysCol...
Definition: Load.c:762
void WDT_func(int mod)
Definition: DAS_Spat.c:1572
#define HG_ON
HG lamp on.
char HOMEDIRECTORY[_MAX_PATH]
Definition: bildef.h:200
short DB_BG_Albl[3]
Background ACTIVE Label Colors.
#define DBDEMO
execution in demo mode
void NoWaitCB(MOBJECT p, void *od, void *ad)
Definition: DAS_Spat.c:2393
#define False
Definition: Mguidefs.h:236
void MObjectAlign(MOBJECT obj, int h_align, int v_align)
int FlgSh_PWD
char otime[10]
Old Time.
int Offset[16]
Offset of the hardware devices (Input Mirror (5), Grating, Filter Wheel...)
int PRG_Check(int mod, char *prgname)
Definition: DAS_Spat.c:531
MOBJECT WDT_edt
edit Mobject for Watch-Dog elapsed time
unsigned short DigOut
Digital Output.
#define NOVA945GSE
NOVA945GSE (SPATRAM2, GASCODNG1, GASCODNG4)
int slope[AMSMAX][2]
Stepper Motors Slope.
LOG file and time structure.
#define NOVA6612G2
NOVA6612G2 (not used in TROPOGAS, LIS, GASCODNG2/3)
#define QJSCAN
Scan spectral range with QJ on.
char DATADIRECTORY[_MAX_PATH]
Definition: bildef.h:201
int Fetch()
Reads the key-word in PRG Files .
Definition: DAS_Spat.c:298
int LoadGeoCoord(void)
Load Geographic Coordinate of the station. Procedure that load the Geographic Coordinate of the stati...
Definition: Load.c:1477
doas DOAS
Definition: DAS_Spat.c:63
PREFUNCTION int MIDFUNCTION InByte(unsigned short Port, int *Data)
dil DIL
Definition: DAS_Spat.c:72
int LoadAMS(void)
Definition: DAS_Spat.c:1201
const char * KeyCode[]
Definition: DAS_Spat.c:164
int PrgNum
Definition: DAS_Spat.c:96
char * MObjectGetText(MOBJECT obj, char *text)
void Task_LOG(TIMEOUT_ID id, void *data)
LOG Task. Write on the LOG file during DAS execution.
Definition: RTC_Time.c:246
int LoadGeoDB(void)
Definition: Load.c:1432
geographical coordinate structure .
U32 NColors
Definition: Dildef.h:648
spectrumheader SPH
Spectrum Header Structure.
Definition: bildef.h:256
void BuildMainShell(void)
Definition: DAS_Spat.c:2597
structure for deltaSZA Measurements .
#define CHKEXLAMP
Check External lamp status.
int Mode
Definition: DAS_Spat.c:108
int WlSet
Wavelength position definition - for SD_Grating.
Definition: DAS_Spat.c:135
void TaskWDT(TIMEOUT_ID id, void *data)
Definition: DAS_Spat.c:1767
char * Fil_Code8H[]
const char array for the realisation of the Filters buttons in the Filter shell
Definition: DAS_Spat.c:204
#define TEMPORIZED
execution driven by MASTER file
int PrgNumInM
Actual number of PRG File in current MASTER or MASTERSZA File.
Definition: DAS_Spat.c:97
void PeltierPS(int mod)
Peltier Power Supply ON/OFF .
Definition: Spat_Device.c:2551
float multiplier[AMSMAX][2]
multiplier, > 0 multiplier, < 0 demultiplier
void DAS_Message(char *str, int er)
Definition: Errors.c:74
#define SZAMASTERM
execution driven by MASTERSZA file ( there is the possibility to distinguish between AM and PM measur...
void MShellUnrealize(MOBJECT obj)
struct das das
das structure (contain all the previous structures) .
long REL_FILE_POS[51]
relative File position
Definition: DAS_Spat.c:124
#define GETCCD
Performs a LIGHT Measurement (shutter opened)
int LoadDB_Options(void)
Load Options. Procedure that load the Options in the file {homedir}/config/Options.INI.
Definition: Load.c:390
char olddate[8]
Definition: bildef.h:158
void MObjectSetText(MOBJECT obj, const char *text)
#define FDAT
Definition: bildef.h:221
#define IREFSUN
Io Measurement with AA Platform near the Sun.
CTYPE const char *PROC_CALL DC_ErrorMessage(int ErrorCode)
Convert an error code into an error message (string). DC_Status returns an error code of the previous...
void MEnableCustomizing(void)
int SZAMax
Maximum SZA for performing measurements.
Definition: DAS_Spat.c:116
float * CCDPwr
Definition: bildef.h:103
int LoadTruePalette(void)
Load the palette map. Procedure that load the palette map from file {homedir}/Palettes/Danbomap1.map.
Definition: Load.c:948
void InitColors(void)
Definition: DAS_Spat.c:3371
float CoolPT
Previous Temperature (DTA -> DC_CoolPT)
int FKIND
Definition: bildef.h:211
void WDT_Task_CB(MOBJECT o, void *od, void *ad)
Definition: DAS_Spat.c:1547
void Task_REFRESH_Temp(TIMEOUT_ID id, void *data)
Temperatures Task. Refresh the temperatures during DAS execution.
Definition: Chktemp.c:1579
MOBJECT Albl_suns
Active Control Panel Labels for Sunset.
int Pos
Filter Wheel current Position.
*double S_sunset
Definition: SOLPOS.C:82
int AssignParam(int mod)
Assign parameters to the CP labels. .
Definition: Load.c:990
int GRATHOME
Home for Grating ID.
int FlgSM_Stop
Steppers Motor Activity: 0 = Motors moving; 1 = Motors stopped.
Definition: DAS_Spat.c:140
int MPaletteMode(void)
bil BIL
Definition: DAS_Spat.c:74
d_geo DGeo
struct for Station location
void Task_HomeGrat(TIMEOUT_ID id, void *data)
Home grating Task. 5) Check for reached end-run of the stepper motor for the grating ...
Definition: RTC_Time.c:980
MOBJECT Albl_Azim
Active Control Panel Labels for Sun Azimuth.
int MObjectGetWidth(MOBJECT obj)
void Task_Timer(TIMEOUT_ID id, void *data)
Timer Task. Very useful procedure that: 1) Provide to refresh the clock display 2) Check if daylight ...
Definition: RTC_Time.c:1184
void MShellDestroy(MOBJECT obj)
config Cfg
Camera controls & Options.
Definition: DAS_Spat.c:46
palette DPAL
Definition: DAS_Spat.c:73
void DAS_Error(int c)
Definition: Errors.c:124
#define WORD
Definition: DSCUD.H:65
#define LIS_
Lampedusa Island Spectrometer - ENEA.
U8 ti_hour
Definition: Dildef.h:236
int exec
= 0 -> PRG Execution Paused; = 1 -> PRG Execution Resumed
int Wl
Grating Wavelength.
long PrgSiz
Size of the PRG file.
Definition: DAS_Spat.c:94
mtcl MTCL
MTColor.
Definition: DAS_Spat.c:62
#define TROPOGAS
TROPOspheric Gas Analyzer Spectrometer.
#define MEASHOR
horizontal measurements with external lamp (lamp,
void Task_LIS_Temp(TIMEOUT_ID id, void *data)
OMU Thermoregulation Task. Provide the thermoregulation of the Optical Mechanical Unit In addition al...
Definition: Chktemp.c:873
#define EM_KEY_PRESS
Definition: Mguidefs.h:316
long AbsFilePos
Absolute File position.
Definition: DAS_Spat.c:122
int hlinebefore
Number of HiddenLines before the central line in Plot.
char * Fil_CodeNG[]
const char array for the realisation of the Filters buttons in the Filter shell for GASCODNG2 and NG3...
Definition: DAS_Spat.c:216
tools Tools
Push buttons for various tools.
char * Program
buffer for the PRG file
Definition: DAS_Spat.c:90
int TIMER
Timer ID.
MOBJECT lbl_Time
Control Panel Labels for Time.
int timezone
Station timezone.
void LaunchBackTask(void)
Launch the DAS Background tasks Common Tasks launched when the DAS MAIN Graphic User Interface is loa...
Definition: DAS_Spat.c:2624
char s_name[4]
Station name.
long dp
Grating backslash recovery steps.
#define DASREVDATE
DAS Revision Date.
unsigned long countsopsh
counting the number of opening shutter
Definition: DAS_Spat.c:133
unsigned int data[576]
Conversion data buffer 64 samples * 8 channels * 2 bytes.
MOBJECT MCreatePButton(MOBJECT parent, const char *text, MTFont font)
#define H_FILTER
Home for filter wheel.
#define WAVELEN
set the grating position
unsigned int * mattempbuff
Definition: DAS_Spat.c:128
int WDT
Watch Dog.
int dimx
Definition: bildef.h:113
int ADTempTest
= 0 -> AD Converter results on the Control Panel; = 1 -> AD Converter Testing Phase(results on the co...
#define LOGMODE
execution for LOG View
int CCDTEMP
CCD Temperature ID.
float PID_ki
d_fileman DFILEM
Definition: bildef.h:257
C_DEF void DI_SplitName(char *fullname, char *fpath, char *fname)
int CoolCnt
Time Counter.
int avgmode
Flag to set Averaging mode: 0 = Repeat measurements for fixed number, 1 = Repeat measurements for fix...
#define OFFLINEPLOT
execution for archived data visualisation
void MGUITerm(void)
#define CENTER_ALIGN
Definition: Mguidefs.h:917
#define GASCODNG2
GASCODNG 2 (with ATX power supply & HiresIV)
#define AUTORNG
Autoranging for optimal exposure time.
double Dailyminsza
Daily minimum SZA.
void ReadLine(char *buf, int nc, FILE *f)
Read Line on a file Read one record of nc character on the file f.
Definition: Load.c:72
#define ESHUTCL
External Shutter CLOSED.
#define AZIMUTH
Positioning of Azimut Axis.
int DeltaTPrec
Definition: DAS_Spat.c:111
long PrgCnt
Counter for the position in the PRG file.
Definition: DAS_Spat.c:93
int settemp8095
void DB_ChooseButtons(int w)
Definition: CreateForms.c:2560
#define WDT_TASK_TIME
Watch Dog Timer.
#define AVGCCDHOR
horizontal AVERAGED measurements with external lamp
int REFRTEMP
REFRESH Temperature ID.
#define DSCB
Definition: DSCUD.H:140
void MObjectSetCompositeHeight(MOBJECT obj, int h)
d_view DPLOT
Definition: bildef.h:254
int PRG_ChkMirror(int mod, char *filename, int record, int par)
Definition: DAS_Spat.c:355
int PRG_ChkMeasAvg(int line, char *fname)
Definition: DAS_Spat.c:414
int sora
Start hour.
MOBJECT Albl_Script
Active Control Panel Labels for Script in execution.
long MGetNColors(void)
void AboutCB(MOBJECT o, void *s, void *v)
Create the About information shell. .
Definition: About.c:39
char DIRDCL[_MAX_PATH]
Definition: bildef.h:210
int ReachTemp
CCD Temperature Reached.
PREFUNCTION int MIDFUNCTION InByteR(unsigned short Port)
int PRG_ChkGrating(int mod, char *filename, int record, int par)
Definition: DAS_Spat.c:376
#define EXPO
Set the exposure time.
int PID_On
PID activation.
C_DEF void DI_FindDirName(char *fullname, char *fdir)
int Dir
Mirror direction.
#define SPATRAM2
SPATRAM2 (with ATX power supply & HiresV)
int Addr[AMSMAX]
address of AMs
int ChkConfigInstance(void)
Definition: DAS_Spat.c:2128
int ViewPlot(int mod)
Create the plot shell. Procedure that build the plot shell for the data visualization.
Definition: Spat_Plot.c:3775
float * Temptemp
Buffer for lis temperature.
#define SPATRAMPLUS
As SPATRAM plus AltAzimuth platform.
int UPS_Battery
flag for UPS Battery: = 0 Normal Operation, 1 = working on UPS battery
dpwd DPWD
Danbo Passw.
Definition: DAS_Spat.c:49
id&#39;s for different tasks .
#define QJ_OFF
QJ lamp off.
char CONFIGDIREQUIPMENT[_MAX_PATH]
Definition: bildef.h:208
#define SF_MODAL
Definition: Mguidefs.h:1019
const char * MGetCurrentDirectory(void)
int ON_OFFLINEPLOT
Definition: DAS_Spat.c:117
void Status(char *tit)
Writes information&#39;s on the Status label .
Definition: Load.c:1556
void RunFULL(void)
DAS Main LOOP for Equipment management This Procedure is called by the MGUIMain function when the exe...
Definition: DAS_Spat.c:2994
double S_sunrise
Definition: SOLPOS.C:80
int NOVA_Out(int novatype, unsigned int out)
Write the NOVA Output port.
Definition: DAS_Spat.c:1375
char * ERR_Option(int ercode)
Alerts for OPTION.INI errors Creates a message window reporting the reasons for the error...
Definition: Load.c:325
ISMM_API BOOL WDT_SetTimeout(HANDLE hIsmm, WORD wTimeout, WORD wTimeOption)
mige MIGE
void delay(unsigned long d)
Pauses for a specified number of milliseconds. .
Definition: Dxl.c:1113
NOVA7892 structure .
int ChkWinInstance(char *buff, MOBJECT obj)
Definition: DAS_Spat.c:2153
MTColor MAllocColor(int r, int g, int b)
int DeltaSZA
= 1 Delta SZA measurements activated, = 0 Continous measurements
int Incr_Read_Temp
Definition: DAS_Spat.c:101
void(* OBJ_EVENT_CB)(MOBJECT obj, MEvent *e, void *ad)
Definition: Mguidefs.h:1456
Definition: Dildef.h:240
char DBFILENAME[_MAX_PATH]
Definition: bildef.h:204
#define LISTEMP_TASK_TIME
spectrometer termoregulation
#define GRAT_TASK_TIME
Grating Home.
#define GASCODNG3
GASCODNG 3 (with ATX power supply & HiresIV)
#define DARKC
Perform a DARK Measurement (shutter closed)
ISMM_API BOOL ISMM_Close(HANDLE hIsmm)
int plotYRange
0 –> full range; 1 –> min/max
int resetFreq
frequency of DAS/Windows Reset
ISMM_API BOOL DIO_GetInput(HANDLE hIsmm, PWORD pwDioData)
void DemoInitMotor(void)
Definition: DAS_Spat.c:1047
#define PRGFILE
execution driven by *.prg file
MOBJECT MCreateColForm(MOBJECT parent)
void SetScriptUseLabel(int master, char *prgf, int emode, MOBJECT lbl)
Definition: DAS_Spat.c:2509
#define DIRECTSUN
void HiresPS(int mod)
Hires Power Supply ON/OFF .
Definition: Spat_Device.c:2532
void MObjectAddEventNotifyCallback(MOBJECT obj, OBJ_EVENT_CB cb, CARD32 event_mask, void *a_data)
int DAS_StartDOY
Definition: DAS_Spat.c:107
void DB_Pause(void)
Definition: CreateForms.c:3766
tools buttons . Push buttons for various tools .
void WriteInit(const char *sname, char *dateffn, char *timebuff)
Init the daily LOG file .
Definition: RTC_Time.c:158
#define SAVE
save the measurement in the predefined file
#define ELAMPON
External Lamp ON.
int ADPC104
0 –> Device PC104 exist, 1 –> PC104 DOESN&#39;T exist
pushbutt PushButt
Push buttons.
int IDY
Number of sensible vertical pixels.
Definition: DAS_Spat.c:119
#define GASCODNG1
GASCODNG 1 (with ATX power supply & HiresIV)
void MShellRealizeXY(MOBJECT obj, int x, int y)
Function prototypes.
#define GASCODNG4
GASCODNG 4.
int LoadDasSysCol(void)
Load system colors. Procedure that load the DAS colors in the file {homedir}/config/DASSysColor.INI.
Definition: Load.c:811
#define FILTER
Set the filter position (0 - 6)
Definition: bildef.h:77
char * Fil_CodeNG1[]
const char array for the realisation of the Filters buttons in the Filter shell for GASCODNG1 instrum...
Definition: DAS_Spat.c:213
#define ZENITH
Positioning of zenith Axis.
int ExeREM
Definition: DAS_Spat.c:143
#define MEASHOR2
Perform horizontal measurement.
int TOTTEXP
Total Exposure time in Averaging mode.
Definition: DAS_Spat.c:115
MOBJECT View_Sh
Definition: bildef.h:35
int amsprogbar
display/hide prograssion bar, 0 = Hide, 1 = display
int WindowsReboot
Flag that became 1 when Windows reboot is setted (SetWinowsReset)
#define _MAX_PATH
Definition: Dildef.h:202
int FFTFilter
Fast Fourier Trasform Filter windows.
Definition: DOASdef.h:25
MOBJECT MCreateShell(const char *title, int flags)
ZenithSt ZST
Definition: DAS_Spat.c:70
ISMM_API BOOL DIO_GetConfig(HANDLE hIsmm, PWORD pwDioConfig)
int FlagFilter
flag for filterinf
int hlineafter
Number of HiddenLines after the central line in Plot.
void Task_AutoEx(TIMEOUT_ID id, void *data)
Automatic Execution Task. .
Definition: RTC_Time.c:963
int MMessageDialog(const char *t, const char *msg, const char *btn1, const char *btn2,...)
structure for OMU temperatures .
Definition: bildef.h:97
#define ALMUCANTAR
das DAS
Definition: DAS_Spat.c:85
int linked
ids IDS
ID tasks.
Definition: DAS_Spat.c:54
int PRG_ChkKeyW(int line, char *fname)
Definition: DAS_Spat.c:348
DSCB dscb
Definition: DAS_Spat.c:67
int LoadFTPSetting(void)
Load FTP Setting for daily back-up.
Definition: Load.c:286
int LoadEquipment(void)
Load the type of Equipment. {homedir}/config/param.ini.
Definition: Load.c:1089
void SZA_FindMin()
computation of daily minimum SZA
Definition: DAS_Spat.c:2808
int ExMaster(int m, int mode)
Definition: DAS_Spat.c:739
#define SPATRAM3
SPATRAM3.
short DB_BG[3]
Default Background Color.
#define H_AZI
Home for Azimut Axis.
double TExp
CCD Exposure time.
Definition: DAS_Spat.c:130
void DB_SelButt_CB(MOBJECT obj, MKeyEvent *pe, void *a_data)
Definition: DAS_Spat.c:858
MirrorSt MIS
Mirror.
Definition: DAS_Spat.c:61
#define SETCCDOFFS
CCD Offset for HiresV.
void MDCreateSplashExe()
Definition: DAS_Spat.c:2267
void MShellRaise(MOBJECT obj)
int ftpstatus
0 = FTP Back-UP Not executed; 1 = FTP Back-UP executed;
ccd DC_CCD
CCD settings.
Definition: DAS_Spat.c:44
int DB_HelpCB(MOBJECT o, void *od, void *ad)
Help Callback Create the help in the predefined WEB Browser.
Definition: DAS_Spat.c:881
nova Nova
NOVA structure.
configpanel ConfigPanel
Configuration panel structure.
int D_InitPC104(void)
Starting function that calls the driver functions used NOTE: By convention, you should capture the BY...
Definition: Dscad.c:120
Function prototypes.
#define SET2D_GRID
Definition: Dildef.h:156
ISMM_API BOOL WDT_Start(HANDLE hIsmm, BOOL bControlState)
#define SZAMODE
execution driven by SZAPRG file
int SM_B
Motor B (su Y12) respectively: ID=0->Grating,ID=1->Not Connected,ID=2->Azimuth.
int MainCommand
Command switch in main loop.
Definition: DAS_Spat.c:105
static double p
Definition: SOLPOS.C:131
int SetWorkDirMGUIenv(char *buff)
set DAS and MGUI enviroment when the program is launched undirectly (for offlineplot or log or auto o...
Definition: DAS_Spat.c:3353
DSCCB dsccb
Definition: DAS_Spat.c:68
char * Fil_Code[]
const char array for the realisation of the Filters buttons in the Filter shell
Definition: DAS_Spat.c:207
#define DFMEASURE
Measurement procedure using the double ND FilterWheel (when Installed)
int LISTEMP
Lis Temperature ID.
#define CALIBRA
Auto calibration with HG Lamp (hg line at 4358A on pix 512)
int AMS_H
Home AMS.
#define TIMER_TASK_TIME
timer
int FlagDisplay
char PrgFile[_MAX_PATH]
Name of the PRG file.
Definition: DAS_Spat.c:91
int LoadDB_DispCoeff(void)
Load dispersion parameters. Procedure that load the dispersion parameters from file {homedir}/DOAS/Di...
Definition: Load.c:234
int Off
Mirror Offset.
void GetDateTime(struct date *dp, struct time *tp, struct tm *when)
Definition: Save.c:43
int wl[]
WaveLength definition - for SD_Grating.
Definition: DAS_Spat.c:182
int MGetScreenWidth(void)
#define REFRESHTEMP_TASK_TIME
refresh of the spectrometer&#39;s temperatures.
void MGUIMain(int argc, char **argv)
MAIN PROGRAM starting point Actions: .
Definition: DAS_Spat.c:3546
U8 ti_min
Definition: Dildef.h:235
int LOG
Log ID.
int pixcorr
Flag to set defective pixel correction: 0=NOT Corrected, 1=Corrected.
int PRG_ChKBegin(int line, char *fname)
Definition: DAS_Spat.c:515
#define SETCCDPOW
SET the CCD Power.
int fileprg
Flag indicating the execution of a PRG file: = 0 –> No PRG File; = 1 –> PRG file in execution...
MTColor PLColor[264]
controlpanel ContrPanel
Control Panel Structure.
int ftpbackup
Flag to set back up: 0 = NO FTP Back-UP; 1 = Perform FTP Back-UP.
#define MEASURE
Performs a measurement setting mirror, filter, grating, TExp...
Bortul Image Library Structure .
Definition: bildef.h:250
int CCD_SetupFlg
Definition: DAS_Spat.c:138
int LoadParam(void)
Load the exe parameters. Procedure that load the parameters for CCD, Stepper Motors and Peltier from ...
Definition: Load.c:1215
int D_WriteInitLog(char *str)
writes devices errors(AMS, CCD...) on the Devices.log file.
Definition: Save.c:144
Definition: Dildef.h:674
int imgtype
Flag to set Image type: 0=MONOINT, 1=RGB.
#define SPACEBAR
Definition: KEYCODES.H:276
#define H_MIRROR
Home for Mirror.
double longitude
Station longitude.
float * PltPwr
Definition: bildef.h:104
void MPButtonSetCallback(MOBJECT button, MGUI_CB cb, void *data)
#define AMS1
AMS1 address.
void AMSINI_Err(int c)
Definition: DAS_Spat.c:2573
void MObjectSetCompositeWidth(MOBJECT obj, int w)
int LoadExec(char *fname)
Load file for automatic execution. Procedure that load the file for automatic execution.
Definition: Load.c:1534
void WDTRefresh(void)
Definition: DAS_Spat.c:1701
CARD32 TIMEOUT_ID
Definition: Mguidefs.h:1421
int Visualizza(int mod, char *nomefile)
Definition: Spat_Plot.c:2069
void FlushLine(char *buf, int nc, FILE *f)
Flush line of file f read a maximum of nc character since when the read char is different from ch(10)...
Definition: Load.c:54
#define DWORD
Definition: DSCUD.H:75
void D_Positioning(MOBJECT p, int id, long tout)
Callback for the void D_VRange and display also the status in the corresponding CP labels...
Definition: Dxl.c:607
static double st
Definition: SOLPOS.C:142
int settempvar
void MDCreateWaitShell(void)
Create a waiting window .
Definition: DAS_Spat.c:2408
int speed[AMSMAX][2]
Stepper Motors Speed.
MOBJECT MDCreateDOAS_MainSh(struct doas *pdoas)
DOAS shell. Procedure that build the shell for the DOAS main panels.
#define BEGIN
re-start the execution of the PRG file
void MShellSetTitle(MOBJECT obj, const char *title)
float PID_kp
int manhormeas
1 = horizontal measurements in manual mode
int step[AMSMAX][2]
Stepper Motors Step.
unsigned char WDT_Timeout
Definition: DAS_Spat.c:145
void * MOBJECT
Definition: Mguidefs.h:192
blens BLENS
Definition: bildef.h:252
#define BOTTOM_ALIGN
Definition: Mguidefs.h:919
Definition: Dildef.h:234
#define True
Definition: Mguidefs.h:235
int ExeDSZA
= 1 the measurements are performed, = 0 waiting for the next deltasza.
nova NOVA
Definition: DAS_Spat.c:77
Status of the Mirror .
#define H_GRAT
Home for Grating.
viewformobj VFO
Definition: bildef.h:255
Definition: dcldef.h:1020
float * AllocFloatMat(int hp, int vp)
Definition: Spat_Plot.c:2009
unsigned int LevelDefPix
Definition: DAS_Spat.c:126
omutemp OMUTEMP
structure for OMU temperatures
Definition: DAS_Spat.c:65
double Pix
Definition: bildef.h:16
int NOVA_In(int novatype, unsigned int DigIn)
Read the NOVA Input port.
Definition: DAS_Spat.c:1306
Definition: dcldef.h:1043
GratingSt GRS
Grating.
Definition: DAS_Spat.c:60
#define CCDTEMP_TASK_TIME
CCD temperature.
#define XEND
stop the execution of the PRG file
omuthr OMUTHR
Definition: DAS_Spat.c:75
int dimy
Definition: bildef.h:113
char * Fil_CodeTropo[]
const char array for the realisation of the Filters buttons in the Filter shell for TROPOGAS instrume...
Definition: DAS_Spat.c:210
int nowait
Definition: DAS_Spat.c:2389
int ChkMaster(int mod)
Definition: DAS_Spat.c:2730
void CCD_Error(char *str)
Alerts for CCD errors Creates a message window reporting the number of the error. ...
Definition: Errors.c:279
C_DEF int DI_PathExist(char *path)
float * CCDTemp
Definition: bildef.h:102
int DB_InfCB(MOBJECT o, void *od, void *ad)
Inf Callback Create the Inf shell.
Definition: DAS_Spat.c:915
char * NDFil_Code[]
const char array for the realisation of the Filters buttons in the ND Filter shell ...
Definition: DAS_Spat.c:219
int filename
Flag to set file name mode 0=Free choice, 1 = Automatic.
int MGetScreenHeight(void)
MOBJECT Albl_Elev
Active Control Panel Labels for Sun Elevation.
#define LOG_TASK_TIME
LOG files.
int EqType
Spectrometer Type.
int N_RM
Number of measurements for Averaging mode in fixed exposure time mode.
Definition: DAS_Spat.c:114
#define RADIO
Unused.
#define TESTAD
execution for testing PC 104 AD converter
#define HELV_MEDIUM
Definition: Mguidefs.h:882
void RunOLP(char *fname)
Definition: DAS_Spat.c:3114
#define NOVA7892
NOVA7892 monoboard (old)
char CONFIGDIRCOMMON[_MAX_PATH]
Definition: bildef.h:206
void MGUIQuitCB(MOBJECT shell, void *od, void *ad)
Exit MGUI Library. Procedure that close MGUI .
Definition: DAS_Spat.c:728
unsigned char DigIn
Digital Input.
#define HG_OFF
HG lamp off.
int nowaitsplash
Definition: DAS_Spat.c:2249
void MObjectSetTransparency(MOBJECT obj, CARD8 level)
void MObjectSetForegroundRGB(MOBJECT obj, int r, int g, int b)
master structure .
void BuildShell(int emode, char **argum)
Definition: DAS_Spat.c:3516
#define SETCCDTEMP
SET the CCD working Temperature.
double Pos
Azimuth Current Position.
int BlindPix
Number of blind pixels (usefull for Dark Current)
Definition: DAS_Spat.c:120
#define HELV_LARGE
Definition: Mguidefs.h:885
int N_AVG
Number of measurements for Averaging mode in fixed number of meas. mode.
Definition: DAS_Spat.c:113
#define HGSCAN
Scan spectral range with HG on.
int darksource
Flag to set Dark source: 0 = Blind Pixels, 1 = Full Frame.
master ExMast[PRGMAXNUM]
Definition: DAS_Spat.c:55
int resetEnabled
DAS/Windows reset option (1 = Enabled; 0 = disabled)
long wav[]
Step Number definition - for SD_Grating.
Definition: DAS_Spat.c:195
#define DASREL
DAS Release Number.
void MShellSetWMCloseCallback(MOBJECT p, WM_CLOSE_CB cb, void *a_data)
C_DEF int DI_FileExist(char *tit)
void MObjectSetSensitive(MOBJECT obj)
int type
type of NOVA monoboard used (7892 or 945GSE)
int resetType
type of period for DAS Reset: 0=Hours, 1=Days
int on
PRG execution control variabile.
Definition: DAS_Spat.c:109
double Pos
Zenith Current Position.
Status of the Azimuth .
stepm STEPM
Stepper Motors.
Definition: DAS_Spat.c:50
adtester ADTESTER
Definition: Chktemp.c:20
MOBJECT MCreateRowForm(MOBJECT parent)
#define WS_ETCHED_IN
Definition: Mguidefs.h:959
int FlagShutter
flag for shutter status. =1–> Shutter Open; =0->shutter Closed
Status of the Filter wheel .
int extshutter
0 = external shutter open; 1 = external shutter closed
System password structure .
void ShutterOpening(int mod)
Definition: Procedures.c:1685
unsigned short WDT_TOUT
WDT timeout.
ISMM_API HANDLE ISMM_Open(void)
#define TOP_ALIGN
Definition: Mguidefs.h:918
Status of the Grating .
void NoWaitSplashCB(MOBJECT p, void *od, void *ad)
Definition: DAS_Spat.c:2251
int AMSPres
AMS Presence: 0 = AMS FOUND; 1 = AMS NOT FOUND.
ISMM_API BOOL DIO_SetOutput(HANDLE hIsmm, WORD wDioData)
int exemode
Set the Execution MODE (Execution modes)
double TPelt
OMU Target Temperature.
int DAS_StartHour
Definition: DAS_Spat.c:106
void DB_2DPlot(char *title, int x, int y, int dx, int dy, int mode)
2D_Plot panel callback.
FilterWheelSt FWS
Filter Wheel.
Definition: DAS_Spat.c:57
AzimuthSt AST
Definition: DAS_Spat.c:71
void WriteShellTitle(MOBJECT o, int eqt)
Definition: DAS_Spat.c:2176
#define AMS3
AMS3 address.
OMU Thermoregulation structure .
#define ESHUTOP
External Shutter OPEN.
void LoadSetDirs(void)
Definition: DAS_Spat.c:3384
float * pTempMat
Definition: bildef.h:100
MOBJECT lbltelap
label elapsed time (for WDT)
#define TESTAMS
execution for testing AMS&#39;s devices
void RunLogMode(int mod, char *p)
Definition: DAS_Spat.c:3478
int FlagSpikes
int SZACalc(double d_lat, double d_long, double d_tzone, int d_year, int d_daynum, int d_hour, int d_minute, int d_second, float d_temp, float d_press, float d_tilt, float d_aspect)
Calc. Solar angles and radiatives quantities. .
Definition: CalcSZA.c:89
#define WS_SHADOW_OUT
Definition: Mguidefs.h:957
#define MANUAL
execution in manual mode (for lab use)
ISMM_API BOOL DIO_GetOutput(HANDLE hIsmm, PWORD pwDioData)
#define MIRROR
set mirror position (0-3)
#define NDFILTER
SET the ND FilterWheel Position.
MOBJECT sh
Definition: bildef.h:108
int LookforWl_X(int x)
Definition: Procedures.c:2295
int power[AMSMAX][2]
Stepper Motors Power.
void Master_Error(int w)
Definition: Errors.c:98
float PID_kd
#define AVGCCD
Averaged measurement.
marconi Marconi
CCD Sensor struct.
void Task_CCD_Temp(TIMEOUT_ID id, void *data)
CCD Temperature Task. Provide the thermoregulation of the CCD sensor during DAS execution.
Definition: Chktemp.c:1068
const char * Mir_CodeTropo[]
const char array for the realisation of the Mirrors buttons in the Mirror shell for TROPOGAS ...
Definition: DAS_Spat.c:234
paramini Paramini
structure for the parameters defined in param.ini configuration file
#define FBIF
Definition: bildef.h:229
#define REM
text after this is a comment
______________________________________________________________________________________
Generated on Mon Sep 18 2017 11:44:07 for DAS - Rel. 3.1.6 - 18/09/2017.