DAS  3.1.6 - 18/09/2017
Init.c
Go to the documentation of this file.
1 #include <windows.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
5 #include <math.h>
6 #include "mgui.h"
7 #include "DAS_Spatram.h"
8 #include "dcl.h"
9 #include "dil.h"
10 #include "wsc.h"
11 #include "dxl.h"
12 #include "bil.h"
13 #include "portio32.h"
14 
24 //marc MARC; ///< Marconi struct
28 
29 // CCD & Camera vars
33 
35 
36 
37 
38 /***********************************************************************/
43 void CBExpo(MOBJECT p, void *od, void *ad)
44 {
45  DC_BrkFlg(0);
46 }
47 /***********************************************************************/
48 /***********************************************************************/
56 {
57  int c;
58  MOBJECT sh, a, pb, pix;
59 
61  MObjectSetBackgroundImageFile(sh, "dilsys/back.bmp", BI_TILED);
62  MFormSetSpacing(sh, 5);
63 
64  a = MCreateColForm(sh);
65  MObjectSetShadow(a, WS_NONE, 0, 0);
66  MFormSetSpacing(a, 0);
67  MObjectSetTransparency(a, 255);
68 
69  for(c = 0; c < 6; c++)
70  if(c == 4)
72  else
74 
75  pix = MCreatePixmapFromFile(sh, "dilsys/down.bmp");
76 
77  a = MCreateColForm(sh);
78  MObjectSetShadow(a, WS_NONE, 0, 0);
79  MFormSetSpacing(a, 0);
80  MObjectSetTransparency(a, 255);
81 
82  for(c = 0; c < 6; c++)
83  if(c == 4)
85  else
87 
88  pb = MCreateImagePButtonExt(sh, "vimg/stop.bmp", "vimg/stopon.bmp", "", "vimg/stoparm.bmp", "", "");
89  MObjectSetShadow(pb, WS_NONE, 0, 0);
90  MPButtonSetCallback(pb, CBExpo, NULL);
91 
92  MShellRealize(sh);
93 
94  return sh;
95 }
96 /***********************************************************************/
97 
98 void __stdcall ShowDown(const char *str, int port)
99 {
100  char buff[16];
101  buff[0] = '\0';
102  strcpy(buff,str);
103 
104  if(DAS.Marconi.LblExpD[0] != NULL)
105  {
106  //DI_WriteDigit(DAS.Marconi.LblExpP, ttot);
107  DI_WriteDigit(DAS.Marconi.LblExpD, buff);
108  MLoopWhileEvents(0);
109  }
110 }
111 
112 int DB_InitDil(void)
113 {
114 
115  char buf[80];
116 /*********************************************************************************
117  * dx = X image dimension
118  * dy = Y image dimension
119  * ifmt = image format
120  * 0 = 16 bit unsigned Monochrome or paletted
121  * 1 = 16 bit RGB
122  * 2 = float (4 bytes) Monochrome or paletted
123  * sts: 1 = Show image, 0 = Hidden, 2 = Can't close image via X on window
124  *
125  * tit = Image name (max 32 chars), if use "NONAME", will be initialized with shaded gray
126  * CBImage = Mouse Call Back on Image
127  * CBClose = Closing Cal back
128  *
129  * Return an image identifier (id) 0 to n
130  * A negative value indicate an error
131  * Errors:
132  * -1 = Memory allocation error
133  * -2 = Type inexistent/Format inexistent
134  * -3 = Too image open at the same time
135  *********************************************************************************/
136 
137  Server = DI_Init(0); //0=No Pop-Up Menu, 1=Yes Pop-Up Menu
138 
139  DI_OpenDigit();
140 
141 
142  if((DAS.Flag.exemode == OFFLINEPLOT) | (DAS.Flag.exemode == DOASMODE))
143  {
144  IDX = BIL.SPH.ccdex - BIL.SPH.ccdsx + 1;
145  IDY = (BIL.SPH.ccdey - BIL.SPH.ccdsy + 1) / BIL.SPH.ccdvb ;
146  IDX = BIL.SPH.ccdwx;
147  IDY = BIL.SPH.ccdwy/BIL.SPH.ccdvb ;
148  }
149  else
150  {
151  IDX = DC_CCD.dx;
152  IDY = DC_CCD.dy/DAS.Paramini.VBin ;
153  }
154 
155 
156  sprintf(buf, "E2V %s on %s",DC_CCDtoName(Cfg.CCDType, 0), DC_PTFtoName(Cfg.Platform, 0));
157  Server = DI_OpenImage((U16)IDX, (U16)IDY, (U16)DAS.DOption.imgtype, 1, buf);
158  DI_RunHisto();
159 
160 
161 
162  return 0;
163 
164 
165 }
166 
167 
168 
169 
170 int DB_InitCamera(int mod)
171 {
172 
173  int er, os, c;
174  double PowTemp;
175  unsigned long mx;
176  char buf[_MAX_PATH];
177  char buff[_MAX_PATH];
178  char str[_MAX_PATH];
179  int StartMode;
180  long np;
181 
182 
183  if (mod)
184  DC_Close(0);
185 
186 
187 //************************** **********************
188 
189  //Set path for the DCL
190  //sprintf(buff, "%s\\dcl\\", BIL.DFILEM.CONFIGDIREQUIPMENT );
191  sprintf(buff, "%s\\dcl\\", BIL.DFILEM.HOMEDIRECTORY);
192  // Return: 1 if PATH exist, else return 0
193  er = DI_PathExist(buff);
194  if (er)
195  {
196  //Set path for the DCL
197  DC_SetPathName(buff);
198  }
199  else
200  {
201  sprintf(buf,"Path '%s' deos not exist,\nPlease create and fill ", buff);
202  MMessageDialog ("DAS ERROR ", buf, "OK",NULL);
203  return 1001;
204 
205  }
206 
207  sprintf(buff, "%s\\%s.cfg", BIL.DFILEM.CONFIGDIREQUIPMENT, CodeEq2Name(DAS.Paramini.EqType));
208 
209 // sprintf(buff, "%s\\camera.cfg", BIL.DFILEM.CONFIGDIREQUIPMENT );
210 // sprintf(buff, "%s\\dcl\\SPATRAM2.cfg", BIL.DFILEM.HOMEDIRECTORY );
211  //Return: 1 if file exist, else return 0
212  er = DI_FileExist(buff);
213  if (er)
214  {
215  er = DC_LoadCameraConfig(buff, &Cfg);
216  if (er)
217  {
218  //sprintf(buff,"Error in reading '%s\\dcl\\camera.cfg' file,\nUNKNOWN Reason. Please contact Danbo", BIL.DFILEM.CONFIGDIREQUIPMENT);
219  //sprintf(buff,"Error in reading '%s\\camera.cfg' file,\nUNKNOWN Reason. Please contact Danbo", BIL.DFILEM.CONFIGDIREQUIPMENT);
220  sprintf(buff,"Error in reading '%s\\%s.cfg' file,\nUNKNOWN Reason. Please contact Danbo", BIL.DFILEM.CONFIGDIREQUIPMENT,CodeEq2Name(DAS.Paramini.EqType));
221  MMessageDialog ("DAS ERROR ", buff, "OK",NULL);
222 
223  sprintf(buff,"Error in reading '%s.cfg' ", CodeEq2Name(DAS.Paramini.EqType));
224  Status(buff);
225  return 1003;
226  }
227 
228  }
229  else
230  {
231  sprintf(buff,"File'%s\\%s.cfg' not found,\n\
232 Now 'dcs.exe' will load the standard 'camera.cfg' configuration file\n\
233 Set the camera parameters, copy the '%s\\dcl\\camera.cfg' file in the %s folder\n\
234 and rename in '%s.cfg'", BIL.DFILEM.CONFIGDIREQUIPMENT, CodeEq2Name(DAS.Paramini.EqType),
236  MMessageDialog ("DAS ERROR ", buff, "OK",NULL);
237  sprintf(str, "%s//%s", BIL.DFILEM.HOMEDIRECTORY , "dcs.exe");
238 
239 
240 
241  er = WinExec(str, SW_SHOW);
242 
243  return 1002;
244 
245  }
246 
247 
248 
249 //************************************************************
250  DC_OpenPar(Cfg.Platform, Cfg.CCDType, 0);
251 
252  DC_RWData(CCD_INFO, READ_DATA, (void *) &DC_CCD, 0);
253  DC_RWData(PTF_INFO, READ_DATA, (void *) &DC_HP, 0);
254 
255 
256  sprintf(buf,"%d", DC_CCD.dx);
257  MObjectSetText(DAS.Gui.ContrPanel.lbl_Par[3], buf);
258 
259  sprintf(buf,"%d", DC_CCD.dy);
260  MObjectSetText(DAS.Gui.ContrPanel.lbl_Par[4], buf);
261 
262  if ((DAS.Flag.exemode == TEMPORIZED) | (DAS.Flag.exemode == PRGFILE) | (DAS.Flag.exemode == TESTCCD) |
263  (DAS.Flag.exemode == MANUAL) | (DAS.Flag.exemode == SZAMASTERM) | (DAS.Flag.exemode == SZAMODE))
264  {
265  os = WhoSys();
266  c = CCDHANDLE | CLEARCCD | TEMPHANDLE | os;
267  // c = CCDHANDLE | CLEARCCD | os;
268  // Init the camera
269 
270 
271  // Clear background task if setted
272  //Cfg.TaskSettings &= (~(CCDHANDLE + TEMPHANDLE + CLEARCCD + MUTE));
273 
274 
275 
276  StartMode = 0;
278  er = DC_Status(Cfg.FDL_PCI_Index);
279  if (er)
280  {
281 // sprintf(buf,DC_ErrorMessage(er));
282 // CCD_Error(buf);
283  return er;
284  }
285  else
286  {
287  DC_RWData(CCD_INFO, READ_DATA, (void *) &DC_CCD, Cfg.FDL_PCI_Index);
288  DC_RWData(PTF_INFO, READ_DATA, (void *) &DC_HP, Cfg.FDL_PCI_Index);
289 
290  if(mod==0)
291  {
292  /*** Init Dil ***/
293  DB_InitDil();
294  /*******************/
295  // Y Zoom for high vertical binning
296  if((IDY) < 50)
297  DI_ImageProperties(Server, (U16)IDX, (U16)IDY, (U16)IDX, (U16)IDY, 0, 0, NULL, 1, 100 / IDY, 0);
298 // Image[Server].attrib = 1;
299  DI_Regen(Server);
300  }
301  else
302  {
303  IDX = DC_CCD.dx;
304  IDY = DC_CCD.dy/DAS.Paramini.VBin ;
305 
306  sprintf(buf, "E2V %s on %s",DC_CCDtoName(Cfg.CCDType, 0), DC_PTFtoName(Cfg.Platform, 0));
307  Server = DI_OpenImage((U16)IDX, (U16)IDY, (U16)DAS.DOption.imgtype, 1, buf);
308  DI_RunHisto();
309 
310  // Y Zoom for high vertical binning
311  if((IDY) < 50)
312  DI_ImageProperties(Server, (U16)IDX, (U16)IDY, (U16)IDX, (U16)IDY, 0, 0, NULL, 1, 100 / IDY, 0);
313 // Image[Server].attrib = 1;
314  DI_Regen(Server);
315 
316 
317  if(Server)
318  {
319  DIL.Img.Mat[Server - 1].attrib = 0;
320  DI_CloseImage(Server - 1);
321  }
322 
323  if(Server == 0)
324  {
325  DIL.Img.Mat[Server + 1].attrib = 0;
326  DI_CloseImage(Server + 1);
327  }
328 
329  }
330 
331  // Set Gain
332  DC_SetGain(0, 0);
333 
334 
335  if (Cfg.Platform == 28) // HIRES V
336  {
337  //DC_SetUsrGain(int Gain, int Range, int Offset, int Camera);
338  DC_SetUsrGain(0, 0 , DAS.Marconi.Offset , 0);
339  }
340  // Set CCD Temperature
341  DC_SetTemp(DAS.Paramini.ITemp, CELSIUS, 0);
342 
343  // Check CCD Cooler Power
344  PowTemp = DC_GetPower(0);
345 
346  // Set CCD Cooler Power
347  DC_SetPower((double) ((double)DAS.Paramini.CoolPw / 10),0);
348 
349  // Check CCD Cooler Power
350  PowTemp = DC_GetPower(0);
351 
352  // Check Binning
353  //DC_GetBinning(orizz, vertic,0);
354 
355  // Set Vertical binning DAS.Paramini.VBIN
356  DC_SetBinning(1, DAS.Paramini.VBin,0);
357 
358  // Check Binning
359  //DC_GetBinning(orizz, vertic,0);
360 
361  /*********************
362  Load defect pixel
363  ********************/
364  if (DAS.DOption.pixcorr)
365  {
366  sprintf(buff, "%s\\%s",BIL.DFILEM.CONFIGDIREQUIPMENT, DAS.DOption.DEFPIXFILENAME);
367  er=LoadDB_DefectPixel(buff);
368  }
369  //buffer for dark matrix
370  if( ImatDark != NULL )
371  free(ImatDark);
372 
373  mx = (unsigned long) IDX * (unsigned long) IDY;
374  ImatDark = (unsigned short *) calloc( mx, sizeof(unsigned short));
375  //Average Matrix (buffer)
376  if (DAS.Marconi.AVGmat != NULL)
377  free(DAS.Marconi.AVGmat);
378 
379  DAS.Marconi.AVGmat = (unsigned long *) calloc( mx, sizeof(unsigned long));
380 
381  return 0;
382  }
383 
384  }
385  else if(DAS.Flag.exemode == DBDEMO || DAS.Flag.exemode == TESTSZAMODE)
386  {
387 
388  if(mod==0)
389  {
390  /*** Init Dil ***/
391  DB_InitDil();
393  // Y Zoom for high vertical binning
394  if((IDY) < 50)
395  DI_ImageProperties(Server, (U16)IDX, (U16)IDY, (U16)IDX, (U16)IDY, 0, 0, (U16)NULL, 1, 100 / (U16)IDY, 0);
396  //Image[Server].attrib = 1;
397  DI_Regen(Server);
398 
399 
400 
401 
402  /*******************/
403  }
404  else
405  {
406  IDX = DC_CCD.dx;
407 
408  IDY = DC_CCD.dy/DAS.Paramini.VBin ;
409 
410 
411  sprintf(buf, "E2V %s on %s",DC_CCDtoName(Cfg.CCDType, 0), DC_PTFtoName(Cfg.Platform, 0));
412  Server = DI_OpenImage((U16)IDX, (U16)IDY, (U16)DAS.DOption.imgtype, 1, buf);
413  DI_RunHisto();
414  // Y Zoom for high vertical binning
415  if((IDY) < 50)
416  DI_ImageProperties(Server, (U16)IDX, (U16)IDY, (U16)IDX, (U16)IDY, 0, 0, NULL, 1, 100 / (U16)IDY, 0);
417  //Image[Server].attrib = 1;
418  DI_Regen(Server);
419 
420  if(Server)
421  {
422  DIL.Img.Mat[Server - 1].attrib = 0;
423  DI_CloseImage(Server - 1);
424  }
425 
426  if(Server == 0)
427  {
428  DIL.Img.Mat[Server + 1].attrib = 0;
429  DI_CloseImage(Server + 1);
430  }
431 
432  }
433  return 0;
434  }
435 
436 
437 
438 /**********************************************************************/
439 // Controlla il Param.log
440 // Apre e legge il Param.log per poi decidere cosa fare con il parametro MODE del sensore
441 // Mode = LoadParamLog();
442 // if(Mode == 2)
443 // {
444  // il file non e' stato trovato quindi si pone Mode=0 (reinizializza il tutto)
445 // Mode = 0;
446 // }
447 /**********************************************************************/
448  return 0;
449 
450 }
451 
452 int DB_InitCOM(int comn)
453 {
454 
455  int er = 0;
456  er = DXL_Open(0, comn, Baud19200);
457  return er;
458 
459 }
460 int DB_CloseCOM(void)
461 {
462  int er;
463 
464  er = DXL_Close();
465  return er;
466 }
467 
468 
469 
470 int D_Homing(MOBJECT p, int id, int sm, int tout)
471 {
472  unsigned long st, et, x;
473  char buf[80];
474  int er = 0;
475  st = GetTickCount();
476  do
477  {
478  er = AMS_TestHome(id, sm);
479 
480 
481  sprintf(buf,"%d", er);
482  Status(buf);
483 
484  if (er)
485  {
486  sprintf(buf,"%d", er);
487  Status(buf);
488  return 1;
489  }
490  et = GetTickCount();
491  x = labs(et - st);
492  MLoopWhileEvents(0);
493  //if((x % 10) == 0 && x > 0)
494  if(x > 0)
495  {
496  if(DAS.DOption.amsprogbar)
497  D_VRange(NULL, (long) x * 100 / tout, 255, 0, 0 );
498  sprintf(buf, "%.1lf sec.", (double)((double)(labs(et - st) - tout)/1000.0 ));
499  MObjectSetText(p, buf);
500  }
501  }while((labs(et - st) < tout));
502 
503 
504  er = AMS_TestHome(id, sm);
505  sprintf(buf,"%d", er);
506  Status(buf);
507 
508 
509 
510  return 0;
511 
512 }
513 
514 
515 
516 // id = AMS address
517 // sm = Stepper Motor: 0 = SM_A, 1 = SM_B
518 int HomeTrack(char *buf, int id, int sm, int mode)
519 {
520 
521  int d, bitn, dir,er;
522  int HomeOnGoing = 1;
523  long tout = 10000;
524  double t;
525  unsigned long st, et, x;
526  long count;
527 
528  //Select Bit number
529  switch(sm)
530  {
531  case 0:
532  bitn = 3;
533  break;
534  case 1:
535  bitn = 1;
536  break;
537  }
538 
539  // Read input
540  d = AMS_chkbitsts(id, bitn);
541 
542  // Select direction
543  /************/
544  if (!d)
545  dir = 0;
546  if (d)
547  dir = 1;
548  /************/
549 
550  // First attempt (fast)
551  /*§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§*/
552  if(DAS.DOption.amsprogbar)
553  D_VRange(buf,0, 255, 0, 0);
554 
555  t = 10E6 / (2 * DAS.StepM.speed_Hz[id][sm] * 1000) - 1 ;
556  count = (long) t;
557 
558  switch(sm)
559  {
560  case 0:
561  AMS_TrackOn(id, dir, 0, count, 0);
562  break;
563  case 1:
564  AMS_TrackOn(id, 0, dir, 0, count);
565  break;
566  }
567 
568 
569 
570  st = GetTickCount();
571 
572  do
573  {
574  // Read input
575  d = AMS_chkbitsts(id, bitn);
576  MLoopWhileEvents(0);
577 
578  if (dir == 0) //Direction = 0
579  {
580  if(d)
581  {
582  HomeOnGoing = 0;
583  er = AMS_TrackOff(id, 1, 1);
584  }
585  }
586  if (dir) //Direction 1
587  {
588  if(d==0)
589  {
590  HomeOnGoing = 0;
591  er = AMS_TrackOff(id, 1, 1);
592  }
593  }
594 
595  et = GetTickCount();
596  x = labs(et - st);
597 // MLoopWhileEvents(0);
598  //For progress bar display
599  //if((x % 10) == 0 && x > 0)
600  if(x > 0)
601  if(DAS.DOption.amsprogbar)
602  D_VRange(NULL, (long) x * 100 / tout, 255, 0, 0 );
603  }while(HomeOnGoing);
604 
605  if(DAS.DOption.amsprogbar)
606  D_VRange(NULL, 100, 0,0,0);
607  /*§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§*/
608 
609  // Second attempt (slow in opposite direction)
610  /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
611  HomeOnGoing = 1;
612  dir = !dir;
613  t = 10E6 / (2 * DAS.StepM.speed_Hz[id][sm] * 1000 / 50) - 1;
614  count = (long) t;
615 
616  switch(sm)
617  {
618  case 0:
619  AMS_TrackOn(id, dir, 0, count, 0);
620  break;
621  case 1:
622  AMS_TrackOn(id, 0, dir, 0, count);
623  break;
624  }
625 
626  if(DAS.DOption.amsprogbar)
627  D_VRange( buf,0, 255, 255, 0);
628 
629  st = GetTickCount();
630 
631  do
632  {
633 
634  d = AMS_chkbitsts(id, bitn);
635  if (dir == 0) //Direction = 0
636  {
637  if(d)
638  {
639  HomeOnGoing = 0;
640  er = AMS_TrackOff(id, 1, 1);
641  }
642  }
643  if (dir) //Direction 1
644  {
645  if(d==0)
646  {
647  HomeOnGoing = 0;
648  er = AMS_TrackOff(id, 1, 1);
649  }
650  }
651 
652  et = GetTickCount();
653  x = labs(et - st);
654  MLoopWhileEvents(0);
655  //For progress bar display
656  //if((x % 10) == 0 && x > 0)
657  if(x > 0)
658  if(DAS.DOption.amsprogbar)
659  D_VRange(NULL, (long) x * 100 / tout, 255, 0, 0 );
660  }while(HomeOnGoing);
661 
662 
663  if(DAS.DOption.amsprogbar)
664  D_VRange(NULL, 100, 0,0,0);
665  /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
666 
667  //Reset the default values of the divider
668  AMS_Divisore(id, 40000,40000);
669 
670 
671  if (mode)
672  {
673  //Home Grating Task
675 
676  }
677 
678  return 0;
679 
680 }
681 
682 
683 
684 
685 int HomeMirror(void)
686 {
687  int er, k;
688  char buf[40];
689 // int DIR[] = { 0, 0 };
690  int dir = 0;
691  long count;
692 // int FlgHomeMir = 1,
693  int sts = 0;
694  int HomeOnGoing = 1;
695 // double t;
696 // unsigned long st, et, x;
697  long tout = 3000;
698 
699  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS1][DAS.StepM.SM_A], "SYS\\ledoff.bmp");
700  sprintf(buf, "%s", "Homing");
701  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[0], buf);
702  Status("Home for Input Mirror...");
703 
704  //st = GetTickCount();
705 
706 
707  if(DAS.StepM.hometype[AMS1][DAS.StepM.SM_A] == 0) //Home Standard
708  {
709  er = AMS_Home(AMS1, 1, 0);
710  count = (long) (2000.0 * DAS.StepM.multiplier[AMS1][DAS.StepM.SM_A]);
711  D_Homing(DAS.Gui.ContrPanel.Albl_LS[0], AMS1, DAS.StepM.SM_A, count);
712  }
713  if(DAS.StepM.hometype[AMS1][DAS.StepM.SM_A] == 1) //Home with Default
714  {
715 
716  //18/05/2007 NOT Tested
717  DAS.StepM.divider[AMS1][DAS.StepM.SM_A]= (unsigned long)(10E6/DAS.StepM.speed_Hz[AMS1][DAS.StepM.SM_A]/2);
718  AMS_Divisore(AMS1,DAS.StepM.divider[AMS1][DAS.StepM.SM_A],40000);
719 
720  er = AMS_HomeDefault(AMS1, 1, 0);
721  D_Homing(DAS.Gui.ContrPanel.Albl_LS[0], AMS1, DAS.StepM.SM_A, 12000);
722  AMS_Divisore(AMS1, 40000,40000);
723 
724  }
725  //Home with tracking with setted values of speed and step/round
726  if(DAS.StepM.hometype[AMS1][DAS.StepM.SM_A] == 2)
727  {
728  sprintf(buf, "Homing Mirror");
729  er = HomeTrack(buf, AMS1,DAS.StepM.SM_A, 0);
730  }
731 
732  // Set final directions
733 
734  AMS_dirfin(AMS1, 1, 0);
735  // Set default values
736  AMS_Default(AMS1);
737 
738  // Re-Init AMS1 ( with no Home)
739  er = DB_InitAMS(AMS1, 1, DAS.StepM.power[AMS1][DAS.StepM.SM_A],
740  DAS.StepM.step[AMS1][DAS.StepM.SM_A], DAS.StepM.slope[AMS1][DAS.StepM.SM_A],
741  DAS.StepM.speed[AMS1][DAS.StepM.SM_A], DAS.StepM.power[AMS1][DAS.StepM.SM_B],
742  DAS.StepM.step[AMS1][DAS.StepM.SM_B], DAS.StepM.slope[AMS1][DAS.StepM.SM_B],
743  DAS.StepM.speed[AMS1][DAS.StepM.SM_B]);
744 
745  // Send Offet for Mirror
746  if(DAS.Paramini.Offset[0] > 0) dir = 0;
747  else dir = 1;
748 
749  if(DAS.Paramini.Offset[0] != 0)
750  {
751  k = (int)SMfraz(DAS.StepM.step[AMS1][DAS.StepM.SM_A]);
752  count = labs(DAS.Paramini.Offset[0] * k * DAS.StepM.multiplier[AMS1][DAS.StepM.SM_A]); //6 e' la riduzione
753  //er = AMS_DoPos(AMS1, DIR[0], 0, count, 0);
754  er = AMS_DoPos(AMS1, dir, 0, labs(count), 0);
755  if(er) { Message("n Step not sent! 2", er); }
756  }
757 
758 
759 
760 
761  er = AMS_AzzeraCoord(AMS1, 0);
762  if(er) { Message("No Zero Coord Mirror", er); }
763  MIS.Pos = 0;
764  if (DAS.Paramini.EqType == TROPOGAS || DAS.Paramini.EqType == SPATRAM3 || DAS.Paramini.EqType == GASCODNG4 )
765  sprintf(buf, "%s",Mir_CodeTropo[0]);
766  else
767  sprintf(buf, "%s",Mir_Code[0]);
768 
769 // sprintf(buf, "%s", " Zenith" );
770  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[0], buf);
771  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS1][DAS.StepM.SM_A], "SYS\\ledGreen.bmp");
772  Status("Home for Input Mirror..DONE");
773 
774  return 0;
775 
776 }
777 
778 
779 
780 int HomeGratingFast(int mod)
781 {
782 
783  int DIR[] = { 0, 0 };
784 // long count;
785 // double t;
786  int er, FlgGratPos = 1;
787  char buf[80];
788  unsigned long st;
789 
790 
791  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS1][DAS.StepM.SM_B], "SYS\\ledoff.bmp");
792  sprintf(buf, "%s", "Homing");
793  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[1], buf);
794  Status("Home for Grating...");
795 
796  st = GetTickCount();
797 
798 
799 
800 
801  if(DAS.StepM.hometype[AMS1][DAS.StepM.SM_B] == 0) //Home Standard
802  {
803  er = AMS_Home(AMS1, 0, 1);
804  D_Homing(DAS.Gui.ContrPanel.Albl_LS[1], AMS1, DAS.StepM.SM_B, 30000);
805  }
806  if(DAS.StepM.hometype[AMS1][DAS.StepM.SM_B] == 1) //Home with Default
807  {
808  er = AMS_HomeDefault(AMS1, 0, 1);
809  D_Homing(DAS.Gui.ContrPanel.Albl_LS[1], AMS1, DAS.StepM.SM_B, 30000);
810  }
811  //Home with tracking with setted values of speed and step/round
812  if(DAS.StepM.hometype[AMS1][DAS.StepM.SM_B] == 2)
813  {
814  sprintf(buf, "Homing Grating");
815  er = HomeTrack(buf, AMS1, DAS.StepM.SM_B, mod);
816  }
817 
818 /**********************************/
819 
820 
821  AMS_dirfin(AMS1, 0, 1);
822 
823  AMS_Default(AMS1);
824 
825  // Re-Init AMS1 ( with no Home)
826  er = DB_InitAMS(AMS1, 1, DAS.StepM.power[AMS1][DAS.StepM.SM_A],
827  DAS.StepM.step[AMS1][DAS.StepM.SM_A], DAS.StepM.slope[AMS1][DAS.StepM.SM_A],
828  DAS.StepM.speed[AMS1][DAS.StepM.SM_A], DAS.StepM.power[AMS1][DAS.StepM.SM_B],
829  DAS.StepM.step[AMS1][DAS.StepM.SM_B], DAS.StepM.slope[AMS1][DAS.StepM.SM_B],
830  DAS.StepM.speed[AMS1][DAS.StepM.SM_B]);
831 
832  // Send Offet for Grating
833  if(DAS.Paramini.Offset[6] > 0) DIR[0] = 0;
834  else DIR[0] = 1;
835 
836  if(DAS.Paramini.Offset[6] != 0)
837  {
838  er = AMS_DoPos(AMS1, 0, DIR[0], 0, labs(DAS.Paramini.Offset[6]));
839  }
840  er = AMS_AzzeraCoord(AMS1, 1);
841  if(er) { Message("No Zero Coord Grating", er); }
842 
843  GRS.Wl = LookforWl_X(4358);//Lookfor4358();
844  sprintf(buf, "%d", 4358);
845  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[1], buf);
846  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS1][DAS.StepM.SM_B], "SYS\\ledGreen.bmp");
847  Status("Home for Grating..DONE");
848 
849  return 0;
850 }
851 
852 
854 {
855  int er, d;
856  char buf[40];
857  long count;
858  double t;
859  int FlgHomeFW = 1;
860  unsigned long st, et, x;
861 
862  sprintf(DXL.buftx, "*01000000"); //d = 12, buio --> senso orario
863  DXL_TxStr(DXL.buftx, strlen(DXL.buftx));
864  d = ACKLEN;
865  er = DXL_RxStr(buf, &d);
866 
867  st = GetTickCount();
868 
869  // Read input
870  d = AMS_chkbitsts(AMS2, 3);
871 
872  d = !d;
873 
874  if(d)
875  {
876  t = 10E6 / (DAS.StepM.speed_Hz[AMS2][DAS.StepM.SM_A] * 1000) ;
877  count = (long) t;
878  AMS_TrackOn(AMS2, 1, 0, count, 0);
879 
880 
881  if(DAS.DOption.amsprogbar)
882  D_VRange("Homing filter",0, 0, 0, 255);
883 
884  do
885  {
886  // Read input
887  d = AMS_chkbitsts(AMS2, 3);
888  MLoopWhileEvents(0);
889  if(d == 1)
890  {
891  er = AMS_TrackOff(AMS2, 1, 2);
892  FlgHomeFW = 0;
893  }
894 
895  /*************************************************************/
896  //For progress bar display
897  // D_Homing(DAS.Gui.ContrPanel.Albl_LS[0], 0, 2000, FlgHomeMir);
898  et = GetTickCount();
899  x = labs(et - st);
900 
901  //if((x % 10) == 0 && x > 0)
902  if(x > 0)
903  {
904  if(DAS.DOption.amsprogbar)
905  D_VRange(NULL, (long) x * 100 / 5000, 255, 0, 0 );
906  sprintf(buf, "%.1lf sec.", (double)fabs(((double)(labs(et - st) - 5000))/1000.0 ));
907  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[2], buf);
908  }
909  /***************************************************/
910  }while (FlgHomeFW);
911 
912  if(DAS.DOption.amsprogbar)
913  D_VRange(NULL, 100, 0,0,0);
914 
915  // Set final directions
916  AMS_dirfin(AMS2, 1, 0);
917  // Set default values
918  AMS_Default(AMS2);
919 
920  // Re-Init AMS2 ( with no Home)
921  er = DB_InitAMS(AMS2, 1, DAS.StepM.power[AMS2][DAS.StepM.SM_A],
922  DAS.StepM.step[AMS2][DAS.StepM.SM_A], DAS.StepM.slope[AMS2][DAS.StepM.SM_A],
923  DAS.StepM.speed[AMS2][DAS.StepM.SM_A], DAS.StepM.power[AMS2][DAS.StepM.SM_B],
924  DAS.StepM.step[AMS2][DAS.StepM.SM_B], DAS.StepM.slope[AMS2][DAS.StepM.SM_B],
925  DAS.StepM.speed[AMS2][DAS.StepM.SM_B]);
926 
927  }
928 
929  er = AMS_AzzeraCoord(AMS2, 0);
930  if(er) { Message("No Zero Coord FW", er); }
931 
932  FWS.Pos = 0;
933  sprintf(buf, "%s", "NULL");
934  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[2], buf);
935  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS2][DAS.StepM.SM_A], "SYS\\ledGreen.bmp");
936  Status("Home for Filter Wheel...DONE !");
937 
938  return 0;
939 }
940 
942 {
943  int er, d;
944  char buf[40];
945  long count;
946  double t;
947  int FlgHomeFW = 1;
948  unsigned long st, et, x;
949 
950  sprintf(DXL.buftx, "*00000100"); //d = 12, buio --> senso orario
951  DXL_TxStr(DXL.buftx, strlen(DXL.buftx));
952  d = ACKLEN;
953  er = DXL_RxStr(buf, &d);
954 
955  st = GetTickCount();
956 
957  // Read input
958  d = AMS_chkbitsts(AMS2, 1);
959 
960  d = !d;
961 
962  if(d)
963  {
964  t = 10E6 / (DAS.StepM.speed_Hz[AMS2][DAS.StepM.SM_A] * 1000) ;
965  count = (long) t;
966  AMS_TrackOn(AMS2, 0, 1, 0, count);
967 
968 
969  if(DAS.DOption.amsprogbar)
970  D_VRange("Homing ND filter",0, 0, 192, 255);
971 
972  do
973  {
974  // Read input
975  d = AMS_chkbitsts(AMS2, 1);
976  MLoopWhileEvents(0);
977  if(d == 1)
978  {
979  er = AMS_TrackOff(AMS2, 1, 1);
980  FlgHomeFW = 0;
981  }
982 
983  /*************************************************************/
984  //For progress bar display
985  // D_Homing(DAS.Gui.ContrPanel.Albl_LS[0], 0, 2000, FlgHomeMir);
986  et = GetTickCount();
987  x = labs(et - st);
988 
989  //if((x % 10) == 0 && x > 0)
990  if(x > 0)
991  {
992  if(DAS.DOption.amsprogbar)
993  D_VRange(NULL, (long) x * 100 / 5000, 255, 0, 0 );
994  sprintf(buf, "%.1lf sec.", (double)fabs(((double)(labs(et - st) - 5000))/1000.0 ));
995  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[3], buf);
996  }
997  /***************************************************/
998  }while (FlgHomeFW);
999 
1000  if(DAS.DOption.amsprogbar)
1001  D_VRange(NULL, 100, 0,0,0);
1002 
1003  // Set final directions
1004  AMS_dirfin(AMS2, 1, 1);
1005  // Set default values
1006  AMS_Default(AMS2);
1007 
1008  // Re-Init AMS2 ( with no Home)
1009  er = DB_InitAMS(AMS2, 1, DAS.StepM.power[AMS2][DAS.StepM.SM_A],
1010  DAS.StepM.step[AMS2][DAS.StepM.SM_A], DAS.StepM.slope[AMS2][DAS.StepM.SM_A],
1011  DAS.StepM.speed[AMS2][DAS.StepM.SM_A], DAS.StepM.power[AMS2][DAS.StepM.SM_B],
1012  DAS.StepM.step[AMS2][DAS.StepM.SM_B], DAS.StepM.slope[AMS2][DAS.StepM.SM_B],
1013  DAS.StepM.speed[AMS2][DAS.StepM.SM_B]);
1014 
1015  }
1016 
1017  er = AMS_AzzeraCoord(AMS2, 1);
1018  if(er) { Message("No Zero Coord ND FW", er); }
1019 
1020  FWS.Pos = 0;
1021  sprintf(buf, "%s", "NULL");
1022  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[3], buf);
1023  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS2][DAS.StepM.SM_B], "SYS\\ledGreen.bmp");
1024  Status("Home for ND Filter Wheel...DONE !");
1025 
1026  return 0;
1027 }
1028 
1029 /*
1030 int HomeFilterWheel(void)
1031 {
1032  int er, d;
1033  char buf[40];
1034  long count;
1035  double t;
1036  int FlgHomeFW = 1;
1037  unsigned long st, et, x;
1038 
1039  st = GetTickCount();
1040 
1041  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM3, "SYS\\ledoff.bmp");
1042  sprintf(buf, "%s", "Homing");
1043  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[2], buf);
1044  Status("Home for Filter Wheel...");
1045 
1046  // Polarita' degli home
1047  if(DAS.Paramini.EqType == LIS_)
1048  {
1049  sprintf(DXL.buftx, "*00000000"); //d = 10, buio --> senso orario
1050  DXL_TxStr(DXL.buftx, strlen(DXL.buftx));
1051  d = ACKLEN;
1052  er = DXL_RxStr(buf, &d);
1053  }
1054  else if (DAS.Paramini.EqType == SPATRAM || DAS.Paramini.EqType == GASCODNG || DAS.Paramini.EqType == SPATRAMPLUS || DAS.Paramini.EqType == TROPOGAS )
1055  {
1056  sprintf(DXL.buftx, "*01000000"); //d = 12, buio --> senso orario
1057  DXL_TxStr(DXL.buftx, strlen(DXL.buftx));
1058  d = ACKLEN;
1059  er = DXL_RxStr(buf, &d);
1060  }
1061  // Leggo gli input per fare Home della routa filtri
1062  sprintf(DXL.buftx, "/");
1063  DXL_TxStr(DXL.buftx, strlen(DXL.buftx));
1064  d = STS0LEN;
1065  er = DXL_RxStr(buf, &d);
1066  d = buf[1];
1067  if(d > '9') d -= 7;
1068  d -= 48;
1069  if((d & 8) == 0)
1070  {
1071  t = 10E6 / (2 * 500.0) - 1;
1072  count = (long) t;
1073  sprintf(DXL.buftx, "0%02X%08lX0000000000", 1, count);
1074  DXL_TxStr(DXL.buftx, strlen(DXL.buftx));
1075  d = ACKLEN;
1076  er = DXL_RxStr(buf, &d);
1077 
1078  D_VRange("Homing Filter Wheel",0, 0, 0, 255);
1079 
1080  do
1081  {
1082 
1083  // Leggo gli input
1084  sprintf(DXL.buftx, "/");
1085  DXL_TxStr(DXL.buftx, strlen(DXL.buftx));
1086  d = STS0LEN;
1087  er = DXL_RxStr(buf, &d);
1088  d = buf[1];
1089  if(d > '9') d -= 7;
1090  d -= 48;
1091  if((d & 8) != 0)
1092  {
1093 
1094  sprintf(DXL.buftx, "50101");
1095  DXL_TxStr(DXL.buftx, strlen(DXL.buftx));
1096  d = ACKLEN;
1097  er = DXL_RxStr(buf, &d);
1098  FlgHomeFW = 0;
1099  }
1100 /*************************************************************/
1101  //For progress bar display
1102 /* et = GetTickCount();
1103  x = labs(et - st);
1104 
1105  if((x % 10) == 0 && x > 0)
1106  {
1107  D_VRange(NULL, (long) x * 100 / 5000, 255, 0, 0 );
1108  sprintf(buf, "%.1lf sec.", (double) fabs(((double)(labs(et - st) - 5000))/1000.0 ));
1109  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[2], buf);
1110  }
1111 /*************************************************************/
1112 /* }while (FlgHomeFW);
1113 
1114  D_VRange(NULL, 100, 0,0,0);
1115 
1116  // Setto direzioni finali
1117  sprintf(DXL.buftx, "-0101");
1118  DXL_TxStr(DXL.buftx, strlen(DXL.buftx));
1119  d = ACKLEN;
1120  er = DXL_RxStr(buf, &d);
1121 
1122  // Set default values
1123  DXL_TxStr("A", 1);
1124  d = ACKLEN;
1125  er = DXL_RxStr(buf, &d);
1126 
1127  DXL.add = 1;
1128  // Re-Init AMS2 ( with no Home)
1129  DB_InitAMS(AMS2, 1, DAS.StepM.cop[DAS.StepM.SM3], DAS.StepM.step[DAS.StepM.SM3], DAS.StepM.slope[DAS.StepM.SM3], DAS.StepM.speed[DAS.StepM.SM3], 0, 0, 0, 0);
1130  }
1131  er = AMS_AzzeraCoord(AMS2, 0);
1132  if(er) { Message("No Zero Coord FW", er); }
1133 
1134  FWS.Pos = 0;
1135  sprintf(buf, "%s", "NULL");
1136  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[2], buf);
1137  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM3, "SYS\\ledGreen.bmp");
1138  Status("Home for Filter Wheel...DONE !");
1139 
1140  return 0;
1141 }
1142 */
1144 {
1145 
1146  int DIR[] = { 0, 0 };
1147 // long count;
1148 // double t;
1149  int er, d, FlgZenPos = 1,h = 0,k = 0;
1150  char buf[80];
1151  unsigned long st;
1152 
1153 
1154 
1155 
1156 
1157  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS3][DAS.StepM.SM_A], "SYS\\ledoff.bmp");
1158  sprintf(buf, "%s", "Homing");
1159  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[4], buf);
1160  Status("Home for Zenith...");
1161 
1162  st = GetTickCount();
1163 
1164  //Home bit
1165  d = AMS_chkbitsts(AMS3, 3);
1166  //EndRun 1 bit
1167  h = AMS_chkbitsts(AMS3, 6);
1168  //EndRun 2 bit
1169  k = AMS_chkbitsts(AMS3, 7);
1170 
1171  st = GetTickCount();
1172 
1173 
1174 
1175 
1176  if(DAS.StepM.hometype[AMS3][DAS.StepM.SM_A] == 0) //Home Standard
1177  {
1178  er = AMS_Home(AMS3, 1, 0);
1179  D_Homing(DAS.Gui.ContrPanel.Albl_LS[4], AMS3, DAS.StepM.SM_A, 5000);
1180  }
1181  if(DAS.StepM.hometype[AMS3][DAS.StepM.SM_B] == 1) //Home with Default
1182  {
1183  er = AMS_HomeDefault(AMS3, 1, 0);
1184  D_Homing(DAS.Gui.ContrPanel.Albl_LS[4], AMS3, DAS.StepM.SM_A, 5000);
1185  }
1186  //Home with tracking with setted values of speed and step/round
1187  if(DAS.StepM.hometype[AMS3][DAS.StepM.SM_A] == 2)
1188  {
1189  sprintf(buf, "Homing Zenith");
1190  er = HomeTrack(buf, AMS3, DAS.StepM.SM_A, 0);
1191  }
1192 
1193  AMS_dirfin(AMS3, 1, 0);
1194 
1195  AMS_Default(AMS3);
1196 
1197  // Re-Init AMS3 ( with no Home)
1198  er = DB_InitAMS(AMS3, 1, DAS.StepM.power[AMS3][DAS.StepM.SM_A],
1199  DAS.StepM.step[AMS3][DAS.StepM.SM_A], DAS.StepM.slope[AMS3][DAS.StepM.SM_A],
1200  DAS.StepM.speed[AMS3][DAS.StepM.SM_A], DAS.StepM.power[AMS3][DAS.StepM.SM_B],
1201  DAS.StepM.step[AMS3][DAS.StepM.SM_B], DAS.StepM.slope[AMS3][DAS.StepM.SM_B],
1202  DAS.StepM.speed[AMS3][DAS.StepM.SM_B]);
1203 
1204 
1205  ZST.Pos = 0;
1206 
1207  //SD_Zenith_H(-3);
1208  //ZST.Pos = 0;
1209 
1210  er = AMS_AzzeraCoord(AMS3, 0);
1211  if(er) { Message("No Zero Coord Zenith", er); }
1212 
1213  SD_Zenith_H(-90);
1214 
1215  //ZST.Pos = -90;
1216  //sprintf(buf, "%s", "-90.0");
1217 
1218  ZST.Pos = 0;
1219  sprintf(buf, "%s", "0.0");
1220  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[4], buf);
1221  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS3][DAS.StepM.SM_A], "SYS\\ledGreen.bmp");
1222  Status("Home for Zenith..DONE");
1223 
1224 
1225  return 0;
1226 }
1227 
1228 
1229 int HomeAzimFast(void)
1230 {
1231 
1232  int dir;
1233  long count;
1234  double t;
1235  int er, d, HomeOnGoing = 1;
1236  char buf[80];
1237  unsigned long st, et, x;
1238 
1239  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS3][DAS.StepM.SM_B], "SYS\\ledoff.bmp");
1240  sprintf(buf, "%s", "Homing");
1241  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[5], buf);
1242  Status("Home for Azimuth...");
1243 
1244  st = GetTickCount();
1245 
1246  d = AMS_chkbitsts(AMS3, 1);
1247  if (DAS.MIGE.type == 2)
1248  d=!d;
1249 
1250  if(d)
1251  {
1252  dir = 0;
1253  }
1254  else
1255  {
1256  dir = 1;
1257  }
1258 
1259  /**********************************/
1260  // First attempt (fast)
1261  /*§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§*/
1262  t = 10E6 / (2 * DAS.StepM.speed_Hz[AMS3][DAS.StepM.SM_B] * 1000) - 1;
1263  count = (long) t;
1264  AMS_TrackOn(AMS3, 0, dir, 0, count);
1265  if(DAS.DOption.amsprogbar)
1266  D_VRange("Homing Azimuth with Track(1)",0, 255, 0, 0);
1267 
1268  do
1269  {
1270  MLoopWhileEvents(0);
1271 
1272  d = AMS_chkbitsts(AMS3, 1);
1273  if (DAS.MIGE.type == 2)
1274  d=!d;
1275 
1276  if(dir == 0)
1277  {
1278  if(d == 0)
1279  {
1280  er = AMS_TrackOff(AMS3, 1, 1);
1281  HomeOnGoing = 0;
1282  }
1283  }
1284  if(dir)
1285  {
1286  if(d)
1287  {
1288  er = AMS_TrackOff(AMS3, 1, 1);
1289  HomeOnGoing = 0;
1290  }
1291  }
1292  //For progress bar display
1293  et = GetTickCount();
1294  x = labs(et - st);
1295  //if((x % 10) == 0 && x > 0)
1296  if(x > 0)
1297  {
1298  if(DAS.DOption.amsprogbar)
1299  D_VRange(NULL, (long) x * 100 / 35000, 255, 0, 0 );
1300  sprintf(buf, "Max Time Left:%.1lf", (double)fabs(((double)(labs(et - st) - 35000))/1000.0 ));
1301  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[5], buf);
1302  }
1303 
1304  }while (HomeOnGoing);
1305  /*§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§*/
1306 
1307  if(DAS.DOption.amsprogbar)
1308  D_VRange(NULL, 100, 0,0,0);
1309 
1310  // Second attempt (slow in opposite direction)
1311  /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
1312  HomeOnGoing = 1;
1313  dir = !dir;
1314  t = 10E6 / (2 * DAS.StepM.speed_Hz[AMS3][DAS.StepM.SM_B] * 1000 / 20) - 1;
1315  count = (long) t;
1316 
1317  AMS_TrackOn(AMS3, 0, dir, 0, count);
1318  if(DAS.DOption.amsprogbar)
1319  D_VRange("Homing with tracking (2)",0, 255, 255, 0);
1320  st = GetTickCount();
1321  do
1322  {
1323  d = AMS_chkbitsts(AMS3, 1);
1324  if (DAS.MIGE.type == 2)
1325  d = !d;
1326 
1327  if(dir == 0)
1328  {
1329  if(d == 0)
1330  {
1331  er = AMS_TrackOff(AMS3, 1, 1);
1332  HomeOnGoing = 0;
1333  }
1334  }
1335  if(dir)
1336  {
1337  if(d)
1338  {
1339  er = AMS_TrackOff(AMS3, 1, 1);
1340  HomeOnGoing = 0;
1341  }
1342  }
1343  //For progress bar display
1344  et = GetTickCount();
1345  x = labs(et - st);
1346  //if((x % 10) == 0 && x > 0)
1347  if(x > 0)
1348  {
1349  if(DAS.DOption.amsprogbar)
1350  D_VRange(NULL, (long) x * 100 / 35000, 255, 0, 0 );
1351  sprintf(buf, "Max Time Left:%.1lf", (double)fabs(((double)(labs(et - st) - 35000))/1000.0 ));
1352  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[5], buf);
1353  }
1354  }while (HomeOnGoing);
1355 
1356  if(DAS.DOption.amsprogbar)
1357  D_VRange(NULL, 100, 0,0,0);
1358  /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
1359 
1360  //Reset the default values of the divider
1361  er = AMS_Divisore(AMS3, 40000,40000);
1362 
1363 
1364 
1365  AMS_Default(AMS3);
1366 
1367  // Re-Init AMS3 ( with no Home)
1368  er = DB_InitAMS(AMS3, 1, DAS.StepM.power[AMS3][DAS.StepM.SM_A],
1369  DAS.StepM.step[AMS3][DAS.StepM.SM_A], DAS.StepM.slope[AMS3][DAS.StepM.SM_A],
1370  DAS.StepM.speed[AMS3][DAS.StepM.SM_A], DAS.StepM.power[AMS3][DAS.StepM.SM_B],
1371  DAS.StepM.step[AMS3][DAS.StepM.SM_B], DAS.StepM.slope[AMS3][DAS.StepM.SM_B],
1372  DAS.StepM.speed[AMS3][DAS.StepM.SM_B]);
1373 
1374  er = AMS_AzzeraCoord(AMS3, 1);
1375  if(er) { Message("No Zero Coord Azimuth", er); }
1376 
1377  AMS_dirfin(AMS3, 0, 1);
1378 
1379 
1380  AST.Pos = 0.0; //for solar tracker
1381  sprintf(buf, "%.1lf %s", AST.Pos, "°N");
1382  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[5], buf);
1383  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS3][DAS.StepM.SM_B], "SYS\\ledGreen.bmp");
1384  Status("Home for Azimuth..DONE");
1385 
1386 
1387  return 0;
1388 }
1389 
1390 
1391 int DB_InitAMS(int nid, int mod, int powera, int stepa, int slopea, int speeda, int powerb, int stepb, int slopeb, int speedb)
1392 {
1393 
1394  int er = 0, d;
1395  char buf[80];
1396  long l;
1397  char *stopstring;
1398 
1399 
1400  DXL.add = nid;
1401 // if (mod != 1)
1402 // {
1403  //****************************************************
1404  // Set final directions
1405  sprintf(DXL.buftx, "-0000");
1406  DXL_TxStr(DXL.buftx, strlen(DXL.buftx));
1407  d = ACKLEN;
1408  er = DXL_RxStr(buf, &d);
1409  // Set default values
1410  DXL_TxStr("A", 1);
1411  d = ACKLEN;
1412  er = DXL_RxStr(buf, &d);
1413  //*****************************************************
1414 // }
1415  // Firmware Revision
1416  er = AMS_firmrev(nid);
1417  d = atoi(DXL.bufrx);
1418  l = strtol( DXL.bufrx, &stopstring, 16 );
1419  DAS.StepM.firmrev[nid] = l/10;
1420 
1421 
1422  if(er == 0)
1423  {
1424  // Send power
1425  er = AMS_Power(nid, powera, powerb);
1426  if(er == 0)
1427  {
1428  // Send step
1429  er = AMS_Step(nid, stepa, stepb);
1430  if(er == 0)
1431  {
1432  // Send slope
1433  er = AMS_Slope(nid, slopea, slopeb);
1434  if(er == 0)
1435  {
1436  // Send speed
1437  er = AMS_Speed(nid, speeda, speedb);
1438  if(er == 0)
1439  {
1440  // Enable slope
1441 // sprintf(DXL.buftx, ";%02X%02X", 0, 0);
1442 // DXL_TxStr(DXL.buftx, 5);
1443 // d = ACKLEN;
1444 // er = DXL_RxStr(buf, &d);
1445  if(er == 0)
1446  {
1447  if(nid == 0 && mod == 0)
1448  {
1449  HomeMirror();
1450 // writelogmotor(1, 0, er, 0, 0, nid);
1451 
1452  HomeGratingFast(0);
1453 // writelogmotor(1, 1, er, 0, 0, nid);
1454  }
1455  if(nid == 1 && mod == 0)
1456  {
1457  HomeFiltersFast();
1458 
1459  if (DAS.DOption.filtertype == FDOUBLE)
1461  //HomeFilterWheel();
1462 // writelogmotor(1, 2, er, 0, 0, nid);
1463  }
1464  if(nid == 0 && mod == 2)
1465  {
1466  HomeMirror();
1467 // writelogmotor(1, 0, er, 0, 0, nid);
1468  }
1469  if(nid == 0 && mod == 3)
1470  {
1471  HomeGratingFast(0);
1472 // writelogmotor(1, 1, er, 0, 0, nid);
1473  }
1474  if(nid == 1 && mod == 4)
1475  {
1476  //HomeFilterWheel();
1477  HomeFiltersFast();
1478 // writelogmotor(1, 2, er, 0, 0, nid);
1479 
1480  }
1481  if(nid == 1 && mod == 7)
1482  {
1483  //HomeFilterWheel();
1485 // writelogmotor(1, 2, er, 0, 0, nid);
1486 
1487  }
1488  if(nid == 2 && mod == 0)
1489  {
1490 
1491  HomeZenithFast();
1492 // writelogmotor(1, 0, er, 0, 0, nid);
1493 
1494  HomeAzimFast();
1495 // writelogmotor(1, 1, er, 0, 0, nid);
1496  }
1497  if(nid == 2 && mod == 5)
1498  {
1499  HomeZenithFast();
1500 // writelogmotor(1, 0, er, 0, 0, nid);
1501  }
1502  if(nid == 2 && mod == 6)
1503  {
1504  HomeAzimFast();
1505 // writelogmotor(1, 1, er, 0, 0, nid);
1506  }
1507  }
1508  else
1509  {
1510  //Slope not enabled
1511  AMS_Error(6);
1512  }
1513  }
1514  else
1515  {
1516  //speed not sent
1517  AMS_Error(5);
1518  }
1519  }
1520  else
1521  {
1522  //Slope not sent
1523  AMS_Error(4);
1524  }
1525  }
1526  else
1527  {
1528  //step not sent
1529  AMS_Error(3);
1530  }
1531  }
1532  else
1533  {
1534  //Power not sent
1535  AMS_Error(2);
1536  }
1537  }
1538  else
1539  {
1540  if(nid == 0)
1541  {
1542  //AMS1 not found
1543  AMS_Error(0);
1544  return 1;
1545  }
1546  if(nid == 1)
1547  {
1548  //AMS2 not found
1549  AMS_Error(1);
1550  return 1;
1551  }
1552  if(nid == 2)
1553  {
1554  //AMS3 not found
1555  AMS_Error(7);
1556  return 1;
1557  }
1558 
1559  }
1560 
1561  if(er)
1562  er = SioReset(DXL.com, 1024, 1024);
1563 
1564  return 0;
1565 
1566 }
1567 
1568 void FPGACB(void)
1569 {
1570  char buf[80];
1571  int d, er;
1572 
1573  DXL_TxStr("B", 1);
1574  d = STS0LEN;
1575  er = DXL_RxStr(DXL.bufrx, &d);
1576 
1577  sprintf(buf, "FPGA ID: %s", DXL.bufrx);
1578  Message(buf, er);
1579 }
1580 
1581 //mod = 1 init COM
1582 //mod = 0 do NOT Init COM
1583 
1584 int DB_InitMotor(int mod)
1585 {
1586 
1587  char buf[80];
1588  int er = 0;
1589  int ans = 0;
1590  //int AMS1 = 0;
1591  //int AMS2 = 1;
1592 // ATTENZIONE - MOTORI:
1593 // SM1 = Stepper motor per specchio d'ingresso (MOTORE A di AMS1 (id=0)
1594 // SM2 = Stepper motor per reticolo (MOTORE B di AMS1 (id=0)
1595 // SM3 = Stepper motor per ruota filtri (MOTORE A di AMS2 (id=1)
1596 // SM4 = If CONNECTED Neutral density Filter Wheel (Motor B AMS2 (id=1)
1597 // SM5 = Stepper motor per reticolo (MOTORE A di AMS3 (id=2)
1598 // SM6 = Stepper motor per ruota filtri (MOTORE B di AMS3 (id=2)
1599 
1600 if(mod)
1601 {
1602 
1603  if((DAS.Paramini.EqType == LIS_) ||
1604  (DAS.Paramini.EqType == TROPOGAS))
1605  // init COM1
1606  er = DB_InitCOM(COM1 );
1607  else if (DAS.Paramini.EqType == SPATRAM ||
1608  DAS.Paramini.EqType == SPATRAMPLUS )
1609  er = DB_InitCOM(COM2);
1610  else if ((DAS.Paramini.EqType == GASCODNG1) ||
1611  (DAS.Paramini.EqType == GASCODNG2) ||
1612  (DAS.Paramini.EqType == GASCODNG3) ||
1613  (DAS.Paramini.EqType == GASCODNG4) ||
1614  (DAS.Paramini.EqType == SPATRAM3) ||
1615  (DAS.Paramini.EqType == SPATRAM2))
1616  {
1617  // init COM2
1618  er = DB_InitCOM(COM2);
1619  }
1620  else
1621  {
1622  sprintf(buf, "For this Equipment the COM Port is UNKNOWN\nPlease Contact DANBO!!!!");
1623  er = MMessageDialog("DAS information", buf, "Ok", NULL);
1624  if (!er)
1625  {
1626  return 1;
1627  }
1628 
1629  }
1630 
1631  if(er)
1632  ComErrors(er);
1633 }
1634  if (er == 0)
1635  {
1636  // Init AMS1
1637  er = DB_InitAMS(AMS1, 0, DAS.StepM.power[AMS1][DAS.StepM.SM_A],
1638  DAS.StepM.step[AMS1][DAS.StepM.SM_A], DAS.StepM.slope[AMS1][DAS.StepM.SM_A],
1639  DAS.StepM.speed[AMS1][DAS.StepM.SM_A], DAS.StepM.power[AMS1][DAS.StepM.SM_B],
1640  DAS.StepM.step[AMS1][DAS.StepM.SM_B], DAS.StepM.slope[AMS1][DAS.StepM.SM_B],
1641  DAS.StepM.speed[AMS1][DAS.StepM.SM_B]);
1642 
1643  // Init AMS2
1644  er = DB_InitAMS(AMS2, 0, DAS.StepM.power[AMS2][DAS.StepM.SM_A],
1645  DAS.StepM.step[AMS2][DAS.StepM.SM_A], DAS.StepM.slope[AMS2][DAS.StepM.SM_A],
1646  DAS.StepM.speed[AMS2][DAS.StepM.SM_A], DAS.StepM.power[AMS2][DAS.StepM.SM_B],
1647  DAS.StepM.step[AMS2][DAS.StepM.SM_B], DAS.StepM.slope[AMS2][DAS.StepM.SM_B],
1648  DAS.StepM.speed[AMS2][DAS.StepM.SM_B]);
1649 
1650  if( DAS.Paramini.EqType == TROPOGAS ||
1651  DAS.Paramini.EqType == SPATRAMPLUS ||
1652  DAS.Paramini.EqType == GASCODNG1 ||
1653  DAS.Paramini.EqType == GASCODNG2 ||
1654  DAS.Paramini.EqType == GASCODNG3 ||
1655  DAS.Paramini.EqType == GASCODNG4 ||
1656  DAS.Paramini.EqType == SPATRAM2 ||
1657  DAS.Paramini.EqType == SPATRAM3)
1658  {
1659  if(DAS.MIGE.linked)
1660  {
1661  // Init AMS3
1662  // for conditionate initializxation also for the PRGFILE execution mode
1663  //if(DAS.Flag.exemode == MANUAL || DAS.Flag.exemode == DBDEMO|| DAS.Flag.exemode == TESTAMS|| DAS.Flag.exemode == PRGFILE)
1664  if(DAS.Flag.exemode == MANUAL || DAS.Flag.exemode == DBDEMO || DAS.Flag.exemode == TESTAMS)
1665  ans = MMessageDialog("", "Do you want to ENABLE the ALTAZIMUTH Platform ?", "Yes", "No", NULL);
1666  if(!ans)
1667  {
1668  er = DB_InitAMS(AMS3, 0, DAS.StepM.power[AMS3][DAS.StepM.SM_A],
1669  DAS.StepM.step[AMS3][DAS.StepM.SM_A], DAS.StepM.slope[AMS3][DAS.StepM.SM_A],
1670  DAS.StepM.speed[AMS3][DAS.StepM.SM_A], DAS.StepM.power[AMS3][DAS.StepM.SM_B],
1671  DAS.StepM.step[AMS3][DAS.StepM.SM_B], DAS.StepM.slope[AMS3][DAS.StepM.SM_B],
1672  DAS.StepM.speed[AMS3][DAS.StepM.SM_B]);
1673 
1674  if( DAS.Paramini.EqType == GASCODNG2 ||
1675  DAS.Paramini.EqType == GASCODNG3 )
1676  {
1677  //set final direction
1678  AMS_dirfin(AMS3, 0, 1);
1679 
1680 
1681  }
1682  }
1683  }
1684  else
1685  {
1686  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS3][DAS.StepM.SM_A], "SYS\\ledoffg.bmp");
1687  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS3][DAS.StepM.SM_B], "SYS\\ledoffg.bmp");
1688  // MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM5, "SYS\\ledoffg.bmp");
1689  // MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM6, "SYS\\ledoffg.bmp");
1690  }
1691  }
1692  }
1693  if (er)
1694  {
1695  FLAG.AMSPres = 1;
1696 
1697  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS1][DAS.StepM.SM_A], "SYS\\ledoffg.bmp");
1698  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS1][DAS.StepM.SM_B], "SYS\\ledoffg.bmp");
1699  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS2][DAS.StepM.SM_A], "SYS\\ledoffg.bmp");
1700  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS2][DAS.StepM.SM_B], "SYS\\ledoffg.bmp");
1701  if((DAS.Paramini.EqType == TROPOGAS))
1702  {
1703  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS3][DAS.StepM.SM_A], "SYS\\ledoffg.bmp");
1704  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS3][DAS.StepM.SM_B], "SYS\\ledoffg.bmp");
1705  }
1706 
1707  return 1;
1708  }
1709  else
1710  {
1711  FLAG.AMSPres = 0;
1712  return 0;
1713  }
1714 }
int AMS_Divisore(int id, unsigned long par1, unsigned long par2)
Definition: Dxl.c:946
stepm StepM
Stepper motors parameters structure.
#define SPATRAM
SPectrometer for Atmospheric TRAcers Measurements - CGE-UE Portugal.
Status of the Zenith .
gui Gui
Graphic User Interface Structure.
U32 FDL_PCI_Index
(R/W) Index selector of all available FDL-PCI. 0 - 7 range.
Definition: dcldef.h:1070
int hometype[AMSMAX][2]
#define WS_NONE
Definition: Mguidefs.h:956
#define SF_NO_RESIZE
Definition: Mguidefs.h:1038
MOBJECT LedSM[AMSMAX][2]
Leds for stepper motors status.
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 MRefreshTimeout(TIMEOUT_ID *pid, CARD32 msec, TIMEOUT_CB cb, void *ud)
double firmrev[AMSMAX]
Firmware Revision.
int D_Homing(MOBJECT p, int id, int sm, int tout)
Definition: Init.c:470
int IDX
Number of sensible horizontal pixels.
Definition: DAS_Spat.c:118
MOBJECT Albl_LS[8]
Active Control Panel Labels for LIS status.
MOBJECT MCreatePixmapFromFile(MOBJECT parent, const char *fname)
#define Baud19200
Definition: WSC.H:120
int Server
Definition: DAS_Spat.c:253
#define BI_TILED
Definition: Mguidefs.h:945
dil DIL
Definition: 2DPlot.c:26
int AMS_Slope(int id, int slopea, int slopeb)
Set slope to the Stepper motors Procedure for setting the slope fot the Stepper Motors.
Definition: Dxl.c:368
AzimuthSt AST
Azimuth.
Definition: Init.c:27
void MLoopWhileEvents(int discard)
optionini DOption
Options for DAS execution.
#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
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
#define TESTCCD
execution for testing CCD Camera
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
void __stdcall DD_VRange(const char *str, int perc, int Port)
Definition: Utils.c:153
int HomeFiltersFast(void)
(Fastest) Fliter wheel in the reference Position. The Fliter wheel reaches the reference Position...
Definition: Init.c:853
int AMS_TrackOn(int id, int adir, int bdir, unsigned long acount, unsigned long bcount)
Activate tracking Procedure for Stepper Motor tracking activation.
Definition: Dxl.c:404
#define ACKLEN
CTYPE const char DLL_P DC_CCDtoName(int CCDCode, int camera)
CTYPE int DLL DC_SetGain(int Gain, int Camera)
Change the ratio between ADU and electrons. Procedure that allows you to set ccd gains, according to preset values in four various values.
#define SF_NO_MAXIMIZE
Definition: Mguidefs.h:1034
Stepper motors parameters structure .
C_DEF void DI_Regen(int s)
int SM_A
Motor A (su Y11) respectively: ID=0->InputMirror,ID=1->FilterWheel,ID=2->Zenith.
int HomeNDFiltersFast(void)
(Fastest) ND Fliter wheel in the reference Position. The ND Fliter wheel reaches the reference Positi...
Definition: Init.c:941
int AMS_Home(int id, int mota, int motb)
Home position for the selected motor the home position is reached with the standard parameters (1KHz...
Definition: Dxl.c:549
DXL structure. Structure for the serial communication with the AMS adapter.
Definition: DXL.H:16
void MPixmapSetImageFile(MOBJECT pixmap, const char *fname)
das structure (contain all the previous structures) .
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
U32 CCDType
(R/W) Used CCD CCD code definitions
Definition: dcldef.h:1066
#define TESTSZAMODE
execution driven by SZAPRG file
DXL_par DXL
DXL structure.
Definition: Init.c:21
#define DOASMODE
execution for DOAS Processing
CTYPE void DLL DC_RWData(int LibraryVariable, int rw, void *data, int Camera)
Procedure that allows read/write operation on a variable used into the library.
int Pos
Mirror Current Position.
flag Flag
Structure for different flags.
char HOMEDIRECTORY[_MAX_PATH]
Definition: bildef.h:200
int filtertype
type of installed filter module: 0=Simple-SM3, 1=Double-SM3+SM4, 2=simpleplus-SM3+TM) ...
U16 * Imat
Definition: Dildef.h:286
int AMS_firmrev(int id)
Firmware Revision Number .
Definition: Dxl.c:475
#define DBDEMO
execution in demo mode
int Offset[16]
Offset of the hardware devices (Input Mirror (5), Grating, Filter Wheel...)
das DAS
DAS structure.
Definition: Init.c:34
void CBExpo(MOBJECT p, void *od, void *ad)
Close the Exposure shell and stop the image acquisition.
Definition: Init.c:43
int slope[AMSMAX][2]
Stepper Motors Slope.
#define READ_DATA
Read data.
Definition: dcldef.h:884
int AMS_Step(int id, int stepa, int stepb)
Set stepping for the Stepper motors Procedure for setting steps for the Stepper Motors.
Definition: Dxl.c:349
MOBJECT lbl_Par[11]
Parametric Labels of the Control Panel.
char * CodeEq2Name(int code)
code Equipment to Name
Definition: Load.c:371
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
#define SF_NO_CLOSE
Definition: Mguidefs.h:1032
#define SF_NO_MINIMIZE
Definition: Mguidefs.h:1036
C_DEF int DI_CloseImage(int s)
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
spectrumheader SPH
Spectrum Header Structure.
Definition: bildef.h:256
int type
S16 dx
Num. of X pixels.
Definition: dcldef.h:1022
img Mat[MAXIMG]
Definition: Dildef.h:552
#define PTF_INFO
R/W ptf internal library structure.
Definition: dcldef.h:876
#define TEMPORIZED
execution driven by MASTER file
int DB_InitCOM(int comn)
Init selected COM port.
Definition: Init.c:452
float multiplier[AMSMAX][2]
multiplier, > 0 multiplier, < 0 demultiplier
#define SZAMASTERM
execution driven by MASTERSZA file ( there is the possibility to distinguish between AM and PM measur...
void MObjectSetText(MOBJECT obj, const char *text)
int HomeZenithFast(void)
Home for Zenith Axis.
Definition: Init.c:1143
image Img
Definition: Dildef.h:675
int Pos
Filter Wheel current Position.
#define COM2
Definition: COMM.H:80
int GRATHOME
Home for Grating ID.
flag FLAG
flags structure
Definition: Init.c:22
#define CCDHANDLE
Enable background activity.
Definition: dcldef.h:396
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
#define STS0LEN
NoMangle int DLL_IMPORT_EXPORT SioReset(int, int, int)
#define LIS_
Lampedusa Island Spectrometer - ENEA.
short unsigned U16
2 byte without sign, range 0-65535
Definition: dcldef.h:375
C_DEF void DI_OpenDigit(void)
Control Flags.
int Wl
Grating Wavelength.
int AMS_TestHome(int id, int par1)
verify if the home position has been reached
Definition: Dxl.c:1042
#define CCD_INFO
R/W ccd internal library structure.
Definition: dcldef.h:875
int HomeAzimFast(void)
Home for Azimuth Axis.
Definition: Init.c:1229
#define TROPOGAS
TROPOspheric Gas Analyzer Spectrometer.
MOBJECT LblExpP[7]
Label for presetted time exposure.
char bufrx[1024]
Rx buffer.
Definition: DXL.H:20
MOBJECT MDCreateExpo(char *tit)
Create Exposure/countdown shell. Procedure that build the Exposure/countdown shell during the calcula...
Definition: Init.c:55
int add
Peripheral address.
Definition: DXL.H:19
#define FDOUBLE
double filter wheel
CTYPE void DLL DC_SetTemp(double TargetTemperature, int Scale, int Camera)
Procedure that turns the camera cooler on and allows you to set an operative temperature of the CCD...
CTYPE void DLL DC_Close(int Camera)
Shuts down the control operations of the camera. Procedure that shuts down the control operations of ...
d_fileman DFILEM
Definition: bildef.h:257
int AMS_HomeDefault(int id, int mota, int motb)
Definition: Dxl.c:567
int DB_InitMotor(int mod)
Initialize AMS. Procedure that initialize the parameters for the AMS&#39;s devices.
Definition: Init.c:1584
#define OFFLINEPLOT
execution for archived data visualisation
unsigned short * ImatDark
buffer for the dark image
Definition: DAS_Spatram.h:3045
#define GASCODNG2
GASCODNG 2 (with ATX power supply & HiresIV)
int WhoSys(void)
Definition: DFileMan.c:306
void MObjectSetBackgroundImageFile(MOBJECT obj, const char *fname, int mode)
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.
CTYPE void DLL DC_SetBinning(int HorValue, int VerValue, int Camera)
Set the horizontal and vertical binning value. This procedure accepts arbitrary values in the range b...
int LoadDB_DefectPixel(char *buff)
Load Defective pixel mask. Procedure that load the Defective pixel mask in the file {homedir}/config/...
Definition: Load.c:182
int DXL_Close(void)
Close COM.
Definition: Dxl.c:1258
CTYPE void DLL DC_BrkFlg(int camera)
#define SPATRAMPLUS
As SPATRAM plus AltAzimuth platform.
unsigned long divider[AMSMAX][2]
Divider for the frequency.
char CONFIGDIREQUIPMENT[_MAX_PATH]
Definition: bildef.h:208
void Status(char *tit)
Writes information&#39;s on the Status label .
Definition: Load.c:1556
mige MIGE
CTYPE void DLL DC_OpenByConfig(config *CameraConfig, int StartMode, DTA1_CB CountDownCallBack, DTA2_CB StatusBarCallBack)
Open the camera. Open the camera using the settings specified in CameraConfig structure data (see con...
#define GRAT_TASK_TIME
Grating Home.
#define GASCODNG3
GASCODNG 3 (with ATX power supply & HiresIV)
stepm STEPM
Stepper Motors.
Definition: Init.c:25
#define PRGFILE
execution driven by *.prg file
MOBJECT MCreateColForm(MOBJECT parent)
int AMS_Power(int id, int powa, int powb)
Set Power for AMS Procedure for setting the user choosed power to the selected AMS adapter...
Definition: Dxl.c:326
int IDY
Number of sensible vertical pixels.
Definition: DAS_Spat.c:119
void __stdcall ShowDown(const char *str, int port)
Shows the countdown. Procedure for the visualisation of the countdown.
Definition: Init.c:98
#define GASCODNG1
GASCODNG 1 (with ATX power supply & HiresIV)
Function prototypes.
#define GASCODNG4
GASCODNG 4.
int amsprogbar
display/hide prograssion bar, 0 = Hide, 1 = display
#define _MAX_PATH
Definition: Dildef.h:202
ccd DC_CCD
CCD settings.
Definition: Init.c:30
MOBJECT MCreateShell(const char *title, int flags)
int MMessageDialog(const char *t, const char *msg, const char *btn1, const char *btn2,...)
S16 dy
Num. of Y pixels.
Definition: dcldef.h:1023
int linked
void ComErrors(int w)
Alerts for COM errors Creates a message window reporting the number of the error. ...
Definition: Errors.c:164
ids IDS
ID tasks.
Definition: DAS_Spat.c:54
int DXL_Open(int addr, int com, int baud)
Open COM.
Definition: Dxl.c:1243
C_DEF void DI_RunHisto(void)
void Message(char *str, int er)
Create a message shell for the AMS errors (Debug Use). .
Definition: Dxl.c:1085
#define SPATRAM3
SPATRAM3.
CTYPE int DLL DC_Status(int Camera)
Return the status of the last operations performed on the camera. This procedure allows you to check ...
MirrorSt MIS
Mirror.
Definition: DAS_Spat.c:61
int AMS_Speed(int id, int speeda, int speedb)
Set speed to the Stepper motors Procedure for setting speed for the Stepper Motors.
Definition: Dxl.c:386
C_DEF int DI_Init(int mod)
Function prototypes.
#define COM1
Definition: COMM.H:79
ZenithSt ZST
Zenith.
Definition: Init.c:26
int DB_InitCamera(int mod)
Initialize Camera Parameters. Procedure that initialize the CCD Camera.
Definition: Init.c:170
#define SZAMODE
execution driven by SZAPRG file
int SD_Zenith_H(float ang)
Definition: Spat_Device.c:2816
bil BIL
Definition: 2DPlot.c:28
int SM_B
Motor B (su Y12) respectively: ID=0->Grating,ID=1->Not Connected,ID=2->Azimuth.
CTYPE void DLL DC_SetPathName(char *Path)
Set the pathname for all dcl files.
#define CELSIUS
Return CCD temperature in Celsius.
Definition: dcldef.h:449
static double p
Definition: SOLPOS.C:131
CTYPE void DLL DC_SetPower(double CoolerPower, int Camera)
Procedure that allows you to set the cooler power. Procedure that allows you to set the power (%) of ...
config Cfg
Camera controls & Options.
Definition: Init.c:32
CTYPE int DLL DC_OpenPar(int Platform, int Sensor, int Camera)
Procedure that initializes dcl internal data structure. Procedure that initializes the DC_HP and DC_C...
int pixcorr
Flag to set defective pixel correction: 0=NOT Corrected, 1=Corrected.
#define CLEARCCD
Clear CCD before acquire.
Definition: dcldef.h:405
controlpanel ContrPanel
Control Panel Structure.
int AMS_TrackOff(int id, int amot, int bmot)
tracking off Procedure for Stepper Motor tracking de-activation
Definition: Dxl.c:422
void AMS_Error(int w)
Alerts for AMS errors Creates a message window reporting the number of the error. ...
Definition: Errors.c:254
paramini PARAM
Param.ini.
Definition: Init.c:23
int AMS_AzzeraCoord(int id, int mtr)
Set to zero the number of steps on the selected motor Set to zero the number of steps on the selecte...
Definition: Dxl.c:439
int imgtype
Flag to set Image type: 0=MONOINT, 1=RGB.
CTYPE const char DLL_P DC_PTFtoName(int PlatFormCode, int camera)
long * AVGmat
buffer for averaging measurements
int HomeMirror(void)
Input Mirror in the reference Position. The Input Mirror reaches the reference Position.
Definition: Init.c:685
void MFormSetSpacing(MOBJECT p, int offset)
void MPButtonSetCallback(MOBJECT button, MGUI_CB cb, void *data)
#define AMS1
AMS1 address.
int AMS_chkbitsts(int id, int bitn)
check bit status Procedure for the determination of the bit number status.
Definition: Dxl.c:192
void FPGACB(void)
Definition: Init.c:1568
MIMAGE digit[13]
Definition: Dildef.h:624
graph Graph
Definition: Dildef.h:676
static double st
Definition: SOLPOS.C:142
int speed[AMSMAX][2]
Stepper Motors Speed.
ptf DC_HP
Platform settings.
Definition: Init.c:31
int step[AMSMAX][2]
Stepper Motors Step.
void * MOBJECT
Definition: Mguidefs.h:192
C_DEF void DI_WriteDigit(MOBJECT *pix, char *fmt)
double speed_Hz[AMSMAX][2]
Stepper Motors Speed [Hz].
int DB_InitDil(void)
Initialize DIL. Procedure that initialize the DTA Imaging library.
Definition: Init.c:112
Definition: dcldef.h:1020
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...
int AMS_dirfin(int id, int dira, int dirb)
Set Final Directions .
Definition: Dxl.c:457
C_DEF int DI_ImageProperties(int srv, U16 dx, U16 dy, U16 wx, U16 wy, U16 ifmt, U16 sts, char *tit, int pix, int pixy, int mode)
Definition: dcldef.h:1043
CTYPE int DLL DC_LoadCameraConfig(const char *PathName, config *CameraConfig)
Load camera configuration from a specified file.
C_DEF int DI_PathExist(char *path)
int EqType
Spectrometer Type.
int com
Comunication port.
Definition: DXL.H:17
unsigned short * AllocUSMat(int hp, int vp)
Definition: Spat_Plot.c:1994
CTYPE double DLL DC_GetPower(int Camera)
Return current cooler power. Procedure that allows you to read the power (%) of the cooler currently ...
void MObjectSetTransparency(MOBJECT obj, CARD8 level)
double Pos
Azimuth Current Position.
U32 Platform
(R/W) Platform code Camera platform definitions
Definition: dcldef.h:1065
int HomeTrack(char *buf, int id, int sm, int mode)
Definition: Init.c:518
int DB_CloseCOM(void)
Close the previously opened COM port.
Definition: Init.c:460
C_DEF int DI_FileExist(char *tit)
double Pos
Zenith Current Position.
Status of the Azimuth .
MOBJECT MCreatePixmapFromData(MOBJECT parent, MIMAGE data)
float SMfraz(int t)
denominator value of the stepping ratio
Definition: Spat_Device.c:129
int AMS_DoPos(int id, int dira, int dirb, unsigned long stepa, unsigned long stepb)
Execute Positioning Execute Stepper positioning. Make all the control on the status of the selected m...
Definition: Dxl.c:644
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
MOBJECT MCreateImagePButtonExt(MOBJECT parent, const char *npf, const char *apf, const char *upf, const char *non, const char *aon, const char *uon)
double ITemp
CCD Target Temperature.
MOBJECT LblExpD[7]
Label for time exposure countdown.
int AMSPres
AMS Presence: 0 = AMS FOUND; 1 = AMS NOT FOUND.
int exemode
Set the Execution MODE (Execution modes)
FilterWheelSt FWS
Filter Wheel.
Definition: DAS_Spat.c:57
#define AMS3
AMS3 address.
GratingSt GRS
Definition: CreateForms.c:82
#define TESTAMS
execution for testing AMS&#39;s devices
#define TEMPHANDLE
Temperature control enabled.
Definition: dcldef.h:398
#define MANUAL
execution in manual mode (for lab use)
C_DEF int DI_OpenImage(U16 dx, U16 dy, U16 ifmt, U16 type, char *tit)
S16 attrib
Definition: Dildef.h:279
char DEFPIXFILENAME[_MAX_PATH]
defective pixel filename with path
int LookforWl_X(int x)
Definition: Procedures.c:2295
int power[AMSMAX][2]
Stepper Motors Power.
marconi Marconi
CCD Sensor struct.
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
______________________________________________________________________________________
Generated on Mon Sep 18 2017 11:44:09 for DAS - Rel. 3.1.6 - 18/09/2017.