The VisAO Camera
ESPMotorCtrl.h
Go to the documentation of this file.
1 /************************************************************
2  * ESPMotorCtrl.h
3  *
4  * Author: Jared R. Males (jrmales@email.arizona.edu)
5  *
6  * Declarations for a Newport ESP motor controller.
7  *
8  * Developed as part of the Magellan Adaptive Optics system.
9  ************************************************************/
10 
11 /** \file ESPMotorCtrl.h
12  * \author Jared R. Males
13  * \brief Declarations for a Newport ESP motor controller.
14  *
15  */
16 
17 #ifndef __ESPMotorCtrl_h__
18 #define __ESPMotorCtrl_h__
19 
20 #include <string>
21 #include <sstream>
22 #include <vector>
23 #include <iostream>
24 #include <cstdlib>
25 #include <cstdio>
26 #include <cmath>
27 
28 ///The namespace of VisAO software
29 namespace VisAO
30 {
31 
32 #define MOVE_RESOLUTION 0.00005
33 
34 /// The ESP motor controller class.
35 /** Manges a set of ESP motor controllers chained together.
36  */
38 {
39 public:
40  /// Default constructor.
41  ESPMotorCtrl();
42 
43  /// Specify number of axes.
44  ESPMotorCtrl(int no);
45 
46  /// Destructor
47  virtual ~ESPMotorCtrl();
48 
49 protected:
50 
51  std::stringstream errStr;
52 
53  int numAxes; ///< Number of motor controllers
54 
55  std::vector<int> axisAddress; ///< The controller address of each axis
56 
57  std::vector<std::string> stageName; ///< The names of the connected motors
58 
59  void getStageName(int axis, std::string &sname);
60 
61  int default_timeout;
62 
63 public:
64  ///Get the error string
65  std::string getErrString(){return errStr.str();}
66 
67  int setNumAxes(int no); ///<Sets the number of axes. Can only be called when uninitialized
68 
69  int powerOnInit(); ///< Checks the controllers for current errors, and populates the stageName vector
70 
71  char getError(int axis);
72 
73  std::string getStageName(int axis);
74 
75  int getCtrlState(int axis, std::string &state);
76 
77  double getCurPos(int axis);
78 
79  int home(int axis);
80 
81  int stop(int axis = 0);
82 
83  int gotoAbsPos(int axis, double apos);
84 
85  int gotoRelPos(int axis, double rpos);
86 
87 
88  int makeCom(std::string &str, int axis, const char *com);
89  int makeCom(std::string &str, int axis, const char *com, int val);
90  int makeCom(std::string &str, int axis, const char *com, double val);
91  int makeCom(std::string &str, int axis, const char *com, std::string &val);
92 
93  int splitResponse(int &axis, std::string &com, std::string &val, std::string &resp);
94 
95  virtual int sendCommand(std::string &com, std::string &resp, int timeout=1000);
96 
97  virtual int sendCommand(std::string &com);
98 
99  ///Called before starting a move. Empty here, to be overridden.
100  virtual void moveStart();
101 
102 };
103 
104 } //namespace VisAO
105 
106 #endif //__ESPMotorCtrl_h__
int numAxes
Number of motor controllers.
Definition: ESPMotorCtrl.h:53
The ESP motor controller class.
Definition: ESPMotorCtrl.h:37
std::vector< int > axisAddress
The controller address of each axis.
Definition: ESPMotorCtrl.h:55
int powerOnInit()
Checks the controllers for current errors, and populates the stageName vector.
ESPMotorCtrl()
Default constructor.
Definition: ESPMotorCtrl.cpp:9
virtual void moveStart()
Called before starting a move. Empty here, to be overridden.
std::vector< std::string > stageName
The names of the connected motors.
Definition: ESPMotorCtrl.h:57
The namespace of VisAO software.
int setNumAxes(int no)
Sets the number of axes. Can only be called when uninitialized.
std::string getErrString()
Get the error string.
Definition: ESPMotorCtrl.h:65
virtual ~ESPMotorCtrl()
Destructor.