DAS  3.1.6 - 18/09/2017
Functions | Variables
Init.c File Reference

Functions executed at DAS start-up. More...

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "mgui.h"
#include "DAS_Spatram.h"
#include "dcl.h"
#include "dil.h"
#include "wsc.h"
#include "dxl.h"
#include "bil.h"
#include "portio32.h"
+ Include dependency graph for Init.c:

Go to the source code of this file.

Functions

void CBExpo (MOBJECT p, void *od, void *ad)
 Close the Exposure shell and stop the image acquisition. More...
 
int D_Homing (MOBJECT p, int id, int sm, int tout)
 
int DB_CloseCOM (void)
 Close the previously opened COM port. More...
 
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. More...
 
int DB_InitCamera (int mod)
 Initialize Camera Parameters.
Procedure that initialize the CCD Camera. More...
 
int DB_InitCOM (int comn)
 Init selected COM port. More...
 
int DB_InitDil (void)
 Initialize DIL. Procedure that initialize the DTA Imaging library. More...
 
int DB_InitMotor (int mod)
 Initialize AMS. Procedure that initialize the parameters for the AMS's devices. More...
 
void FPGACB (void)
 
int HomeAzimFast (void)
 Home for Azimuth Axis. More...
 
int HomeFiltersFast (void)
 (Fastest) Fliter wheel in the reference Position.
The Fliter wheel reaches the reference Position. Similar to HomeFilterWheel(void), but faster More...
 
int HomeGratingFast (int mod)
 (Fastest) Grating in the reference Position.
The Grating reaches the reference Position. Similar to HomeGrating(void), but faster More...
 
int HomeMirror (void)
 Input Mirror in the reference Position.
The Input Mirror reaches the reference Position. More...
 
int HomeNDFiltersFast (void)
 (Fastest) ND Fliter wheel in the reference Position.
The ND Fliter wheel reaches the reference Position. Similar to HomeFilterWheel(void), but faster More...
 
int HomeTrack (char *buf, int id, int sm, int mode)
 
int HomeZenithFast (void)
 Home for Zenith Axis. More...
 
MOBJECT MDCreateExpo (char *tit)
 Create Exposure/countdown shell. Procedure that build the Exposure/countdown shell during the calculated or "apriori" imposed integration time. More...
 
void __stdcall ShowDown (const char *str, int port)
 Shows the countdown.
Procedure for the visualisation of the countdown. More...
 

Variables

AzimuthSt AST
 Azimuth. More...
 
config Cfg
 Camera controls & Options. More...
 
das DAS
 DAS structure. More...
 
ccd DC_CCD
 CCD settings. More...
 
ptf DC_HP
 Platform settings. More...
 
DXL_par DXL
 DXL structure. More...
 
flag FLAG
 flags structure More...
 
paramini PARAM
 Param.ini. More...
 
stepm STEPM
 Stepper Motors. More...
 
ZenithSt ZST
 Zenith. More...
 

Detailed Description

Functions executed at DAS start-up.

Author
Daniele Bortoli

Definition in file Init.c.

Function Documentation

§ CBExpo()

void CBExpo ( MOBJECT  p,
void *  od,
void *  ad 
)

Close the Exposure shell and stop the image acquisition.

Returns
void

Definition at line 43 of file Init.c.

References DC_BrkFlg().

Referenced by MDCreateExpo().

44 {
45  DC_BrkFlg(0);
46 }
CTYPE void DLL DC_BrkFlg(int camera)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ D_Homing()

int D_Homing ( MOBJECT  p,
int  id,
int  sm,
int  tout 
)

Definition at line 470 of file Init.c.

References AMS_TestHome(), optionini::amsprogbar, D_VRange(), das::DOption, MLoopWhileEvents(), MObjectSetText(), st, and Status().

Referenced by HomeGratingFast(), HomeMirror(), and HomeZenithFast().

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  {
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 }
void MLoopWhileEvents(int discard)
optionini DOption
Options for DAS execution.
void D_VRange(char *str, int val, int, int g, int b)
Create and display the status bar.
Definition: Utils.c:206
das DAS
DAS structure.
Definition: Init.c:34
void MObjectSetText(MOBJECT obj, const char *text)
int AMS_TestHome(int id, int par1)
verify if the home position has been reached
Definition: Dxl.c:1042
void Status(char *tit)
Writes information&#39;s on the Status label .
Definition: Load.c:1556
int amsprogbar
display/hide prograssion bar, 0 = Hide, 1 = display
static double p
Definition: SOLPOS.C:131
static double st
Definition: SOLPOS.C:142
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ DB_CloseCOM()

int DB_CloseCOM ( void  )

Close the previously opened COM port.

Definition at line 460 of file Init.c.

References DXL_Close().

461 {
462  int er;
463 
464  er = DXL_Close();
465  return er;
466 }
int DXL_Close(void)
Close COM.
Definition: Dxl.c:1258
+ Here is the call graph for this function:

§ DB_InitAMS()

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.

Parameters
nid= AMS address:
  • 0 = AMS1
  • 1 = AMS2
  • 2 = AMS3
mod
  • 0 –> Init with home
  • 1 –> Init without home
  • 2 –> Home Input Mirror
  • 3 –> Home Grating
  • 4 –> Home Filter Wheel
  • 5 –> Home Zenith
  • 6 –> Home Azimuth
  • 7 –> Home ND Filter Wheel
powera–> Power assigned to motor A
stepa= 0, 1...13. steps assigned to motor A
slopea–> Slope assigned to motor A
speeda–> Speed assigned to motor A
powerb–> Power assigned to motor B
stepb= 0, 1...13. steps assigned to motor B
slopeb–> Slope assigned to motor B
speedb–> Speed assigned to motor B
Returns
er:
  • = 0 –> Init succesfully
  • = 1 –> Problems encountred

Definition at line 1391 of file Init.c.

References ACKLEN, DXL_par::add, AMS_Error(), AMS_firmrev(), AMS_Power(), AMS_Slope(), AMS_Speed(), AMS_Step(), DXL_par::bufrx, DXL_par::buftx, DXL_par::com, das::DOption, DXL_RxStr(), DXL_TxStr(), FDOUBLE, optionini::filtertype, stepm::firmrev, HomeAzimFast(), HomeFiltersFast(), HomeGratingFast(), HomeMirror(), HomeNDFiltersFast(), HomeZenithFast(), SioReset(), and das::StepM.

Referenced by DB_Home_CB(), DB_InitMotor(), E_Home_SM4(), E_Home_SM6(), HomeAzimFast(), HomeFiltersFast(), HomeGratingFast(), HomeMirror(), HomeNDFiltersFast(), and HomeZenithFast().

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 }
stepm StepM
Stepper motors parameters structure.
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
double firmrev[AMSMAX]
Firmware Revision.
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
optionini DOption
Options for DAS execution.
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
int HomeFiltersFast(void)
(Fastest) Fliter wheel in the reference Position. The Fliter wheel reaches the reference Position...
Definition: Init.c:853
#define ACKLEN
int HomeNDFiltersFast(void)
(Fastest) ND Fliter wheel in the reference Position. The ND Fliter wheel reaches the reference Positi...
Definition: Init.c:941
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
DXL_par DXL
DXL structure.
Definition: Init.c:21
int filtertype
type of installed filter module: 0=Simple-SM3, 1=Double-SM3+SM4, 2=simpleplus-SM3+TM) ...
int AMS_firmrev(int id)
Firmware Revision Number .
Definition: Dxl.c:475
das DAS
DAS structure.
Definition: Init.c:34
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
int HomeZenithFast(void)
Home for Zenith Axis.
Definition: Init.c:1143
NoMangle int DLL_IMPORT_EXPORT SioReset(int, int, int)
int HomeAzimFast(void)
Home for Azimuth Axis.
Definition: Init.c:1229
char bufrx[1024]
Rx buffer.
Definition: DXL.H:20
int add
Peripheral address.
Definition: DXL.H:19
#define FDOUBLE
double filter wheel
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 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
void AMS_Error(int w)
Alerts for AMS errors Creates a message window reporting the number of the error. ...
Definition: Errors.c:254
int HomeMirror(void)
Input Mirror in the reference Position. The Input Mirror reaches the reference Position.
Definition: Init.c:685
int com
Comunication port.
Definition: DXL.H:17
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ DB_InitCamera()

int DB_InitCamera ( int  mod)

Initialize Camera Parameters.
Procedure that initialize the CCD Camera.

Parameters
mod
  • = 0 –> Init Camera
  • = 1 –> RE-Init Camera
Returns
0 = Operation done, NO Errors
Errors related to the file system
  • 1001 = Path "..\DASxxx\Config\'Equipment'\dcl" deos not exist
  • 1002 = File "..\DASxxx\Config\'Equipment'\dcl\camera.cfg" deos not exist
  • 1003 = Error in reading file "..\DASxxx\Config\'Equipment'\dcl\camera.cfg"
Errors related to the CCD Camera (returned by DC_Status())
  • 0 = Operation done.
  • 1 = Camera not found
  • 2 = Link failure
  • 3 = Unsupported platform
  • 4 = Interface locked
  • 5 = Platform definition not found
  • 6 = CCD definition not found
  • 7 = FW error, zero position not found
  • 8 = Pattern generator overflow
  • 9 = Memory allocation error in DMA
  • 10 = Serializer not linked
  • 11 = Invalid serial decoder identifier
  • 12 = Unsupported platform in array mode
  • 13 = Invalid handle in WD_Open()
  • 14 = Windriver license string not valid
  • 15 = FDL-PCI card not found
  • 16 = Memory (image) allocation error
  • 17 = No USB device
  • 18 = Can't open USB device
  • 19 = Can't load io.dll library
  • 20 = Can't load fdlusb.dll library
  • 21 = Can't load fdlusb license file
  • 22 = Memory allocation error while creating pattern generator data
  • 23 = Error to creating pattern generator file
  • 24 = CoProcessor communication error

Definition at line 170 of file Init.c.

References _MAX_PATH, AllocUSMat(), img::attrib, marconi::AVGmat, BIL, CCD_INFO, CCDHANDLE, config::CCDType, CELSIUS, CLEARCCD, CodeEq2Name(), d_fileman::CONFIGDIREQUIPMENT, gui::ContrPanel, paramini::CoolPw, DB_InitDil(), DBDEMO, DC_CCDtoName(), DC_Close(), DC_GetPower(), DC_LoadCameraConfig(), DC_OpenByConfig(), DC_OpenPar(), DC_PTFtoName(), DC_RWData(), DC_SetBinning(), DC_SetGain(), DC_SetPathName(), DC_SetPower(), DC_SetTemp(), DC_SetUsrGain(), DC_Status(), DD_VRange(), optionini::DEFPIXFILENAME, bil::DFILEM, DI_CloseImage(), DI_FileExist(), DI_ImageProperties(), DI_OpenImage(), DI_PathExist(), DI_Regen(), DI_RunHisto(), DIL, das::DOption, ccd::dx, ccd::dy, paramini::EqType, flag::exemode, config::FDL_PCI_Index, das::Flag, das::Gui, d_fileman::HOMEDIRECTORY, IDX, IDY, img::Imat, ImatDark, dil::Img, optionini::imgtype, paramini::ITemp, controlpanel::lbl_Par, LoadDB_DefectPixel(), MANUAL, das::Marconi, image::Mat, MMessageDialog(), MObjectSetText(), marconi::Offset, das::Paramini, optionini::pixcorr, config::Platform, PRGFILE, PTF_INFO, READ_DATA, Server, ShowDown(), Status(), SZAMASTERM, SZAMODE, TEMPHANDLE, TEMPORIZED, TESTCCD, TESTSZAMODE, paramini::VBin, and WhoSys().

Referenced by ApplyChCB(), E_SetCCDTemp(), E_SetCCDVBin(), InitCCD_AMS(), and Task_CCD_Temp().

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 //************************************************************
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);
258 
259  sprintf(buf,"%d", DC_CCD.dy);
261 
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  {
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
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
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();
392  DIL.Img.Mat[Server].Imat = AllocUSMat(IDX, IDY);
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 }
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 IDX
Number of sensible horizontal pixels.
Definition: DAS_Spat.c:118
int Server
Definition: DAS_Spat.c:253
dil DIL
Definition: 2DPlot.c:26
optionini DOption
Options for DAS execution.
#define TESTCCD
execution for testing CCD Camera
void __stdcall DD_VRange(const char *str, int perc, int Port)
Definition: Utils.c:153
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.
C_DEF void DI_Regen(int s)
U32 CCDType
(R/W) Used CCD CCD code definitions
Definition: dcldef.h:1066
#define TESTSZAMODE
execution driven by SZAPRG file
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.
flag Flag
Structure for different flags.
char HOMEDIRECTORY[_MAX_PATH]
Definition: bildef.h:200
U16 * Imat
Definition: Dildef.h:286
#define DBDEMO
execution in demo mode
das DAS
DAS structure.
Definition: Init.c:34
#define READ_DATA
Read data.
Definition: dcldef.h:884
MOBJECT lbl_Par[11]
Parametric Labels of the Control Panel.
char * CodeEq2Name(int code)
code Equipment to Name
Definition: Load.c:371
C_DEF int DI_CloseImage(int s)
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
#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)
image Img
Definition: Dildef.h:675
#define CCDHANDLE
Enable background activity.
Definition: dcldef.h:396
short unsigned U16
2 byte without sign, range 0-65535
Definition: dcldef.h:375
#define CCD_INFO
R/W ccd internal library structure.
Definition: dcldef.h:875
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
unsigned short * ImatDark
buffer for the dark image
Definition: DAS_Spatram.h:3045
int WhoSys(void)
Definition: DFileMan.c:306
int VBin
CCD Vertical Binning.
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
char CONFIGDIREQUIPMENT[_MAX_PATH]
Definition: bildef.h:208
void Status(char *tit)
Writes information&#39;s on the Status label .
Definition: Load.c:1556
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 PRGFILE
execution driven by *.prg file
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 _MAX_PATH
Definition: Dildef.h:202
ccd DC_CCD
CCD settings.
Definition: Init.c:30
int MMessageDialog(const char *t, const char *msg, const char *btn1, const char *btn2,...)
S16 dy
Num. of Y pixels.
Definition: dcldef.h:1023
C_DEF void DI_RunHisto(void)
CTYPE int DLL DC_Status(int Camera)
Return the status of the last operations performed on the camera. This procedure allows you to check ...
#define SZAMODE
execution driven by SZAPRG file
bil BIL
Definition: 2DPlot.c:28
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
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 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
ptf DC_HP
Platform settings.
Definition: Init.c:31
int DB_InitDil(void)
Initialize DIL. Procedure that initialize the DTA Imaging library.
Definition: Init.c:112
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...
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)
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.
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 ...
U32 Platform
(R/W) Platform code Camera platform definitions
Definition: dcldef.h:1065
C_DEF int DI_FileExist(char *tit)
double ITemp
CCD Target Temperature.
int exemode
Set the Execution MODE (Execution modes)
#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
marconi Marconi
CCD Sensor struct.
paramini Paramini
structure for the parameters defined in param.ini configuration file
+ Here is the caller graph for this function:

§ DB_InitCOM()

int DB_InitCOM ( int  comn)

Init selected COM port.

Parameters
comn
  • = 0 –> COM1
  • = 1 –> COM2
  • = i –> COM(i+1) .
Returns
er:
  • = 0 –> Init succesfully
  • = 1 –> Problems encountred

Definition at line 452 of file Init.c.

References Baud19200, and DXL_Open().

Referenced by DB_InitMotor().

453 {
454 
455  int er = 0;
456  er = DXL_Open(0, comn, Baud19200);
457  return er;
458 
459 }
#define Baud19200
Definition: WSC.H:120
int DXL_Open(int addr, int com, int baud)
Open COM.
Definition: Dxl.c:1243
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ DB_InitDil()

int DB_InitDil ( void  )

Initialize DIL. Procedure that initialize the DTA Imaging library.

Returns
int

Definition at line 112 of file Init.c.

References BIL, spectrumheader::ccdex, spectrumheader::ccdey, spectrumheader::ccdsx, spectrumheader::ccdsy, config::CCDType, spectrumheader::ccdvb, spectrumheader::ccdwx, spectrumheader::ccdwy, DC_CCDtoName(), DC_PTFtoName(), DI_Init(), DI_OpenDigit(), DI_OpenImage(), DI_RunHisto(), DOASMODE, das::DOption, ccd::dx, ccd::dy, flag::exemode, das::Flag, IDX, IDY, optionini::imgtype, OFFLINEPLOT, das::Paramini, config::Platform, Server, bil::SPH, and paramini::VBin.

Referenced by DB_InitCamera(), ViewNext(), ViewNext_BIN(), and Visualizza().

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 
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;
153  }
154 
155 
156  sprintf(buf, "E2V %s on %s",DC_CCDtoName(Cfg.CCDType, 0), DC_PTFtoName(Cfg.Platform, 0));
158  DI_RunHisto();
159 
160 
161 
162  return 0;
163 
164 
165 }
int IDX
Number of sensible horizontal pixels.
Definition: DAS_Spat.c:118
int Server
Definition: DAS_Spat.c:253
optionini DOption
Options for DAS execution.
CTYPE const char DLL_P DC_CCDtoName(int CCDCode, int camera)
U32 CCDType
(R/W) Used CCD CCD code definitions
Definition: dcldef.h:1066
#define DOASMODE
execution for DOAS Processing
flag Flag
Structure for different flags.
das DAS
DAS structure.
Definition: Init.c:34
spectrumheader SPH
Spectrum Header Structure.
Definition: bildef.h:256
S16 dx
Num. of X pixels.
Definition: dcldef.h:1022
short unsigned U16
2 byte without sign, range 0-65535
Definition: dcldef.h:375
C_DEF void DI_OpenDigit(void)
#define OFFLINEPLOT
execution for archived data visualisation
int VBin
CCD Vertical Binning.
int IDY
Number of sensible vertical pixels.
Definition: DAS_Spat.c:119
ccd DC_CCD
CCD settings.
Definition: Init.c:30
S16 dy
Num. of Y pixels.
Definition: dcldef.h:1023
C_DEF void DI_RunHisto(void)
C_DEF int DI_Init(int mod)
bil BIL
Definition: 2DPlot.c:28
config Cfg
Camera controls & Options.
Definition: Init.c:32
int imgtype
Flag to set Image type: 0=MONOINT, 1=RGB.
CTYPE const char DLL_P DC_PTFtoName(int PlatFormCode, int camera)
U32 Platform
(R/W) Platform code Camera platform definitions
Definition: dcldef.h:1065
int exemode
Set the Execution MODE (Execution modes)
C_DEF int DI_OpenImage(U16 dx, U16 dy, U16 ifmt, U16 type, char *tit)
paramini Paramini
structure for the parameters defined in param.ini configuration file
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ DB_InitMotor()

int DB_InitMotor ( int  mod)

Initialize AMS. Procedure that initialize the parameters for the AMS's devices.

Parameters
mod;mod = 0–> do not init COM, mod = 1 –> init COM
Returns
int

Definition at line 1584 of file Init.c.

References AMS1, AMS2, AMS3, AMS_dirfin(), flag::AMSPres, COM1, COM2, ComErrors(), gui::ContrPanel, DB_InitAMS(), DB_InitCOM(), DBDEMO, paramini::EqType, flag::exemode, das::Flag, GASCODNG1, GASCODNG2, GASCODNG3, GASCODNG4, das::Gui, controlpanel::LedSM, mige::linked, LIS_, MANUAL, das::MIGE, MMessageDialog(), MPixmapSetImageFile(), das::Paramini, stepm::power, stepm::slope, stepm::SM_A, stepm::SM_B, SPATRAM, SPATRAM2, SPATRAM3, SPATRAMPLUS, stepm::speed, stepm::step, das::StepM, TESTAMS, and TROPOGAS.

Referenced by ApplyChCB(), and InitCCD_AMS().

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 ||
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],
1642 
1643  // Init AMS2
1644  er = DB_InitAMS(AMS2, 0, DAS.StepM.power[AMS2][DAS.StepM.SM_A],
1649 
1650  if( DAS.Paramini.EqType == TROPOGAS ||
1656  DAS.Paramini.EqType == SPATRAM2 ||
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)
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],
1673 
1674  if( DAS.Paramini.EqType == GASCODNG2 ||
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 }
stepm StepM
Stepper motors parameters structure.
#define SPATRAM
SPectrometer for Atmospheric TRAcers Measurements - CGE-UE Portugal.
gui Gui
Graphic User Interface Structure.
MOBJECT LedSM[AMSMAX][2]
Leds for stepper motors status.
#define AMS2
AMS2 address.
int SM_A
Motor A (su Y11) respectively: ID=0->InputMirror,ID=1->FilterWheel,ID=2->Zenith.
void MPixmapSetImageFile(MOBJECT pixmap, const char *fname)
flag Flag
Structure for different flags.
#define DBDEMO
execution in demo mode
das DAS
DAS structure.
Definition: Init.c:34
int slope[AMSMAX][2]
Stepper Motors Slope.
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
int DB_InitCOM(int comn)
Init selected COM port.
Definition: Init.c:452
#define COM2
Definition: COMM.H:80
flag FLAG
flags structure
Definition: Init.c:22
#define LIS_
Lampedusa Island Spectrometer - ENEA.
#define TROPOGAS
TROPOspheric Gas Analyzer Spectrometer.
#define GASCODNG2
GASCODNG 2 (with ATX power supply & HiresIV)
#define SPATRAM2
SPATRAM2 (with ATX power supply & HiresV)
#define SPATRAMPLUS
As SPATRAM plus AltAzimuth platform.
mige MIGE
#define GASCODNG3
GASCODNG 3 (with ATX power supply & HiresIV)
#define GASCODNG1
GASCODNG 1 (with ATX power supply & HiresIV)
#define GASCODNG4
GASCODNG 4.
int MMessageDialog(const char *t, const char *msg, const char *btn1, const char *btn2,...)
int linked
void ComErrors(int w)
Alerts for COM errors Creates a message window reporting the number of the error. ...
Definition: Errors.c:164
#define SPATRAM3
SPATRAM3.
#define COM1
Definition: COMM.H:79
int SM_B
Motor B (su Y12) respectively: ID=0->Grating,ID=1->Not Connected,ID=2->Azimuth.
controlpanel ContrPanel
Control Panel Structure.
#define AMS1
AMS1 address.
int speed[AMSMAX][2]
Stepper Motors Speed.
int step[AMSMAX][2]
Stepper Motors Step.
int AMS_dirfin(int id, int dira, int dirb)
Set Final Directions .
Definition: Dxl.c:457
int EqType
Spectrometer Type.
int AMSPres
AMS Presence: 0 = AMS FOUND; 1 = AMS NOT FOUND.
int exemode
Set the Execution MODE (Execution modes)
#define AMS3
AMS3 address.
#define TESTAMS
execution for testing AMS&#39;s devices
#define MANUAL
execution in manual mode (for lab use)
int power[AMSMAX][2]
Stepper Motors Power.
paramini Paramini
structure for the parameters defined in param.ini configuration file
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ FPGACB()

void FPGACB ( void  )

Definition at line 1568 of file Init.c.

References DXL_par::bufrx, DXL_RxStr(), DXL_TxStr(), Message(), and STS0LEN.

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 }
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
DXL_par DXL
DXL structure.
Definition: Init.c:21
#define STS0LEN
char bufrx[1024]
Rx buffer.
Definition: DXL.H:20
void Message(char *str, int er)
Create a message shell for the AMS errors (Debug Use). .
Definition: Dxl.c:1085
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
+ Here is the call graph for this function:

§ HomeAzimFast()

int HomeAzimFast ( void  )

Home for Azimuth Axis.

Definition at line 1229 of file Init.c.

References controlpanel::Albl_LS, AMS3, AMS_AzzeraCoord(), AMS_chkbitsts(), AMS_Default(), AMS_dirfin(), AMS_Divisore(), AMS_TrackOff(), AMS_TrackOn(), optionini::amsprogbar, gui::ContrPanel, D_VRange(), DB_InitAMS(), das::DOption, das::Gui, controlpanel::LedSM, Message(), das::MIGE, MLoopWhileEvents(), MObjectSetText(), MPixmapSetImageFile(), AzimuthSt::Pos, stepm::power, stepm::slope, stepm::SM_A, stepm::SM_B, stepm::speed, stepm::speed_Hz, st, Status(), stepm::step, das::StepM, and mige::type.

Referenced by DB_InitAMS(), and DB_TestHomeTypeCB().

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");
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 ));
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 ));
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],
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");
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 }
int AMS_Divisore(int id, unsigned long par1, unsigned long par2)
Definition: Dxl.c:946
stepm StepM
Stepper motors parameters structure.
gui Gui
Graphic User Interface Structure.
MOBJECT LedSM[AMSMAX][2]
Leds for stepper motors status.
MOBJECT Albl_LS[8]
Active Control Panel Labels for LIS status.
AzimuthSt AST
Azimuth.
Definition: Init.c:27
void MLoopWhileEvents(int discard)
optionini DOption
Options for DAS execution.
void D_VRange(char *str, int val, int, int g, int b)
Create and display the status bar.
Definition: Utils.c:206
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
int SM_A
Motor A (su Y11) respectively: ID=0->InputMirror,ID=1->FilterWheel,ID=2->Zenith.
void MPixmapSetImageFile(MOBJECT pixmap, const char *fname)
das DAS
DAS structure.
Definition: Init.c:34
int slope[AMSMAX][2]
Stepper Motors Slope.
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 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 type
void MObjectSetText(MOBJECT obj, const char *text)
void Status(char *tit)
Writes information&#39;s on the Status label .
Definition: Load.c:1556
mige MIGE
int amsprogbar
display/hide prograssion bar, 0 = Hide, 1 = display
void Message(char *str, int er)
Create a message shell for the AMS errors (Debug Use). .
Definition: Dxl.c:1085
int SM_B
Motor B (su Y12) respectively: ID=0->Grating,ID=1->Not Connected,ID=2->Azimuth.
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
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 AMS_chkbitsts(int id, int bitn)
check bit status Procedure for the determination of the bit number status.
Definition: Dxl.c:192
static double st
Definition: SOLPOS.C:142
int speed[AMSMAX][2]
Stepper Motors Speed.
int step[AMSMAX][2]
Stepper Motors Step.
double speed_Hz[AMSMAX][2]
Stepper Motors Speed [Hz].
int AMS_dirfin(int id, int dira, int dirb)
Set Final Directions .
Definition: Dxl.c:457
double Pos
Azimuth Current Position.
#define AMS3
AMS3 address.
int power[AMSMAX][2]
Stepper Motors Power.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ HomeFiltersFast()

int HomeFiltersFast ( void  )

(Fastest) Fliter wheel in the reference Position.
The Fliter wheel reaches the reference Position. Similar to HomeFilterWheel(void), but faster

Returns
er:
  • = 0 –> Operation concluded succesfully
  • = 1 –> Problems in positioning

Definition at line 853 of file Init.c.

References ACKLEN, controlpanel::Albl_LS, AMS2, AMS_AzzeraCoord(), AMS_chkbitsts(), AMS_Default(), AMS_dirfin(), AMS_TrackOff(), AMS_TrackOn(), optionini::amsprogbar, DXL_par::buftx, gui::ContrPanel, D_VRange(), DB_InitAMS(), das::DOption, DXL_RxStr(), DXL_TxStr(), FWS, das::Gui, controlpanel::LedSM, Message(), MLoopWhileEvents(), MObjectSetText(), MPixmapSetImageFile(), FilterWheelSt::Pos, stepm::power, stepm::slope, stepm::SM_A, stepm::SM_B, stepm::speed, stepm::speed_Hz, st, Status(), stepm::step, and das::StepM.

Referenced by DB_InitAMS(), DB_TestHomeTypeCB(), and E_Home_SM3().

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 
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  {
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 ));
908  }
909  /***************************************************/
910  }while (FlgHomeFW);
911 
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)
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");
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 }
stepm StepM
Stepper motors parameters structure.
gui Gui
Graphic User Interface Structure.
MOBJECT LedSM[AMSMAX][2]
Leds for stepper motors status.
MOBJECT Albl_LS[8]
Active Control Panel Labels for LIS status.
void MLoopWhileEvents(int discard)
optionini DOption
Options for DAS execution.
#define AMS2
AMS2 address.
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
void D_VRange(char *str, int val, int, int g, int b)
Create and display the status bar.
Definition: Utils.c:206
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
int SM_A
Motor A (su Y11) respectively: ID=0->InputMirror,ID=1->FilterWheel,ID=2->Zenith.
void MPixmapSetImageFile(MOBJECT pixmap, const char *fname)
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
DXL_par DXL
DXL structure.
Definition: Init.c:21
das DAS
DAS structure.
Definition: Init.c:34
int slope[AMSMAX][2]
Stepper Motors Slope.
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 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
void MObjectSetText(MOBJECT obj, const char *text)
int Pos
Filter Wheel current Position.
void Status(char *tit)
Writes information&#39;s on the Status label .
Definition: Load.c:1556
int amsprogbar
display/hide prograssion bar, 0 = Hide, 1 = display
void Message(char *str, int er)
Create a message shell for the AMS errors (Debug Use). .
Definition: Dxl.c:1085
int SM_B
Motor B (su Y12) respectively: ID=0->Grating,ID=1->Not Connected,ID=2->Azimuth.
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
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 AMS_chkbitsts(int id, int bitn)
check bit status Procedure for the determination of the bit number status.
Definition: Dxl.c:192
static double st
Definition: SOLPOS.C:142
int speed[AMSMAX][2]
Stepper Motors Speed.
int step[AMSMAX][2]
Stepper Motors Step.
double speed_Hz[AMSMAX][2]
Stepper Motors Speed [Hz].
int AMS_dirfin(int id, int dira, int dirb)
Set Final Directions .
Definition: Dxl.c:457
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
FilterWheelSt FWS
Filter Wheel.
Definition: DAS_Spat.c:57
int power[AMSMAX][2]
Stepper Motors Power.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ HomeGratingFast()

int HomeGratingFast ( int  mod)

(Fastest) Grating in the reference Position.
The Grating reaches the reference Position. Similar to HomeGrating(void), but faster

Returns
er:
  • = 0 –> Operation concluded succesfully
  • = 1 –> Problems in positioning

Definition at line 780 of file Init.c.

References controlpanel::Albl_LS, AMS1, AMS_AzzeraCoord(), AMS_Default(), AMS_dirfin(), AMS_DoPos(), AMS_Home(), AMS_HomeDefault(), gui::ContrPanel, D_Homing(), DB_InitAMS(), GRS, das::Gui, HomeTrack(), stepm::hometype, controlpanel::LedSM, LookforWl_X(), Message(), MObjectSetText(), MPixmapSetImageFile(), paramini::Offset, das::Paramini, stepm::power, stepm::slope, stepm::SM_A, stepm::SM_B, stepm::speed, st, Status(), stepm::step, das::StepM, and GratingSt::Wl.

Referenced by DB_InitAMS(), DB_TestHomeTypeCB(), E_HGratCal(), E_Home_SM2(), and Task_HomeGrat().

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");
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);
805  }
806  if(DAS.StepM.hometype[AMS1][DAS.StepM.SM_B] == 1) //Home with Default
807  {
808  er = AMS_HomeDefault(AMS1, 0, 1);
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)
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);
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 }
stepm StepM
Stepper motors parameters structure.
gui Gui
Graphic User Interface Structure.
int hometype[AMSMAX][2]
MOBJECT LedSM[AMSMAX][2]
Leds for stepper motors status.
int D_Homing(MOBJECT p, int id, int sm, int tout)
Definition: Init.c:470
MOBJECT Albl_LS[8]
Active Control Panel Labels for LIS status.
int SM_A
Motor A (su Y11) respectively: ID=0->InputMirror,ID=1->FilterWheel,ID=2->Zenith.
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
void MPixmapSetImageFile(MOBJECT pixmap, const char *fname)
int Offset[16]
Offset of the hardware devices (Input Mirror (5), Grating, Filter Wheel...)
das DAS
DAS structure.
Definition: Init.c:34
int slope[AMSMAX][2]
Stepper Motors Slope.
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 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
void MObjectSetText(MOBJECT obj, const char *text)
int Wl
Grating Wavelength.
int AMS_HomeDefault(int id, int mota, int motb)
Definition: Dxl.c:567
void Status(char *tit)
Writes information&#39;s on the Status label .
Definition: Load.c:1556
void Message(char *str, int er)
Create a message shell for the AMS errors (Debug Use). .
Definition: Dxl.c:1085
int SM_B
Motor B (su Y12) respectively: ID=0->Grating,ID=1->Not Connected,ID=2->Azimuth.
controlpanel ContrPanel
Control Panel Structure.
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
#define AMS1
AMS1 address.
static double st
Definition: SOLPOS.C:142
int speed[AMSMAX][2]
Stepper Motors Speed.
int step[AMSMAX][2]
Stepper Motors Step.
int AMS_dirfin(int id, int dira, int dirb)
Set Final Directions .
Definition: Dxl.c:457
int HomeTrack(char *buf, int id, int sm, int mode)
Definition: Init.c:518
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
GratingSt GRS
Definition: CreateForms.c:82
int LookforWl_X(int x)
Definition: Procedures.c:2295
int power[AMSMAX][2]
Stepper Motors Power.
paramini Paramini
structure for the parameters defined in param.ini configuration file
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ HomeMirror()

int HomeMirror ( void  )

Input Mirror in the reference Position.
The Input Mirror reaches the reference Position.

Returns
er:
  • = 0 –> Operation concluded succesfully
  • = 1 –> Problems in positioning

Definition at line 685 of file Init.c.

References controlpanel::Albl_LS, AMS1, AMS_AzzeraCoord(), AMS_Default(), AMS_dirfin(), AMS_Divisore(), AMS_DoPos(), AMS_Home(), AMS_HomeDefault(), gui::ContrPanel, D_Homing(), DB_InitAMS(), stepm::divider, paramini::EqType, GASCODNG4, das::Gui, HomeTrack(), stepm::hometype, controlpanel::LedSM, Message(), Mir_Code, Mir_CodeTropo, MIS, MObjectSetText(), MPixmapSetImageFile(), stepm::multiplier, paramini::Offset, das::Paramini, MirrorSt::Pos, stepm::power, stepm::slope, stepm::SM_A, stepm::SM_B, SMfraz(), SPATRAM3, stepm::speed, stepm::speed_Hz, Status(), stepm::step, das::StepM, and TROPOGAS.

Referenced by DB_InitAMS(), DB_TestHomeTypeCB(), and E_Home_SM1().

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");
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]);
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);
719 
720  er = AMS_HomeDefault(AMS1, 1, 0);
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)
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;
765  sprintf(buf, "%s",Mir_CodeTropo[0]);
766  else
767  sprintf(buf, "%s",Mir_Code[0]);
768 
769 // sprintf(buf, "%s", " Zenith" );
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 }
int AMS_Divisore(int id, unsigned long par1, unsigned long par2)
Definition: Dxl.c:946
stepm StepM
Stepper motors parameters structure.
gui Gui
Graphic User Interface Structure.
int hometype[AMSMAX][2]
MOBJECT LedSM[AMSMAX][2]
Leds for stepper motors status.
int D_Homing(MOBJECT p, int id, int sm, int tout)
Definition: Init.c:470
MOBJECT Albl_LS[8]
Active Control Panel Labels for LIS status.
const char * Mir_Code[]
const char array for the realisation of the Mirrors buttons in the Mirror shell
Definition: DAS_Spat.c:231
int SM_A
Motor A (su Y11) respectively: ID=0->InputMirror,ID=1->FilterWheel,ID=2->Zenith.
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
void MPixmapSetImageFile(MOBJECT pixmap, const char *fname)
int Pos
Mirror Current Position.
int Offset[16]
Offset of the hardware devices (Input Mirror (5), Grating, Filter Wheel...)
das DAS
DAS structure.
Definition: Init.c:34
int slope[AMSMAX][2]
Stepper Motors Slope.
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 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
float multiplier[AMSMAX][2]
multiplier, > 0 multiplier, < 0 demultiplier
void MObjectSetText(MOBJECT obj, const char *text)
#define TROPOGAS
TROPOspheric Gas Analyzer Spectrometer.
int AMS_HomeDefault(int id, int mota, int motb)
Definition: Dxl.c:567
unsigned long divider[AMSMAX][2]
Divider for the frequency.
void Status(char *tit)
Writes information&#39;s on the Status label .
Definition: Load.c:1556
#define GASCODNG4
GASCODNG 4.
void Message(char *str, int er)
Create a message shell for the AMS errors (Debug Use). .
Definition: Dxl.c:1085
#define SPATRAM3
SPATRAM3.
MirrorSt MIS
Mirror.
Definition: DAS_Spat.c:61
int SM_B
Motor B (su Y12) respectively: ID=0->Grating,ID=1->Not Connected,ID=2->Azimuth.
controlpanel ContrPanel
Control Panel Structure.
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
#define AMS1
AMS1 address.
int speed[AMSMAX][2]
Stepper Motors Speed.
int step[AMSMAX][2]
Stepper Motors Step.
double speed_Hz[AMSMAX][2]
Stepper Motors Speed [Hz].
int AMS_dirfin(int id, int dira, int dirb)
Set Final Directions .
Definition: Dxl.c:457
int EqType
Spectrometer Type.
int HomeTrack(char *buf, int id, int sm, int mode)
Definition: Init.c:518
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
int power[AMSMAX][2]
Stepper Motors Power.
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
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ HomeNDFiltersFast()

int HomeNDFiltersFast ( void  )

(Fastest) ND Fliter wheel in the reference Position.
The ND Fliter wheel reaches the reference Position. Similar to HomeFilterWheel(void), but faster

Returns
er:
  • = 0 –> Operation concluded succesfully
  • = 1 –> Problems in positioning

Definition at line 941 of file Init.c.

References ACKLEN, controlpanel::Albl_LS, AMS2, AMS_AzzeraCoord(), AMS_chkbitsts(), AMS_Default(), AMS_dirfin(), AMS_TrackOff(), AMS_TrackOn(), optionini::amsprogbar, DXL_par::buftx, gui::ContrPanel, D_VRange(), DB_InitAMS(), das::DOption, DXL_RxStr(), DXL_TxStr(), FWS, das::Gui, controlpanel::LedSM, Message(), MLoopWhileEvents(), MObjectSetText(), MPixmapSetImageFile(), FilterWheelSt::Pos, stepm::power, stepm::slope, stepm::SM_A, stepm::SM_B, stepm::speed, stepm::speed_Hz, st, Status(), stepm::step, and das::StepM.

Referenced by DB_InitAMS().

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 
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  {
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 ));
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],
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");
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 }
stepm StepM
Stepper motors parameters structure.
gui Gui
Graphic User Interface Structure.
MOBJECT LedSM[AMSMAX][2]
Leds for stepper motors status.
MOBJECT Albl_LS[8]
Active Control Panel Labels for LIS status.
void MLoopWhileEvents(int discard)
optionini DOption
Options for DAS execution.
#define AMS2
AMS2 address.
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
void D_VRange(char *str, int val, int, int g, int b)
Create and display the status bar.
Definition: Utils.c:206
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
int SM_A
Motor A (su Y11) respectively: ID=0->InputMirror,ID=1->FilterWheel,ID=2->Zenith.
void MPixmapSetImageFile(MOBJECT pixmap, const char *fname)
int DXL_RxStr(char *rx, int *len)
receive string from a serial port
Definition: Dxl.c:1187
DXL_par DXL
DXL structure.
Definition: Init.c:21
das DAS
DAS structure.
Definition: Init.c:34
int slope[AMSMAX][2]
Stepper Motors Slope.
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 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
void MObjectSetText(MOBJECT obj, const char *text)
int Pos
Filter Wheel current Position.
void Status(char *tit)
Writes information&#39;s on the Status label .
Definition: Load.c:1556
int amsprogbar
display/hide prograssion bar, 0 = Hide, 1 = display
void Message(char *str, int er)
Create a message shell for the AMS errors (Debug Use). .
Definition: Dxl.c:1085
int SM_B
Motor B (su Y12) respectively: ID=0->Grating,ID=1->Not Connected,ID=2->Azimuth.
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
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 AMS_chkbitsts(int id, int bitn)
check bit status Procedure for the determination of the bit number status.
Definition: Dxl.c:192
static double st
Definition: SOLPOS.C:142
int speed[AMSMAX][2]
Stepper Motors Speed.
int step[AMSMAX][2]
Stepper Motors Step.
double speed_Hz[AMSMAX][2]
Stepper Motors Speed [Hz].
int AMS_dirfin(int id, int dira, int dirb)
Set Final Directions .
Definition: Dxl.c:457
void DXL_TxStr(char *tx, int len)
send string to a serial port
Definition: Dxl.c:1153
FilterWheelSt FWS
Filter Wheel.
Definition: DAS_Spat.c:57
int power[AMSMAX][2]
Stepper Motors Power.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ HomeTrack()

int HomeTrack ( char *  buf,
int  id,
int  sm,
int  mode 
)

Definition at line 518 of file Init.c.

References AMS_chkbitsts(), AMS_Divisore(), AMS_TrackOff(), AMS_TrackOn(), optionini::amsprogbar, D_VRange(), das::DOption, GRAT_TASK_TIME, ids::GRATHOME, IDS, MLoopWhileEvents(), MRefreshTimeout(), stepm::speed_Hz, st, das::StepM, and Task_HomeGrat().

Referenced by HomeGratingFast(), HomeMirror(), and HomeZenithFast().

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  /*§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§*/
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)
602  D_VRange(NULL, (long) x * 100 / tout, 255, 0, 0 );
603  }while(HomeOnGoing);
604 
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 
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)
659  D_VRange(NULL, (long) x * 100 / tout, 255, 0, 0 );
660  }while(HomeOnGoing);
661 
662 
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 }
int AMS_Divisore(int id, unsigned long par1, unsigned long par2)
Definition: Dxl.c:946
stepm StepM
Stepper motors parameters structure.
void MRefreshTimeout(TIMEOUT_ID *pid, CARD32 msec, TIMEOUT_CB cb, void *ud)
void MLoopWhileEvents(int discard)
optionini DOption
Options for DAS execution.
void D_VRange(char *str, int val, int, int g, int b)
Create and display the status bar.
Definition: Utils.c:206
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
das DAS
DAS structure.
Definition: Init.c:34
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
#define GRAT_TASK_TIME
Grating Home.
int amsprogbar
display/hide prograssion bar, 0 = Hide, 1 = display
ids IDS
ID tasks.
Definition: DAS_Spat.c:54
int AMS_TrackOff(int id, int amot, int bmot)
tracking off Procedure for Stepper Motor tracking de-activation
Definition: Dxl.c:422
int AMS_chkbitsts(int id, int bitn)
check bit status Procedure for the determination of the bit number status.
Definition: Dxl.c:192
static double st
Definition: SOLPOS.C:142
double speed_Hz[AMSMAX][2]
Stepper Motors Speed [Hz].
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ HomeZenithFast()

int HomeZenithFast ( void  )

Home for Zenith Axis.

Definition at line 1143 of file Init.c.

References controlpanel::Albl_LS, AMS3, AMS_AzzeraCoord(), AMS_chkbitsts(), AMS_Default(), AMS_dirfin(), AMS_Home(), AMS_HomeDefault(), gui::ContrPanel, D_Homing(), DB_InitAMS(), das::Gui, HomeTrack(), stepm::hometype, controlpanel::LedSM, Message(), MObjectSetText(), MPixmapSetImageFile(), ZenithSt::Pos, stepm::power, SD_Zenith_H(), stepm::slope, stepm::SM_A, stepm::SM_B, stepm::speed, st, Status(), stepm::step, and das::StepM.

Referenced by DB_InitAMS(), DB_TestHomeTypeCB(), and E_Home_SM5().

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");
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);
1180  }
1181  if(DAS.StepM.hometype[AMS3][DAS.StepM.SM_B] == 1) //Home with Default
1182  {
1183  er = AMS_HomeDefault(AMS3, 1, 0);
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],
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");
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 }
stepm StepM
Stepper motors parameters structure.
gui Gui
Graphic User Interface Structure.
int hometype[AMSMAX][2]
MOBJECT LedSM[AMSMAX][2]
Leds for stepper motors status.
int D_Homing(MOBJECT p, int id, int sm, int tout)
Definition: Init.c:470
MOBJECT Albl_LS[8]
Active Control Panel Labels for LIS status.
int SM_A
Motor A (su Y11) respectively: ID=0->InputMirror,ID=1->FilterWheel,ID=2->Zenith.
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
void MPixmapSetImageFile(MOBJECT pixmap, const char *fname)
das DAS
DAS structure.
Definition: Init.c:34
int slope[AMSMAX][2]
Stepper Motors Slope.
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 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
void MObjectSetText(MOBJECT obj, const char *text)
int AMS_HomeDefault(int id, int mota, int motb)
Definition: Dxl.c:567
void Status(char *tit)
Writes information&#39;s on the Status label .
Definition: Load.c:1556
void Message(char *str, int er)
Create a message shell for the AMS errors (Debug Use). .
Definition: Dxl.c:1085
ZenithSt ZST
Zenith.
Definition: Init.c:26
int SD_Zenith_H(float ang)
Definition: Spat_Device.c:2816
int SM_B
Motor B (su Y12) respectively: ID=0->Grating,ID=1->Not Connected,ID=2->Azimuth.
controlpanel ContrPanel
Control Panel Structure.
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 AMS_chkbitsts(int id, int bitn)
check bit status Procedure for the determination of the bit number status.
Definition: Dxl.c:192
static double st
Definition: SOLPOS.C:142
int speed[AMSMAX][2]
Stepper Motors Speed.
int step[AMSMAX][2]
Stepper Motors Step.
int AMS_dirfin(int id, int dira, int dirb)
Set Final Directions .
Definition: Dxl.c:457
int HomeTrack(char *buf, int id, int sm, int mode)
Definition: Init.c:518
double Pos
Zenith Current Position.
#define AMS3
AMS3 address.
int power[AMSMAX][2]
Stepper Motors Power.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ MDCreateExpo()

MOBJECT MDCreateExpo ( char *  tit)

Create Exposure/countdown shell. Procedure that build the Exposure/countdown shell during the calculated or "apriori" imposed integration time.

Create the Exposure shell.
Creation of the Exposure shell during an image acquisition.

Parameters
*titpointer to the char variable with the integration time
Returns
void
Parameters
titpointer to a char variable containing the title of the shell.
Returns
MOBJECT shell

Definition at line 55 of file Init.c.

References BI_TILED, CBExpo(), graph::digit, DIL, dil::Graph, marconi::LblExpD, marconi::LblExpP, das::Marconi, MCreateColForm(), MCreateImagePButtonExt(), MCreatePixmapFromData(), MCreatePixmapFromFile(), MCreateShell(), MFormSetSpacing(), MObjectSetBackgroundImageFile(), MObjectSetShadow(), MObjectSetTransparency(), MPButtonSetCallback(), MShellRealize(), SF_NO_CLOSE, SF_NO_MAXIMIZE, SF_NO_MINIMIZE, SF_NO_RESIZE, and WS_NONE.

Referenced by DB_GetCCD().

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 }
#define WS_NONE
Definition: Mguidefs.h:956
#define SF_NO_RESIZE
Definition: Mguidefs.h:1038
MOBJECT MCreatePixmapFromFile(MOBJECT parent, const char *fname)
#define BI_TILED
Definition: Mguidefs.h:945
dil DIL
Definition: 2DPlot.c:26
void MObjectSetShadow(MOBJECT obj, int type, int in, int out)
void MShellRealize(MOBJECT obj)
#define SF_NO_MAXIMIZE
Definition: Mguidefs.h:1034
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
#define SF_NO_CLOSE
Definition: Mguidefs.h:1032
#define SF_NO_MINIMIZE
Definition: Mguidefs.h:1036
MOBJECT LblExpP[7]
Label for presetted time exposure.
void MObjectSetBackgroundImageFile(MOBJECT obj, const char *fname, int mode)
MOBJECT MCreateColForm(MOBJECT parent)
MOBJECT MCreateShell(const char *title, int flags)
void MFormSetSpacing(MOBJECT p, int offset)
void MPButtonSetCallback(MOBJECT button, MGUI_CB cb, void *data)
MIMAGE digit[13]
Definition: Dildef.h:624
graph Graph
Definition: Dildef.h:676
void * MOBJECT
Definition: Mguidefs.h:192
void MObjectSetTransparency(MOBJECT obj, CARD8 level)
MOBJECT MCreatePixmapFromData(MOBJECT parent, MIMAGE data)
MOBJECT MCreateImagePButtonExt(MOBJECT parent, const char *npf, const char *apf, const char *upf, const char *non, const char *aon, const char *uon)
MOBJECT LblExpD[7]
Label for time exposure countdown.
marconi Marconi
CCD Sensor struct.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ ShowDown()

void __stdcall ShowDown ( const char *  str,
int  port 
)

Shows the countdown.
Procedure for the visualisation of the countdown.

Parameters
cdownpointer to a char variable containing the partial time.
Returns
void

Definition at line 98 of file Init.c.

References DI_WriteDigit(), marconi::LblExpD, das::Marconi, and MLoopWhileEvents().

Referenced by DB_GetCCD(), and DB_InitCamera().

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);
108  MLoopWhileEvents(0);
109  }
110 }
void MLoopWhileEvents(int discard)
das DAS
DAS structure.
Definition: Init.c:34
C_DEF void DI_WriteDigit(MOBJECT *pix, char *fmt)
MOBJECT LblExpD[7]
Label for time exposure countdown.
marconi Marconi
CCD Sensor struct.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

§ AST

AzimuthSt AST

Azimuth.

Definition at line 27 of file Init.c.

§ Cfg

config Cfg

Camera controls & Options.

Definition at line 32 of file Init.c.

§ DAS

das DAS

DAS structure.

Definition at line 34 of file Init.c.

§ DC_CCD

ccd DC_CCD

CCD settings.

Definition at line 30 of file Init.c.

§ DC_HP

ptf DC_HP

Platform settings.

Definition at line 31 of file Init.c.

§ DXL

DXL_par DXL

DXL structure.

Definition at line 21 of file Init.c.

§ FLAG

flag FLAG

flags structure

Definition at line 22 of file Init.c.

§ PARAM

paramini PARAM

Param.ini.

Definition at line 23 of file Init.c.

§ STEPM

stepm STEPM

Stepper Motors.

Definition at line 25 of file Init.c.

§ ZST

ZenithSt ZST

Zenith.

Definition at line 26 of file Init.c.

______________________________________________________________________________________
Generated on Mon Sep 18 2017 11:46:30 for DAS - Rel. 3.1.6 - 18/09/2017.