2 #include "XYZControlGalil.h"
3 #include "GalilController.h"
4 #include "parameters/Devices.h"
5 #include "controllers/ScopeLogger.h"
8 #ifdef SCOPE_USE_GALIL_XYZSTAGE
12 XYZControlGalil::XYZControlGalil()
14 , xcountspermicron(1.0)
15 , ycountspermicron(1.0)
16 , zcountspermicron(1.0) {
19 XYZControlGalil::~XYZControlGalil() {
23 void XYZControlGalil::Initialize(parameters::XYZControlGalil& _params) {
24 xcountspermicron = _params.xcountspermicron();
25 ycountspermicron = _params.ycountspermicron();
26 zcountspermicron = _params.zcountspermicron();
29 gc = std::unique_ptr<GalilController>(
new GalilController(_params.comstring()));
31 ScopeLogger scope_logger;
32 std::wstringstream msg;
33 msg << L
"Connected XYControlGalil to Galil controller, library version " << gc->LibraryVersion() << L
"\n" , gc->Connection();
34 scope_logger.Log(msg.str(), log_info);
37 gc->Command(L
"WT100");
39 gc->Command(L
"WT500");
44 scope_logger.Log(L
"Initialized XYZControlGalil", log_info);
54 void XYZControlGalil::UpdatePositionValues() {
55 double p = gc->CommandValue(L
"PAX=?");
56 xyzpos[0]->Set(p/xcountspermicron);
57 p = gc->CommandValue(L
"PAY=?");
58 xyzpos[1]->Set(p/ycountspermicron);
59 p = gc->CommandValue(L
"PAZ=?");
60 xyzpos[2]->Set(p/zcountspermicron);
63 double XYZControlGalil::CurrentXPosition() {
66 pos = gc->CommandValue(L
"PAX=?");
67 pos /= xcountspermicron;
73 double XYZControlGalil::CurrentYPosition() {
76 pos = gc->CommandValue(L
"PAY=?");
77 pos /= ycountspermicron;
83 double XYZControlGalil::CurrentZPosition() {
86 pos = gc->CommandValue(L
"PAZ=?");
87 pos /= zcountspermicron;
93 void XYZControlGalil::SetZeroXAxis() {
95 gc->Command(L
"DPX=0");
96 UpdatePositionValues();
101 void XYZControlGalil::SetZeroYAxis() {
103 gc->Command(L
"DPY=0");
104 UpdatePositionValues();
109 void XYZControlGalil::SetZeroZAxis() {
111 gc->Command(L
"DPZ=0");
112 UpdatePositionValues();
117 void XYZControlGalil::MoveRelative(
const double& _xrel,
const double& _yrel,
const double& _zrel) {
119 if ( (abs(_xrel) > 2000) || (abs(_yrel) > 2000) || (abs(_zrel) > 2000) )
120 throw ScopeException(
"XYZControlGalil::MoveRelative travel range too large");
121 int32_t countsx = round2i32(static_cast<double>(xcountspermicron) * _xrel);
122 int32_t countsy = round2i32(static_cast<double>(ycountspermicron) * _yrel);
123 int32_t countsz = round2i32(static_cast<double>(zcountspermicron) * _zrel);
124 std::wstringstream cmd;
125 cmd << L
"PR " << countsx << L
"," << countsy << L
"," << countsz;
126 DBOUT(L
"XYZControlGalil::MoveRelative " << cmd.str());
127 gc->Command(cmd.str());
129 gc->Command(L
"MG TIME");
131 UpdatePositionValues();
134 void XYZControlGalil::MoveAbsolute(
const double& _xabs,
const double& _yabs,
const double& _zabs) {
136 if ( (abs(_xabs) > 20000) || (abs(_yabs) > 20000) || (abs(_zabs) > 20000) )
137 throw ScopeException(
"XYZControlGalil::MoveAbsolute travel range too large");
138 int32_t countsx = round2i32(static_cast<double>(xcountspermicron) * _xabs);
139 int32_t countsy = round2i32(static_cast<double>(ycountspermicron) * _yabs);
140 int32_t countsz = round2i32(static_cast<double>(zcountspermicron) * _zabs);
141 std::wstringstream cmd;
142 cmd << L
"PA " << countsx << L
"," << countsy << L
"," << countsz;
143 gc->Command(cmd.str());
147 gc->Command(L
"MG TIME");
149 UpdatePositionValues();
This is the include file for standard system include files, or project specific include files that ar...
#define DBOUT(s)
A debug output to the debug console.
void ScopeExceptionHandler(const std::string &_origin, const bool &_log, const bool &_showmessagebox, const bool &_trace, const bool &_rethrow)
Handles all exceptions and does nice logging.
virtual void Initialize(parameters::XYZControl &_params)
Initialize hardware.