FEDRA emulsion software from the OPERA Collaboration
AcqStage1.h
Go to the documentation of this file.
1#ifndef ROOT_AcqStage1
2#define ROOT_AcqStage1
4// //
5// AcqStage1 //
6// //
7// Interface to the stage controller //
8// These classes manage Micos stages X,Y,Z
9// Althow the code is based on SySal, the preference is made
10// for NI native functions executed on board of NI7344 controller, rather than
11// host processor threads, like in SySal
12// The Breakpoint generation functions are exploited and the buffered
13// BP generation is realized by on-board program to provide
14// harware syncronization between stage and camera.
15// Cable connecting DB25 "Digital IO" connector of MICOS amplifyer block
16// with DB9 auxiliary digital connector of Odyssey Xpro must be present
17// to provide syncronous stage-framegrabber operation.
18// The pinout is as follows:
19//
20// DB9 Male DB25 Female
21// Pin Signal Pin Signal
22// 1 "Trig0" 5 "Breakpoint3"
23// 6 "GND" 16 "GND"
24// //
26
27#include <cstdio>
28#include <cstdlib>
29#include <string>
30#include <ctime>
31
32// fix rootcint errors with Visual C++ 2005
33#ifndef __CINT__
34# include <conio.h>
35#endif
36
37// kbhit, getch POSIX functions are deprecated beginning in Visual C++ 2005.
38// Use the ISO C++ conformant _kbhit and _getch instead.
39#if MSC_VER >= 1400 // Visual C++ 2005 MSC_VER=1400
40# define kbhit _kbhit
41# define getch _getch
42#endif
43
44#include "TObject.h"
45#include "EdbAffine.h"
46#include "EdbFiducial.h"
47
48#include "NI/include/flexmotn.h"
49
50//______________________________________________________________________________
51class AcqAxis : public TObject {
52
53 public:
54
55 AcqAxis();
56 AcqAxis(int Ax); // Main constructor, Ax is from 1 to 3
57 virtual ~AcqAxis() {}
58
59 int Axis; // Axis number (1 to 3)
60 int BoardId; // NI7344 Board number (Default is 0)
61 int StepsRev; // Step motor parameter : steps per revolution
62 int LinesRev; // Encoder parameter : lines per revolution (in case of linear encoder defines line-to-step ratio only).
63 float EncoderToMicrons; // Microns per one line of encoder
64 float MicronsToSteps; // Microns per one step of step motor
65 float Accel; // Max acceleration [mic/s2]
66 float MaxSpeed; // Max speed [mic/s]
67 int LimPol,HomePol; // Limiter switch and Home switch polarities
68 int CtlModeIsCWCCW; // Stepper control mode: Step/Direction (0) or Clockwise/Counterclockwise (1)
69 int TurnOffLightTime; //Not implemented yet!
70 int Invert; // defines axis direction inversion
71 float HomingSpeed; // Speed when perfoming home finding
72 float Reference; // user derived Reference value (usually emulsion corner position for X,Y and glass surface for Z)
73 float NominalReference; // Nominal Reference value (usually emulsion corner position for X,Y and glass surface for Z)
74
75
76 bool Initialize();
77 void PosMove( float Pos, float Speed, float Acc);
78 void Move( float Speed, float Acc);
79 void Stop();
80 void Reset();
81 int FindHome(int Direction);
82 int WaitForHome(int Timeout);
83 int WaitForMoveComplete( u32 Timeout);
84 float GetPos();
85 int GetLimiter();
86 bool IsMoveComplete();
87 void LoadMoveCompleteCriteria(bool MotorOff, bool Stop, bool Delay, bool InPosition, float DeadBand, int sdelay, int minPulse);
88 void ArmBreakpoint(float Pos);
89 void LoadBreakpointSequence(float *Pos, int N);
94 void DisarmBreakpoint();
96 void Test( float *Pos, int N);
97 void SetFilterFrequency(int Freq);
99 void SetFollowingError(u16 Error);
100
101
102 ClassDef(AcqAxis,1)
103};
104
105
106//______________________________________________________________________________
107class AcqLight : public TObject {
108
109
110 public:
111
112 AcqLight();
113 virtual ~AcqLight() {}
114
115 int BoardId; // NI7344 Board number (0)
116 int TurnOffLightTime; // Light must be turned off if system is idle for a given time (Not implemented)
117 int LightLevel; // Light level (0-32767)
118 bool IsON;
119// TTimer* T;
120// TThread* Thread;
121
122 bool Initialize();
123 void ResetTimer(); //Not implemented yet
124 void ON();
125 void OFF();
126 int ReadTemperature();
127 int ReadLightLevel();
128
129 ClassDef(AcqLight,1)
130};
131
132
133//______________________________________________________________________________
134class AcqStage1 : public TObject {
135
136
137 public:
138 int BoardId; //NI7344 Board number (0)
139 float ZHomingXPos, ZHomingYPos; //Positions on X and Y where Z homing can be made safely.
140 float EmTopLayer; // user measured Thickness of top emulsion layer (by focusing procedure)
141 float EmBotLayer; // user measured Thickness of bottom emulsion layer (by focusing procedure)
142 float EmBase; // user measured Thickness of emulsion base [mic]
143 float NominalEmLayer; // nominal Thickness of emulsion layer
144 float NominalEmBase; // nominal Thickness of emulsion base [mic]
145 AcqAxis* X; // Pointers to Axes and light controller
149
152
153
154 AcqStage1();
155 virtual ~AcqStage1() {X->Stop(); Y->Stop(); Z->Stop();}
156 bool Initialize();
157 void Stop();
158 int GetLastError(char * Description, int size);
159 int GetLastModalError(char * Description, int size);
160 void Monitor();
161 void ScanToZ0AndGotoXYZ(float Z0, float Z0speed, float Z0acc, float X, float Y, float XYSpeed, float XYAcc, float Z, float Zspeed, float Zacc, u32 Timeout);
162
163 ClassDef(AcqStage1,1)
164};
165
166R__EXTERN AcqStage1 *gStage;
167
168#endif /* ROOT_AcqStage1 */
R__EXTERN AcqStage1 * gStage
Definition: AcqStage1.h:166
unsigned long u32
Definition: MotnCnst.h:24
unsigned short u16
Definition: MotnCnst.h:23
Definition: AcqStage1.h:51
int FindHome(int Direction)
Definition: AcqStage1.cxx:631
int TurnOffLightTime
Definition: AcqStage1.h:69
void ArmBreakpointSequence()
Definition: AcqStage1.cxx:765
void LoadMoveCompleteCriteria(bool MotorOff, bool Stop, bool Delay, bool InPosition, float DeadBand, int sdelay, int minPulse)
Definition: AcqStage1.cxx:567
void DisarmBreakpointSequence()
Definition: AcqStage1.cxx:760
int CtlModeIsCWCCW
Definition: AcqStage1.h:68
AcqAxis()
Definition: AcqStage1.cxx:438
void Move(float Speed, float Acc)
Definition: AcqStage1.cxx:548
int GetLimiter()
Definition: AcqStage1.cxx:613
int LinesRev
Definition: AcqStage1.h:62
void LoadBreakpointSequence(float *Pos, int N)
Definition: AcqStage1.cxx:722
void Test(float *Pos, int N)
Definition: AcqStage1.cxx:801
void DisarmBreakpoint()
Definition: AcqStage1.cxx:705
bool IsMoveComplete()
Definition: AcqStage1.cxx:590
float MicronsToSteps
Definition: AcqStage1.h:64
int StepsRev
Definition: AcqStage1.h:61
float HomingSpeed
Definition: AcqStage1.h:71
void PosMove(float Pos, float Speed, float Acc)
Definition: AcqStage1.cxx:524
void Reset()
Definition: AcqStage1.cxx:508
int BoardId
Definition: AcqStage1.h:60
void ArmBreakpoint(float Pos)
Definition: AcqStage1.cxx:696
float Accel
Definition: AcqStage1.h:65
int HomePol
Definition: AcqStage1.h:67
bool Initialize()
Definition: AcqStage1.cxx:463
int ReadFollowingError()
Definition: AcqStage1.cxx:844
float Reference
Definition: AcqStage1.h:72
float NominalReference
Definition: AcqStage1.h:73
float EncoderToMicrons
Definition: AcqStage1.h:63
float MaxSpeed
Definition: AcqStage1.h:66
void DumpBreakpointSequence()
Definition: AcqStage1.cxx:788
int Invert
Definition: AcqStage1.h:70
float GetPos()
Definition: AcqStage1.cxx:599
void SetFilterFrequency(int Freq)
Definition: AcqStage1.cxx:838
virtual ~AcqAxis()
Definition: AcqStage1.h:57
bool IsBreakpointOccured()
Definition: AcqStage1.cxx:710
int LimPol
Definition: AcqStage1.h:67
int WaitForMoveComplete(u32 Timeout)
Definition: AcqStage1.cxx:514
int Axis
Definition: AcqStage1.h:59
int IsBreakpointSequenceArmed()
Definition: AcqStage1.cxx:778
void Stop()
Definition: AcqStage1.cxx:502
int WaitForHome(int Timeout)
Definition: AcqStage1.cxx:658
void SetFollowingError(u16 Error)
Definition: AcqStage1.cxx:854
Definition: AcqStage1.h:107
int ReadTemperature()
Definition: AcqStage1.cxx:917
AcqLight()
Definition: AcqStage1.cxx:860
bool Initialize()
Definition: AcqStage1.cxx:870
int BoardId
Definition: AcqStage1.h:115
int TurnOffLightTime
Definition: AcqStage1.h:116
int LightLevel
Definition: AcqStage1.h:117
int ReadLightLevel()
Definition: AcqStage1.cxx:926
bool IsON
Definition: AcqStage1.h:118
virtual ~AcqLight()
Definition: AcqStage1.h:113
void ResetTimer()
Definition: AcqStage1.cxx:910
void OFF()
Definition: AcqStage1.cxx:903
void ON()
Definition: AcqStage1.cxx:895
Definition: AcqStage1.h:134
float EmTopLayer
Definition: AcqStage1.h:140
float EmBase
Definition: AcqStage1.h:142
bool AbsCoords
Definition: AcqStage1.h:151
AcqStage1()
Definition: AcqStage1.cxx:106
int GetLastModalError(char *Description, int size)
Definition: AcqStage1.cxx:216
AcqLight * L
Definition: AcqStage1.h:148
void ScanToZ0AndGotoXYZ(float Z0, float Z0speed, float Z0acc, float X, float Y, float XYSpeed, float XYAcc, float Z, float Zspeed, float Zacc, u32 Timeout)
Definition: AcqStage1.cxx:231
bool Initialize()
Definition: AcqStage1.cxx:168
virtual ~AcqStage1()
Definition: AcqStage1.h:155
int BoardId
Definition: AcqStage1.h:138
void Stop()
Definition: AcqStage1.cxx:193
float NominalEmLayer
Definition: AcqStage1.h:143
void Monitor()
Definition: AcqStage1.cxx:311
float NominalEmBase
Definition: AcqStage1.h:144
float EmBotLayer
Definition: AcqStage1.h:141
EdbAffine2D * eAffine
Definition: AcqStage1.h:150
AcqAxis * Y
Definition: AcqStage1.h:146
float ZHomingXPos
Definition: AcqStage1.h:139
int GetLastError(char *Description, int size)
Definition: AcqStage1.cxx:202
float ZHomingYPos
Definition: AcqStage1.h:139
AcqAxis * Z
Definition: AcqStage1.h:147
AcqAxis * X
Definition: AcqStage1.h:145
Definition: EdbAffine.h:17
float Speed
Definition: hwinit.C:69
float Z0
Definition: hwinit.C:67