DAS  3.1.6 - 18/09/2017
Exec.c
Go to the documentation of this file.
1 #include <windows.h>
2 #include <stdio.h>
3 #include <io.h>
4 #include <fcntl.h>
5 #include <sys/types.h>
6 #include <sys/stat.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <time.h>
10 #include <sys/timeb.h>
11 #include <string.h>
12 #include "mgui.h"
13 #include "DAS_Spatram.h"
14 #include "dcl.h"
15 #include "dil.h"
16 #include "dxl.h"
17 #include "wsc.h"
18 #include "bil.h"
19 
27 DXL_par DXL; //Com structure
28 flag FLAG; //flags structure
31 paramini PARAM; //Param.ini
32 
33 
34 int Total = 0; // Contatore Files
35 
36 
37 
38 double FlagTExp = 1.0; //Flag per il tempo d'integrazione
39 //unsigned Low = 0;
40 //unsigned High = 0;
41 char OldDate[8]; //Data d'inizio misura
42 char NewDate[8]; //Data di fine misura
43 
44 
45 extern int ExeREM;
46 
47 void E_REM(void)
48 {
49  // Flush stringa
50  if(ExeREM)
51  while(Program[PrgCnt++] != 10);
52 }
53 
54 void E_ExtLampON(void)
55 {
56  ExeREM = 0;
57 
58  if(FLAG.extlamp == 0)
59  ExtLamp(0);
60 
61  ExeREM = 1;
62  E_REM();
63 
64 }
65 
66 void E_ExtLampOFF(void)
67 {
68  ExeREM = 0;
69 
70  if(FLAG.extlamp)
71  ExtLamp(0);
72 
73  ExeREM = 1;
74  E_REM();
75 
76 }
77 
78 
79 void E_ExtShutOpen(void)
80 {
81  ExeREM = 0;
82 
83  if(FLAG.extshutter == 1)
84  ExtShutt(0);
85 
86  ExeREM = 1;
87  E_REM();
88 }
89 
90 
91 void E_ExtShutClose(void)
92 {
93  ExeREM = 0;
94 
95  if(FLAG.extshutter == 0)
96  ExtShutt(0);
97 
98  ExeREM = 1;
99  E_REM();
100 }
101 
102 /*
103 
104 
105 /*******************************************************************************************/
106 //Le funzioni di Home dei motori durante una tabella di misura non funzionano bene:
107 //il motore si sta ancora muovendo che il ciclo ricomincia,
108 //probabilmente perche' ExeREM diventa 1 subito e non aspetta che finisca l'home
109 // SOLUZIONE: Aggiungere un parametro nella chiamata alla funzione HomeMirrorFast che faccia
110 //capire che si e' dentro una tabella e che commuti ExeREM a 1 solo a posizionamento terminato.
111 int E_Home_SM1(void)
112 {
113  ExeREM = 0;
114 
115  Status("Home for Mirror..");
116 // AMS_MotorOn_Off(AMS1,1,0);
117  //MClearTimeout(&IDS.GRATHOME);
119  //MClearTimeout(&IDS.REFRTEMP);
120  HomeMirror();
121 // AMS_MotorOn_Off(AMS1,0,0);
122  //Home Grating Task
123 
125  // PeltierTemp Task
126  if((FLAG.ADPC104 == 0) | (FLAG.ADTempTest == 1))
127  {
128  //MRefreshTimeout(&IDS.LISTEMP, LISTEMP_TASK_TIME, Task_LIS_Temp, NULL);
129  }
130 
131  ExeREM = 1;
132  E_REM();
133 
134  return 0;
135 
136 
137 }
138 
139 int E_Home_SM2(void)
140 {
141  ExeREM = 0;
142  Status("Home for Grating...");
143 // AMS_MotorOn_Off(AMS1,0,1);
144  HomeGratingFast(0);
145 // AMS_MotorOn_Off(AMS1,0,0);
146 
147  ExeREM = 1;
148  E_REM();
149 
150  return 0;
151 }
152 
153 
154 int E_Home_SM3(void)
155 {
156  ExeREM = 0;
157  Status("Home for Filter Wheel...");
158  AMS_MotorOn_Off(AMS2,1,1);
159  HomeFiltersFast();
160 // AMS_MotorOn_Off(AMS2,0,0);
161 
162  ExeREM = 1;
163  E_REM();
164 
165  return 0;
166 }
167 
168 int E_Home_SM5(void)
169 {
170  ExeREM = 0;
171  Status("Home for Zenith...");
172 // AMS_MotorOn_Off(AMS3,1,0);
173  HomeZenithFast();
174 // AMS_MotorOn_Off(AMS3,0,0);
175 
176  ExeREM = 1;
177  E_REM();
178 
179  return 0;
180 }
181 
182 int E_Home_SM6(void)
183 {
184  int er =0;
185 
186  ExeREM = 0;
187  Status("Home for Azimuth...");
188 
190  AMS_Default(AMS3);
191  er = DB_InitAMS(AMS3, 6, DAS.StepM.power[AMS3][DAS.StepM.SM_A],
192  DAS.StepM.step[AMS3][DAS.StepM.SM_A], DAS.StepM.slope[AMS3][DAS.StepM.SM_A],
193  DAS.StepM.speed[AMS3][DAS.StepM.SM_A], DAS.StepM.power[AMS3][DAS.StepM.SM_B],
194  DAS.StepM.step[AMS3][DAS.StepM.SM_B], DAS.StepM.slope[AMS3][DAS.StepM.SM_B],
195  DAS.StepM.speed[AMS3][DAS.StepM.SM_B]);
196  //Attiva i pulsanti sulla keyboard
198 
199 
200 // HomeAzimFast();
201 
202  ExeREM = 1;
203  E_REM();
204 
205  return 0;
206 }
207 
208 
209 int E_Home_SM4(void)
210 {
211  int er =0;
212 
213  ExeREM = 0;
214  Status("Home for NDFilter Wheel...");
215 
217  AMS_Default(AMS2);
218  er = DB_InitAMS(AMS2, 7, DAS.StepM.power[AMS2][DAS.StepM.SM_A],
219  DAS.StepM.step[AMS2][DAS.StepM.SM_A], DAS.StepM.slope[AMS2][DAS.StepM.SM_A],
220  DAS.StepM.speed[AMS2][DAS.StepM.SM_A], DAS.StepM.power[AMS2][DAS.StepM.SM_B],
221  DAS.StepM.step[AMS2][DAS.StepM.SM_B], DAS.StepM.slope[AMS2][DAS.StepM.SM_B],
222  DAS.StepM.speed[AMS2][DAS.StepM.SM_B]);
223  //Attiva i pulsanti sulla keyboard
225 
226 
227 // HomeAzimFast();
228 
229  ExeREM = 1;
230  E_REM();
231 
232  return 0;
233 }
234 
235 
236 /*******************************************************************************************/
237 void E_Plot(void)
238 {
239  ExeREM = 0;
240  ViewPlot(1);
241  ExeREM = 1;
242  E_REM();
243 // delay(3000);
244 }
245 
246 void E_Hg_On(void)
247 {
248  ExeREM = 0;
249  HgLamp(1);
250  ExeREM = 1;
251  E_REM();
252 
253 }
254 
255 void E_Hg_Off(void)
256 {
257  ExeREM = 0;
258  HgLamp(0);
259  ExeREM = 1;
260  E_REM();
261 }
262 
263 void E_Qj_On(void)
264 {
265  ExeREM = 0;
266  QjLamp(1);
267  ExeREM = 1;
268  E_REM();
269 
270 }
271 void E_Qj_Off(void)
272 {
273  ExeREM = 0;
274  QjLamp(0);
275  ExeREM = 1;
276  E_REM();
277 
278 }
279 void E_Dark(void)
280 {
281 
282  struct tm today;
283  ExeREM = 0;
284 
285  DC_GetCCD(0, TExp, DIL.Img.Mat[Server].Imat, 0);
286  if (DAS.DOption.pixcorr)
288 
292 
293  DI_Regen(Server);
294 
296  // gettime( &DIL.Img.Mat[Server].TIME );
297  // getdate( &DIL.Img.Mat[Server].DATE );
298 
299  ExeREM = 1;
300  E_REM();
301 
302 }
303 
304 
305 void quick(unsigned *elemento, int conta)
306 {
307 // int qs(unsigned *elemento, int sinistra, int destra);
308 
309 // qs(elemento, 0, conta - 1);
310 
311 }
312 
313 //void BSort(unsigned *v, long n)
314 //{
315 /*
316  long gap, i, j, temp;
317  n--;
318  for(gap = n / 2; gap > 0; gap /= 2)
319  for(i = gap; i <= n; i++)
320  for(j = i - gap; j >= 0 && v[j] > v[j + gap]; j -= gap)
321  {
322  temp = v[j];
323  v[j] = v[j + gap];
324  v[j + gap] = temp;
325  }
326 */
327 //}
328 //int FlagCalibra = 0;
329 
330 void E_Calibra(void)
331 {
332  ExeREM = 0;
333  D_Calibra();
334  ExeREM = 1;
335  E_REM();
336 
337 }
338 
339 int FlagBarra = 0;
340 
341 
342 void E_AutoRange(void)
343 {
344 
345  ExeREM = 0;
346  Status("Autoranging...");
347  AutoRange(0);
348  ExeREM = 1;
349  E_REM();
350 
351 }
352 
353 
354 
355 void E_Save(void)
356 {
357 
358  ExeREM = 0;
359  D_Saving();
360  ExeREM = 1;
361  E_REM();
362 
363 }
364 
365 void E_Expo(void)
366 {
367  double l;
368 // PrgCnt += 4;
369  sscanf(&Program[PrgCnt], "%lf", &l);
370  Status("Exposure Time");
371 // TExp = l;
372  E_REM();
373 }
374 
375 void E_SetCCDTemp(void)
376 {
377 
378  double l;
379  int er=0;
380  char str[80];
381  sscanf(&Program[PrgCnt], "%lf", &l);
382  Status("CCD Temperature");
383  DAS.Paramini.ITemp = l;
384  OMUTHR.ReachTemp = 0;
385  sprintf(str, "%.1lf", DAS.Paramini.ITemp);
386  MObjectSetText(DAS.Gui.ContrPanel.lbl_Par[0], str);
387 
388  er = DB_InitCamera(1);
389  E_REM();
390 
391 
392 }
393 
394 void E_SetCCDOffSet(void)
395 {
396 
397  int os;
398  int er=0;
399 // char str[80];
400  sscanf(&Program[PrgCnt], "%d", &os);
401  Status("CCD OffSet");
402  DAS.Marconi.Offset = os;
403  DC_SetUsrGain(0, 0 , DAS.Marconi.Offset , 0);
404 
405  E_REM();
406 
407 
408 }
409 
410 
411 void E_SetCCDPow(void)
412 {
413 
414  int l;
415  int er=0;
416  char str[80];
417  sscanf(&Program[PrgCnt], "%d", &l);
418  Status("CCD Temperature");
419  DAS.Paramini.CoolPw = l;
420  OMUTHR.ReachTemp = 0;
421  sprintf(str,"%.1lf%%",(double)DAS.Paramini.CoolPw / 10);
422  MObjectSetText(DAS.Gui.ContrPanel.lbl_Par[1], str);
423  E_REM();
424 
425 
426 }
427 
428 
429 void E_NDFilter(void)
430 {
431 
432  int l;
433  int er=0;
434 // char str[80];
435  sscanf(&Program[PrgCnt], "%d", &l);
436  ExeREM = 0;
437  SD_NDFilterW(l);
438  ExeREM = 1;
439  E_REM();
440 
441 
442 
443 }
444 
445 
446 void E_SetCCDVBin(void)
447 {
448 
449  int d, er = 0;
450  sscanf(&Program[PrgCnt], "%d", &d);
451  Status("CCD Vertical Binning");
452  DAS.Paramini.VBin = d;
453  er = DB_InitCamera(1);
454  E_REM();
455 
456 
457 
458 }
459 
460 //mod = 0 single measurement
461 //mod = 1 averaged measurement with autoranging
462 //mod = 2 averaged measurement without autoranging....
463 void PerformMeas(int mod, int ar, double te, int mt, int sv, int pl)
464 {
465 
466 
467 repeat:
468 
469  if(mod == 1)
470  {
471 
472  //Autoranging (ar=1) or fixed texp (ar=0)
473  if(ar == 0)
474  TExp = te;
475  //Light measurements (mt=1) or dark measurement (mt=0)
476  if(mt)
477  D_Average(1); // 1 = perform autoranging, 0 = DO NOT PERFORM autoranging
478 
479  else
480  DB_GetCCD(0);
481  }
482  if(mod == 2)
483  {
484 
485  //Autoranging (ar=1) or fixed texp (ar=0)
486  if(ar == 0)
487  TExp = te;
488  //Light measurements (mt=1) or dark measurement (mt=0)
489  if(mt)
490  D_Average(0);
491  else
492  DB_GetCCD(0);
493  }
494  if(mod == 0) //single measurements
495  {
496  //Autoranging (ar=1) or fixed texp (ar=0)
497  if(ar)
498  AutoRange(0);
499  else
500  {
501  //if te not zero, use te as TExp otherwise
502  //TExp remains the same previously calculated
503  if (te != 0)
504  TExp = te;
505  }
506 
507  //Light measurements (mt=1) or dark measurement (mt=0)
508  if(mt)
509  DB_GetCCD(1);
510 
511 
512  else
513  DB_GetCCD(0);
514  }
515 
516  //Check the image maximum value
517 // if (DIL.Img.Mat[Server].IHigh >= 65000) //CCD Saturated
518 // goto repeat;
519 
520  //save measurement
521  if(sv)
522  {
523  D_Saving();
524  }
525  //plot spectrum
526  if(pl)
527  if(DAS.Flag.plotW)
528  D_Plot();
529 
530 
531  Status("Ready");
532 
533 }
534 
535 
536 
537 
538 void E_AvgCCDHor(void)
539 {
540 
541  int er=0;
542  int l, f, m, a, d, s, g, wl;
543  double t;
544  extern struct date dok;
545 
546  int StsTot = 0;
547  int StsMir = 0, StsGrat = 0, StsFW = 0;
548 
549  // The progression of "PrgCnt" is now in the Fetch function
550  // PrgCnt += 7;
551 
552  sscanf(&Program[PrgCnt], "%d%d%d%d%lf%d%d%d", &m, &wl, &f, &a, &t, &d, &s, &g);
553 
554  l= LookforWl_X(wl);
555 
556 
557  if (DAS.DOption.smposmode)
558  SD_PosOMUDev(m, l, f);
559  //SD_Position(m, l, f, 0, 0);
560  else
561  {
562  //mirror positioning
563  SD_Mirror(m);
564  //grating positioning
565  SD_Grating(l);
566  //filter wheel positioning
567  SD_FilterW(f);
568  //Zenith positioning
569 // SD_Zenith(z);
570  //Azimuth positioning
571 // SD_Azimuth(az);
572  }
573  ExeREM = 0;
574  /******************************************************************/
575 
576  //*********************** Start First Measurement ******************
577 
578  PerformMeas(1, a, t, d, s, g); //Measuremet with TExp computed by Autoranging with external lamp
579 
580  //*********************** End First Measurement ******************
581 
582  //*********************** Start Second Measurement ******************
583  //Close External Shutter
584  if (FLAG.extshutter == 0)
585  {
586  ExtShutt(0);
587  FLAG.extshutter = 1;
588 
589  }
590 
591  PerformMeas(2, a, t, d, s, g); //Measuremet with previous TExp (computed by Autoranging with external lamp)
592  //*********************** End Second Measurement ******************
593 
594  //*********************** Start Third Measurement ******************
595  PerformMeas(0, a, t, d, s, g); //Measurement with TExp computed by Autoranging without external lamp
596 
597  //Open External Shutter
598  if (FLAG.extshutter)
599  {
600  ExtShutt(0);
601  FLAG.extshutter = 0;
602  }
603 
604  //*********************** End Third Measurement ******************
605 
606  ExeREM = 1;
607  E_REM();
608 
609 }
610 
611 
612 void E_Average(void)
613 {
614 
615  int er=0;
616  int l, f, m, a, d, s, g, wl;
617  double t;
618 
619 
620  extern struct date dok;
621  int StsTot = 0;
622  int StsMir = 0, StsGrat = 0, StsFW = 0;
623 
624  sscanf(&Program[PrgCnt], "%d%d%d%d%lf%d%d%d", &m, &wl, &f, &a, &t, &d, &s, &g);
625 
626  l= LookforWl_X(wl);
627 
628 
629 
630  //Posiziona specchio
631  SD_Mirror(m);
632  //Posiziona reticolo
633  SD_Grating(l);
634  //Posiziona Ruota dei filtri
635  SD_FilterW(f);
636 
637  ExeREM = 0;
638 
639  PerformMeas(1, a, t, d, s, g); //Measuremet with TExp computed by Autoranging
640 
641 
642  ExeREM = 1;
643  E_REM();
644 
645 }
646 
647 
648 
649 
650 void Radio(int g)
651 {
652 // double tup, tdw;
653 // Mirror(1);
654  E_AutoRange();
655 // tdw = TExp;
656 
657 // Mirror(3);
658  E_AutoRange();
659 // tup = TExp;
660 
661 // if(tdw < tup) TExp = tdw;
662 // else TExp = tup;
663 
664 // Mirror(1);
665  E_GetCCD();
666  E_Save();
667  if(g)
668  {
669 // E_Grafo();
670  }
671 // Mirror(3);
672  E_GetCCD();
673  E_Save();
674  if(g)
675 // { E_Grafo(); }
676 
677 // Mirror(1);
678  E_GetCCD();
679  E_Save();
680 // if(g)
681 // { E_Grafo(); }
682 
683 }
684 void E_Radio(void)
685 {
686  int l, f, p, m, a, d, s, g;
687  double t;
688 // PrgCnt += 7;
689 
690  sscanf(&Program[PrgCnt], "%d%d%d%d%d%lf%d%d%d", &l, &f, &p, &m, &a, &t, &d, &s, &g);
691 
692  E_REM();
693 
694 // Grating(l);
695 // FW(f);
696 // Polarizer(p);
697 
698  ExeREM = 0;
699 // Radio(g);
700  ExeREM = 1;
701 
702 }
703 
704 
705 int E_GetCCD(void)
706 {
707 
708  ExeREM = 0;
709  Status("Getting CCD Image...");
710  DB_GetCCD(1);
711  ExeREM = 1;
712  E_REM();
713  return 0;
714 
715 
716 }
717 
718 void E_Lambda(void)
719 {
720  int wl, l;
721 // The progression of "PrgCnt" is now in the Fetch function
722 // PrgCnt += 7;
723  sscanf(&Program[PrgCnt], "%d", &wl);
724  l= LookforWl_X(wl);
725  ExeREM = 0;
726  SD_Grating(l);
727  ExeREM = 1;
728  E_REM();
729 }
730 
731 void E_WAIT(void)
732 {
733  unsigned l, c;
734 // The progression of "PrgCnt" is now in the Fetch function
735 // PrgCnt += 4;
736  sscanf(&Program[PrgCnt], "%u", &l);
737 
738  for(c = 0; c < l / 100; c++)
739  {
740  Sleep(100);
741  MLoopWhileEvents(0);
742  }
743  E_REM();
744 }
745 void E_Label(void)
746 {
747  char lab[255];
748  int c = 0;
749 // The progression of "PrgCnt" is now in the Fetch function
750 // PrgCnt += 5;
751 // while(Program[PrgCnt++] != 34);
752  PrgCnt =PrgCnt+2;
753  do
754  lab[c++] = Program[PrgCnt];
755  while(Program[PrgCnt++] != 34);
756  E_REM();
757 // lab[c] = 0;
758 // Status(lab);
759 }
760 
761 void E_Filter(void)
762 {
763  int l;
764 // The progression of "PrgCnt" is now in the Fetch function
765 // PrgCnt += 6;
766  sscanf(&Program[PrgCnt], "%d", &l);
767  ExeREM = 0;
768  SD_FilterW(l);
769  ExeREM = 1;
770  E_REM();
771 }
772 
773 void E_Mirror(void)
774 {
775  int l;
776 // The progression of "PrgCnt" is now in the Fetch function
777 // PrgCnt += 6;
778  sscanf(&Program[PrgCnt], "%d", &l);
779  ExeREM = 0;
780  SD_Mirror(l);
781  ExeREM = 1;
782  E_REM();
783 }
784 
785 int DB_StsMotor(int c)
786 {
787  int sts = 0, d, er = 0;
788 
789  switch(c)
790  {
791  case 0:
792  {
793  DXL.add = 0;
794  do
795  {
796  DXL_TxStr("800", 3);
797  d = STS0LEN;
798  er = DXL_RxStr(DXL.bufrx, &d);
799  MLoopWhileEvents(0);
800  }while(DXL.bufrx[0] == '0' && DXL.bufrx[1] == '0' && er == 0);
801  sts = 1;
802  }
803  break;
804 
805  case 1:
806  {
807  DXL.add = 0;
808  do
809  {
810  DXL_TxStr("801", 3);
811  d = STS0LEN;
812  er = DXL_RxStr(DXL.bufrx, &d);
813  MLoopWhileEvents(0);
814 
815  }while(DXL.bufrx[0] == '0' && DXL.bufrx[1] == '0' && er == 0);
816  sts = 1;
817  }
818  break;
819 
820  case 2:
821  {
822  DXL.add = 1;
823  do
824  {
825  DXL_TxStr("800", 3);
826  d = STS0LEN;
827  er = DXL_RxStr(DXL.bufrx, &d);
828  MLoopWhileEvents(0);
829  }while(DXL.bufrx[0] == '0' && DXL.bufrx[1] == '0' && er == 0);
830  sts = 1;
831  DXL.add=0;
832  }
833  break;
834 
835  }
836  return sts;
837 }
838 
839 
840 
841 
842 
843 
844 
845 void E_IRefSun(void)
846 {
847 
848  char str[16];
849  float azi, elev;
850  int er=0;
851  int l, f, m, a, d, s, g, wl;
852  double t;
853 
854  //sun Azimuth angle
855  sprintf(str, "%.01lf", S_azim);
856  azi = (float)atof(str);
857 
858  //Elevation Angle
859  sprintf(str, "%.01lf", (90 - S_zenetr));
860  elev = (float)atof(str);
861 
862 
863  sscanf(&Program[PrgCnt], "%d%d%d%d%lf%d%d%d", &m, &wl, &f, &a, &t, &d, &s, &g);
864 
865  l= LookforWl_X(wl);
866 
867 
868  if (DAS.DOption.smposmode)
869  SD_Position(m, l, f, elev, azi);
870  else
871  {
872  //mirror positioning
873  SD_Mirror(m);
874  //grating positioning
875  SD_Grating(l);
876  //filter wheel positioning
877  SD_FilterW(f);
878  //Zenith positioning
879  SD_Zenith(elev);
880  //Azimuth positioning
881  SD_Azimuth(azi,0);
882  }
883 
884 
885  ExeREM = 0;
886  PerformMeas(0, a, t, d, s, g);
887 
888  ExeREM = 1;
889  E_REM();
890 }
891 
892 
893 void E_AAPos(void)
894 {
895 
896  int er=0;
897 // int l, f, m, d, g;
898  double z, az;
899 // double t;
900 
901 
902  sscanf(&Program[PrgCnt], "%lf%lf", &z, &az);
903 
904 
905  SD_Position(-1, -1, -1, z, az);
906  E_REM();
907 }
908 
909 
910 
911 void E_DFMeasure(void)
912 {
913  int er=0;
914  int l, f, m, a, d, s, g,nf;
915  int wl;
916  double t;
917  extern struct date dok;
918 
919 
920  int StsTot = 0;
921  int StsMir = 0, StsGrat = 0, StsFW = 0;
922 // The progression of "PrgCnt" is now in the Fetch function
923 // PrgCnt += 7;
924 
925 
926  sscanf(&Program[PrgCnt], "%d%d%d%d%d%lf%d%d%d", &m, &wl, &f, &nf, &a, &t, &d, &s, &g);
927 
928  l= LookforWl_X(wl);
929 
930 
931  if (DAS.DOption.smposmode)
932  {
933  SD_PosOMUDev(m, l, f);
934  if(DAS.DOption.filtertype == FDOUBLE)
935  {
936  if((DAS.Paramini.EqType == SPATRAM2) || (DAS.Paramini.EqType == SPATRAMPLUS) || (DAS.Paramini.EqType == SPATRAM3))
937  SD_NDFilterW(nf); //ND1
938  }
939  if(DAS.DOption.filtertype == FPLUS)
940  {
941  //if(DAS.Paramini.EqType == GASCODNG1)
942  //{
943  SD_FNTorqueM(nf);//ND1
944  delay(700);
945  //}
946  }
947  }
948  //SD_Position(m, l, f, 0, 0);
949  else
950  {
951  //mirror positioning
952  SD_Mirror(m);
953  //grating positioning
954  SD_Grating(l);
955  //filter wheel positioning
956  SD_FilterW(f);
957  //Neutral filter wheel positioning
958  SD_NDFilterW(nf);
959  if(DAS.DOption.filtertype == FDOUBLE)
960  {
961  if((DAS.Paramini.EqType == SPATRAM2) || (DAS.Paramini.EqType == SPATRAMPLUS) || (DAS.Paramini.EqType == SPATRAM3))
962  SD_NDFilterW(nf); //ND1
963  }
964  if(DAS.DOption.filtertype == FPLUS)
965  {
966  //if(DAS.Paramini.EqType == GASCODNG1)
967  //{
968  SD_FNTorqueM(nf);//ND1
969  delay(700);
970  //}
971  }
972  //Zenith positioning
973  //SD_Zenith(z);
974  //Azimuth positioning
975  //SD_Azimuth(az);
976  }
977 
978  ExeREM = 0;
979 
980  if(DAS.DOption.measmode == 0) //Single
981  PerformMeas(0, a, t, d, s, g);
982  if(DAS.DOption.measmode == 1) //AVG
983  {
984  if(DAS.DOption.avgautor)
985  PerformMeas(1, a, t, d, s, g);
986  else
987  PerformMeas(2, a, t, d, s, g);
988 
989  }
990 
991  ExeREM = 1;
992  E_REM();
993 
994 
995 }
996 
997 void E_AAMeasure(void)
998 {
999 
1000  int er=0;
1001  int l, f, m, a, d, s, g, wl;
1002  double z, az;
1003  double t;
1004 
1005  sscanf(&Program[PrgCnt], "%d%d%d%lf%lf%d%lf%d%d%d", &m, &wl, &f, &z, &az, &a, &t, &d, &s, &g);
1006 
1007  l= LookforWl_X(wl);
1008 
1009 
1010  if(z == 360)
1011  z = -S_zenetr; //per misure di Io nel piano azimuthale in cui ho fatto misure (da controllarese deve essere positivo negativo o 90-)
1012 
1013 
1014  if (DAS.DOption.smposmode)
1015  SD_Position(m, l, f, z, az);
1016  else
1017  {
1018  //mirror positioning
1019  SD_Mirror(m);
1020  //grating positioning
1021  SD_Grating(l);
1022  //filter wheel positioning
1023  SD_FilterW(f);
1024  //Zenith positioning
1025  SD_Zenith((float)z);
1026  //Azimuth positioning
1027  SD_Azimuth((float)az,0);
1028  }
1029 
1030  if(DAS.DOption.filtertype == FDOUBLE)
1031  {
1032  if((DAS.Paramini.EqType == SPATRAM2) || (DAS.Paramini.EqType == SPATRAMPLUS) || (DAS.Paramini.EqType == SPATRAM3))
1033  SD_NDFilterW(0); //Reset NDFilterWheel position
1034  }
1035 
1036  if(DAS.DOption.filtertype == FPLUS)
1037  {
1038  SD_FNTorqueM(0); //Reset NDFilterWheel position
1039  }
1040 
1041  ExeREM = 0;
1042 
1043 
1044  if(DAS.DOption.measmode == 0) //Single
1045  PerformMeas(0, a, t, d, s, g);
1046  if(DAS.DOption.measmode == 1) //AVG
1047  {
1048  if(DAS.DOption.avgautor)
1049  PerformMeas(1, a, t, d, s, g);
1050  else
1051  PerformMeas(2, a, t, d, s, g);
1052 
1053  }
1054 
1055  ExeREM = 1;
1056  E_REM();
1057 
1058 }
1059 
1060 void E_Measure(void)
1061 {
1062  int er=0;
1063  int l, f, m, a, d, s, g;
1064  int wl;
1065  double t;
1066  extern struct date dok;
1067 
1068 
1069  int StsTot = 0;
1070  int StsMir = 0, StsGrat = 0, StsFW = 0;
1071 // The progression of "PrgCnt" is now in the Fetch function
1072 // PrgCnt += 7;
1073 
1074 
1075  sscanf(&Program[PrgCnt], "%d%d%d%d%lf%d%d%d", &m, &wl, &f, &a, &t, &d, &s, &g);
1076 
1077  l= LookforWl_X(wl);
1078 
1079 
1080  if (DAS.DOption.smposmode)
1081  SD_PosOMUDev(m, l, f);
1082 
1083  //SD_Position(m, l, f, 0, 0);
1084  else
1085  {
1086  //mirror positioning
1087  SD_Mirror(m);
1088  //grating positioning
1089  SD_Grating(l);
1090  //filter wheel positioning
1091  SD_FilterW(f);
1092  //Zenith positioning
1093  //SD_Zenith(z);
1094  //Azimuth positioning
1095  //SD_Azimuth(az);
1096  }
1097 
1098  ExeREM = 0;
1099 
1100  if(DAS.DOption.measmode == 0) //Single
1101  PerformMeas(0, a, t, d, s, g);
1102  if(DAS.DOption.measmode == 1) //AVG
1103  {
1104  if(DAS.DOption.avgautor)
1105  PerformMeas(1, a, t, d, s, g);
1106  else
1107  PerformMeas(2, a, t, d, s, g);
1108 
1109  }
1110 
1111  ExeREM = 1;
1112  E_REM();
1113 
1114 
1115 }
1116 
1117 int ExtLamp(int mod)
1118 {
1119 
1120  unsigned long t = 1000;
1121 
1122  DAS.StepM.OOP[AMS1] |= 0x80; //bit 7, 10000000, dec = 128
1123 
1124 
1125  // 1's complement
1126  DAS.StepM.OOP[AMS1] = ~DAS.StepM.OOP[AMS1];
1127  //write on the optoinsulated port
1128  AMS_wopto(AMS1, DAS.StepM.OOP[AMS1]);
1129  // again 1's complement for restoring the positive logic
1130  DAS.StepM.OOP[AMS1] = ~DAS.StepM.OOP[AMS1];
1131 
1132  delay(t);
1133 
1134  DAS.StepM.OOP[AMS1] &= 0x7F; // 01111111, dec = 127
1135 
1136  // 1's complement
1137  DAS.StepM.OOP[AMS1] = ~DAS.StepM.OOP[AMS1];
1138  //write on the optoinsulated port
1139  AMS_wopto(AMS1, DAS.StepM.OOP[AMS1]);
1140  // again 1's complement for restoring the positive logic
1141  DAS.StepM.OOP[AMS1] = ~DAS.StepM.OOP[AMS1];
1142 
1143 
1144 
1145  delay(t);
1146 
1147 
1148  return 0;
1149 
1150 }
1151 
1152 
1153 
1154 
1155 int ExtShutt(int mod)
1156 {
1157 
1158  unsigned long t = 500;
1159  char buf[256];
1160  int er = 0;
1161 
1162  if(DAS.Paramini.EqType == TROPOGAS )
1163  {
1164  DAS.StepM.OOP[AMS2] |= 0x40; //bit 6, 01000000, dec = 64
1165 
1166  // 1's complement
1167  DAS.StepM.OOP[AMS2] = ~DAS.StepM.OOP[AMS2];
1168  //write on the optoinsulated port
1169  AMS_wopto(AMS2, DAS.StepM.OOP[AMS2]);
1170  // again 1's complement for restoring the positive logic
1171  DAS.StepM.OOP[AMS2] = ~DAS.StepM.OOP[AMS2];
1172 
1173  delay(t);
1174 
1175  DAS.StepM.OOP[AMS2] &= 0xBF; // 10111111, dec = 191
1176 
1177  // 1's complement
1178  DAS.StepM.OOP[AMS2] = ~DAS.StepM.OOP[AMS2];
1179  //write on the optoinsulated port
1180  AMS_wopto(AMS2, DAS.StepM.OOP[AMS2]);
1181  // again 1's complement for restoring the positive logic
1182  DAS.StepM.OOP[AMS2] = ~DAS.StepM.OOP[AMS2];
1183 
1184  //delay(t);
1185 
1186  }
1187  else if(DAS.Paramini.EqType == SPATRAM2)
1188  {
1189  DAS.StepM.OOP[AMS1] |= 0x40; //bit 6, 01000000, dec = 64
1190 
1191 
1192  // 1's complement
1193  DAS.StepM.OOP[AMS1] = ~DAS.StepM.OOP[AMS1];
1194  //write on the optoinsulated port
1195  AMS_wopto(AMS1, DAS.StepM.OOP[AMS1]);
1196  // again 1's complement for restoring the positive logic
1197  DAS.StepM.OOP[AMS1] = ~DAS.StepM.OOP[AMS1];
1198 
1199  delay(t);
1200 
1201  DAS.StepM.OOP[AMS1] &= 0xBF; // 10111111, dec = 191
1202 
1203 
1204  // 1's complement
1205  DAS.StepM.OOP[AMS1] = ~DAS.StepM.OOP[AMS1];
1206  //write on the optoinsulated port
1207  AMS_wopto(AMS1, DAS.StepM.OOP[AMS1]);
1208  // again 1's complement for restoring the positive logic
1209  DAS.StepM.OOP[AMS1] = ~DAS.StepM.OOP[AMS1];
1210 
1211  //delay(t);
1212  }
1213  else
1214  {
1215  sprintf(buf, "For this Equipment the AMS is UNKNOWN\nPlease Contact DANBO!!!!");
1216  er = MMessageDialog("DAS information", buf, "Ok", NULL);
1217  if (!er)
1218  return 1;
1219 
1220  }
1221  return 0;
1222 
1223 }
1224 
1225 void E_ChkExLamp(void)
1226 {
1227 
1228  int flagstatus = 1;
1229  int cont = 0;
1230  double Texp_temp = 0;
1231  double T1 = 0, T2 = 0;
1232  extern struct date dok;
1233 
1234  // Check if the shutter is open or closed
1235  // It has to be open (so the Exposure time has to be short...)
1236  ExeREM = 0;
1237  do
1238  {
1239  //the shutter is thinked to be open
1240  //first measurement with the shutter open
1241  AutoRange(0);
1242  T1 = TExp;
1243 
1244  //Close External Shutter
1245 
1246  ExtShutt(0);
1247 
1248  AutoRange(0);
1249  T2 = TExp;
1250  if( T1/T2 < 1) // the shutter was open at the first measurement and Now it has to be open again
1251  { //Open External Shutter
1252  ExtShutt(0);
1253  FLAG.extshutter = 0;
1254  flagstatus = 0;
1255  }
1256  else
1257  {
1258  //the shutter was closed at the first measurement so now is already open
1259  FLAG.extshutter = 0;
1260  flagstatus = 0;
1261  }
1262 // AutoRange(0);
1263 // if( (TExp <= T1 + 1) & (TExp >= T1 - 1))
1264 // flagstatus = 0;
1265 
1266  cont++;
1267 
1268  }while((flagstatus) | (cont == 5));
1269 
1270  ExeREM = 1;
1271  E_REM();
1272 
1273 }
1274 
1275 
1276 
1277 
1278 
1279 
1280 void E_Meashor(void)
1281 {
1282  int er=0;
1283  int l, f, m, a, d, s, g, wl;
1284  double t;
1285  extern struct date dok;
1286 
1287  int StsTot = 0;
1288  int StsMir = 0, StsGrat = 0, StsFW = 0;
1289 
1290  // The progression of "PrgCnt" is now in the Fetch function
1291  // PrgCnt += 7;
1292 
1293  sscanf(&Program[PrgCnt], "%d%d%d%d%lf%d%d%d", &m, &wl, &f, &a, &t, &d, &s, &g);
1294 
1295  l= LookforWl_X(wl);
1296 
1297 
1298  if (DAS.DOption.smposmode)
1299  SD_PosOMUDev(m, l, f);
1300  //SD_Position(m, l, f, 0, 0);
1301  else
1302  {
1303  //mirror positioning
1304  SD_Mirror(m);
1305  //grating positioning
1306  SD_Grating(l);
1307  //filter wheel positioning
1308  SD_FilterW(f);
1309  //Zenith positioning
1310  //SD_Zenith(z);
1311  //Azimuth positioning
1312  //SD_Azimuth(az);
1313  }
1314  ExeREM = 0;
1315  /******************************************************************/
1316  /******************************************************************/
1317 
1318  //*********************** Start First Measurement ******************
1319  PerformMeas(0, a, t, d, s, g);
1320  //*********************** End First Measurement ******************
1321 
1322  //*********************** Start Second Measurement ******************
1323  //Close External Shutter
1324  if (FLAG.extshutter == 0)
1325  {
1326  ExtShutt(0);
1327  FLAG.extshutter = 1;
1328 
1329  }
1330 
1331  //Measure (d=1) or dark (d=0) -
1332  if(d)
1333  {
1334  DB_GetCCD(1);
1335  }
1336  else
1337  {
1338  DB_GetCCD(0);
1339  }
1340 
1341  //
1342  if(s)
1343  {
1344  D_Saving();
1345  }
1346  if(g)
1347  {
1348  if(DAS.Flag.plotW)
1349  D_Plot();
1350  }
1351  //*********************** End Second Measurement ******************
1352 
1353  //*********************** Start Third Measurement ******************
1354  PerformMeas(0, a, t, d, s, g);
1355 
1356 
1357  //Open External Shutter
1358  if (FLAG.extshutter)
1359  {
1360  ExtShutt(0);
1361  FLAG.extshutter = 0;
1362  }
1363  //*********************** End Third Measurement ******************
1364  ExeREM = 1;
1365  E_REM();
1366 
1367 }
1368 
1369 
1370 void E_Meashor2(void)
1371 {
1372  int er=0;
1373  int l, f, m, a, d, s, g;
1374  double t;
1375  extern struct date dok;
1376  int wl;
1377 
1378  int StsTot = 0;
1379  int StsMir = 0, StsGrat = 0, StsFW = 0;
1380 
1381  // The progression of "PrgCnt" is now in the Fetch function
1382  // PrgCnt += 7;
1383 
1384  sscanf(&Program[PrgCnt], "%d%d%d%d%lf%d%d%d", &m, &wl, &f, &a, &t, &d, &s, &g);
1385 
1386  l= LookforWl_X(wl);
1387 
1388 
1389  if (DAS.DOption.smposmode)
1390  SD_PosOMUDev(m, l, f);
1391  //SD_Position(m, l, f, 0, 0);
1392  else
1393  {
1394  //mirror positioning
1395  SD_Mirror(m);
1396  //grating positioning
1397  SD_Grating(l);
1398  //filter wheel positioning
1399  SD_FilterW(f);
1400  //Zenith positioning
1401  //SD_Zenith(z);
1402  //Azimuth positioning
1403  //SD_Azimuth(az);
1404  }
1405  ExeREM = 0;
1406  /******************************************************************/
1407  /******************************************************************/
1408 
1409  //*********************** Start First Measurement ******************
1410  PerformMeas(0, a, t, d, s, g);
1411  //*********************** End First Measurement ******************
1412 
1413  //*********************** Start Second Measurement ******************
1414  //Close External Shutter
1415  if (FLAG.extshutter == 0)
1416  {
1417  ExtShutt(0);
1418  FLAG.extshutter = 1;
1419 
1420  }
1421 
1422  //Measure (d=1) or dark (d=0) -
1423  if(d)
1424  {
1425  DB_GetCCD(1);
1426  }
1427  else
1428  {
1429  DB_GetCCD(0);
1430  }
1431 
1432  //
1433  if(s)
1434  {
1435  D_Saving();
1436  }
1437  if(g)
1438  {
1439  if(DAS.Flag.plotW)
1440  D_Plot();
1441  }
1442  //*********************** End Second Measurement ******************
1443 
1444  //*********************** Start Third Measurement ******************
1445 // PerformMeas(0, a, t, d, s, g);
1446 
1447 
1448  //Open External Shutter
1449  if (FLAG.extshutter)
1450  {
1451  ExtShutt(0);
1452  FLAG.extshutter = 0;
1453  }
1454  //*********************** End Third Measurement ******************
1455  ExeREM = 1;
1456  E_REM();
1457 
1458 }
1459 
1460 
1461 void E_Zenith(void)
1462 {
1463  double l;
1464  sscanf(&Program[PrgCnt], "%lf", &l);
1465  ExeREM = 0;
1466  l = (float) l;
1467  SD_Zenith((float)l);
1468 
1469  ExeREM = 1;
1470  E_REM();
1471 }
1472 
1473 void E_Azimuth(void)
1474 {
1475  double l;
1476  sscanf(&Program[PrgCnt], "%lf", &l);
1477  ExeREM = 0;
1478 
1479  l = (float) l;
1480 
1481  SD_Azimuth((float)l,0);
1482 
1483  ExeREM = 1;
1484  E_REM();
1485 }
1486 
1487 
1488 void E_HGratCal(void)
1489 {
1490  ExeREM = 0;
1491  Status("Home for Grating...");
1492 // AMS_MotorOn_Off(AMS1,0,1);
1493  HomeGratingFast(0);
1494 // AMS_MotorOn_Off(AMS1,0,0);
1495 
1496  D_Calibra();
1497 
1498  ExeREM = 1;
1499 // E_REM();
1500 
1501 
1502 }
1503 
1504 void E_HgScan(void)
1505 {
1506 
1507  int l;
1508 
1509  //Switch On QJ Lamp
1510  E_Hg_On();
1511  ExeREM = 0;
1512  //Position Mirror
1513  SD_Mirror(2);
1514 
1515  for (l=1; l<10; l++)
1516  {
1517  //position grating
1518  SD_Grating(l);
1519  // Position Filterwheel
1520  SD_FilterW(0);
1521  if(DAS.DOption.filtertype == FDOUBLE)
1522  SD_NDFilterW(0);
1523  else if(DAS.DOption.filtertype == FPLUS)
1524  SD_FNTorqueM(0);
1525  //autorange
1526  Status("Autoranging...");
1527  AutoRange(0);
1528  Status("Getting CCD Image...");
1529  DB_GetCCD(1);
1530  //Save the Spectrum
1531  SaveCalib(1);
1532 
1533  if(DAS.Flag.plotW)
1534  D_Plot();
1535 
1536 
1537 
1538 
1539  }
1540  E_Hg_Off();
1541 
1542  ExeREM = 1;
1543  //E_REM();
1544 
1545 
1546 }
1547 
1548 void E_QjScan(void)
1549 {
1550  //perform a full scan set of measurement with the QJ lamp
1551 
1552  int l;
1553 
1554  //Switch On QJ Lamp
1555  E_Qj_On();
1556  ExeREM = 0;
1557  //Position Mirror
1558  SD_Mirror(2);
1559 
1560  for (l=1; l<10; l++)
1561  {
1562  //position grating
1563  SD_Grating(l);
1564  // Position Filterwheel
1565  SD_FilterW(0);
1566  if(DAS.DOption.filtertype == FDOUBLE)
1567  SD_NDFilterW(0);
1568  else if(DAS.DOption.filtertype == FPLUS)
1569  SD_FNTorqueM(0);
1570  //autorange
1571  Status("Autoranging...");
1572  AutoRange(0);
1573  Status("Getting CCD Image...");
1574  DB_GetCCD(1);
1575  //Save the Spectrum
1576  SaveCalib(1);
1577 
1578  if(DAS.Flag.plotW)
1579  D_Plot();
1580 
1581 
1582 
1583 
1584  }
1585  E_Qj_Off();
1586 
1587 
1588  SaveCnt++;
1589 
1590  ExeREM = 1;
1591  //E_REM();
1592 
1593 }
1594 
1595 
1596 void E_DirectSun(void)
1597 {
1598 
1599  char str[16];
1600  float azi, elev;
1601  int er=0;
1602  int l, f, m, a, d, s, g, wl, nf;
1603  double t;
1604 
1605  //sun Azimuth angle
1606  sprintf(str, "%.01lf", S_azim);
1607  azi = atof(str);
1608 
1609  //Elevation Angle
1610  sprintf(str, "%.01lf", (90 - S_zenetr));
1611  elev = atof(str);
1612 
1613 
1614 
1615  sscanf(&Program[PrgCnt], "%d%d%d%d%d%lf%d%d%d", &m, &wl, &f, &nf, &a, &t, &d, &s, &g);
1616 
1617  l= LookforWl_X(wl);
1618 
1619 
1620  if (DAS.DOption.smposmode)
1621  {
1622  //SD_PosOMUDev(m, l, f);
1623  SD_Position(m, l, f, elev, azi);
1624  if(DAS.DOption.filtertype == FDOUBLE)
1625  {
1626  if(DAS.Paramini.EqType == SPATRAM2 || DAS.Paramini.EqType == SPATRAMPLUS || DAS.Paramini.EqType == SPATRAM3)
1627  SD_NDFilterW(nf); //ND1
1628  }
1629  if(DAS.DOption.filtertype == FPLUS)
1630  {
1631  // if(DAS.Paramini.EqType == GASCODNG1)
1632  // {
1633  SD_FNTorqueM(nf);//ND1
1634  delay(700);
1635  // }
1636  }
1637 
1638  }
1639  //SD_Position(m, l, f, 0, 0);
1640  else
1641  {
1642  //mirror positioning
1643  SD_Mirror(m);
1644  //grating positioning
1645  SD_Grating(l);
1646  //filter wheel positioning
1647  SD_FilterW(f);
1648  //Neutral filter wheel positioning
1649  SD_NDFilterW(nf);
1650  if(DAS.DOption.filtertype == FDOUBLE)
1651  {
1652  if(DAS.Paramini.EqType == SPATRAM2 || DAS.Paramini.EqType == SPATRAMPLUS ||DAS.Paramini.EqType == SPATRAM3)
1653  SD_NDFilterW(nf); //ND1
1654  }
1655  if(DAS.DOption.filtertype == FPLUS)
1656  {
1657 // if(DAS.Paramini.EqType == GASCODNG1)
1658 // {
1659  SD_FNTorqueM(nf);//ND1
1660  delay(700);
1661 // }
1662  }
1663  //Zenith positioning
1664  //SD_Zenith(z);
1665  //Azimuth positioning
1666  //SD_Azimuth(az);
1667  }
1668 
1669 
1670  ExeREM = 0;
1671  PerformMeas(0, a, t, d, s, g);
1672 
1673  ExeREM = 1;
1674  E_REM();
1675 
1676 
1677 
1678 }
1679 
1680 void E_Almucantar(void)
1681 {
1682 
1683  char str[16];
1684  float azi, elev;
1685  int er=0;
1686  int l, f, m, a, d, s, g, wl, nf,k;
1687  double t;
1688 
1689  //sun Azimuth angle
1690  sprintf(str, "%.01lf", S_azim);
1691  azi = atof(str);
1692 
1693  //Elevation Angle
1694  sprintf(str, "%.01lf", (90 - S_zenetr));
1695  elev = atof(str);
1696 
1697 
1698 
1699  sscanf(&Program[PrgCnt], "%d%d%d%d%d%lf%d%d%d", &m, &wl, &f, &nf, &a, &t, &d, &s, &g);
1700 
1701  l= LookforWl_X(wl);
1702 
1703 for(k=0; k<=360; k+=10)
1704 {
1705 
1706 if (DAS.DOption.smposmode)
1707  {
1708  //SD_PosOMUDev(m, l, f);
1709  SD_Position(m, l, f, elev, k);
1710 
1711 
1712  if(DAS.DOption.filtertype == FDOUBLE)
1713  {
1714  if(DAS.Paramini.EqType == SPATRAM2 || DAS.Paramini.EqType == SPATRAMPLUS || DAS.Paramini.EqType == SPATRAM3)
1715  SD_NDFilterW(nf); //ND1
1716  }
1717  if(DAS.DOption.filtertype == FPLUS)
1718  {
1719 // if(DAS.Paramini.EqType == GASCODNG1)
1720 // {
1721  SD_FNTorqueM(nf);//ND1
1722  delay(700);
1723 // }
1724  }
1725 
1726  }
1727  //SD_Position(m, l, f, 0, 0);
1728  else
1729  {
1730  //mirror positioning
1731  SD_Mirror(m);
1732  //grating positioning
1733  SD_Grating(l);
1734  //filter wheel positioning
1735  SD_FilterW(f);
1736  //Neutral filter wheel positioning
1737  SD_NDFilterW(nf);
1738  if(DAS.DOption.filtertype == FDOUBLE)
1739  {
1740  if(DAS.Paramini.EqType == SPATRAM2 ||
1741  DAS.Paramini.EqType == SPATRAMPLUS ||
1742  DAS.Paramini.EqType == SPATRAM3)
1743  SD_NDFilterW(nf); //ND1
1744  }
1745  if(DAS.DOption.filtertype == FPLUS)
1746  {
1747 // if(DAS.Paramini.EqType == GASCODNG1)
1748 // {
1749  SD_FNTorqueM(nf);//ND1
1750  delay(700);
1751 // }
1752  }
1753  //Zenith positioning
1754  //SD_Zenith(z);
1755  //Azimuth positioning
1756  //SD_Azimuth(az);
1757  }
1758 
1759 
1760  ExeREM = 0;
1761  PerformMeas(0, a, t, d, s, g);
1762 
1763  ExeREM = 1;
1764 }
1765  E_REM();
1766 
1767 }
stepm StepM
Stepper motors parameters structure.
gui Gui
Graphic User Interface Structure.
void DB_KB_ButtonActive(int mod)
Enable/Disable Push buttons on the Control Panel.
Definition: CreateForms.c:3810
void E_NDFilter(void)
Set ND Filter. Set ND Filter All the E_xxxxx() function are used during the execution in PRG mode...
Definition: Exec.c:429
void MRefreshTimeout(TIMEOUT_ID *pid, CARD32 msec, TIMEOUT_CB cb, void *ud)
int SD_Grating(int ang)
Positioning Grating. The Grating move to the position specified by ang (Wavelength) ...
Definition: Spat_Device.c:2108
int ExeREM
Definition: DAS_Spat.c:143
int SD_Mirror(int where)
Positioning Input Mirror. The Input Mirror reaches the position specified by where.
Definition: Spat_Device.c:1898
int ExtLamp(int mod)
change the status of the external lamp change the status of the external lamp (ON or OFF) through a r...
Definition: Exec.c:1117
double S_zenetr
Definition: SOLPOS.C:92
void HgLamp(int mod)
HG Lamp ON/OFF .
Definition: Spat_Device.c:2673
int Server
Definition: DAS_Spat.c:253
void E_Meashor2(void)
perform horizontal measurements (2) 1) measurement with external lamp 2) measurement without the exte...
Definition: Exec.c:1370
int DB_InitCamera(int mod)
Initialize Camera Parameters. Procedure that initialize the CCD Camera.
Definition: Init.c:170
dil DIL
Definition: 2DPlot.c:26
void MLoopWhileEvents(int discard)
optionini DOption
Options for DAS execution.
int extlamp
0 = external lamp OFF; 1 = external lamp ON
#define AMS2
AMS2 address.
void E_Filter(void)
Filter Wheel positioning. Procedure for Filter Wheel positioning. All the E_xxxxx() function are used...
Definition: Exec.c:761
void SD_FNTorqueM(int mod)
Positioning NDFilter. .
Definition: Spat_Device.c:3066
void E_Hg_On(void)
HG ON. Hg lamp ON. All the E_xxxxx() function are used during the execution in PRG mode...
Definition: Exec.c:246
void E_Lambda(void)
Lambda Reading. When the WAVELEN key-word is encountred in the PRG file, the Wavelength code from PRG...
Definition: Exec.c:718
void E_IRefSun(void)
Io Measured near the sun. This procedure carries out a measurements for the reference spectrum used i...
Definition: Exec.c:845
int DB_InitAMS(int nid, int mod, int powera, int stepa, int slopea, int speeda, int powerb, int stepb, int slopeb, int speedb)
Init selected AMS.
Definition: Init.c:1391
void E_DirectSun(void)
. All the E_xxxxx() function are used during the execution in PRG mode
Definition: Exec.c:1596
int E_Home_SM4(void)
Home for SM4. Set the reference position for Stepper motor 4 (Neutral density filter wheel)...
Definition: Exec.c:209
flag FLAG
Definition: Exec.c:28
void E_WAIT(void)
Delay Procedure. sleep the program . All the E_xxxxx() function are used during the execution in PRG ...
Definition: Exec.c:731
int HomeMirror(void)
Input Mirror in the reference Position. The Input Mirror reaches the reference Position.
Definition: Init.c:685
C_DEF void DI_Regen(int s)
double S_azim
O: Solar azimuth angle: N=0, E=90, S=180, W=270.
Definition: SOLPOS.C:45
int SM_A
Motor A (su Y11) respectively: ID=0->InputMirror,ID=1->FilterWheel,ID=2->Zenith.
C_DEF double DI_ScanMaxMin(int w, float *mx, float *mi)
int Total
Progressive acquisition number for file (MAX defined = 50)
Definition: Exec.c:34
DXL structure. Structure for the serial communication with the AMS adapter.
Definition: DXL.H:16
int plotW
Flag for the plot display.
das structure (contain all the previous structures) .
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
void E_Radio(void)
Radiometric Measurements. Procedure for Radiometric Measurements. All the E_xxxxx() function are used...
Definition: Exec.c:684
int SaveCnt
Definition: Procedures.c:49
flag Flag
Structure for different flags.
void E_Meashor(void)
perform horizontal measurements (3) 1) measurement with external lamp 2) measurement without the exte...
Definition: Exec.c:1280
omuthr OMUTHR
Definition: Exec.c:29
void E_Label(void)
labeling. The text after the key-word is a label. All the E_xxxxx() function are used during the exec...
Definition: Exec.c:745
int filtertype
type of installed filter module: 0=Simple-SM3, 1=Double-SM3+SM4, 2=simpleplus-SM3+TM) ...
U16 * Imat
Definition: Dildef.h:286
char OldDate[8]
Definition: Exec.c:41
void D_Average(int mod)
Performs averaged measurements .
Definition: Procedures.c:2655
int SD_Zenith(float ang)
Positioning Zenith. The Zenith reaches the position specified by ang.
Definition: Spat_Device.c:2916
int slope[AMSMAX][2]
Stepper Motors Slope.
int SD_FilterW(int filter)
Positioning Filter wheel. The filter wheel move on the filter number specified by filter...
Definition: Spat_Device.c:2244
void quick(unsigned *elemento, int conta)
Definition: Exec.c:305
void E_Hg_Off(void)
HG OFF. Hg lamp OFF. All the E_xxxxx() function are used during the execution in PRG mode...
Definition: Exec.c:255
void E_AAPos(void)
alt Az Positioning. Available for SPATRAMPLUS and TROPOGAS (with the AltAzPlatform) ...
Definition: Exec.c:893
MOBJECT lbl_Par[11]
Parametric Labels of the Control Panel.
int HomeGratingFast(int mod)
(Fastest) Grating in the reference Position. The Grating reaches the reference Position. Similar to HomeGrating(void), but faster
Definition: Init.c:780
void AMS_Default(int id)
Set default values to AMS parameters Procedure for setting the default values of power.speed, stepping and slope to the selected AMS adapter.
Definition: Dxl.c:174
int E_Home_SM6(void)
Home for SM6. Set the reference position for Stepper motor 6 (MIGE Azimuth). All the E_xxxxx() functi...
Definition: Exec.c:182
int avgautor
autoranging for averaged measurement, 0 = NO AutoR before average; 1 = AutoR before average; ...
img Mat[MAXIMG]
Definition: Dildef.h:552
struct date DATE
Definition: Dildef.h:348
DXL_par DXL
Definition: Exec.c:27
int E_Home_SM5(void)
Home for SM5. Set the reference position for Stepper motor 5 (MIGE Zenith). All the E_xxxxx() functio...
Definition: Exec.c:168
void MObjectSetText(MOBJECT obj, const char *text)
void QjLamp(int mod)
QJ Lamp ON/OFF .
Definition: Spat_Device.c:2724
das DAS
Definition: Exec.c:30
void E_ExtLampON(void)
External lamp ON.
Definition: Exec.c:54
void E_Calibra(void)
Execute D_Calibra. D_Calibra is a procedure for the spectral calibration with HG lamp. Shift of HG spectral line at 4358.4 on pixel 512 All the E_xxxxx() function are used during the execution in PRG mode.
Definition: Exec.c:330
image Img
Definition: Dildef.h:675
int GRATHOME
Home for Grating ID.
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
void MRemoveTimeout(TIMEOUT_ID id)
#define STS0LEN
Control Flags.
#define TROPOGAS
TROPOspheric Gas Analyzer Spectrometer.
void D_Saving(void)
Saving image. Procedure for saving the CCD Image Used since version 2.1.0. The coiche between binary ...
Definition: Procedures.c:1369
void E_Azimuth(void)
Position Azimuth Axis.
Definition: Exec.c:1473
char * Program
buffer for the PRG file
Definition: DAS_Spat.c:90
char bufrx[1024]
Rx buffer.
Definition: DXL.H:20
int add
Peripheral address.
Definition: DXL.H:19
void E_HgScan(void)
Check the full spectral range with HG ON. All the E_xxxxx() function are used during the execution in...
Definition: Exec.c:1504
void E_Dark(void)
Execute Dark Measurement. Procedure for Dark Measurement. All the E_xxxxx() function are used during ...
Definition: Exec.c:279
void E_Qj_On(void)
Qj ON. QJ - Halogen - lamp ON. All the E_xxxxx() function are used during the execution in PRG mode...
Definition: Exec.c:263
int ADTempTest
= 0 -> AD Converter results on the Control Panel; = 1 -> AD Converter Testing Phase(results on the co...
#define FDOUBLE
double filter wheel
#define FPLUS
Filter Wheel Torque Motor.
int SD_Azimuth(float ang, float raz)
Positioning Azimuth. The Zenith reaches the position specified by ang.
Definition: Spat_Device.c:3110
int E_GetCCD(void)
Get CCD. Execute DB_GetCCD. All the E_xxxxx() function are used during the execution in PRG mode...
Definition: Exec.c:705
int AMS_MotorOn_Off(int id, int mtr1, int mtr2)
Motor ON-OFF. Switch On-Off the selected motor of the selected AMS.
Definition: Dxl.c:930
void E_ExtLampOFF(void)
External lamp OFF.
Definition: Exec.c:66
long PrgCnt
Counter for the position in the PRG file.
Definition: DAS_Spat.c:93
int D_Calibra(void)
Spectral Calibration Procedure for the spectral calibration with HG lamp. Shift of HG spectral line a...
Definition: Procedures.c:2313
void E_DFMeasure(void)
Perform Measurement setting the ND Filter Wheel also. All the E_xxxxx() function are used during the ...
Definition: Exec.c:911
unsigned char OOP[AMSMAX]
2 byte Word for AMS Opto insulated Output Port Status
void E_SetCCDPow(void)
Set CCD Power. Set CCD Power. All the E_xxxxx() function are used during the execution in PRG mode...
Definition: Exec.c:411
void DB_DefectPixCorr(void)
Apply thew pixel correction. .
Definition: Procedures.c:1568
int VBin
CCD Vertical Binning.
paramini structure . It contains some of the parameters defined in the file PARAM.INI .
#define SPATRAM2
SPATRAM2 (with ATX power supply & HiresV)
int CoolPw
CCD Init Power.
int ViewPlot(int mod)
Create the plot shell. Procedure that build the plot shell for the data visualization.
Definition: Spat_Plot.c:3775
#define SPATRAMPLUS
As SPATRAM plus AltAzimuth platform.
void Status(char *tit)
Writes information&#39;s on the Status label .
Definition: Load.c:1556
double FlagTExp
Definition: Exec.c:38
void E_ChkExLamp(void)
Definition: Exec.c:1225
int ExtShutt(int mod)
change the status of the external shutter change the status of the external shutter (OPEN or CLOSED) ...
Definition: Exec.c:1155
void delay(unsigned long d)
Pauses for a specified number of milliseconds. .
Definition: Dxl.c:1113
int FlagBarra
Definition: Exec.c:339
void E_Mirror(void)
Inpot Mirror positioning. Procedure for Input mirror positioning. All the E_xxxxx() function are used...
Definition: Exec.c:773
Definition: Dildef.h:240
void E_SetCCDTemp(void)
Set CCD Temp. Set CCD Temp. All the E_xxxxx() function are used during the execution in PRG mode...
Definition: Exec.c:375
void SaveCalib(int mod)
Definition: Procedures.c:2130
#define GRAT_TASK_TIME
Grating Home.
float IHigh
Definition: Dildef.h:303
double AutoRange(int mod)
Calculate the exposure time The optimum exposure time (TExp) is calculated with an initial TExpAR=0...
Definition: Procedures.c:899
int ADPC104
0 –> Device PC104 exist, 1 –> PC104 DOESN&#39;T exist
paramini PARAM
Definition: Exec.c:31
Function prototypes.
void E_Average(void)
Averaged Measurements. Procedure for Averaged Measurements. All the E_xxxxx() function are used durin...
Definition: Exec.c:612
int MMessageDialog(const char *t, const char *msg, const char *btn1, const char *btn2,...)
void E_Measure(void)
Perform Measurement. All the E_xxxxx() function are used during the execution in PRG mode...
Definition: Exec.c:1060
ids IDS
ID tasks.
Definition: DAS_Spat.c:54
int HomeFiltersFast(void)
(Fastest) Fliter wheel in the reference Position. The Fliter wheel reaches the reference Position...
Definition: Init.c:853
#define SPATRAM3
SPATRAM3.
double TExp
CCD Exposure time.
Definition: DAS_Spat.c:130
CTYPE void DLL DC_GetCCD(int Mode, double Exposure, U16 *mat, int Camera)
Get an image at full resolution. Procedure that allows you to read an image, given an exposure time e...
Function prototypes.
float ILow
Definition: Dildef.h:302
int E_Home_SM2(void)
Home for SM2. Set the reference position for Stepper motor 2 (Grating). All the E_xxxxx() function ar...
Definition: Exec.c:139
int AMS_wopto(int id, unsigned int w)
write the value on the optoinsulated port write the value on the optoinsulated port.
Definition: Dxl.c:911
int E_Home_SM3(void)
Home for SM3. Set the reference position for Stepper motor 3 (Filter Wheel). All the E_xxxxx() functi...
Definition: Exec.c:154
int SM_B
Motor B (su Y12) respectively: ID=0->Grating,ID=1->Not Connected,ID=2->Azimuth.
void Radio(int g)
NOT Used .
Definition: Exec.c:650
static double p
Definition: SOLPOS.C:131
void E_REM(void)
Flush string since the Carriege Return. Procedure for flushing the readed string since the Carriege R...
Definition: Exec.c:47
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 pixcorr
Flag to set defective pixel correction: 0=NOT Corrected, 1=Corrected.
void E_Expo(void)
Exposuring. Read the Exposure time from PRG file. All the E_xxxxx() function are used during the exec...
Definition: Exec.c:365
controlpanel ContrPanel
Control Panel Structure.
int SD_PosOMUDev(int m, int w, int f)
perform the simoultaneous positioning of the Spectrometer Devices in the OMU Unit m = mirror w = wave...
Definition: Spat_Device.c:747
void E_QjScan(void)
Check the full spectral range with QJ ON. All the E_xxxxx() function are used during the execution in...
Definition: Exec.c:1548
void E_HGratCal(void)
Perform home grating and HG Calibration. All the E_xxxxx() function are used during the execution in ...
Definition: Exec.c:1488
void E_Save(void)
Save Image. Procedure for saving image or data. All the E_xxxxx() function are used during the execut...
Definition: Exec.c:355
#define AMS1
AMS1 address.
int measmode
measuring mode: 0 = Single; 1 = Averaged
int SD_Position(int m, int w, int f, double z, double a)
perform the simoultaneous positioning of the Spectrometer Devices m = mirror w = wavelength (Grating)...
Definition: Spat_Device.c:1243
void E_Almucantar(void)
. All the E_xxxxx() function are used during the execution in PRG mode
Definition: Exec.c:1680
int speed[AMSMAX][2]
Stepper Motors Speed.
void E_Zenith(void)
Position Zenith Axis.
Definition: Exec.c:1461
int step[AMSMAX][2]
Stepper Motors Step.
void E_SetCCDVBin(void)
Set CCD Vert Binn. Set CCD Vert Binn. All the E_xxxxx() function are used during the execution in PRG...
Definition: Exec.c:446
CTYPE void DLL DC_SetUsrGain(int Gain, int Range, int Offset, int Camera)
Procedure that allows you to set the ccd gain. Procedure that allows you to set the ccd gain...
void D_Plot(void)
ViewPlot callback .
Definition: Procedures.c:192
void E_AutoRange(void)
Autoranging. Procedure for Autoranging. All the E_xxxxx() function are used during the execution in P...
Definition: Exec.c:342
int smposmode
positioning mode for stepper , 0 = sequential mode; 1 = simoultaneous mode
struct time TIME
Definition: Dildef.h:347
int DB_StsMotor(int c)
Definition: Exec.c:785
static double elev
Definition: SOLPOS.C:130
void E_AAMeasure(void)
perform measurements with the Alt Azimuth Platform perform measurements with the Alt Azimuth Platform...
Definition: Exec.c:997
void E_SetCCDOffSet(void)
Set the CCD Offst (only for HIRES-V. All the E_xxxxx() function are used during the execution in PRG ...
Definition: Exec.c:394
int EqType
Spectrometer Type.
int HomeZenithFast(void)
Home for Zenith Axis.
Definition: Init.c:1143
void E_ExtShutClose(void)
Close External Shutter.
Definition: Exec.c:91
void E_AvgCCDHor(void)
Averaged Horizontal Measurements. Procedure for Averaged Measurements with external lamp...
Definition: Exec.c:538
float Low
Definition: Dildef.h:294
char NewDate[8]
Definition: Exec.c:42
void PerformMeas(int mod, int ar, double te, int mt, int sv, int pl)
Perform Averaged or single measurements.
Definition: Exec.c:463
int SD_NDFilterW(int filter)
Positioning Filter wheel. The filter wheel move on the filter number specified by filter...
Definition: Spat_Device.c:2354
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
int extshutter
0 = external shutter open; 1 = external shutter closed
double ITemp
CCD Target Temperature.
float High
Definition: Dildef.h:295
void E_Qj_Off(void)
Qj OFF. QJ - Halogen - lamp OFF. All the E_xxxxx() function are used during the execution in PRG mode...
Definition: Exec.c:271
#define AMS3
AMS3 address.
OMU Thermoregulation structure .
int DB_GetCCD(int mod)
Get CCD Image. .
Definition: Procedures.c:1749
void E_Plot(void)
Plot Spectrum. Plot Spectrum. All the E_xxxxx() function are used during the execution in PRG mode...
Definition: Exec.c:237
int E_Home_SM1(void)
Home for SM1. Set the reference position for Stepper motor 1 (Input Mirror). All the E_xxxxx() functi...
Definition: Exec.c:111
int ReachTemp
Target Temperature status.
int LookforWl_X(int x)
Definition: Procedures.c:2295
int power[AMSMAX][2]
Stepper Motors Power.
marconi Marconi
CCD Sensor struct.
paramini Paramini
structure for the parameters defined in param.ini configuration file
void E_ExtShutOpen(void)
Open External Shutter.
Definition: Exec.c:79
______________________________________________________________________________________
Generated on Mon Sep 18 2017 11:44:08 for DAS - Rel. 3.1.6 - 18/09/2017.