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

module to handle spectrometer DEVICES. More...

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <io.h>
#include <math.h>
#include <sys\stat.h>
#include <time.h>
#include <sys/types.h>
#include <sys/timeb.h>
#include "mgui.h"
#include "DAS_Spatram.h"
#include "dcl.h"
#include "dxl.h"
+ Include dependency graph for Spat_Device.c:

Go to the source code of this file.

Functions

void AMS_PWM_Zero (int mod)
 
void FANECU (int mod)
 FAN ON/OFF
. More...
 
void FANPeltier (int mod)
 FAN ON/OFF
. More...
 
void HgLamp (int mod)
 HG Lamp ON/OFF
. More...
 
void HiresPS (int mod)
 Hires Power Supply ON/OFF
. More...
 
float MIGEActualZenAz (int mode)
 convert SUN AZIMUTH and ZENITH angles, to be used with MIGE mode = 0 –> fix azimuth and return azimuth for MIGE positioning mode = 1 –> fix zenith and return zenith for MIGE positioning More...
 
void Peltier (int mod)
 Peltier ON/OFF
. More...
 
void PeltierPS (int mod)
 Peltier Power Supply ON/OFF
. More...
 
void QjLamp (int mod)
 QJ Lamp ON/OFF
. More...
 
int SD_Azimuth (float ang, float raz)
 Positioning Azimuth.
The Zenith reaches the position specified by ang. More...
 
int SD_FilterW (int filter)
 Positioning Filter wheel.
The filter wheel move on the filter number specified by filter.
See also Filter Wheel page. More...
 
void SD_FNTorqueM (int mod)
 Positioning NDFilter.
. More...
 
int SD_Grating (int ang)
 Positioning Grating.
The Grating move to the position specified by ang (Wavelength) More...
 
int SD_Mirror (int where)
 Positioning Input Mirror.
The Input Mirror reaches the position specified by where. More...
 
int SD_NDFilterW (int filter)
 Positioning Filter wheel.
The filter wheel move on the filter number specified by filter.
See also Filter Wheel page. More...
 
int SD_PosAADev (double z, double a)
 perform the simoultaneous positioning of the AltAzimuth platform z = Zenith Axis a = Grating Position More...
 
int SD_Position (int m, int w, int f, double z, double a)
 perform the simoultaneous positioning of the Spectrometer Devices m = mirror w = wavelength (Grating) f = filter wheel z = zenith a = azimuth More...
 
int SD_PosOMUDev (int m, int w, int f)
 perform the simoultaneous positioning of the Spectrometer Devices in the OMU Unit m = mirror w = wavelength (Grating) f = filter wheel More...
 
int SD_Zenith (float ang)
 Positioning Zenith.
The Zenith reaches the position specified by ang. More...
 
int SD_Zenith_H (float ang)
 
int SM_stepr (int t)
 AMS 'steps/round' value return the AMS 'steps/round' value (microstepping) depending on the setted step fractioning. More...
 
float SMfraz (int t)
 denominator value of the stepping ratio
More...
 
void WriteLogAMS (int id, int dira, int dirb, unsigned long stepa, unsigned long stepb)
 
void writelogmotor (int mod, int id_motore, int k, int d, long steps, unsigned char ams_id)
 Write Motor Operations on Log File.
Write on the SM.LOG file the commands send to the motors. More...
 

Variables

AzimuthSt AST
 
das DAS
 DAS structure. More...
 
DXL_par DXL
 
flag FLAG
 flags structure More...
 
GratingSt GRS
 Grating. More...
 
ZenithSt ZST
 

Detailed Description

module to handle spectrometer DEVICES.

Author
Daniele Bortoli

Definition in file Spat_Device.c.

Function Documentation

§ AMS_PWM_Zero()

void AMS_PWM_Zero ( int  mod)

Definition at line 2570 of file Spat_Device.c.

References AMS2, AMS_wopto(), ChkDigIO(), delay(), stepm::OOP, and das::StepM.

Referenced by OMU_DoPeltPow().

2571 {
2572 
2573  int er;
2574 
2575  er = ChkDigIO(DAS.StepM.OOP[AMS2], 0);
2576 
2577  if(mod)
2578  DAS.StepM.OOP[AMS2] |= 0x01; //bit 0 , 00000001
2579  else
2580  DAS.StepM.OOP[AMS2] &= 0xFE;
2581 
2582 
2583  // 1's complement
2584  DAS.StepM.OOP[AMS2] = ~DAS.StepM.OOP[AMS2];
2585  //write on the optoinsulated port
2586  //AMS_wopto(AMS2, DAS.StepM.OOP[AMS2]);
2587  AMS_wopto(AMS2, 1);
2588  delay(500);
2589  // again 1's complement for restoring the positive logic
2590  DAS.StepM.OOP[AMS2] = ~DAS.StepM.OOP[AMS2];
2591 
2592 
2593 
2594 
2595 }
das DAS
DAS structure.
Definition: Spat_Device.c:27
stepm StepM
Stepper motors parameters structure.
#define AMS2
AMS2 address.
int ChkDigIO(unsigned char word, int bitn)
check for digital I/O Status
unsigned char OOP[AMSMAX]
2 byte Word for AMS Opto insulated Output Port Status
void delay(unsigned long d)
Pauses for a specified number of milliseconds. .
Definition: Dxl.c:1113
int AMS_wopto(int id, unsigned int w)
write the value on the optoinsulated port write the value on the optoinsulated port.
Definition: Dxl.c:911
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ FANECU()

void FANECU ( int  mod)

FAN ON/OFF
.

Parameters
mod
  • = 0 –> FAN OFF
  • = 1 –> FAN ON

Definition at line 2619 of file Spat_Device.c.

References AMS3, AMS_wopto(), delay(), das::Gui, pushbutt::KeyB, MObjectSetText(), stepm::OOP, gui::PushButt, and das::StepM.

Referenced by DB_KeyB_CB(), and Task_LIS_Temp().

2620 {
2621 
2622  unsigned long t = 500;
2623 // char buf[256];
2624  int er = 0;
2625 
2626 
2627  if(mod)
2628  {
2629  DAS.StepM.OOP[AMS3] |= 0x02; //bit 1, 00000010
2630  MObjectSetText(DAS.Gui.PushButt.KeyB[6], "F ECU On");
2631  }
2632  else
2633  {
2634  DAS.StepM.OOP[AMS3] &= 0xFD; //11111101
2635  MObjectSetText(DAS.Gui.PushButt.KeyB[6], "F ECU Off");
2636  }
2637 
2638  // 1's complement
2639  DAS.StepM.OOP[AMS3] = ~DAS.StepM.OOP[AMS3];
2640  //write on the optoinsulated port
2642  delay(100);
2643  // again 1's complement for restoring the positive logic
2644  DAS.StepM.OOP[AMS3] = ~DAS.StepM.OOP[AMS3];
2645 
2646 
2647 }
das DAS
DAS structure.
Definition: Spat_Device.c:27
stepm StepM
Stepper motors parameters structure.
gui Gui
Graphic User Interface Structure.
MOBJECT KeyB[28]
Keyboard Buttons.
void MObjectSetText(MOBJECT obj, const char *text)
unsigned char OOP[AMSMAX]
2 byte Word for AMS Opto insulated Output Port Status
void delay(unsigned long d)
Pauses for a specified number of milliseconds. .
Definition: Dxl.c:1113
pushbutt PushButt
Push buttons.
int AMS_wopto(int id, unsigned int w)
write the value on the optoinsulated port write the value on the optoinsulated port.
Definition: Dxl.c:911
#define AMS3
AMS3 address.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ FANPeltier()

void FANPeltier ( int  mod)

FAN ON/OFF
.

Parameters
mod
  • = 0 –> FAN OFF
  • = 1 –> FAN ON

Definition at line 2652 of file Spat_Device.c.

References AMS1, AMS_wopto(), delay(), stepm::OOP, and das::StepM.

Referenced by ADTesterCB(), OMU_ChooseDir(), and ShutCB().

2653 {
2654 
2655  if(mod)
2656  DAS.StepM.OOP[AMS1] |= 0x02; //bit 1, 00000010
2657  else
2658  DAS.StepM.OOP[AMS1] &= 0xFD; //11111101
2659 
2660 
2661  // 1's complement
2662  DAS.StepM.OOP[AMS1] = ~DAS.StepM.OOP[AMS1];
2663  //write on the optoinsulated port
2664  //delay(500);
2666  delay(750);
2667  // again 1's complement for restoring the positive logic
2668  DAS.StepM.OOP[AMS1] = ~DAS.StepM.OOP[AMS1];
2669 
2670 
2671 }
das DAS
DAS structure.
Definition: Spat_Device.c:27
stepm StepM
Stepper motors parameters structure.
unsigned char OOP[AMSMAX]
2 byte Word for AMS Opto insulated Output Port Status
void delay(unsigned long d)
Pauses for a specified number of milliseconds. .
Definition: Dxl.c:1113
int AMS_wopto(int id, unsigned int w)
write the value on the optoinsulated port write the value on the optoinsulated port.
Definition: Dxl.c:911
#define AMS1
AMS1 address.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ HgLamp()

void HgLamp ( int  mod)

HG Lamp ON/OFF
.

Parameters
mod
  • = 0 –> Lamp OFF
  • = 1 –> Lamp ON

Definition at line 2673 of file Spat_Device.c.

References AMS1, AMS_wopto(), gui::ContrPanel, das::Gui, HGFlg, controlpanel::LedHG, MObjectSetText(), MPixmapSetImageFile(), stepm::OOP, controlpanel::pblamps, and das::StepM.

Referenced by D_Calibra(), DB_KeyB_CB(), E_Hg_Off(), E_Hg_On(), ShutCB(), and WinRes().

2674 {
2675 
2676  if(mod)
2677  {
2678 
2679  // Bitwise inclusive OR
2680  //The bitwise-inclusive-OR operator compares each bit of its first operand to
2681  //the corresponding bit of its second operand. If either bit is 1,
2682  //the corresponding result bit is set to 1. Otherwise, the corresponding
2683  //result bit is set to 0.
2684  //i.e if(DAS.StepM.OOP[AMS1] = 00000000) -->
2685  //DAS.StepM.OOP[AMS1] | 0x04 = 00000000 | 00000100 = 00000100
2686  DAS.StepM.OOP[AMS1] |= 0x04; //bit 2, 00000100
2687  HGFlg = 1;
2688  MObjectSetText(DAS.Gui.ContrPanel.pblamps[0], "Hg On");
2689  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedHG, "SYS\\ledonHG.bmp");
2690 
2691  }
2692  else
2693  {
2694  //The bitwise-AND operator compares each bit of its first operand to
2695  //the corresponding bit of its second operand. If both bits are 1,
2696  //the corresponding result bit is set to 1. Otherwise, the corresponding
2697  //result bit is set to 0.
2698  //i.e if(DAS.StepM.OOP[AMS1] = 00000100) -->
2699  //DAS.StepM.OOP[AMS1] | 0xFB = 00000100 | 11111011 = 00000000
2700  DAS.StepM.OOP[AMS1] &= 0xFB; //11111011
2701 
2702  HGFlg = 0;
2703  MObjectSetText(DAS.Gui.ContrPanel.pblamps[0], "Hg Off");
2704  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedHG, "SYS\\ledoff.bmp");
2705  }
2706 
2707  // 1's complement
2708  // 1) if mod and DAS.StepM.OOP[AMS1] = 00000100 then 11111011
2709  // 2) if !mod and DAS.StepM.OOP[AMS1] = 00000000 then 11111111
2710  DAS.StepM.OOP[AMS1] = ~DAS.StepM.OOP[AMS1];
2711 
2712  //write on the optoinsulated port
2713  // 1) bit 2 set to 0 (we are in negative logic so 0 = ON, 1 = OFF)
2714  // 1) bit 2 set to 1 (we are in negative logic so 0 = ON, 1 = OFF)
2716 
2717  // again 1's complement for restoring the positive logic
2718  // 1) if mod and DAS.StepM.OOP[AMS1] = 11111011 then 00000100 (bit 2 on)
2719  // 2) if !mod and DAS.StepM.OOP[AMS1] = 11111111 then 00000000 (bit 2 off)
2720  DAS.StepM.OOP[AMS1] = ~DAS.StepM.OOP[AMS1];
2721 
2722 }
das DAS
DAS structure.
Definition: Spat_Device.c:27
stepm StepM
Stepper motors parameters structure.
gui Gui
Graphic User Interface Structure.
void MPixmapSetImageFile(MOBJECT pixmap, const char *fname)
MOBJECT pblamps[2]
Control Panel Push buttons for HG and QJ Lamps.
void MObjectSetText(MOBJECT obj, const char *text)
unsigned char OOP[AMSMAX]
2 byte Word for AMS Opto insulated Output Port Status
int AMS_wopto(int id, unsigned int w)
write the value on the optoinsulated port write the value on the optoinsulated port.
Definition: Dxl.c:911
controlpanel ContrPanel
Control Panel Structure.
#define AMS1
AMS1 address.
int HGFlg
Definition: DAS_Spatram.h:2968
MOBJECT LedHG
Control Panel Led for HG Lamp.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ HiresPS()

void HiresPS ( int  mod)

Hires Power Supply ON/OFF
.

Parameters
mod
  • = 0 –> Hires Power Supply OFF
  • = 1 –> Hires Power Supply ON

Definition at line 2532 of file Spat_Device.c.

References AMS1, AMS_wopto(), stepm::OOP, and das::StepM.

Referenced by InitCCD_AMS(), and ShutCB().

2533 {
2534  if(mod)
2535  DAS.StepM.OOP[AMS1] |= 0x20; //bit 5, 00100000, dec = 32
2536  else
2537  DAS.StepM.OOP[AMS1] &= 0xDF; // 11011111, dec = 223
2538 
2539 
2540  // 1's complement
2541  DAS.StepM.OOP[AMS1] = ~DAS.StepM.OOP[AMS1];
2542  //write on the optoinsulated port
2544  // again 1's complement for restoring the positive logic
2545  DAS.StepM.OOP[AMS1] = ~DAS.StepM.OOP[AMS1];
2546 
2547 
2548 
2549 }
das DAS
DAS structure.
Definition: Spat_Device.c:27
stepm StepM
Stepper motors parameters structure.
unsigned char OOP[AMSMAX]
2 byte Word for AMS Opto insulated Output Port Status
int AMS_wopto(int id, unsigned int w)
write the value on the optoinsulated port write the value on the optoinsulated port.
Definition: Dxl.c:911
#define AMS1
AMS1 address.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ MIGEActualZenAz()

float MIGEActualZenAz ( int  mode)

convert SUN AZIMUTH and ZENITH angles, to be used with MIGE mode = 0 –> fix azimuth and return azimuth for MIGE positioning mode = 1 –> fix zenith and return zenith for MIGE positioning

Definition at line 2759 of file Spat_Device.c.

References elev, MIGEAz(), MIGEZen(), S_azim, and S_zenetr.

2760 {
2761 
2762 // float MAZMax = 120.0; //MIGE Azimut MAX
2763 // float MAZMin = -60.0; //MIGE Azimut Min
2764  float MAZMax = 120.0; //MIGE Azimut MAX
2765  float MAZMin = 0.0; //MIGE Azimut Min
2766 
2767  float SAA, SEA, elev, az;
2768  char str[80];
2769 
2770  if (mode == 0) //fix azimuth angle
2771  {
2772  //Need condition for the latitude?
2773  // Inside Tropics
2774 
2775  //sun Azimuth angle
2776  sprintf(str, "%.01lf", S_azim);
2777  SAA = (float)atof(str);
2778 
2779  az = MIGEAz(SAA);
2780  return az;
2781  }
2782 
2783  if (mode == 1) //fix zenith angle
2784  {
2785  //sun Azimuth angle
2786  sprintf(str, "%.01lf", S_azim);
2787  SAA = (float)atof(str);
2788 
2789 
2790  //sun Zenit angle
2791  sprintf(str, "%.01lf", (90 - S_zenetr));
2792  SEA = (float)atof(str);
2793 
2794  elev = MIGEZen(SEA);
2795 /*
2796  if (SAA >= 0 && SAA <= MAZMax)
2797  {
2798  elev = elev;
2799  }
2800  if (SAA > MAZMax && SAA <= (MAZMax + 180))
2801  {
2802  elev = -elev;
2803  }
2804  if (SAA > (MAZMax + 180) && SAA < 360)
2805  {
2806  elev = elev;
2807  }
2808 */
2809  return elev;
2810  }
2811 
2812 return 0;
2813 
2814 }
double S_zenetr
Definition: SOLPOS.C:92
double S_azim
O: Solar azimuth angle: N=0, E=90, S=180, W=270.
Definition: SOLPOS.C:45
static double elev
Definition: SOLPOS.C:130
float MIGEZen(float p)
Definition: CreateForms.c:3419
float MIGEAz(float p)
Definition: CreateForms.c:3475
+ Here is the call graph for this function:

§ Peltier()

void Peltier ( int  mod)

Peltier ON/OFF
.

Parameters
mod
  • = 0 –> Peltier OFF
  • = 1 –> Peltier ON

Definition at line 2597 of file Spat_Device.c.

References AMS1, AMS_wopto(), delay(), stepm::OOP, and das::StepM.

Referenced by ADTesterCB(), OMU_ChooseDir(), and ShutCB().

2598 {
2599 
2600  if(mod) // Cold
2601  DAS.StepM.OOP[AMS1] |= 0x01; //bit 0 , 00000001
2602  else // Heat
2603  DAS.StepM.OOP[AMS1] &= 0xFE;
2604 
2605 
2606  // 1's complement
2607  DAS.StepM.OOP[AMS1] = ~DAS.StepM.OOP[AMS1];
2608  //write on the optoinsulated port
2610  delay(750);
2611  // again 1's complement for restoring the positive logic
2612  DAS.StepM.OOP[AMS1] = ~DAS.StepM.OOP[AMS1];
2613 
2614 
2615 
2616 
2617 }
das DAS
DAS structure.
Definition: Spat_Device.c:27
stepm StepM
Stepper motors parameters structure.
unsigned char OOP[AMSMAX]
2 byte Word for AMS Opto insulated Output Port Status
void delay(unsigned long d)
Pauses for a specified number of milliseconds. .
Definition: Dxl.c:1113
int AMS_wopto(int id, unsigned int w)
write the value on the optoinsulated port write the value on the optoinsulated port.
Definition: Dxl.c:911
#define AMS1
AMS1 address.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ PeltierPS()

void PeltierPS ( int  mod)

Peltier Power Supply ON/OFF
.

Parameters
mod
  • = 0 –> Peltier Power Supply OFF
  • = 1 –> Peltier Power Supply ON

Definition at line 2551 of file Spat_Device.c.

References AMS1, AMS_wopto(), stepm::OOP, and das::StepM.

Referenced by InitCCD_AMS(), and ShutCB().

2552 {
2553 
2554  if(mod)
2555  DAS.StepM.OOP[AMS1] |= 0x10; //bit 4, 00010000, dec = 16
2556  else
2557  DAS.StepM.OOP[AMS1] &= 0xEF; // 11101111, dec = 239
2558 
2559 
2560  // 1's complement
2561  DAS.StepM.OOP[AMS1] = ~DAS.StepM.OOP[AMS1];
2562  //write on the optoinsulated port
2564  // again 1's complement for restoring the positive logic
2565  DAS.StepM.OOP[AMS1] = ~DAS.StepM.OOP[AMS1];
2566 
2567 
2568 }
das DAS
DAS structure.
Definition: Spat_Device.c:27
stepm StepM
Stepper motors parameters structure.
unsigned char OOP[AMSMAX]
2 byte Word for AMS Opto insulated Output Port Status
int AMS_wopto(int id, unsigned int w)
write the value on the optoinsulated port write the value on the optoinsulated port.
Definition: Dxl.c:911
#define AMS1
AMS1 address.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ QjLamp()

void QjLamp ( int  mod)

QJ Lamp ON/OFF
.

Parameters
mod
  • = 0 –> Lamp OFF
  • = 1 –> Lamp ON

Definition at line 2724 of file Spat_Device.c.

References AMS1, AMS_wopto(), gui::ContrPanel, das::Gui, controlpanel::LedQJ, MObjectSetText(), MPixmapSetImageFile(), stepm::OOP, controlpanel::pblamps, QJFlg, and das::StepM.

Referenced by DB_KeyB_CB(), E_Qj_Off(), E_Qj_On(), GetDefPix(), ShutCB(), and WinRes().

2725 {
2726 
2727  if(mod)
2728  {
2729  DAS.StepM.OOP[AMS1] |= 0x08; //bit 3, 00001000
2730  QJFlg = 1;
2731  MObjectSetText(DAS.Gui.ContrPanel.pblamps[1], "Qj On");
2732  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedQJ, "SYS\\ledonQJ.bmp");
2733 
2734  }
2735  else
2736  {
2737  DAS.StepM.OOP[AMS1] &= 0xF7; //11110111
2738  QJFlg = 0;
2739  MObjectSetText(DAS.Gui.ContrPanel.pblamps[1], "Qj Off");
2740  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedQJ, "SYS\\ledoff.bmp");
2741  }
2742 
2743  // 1's complement
2744  DAS.StepM.OOP[AMS1] = ~DAS.StepM.OOP[AMS1];
2745  //write on the optoinsulated port
2747  // again 1's complement for restoring the positive logic
2748  DAS.StepM.OOP[AMS1] = ~DAS.StepM.OOP[AMS1];
2749 
2750 
2751 }
das DAS
DAS structure.
Definition: Spat_Device.c:27
stepm StepM
Stepper motors parameters structure.
gui Gui
Graphic User Interface Structure.
MOBJECT LedQJ
Control Panel Led for QJ Lamp.
void MPixmapSetImageFile(MOBJECT pixmap, const char *fname)
int QJFlg
Definition: DAS_Spatram.h:2969
MOBJECT pblamps[2]
Control Panel Push buttons for HG and QJ Lamps.
void MObjectSetText(MOBJECT obj, const char *text)
unsigned char OOP[AMSMAX]
2 byte Word for AMS Opto insulated Output Port Status
int AMS_wopto(int id, unsigned int w)
write the value on the optoinsulated port write the value on the optoinsulated port.
Definition: Dxl.c:911
controlpanel ContrPanel
Control Panel Structure.
#define AMS1
AMS1 address.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ SD_Azimuth()

int SD_Azimuth ( float  ang,
float  raz 
)

Positioning Azimuth.
The Zenith reaches the position specified by ang.

Parameters
ang=mechanical angle
raz=real azimuth angle
Returns
er:
  • = 0 –> Operation concluded succesfully
  • = 1 –> Problems in positioning

Definition at line 3110 of file Spat_Device.c.

References controlpanel::Albl_LS, AMS3, gui::ContrPanel, DB_KB_ButtonActive(), DB_StepMotor(), flag::exec, flag::fileprg, das::Gui, pushbutt::KeyB, controlpanel::LedSM, MIGEAz(), MObjectSetSensitive(), MObjectSetText(), MPixmapSetImageFile(), stepm::multiplier, stepm::nstep, AzimuthSt::Pos, gui::PushButt, AzimuthSt::realazpos, stepm::Revo, stepm::SM_B, SM_stepr(), stepm::step, and das::StepM.

Referenced by ActMvAzimDegCB(), E_AAMeasure(), E_Azimuth(), and E_IRefSun().

3111 {
3112  int er = 0;
3113  char buf[80];
3114  long n, dp = 500; // dp sono i dead pulse, vanno aggiunti all'inversione per il recupero del gioco
3115  int dir;
3116  int k = 0;
3117  float yy;
3118  double GRASTEP, STEPGRA;
3119  float razang;
3120 
3121 
3122  razang=MIGEAz((float)ang);
3123 
3124  k = SM_stepr(DAS.StepM.step[AMS3][DAS.StepM.SM_B]); // step/round
3125 
3126  GRASTEP = (float)360.0 / (float) k; // degree/step
3127 
3128  STEPGRA = (float) k / (float)360.0; // step/degree
3129 
3130  yy = (razang - (float)AST.Pos);
3131 
3132  n = (long) (yy * STEPGRA * DAS.StepM.multiplier[AMS3][1]);
3133 
3134  AST.Pos = razang;
3135  AST.realazpos = ang;
3136 
3137  // Select direction
3138  if(n < 0)
3139  dir = 1;
3140  else
3141  dir = 0;
3142 
3143  n = labs(n);
3144  DAS.StepM.Revo[AMS3][DAS.StepM.SM_B] = dir;
3145  DAS.StepM.nstep[AMS3][DAS.StepM.SM_B] = n;
3146 
3147 
3148 
3149 
3150  //Disattiva i pulsanti sulla keyboard
3151  DB_KB_ButtonActive(0);
3154 
3155 /*
3156  k = (float) SM_stepr(DAS.StepM.step[AMS3][1]); // step/round
3157 
3158  GRASTEP = (float)360.0 / (float) k; // degree/step
3159 
3160  STEPGRA = (float) k / (float)360.0; // step/degree
3161 
3162 
3163 
3164  x = (ang - AST.Pos); // (-35-0) = -35 //1
3165  //(55-(-35)) = -90 //2
3166  //(56-55) = 1 //3
3167  //(90-96) = 6 //4
3168 
3169 
3170  n = (long) (x * STEPGRA * DAS.StepM.multiplier[AMS3][1]); //4 e' la riduzione
3171 
3172  prepos = AST.Pos;
3173  AST.Pos = ang;
3174  AST.realazpos = raz;
3175 
3176  sprintf(buf, " %.1lf --> %.1lf", prepos, ang);
3177  Status(buf);
3178 
3179  // Select direction
3180  if(n < 0)
3181  dir = 1;
3182  else
3183  dir = 0;
3184 
3185  n = labs(n);
3186 
3187 
3188 
3189 
3190  if (n==0)
3191  {
3192  //Attiva i pulsanti sulla keyboard
3193  DB_KB_ButtonActive(1);
3194  return 1;
3195  }
3196 */
3197  // Eseguo n passi
3198  if(n)
3199  {
3200  er = DB_StepMotor(AMS3, 5, DAS.StepM.nstep[AMS3][DAS.StepM.SM_B], DAS.StepM.Revo[AMS3][DAS.StepM.SM_B]);
3201  if (er)
3202  {
3203  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS3][1], "SYS\\ledGreen.bmp");
3204  }
3205  }
3206 
3207 
3208  //sprintf(buf, "%.1lf%s %.1lf%s", ang, " °", raz, " °");
3209  sprintf(buf, "%.1lf", AST.realazpos );
3211  if(!FLAG.fileprg || !FLAG.exec )
3212  //Attiva i pulsanti sulla keyboard se non si sta eseguendo una tabella di misure
3213  //oppure se il programma e' stato sospeso (si e' premuto il tasto "pause")
3214  DB_KB_ButtonActive(1);
3215 
3216 
3217 
3218  if(er) return 1;
3219 
3220 
3221  return 0;
3222 
3223 }
das DAS
DAS structure.
Definition: Spat_Device.c:27
stepm StepM
Stepper motors parameters structure.
gui Gui
Graphic User Interface Structure.
void DB_KB_ButtonActive(int mod)
Enable/Disable Push buttons on the Control Panel.
Definition: CreateForms.c:3810
MOBJECT LedSM[AMSMAX][2]
Leds for stepper motors status.
MOBJECT Albl_LS[8]
Active Control Panel Labels for LIS status.
MOBJECT KeyB[28]
Keyboard Buttons.
double realazpos
void MPixmapSetImageFile(MOBJECT pixmap, const char *fname)
unsigned long nstep[AMSMAX][2]
Number of steps to be executed.
float multiplier[AMSMAX][2]
multiplier, > 0 multiplier, < 0 demultiplier
int SM_stepr(int t)
AMS &#39;steps/round&#39; value return the AMS &#39;steps/round&#39; value (microstepping) depending on the setted st...
Definition: Spat_Device.c:209
void MObjectSetText(MOBJECT obj, const char *text)
AzimuthSt AST
Definition: Spat_Device.c:25
int exec
= 0 -> PRG Execution Paused; = 1 -> PRG Execution Resumed
pushbutt PushButt
Push buttons.
int Revo[AMSMAX][2]
Revolution Direction CW CCW.
flag FLAG
flags structure
Definition: Spat_Device.c:19
int SM_B
Motor B (su Y12) respectively: ID=0->Grating,ID=1->Not Connected,ID=2->Azimuth.
int fileprg
Flag indicating the execution of a PRG file: = 0 –> No PRG File; = 1 –> PRG file in execution...
controlpanel ContrPanel
Control Panel Structure.
int step[AMSMAX][2]
Stepper Motors Step.
double Pos
Azimuth Current Position.
void MObjectSetSensitive(MOBJECT obj)
float MIGEAz(float p)
Definition: CreateForms.c:3475
#define AMS3
AMS3 address.
int DB_StepMotor(int id, int motor, long step, int dir)
Send steps to the selected stepper motor. .
Definition: Dxl.c:816
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ SD_FilterW()

int SD_FilterW ( int  filter)

Positioning Filter wheel.
The filter wheel move on the filter number specified by filter.
See also Filter Wheel page.

Parameters
filter
  • 0 = NULL
  • 1 = NULL
  • 2 = UG5
  • 3 = UG11
  • 4 = BG23
  • 5 = ND
    – For LIS Spectrometer the filter wheel is bigger so we have 2 filters more and the filter parameter renges since 0 to 7.
Returns
er:
  • 0 = Operation concluded succesfully
  • 1 = Problems in positioning

Definition at line 2244 of file Spat_Device.c.

References controlpanel::Albl_LS, AMS2, gui::ContrPanel, DB_KB_ButtonActive(), DB_StepMotor(), paramini::EqType, flag::exec, Fil_Code, Fil_Code8H, Fil_CodeNG, Fil_CodeNG1, Fil_CodeTropo, flag::fileprg, FWS, GASCODNG1, GASCODNG2, GASCODNG3, GASCODNG4, das::Gui, gui::HorizMeas, pushbutt::KeyB, horizmeas::lbl, controlpanel::LedSM, LIS_, flag::manhormeas, MMessageDialog(), MObjectSetSensitive(), MObjectSetText(), MPixmapSetImageFile(), das::Paramini, FilterWheelSt::Pos, gui::PushButt, SM_stepr(), SPATRAM, SPATRAM2, SPATRAM3, SPATRAMPLUS, Status(), stepm::step, das::StepM, and TROPOGAS.

Referenced by AutoR_SetND_Filter(), D_Calibra(), D_Measure(), DB_KeyB_CB(), E_AAMeasure(), E_Almucantar(), E_Average(), E_AvgCCDHor(), E_DFMeasure(), E_DirectSun(), E_Filter(), E_HgScan(), E_IRefSun(), E_Meashor(), E_Meashor2(), E_Measure(), and E_QjScan().

2245 {
2246 
2247  char buf[80];
2248  long n[3];
2249  long nx;
2250  int d, dir[3]; // 0 = CW, 1 = CCW
2251  int k , er;
2252 // char Filter[4];
2253 
2254  //Disattiva i pulsanti sulla keyboard
2255  DB_KB_ButtonActive(0);
2258 
2259  /************************************************************/
2260  //Sceglie quale ruota e' installata (a 8 fori....
2261  if(DAS.Paramini.EqType == LIS_)
2262  {
2263  k = SM_stepr(DAS.StepM.step[AMS2][0]) / 8;
2264 
2265  if(filter < 0 || filter > 7) return 0;
2266  }
2267  // ...oppure a 6 fori....
2268  else if (DAS.Paramini.EqType == SPATRAM ||
2269  DAS.Paramini.EqType == GASCODNG1 ||
2271  DAS.Paramini.EqType == TROPOGAS ||
2275  DAS.Paramini.EqType == SPATRAM3 ||
2277  {
2278  k = SM_stepr(DAS.StepM.step[AMS2][0]) / 6;
2279  if(filter < 0 || filter > 5) return 0;
2280  }
2281  else // ...oppure non lo sa)
2282  {
2283  sprintf(buf, "For this Equipment the Filter Wheel type is UNKNOWN\nPlease Contact DANBO!!!!");
2284  er = MMessageDialog("DAS information", buf, "Ok", NULL);
2285  if (!er)
2286  {
2287  return 0;
2288  }
2289 
2290  }
2291  /**************************************************************/
2292 
2293  n[2] = (long)(FWS.Pos - filter) * k;
2294 
2295  if(n[2] < 0) dir[2] = 1;
2296  else dir[2] = 0;
2297  n[2] = labs(n[2]);
2298 
2299  nx = n[2];
2300  d = dir[2];
2301 
2302  // Eseguo NStep
2303 
2304  Status("New Filter Wheel Position");
2305 
2306 
2307  if(nx)
2308  {
2309  er=DB_StepMotor(AMS2, 2, nx, d);
2310  if (er)
2311  {
2312  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS2][0], "SYS\\ledGreen.bmp");
2313  }
2314  }
2315 
2316 
2317  FWS.Pos = filter;
2318  if ( DAS.Paramini.EqType == LIS_)
2319  sprintf(buf, "%s", Fil_Code8H[filter]);
2320  else
2321  {
2322  if(DAS.Paramini.EqType == TROPOGAS)
2323  sprintf(buf, "%s",Fil_CodeTropo[filter]);
2325  sprintf(buf, "%s",Fil_CodeNG[filter]);
2326  else if (DAS.Paramini.EqType == GASCODNG1)
2327  sprintf(buf, "%s",Fil_CodeNG1[filter]);
2328  else
2329  sprintf(buf, "%s",Fil_Code[filter]);
2330  }
2331 
2333  if(FLAG.manhormeas)
2334  MObjectSetText(DAS.Gui.HorizMeas.lbl[2], buf);
2335  Status("Ready");
2336 
2337  if(!FLAG.fileprg || !FLAG.exec )
2338  //Attiva i pulsanti sulla keyboard se non si sta eseguendo una tabella di misure
2339  //oppure se il programma e' stato sospeso (si e' premuto il tasto "pause")
2340  DB_KB_ButtonActive(1);
2341 
2342 
2343  if(er) return 1;
2344 
2345  return 0;
2346 
2347 
2348 }
das DAS
DAS structure.
Definition: Spat_Device.c:27
stepm StepM
Stepper motors parameters structure.
#define SPATRAM
SPectrometer for Atmospheric TRAcers Measurements - CGE-UE Portugal.
gui Gui
Graphic User Interface Structure.
void DB_KB_ButtonActive(int mod)
Enable/Disable Push buttons on the Control Panel.
Definition: CreateForms.c:3810
MOBJECT LedSM[AMSMAX][2]
Leds for stepper motors status.
MOBJECT Albl_LS[8]
Active Control Panel Labels for LIS status.
#define AMS2
AMS2 address.
MOBJECT KeyB[28]
Keyboard Buttons.
void MPixmapSetImageFile(MOBJECT pixmap, const char *fname)
char * Fil_Code8H[]
const char array for the realisation of the Filters buttons in the Filter shell
Definition: DAS_Spat.c:204
int SM_stepr(int t)
AMS &#39;steps/round&#39; value return the AMS &#39;steps/round&#39; value (microstepping) depending on the setted st...
Definition: Spat_Device.c:209
void MObjectSetText(MOBJECT obj, const char *text)
int Pos
Filter Wheel current Position.
#define LIS_
Lampedusa Island Spectrometer - ENEA.
int exec
= 0 -> PRG Execution Paused; = 1 -> PRG Execution Resumed
#define TROPOGAS
TROPOspheric Gas Analyzer Spectrometer.
horizmeas HorizMeas
Structure for Horizontal Measurements.
char * Fil_CodeNG[]
const char array for the realisation of the Filters buttons in the Filter shell for GASCODNG2 and NG3...
Definition: DAS_Spat.c:216
#define GASCODNG2
GASCODNG 2 (with ATX power supply & HiresIV)
#define SPATRAM2
SPATRAM2 (with ATX power supply & HiresV)
#define SPATRAMPLUS
As SPATRAM plus AltAzimuth platform.
void Status(char *tit)
Writes information&#39;s on the Status label .
Definition: Load.c:1556
#define GASCODNG3
GASCODNG 3 (with ATX power supply & HiresIV)
pushbutt PushButt
Push buttons.
#define GASCODNG1
GASCODNG 1 (with ATX power supply & HiresIV)
#define GASCODNG4
GASCODNG 4.
char * Fil_CodeNG1[]
const char array for the realisation of the Filters buttons in the Filter shell for GASCODNG1 instrum...
Definition: DAS_Spat.c:213
int MMessageDialog(const char *t, const char *msg, const char *btn1, const char *btn2,...)
#define SPATRAM3
SPATRAM3.
flag FLAG
flags structure
Definition: Spat_Device.c:19
char * Fil_Code[]
const char array for the realisation of the Filters buttons in the Filter shell
Definition: DAS_Spat.c:207
int fileprg
Flag indicating the execution of a PRG file: = 0 –> No PRG File; = 1 –> PRG file in execution...
controlpanel ContrPanel
Control Panel Structure.
int manhormeas
1 = horizontal measurements in manual mode
int step[AMSMAX][2]
Stepper Motors Step.
char * Fil_CodeTropo[]
const char array for the realisation of the Filters buttons in the Filter shell for TROPOGAS instrume...
Definition: DAS_Spat.c:210
int EqType
Spectrometer Type.
void MObjectSetSensitive(MOBJECT obj)
MOBJECT lbl[15]
generic labels for hor meas shell
FilterWheelSt FWS
Filter Wheel.
Definition: DAS_Spat.c:57
int DB_StepMotor(int id, int motor, long step, int dir)
Send steps to the selected stepper motor. .
Definition: Dxl.c:816
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:

§ SD_FNTorqueM()

void SD_FNTorqueM ( int  mod)

Positioning NDFilter.
.

Definition at line 3066 of file Spat_Device.c.

References controlpanel::Albl_LS, AMS1, AMS_wopto(), gui::ContrPanel, das::Gui, controlpanel::LedSM, MObjectSetText(), MPixmapSetImageFile(), stepm::OOP, das::StepM, and TMFlg.

Referenced by AutoR_SetND_Filter(), DB_KeyB_CB(), E_AAMeasure(), E_Almucantar(), E_DFMeasure(), E_DirectSun(), E_HgScan(), and E_QjScan().

3067 {
3068 
3069  if(mod)
3070  {
3071 
3072  // Bitwise inclusive OR
3073  //The bitwise-inclusive-OR operator compares each bit of its first operand to
3074  //the corresponding bit of its second operand. If either bit is 1,
3075  //the corresponding result bit is set to 1. Otherwise, the corresponding
3076  //result bit is set to 0.
3077  //i.e if(DAS.StepM.OOP[AMS1] = 00000000) -->
3078  //DAS.StepM.OOP[AMS1] | 0x10 = 00000000 | 00010000 = 00010000
3079  DAS.StepM.OOP[AMS1] |= 0x10; //bit 4, 00010000
3080  TMFlg = 1;
3082  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[1][1], "SYS\\ledGreen.bmp");
3083 
3084  }
3085  else
3086  {
3087  //The bitwise-AND operator compares each bit of its first operand to
3088  //the corresponding bit of its second operand. If both bits are 1,
3089  //the corresponding result bit is set to 1. Otherwise, the corresponding
3090  //result bit is set to 0.
3091  //i.e if(DAS.StepM.OOP[AMS1] = 00010000) -->
3092  //DAS.StepM.OOP[AMS1] | 0xEF = 00010000 | 11101111 = 00000000
3093  DAS.StepM.OOP[AMS1] &= 0xEF; //11111011
3094 
3095  TMFlg = 0;
3096  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[3], " OFF");
3097  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[1][1], "SYS\\ledoff.bmp");
3098  }
3099 
3100  DAS.StepM.OOP[AMS1] = ~DAS.StepM.OOP[AMS1];
3101 
3103 
3104  DAS.StepM.OOP[AMS1] = ~DAS.StepM.OOP[AMS1];
3105 
3106 }
das DAS
DAS structure.
Definition: Spat_Device.c:27
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 MPixmapSetImageFile(MOBJECT pixmap, const char *fname)
void MObjectSetText(MOBJECT obj, const char *text)
int TMFlg
Definition: DAS_Spatram.h:2972
unsigned char OOP[AMSMAX]
2 byte Word for AMS Opto insulated Output Port Status
int AMS_wopto(int id, unsigned int w)
write the value on the optoinsulated port write the value on the optoinsulated port.
Definition: Dxl.c:911
controlpanel ContrPanel
Control Panel Structure.
#define AMS1
AMS1 address.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ SD_Grating()

int SD_Grating ( int  ang)

Positioning Grating.
The Grating move to the position specified by ang (Wavelength)

Parameters
ang–> int from 0 to 14 –> grating position –> Wavelength
Returns
er:
  • = 0 –> Operation concluded succesfully
  • = 1 –> Problems in positioning

Definition at line 2108 of file Spat_Device.c.

References controlpanel::Albl_LS, AMS1, gui::ContrPanel, DB_KB_ButtonActive(), DB_StepMotor(), GratingSt::dp, flag::exec, flag::fileprg, das::Gui, gui::HorizMeas, pushbutt::KeyB, horizmeas::lbl, controlpanel::LedSM, flag::manhormeas, MObjectSetSensitive(), MObjectSetText(), MPixmapSetImageFile(), stepm::multiplier, stepm::nstep, GratingSt::Pos, gui::PushButt, SM_stepr(), Status(), stepm::step, das::StepM, wav, wl, and GratingSt::Wl.

Referenced by D_Calibra(), D_Measure(), DB_KeyB_CB(), E_AAMeasure(), E_Almucantar(), E_Average(), E_AvgCCDHor(), E_DFMeasure(), E_DirectSun(), E_HgScan(), E_IRefSun(), E_Lambda(), E_Meashor(), E_Meashor2(), E_Measure(), E_QjScan(), and WinRes().

2109 {
2110  int er = 0;
2111  char buf[80];
2112  long n, dp = 1500; // dp sono i dead pulse, vanno aggiunti all'inversione per il recupero del gioco
2113  int dir;
2114  float k = 0;
2115  long period = 5000;
2116  int prepos;
2117  long prestep;
2118  //se ang non e' compreso nei limiti esce dalla function
2119  if(ang < 0 || ang > 18) return 0;
2120 
2121  //Status("Set NEW Grating Position");
2122 
2123  //Disable the keyboard buttons
2124  DB_KB_ButtonActive(0);
2127 
2128 
2129  /******************************************
2130  //in SD_Position
2131  k = SM_stepr(DAS.StepM.step[AMS1][1])/3200;
2132  n = (long)(((float) (-wav[GRS.Wl] + wav[w]) ) * 4 * k);
2133 
2134  if(n < 0)
2135  dir = 1;
2136  else
2137  dir = 0;
2138 
2139  n = labs(n);
2140 
2141 
2142  /***********************************************/
2143 
2144  //Multiplier factor depending on the values of microsteps
2145  k = (float)SM_stepr(DAS.StepM.step[AMS1][1])/3200;
2146 
2147  //Actual steps sent to the grating motor
2148  n = (long)(((float) (-wav[GRS.Wl] + wav[ang]) ) * DAS.StepM.multiplier[AMS1][1] * k);
2149 
2150  prepos = wl[GRS.Wl];
2151  prestep = wav[GRS.Wl];
2152  GRS.Wl = ang;
2153 
2154  sprintf(buf, " %4d --> %4d", prepos, wl[ang]);
2155  Status(buf);
2156 
2157  //Select the direction (n < 0 --> Dir = 1 = UV; n > 0 --> Dir = 0 = Vis.)
2158  if(n < 0)
2159  dir = 1;
2160  else
2161  dir = 0;
2162 
2163  n = labs(n);
2164  DAS.StepM.nstep[AMS1][1]= n;
2165 
2166  if(n && dir == 0) //towards UV
2167  n += GRS.dp; // add fixed step number for backlash recovery (recupero del gioco)
2168 
2169 
2170  GRS.Pos = n;
2171 
2172  if (n==0)
2173  {
2174  //Attiva i pulsanti sulla keyboard
2175  DB_KB_ButtonActive(1);
2176  return 1;
2177  }
2178 
2179  // Eseguo n passi
2180  if(n)
2181  {
2182  er = DB_StepMotor(AMS1, 1, n, dir);
2183  if (er)
2184  {
2185  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS1][1], "SYS\\ledGreen.bmp");
2186  }
2187  }
2188 
2189  //Se ci si e' mossi verso l'UV si fa il recupero del gioco
2190 /* if(DAS.Paramini.EqType == LIS_)
2191  {
2192  if(dir == 1)
2193  {
2194  er=DB_StepMotor(AMS1, 1, GRS.dp, 1);
2195  if (er)
2196  {
2197  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM2, "SYS\\ledGreen.bmp");
2198  }
2199  }
2200 
2201  }
2202  else if (DAS.Paramini.EqType == SPATRAM || DAS.Paramini.EqType == GASCODNG || DAS.Paramini.EqType == SPATRAMPLUS || DAS.Paramini.EqType == TROPOGAS )
2203  {
2204 */
2205  if(n && dir == 0)
2206  {
2207  er=DB_StepMotor(AMS1, 1, GRS.dp, 1);
2208  if (er)
2209  {
2210  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS1][1], "SYS\\ledGreen.bmp");
2211  }
2212  }
2213 // }
2214 
2215 
2216  sprintf(buf, "%4d", wl[ang]);
2218 
2219  sprintf(buf, "Steps : %ld", (-prestep + wav[ang]) );
2220  Status(buf);
2221 
2222  if(FLAG.manhormeas)
2223  MObjectSetText(DAS.Gui.HorizMeas.lbl[1], buf);
2224  if(!FLAG.fileprg || !FLAG.exec )
2225  //Attiva i pulsanti sulla keyboard se non si sta eseguendo una tabella di misure
2226  //oppure se il programma e' stato sospeso (si e' premuto il tasto "pause")
2227  DB_KB_ButtonActive(1);
2228 
2229 
2230 
2231  if(er) return 1;
2232 
2233 
2234  return 0;
2235 
2236 }
das DAS
DAS structure.
Definition: Spat_Device.c:27
stepm StepM
Stepper motors parameters structure.
gui Gui
Graphic User Interface Structure.
void DB_KB_ButtonActive(int mod)
Enable/Disable Push buttons on the Control Panel.
Definition: CreateForms.c:3810
MOBJECT LedSM[AMSMAX][2]
Leds for stepper motors status.
MOBJECT Albl_LS[8]
Active Control Panel Labels for LIS status.
MOBJECT KeyB[28]
Keyboard Buttons.
void MPixmapSetImageFile(MOBJECT pixmap, const char *fname)
unsigned long nstep[AMSMAX][2]
Number of steps to be executed.
float multiplier[AMSMAX][2]
multiplier, > 0 multiplier, < 0 demultiplier
int SM_stepr(int t)
AMS &#39;steps/round&#39; value return the AMS &#39;steps/round&#39; value (microstepping) depending on the setted st...
Definition: Spat_Device.c:209
void MObjectSetText(MOBJECT obj, const char *text)
int exec
= 0 -> PRG Execution Paused; = 1 -> PRG Execution Resumed
int Wl
Grating Wavelength.
horizmeas HorizMeas
Structure for Horizontal Measurements.
long dp
Grating backslash recovery steps.
void Status(char *tit)
Writes information&#39;s on the Status label .
Definition: Load.c:1556
pushbutt PushButt
Push buttons.
flag FLAG
flags structure
Definition: Spat_Device.c:19
int wl[]
WaveLength definition - for SD_Grating.
Definition: DAS_Spat.c:182
int fileprg
Flag indicating the execution of a PRG file: = 0 –> No PRG File; = 1 –> PRG file in execution...
controlpanel ContrPanel
Control Panel Structure.
GratingSt GRS
Grating.
Definition: Spat_Device.c:22
#define AMS1
AMS1 address.
int manhormeas
1 = horizontal measurements in manual mode
int step[AMSMAX][2]
Stepper Motors Step.
long Pos
Grating Position.
long wav[]
Step Number definition - for SD_Grating.
Definition: DAS_Spat.c:195
void MObjectSetSensitive(MOBJECT obj)
MOBJECT lbl[15]
generic labels for hor meas shell
int DB_StepMotor(int id, int motor, long step, int dir)
Send steps to the selected stepper motor. .
Definition: Dxl.c:816
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ SD_Mirror()

int SD_Mirror ( int  where)

Positioning Input Mirror.
The Input Mirror reaches the position specified by where.

Parameters
where–> int from 0 to 3 –> grating position –> Wavelength
Returns
er:
  • = 0 –> Operation concluded succesfully
  • = 1 –> Problems in positioning

Definition at line 1898 of file Spat_Device.c.

References controlpanel::Albl_LS, AMS1, gui::ContrPanel, DB_KB_ButtonActive(), DB_StepMotor(), paramini::EqType, flag::exec, flag::fileprg, GASCODNG4, das::Gui, gui::HorizMeas, pushbutt::KeyB, horizmeas::lbl, controlpanel::LedSM, flag::manhormeas, Mir_Code, Mir_CodeTropo, MIS, MObjectSetSensitive(), MObjectSetText(), MPixmapSetImageFile(), stepm::multiplier, paramini::Offset, das::Paramini, MirrorSt::Pos, gui::PushButt, SM_stepr(), SPATRAM3, Status(), stepm::step, das::StepM, and TROPOGAS.

Referenced by D_Calibra(), D_Measure(), DB_KeyB_CB(), E_AAMeasure(), E_Almucantar(), E_Average(), E_AvgCCDHor(), E_DFMeasure(), E_DirectSun(), E_HgScan(), E_IRefSun(), E_Meashor(), E_Meashor2(), E_Measure(), E_Mirror(), E_QjScan(), and GetDefPix().

1899 {
1900 
1901  char buf[80];
1902  long n[3];
1903  long nx;
1904  int d, dir[3]; // 0 = CW, 1 = CCW
1905  int k = 1500, er = 0;
1906 
1907  int StepWithOffset [4][4];
1908 
1909  //mtr1(or 2) = 0 --> motor off
1910  //mtr1(or 2) = 1 --> motor on
1911  /* 22 */
1912 // AMS_MotorOn_Off(AMS1, 1, 0);
1913 
1914 // k = SM_stepr(DAS.StepM.step[AMS1][0]) * 6 / 4;
1915 
1916  k = SM_stepr(DAS.StepM.step[AMS1][0]) * DAS.StepM.multiplier[AMS1][0] / 4; //4 is the number of positions
1917 
1918  StepWithOffset [0][0] = 0;
1919  StepWithOffset [0][1] = 3*k - DAS.Paramini.Offset[2];
1920  StepWithOffset [0][2] = 2*k - DAS.Paramini.Offset[3];
1921  StepWithOffset [0][3] = k - DAS.Paramini.Offset[4];
1922 
1923  StepWithOffset [1][0] = k + DAS.Paramini.Offset[2];
1924  StepWithOffset [1][1] = 0;
1925  StepWithOffset [1][2] = 3*k - DAS.Paramini.Offset[3] + DAS.Paramini.Offset[2];
1926  StepWithOffset [1][3] = 2*k - DAS.Paramini.Offset[4]+ DAS.Paramini.Offset[2];
1927 
1928  StepWithOffset [2][0] = 2*k + DAS.Paramini.Offset[3];
1929  StepWithOffset [2][1] = k - DAS.Paramini.Offset[2]+DAS.Paramini.Offset[3];
1930  StepWithOffset [2][2] = 0;
1931  StepWithOffset [2][3] = 3*k - DAS.Paramini.Offset[4]+DAS.Paramini.Offset[3];
1932 
1933  StepWithOffset [3][0] = 3*k + DAS.Paramini.Offset[4];
1934  StepWithOffset [3][1] = 2*k - DAS.Paramini.Offset[2]+ DAS.Paramini.Offset[4];
1935  StepWithOffset [3][2] = k - DAS.Paramini.Offset[3] + DAS.Paramini.Offset[4];
1936  StepWithOffset [3][3] = 0;
1937 
1938 
1939 
1940 
1941 
1942  if(where < 0 || where > 3) return 0;
1943 
1944  //Disattiva i pulsanti sulla keyboard
1945  DB_KB_ButtonActive(0);
1948 
1949  nx = StepWithOffset [where][MIS.Pos];
1950  d = 1;
1951 
1952 
1953 // Procedure by danbo (20/10/2005)
1954 /*
1955  er = (long)(MIS.Pos - where);
1956 
1957  switch (er)
1958  {
1959  case 0:
1960  n[2] = 0;
1961  break;
1962  case 1:
1963  n[2] = er * k * 3;
1964 
1965  break;
1966  case -3:
1967  case -1:
1968  case 2:
1969  case (-2):
1970  n[2] = er * k;
1971  break;
1972  case 3:
1973  n[2] = er * k / 3;
1974 
1975  break;
1976 
1977  }
1978 
1979 
1980  dir[2] = 1;
1981  n[2] = labs(n[2]);
1982 */
1983  /*
1984  if (er < 0)
1985  n[2] += DAS.Paramini.Offset[where + 1];
1986  if (er > 0)
1987  n[2] -= DAS.Paramini.Offset[MIS.Pos + 1];
1988 */
1989 /*
1990  if(DAS.Paramini.Offset[MIS.Pos + 1] != 0 || DAS.Paramini.Offset[where + 1] != 0)
1991  {
1992 
1993  n[2] += (DAS.Paramini.Offset[MIS.Pos + 1] + DAS.Paramini.Offset[where + 1]);
1994 
1995  }
1996 */
1997 /*
1998  switch (where)
1999  {
2000  case 0:
2001  switch (MIS.Pos)
2002  case 0:
2003  n[2] = 0;
2004  break;
2005  case 1;
2006 */
2007 
2008  // n[2] += DAS.Paramini.Offset[MIS.Pos + 1];
2009 
2010 
2011 // sprintf(buf," MISPos:%d, where:%d, numstep=%ld, dir=%d", MIS.Pos, where, n[2], dir[2]);
2012 // MMessageDialog("DAS Inf", buf, "ok", NULL);
2013 
2014 
2015 //Previous version
2016 /*
2017  n[0] = (long) (4 - where + MIS.Pos) * k;
2018  dir[0] = 1;
2019 
2020  n[1] = (long) (4 - MIS.Pos + where) * k;
2021  dir[1] = 0;
2022 */
2023 // n[2] = (long)(MIS.Pos - where) * k;
2024 
2025 
2026  // In order to move the mirror always in the same direction
2027 // dir[2] = 1;
2028  // the direction is chosen depending on the previous position
2029 /* if(n[2] < 0) dir[2] = 1;
2030  else dir[2] = 0;
2031 */
2032 
2033 // n[2] = labs(n[2]);
2034 
2035  // Cerca il valore minimo
2036 /* for(c = 0; c < 2; c++)
2037  if(n[c] < n[c + 1]) { d = dir[c]; nx = n[c]; }
2038  else { d = dir[c + 1]; nx = n[c + 1]; }
2039 
2040  if (nx==0) return 1;
2041 
2042 
2043  nx = n[2];
2044  d = dir[2];
2045 */
2046  // Eseguo NStep
2047 
2048  Status("New Input Mirror Position");
2049 
2050  if(nx)
2051  {
2052  er = DB_StepMotor(AMS1, 0, nx, d);
2053 
2054  if (er)
2055  {
2056  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS1][0], "SYS\\ledGreen.bmp");
2057  }
2058 
2059 
2060  }
2061 
2062 
2063 
2064  MIS.Pos = where;
2065  /*--------------------------------------------------------------------*/
2066  // Send OffSet for Mirror position
2067 
2068 /* if(DAS.Paramini.Offset[MIS.Pos + 1] != 0)
2069  {
2070  if(DAS.Paramini.Offset[MIS.Pos + 1] > 0) d = 0;
2071  else d = 1;
2072 
2073  er = AMS_DoPos(AMS1, d, 0, labs(DAS.Paramini.Offset[MIS.Pos + 1]), 0);
2074  if(er) { Message("n Step not sent! 2", er); }
2075  }
2076 */
2077  /*--------------------------------------------------------------------*/
2079  sprintf(buf, "%s",Mir_CodeTropo[where]);
2080  else
2081  sprintf(buf, "%s",Mir_Code[where]);
2082 
2084  if(FLAG.manhormeas)
2085  MObjectSetText(DAS.Gui.HorizMeas.lbl[0], buf);
2086 
2087 
2088 
2089 // Status("Ready");
2090  if(!FLAG.fileprg || !FLAG.exec )
2091  //Attiva i pulsanti sulla keyboard se non si sta eseguendo una tabella di misure
2092  //oppure se il programma e' stato sospeso (si e' premuto il tasto "pause")
2093  DB_KB_ButtonActive(1);
2094 
2095 // AMS_MotorOn_Off(AMS1, 0, 0);
2096 
2097  if(er) return 1;
2098 
2099  return 0;
2100 
2101 }
das DAS
DAS structure.
Definition: Spat_Device.c:27
stepm StepM
Stepper motors parameters structure.
gui Gui
Graphic User Interface Structure.
void DB_KB_ButtonActive(int mod)
Enable/Disable Push buttons on the Control Panel.
Definition: CreateForms.c:3810
MOBJECT LedSM[AMSMAX][2]
Leds for stepper motors status.
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
MOBJECT KeyB[28]
Keyboard Buttons.
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...)
float multiplier[AMSMAX][2]
multiplier, > 0 multiplier, < 0 demultiplier
int SM_stepr(int t)
AMS &#39;steps/round&#39; value return the AMS &#39;steps/round&#39; value (microstepping) depending on the setted st...
Definition: Spat_Device.c:209
void MObjectSetText(MOBJECT obj, const char *text)
int exec
= 0 -> PRG Execution Paused; = 1 -> PRG Execution Resumed
#define TROPOGAS
TROPOspheric Gas Analyzer Spectrometer.
horizmeas HorizMeas
Structure for Horizontal Measurements.
void Status(char *tit)
Writes information&#39;s on the Status label .
Definition: Load.c:1556
pushbutt PushButt
Push buttons.
#define GASCODNG4
GASCODNG 4.
#define SPATRAM3
SPATRAM3.
MirrorSt MIS
Mirror.
Definition: DAS_Spat.c:61
flag FLAG
flags structure
Definition: Spat_Device.c:19
int fileprg
Flag indicating the execution of a PRG file: = 0 –> No PRG File; = 1 –> PRG file in execution...
controlpanel ContrPanel
Control Panel Structure.
#define AMS1
AMS1 address.
int manhormeas
1 = horizontal measurements in manual mode
int step[AMSMAX][2]
Stepper Motors Step.
int EqType
Spectrometer Type.
void MObjectSetSensitive(MOBJECT obj)
MOBJECT lbl[15]
generic labels for hor meas shell
int DB_StepMotor(int id, int motor, long step, int dir)
Send steps to the selected stepper motor. .
Definition: Dxl.c:816
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:

§ SD_NDFilterW()

int SD_NDFilterW ( int  filter)

Positioning Filter wheel.
The filter wheel move on the filter number specified by filter.
See also Filter Wheel page.

Parameters
filter
  • 0 = NULL
  • 1 = ND1
  • 2 = ND2
  • 3 =
  • 4 =
  • 5 =
    – For LIS Spectrometer the filter wheel is bigger so we have 2 filters more and the filter parameter renges since 0 to 7.
Returns
er:
  • 0 = Operation concluded succesfully
  • 1 = Problems in positioning

Definition at line 2354 of file Spat_Device.c.

References controlpanel::Albl_LS, AMS2, gui::ContrPanel, DB_KB_ButtonActive(), DB_StepMotor(), paramini::EqType, flag::exec, Fil_Code8H, Fil_CodeNG, Fil_CodeTropo, flag::fileprg, GASCODNG1, GASCODNG2, GASCODNG3, GASCODNG4, das::Gui, gui::HorizMeas, pushbutt::KeyB, horizmeas::lbl, controlpanel::LedSM, LIS_, flag::manhormeas, MMessageDialog(), MObjectSetSensitive(), MObjectSetText(), MPixmapSetImageFile(), NDFil_Code, NDFWS, das::Paramini, NDFilterWheelSt::Pos, gui::PushButt, SM_stepr(), SPATRAM, SPATRAM2, SPATRAM3, SPATRAMPLUS, Status(), stepm::step, das::StepM, and TROPOGAS.

Referenced by AutoR_SetND_Filter(), DB_KeyB_CB(), E_AAMeasure(), E_Almucantar(), E_DFMeasure(), E_DirectSun(), E_HgScan(), E_NDFilter(), and E_QjScan().

2355 {
2356 
2357  char buf[80];
2358  long n[3];
2359  long nx;
2360  int d, dir[3]; // 0 = CW, 1 = CCW
2361  int k , er;
2362 // char Filter[4];
2363 
2364  //Disattiva i pulsanti sulla keyboard
2365  DB_KB_ButtonActive(0);
2368 
2369  /************************************************************/
2370  if (DAS.Paramini.EqType == SPATRAM ||
2371  DAS.Paramini.EqType == GASCODNG1 ||
2373  DAS.Paramini.EqType == TROPOGAS ||
2377  DAS.Paramini.EqType == SPATRAM3 ||
2379  {
2380  k = SM_stepr(DAS.StepM.step[AMS2][1]) / 6;
2381  if(filter < 0 || filter > 5) return 0;
2382  }
2383  else // ...oppure non lo sa)
2384  {
2385  sprintf(buf, "For this Equipment the Filter Wheel type is UNKNOWN\nPlease Contact DANBO!!!!");
2386  er = MMessageDialog("DAS information", buf, "Ok", NULL);
2387  if (!er)
2388  {
2389  return 0;
2390  }
2391 
2392  }
2393  /**************************************************************/
2394 
2395  n[2] = (long)(NDFWS.Pos - filter) * k;
2396 
2397  if(n[2] < 0) dir[2] = 1;
2398  else dir[2] = 0;
2399  n[2] = labs(n[2]);
2400 
2401  nx = n[2];
2402  d = dir[2];
2403 
2404  // Eseguo NStep
2405 
2406  Status("New ND Filter Wheel Position");
2407 
2408 
2409  if(nx)
2410  {
2411  er=DB_StepMotor(AMS2, 3, nx, d);
2412  if (er)
2413  {
2414  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS2][1], "SYS\\ledGreen.bmp");
2415  }
2416  }
2417 
2418 
2419  NDFWS.Pos = filter;
2420  if ( DAS.Paramini.EqType == LIS_)
2421  sprintf(buf, "%s", Fil_Code8H[filter]);
2422  else
2423  {
2424  if(DAS.Paramini.EqType == TROPOGAS)
2425  sprintf(buf, "%s",Fil_CodeTropo[filter]);
2427  sprintf(buf, "%s",Fil_CodeNG[filter]);
2428  else
2429  sprintf(buf, "%s",NDFil_Code[filter]);
2430  }
2431 
2433  if(FLAG.manhormeas)
2434  MObjectSetText(DAS.Gui.HorizMeas.lbl[3], buf);
2435  Status("Ready");
2436 
2437  if(!FLAG.fileprg || !FLAG.exec )
2438  //Attiva i pulsanti sulla keyboard se non si sta eseguendo una tabella di misure
2439  //oppure se il programma e' stato sospeso (si e' premuto il tasto "pause")
2440  DB_KB_ButtonActive(1);
2441 
2442 
2443  if(er) return 1;
2444 
2445  return 0;
2446 
2447 
2448 }
das DAS
DAS structure.
Definition: Spat_Device.c:27
stepm StepM
Stepper motors parameters structure.
#define SPATRAM
SPectrometer for Atmospheric TRAcers Measurements - CGE-UE Portugal.
NDFilterWheelSt NDFWS
ND Filter Wheel.
Definition: DAS_Spat.c:58
gui Gui
Graphic User Interface Structure.
void DB_KB_ButtonActive(int mod)
Enable/Disable Push buttons on the Control Panel.
Definition: CreateForms.c:3810
MOBJECT LedSM[AMSMAX][2]
Leds for stepper motors status.
int Pos
Filter Wheel current Position.
MOBJECT Albl_LS[8]
Active Control Panel Labels for LIS status.
#define AMS2
AMS2 address.
MOBJECT KeyB[28]
Keyboard Buttons.
void MPixmapSetImageFile(MOBJECT pixmap, const char *fname)
char * Fil_Code8H[]
const char array for the realisation of the Filters buttons in the Filter shell
Definition: DAS_Spat.c:204
int SM_stepr(int t)
AMS &#39;steps/round&#39; value return the AMS &#39;steps/round&#39; value (microstepping) depending on the setted st...
Definition: Spat_Device.c:209
void MObjectSetText(MOBJECT obj, const char *text)
#define LIS_
Lampedusa Island Spectrometer - ENEA.
int exec
= 0 -> PRG Execution Paused; = 1 -> PRG Execution Resumed
#define TROPOGAS
TROPOspheric Gas Analyzer Spectrometer.
horizmeas HorizMeas
Structure for Horizontal Measurements.
char * Fil_CodeNG[]
const char array for the realisation of the Filters buttons in the Filter shell for GASCODNG2 and NG3...
Definition: DAS_Spat.c:216
#define GASCODNG2
GASCODNG 2 (with ATX power supply & HiresIV)
#define SPATRAM2
SPATRAM2 (with ATX power supply & HiresV)
#define SPATRAMPLUS
As SPATRAM plus AltAzimuth platform.
void Status(char *tit)
Writes information&#39;s on the Status label .
Definition: Load.c:1556
#define GASCODNG3
GASCODNG 3 (with ATX power supply & HiresIV)
pushbutt PushButt
Push buttons.
#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,...)
#define SPATRAM3
SPATRAM3.
flag FLAG
flags structure
Definition: Spat_Device.c:19
int fileprg
Flag indicating the execution of a PRG file: = 0 –> No PRG File; = 1 –> PRG file in execution...
controlpanel ContrPanel
Control Panel Structure.
int manhormeas
1 = horizontal measurements in manual mode
int step[AMSMAX][2]
Stepper Motors Step.
char * Fil_CodeTropo[]
const char array for the realisation of the Filters buttons in the Filter shell for TROPOGAS instrume...
Definition: DAS_Spat.c:210
char * NDFil_Code[]
const char array for the realisation of the Filters buttons in the ND Filter shell ...
Definition: DAS_Spat.c:219
int EqType
Spectrometer Type.
void MObjectSetSensitive(MOBJECT obj)
MOBJECT lbl[15]
generic labels for hor meas shell
int DB_StepMotor(int id, int motor, long step, int dir)
Send steps to the selected stepper motor. .
Definition: Dxl.c:816
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:

§ SD_PosAADev()

int SD_PosAADev ( double  z,
double  a 
)

perform the simoultaneous positioning of the AltAzimuth platform z = Zenith Axis a = Grating Position

Definition at line 447 of file Spat_Device.c.

References optionini::aaopmode, controlpanel::Albl_LS, AMS3, AMS_sendstep(), optionini::amsprogbar, gui::ContrPanel, D_VRangeSim(), DBDEMO, DD_VOpen, das::DOption, flag::exemode, das::Flag, das::Gui, controlpanel::LedSM, MIGEAz(), MIGEZen(), MLoopWhileEvents(), MObjectSetText(), MPixmapSetImageFile(), stepm::multiplier, stepm::NAMS, stepm::nstep, ZenithSt::Pos, AzimuthSt::Pos, stepm::postime, AzimuthSt::realazpos, ZenithSt::realzenpos, stepm::Revo, S_azim, stepm::SM_A, stepm::SM_B, SM_stepr(), stepm::speed_Hz, st, stepm::step, das::StepM, and WriteLogAMS().

Referenced by MIGEAntiSunTrack(), and MIGESunTrack().

448 {
449 
450  int k, i, s, dir;
451  float GRASTEP, STEPGRA;
452  long minpostime = 2147483647, maxpostime = 0;
453  long st, et, tt, n;
454  double ttout = 0, yy;
455  char buf[80];
456  long dp = 500; // dp are the dead pulse, they have to be added for backlash recovery
457  //float MAZMax = 120.0; //MIGE Azimut MAX
458  //float MAZMin = -60.0; //MIGE Azimut Min
459  float rzenang, razang, az;
460 
461  float MAZMax = 90.0; //MIGE Azimut MAX
462  float MAZMin = -90.0; //MIGE Azimut Min
463 
464 
465  k=DAS.StepM.NAMS-1;
466  for (i=0;i<2;i++)
467  {
468  s = 2 * k + i;
469  DD_VOpen[s] = 0;
470  }
471 
472 
473  //a --> Azimuth
474 
475  //Azimuth positioning
476  razang=MIGEAz((float)a);
477 
478  k = SM_stepr(DAS.StepM.step[AMS3][DAS.StepM.SM_B]); // step/round
479 
480  GRASTEP = (float)360.0 / (float) k; // degree/step
481 
482  STEPGRA = (float) k / (float)360.0; // step/degree
483 
484  yy = (razang - AST.Pos);
485 
486  n = (long) (yy * STEPGRA * DAS.StepM.multiplier[AMS3][1]);
487 
488  AST.Pos = razang;
489  AST.realazpos = a;
490 
491  // Select direction
492  if(n < 0)
493  dir = 1;
494  else
495  dir = 0;
496 
497  n = labs(n);
498  DAS.StepM.Revo[AMS3][DAS.StepM.SM_B] = dir;
499  DAS.StepM.nstep[AMS3][DAS.StepM.SM_B] = n;
500 
501 /**************************************************************************/
502  /*******************************/
503  //z --> Zenith
504  //if(z >= -91 && z <= 45 )
505 // if(z >= -90 && z <= 90 )
506  //Zenith positioning
507  rzenang=MIGEZen((float)z);
508 
509  if(z >= 0 && z <= 180 )
510  {
511 
512  k = SM_stepr(DAS.StepM.step[AMS3][DAS.StepM.SM_A]); // step/round
513 
514  GRASTEP = (float) 360.0 / (float) k; // degree/step
515 
516  STEPGRA = (float) k / (float) 360.0; // step/degree
517 
518 // yy = -(z - ZST.Pos);
519  yy = -(rzenang - ZST.Pos);
520  n = (long)(yy * STEPGRA * (DAS.StepM.multiplier[AMS3][0]));
521 // ZST.Pos = z;
522  ZST.Pos = rzenang;
523  ZST.realzenpos = z;
524  // Select direction
525  if(n < 0)
526  dir = 1;
527  else
528  dir = 0;
529 
530  n = labs(n);
531  DAS.StepM.Revo[AMS3][DAS.StepM.SM_A] = dir;
532  DAS.StepM.nstep[AMS3][DAS.StepM.SM_A] = n;
533  }
534  else
535  {
536  DAS.StepM.Revo[AMS3][DAS.StepM.SM_A] = 0;
537  DAS.StepM.nstep[AMS3][DAS.StepM.SM_A] = 0;
538  sprintf(buf, "Not Allowed Zen.");
540 
541  }
542 
543 
544 /**************************************************************************/
545  // Tout computation and Max finding
546  k=DAS.StepM.NAMS-1;
547  for (i=0;i<2;i++)
548  {
549  DAS.StepM.postime[k][i] = (long) (DAS.StepM.nstep[k][i]/(float) DAS.StepM.speed_Hz[k][i]);
550  if (DAS.StepM.postime[k][i] >= maxpostime) maxpostime = DAS.StepM.postime[k][i];
551  if (DAS.StepM.postime[k][i] <= minpostime) minpostime = DAS.StepM.postime[k][i];
552  }
553 /*************************************************************************/
554 
555 /**************************************************************************/
556  // Init Progression bar
557  k=DAS.StepM.NAMS-1;
558  for (i=0;i<2;i++)
559  {
560  if (DAS.StepM.nstep[k][i] != 0)
561  {
562  s = 2*k+i;
563  switch (s)
564  {
565  case 0:
567  D_VRangeSim(0, "Positioning Mirror",0, 255, 0, 0, 50, 0);
568  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[k][i], "SYS\\ledoff.bmp");
569 
570  break;
571  case 1:
573  D_VRangeSim(1, "Positioning Grating",0, 255, 255, 0, 50, 100);
574  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[k][i], "SYS\\ledoff.bmp");
575  break;
576  case 2:
578  D_VRangeSim(2, "Positioning Filter Wheel",0, 0, 0, 255, 50, 200);
579  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[k][i], "SYS\\ledoff.bmp");
580  break;
581  case 3:
582  break;
583  case 4:
585  if(DAS.DOption.aaopmode == 2)
586  {
587  D_VRangeSim(4,"Positioning Zenith",0, 0, 255, 255, 50, 300);
588 
589  }
590  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[k][i], "SYS\\ledoff.bmp");
591  break;
592  case 5:
594  if(DAS.DOption.aaopmode == 2)
595  {
596  D_VRangeSim(5,"Positioning Azimuth",0, 0, 192, 255, 50, 400);
597 
598  }
599  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[k][i], "SYS\\ledoff.bmp");
600  break;
601 
602 
603  }
604  }
605  }
606 
607 /*************************************************************************/
608 
609 /**************************************************************************/
610  // Send step
611  if (DAS.Flag.exemode != DBDEMO)
612  {
613  k=DAS.StepM.NAMS-1;
616 
619 
620  }
621 
622  //Time Out loop
623  st = GetTickCount();
624  do
625  {
626  et = GetTickCount();
627  tt = labs(et - st);
628  MLoopWhileEvents(0);
629  if(tt > 0)
630  {
631  if(DD_VOpen[4])
632  {
634  D_VRangeSim(4, NULL,(unsigned long) tt * 100 / DAS.StepM.postime[AMS3][0], 0, 255, 255, 50, 300);
635  if (tt >= DAS.StepM.postime[AMS3][0])
636  {
637  sprintf(buf, "%.1lf", z);
639  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[2][0], "SYS\\ledGreen.bmp");
640  }
641  else
642  {
643  sprintf(buf, "%.1lf sec. left", (double)fabs(((double)(tt - DAS.StepM.postime[AMS3][0]))/1000.0 ));
645  }
646  }
647  else
648  {
649  if (tt >= DAS.StepM.postime[AMS3][0])
650  {
651  sprintf(buf, "%.1lf", ZST.realzenpos);
652 
654  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[2][0], "SYS\\ledGreen.bmp");
655  }
656  else
657  {
658  sprintf(buf, "%.1lf sec. left", (double)fabs(((double)(tt - DAS.StepM.postime[AMS3][0]))/1000.0 ));
660  }
661 
662  }
663 
664  if(DD_VOpen[5])
665  {
667  D_VRangeSim(5, NULL,(unsigned long) tt * 100 / DAS.StepM.postime[AMS3][1], 0, 192, 255, 50, 400);
668  if (labs(et - st) >= DAS.StepM.postime[AMS3][1])
669  {
670  az = (float)S_azim;
671  //sprintf(buf, "%.1lf %.1lf", az, a );
672  sprintf(buf, "%.1lf", AST.realazpos);
674  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[2][1], "SYS\\ledGreen.bmp");
675  }
676  else
677  {
678  sprintf(buf, "%.1lf sec. left", (double)fabs(((double)(tt - DAS.StepM.postime[AMS3][1]))/1000.0 ));
680  }
681  }
682  else
683  {
684  if (labs(et - st) >= DAS.StepM.postime[AMS3][1])
685  {
686  az = (float)S_azim;
687  //sprintf(buf, "%.1lf %.1lf", az, a );
688  sprintf(buf, " %.1lf", AST.realazpos );
690  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[2][1], "SYS\\ledGreen.bmp");
691  }
692  else
693  {
694  sprintf(buf, "%.1lf sec. left", (double)fabs(((double)(tt - DAS.StepM.postime[AMS3][1]))/1000.0 ));
696  }
697 
698  }
699 
700 
701  }
702  }while((tt < maxpostime));
703 /**************************************************************************/
704 
705 /**************************************************************************/
706 
707  // Check if all the progression bars have been destroyed.
708  // If not the active one is destroyed and the apprpriate label is written
709  k=DAS.StepM.NAMS-1;
710  for (i=0;i<2;i++)
711  {
712  s = 2*k+i;
713  if(DD_VOpen[s])
714  {
716  D_VRangeSim(s, NULL, 100, 0, 0, 0, 0, 0);
717  switch (s)
718  {
719  case 4:
720  sprintf(buf, "%.1lf", z);
722  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[k][i], "SYS\\ledGreen.bmp");
723  break;
724  case 5:
725  sprintf(buf, "%.1lf", (double) a);
727  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[k][i], "SYS\\ledGreen.bmp");
728  break;
729 
730 
731  }
732  }
733  }
734 
735 
736 
737 return 0;
738 
739 }
das DAS
DAS structure.
Definition: Spat_Device.c:27
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 D_VRangeSim(int id, char *str, int val, int r, int g, int b, int x, int y)
init progress bar during simultaneous positioning
Definition: Utils.c:258
void MLoopWhileEvents(int discard)
optionini DOption
Options for DAS execution.
int NAMS
Number of AMSs Devices.
double realazpos
double S_azim
O: Solar azimuth angle: N=0, E=90, S=180, W=270.
Definition: SOLPOS.C:45
int SM_A
Motor A (su Y11) respectively: ID=0->InputMirror,ID=1->FilterWheel,ID=2->Zenith.
void MPixmapSetImageFile(MOBJECT pixmap, const char *fname)
unsigned long nstep[AMSMAX][2]
Number of steps to be executed.
flag Flag
Structure for different flags.
#define DBDEMO
execution in demo mode
float multiplier[AMSMAX][2]
multiplier, > 0 multiplier, < 0 demultiplier
int SM_stepr(int t)
AMS &#39;steps/round&#39; value return the AMS &#39;steps/round&#39; value (microstepping) depending on the setted st...
Definition: Spat_Device.c:209
void MObjectSetText(MOBJECT obj, const char *text)
AzimuthSt AST
Definition: Spat_Device.c:25
long postime[AMSMAX][2]
time necessary for positioning
void WriteLogAMS(int id, int dira, int dirb, unsigned long stepa, unsigned long stepb)
Definition: Spat_Device.c:299
int Revo[AMSMAX][2]
Revolution Direction CW CCW.
ZenithSt ZST
Definition: Spat_Device.c:24
int amsprogbar
display/hide prograssion bar, 0 = Hide, 1 = display
int SM_B
Motor B (su Y12) respectively: ID=0->Grating,ID=1->Not Connected,ID=2->Azimuth.
controlpanel ContrPanel
Control Panel Structure.
int DD_VOpen[16]
Definition: Utils.c:151
static double st
Definition: SOLPOS.C:142
int step[AMSMAX][2]
Stepper Motors Step.
double speed_Hz[AMSMAX][2]
Stepper Motors Speed [Hz].
int aaopmode
operation mode for the Alt Az Platform, 0 = solar Traxker; 1 = Anti-Solar Tracker; 2 = Free Positioni...
double realzenpos
double Pos
Azimuth Current Position.
int AMS_sendstep(int id, int dira, int dirb, unsigned long stepa, unsigned long stepb)
Send steps Procedure for sending steps to the Stepper Motor.
Definition: Dxl.c:513
float MIGEZen(float p)
Definition: CreateForms.c:3419
double Pos
Zenith Current Position.
float MIGEAz(float p)
Definition: CreateForms.c:3475
int exemode
Set the Execution MODE (Execution modes)
#define AMS3
AMS3 address.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ SD_Position()

int SD_Position ( int  m,
int  w,
int  f,
double  z,
double  a 
)

perform the simoultaneous positioning of the Spectrometer Devices m = mirror w = wavelength (Grating) f = filter wheel z = zenith a = azimuth

Definition at line 1243 of file Spat_Device.c.

References optionini::aaopmode, controlpanel::Albl_LS, AMS1, AMS2, AMS3, AMS_sendstep(), optionini::amsprogbar, gui::ContrPanel, D_VRangeSim(), DB_StepMotor(), DBDEMO, DD_VOpen, das::DOption, GratingSt::dp, paramini::EqType, flag::exemode, Fil_Code, Fil_Code8H, Fil_CodeNG, Fil_CodeNG1, Fil_CodeTropo, das::Flag, FWS, GASCODNG1, GASCODNG2, GASCODNG3, GASCODNG4, das::Gui, controlpanel::LedSM, LIS_, MIGEAz(), MIGEZen(), Mir_Code, Mir_CodeTropo, MIS, MLoopWhileEvents(), MObjectSetText(), MPixmapSetImageFile(), stepm::multiplier, stepm::NAMS, stepm::nstep, paramini::Offset, das::Paramini, FilterWheelSt::Pos, MirrorSt::Pos, ZenithSt::Pos, AzimuthSt::Pos, stepm::postime, AzimuthSt::realazpos, ZenithSt::realzenpos, stepm::Revo, stepm::SM_A, stepm::SM_B, SM_stepr(), SPATRAM, SPATRAM2, SPATRAM3, SPATRAMPLUS, stepm::speed_Hz, st, stepm::step, das::StepM, TROPOGAS, wav, wl, GratingSt::Wl, and WriteLogAMS().

Referenced by E_AAMeasure(), E_AAPos(), E_Almucantar(), E_DirectSun(), E_IRefSun(), ExecSimPosCB(), and MIGEZenAzPos_CB().

1244 {
1245 
1246  int k, i, s, er, dir;
1247  float GRASTEP, STEPGRA;
1248  long minpostime = 2147483647, maxpostime = 0;
1249  long st, et, tt, n;
1250  double ttout = 0, yy;
1251  char buf[80], str[16];
1252  long dp = 500; // dp sono i dead pulse, vanno aggiunti all'inversione per il recupero del gioco
1253  float razang, rzenang;
1254  int StepWithOffset [4][4];
1255  float g;
1256 
1257 
1258  for(k=0;k<DAS.StepM.NAMS;k++)
1259  { for (i=0;i<2;i++)
1260  {
1261  s = 2 * k + i;
1262  DD_VOpen[s] = 0;
1263  }
1264  }
1265  /*******************************/
1266 
1267  if((m >= 0) && (m <= 3))
1268  {
1269  k = SM_stepr(DAS.StepM.step[AMS1][DAS.StepM.SM_A]) * 6 / 4;
1270 
1271 
1272 /* er = (long)(MIS.Pos - m);
1273  switch (er)
1274  {
1275  case 0:
1276  n = 0;
1277  break;
1278  case 1:
1279  n = er * k * 3;
1280  break;
1281  case -3:
1282  case -1:
1283  case 2:
1284  case (-2):
1285  n = er * k;
1286  break;
1287  case 3:
1288  n = er * k / 3;
1289  break;
1290 
1291  }
1292 */
1293  StepWithOffset [0][0] = 0;
1294  StepWithOffset [0][1] = 3*k - DAS.Paramini.Offset[2];
1295  StepWithOffset [0][2] = 2*k - DAS.Paramini.Offset[3];
1296  StepWithOffset [0][3] = k - DAS.Paramini.Offset[4];
1297 
1298  StepWithOffset [1][0] = k + DAS.Paramini.Offset[2];
1299  StepWithOffset [1][1] = 0;
1300  StepWithOffset [1][2] = 3*k - DAS.Paramini.Offset[3] + DAS.Paramini.Offset[2];
1301  StepWithOffset [1][3] = 2*k - DAS.Paramini.Offset[4]+ DAS.Paramini.Offset[2];
1302 
1303  StepWithOffset [2][0] = 2*k + DAS.Paramini.Offset[3];
1304  StepWithOffset [2][1] = k - DAS.Paramini.Offset[2]+DAS.Paramini.Offset[3];
1305  StepWithOffset [2][2] = 0;
1306  StepWithOffset [2][3] = 3*k - DAS.Paramini.Offset[4]+DAS.Paramini.Offset[3];
1307 
1308  StepWithOffset [3][0] = 3*k + DAS.Paramini.Offset[4];
1309  StepWithOffset [3][1] = 2*k - DAS.Paramini.Offset[2]+ DAS.Paramini.Offset[4];
1310  StepWithOffset [3][2] = k - DAS.Paramini.Offset[3] + DAS.Paramini.Offset[4];
1311  StepWithOffset [3][3] = 0;
1312 
1313 
1314  dir = 1;
1315  n = StepWithOffset [m][MIS.Pos];
1316  n = labs(n);
1317  DAS.StepM.Revo[AMS1][DAS.StepM.SM_A] = dir;
1318  DAS.StepM.nstep[AMS1][DAS.StepM.SM_A] = n;
1319  MIS.Pos = m;
1320  }
1321  else
1322  {
1323  DAS.StepM.Revo[AMS1][DAS.StepM.SM_A] = 0;
1324  DAS.StepM.nstep[AMS1][DAS.StepM.SM_A] = 0;
1325 
1326  }
1327 
1328  /******************************/
1329 
1330  /*******************************/
1331  //w
1332  if(w >= 0 && w <= 17)
1333  {
1334  g = (float) SM_stepr(DAS.StepM.step[AMS1][1])/3200;
1335  n = (long)(((float) (-wav[GRS.Wl] + wav[w]) ) * 4 * g);
1336 
1337  if(n < 0)
1338  dir = 1;
1339  else
1340  dir = 0;
1341 
1342  n = labs(n);
1343 
1344 
1345  if(n && dir == 0) //si va verso l'UV
1346  n += GRS.dp; // // add fixed step number for backlash recovery
1347 
1348  DAS.StepM.Revo[AMS1][DAS.StepM.SM_B] = dir;
1349  DAS.StepM.nstep[AMS1][DAS.StepM.SM_B] = n;
1350  GRS.Wl = w;
1351  }
1352  else
1353  {
1354  DAS.StepM.Revo[AMS1][DAS.StepM.SM_B] = 0;
1355  DAS.StepM.nstep[AMS1][DAS.StepM.SM_B] = 0;
1356 
1357  }
1358  /*******************************/
1359 
1360  /*******************************/
1361  //f
1362 
1363  //8 holes....
1364  if(DAS.Paramini.EqType == LIS_)
1365  {
1366  k = SM_stepr(DAS.StepM.step[AMS2][DAS.StepM.SM_A]) / 8;
1367  if(f >= 0 && f <= 8)
1368  {
1369  n= (long)(FWS.Pos - f) * k;
1370  if(n < 0)
1371  dir = 1;
1372  else
1373  dir = 0;
1374 
1375  n = labs(n);
1376  DAS.StepM.Revo[AMS2][DAS.StepM.SM_A] = dir;
1377  DAS.StepM.nstep[AMS2][DAS.StepM.SM_A] = n;
1378  FWS.Pos = f;
1379  }
1380  else
1381  {
1382  n = 0;
1383  DAS.StepM.Revo[AMS2][DAS.StepM.SM_A] = 0;
1384  DAS.StepM.nstep[AMS2][DAS.StepM.SM_A] = 0;
1385  }
1386 
1387 
1388  }
1389  // ...or 6 holes....
1390  if (DAS.Paramini.EqType == SPATRAM ||
1391  DAS.Paramini.EqType == GASCODNG1 ||
1393  DAS.Paramini.EqType == TROPOGAS ||
1394  DAS.Paramini.EqType == GASCODNG2 ||
1397  DAS.Paramini.EqType == SPATRAM3 ||
1399  {
1400  k = SM_stepr(DAS.StepM.step[AMS2][DAS.StepM.SM_A]) / 6;
1401  if(f >= 0 && f <= 5)
1402  {
1403  n= (long)(FWS.Pos - f) * k;
1404  if(n < 0)
1405  dir = 1;
1406  else
1407  dir = 0;
1408 
1409  n = labs(n);
1410  DAS.StepM.Revo[AMS2][DAS.StepM.SM_A] = dir;
1411  DAS.StepM.nstep[AMS2][DAS.StepM.SM_A] = n;
1412  FWS.Pos = f;
1413  }
1414  else
1415  {
1416  n = 0;
1417  DAS.StepM.Revo[AMS2][DAS.StepM.SM_A] = 0;
1418  DAS.StepM.nstep[AMS2][DAS.StepM.SM_A] = 0;
1419  }
1420  }
1421 
1422  /*******************************/
1423  //a --> Azimuth
1424 
1425  //Azimuth positioning
1426  razang=MIGEAz((float)a);
1427 
1428  k = SM_stepr(DAS.StepM.step[AMS3][DAS.StepM.SM_B]); // step/round
1429 
1430  GRASTEP = (float)360.0 / (float) k; // degree/step
1431 
1432  STEPGRA = (float) k / (float)360.0; // step/degree
1433 
1434  yy = (razang - AST.Pos);
1435 
1436  n = (long) (yy * STEPGRA * DAS.StepM.multiplier[AMS3][1]);
1437 
1438  AST.Pos = razang;
1439  AST.realazpos = a;
1440 
1441  // Select direction
1442  if(n < 0)
1443  dir = 1;
1444  else
1445  dir = 0;
1446 
1447  n = labs(n);
1448  DAS.StepM.Revo[AMS3][DAS.StepM.SM_B] = dir;
1449  DAS.StepM.nstep[AMS3][DAS.StepM.SM_B] = n;
1450 
1451 /**************************************************************************/
1452  /*******************************/
1453  //z --> Zenith
1454  //if(z >= -91 && z <= 45 )
1455 // if(z >= -90 && z <= 90 )
1456  //Zenith positioning
1457  rzenang=MIGEZen((float)z);
1458 
1459  if(z >= 0 && z <= 180 )
1460  {
1461 
1462 
1463 
1464 
1465 
1466  k = SM_stepr(DAS.StepM.step[AMS3][DAS.StepM.SM_A]); // step/round
1467 
1468  GRASTEP = (float) 360.0 / (float) k; // degree/step
1469 
1470  STEPGRA = (float) k / (float) 360.0; // step/degree
1471 
1472 // yy = -(z - ZST.Pos);
1473  yy = -(rzenang - ZST.Pos);
1474  n = (long)(yy * STEPGRA * (DAS.StepM.multiplier[AMS3][0]));
1475 // ZST.Pos = z;
1476  ZST.Pos = rzenang;
1477  ZST.realzenpos = z;
1478  // Select direction
1479  if(n < 0)
1480  dir = 1;
1481  else
1482  dir = 0;
1483 
1484  n = labs(n);
1485  DAS.StepM.Revo[AMS3][DAS.StepM.SM_A] = dir;
1486  DAS.StepM.nstep[AMS3][DAS.StepM.SM_A] = n;
1487  }
1488  else
1489  {
1490  DAS.StepM.Revo[AMS3][DAS.StepM.SM_A] = 0;
1491  DAS.StepM.nstep[AMS3][DAS.StepM.SM_A] = 0;
1492  sprintf(buf, "Not Allowed Zen.");
1494 
1495  }
1496  /*******************************/
1497 
1498 
1499 
1500 
1501 
1502  // Tout computation and Max finding
1503  for(k=0;k<DAS.StepM.NAMS;k++)
1504  {
1505  for (i=0;i<2;i++)
1506  {
1507  DAS.StepM.postime[k][i] = (long)( DAS.StepM.nstep[k][i]/(float) DAS.StepM.speed_Hz[k][i]);
1508  if (DAS.StepM.postime[k][i] >= maxpostime) maxpostime = DAS.StepM.postime[k][i];
1509  if (DAS.StepM.postime[k][i] <= minpostime) minpostime = DAS.StepM.postime[k][i];
1510  }
1511  }
1512 /*************************************************************************/
1513 
1514 /**************************************************************************/
1515  // Init Progression bar
1516  for(k=0;k<DAS.StepM.NAMS;k++)
1517  {
1518  for (i=0;i<2;i++)
1519  {
1520  if (DAS.StepM.nstep[k][i] != 0)
1521  {
1522  s = 2*k+i;
1523  switch (s)
1524  {
1525  case 0:
1526  if(DAS.DOption.amsprogbar)
1527  D_VRangeSim(0, "Positioning Mirror",0, 255, 0, 0, 50, 0);
1528  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[k][i], "SYS\\ledoff.bmp");
1529 
1530  break;
1531  case 1:
1532  if(DAS.DOption.amsprogbar)
1533  D_VRangeSim(1, "Positioning Grating",0, 255, 255, 0, 50, 100);
1534  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[k][i], "SYS\\ledoff.bmp");
1535  break;
1536  case 2:
1537  if(DAS.DOption.amsprogbar)
1538  D_VRangeSim(2, "Positioning Filter Wheel",0, 0, 0, 255, 50, 200);
1539  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[k][i], "SYS\\ledoff.bmp");
1540  break;
1541  case 3:
1542  break;
1543  case 4:
1544  if(DAS.DOption.amsprogbar)
1545  if(DAS.DOption.aaopmode == 2)
1546  {
1547  D_VRangeSim(4,"Positioning Zenith",0, 0, 255, 255, 50, 300);
1548 
1549  }
1550  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[k][i], "SYS\\ledoff.bmp");
1551  break;
1552  case 5:
1553  if(DAS.DOption.amsprogbar)
1554  if(DAS.DOption.aaopmode == 2)
1555  {
1556  D_VRangeSim(5,"Positioning Azimuth",0, 0, 192, 255, 50, 400);
1557 
1558  }
1559  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[k][i], "SYS\\ledoff.bmp");
1560  break;
1561 
1562 
1563  }
1564  }
1565  }
1566  }
1567 /*************************************************************************/
1568 
1569 /**************************************************************************/
1570  // Send step
1571 
1572  for(k=0;k<DAS.StepM.NAMS;k++)
1573  {
1574  if (DAS.Flag.exemode != DBDEMO)
1575  {
1578  }
1581 
1582  }
1583 
1584 
1585  //Time Out loop
1586  st = GetTickCount();
1587  do
1588  {
1589  et = GetTickCount();
1590  tt = labs(et - st);
1591  MLoopWhileEvents(0);
1592  if(tt > 0)
1593  {
1594 
1595  if(DD_VOpen[0])
1596  {
1597  if(DAS.DOption.amsprogbar)
1598  D_VRangeSim(0 ,NULL,(unsigned long) tt * 100 / DAS.StepM.postime[AMS1][0], 255, 0, 0, 50, 0);
1599  sprintf(buf, "%.1f sec. left", (double)fabs(((double)(tt - DAS.StepM.postime[AMS1][0]))/1000.0 ));
1601  if (tt >= DAS.StepM.postime[AMS1][0])
1602  {
1604  sprintf(str, "%s",Mir_CodeTropo[m]);
1605  else
1606  sprintf(str, "%s",Mir_Code[m]);
1607 
1608  sprintf(buf, "%s", str);
1610  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[0][0], "SYS\\ledGreen.bmp");
1611 
1612  }
1613  }
1614  else
1615  {
1616  sprintf(buf, "%.1f sec. left", (double)fabs(((double)(tt - DAS.StepM.postime[AMS1][0]))/1000.0 ));
1618  if (tt >= DAS.StepM.postime[AMS1][0])
1619  {
1620  if (m != -1)
1621  {
1623  sprintf(str, "%s",Mir_CodeTropo[m]);
1624  else
1625  sprintf(str, "%s",Mir_Code[m]);
1626 
1627  }
1628  else
1629  {
1631  sprintf(str, "%s",Mir_CodeTropo[MIS.Pos]);
1632  else
1633  sprintf(str, "%s",Mir_Code[MIS.Pos]);
1634 
1635  //sprintf(buf, "%s", str);
1636  //MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[0], buf);
1637  //MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[0][0], "SYS\\ledGreen.bmp");
1638 
1639  }
1640  sprintf(buf, "%s", str);
1642  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[0][0], "SYS\\ledGreen.bmp");
1643 
1644 
1645  }
1646 
1647  }
1648  if(DD_VOpen[1])
1649  {
1650  if(DAS.DOption.amsprogbar)
1651  D_VRangeSim(1, NULL,(unsigned long) tt * 100 / DAS.StepM.postime[AMS1][1], 255, 255, 0, 50, 100);
1652  sprintf(buf, "%.1lf sec. left", (double)fabs(((double)(tt - DAS.StepM.postime[AMS1][1]))/1000.0 ));
1654  if (tt >= DAS.StepM.postime[AMS1][1])
1655  {
1656  sprintf(buf, "%4d", wl[w]);
1658  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[0][1], "SYS\\ledGreen.bmp");
1659  }
1660  }
1661  else
1662  {
1663  sprintf(buf, "%.1lf sec. left", (double)fabs(((double)(tt - DAS.StepM.postime[AMS1][1]))/1000.0 ));
1665  if (tt >= DAS.StepM.postime[AMS1][1])
1666  {
1667  if(w != -1)
1668  sprintf(buf, "%4d", wl[w]);
1669  else
1670  sprintf(buf, "%4d", wl[GRS.Wl]);
1672  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[0][1], "SYS\\ledGreen.bmp");
1673  }
1674  }
1675  if(DD_VOpen[2])
1676  {
1677  if(DAS.DOption.amsprogbar)
1678  D_VRangeSim(2, NULL,(unsigned long) tt * 100 / DAS.StepM.postime[AMS2][0], 0, 0, 255, 50, 200);
1679  sprintf(buf, "%.1lf sec. left", (double)fabs(((double) (tt - DAS.StepM.postime[AMS2][0]) )/1000.0 ));
1681  if (tt >= DAS.StepM.postime[AMS2][0])
1682  {
1683  if ( DAS.Paramini.EqType == LIS_)
1684  sprintf(buf, "%s", Fil_Code8H[f]);
1685  else
1686  {
1687  if(DAS.Paramini.EqType == TROPOGAS)
1688  sprintf(buf, "%s",Fil_CodeTropo[f]);
1690  sprintf(buf, "%s",Fil_CodeNG[f]);
1691  else if (DAS.Paramini.EqType == GASCODNG1)
1692  sprintf(buf, "%s",Fil_CodeNG1[f]);
1693  else
1694  sprintf(buf, "%s",Fil_Code[f]);
1695  }
1697  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[1][0], "SYS\\ledGreen.bmp");
1698  }
1699  }
1700  else
1701  {
1702  sprintf(buf, "%.1lf sec. left", (double)fabs(((double) (tt - DAS.StepM.postime[AMS2][0]) )/1000.0 ));
1704  if (tt >= DAS.StepM.postime[AMS2][0])
1705  {
1706  if(f != -1)
1707  {
1708  if ( DAS.Paramini.EqType == LIS_)
1709  sprintf(buf, "%s", Fil_Code8H[f]);
1710  else
1711  {
1712  if(DAS.Paramini.EqType == TROPOGAS)
1713  sprintf(buf, "%s",Fil_CodeTropo[f]);
1715  sprintf(buf, "%s",Fil_CodeNG[f]);
1716  else if (DAS.Paramini.EqType == GASCODNG1)
1717  sprintf(buf, "%s",Fil_CodeNG1[f]);
1718  else
1719  sprintf(buf, "%s",Fil_Code[f]);
1720  }
1721  }
1722  else
1723  {
1724  if ( DAS.Paramini.EqType == LIS_)
1725  sprintf(buf, "%s", Fil_Code8H[FWS.Pos]);
1726  else
1727  {
1728  if(DAS.Paramini.EqType == TROPOGAS)
1729  sprintf(buf, "%s",Fil_CodeTropo[FWS.Pos]);
1731  sprintf(buf, "%s",Fil_CodeNG[FWS.Pos]);
1732  else
1733  sprintf(buf, "%s",Fil_Code[FWS.Pos]);
1734  }
1735  }
1736 
1738  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[1][0], "SYS\\ledGreen.bmp");
1739  }
1740  }
1741 
1742  if(DD_VOpen[4])
1743  {
1744  if(DAS.DOption.amsprogbar)
1745  D_VRangeSim(4, NULL,(unsigned long) tt * 100 / DAS.StepM.postime[AMS3][0], 0, 255, 255, 50, 300);
1746  if (tt >= DAS.StepM.postime[AMS3][0])
1747  {
1748  sprintf(buf, "%.1lf", z);
1750  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[2][0], "SYS\\ledGreen.bmp");
1751  }
1752  else
1753  {
1754  sprintf(buf, "%.1lf sec. left", (double)fabs(((double)(tt - DAS.StepM.postime[AMS3][0]))/1000.0 ));
1756  }
1757  }
1758  else
1759  {
1760  if (tt >= DAS.StepM.postime[AMS3][0])
1761  {
1762  sprintf(buf, "%.1lf", z);
1764  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[2][0], "SYS\\ledGreen.bmp");
1765  }
1766  else
1767  {
1768  sprintf(buf, "%.1lf sec. left", (double)fabs(((double)(tt - DAS.StepM.postime[AMS3][0]))/1000.0 ));
1770  }
1771 
1772  }
1773 
1774  if(DD_VOpen[5])
1775  {
1776  if(DAS.DOption.amsprogbar)
1777  D_VRangeSim(5, NULL,(unsigned long) tt * 100 / DAS.StepM.postime[AMS3][1], 0, 192, 255, 50, 400);
1778  if (labs(et - st) >= DAS.StepM.postime[AMS3][1])
1779  {
1780  sprintf(buf, "%.1lf", a);
1782  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[2][1], "SYS\\ledGreen.bmp");
1783  }
1784  else
1785  {
1786  sprintf(buf, "%.1lf sec. left", (double)fabs(((double)(tt - DAS.StepM.postime[AMS3][1]))/1000.0 ));
1788  }
1789  }
1790  else
1791  {
1792  if (labs(et - st) >= DAS.StepM.postime[AMS3][1])
1793  {
1794  sprintf(buf, "%.1lf", a);
1796  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[2][1], "SYS\\ledGreen.bmp");
1797  }
1798  else
1799  {
1800  sprintf(buf, "%.1lf sec. left", (double)fabs(((double)(tt - DAS.StepM.postime[AMS3][1]))/1000.0 ));
1802  }
1803 
1804  }
1805 
1806 
1807  }
1808  }while((tt < maxpostime));
1809 /**************************************************************************/
1810 /**************************************************************************/
1811 
1812  // Check if all the progression bars have been destroyed.
1813  // If not the active one is destroyed and the apprpriate label is written
1814  for(k=0;k<DAS.StepM.NAMS;k++)
1815  {
1816  for (i=0;i<2;i++)
1817  {
1818  s = 2*k+i;
1819  if(DD_VOpen[s])
1820  {
1821  if(DAS.DOption.amsprogbar)
1822  D_VRangeSim(s, NULL, 100, 0, 0, 0, 0, 0);
1823  switch (s)
1824  {
1825  case 0:
1826  if (m != -1)
1827  {
1829  sprintf(str, "%s",Mir_CodeTropo[m]);
1830  else
1831  sprintf(str, "%s",Mir_Code[m]);
1832  sprintf(buf, "%s", str);
1834  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[k][i], "SYS\\ledGreen.bmp");
1835  }
1836  break;
1837  case 1:
1838  sprintf(buf, "%4d", wl[w]);
1840  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[k][i], "SYS\\ledGreen.bmp");
1841  break;
1842  case 2:
1843  if ( DAS.Paramini.EqType == LIS_)
1844  sprintf(buf, "%s", Fil_Code8H[f]);
1845  else
1846  {
1847  if(DAS.Paramini.EqType == TROPOGAS)
1848  sprintf(buf, "%s",Fil_CodeTropo[f]);
1850  sprintf(buf, "%s",Fil_CodeNG[f]);
1851  else if (DAS.Paramini.EqType == GASCODNG1)
1852  sprintf(buf, "%s",Fil_CodeNG1[f]);
1853  else
1854  sprintf(buf, "%s",Fil_Code[f]);
1855  }
1857  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[k][i], "SYS\\ledGreen.bmp");
1858  break;
1859  case 3:
1860 
1861  break;
1862  case 4:
1863  sprintf(buf, "%.1lf", z);
1865  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[k][i], "SYS\\ledGreen.bmp");
1866  break;
1867  case 5:
1868  sprintf(buf, "%.1lf", (double) a);
1870  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[k][i], "SYS\\ledGreen.bmp");
1871  break;
1872 
1873 
1874  }
1875  }
1876  }
1877 
1878  }
1879 /**************************************************************************/
1880  //Recupero del gioco per grating
1881 
1882  if(DAS.StepM.nstep[AMS1][DAS.StepM.SM_B] && (DAS.StepM.Revo[AMS1][DAS.StepM.SM_B] == 0) )
1883  {
1884  er=DB_StepMotor(AMS1, 1, GRS.dp, 1);
1885  if (er)
1886  {
1887  sprintf(buf, "%4d", wl[w]);
1889  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS1][1], "SYS\\ledGreen.bmp");
1890  }
1891  }
1892 
1893 /**************************************************************************/
1894  return 0;
1895 
1896 
1897 }
das DAS
DAS structure.
Definition: Spat_Device.c:27
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.
MOBJECT Albl_LS[8]
Active Control Panel Labels for LIS status.
void D_VRangeSim(int id, char *str, int val, int r, int g, int b, int x, int y)
init progress bar during simultaneous positioning
Definition: Utils.c:258
void MLoopWhileEvents(int discard)
optionini DOption
Options for DAS execution.
#define AMS2
AMS2 address.
const char * Mir_Code[]
const char array for the realisation of the Mirrors buttons in the Mirror shell
Definition: DAS_Spat.c:231
int NAMS
Number of AMSs Devices.
double realazpos
int SM_A
Motor A (su Y11) respectively: ID=0->InputMirror,ID=1->FilterWheel,ID=2->Zenith.
void MPixmapSetImageFile(MOBJECT pixmap, const char *fname)
unsigned long nstep[AMSMAX][2]
Number of steps to be executed.
int Pos
Mirror Current Position.
flag Flag
Structure for different flags.
#define DBDEMO
execution in demo mode
int Offset[16]
Offset of the hardware devices (Input Mirror (5), Grating, Filter Wheel...)
char * Fil_Code8H[]
const char array for the realisation of the Filters buttons in the Filter shell
Definition: DAS_Spat.c:204
float multiplier[AMSMAX][2]
multiplier, > 0 multiplier, < 0 demultiplier
int SM_stepr(int t)
AMS &#39;steps/round&#39; value return the AMS &#39;steps/round&#39; value (microstepping) depending on the setted st...
Definition: Spat_Device.c:209
void MObjectSetText(MOBJECT obj, const char *text)
int Pos
Filter Wheel current Position.
AzimuthSt AST
Definition: Spat_Device.c:25
#define LIS_
Lampedusa Island Spectrometer - ENEA.
int Wl
Grating Wavelength.
#define TROPOGAS
TROPOspheric Gas Analyzer Spectrometer.
char * Fil_CodeNG[]
const char array for the realisation of the Filters buttons in the Filter shell for GASCODNG2 and NG3...
Definition: DAS_Spat.c:216
long dp
Grating backslash recovery steps.
long postime[AMSMAX][2]
time necessary for positioning
#define GASCODNG2
GASCODNG 2 (with ATX power supply & HiresIV)
#define SPATRAM2
SPATRAM2 (with ATX power supply & HiresV)
#define SPATRAMPLUS
As SPATRAM plus AltAzimuth platform.
void WriteLogAMS(int id, int dira, int dirb, unsigned long stepa, unsigned long stepb)
Definition: Spat_Device.c:299
#define GASCODNG3
GASCODNG 3 (with ATX power supply & HiresIV)
int Revo[AMSMAX][2]
Revolution Direction CW CCW.
#define GASCODNG1
GASCODNG 1 (with ATX power supply & HiresIV)
#define GASCODNG4
GASCODNG 4.
ZenithSt ZST
Definition: Spat_Device.c:24
char * Fil_CodeNG1[]
const char array for the realisation of the Filters buttons in the Filter shell for GASCODNG1 instrum...
Definition: DAS_Spat.c:213
int amsprogbar
display/hide prograssion bar, 0 = Hide, 1 = display
#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.
char * Fil_Code[]
const char array for the realisation of the Filters buttons in the Filter shell
Definition: DAS_Spat.c:207
int wl[]
WaveLength definition - for SD_Grating.
Definition: DAS_Spat.c:182
controlpanel ContrPanel
Control Panel Structure.
GratingSt GRS
Grating.
Definition: Spat_Device.c:22
#define AMS1
AMS1 address.
int DD_VOpen[16]
Definition: Utils.c:151
static double st
Definition: SOLPOS.C:142
int step[AMSMAX][2]
Stepper Motors Step.
double speed_Hz[AMSMAX][2]
Stepper Motors Speed [Hz].
int aaopmode
operation mode for the Alt Az Platform, 0 = solar Traxker; 1 = Anti-Solar Tracker; 2 = Free Positioni...
char * Fil_CodeTropo[]
const char array for the realisation of the Filters buttons in the Filter shell for TROPOGAS instrume...
Definition: DAS_Spat.c:210
double realzenpos
int EqType
Spectrometer Type.
double Pos
Azimuth Current Position.
long wav[]
Step Number definition - for SD_Grating.
Definition: DAS_Spat.c:195
int AMS_sendstep(int id, int dira, int dirb, unsigned long stepa, unsigned long stepb)
Send steps Procedure for sending steps to the Stepper Motor.
Definition: Dxl.c:513
float MIGEZen(float p)
Definition: CreateForms.c:3419
double Pos
Zenith Current Position.
float MIGEAz(float p)
Definition: CreateForms.c:3475
int exemode
Set the Execution MODE (Execution modes)
FilterWheelSt FWS
Filter Wheel.
Definition: DAS_Spat.c:57
#define AMS3
AMS3 address.
int DB_StepMotor(int id, int motor, long step, int dir)
Send steps to the selected stepper motor. .
Definition: Dxl.c:816
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:

§ SD_PosOMUDev()

int SD_PosOMUDev ( int  m,
int  w,
int  f 
)

perform the simoultaneous positioning of the Spectrometer Devices in the OMU Unit m = mirror w = wavelength (Grating) f = filter wheel

Definition at line 747 of file Spat_Device.c.

References controlpanel::Albl_LS, AMS1, AMS2, AMS_sendstep(), optionini::amsprogbar, gui::ContrPanel, D_VRangeSim(), DB_StepMotor(), DBDEMO, DD_VOpen, das::DOption, GratingSt::dp, paramini::EqType, flag::exemode, Fil_Code, Fil_Code8H, Fil_CodeNG, Fil_CodeNG1, Fil_CodeTropo, das::Flag, FWS, GASCODNG1, GASCODNG2, GASCODNG3, GASCODNG4, das::Gui, controlpanel::LedSM, LIS_, Mir_Code, Mir_CodeTropo, MIS, MLoopWhileEvents(), MObjectSetText(), MPixmapSetImageFile(), stepm::multiplier, stepm::NAMS, stepm::nstep, paramini::Offset, das::Paramini, FilterWheelSt::Pos, MirrorSt::Pos, stepm::postime, stepm::Revo, stepm::SM_A, stepm::SM_B, SM_stepr(), SPATRAM, SPATRAM2, SPATRAM3, SPATRAMPLUS, stepm::speed_Hz, st, stepm::step, das::StepM, TROPOGAS, wav, wl, GratingSt::Wl, and WriteLogAMS().

Referenced by E_AvgCCDHor(), E_DFMeasure(), E_Meashor(), E_Meashor2(), and E_Measure().

748 {
749 
750  int k, i, s, er, dir;
751  int backlash = 0;
752 // float GRASTEP, STEPGRA;
753  long minpostime = 2147483647, maxpostime = 0;
754  long st, et, tt, n;
755  double ttout = 0;
756  char buf[80], str[16];
757  long dp = 500; // dp sono i dead pulse, vanno aggiunti all'inversione per il recupero del gioco
758  int StepWithOffset [4][4];
759  float g = 0;
760 
761  for(k=0;k<DAS.StepM.NAMS;k++)
762  { for (i=0;i<2;i++)
763  {
764  s = 2 * k + i;
765  DD_VOpen[s] = 0;
766  }
767  }
768  /*******************************/
769 
770  if((m >= 0) && (m <= 3))
771  {
772  k = SM_stepr(DAS.StepM.step[AMS1][DAS.StepM.SM_A]) * 6 / 4;
773 /* er = (long)(MIS.Pos - m);
774  switch (er)
775  {
776  case 0:
777  n = 0;
778  break;
779  case 1:
780  n = er * k * 3;
781  break;
782  case -3:
783  case -1:
784  case 2:
785  case (-2):
786  n = er * k;
787  break;
788  case 3:
789  n = er * k / 3;
790  break;
791 
792  }
793 
794  */
795  k = SM_stepr(DAS.StepM.step[AMS1][0]) * DAS.StepM.multiplier[AMS1][0] / 4; //4 is the number of positions
796 
797  StepWithOffset [0][0] = 0;
798  StepWithOffset [0][1] = 3*k - DAS.Paramini.Offset[2];
799  StepWithOffset [0][2] = 2*k - DAS.Paramini.Offset[3];
800  StepWithOffset [0][3] = k - DAS.Paramini.Offset[4];
801 
802  StepWithOffset [1][0] = k + DAS.Paramini.Offset[2];
803  StepWithOffset [1][1] = 0;
804  StepWithOffset [1][2] = 3*k - DAS.Paramini.Offset[3] + DAS.Paramini.Offset[2];
805  StepWithOffset [1][3] = 2*k - DAS.Paramini.Offset[4]+ DAS.Paramini.Offset[2];
806 
807  StepWithOffset [2][0] = 2*k + DAS.Paramini.Offset[3];
808  StepWithOffset [2][1] = k - DAS.Paramini.Offset[2]+DAS.Paramini.Offset[3];
809  StepWithOffset [2][2] = 0;
810  StepWithOffset [2][3] = 3*k - DAS.Paramini.Offset[4]+DAS.Paramini.Offset[3];
811 
812  StepWithOffset [3][0] = 3*k + DAS.Paramini.Offset[4];
813  StepWithOffset [3][1] = 2*k - DAS.Paramini.Offset[2]+ DAS.Paramini.Offset[4];
814  StepWithOffset [3][2] = k - DAS.Paramini.Offset[3] + DAS.Paramini.Offset[4];
815  StepWithOffset [3][3] = 0;
816 
817  n = StepWithOffset [m][MIS.Pos];
818 
819 
820 
821  dir = 1;
822  //n = labs(n);
823  DAS.StepM.Revo[AMS1][DAS.StepM.SM_A] = dir;
824  DAS.StepM.nstep[AMS1][DAS.StepM.SM_A] = n;
825  MIS.Pos = m;
826  }
827  else
828  {
829  DAS.StepM.Revo[AMS1][DAS.StepM.SM_A] = 0;
830  DAS.StepM.nstep[AMS1][DAS.StepM.SM_A] = 0;
831 
832  }
833 
834  /******************************/
835  /******************************/
836  //w - Grating position section
837  if(w >= 0 && w <= 17)
838  {
839  g = (float) SM_stepr(DAS.StepM.step[AMS1][1])/3200;
840  n = (long)(((float) (-wav[GRS.Wl] + wav[w]) ) * 4 * g);
841 
842  if(n < 0)
843  dir = 1;
844  else
845  {
846  dir = 0;
847  backlash = 1; //for the backlash recovery
848  }
849  n = labs(n);
850 
851 
852  if(n && dir == 0) //si va verso l'UV
853  n += GRS.dp; // // add fixed step number for backlash recovery
854 
855  DAS.StepM.Revo[AMS1][DAS.StepM.SM_B] = dir;
856  DAS.StepM.nstep[AMS1][DAS.StepM.SM_B] = n;
857  GRS.Wl = w;
858  }
859  else
860  {
861  DAS.StepM.Revo[AMS1][DAS.StepM.SM_B] = 0;
862  DAS.StepM.nstep[AMS1][DAS.StepM.SM_B] = 0;
863 
864  }
865  /*******************************/
866  /*******************************/
867  // f - Filter wheel Section
868 
869  //8 holes....
870  if(DAS.Paramini.EqType == LIS_)
871  {
872  k = SM_stepr(DAS.StepM.step[AMS2][DAS.StepM.SM_A]) / 8;
873  if(f >= 0 && f <= 8)
874  {
875  n= (long)(FWS.Pos - f) * k;
876  if(n < 0)
877  dir = 1;
878  else
879  dir = 0;
880 
881  n = labs(n);
882  DAS.StepM.Revo[AMS2][DAS.StepM.SM_A] = dir;
883  DAS.StepM.nstep[AMS2][DAS.StepM.SM_A] = n;
884  FWS.Pos = f;
885  }
886  else
887  {
888  n = 0;
889  DAS.StepM.Revo[AMS2][DAS.StepM.SM_A] = 0;
890  DAS.StepM.nstep[AMS2][DAS.StepM.SM_A] = 0;
891  }
892 
893 
894  }
895  // ...or 6 holes....
896  if (DAS.Paramini.EqType == SPATRAM ||
899  DAS.Paramini.EqType == TROPOGAS ||
905  {
906  k = SM_stepr(DAS.StepM.step[AMS2][DAS.StepM.SM_A]) / 6;
907  if(f >= 0 && f <= 5)
908  {
909  n= (long)(FWS.Pos - f) * k;
910  if(n < 0)
911  dir = 1;
912  else
913  dir = 0;
914 
915  n = labs(n);
916  DAS.StepM.Revo[AMS2][DAS.StepM.SM_A] = dir;
917  DAS.StepM.nstep[AMS2][DAS.StepM.SM_A] = n;
918  FWS.Pos = f;
919  }
920  else
921  {
922  n = 0;
923  DAS.StepM.Revo[AMS2][DAS.StepM.SM_A] = 0;
924  DAS.StepM.nstep[AMS2][DAS.StepM.SM_A] = 0;
925  }
926  }
927 
928 /**************************************************************************/
929  // Tout computation and Max finding
930  for(k=0;k<2;k++)
931  {
932  for (i=0;i<2;i++)
933  {
934  DAS.StepM.postime[k][i] = (long)( DAS.StepM.nstep[k][i]/(float) DAS.StepM.speed_Hz[k][i]);
935  if (DAS.StepM.postime[k][i] >= maxpostime) maxpostime = DAS.StepM.postime[k][i];
936  if (DAS.StepM.postime[k][i] <= minpostime) minpostime = DAS.StepM.postime[k][i];
937  }
938  }
939 /*************************************************************************/
940 
941  // Init Progression bar
942  for(k=0;k<2;k++)
943  {
944  for (i=0;i<2;i++)
945  {
946  if (DAS.StepM.nstep[k][i] != 0)
947  {
948  s = 2*k+i;
949  switch (s)
950  {
951  case 0:
953  D_VRangeSim(0, "Positioning Mirror",0, 255, 0, 0, 50, 0);
954  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[k][i], "SYS\\ledoff.bmp");
955 
956  break;
957  case 1:
959  D_VRangeSim(1, "Positioning Grating",0, 255, 255, 0, 50, 100);
960  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[k][i], "SYS\\ledoff.bmp");
961  break;
962  case 2:
964  D_VRangeSim(2, "Positioning Filter Wheel",0, 0, 0, 255, 50, 200);
965  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[k][i], "SYS\\ledoff.bmp");
966  break;
967  case 3:
968  break;
969  }
970  }
971  }
972  }
973 
974 /*************************************************************************/
975 
976 /**************************************************************************/
977  // Send step
978  if (DAS.Flag.exemode != DBDEMO)
979  {
980 
981  for(k=0;k<2;k++)
982  {
985 
988 
989  }
990  }
991 /**************************************************************************/
992 
993  //Time Out loop
994  st = GetTickCount();
995  do
996  {
997  et = GetTickCount();
998  tt = labs(et - st);
999  MLoopWhileEvents(0);
1000  if(tt > 0)
1001  {
1002 
1003  if(DD_VOpen[0])
1004  {
1005  if(DAS.DOption.amsprogbar)
1006  D_VRangeSim(0 ,NULL,(unsigned long) tt * 100 / DAS.StepM.postime[AMS1][0], 255, 0, 0, 50, 0);
1007  sprintf(buf, "%.1f sec. left", (double)fabs(((double)(tt - DAS.StepM.postime[AMS1][0]))/1000.0 ));
1009  if (tt >= DAS.StepM.postime[AMS1][0])
1010  {
1012  sprintf(str, "%s",Mir_CodeTropo[m]);
1013  else
1014  sprintf(str, "%s",Mir_Code[m]);
1015 
1016  sprintf(buf, "%s", str);
1018  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[0][0], "SYS\\ledGreen.bmp");
1019 
1020  }
1021  }
1022  else
1023  {
1024  sprintf(buf, "%.1f sec. left", (double)fabs(((double)(tt - DAS.StepM.postime[AMS1][0]))/1000.0 ));
1026  if (tt >= DAS.StepM.postime[AMS1][0])
1027  {
1028  if (m != -1)
1029  {
1031  sprintf(str, "%s",Mir_CodeTropo[m]);
1032  else
1033  sprintf(str, "%s",Mir_Code[m]);
1034 
1035  }
1036  else
1037  {
1039  sprintf(str, "%s",Mir_CodeTropo[MIS.Pos]);
1040  else
1041  sprintf(str, "%s",Mir_Code[MIS.Pos]);
1042 
1043  //sprintf(buf, "%s", str);
1044  //MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[0], buf);
1045  //MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[0][0], "SYS\\ledGreen.bmp");
1046 
1047  }
1048  sprintf(buf, "%s", str);
1050  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[0][0], "SYS\\ledGreen.bmp");
1051 
1052 
1053  }
1054 
1055  }
1056  if(DD_VOpen[1])
1057  {
1058  if(DAS.DOption.amsprogbar)
1059  D_VRangeSim(1, NULL,(unsigned long) tt * 100 / DAS.StepM.postime[AMS1][1], 255, 255, 0, 50, 100);
1060  sprintf(buf, "%.1lf sec. left", (double)fabs(((double)(tt - DAS.StepM.postime[AMS1][1]))/1000.0 ));
1062  if (tt >= DAS.StepM.postime[AMS1][1])
1063  {
1064  sprintf(buf, "%4d", wl[w]);
1066  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[0][1], "SYS\\ledGreen.bmp");
1067  }
1068  }
1069  else
1070  {
1071  sprintf(buf, "%.1lf sec. left", (double)fabs(((double)(tt - DAS.StepM.postime[AMS1][1]))/1000.0 ));
1073  if (tt >= DAS.StepM.postime[AMS1][1])
1074  {
1075  if(w != -1)
1076  sprintf(buf, "%4d", wl[w]);
1077  else
1078  sprintf(buf, "%4d", wl[GRS.Wl]);
1080  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[0][1], "SYS\\ledGreen.bmp");
1081  }
1082  }
1083  if(DD_VOpen[2])
1084  {
1085  if(DAS.DOption.amsprogbar)
1086  D_VRangeSim(2, NULL,(unsigned long) tt * 100 / DAS.StepM.postime[AMS2][0], 0, 0, 255, 50, 200);
1087  sprintf(buf, "%.1lf sec. left", (double)fabs(((double) (tt - DAS.StepM.postime[AMS2][0]) )/1000.0 ));
1089  if (tt >= DAS.StepM.postime[AMS2][0])
1090  {
1091  if ( DAS.Paramini.EqType == LIS_)
1092  sprintf(buf, "%s", Fil_Code8H[f]);
1093  else
1094  {
1095  if(DAS.Paramini.EqType == TROPOGAS)
1096  sprintf(buf, "%s",Fil_CodeTropo[f]);
1098  sprintf(buf, "%s",Fil_CodeNG[f]);
1099  else if (DAS.Paramini.EqType == GASCODNG1)
1100  sprintf(buf, "%s",Fil_CodeNG1[f]);
1101 
1102  else
1103  sprintf(buf, "%s",Fil_Code[f]);
1104  }
1106  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[1][0], "SYS\\ledGreen.bmp");
1107  }
1108  }
1109  else
1110  {
1111  sprintf(buf, "%.1lf sec. left", (double)fabs(((double) (tt - DAS.StepM.postime[AMS2][0]) )/1000.0 ));
1113  if (tt >= DAS.StepM.postime[AMS2][0])
1114  {
1115  if(f != -1)
1116  {
1117  if ( DAS.Paramini.EqType == LIS_)
1118  sprintf(buf, "%s", Fil_Code8H[f]);
1119  else
1120  {
1121  if(DAS.Paramini.EqType == TROPOGAS)
1122  sprintf(buf, "%s",Fil_CodeTropo[f]);
1124  sprintf(buf, "%s",Fil_CodeNG[f]);
1125  else if (DAS.Paramini.EqType == GASCODNG1)
1126  sprintf(buf, "%s",Fil_CodeNG1[f]);
1127 
1128  else
1129  sprintf(buf, "%s",Fil_Code[f]);
1130  }
1131  }
1132  else
1133  {
1134  if ( DAS.Paramini.EqType == LIS_)
1135  sprintf(buf, "%s", Fil_Code8H[FWS.Pos]);
1136  else
1137  {
1138  if(DAS.Paramini.EqType == TROPOGAS)
1139  sprintf(buf, "%s",Fil_CodeTropo[FWS.Pos]);
1141  sprintf(buf, "%s",Fil_CodeNG[FWS.Pos]);
1142  else
1143  sprintf(buf, "%s",Fil_Code[FWS.Pos]);
1144  }
1145  }
1146 
1148  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[1][0], "SYS\\ledGreen.bmp");
1149  }
1150  }
1151 
1152 
1153 
1154  }
1155  }while((tt < maxpostime));
1156 /**************************************************************************/
1157 /**************************************************************************/
1158 
1159  // Check if all the progression bars have been destroyed.
1160  // If not the active one is destroyed and the apprpriate label is written
1161  for(k=0;k<2;k++)
1162  {
1163  for (i=0;i<2;i++)
1164  {
1165  s = 2*k+i;
1166  if(DD_VOpen[s])
1167  {
1168  if(DAS.DOption.amsprogbar)
1169  D_VRangeSim(s, NULL, 100, 0, 0, 0, 0, 0);
1170  switch (s)
1171  {
1172  case 0:
1173  if (m != -1)
1174  {
1176  sprintf(str, "%s",Mir_CodeTropo[m]);
1177  else
1178  sprintf(str, "%s",Mir_Code[m]);
1179  sprintf(buf, "%s", str);
1181  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[k][i], "SYS\\ledGreen.bmp");
1182  }
1183  break;
1184  case 1:
1185  sprintf(buf, "%4d", wl[w]);
1187  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[k][i], "SYS\\ledGreen.bmp");
1188  break;
1189  case 2:
1190  if ( DAS.Paramini.EqType == LIS_)
1191  sprintf(buf, "%s", Fil_Code8H[f]);
1192  else
1193  {
1194  if(DAS.Paramini.EqType == TROPOGAS)
1195  sprintf(buf, "%s",Fil_CodeTropo[f]);
1197  sprintf(buf, "%s",Fil_CodeNG[f]);
1198  else if (DAS.Paramini.EqType == GASCODNG1)
1199  sprintf(buf, "%s",Fil_CodeNG1[f]);
1200  else
1201  sprintf(buf, "%s",Fil_Code[f]);
1202  }
1204  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[k][i], "SYS\\ledGreen.bmp");
1205  break;
1206  case 3:
1207 
1208  break;
1209 
1210  }
1211  }
1212  }
1213 
1214  }
1215 /**************************************************************************/
1216  //Recupero del gioco per grating
1217 
1218  if(DAS.StepM.nstep[AMS1][DAS.StepM.SM_B] && (DAS.StepM.Revo[AMS1][DAS.StepM.SM_B] == 0) )
1219  {
1220  er=DB_StepMotor(AMS1, 1, GRS.dp, 1);
1221  if (er)
1222  {
1223  sprintf(buf, "%4d", wl[w]);
1225  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS1][1], "SYS\\ledGreen.bmp");
1226  }
1227  }
1228 
1229 /**************************************************************************/
1230  return 0;
1231 
1232 
1233 
1234 }
das DAS
DAS structure.
Definition: Spat_Device.c:27
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.
MOBJECT Albl_LS[8]
Active Control Panel Labels for LIS status.
void D_VRangeSim(int id, char *str, int val, int r, int g, int b, int x, int y)
init progress bar during simultaneous positioning
Definition: Utils.c:258
void MLoopWhileEvents(int discard)
optionini DOption
Options for DAS execution.
#define AMS2
AMS2 address.
const char * Mir_Code[]
const char array for the realisation of the Mirrors buttons in the Mirror shell
Definition: DAS_Spat.c:231
int NAMS
Number of AMSs Devices.
int SM_A
Motor A (su Y11) respectively: ID=0->InputMirror,ID=1->FilterWheel,ID=2->Zenith.
void MPixmapSetImageFile(MOBJECT pixmap, const char *fname)
unsigned long nstep[AMSMAX][2]
Number of steps to be executed.
int Pos
Mirror Current Position.
flag Flag
Structure for different flags.
#define DBDEMO
execution in demo mode
int Offset[16]
Offset of the hardware devices (Input Mirror (5), Grating, Filter Wheel...)
char * Fil_Code8H[]
const char array for the realisation of the Filters buttons in the Filter shell
Definition: DAS_Spat.c:204
float multiplier[AMSMAX][2]
multiplier, > 0 multiplier, < 0 demultiplier
int SM_stepr(int t)
AMS &#39;steps/round&#39; value return the AMS &#39;steps/round&#39; value (microstepping) depending on the setted st...
Definition: Spat_Device.c:209
void MObjectSetText(MOBJECT obj, const char *text)
int Pos
Filter Wheel current Position.
#define LIS_
Lampedusa Island Spectrometer - ENEA.
int Wl
Grating Wavelength.
#define TROPOGAS
TROPOspheric Gas Analyzer Spectrometer.
char * Fil_CodeNG[]
const char array for the realisation of the Filters buttons in the Filter shell for GASCODNG2 and NG3...
Definition: DAS_Spat.c:216
long dp
Grating backslash recovery steps.
long postime[AMSMAX][2]
time necessary for positioning
#define GASCODNG2
GASCODNG 2 (with ATX power supply & HiresIV)
#define SPATRAM2
SPATRAM2 (with ATX power supply & HiresV)
#define SPATRAMPLUS
As SPATRAM plus AltAzimuth platform.
void WriteLogAMS(int id, int dira, int dirb, unsigned long stepa, unsigned long stepb)
Definition: Spat_Device.c:299
#define GASCODNG3
GASCODNG 3 (with ATX power supply & HiresIV)
int Revo[AMSMAX][2]
Revolution Direction CW CCW.
#define GASCODNG1
GASCODNG 1 (with ATX power supply & HiresIV)
#define GASCODNG4
GASCODNG 4.
char * Fil_CodeNG1[]
const char array for the realisation of the Filters buttons in the Filter shell for GASCODNG1 instrum...
Definition: DAS_Spat.c:213
int amsprogbar
display/hide prograssion bar, 0 = Hide, 1 = display
#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.
char * Fil_Code[]
const char array for the realisation of the Filters buttons in the Filter shell
Definition: DAS_Spat.c:207
int wl[]
WaveLength definition - for SD_Grating.
Definition: DAS_Spat.c:182
controlpanel ContrPanel
Control Panel Structure.
GratingSt GRS
Grating.
Definition: Spat_Device.c:22
#define AMS1
AMS1 address.
int DD_VOpen[16]
Definition: Utils.c:151
static double st
Definition: SOLPOS.C:142
int step[AMSMAX][2]
Stepper Motors Step.
double speed_Hz[AMSMAX][2]
Stepper Motors Speed [Hz].
char * Fil_CodeTropo[]
const char array for the realisation of the Filters buttons in the Filter shell for TROPOGAS instrume...
Definition: DAS_Spat.c:210
int EqType
Spectrometer Type.
long wav[]
Step Number definition - for SD_Grating.
Definition: DAS_Spat.c:195
int AMS_sendstep(int id, int dira, int dirb, unsigned long stepa, unsigned long stepb)
Send steps Procedure for sending steps to the Stepper Motor.
Definition: Dxl.c:513
int exemode
Set the Execution MODE (Execution modes)
FilterWheelSt FWS
Filter Wheel.
Definition: DAS_Spat.c:57
int DB_StepMotor(int id, int motor, long step, int dir)
Send steps to the selected stepper motor. .
Definition: Dxl.c:816
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:

§ SD_Zenith()

int SD_Zenith ( float  ang)

Positioning Zenith.
The Zenith reaches the position specified by ang.

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

Definition at line 2916 of file Spat_Device.c.

References controlpanel::Albl_LS, AMS3, gui::ContrPanel, DB_KB_ButtonActive(), DB_StepMotor(), flag::exec, flag::fileprg, das::Gui, pushbutt::KeyB, controlpanel::LedSM, MIGEZen(), MObjectSetSensitive(), MObjectSetText(), MPixmapSetImageFile(), stepm::multiplier, stepm::nstep, ZenithSt::Pos, gui::PushButt, ZenithSt::realzenpos, stepm::Revo, stepm::SM_A, SM_stepr(), stepm::step, and das::StepM.

Referenced by ActMvZenDegCB(), E_AAMeasure(), E_IRefSun(), and E_Zenith().

2917 {
2918  int er = 0;
2919  char buf[80];
2920  long n, dp = 500; // dp sono i dead pulse, vanno aggiunti all'inversione per il recupero del gioco
2921  int dir;
2922  int k = 0;
2923 // float x;
2924  double GRASTEP, STEPGRA;
2925 // float prepos;
2926  double yy;
2927  float rzenang;
2928 // if(DAS.MIGE.type)
2929 // {
2930  // +90 --> DX looking to the North
2931  // -90 --> SX looking to the North
2932 // if(ang < 0 || ang > 180 ) return 0;
2933 // }
2934 // else
2935 // {
2936  //if ang is not in the limits the DAS exit from the function
2937 // if(ang < -91 || ang > 45 ) return 0;
2938 // }
2939  //Status("Set NEW zenith Position");
2940 
2941  //Disattiva i pulsanti sulla keyboard
2942  DB_KB_ButtonActive(0);
2945 
2946 /*
2947  k = (float)SM_stepr(DAS.StepM.step[AMS3][0]); // step/round
2948 
2949  GRASTEP = 360/k; // º/step
2950 
2951  STEPGRA = k/360; // step/º
2952 
2953 
2954  yy = -(ang - ZST.Pos); // -(55-90) = 35 //1
2955  //-(56-55) = -1 //2
2956  //-(96-56) = -40 //3
2957  //-(90-96) = 6 //4
2958 
2959 
2960  n = (long)(yy * STEPGRA * (DAS.StepM.multiplier[AMS3][0])); //4 e' la riduzione
2961 
2962 
2963  prepos = ZST.Pos;
2964  ZST.Pos = ang;
2965 
2966  sprintf(buf, " %.1lf --> %.1lf", prepos, ang);
2967  Status(buf);
2968 
2969  // Select direction
2970  if(n < 0)
2971  dir = 1;
2972  else
2973  dir = 0;
2974 
2975  n = labs(n);
2976 
2977 // if(n && dir == 0) //si va verso l'UV
2978 // n += dp; // // add fixed step number for backlash recovery
2979 
2980 
2981 */
2982 
2983 
2984  //Zenith positioning
2985  rzenang=MIGEZen((float)ang);
2986 
2987  if(ang >= 0 && ang <= 180 )
2988  {
2989 
2990 
2991 
2992  k = SM_stepr(DAS.StepM.step[AMS3][DAS.StepM.SM_A]); // step/round
2993 
2994  GRASTEP = (float) 360.0 / (float) k; // degree/step
2995 
2996  STEPGRA = (float) k / (float) 360.0; // step/degree
2997 
2998 // yy = -(z - ZST.Pos);
2999  yy = -(rzenang - ZST.Pos);
3000  n = (long)(yy * STEPGRA * (DAS.StepM.multiplier[AMS3][0]));
3001 // ZST.Pos = z;
3002  ZST.Pos = rzenang;
3003  ZST.realzenpos = ang;
3004  // Select direction
3005  if(n < 0)
3006  dir = 1;
3007  else
3008  dir = 0;
3009 
3010  n = labs(n);
3011  DAS.StepM.Revo[AMS3][DAS.StepM.SM_A] = dir;
3012  DAS.StepM.nstep[AMS3][DAS.StepM.SM_A] = n;
3013  }
3014  else
3015  {
3016  DAS.StepM.Revo[AMS3][DAS.StepM.SM_A] = 0;
3017  DAS.StepM.nstep[AMS3][DAS.StepM.SM_A] = 0;
3018  sprintf(buf, "Not Allowed Zen.");
3020 
3021  }
3022 
3023  if (n==0)
3024  {
3025  //Attiva i pulsanti sulla keyboard
3026  DB_KB_ButtonActive(1);
3027  return 1;
3028  }
3029 
3030  // Eseguo n passi
3031  if(n)
3032  {
3034  if (er)
3035  {
3036  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS3][0], "SYS\\ledGreen.bmp");
3037  }
3038  }
3039 
3040 /* if(dir == 0)
3041  {
3042  er=DB_StepMotor(AMS3, DAS.StepM.SM5, dp, 1);
3043  if (er)
3044  {
3045  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM5, "SYS\\ledGreen.bmp");
3046  }
3047  }
3048 */
3049 
3050  sprintf(buf, "%.2lf", ang);
3052  if(!FLAG.fileprg || !FLAG.exec )
3053  //Attiva i pulsanti sulla keyboard se non si sta eseguendo una tabella di misure
3054  //oppure se il programma e' stato sospeso (si e' premuto il tasto "pause")
3055  DB_KB_ButtonActive(1);
3056 
3057 
3058 
3059  if(er) return 1;
3060 
3061 
3062  return 0;
3063 
3064 }
das DAS
DAS structure.
Definition: Spat_Device.c:27
stepm StepM
Stepper motors parameters structure.
gui Gui
Graphic User Interface Structure.
void DB_KB_ButtonActive(int mod)
Enable/Disable Push buttons on the Control Panel.
Definition: CreateForms.c:3810
MOBJECT LedSM[AMSMAX][2]
Leds for stepper motors status.
MOBJECT Albl_LS[8]
Active Control Panel Labels for LIS status.
MOBJECT KeyB[28]
Keyboard Buttons.
int SM_A
Motor A (su Y11) respectively: ID=0->InputMirror,ID=1->FilterWheel,ID=2->Zenith.
void MPixmapSetImageFile(MOBJECT pixmap, const char *fname)
unsigned long nstep[AMSMAX][2]
Number of steps to be executed.
float multiplier[AMSMAX][2]
multiplier, > 0 multiplier, < 0 demultiplier
int SM_stepr(int t)
AMS &#39;steps/round&#39; value return the AMS &#39;steps/round&#39; value (microstepping) depending on the setted st...
Definition: Spat_Device.c:209
void MObjectSetText(MOBJECT obj, const char *text)
int exec
= 0 -> PRG Execution Paused; = 1 -> PRG Execution Resumed
pushbutt PushButt
Push buttons.
int Revo[AMSMAX][2]
Revolution Direction CW CCW.
ZenithSt ZST
Definition: Spat_Device.c:24
flag FLAG
flags structure
Definition: Spat_Device.c:19
int fileprg
Flag indicating the execution of a PRG file: = 0 –> No PRG File; = 1 –> PRG file in execution...
controlpanel ContrPanel
Control Panel Structure.
int step[AMSMAX][2]
Stepper Motors Step.
double realzenpos
void MObjectSetSensitive(MOBJECT obj)
float MIGEZen(float p)
Definition: CreateForms.c:3419
double Pos
Zenith Current Position.
#define AMS3
AMS3 address.
int DB_StepMotor(int id, int motor, long step, int dir)
Send steps to the selected stepper motor. .
Definition: Dxl.c:816
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ SD_Zenith_H()

int SD_Zenith_H ( float  ang)

Definition at line 2816 of file Spat_Device.c.

References controlpanel::Albl_LS, AMS3, gui::ContrPanel, DB_KB_ButtonActive(), DB_StepMotor(), flag::exec, flag::fileprg, das::Gui, pushbutt::KeyB, controlpanel::LedSM, MObjectSetSensitive(), MObjectSetText(), MPixmapSetImageFile(), stepm::multiplier, ZenithSt::Pos, gui::PushButt, SM_stepr(), Status(), stepm::step, and das::StepM.

Referenced by HomeZenithFast().

2817 {
2818 
2819  int er = 0;
2820  char buf[80];
2821  long n, dp = 500; // dp sono i dead pulse, vanno aggiunti all'inversione per il recupero del gioco
2822  int dir;
2823  float k = 0;
2824 // float x;
2825  double GRASTEP, STEPGRA;
2826  float prepos;
2827  double yy;
2828 // float rzenang;
2829 // if(DAS.MIGE.type)
2830 // {
2831  // +90 --> DX looking to the North
2832  // -90 --> SX looking to the North
2833  if(ang < -91 || ang > 91 ) return 0;
2834 // }
2835 // else
2836 // {
2837  //if ang is not in the limits the DAS exit from the function
2838 // if(ang < -91 || ang > 45 ) return 0;
2839 // }
2840  //Status("Set NEW zenith Position");
2841 
2842  //Disattiva i pulsanti sulla keyboard
2843  DB_KB_ButtonActive(0);
2846 
2847 
2848  k = (float)SM_stepr(DAS.StepM.step[AMS3][0]); // step/round
2849 
2850  GRASTEP = 360/k; // º/step
2851 
2852  STEPGRA = k/360; // step/º
2853 
2854 
2855  yy = -(ang - ZST.Pos); // -(55-90) = 35 //1
2856  //-(56-55) = -1 //2
2857  //-(96-56) = -40 //3
2858  //-(90-96) = 6 //4
2859 
2860 
2861  n = (long)(yy * STEPGRA * (DAS.StepM.multiplier[AMS3][0])); //4 e' la riduzione
2862 
2863 
2864  prepos = (float)ZST.Pos;
2865  ZST.Pos = ang;
2866 
2867  sprintf(buf, " %.1lf --> %.1lf", prepos, ang);
2868  Status(buf);
2869 
2870  // Select direction
2871  if(n < 0)
2872  dir = 1;
2873  else
2874  dir = 0;
2875 
2876  n = labs(n);
2877 
2878 
2879  if (n==0)
2880  {
2881  //Attiva i pulsanti sulla keyboard
2882  DB_KB_ButtonActive(1);
2883  return 1;
2884  }
2885 
2886  // Eseguo n passi
2887  if(n)
2888  {
2889  er = DB_StepMotor(AMS3, 4, n, dir);
2890  if (er)
2891  {
2892  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS3][0], "SYS\\ledGreen.bmp");
2893  }
2894  }
2895 
2896  sprintf(buf, "%.2lf", ang);
2898  if(!FLAG.fileprg || !FLAG.exec )
2899  //Attiva i pulsanti sulla keyboard se non si sta eseguendo una tabella di misure
2900  //oppure se il programma e' stato sospeso (si e' premuto il tasto "pause")
2901  DB_KB_ButtonActive(1);
2902 
2903 
2904 
2905  if(er) return 1;
2906 
2907 
2908  return 0;
2909 
2910 
2911 
2912 
2913 
2914 }
das DAS
DAS structure.
Definition: Spat_Device.c:27
stepm StepM
Stepper motors parameters structure.
gui Gui
Graphic User Interface Structure.
void DB_KB_ButtonActive(int mod)
Enable/Disable Push buttons on the Control Panel.
Definition: CreateForms.c:3810
MOBJECT LedSM[AMSMAX][2]
Leds for stepper motors status.
MOBJECT Albl_LS[8]
Active Control Panel Labels for LIS status.
MOBJECT KeyB[28]
Keyboard Buttons.
void MPixmapSetImageFile(MOBJECT pixmap, const char *fname)
float multiplier[AMSMAX][2]
multiplier, > 0 multiplier, < 0 demultiplier
int SM_stepr(int t)
AMS &#39;steps/round&#39; value return the AMS &#39;steps/round&#39; value (microstepping) depending on the setted st...
Definition: Spat_Device.c:209
void MObjectSetText(MOBJECT obj, const char *text)
int exec
= 0 -> PRG Execution Paused; = 1 -> PRG Execution Resumed
void Status(char *tit)
Writes information&#39;s on the Status label .
Definition: Load.c:1556
pushbutt PushButt
Push buttons.
ZenithSt ZST
Definition: Spat_Device.c:24
flag FLAG
flags structure
Definition: Spat_Device.c:19
int fileprg
Flag indicating the execution of a PRG file: = 0 –> No PRG File; = 1 –> PRG file in execution...
controlpanel ContrPanel
Control Panel Structure.
int step[AMSMAX][2]
Stepper Motors Step.
void MObjectSetSensitive(MOBJECT obj)
double Pos
Zenith Current Position.
#define AMS3
AMS3 address.
int DB_StepMotor(int id, int motor, long step, int dir)
Send steps to the selected stepper motor. .
Definition: Dxl.c:816
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ SM_stepr()

int SM_stepr ( int  t)

AMS 'steps/round' value return the AMS 'steps/round' value (microstepping) depending on the setted step fractioning.

Parameters
t= fraction
Returns
er = steps/round
t | er
-—|-----—
0 | 400
1 | 800
2 | 1000
3 | 1600
4 | 2000
5 | 3200
6 | 5000
7 | 6400
8 | 10000
9 | 12800
10 | 25000
11 | 25600
12 | 50000
13 | 51200

Definition at line 209 of file Spat_Device.c.

Referenced by ActMvGratCB(), D_Calibra(), SD_Azimuth(), SD_FilterW(), SD_Grating(), SD_Mirror(), SD_NDFilterW(), SD_PosAADev(), SD_Position(), SD_PosOMUDev(), SD_Zenith(), and SD_Zenith_H().

210 {
211 
212 
213 
214 
215  int c = t;
216  int r;
217 
218  switch(c)
219  {
220  case 0:
221  r = 400;
222  break;
223  case 1:
224  r = 800;
225  break;
226  case 2 :
227  r = 1000;
228  break;
229  case 3:
230  r = 1600;
231  break;
232  case 4 :
233  r = 2000;
234  break;
235  case 5:
236  r = 3200;
237  break;
238  case 6 :
239  r = 5000;
240  break;
241  case 7:
242  r = 6400;
243  break;
244  case 8 :
245  r = 10000;
246  break;
247  case 9:
248  r = 12800;
249  break;
250  case 10 :
251  r = 25000;
252  break;
253  case 11:
254  r = 25600;
255  break;
256  case 12 :
257  r = 50000;
258  break;
259  case 13:
260  r = 51200;
261  break;
262 
263  }
264 
265  return r;
266 
267 
268 }
+ Here is the caller graph for this function:

§ SMfraz()

float SMfraz ( int  t)

denominator value of the stepping ratio

Parameters
tvalue of microstepping (0 to 13)

Definition at line 129 of file Spat_Device.c.

Referenced by ActMvAzimCB(), ActMvZenCB(), and HomeMirror().

130 {
131  int c = t;
132  float r;
133 
134  switch(c)
135  {
136  case 0:
137  r = 1;
138  break;
139  case 1:
140  r = 2;
141  break;
142  case 2 :
143  r = 2.5;
144  break;
145  case 3:
146  r = 4;
147  break;
148  case 4 :
149  r = 5;
150  break;
151  case 5:
152  r = 8;
153  break;
154  case 6 :
155  r = 12.5;
156  break;
157  case 7:
158  r = 16;
159  break;
160  case 8 :
161  r = 25;
162  break;
163  case 9:
164  r = 32;
165  break;
166  case 10 :
167  r = 62.5;
168  break;
169  case 11:
170  r = 64;
171  break;
172  case 12 :
173  r = 125;
174  break;
175  case 13:
176  r = 128;
177  break;
178 
179  }
180 
181  return r;
182 
183 
184 }
+ Here is the caller graph for this function:

§ WriteLogAMS()

void WriteLogAMS ( int  id,
int  dira,
int  dirb,
unsigned long  stepa,
unsigned long  stepb 
)

Definition at line 299 of file Spat_Device.c.

References DXL_par::bufrx, DXL_par::buftx, DLOG, and dlog::fsmlog.

Referenced by SD_PosAADev(), SD_Position(), and SD_PosOMUDev().

300 {
301 
302  int fc;
303  char str[250];
304  char str1[30];
305  char str2[30];
306  char timebuf[9];
307  char datebuf[9];
308 
309  _strtime(timebuf);
310  _strdate(datebuf);
311 
312  if(id==0)
313  {
314  if(stepa && (stepb==0))
315  {
316  sprintf(str1,"Input Mirror");
317  fc = open(DLOG.fsmlog, O_WRONLY | O_APPEND | O_TEXT | O_CREAT, S_IWRITE);
318  if(fc)
319  {
320  sprintf(str, "%s at %s: %s, from AMS%u, dir=%d, Steps=%ld, Steps(esa)=%lX, DXL.buftx=%s, DXL.bufrx=%s\n", datebuf, timebuf, str1, id, dira, stepa, stepa, DXL.buftx, DXL.bufrx);
321  write(fc, str, strlen(str));
322  }
323  close(fc);
324 
325  }
326  if(stepb && (stepa==0))
327  {
328  sprintf(str1,"Grating ");
329  fc = open(DLOG.fsmlog, O_WRONLY | O_APPEND | O_TEXT | O_CREAT, S_IWRITE);
330  if(fc)
331  {
332  sprintf(str, "%s at %s: %s, from AMS%u, dir=%d, Steps=%ld, Steps(esa)=%lX, DXL.buftx=%s, DXL.bufrx=%s\n", datebuf, timebuf, str1, id, dirb, stepb, stepb, DXL.buftx, DXL.bufrx);
333  write(fc, str, strlen(str));
334  }
335  close(fc);
336 
337  }
338  if(stepa && stepb)
339  {
340  sprintf(str1,"Input Mirror");
341  sprintf(str2,"Grating ");
342  fc = open(DLOG.fsmlog, O_WRONLY | O_APPEND | O_TEXT | O_CREAT, S_IWRITE);
343  if(fc)
344  {
345  sprintf(str, "%s at %s: %s, from AMS%u, dir=%d, Steps=%ld, Steps(esa)=%lX, DXL.buftx=%s, DXL.bufrx=%s\n", datebuf, timebuf, str1, id, dira, stepa, stepa, DXL.buftx, DXL.bufrx);
346  write(fc, str, strlen(str));
347  sprintf(str, "%s at %s: %s, from AMS%u, dir=%d, Steps=%ld, Steps(esa)=%lX, DXL.buftx=%s, DXL.bufrx=%s\n", datebuf, timebuf, str2, id, dirb, stepb, stepb, DXL.buftx, DXL.bufrx);
348  write(fc, str, strlen(str));
349  }
350  close(fc);
351  }
352 
353  }
354 
355  if(id==1)
356  {
357  if(stepa && (stepb==0))
358  {
359  sprintf(str1,"Filter Wheel");
360  fc = open(DLOG.fsmlog, O_WRONLY | O_APPEND | O_TEXT | O_CREAT, S_IWRITE);
361  if(fc)
362  {
363  sprintf(str, "%s at %s: %s, from AMS%u, dir=%d, Steps=%ld, Steps(esa)=%lX, DXL.buftx=%s, DXL.bufrx=%s\n", datebuf, timebuf, str1, id, dira, stepa, stepa, DXL.buftx, DXL.bufrx);
364  write(fc, str, strlen(str));
365  }
366  close(fc);
367 
368  }
369  if(stepb && (stepa==0))
370  {
371  sprintf(str2,"SPARE ");
372  fc = open(DLOG.fsmlog, O_WRONLY | O_APPEND | O_TEXT | O_CREAT, S_IWRITE);
373  if(fc)
374  {
375  sprintf(str, "%s at %s: %s, from AMS%u, dir=%d, Steps=%ld, Steps(esa)=%lX, DXL.buftx=%s, DXL.bufrx=%s\n",
376  datebuf, timebuf, str2, id, dirb, stepb, stepb, DXL.buftx, DXL.bufrx);
377  write(fc, str, strlen(str));
378  }
379  close(fc);
380 
381  }
382  if(stepa && stepb)
383  {
384  sprintf(str1,"Filter Wheel");
385  sprintf(str2,"SPARE ");
386  fc = open(DLOG.fsmlog, O_WRONLY | O_APPEND | O_TEXT | O_CREAT, S_IWRITE);
387  if(fc)
388  {
389  sprintf(str, "%s at %s: %s, from AMS%u, dir=%d, Steps=%ld, Steps(esa)=%lX, DXL.buftx=%s, DXL.bufrx=%s\n", datebuf, timebuf, str1, id, dira, stepa, stepa, DXL.buftx, DXL.bufrx);
390  write(fc, str, strlen(str));
391  sprintf(str, "%s at %s: %s, from AMS%u, dir=%d, Steps=%ld, Steps(esa)=%lX, DXL.buftx=%s, DXL.bufrx=%s\n", datebuf, timebuf, str2, id, dirb, stepb, stepb, DXL.buftx, DXL.bufrx);
392  write(fc, str, strlen(str));
393  }
394  close(fc);
395  }
396  }
397 
398  if(id==2)
399  {
400  if(stepa && (stepb==0))
401  {
402  sprintf(str1,"Zenith ");
403  fc = open(DLOG.fsmlog, O_WRONLY | O_APPEND | O_TEXT | O_CREAT, S_IWRITE);
404  if(fc)
405  {
406  sprintf(str, "%s at %s: %s, from AMS%u, dir=%d, Steps=%ld, Steps(esa)=%lX, DXL.buftx=%s, DXL.bufrx=%s\n",
407  datebuf, timebuf, str1, id, dira, stepa, stepa, DXL.buftx, DXL.bufrx);
408  write(fc, str, strlen(str));
409  }
410  close(fc);
411 
412  }
413  if(stepb && (stepa==0))
414  {
415  sprintf(str2,"Azimuth ");
416  fc = open(DLOG.fsmlog, O_WRONLY | O_APPEND | O_TEXT | O_CREAT, S_IWRITE);
417  if(fc)
418  {
419  sprintf(str, "%s at %s: %s, from AMS%u, dir=%d, Steps=%ld, Steps(esa)=%lX, DXL.buftx=%s, DXL.bufrx=%s\n",
420  datebuf, timebuf, str2, id, dirb, stepb, stepb, DXL.buftx, DXL.bufrx);
421  write(fc, str, strlen(str));
422  }
423  close(fc);
424 
425  }
426  if(stepa && stepb)
427  {
428  sprintf(str1,"Zenith ");
429  sprintf(str2,"Azimuth ");
430  fc = open(DLOG.fsmlog, O_WRONLY | O_APPEND | O_TEXT | O_CREAT, S_IWRITE);
431  if(fc)
432  {
433  sprintf(str, "%s at %s: %s, from AMS%u, dir=%d, Steps=%ld, Steps(esa)=%lX, DXL.buftx=%s, DXL.bufrx=%s\n", datebuf, timebuf, str1, id, dira, stepa, stepa, DXL.buftx, DXL.bufrx);
434  write(fc, str, strlen(str));
435  sprintf(str, "%s at %s: %s, from AMS%u, dir=%d, Steps=%ld, Steps(esa)=%lX, DXL.buftx=%s, DXL.bufrx=%s\n", datebuf, timebuf, str2, id, dirb, stepb, stepb, DXL.buftx, DXL.bufrx);
436  write(fc, str, strlen(str));
437  }
438  close(fc);
439  }
440  }
441 
442 }
char fsmlog[_MAX_PATH]
daily LOG file for stepper motor moovements
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
dlog DLOG
Definition: DAS_Spat.c:52
DXL_par DXL
Definition: Spat_Device.c:17
char bufrx[1024]
Rx buffer.
Definition: DXL.H:20
+ Here is the caller graph for this function:

§ writelogmotor()

void writelogmotor ( int  mod,
int  id_motore,
int  k,
int  d,
long  steps,
unsigned char  ams_id 
)

Write Motor Operations on Log File.
Write on the SM.LOG file the commands send to the motors.

Parameters
mod
  • = 0 write commands
  • = 1 AMS initialization
id_motore
  • = SMx, with X = 1, 2, 3. (5, 6 for TROPOGAS)
k= er
d= direction:
  • = 0
  • = 1
steps= number of steps
ams_id= AMS address:
  • 0 = AMS1
  • 1 = AMS2
  • 2 = AMS3

Definition at line 48 of file Spat_Device.c.

References DXL_par::bufrx, DXL_par::buftx, DLOG, and dlog::fsmlog.

Referenced by AMS_DoPos().

49 {
50  int fc;
51  char str[250];
52  char str1[30];
53  char timebuf[9];
54  char datebuf[9];
55 
56  if (mod==0)
57  {
58  if(id_motore==0)
59  sprintf(str1,"Input Mirror");
60  if(id_motore==1)
61  sprintf(str1,"Grating ");
62  if(id_motore==2)
63  sprintf(str1,"Filter Wheel");
64  if(id_motore==4)
65  sprintf(str1,"Zenith ");
66  if(id_motore==5)
67  sprintf(str1,"Azimuth ");
68 
69  fc = open(DLOG.fsmlog, O_WRONLY | O_APPEND | O_TEXT | O_CREAT, S_IWRITE);
70 
71  if(fc > 0)
72  {
73  _strtime(timebuf);
74  _strdate(datebuf);
75 
76 
77 // sprintf(str, "%s, err = %d, from AMS%u, dir=%d, Steps=%ld, Steps(esa)=%lX, DXL.buftx=%s, DXL.bufrx=%s\n",
78 // str1, k, ams_id, d, steps, steps, DXL.buftx, DXL.bufrx);
79 // write(fc, str, strlen(str));
80 
81  sprintf(str, "%s at %s: %s, from AMS%u, dir=%d, Steps=%ld, Steps(esa)=%lX, DXL.buftx=%s, DXL.bufrx=%s\n",
82  datebuf, timebuf, str1, ams_id, d, steps, steps, DXL.buftx, DXL.bufrx);
83  write(fc, str, strlen(str));
84 
85  }
86 
87  close(fc);
88  }
89  // For the AMS initialization
90  if (mod == 1)
91  {
92 
93  if(id_motore==0)
94  sprintf(str1,"Input Mirror");
95  if(id_motore==1)
96  sprintf(str1,"Grating ");
97  if(id_motore==2)
98  sprintf(str1,"Filter Wheel");
99 
100 
101 
102  fc = open("LOG\\logSM.log", O_WRONLY | O_APPEND | O_TEXT | O_CREAT, S_IWRITE);
103 
104  if(fc > 0)
105  {
106 
107  _strtime(timebuf);
108  _strdate(datebuf);
109 
110  sprintf(str, "%s at %s, AMSs Init with\n ", datebuf, timebuf);
111  write(fc, str, strlen(str));
112 
113 // sprintf(str, "%s :\n Power:%d (%.1lf%%), Step: %d (%s), Slope: %d, Speed: %d (%.3lf) \n",str1, DAS.StepM.cop[id_motore], DAS.StepM.cop_perc[id_motore], DAS.StepM.step[id_motore], DAS.StepM.step_fraz[id_motore], DAS.StepM.slope[id_motore], DAS.StepM.speed[id_motore], DAS.StepM.speed_Hz[id_motore]);
114  write(fc, str, strlen(str));
115 
116  }
117 
118  close(fc);
119  }
120 
121 
122 
123 }
char fsmlog[_MAX_PATH]
daily LOG file for stepper motor moovements
char buftx[1024]
Tx buffer.
Definition: DXL.H:21
dlog DLOG
Definition: DAS_Spat.c:52
DXL_par DXL
Definition: Spat_Device.c:17
char bufrx[1024]
Rx buffer.
Definition: DXL.H:20
+ Here is the caller graph for this function:

Variable Documentation

§ AST

AzimuthSt AST

Definition at line 25 of file Spat_Device.c.

§ DAS

das DAS

DAS structure.

Definition at line 27 of file Spat_Device.c.

§ DXL

DXL_par DXL

Definition at line 17 of file Spat_Device.c.

§ FLAG

flag FLAG

flags structure

Definition at line 19 of file Spat_Device.c.

§ GRS

GratingSt GRS

Grating.

Definition at line 22 of file Spat_Device.c.

§ ZST

ZenithSt ZST

Definition at line 24 of file Spat_Device.c.

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