The VisAO Camera
VisAO::GimbalMotorCtrl Class Reference

The gimbal motor controller class. More...

#include <GimbalMotorCtrl.h>

+ Inheritance diagram for VisAO::GimbalMotorCtrl:

Public Member Functions

 GimbalMotorCtrl (std::string name, const std::string &conffile) throw (AOException)
 Standard constructor with a config file.
 
 GimbalMotorCtrl (int argc, char **argv) throw (AOException)
 Standard constructor with a command line.
 
void Create ()
 Initialization common to both constructors. More...
 
int setupNetwork ()
 Establish the serial-over-ip connection. More...
 
int checkConnStat ()
 Check connection status by querying the status of each controller. Changes curState. More...
 
int getCurState ()
 Get the current process state.
 
double get_x_pos ()
 Get the x position.
 
int getXMoving ()
 Get the moving status of the x axis.
 
double get_y_pos ()
 Get the y position.
 
int getYMoving ()
 Get the moving status of the y axis.
 
int getPowerStatus ()
 Get the status of the power outlet. More...
 
int center ()
 Read the preset center position for current board conditions, and gimbal to it.
 
int dark ()
 Gimbal to the dark position.
 
int savepreset ()
 Save the current position as the preset for this board setup.
 
virtual int sendCommand (std::string &com, std::string &resp, int timeout)
 Implementation of ESPMotorCtrl sendCommand.
 
virtual int sendCommand (std::string &com)
 Implementation of ESPMotorCtrl sendCommand.
 
virtual int Run ()
 The main loop. More...
 
virtual std::string remote_command (std::string com)
 Overridden from VisAOApp_base::remote_command, here just calls common_command.
 
virtual std::string local_command (std::string com)
 Overridden from VisAOApp_base::local_command, here just calls common_command.
 
virtual std::string script_command (std::string com)
 Overridden from VisAOApp_base::script_command, here just calls common_command.
 
std::string common_command (std::string com, int cmode)
 The common command processor for commands received by fifo.
 
std::string get_state_str ()
 Get the state string. More...
 
virtual void moveStart ()
 Called when a move starts, for data logging. Overriden from ESPMotorCtrl.
 
void moveStop ()
 Called when a move stops, for data logging.
 
virtual int update_statusboard ()
 Update the gimbal status board.
 
virtual void dataLogger (timeval tv)
 Write gimbal positions to the data log.
 
- Public Member Functions inherited from VisAO::ESPMotorCtrl
 ESPMotorCtrl ()
 Default constructor.
 
 ESPMotorCtrl (int no)
 Specify number of axes.
 
virtual ~ESPMotorCtrl ()
 Destructor.
 
std::string getErrString ()
 Get the error string.
 
int setNumAxes (int no)
 Sets the number of axes. Can only be called when uninitialized.
 
int powerOnInit ()
 Checks the controllers for current errors, and populates the stageName vector.
 
char getError (int axis)
 
std::string getStageName (int axis)
 
int getCtrlState (int axis, std::string &state)
 
double getCurPos (int axis)
 
int home (int axis)
 
int stop (int axis=0)
 
int gotoAbsPos (int axis, double apos)
 
int gotoRelPos (int axis, double rpos)
 
int makeCom (std::string &str, int axis, const char *com)
 
int makeCom (std::string &str, int axis, const char *com, int val)
 
int makeCom (std::string &str, int axis, const char *com, double val)
 
int makeCom (std::string &str, int axis, const char *com, std::string &val)
 
int splitResponse (int &axis, std::string &com, std::string &val, std::string &resp)
 
- Public Member Functions inherited from VisAO::VisAOApp_standalone
 VisAOApp_standalone () throw (AOException)
 Default constructor.
 
 VisAOApp_standalone (string name, int id, int logLevel=Logger::LOG_LEV_INFO) throw (AOException)
 Complicated constructor.
 
void set_conffile (std::string name) throw (AOException)
 
 VisAOApp_standalone (std::string name, const std::string &conffile) throw (AOException)
 Config file constructor.
 
void set_conffile (std::string name, const std::string &conffile) throw (AOException)
 For use if default constructed.
 
 VisAOApp_standalone (int argc, char **argv) throw (AOException)
 Command line constructor.
 
void usage ()
 
virtual std::string get_app_name ()
 Get the application name.
 
void log_msg (int LogLevel, std::string lmsg)
 Report an error. Also calls log_msg. Overloaded from VisAOApp_base. More...
 
virtual int Exec ()
 Installs the term and XXXX signal handlers, and calls Run(). More...
 
void signal_catcher ()
 Signal loop, normally won't need to be overridden. More...
 
virtual int start_signal_catcher (bool inherit_sched=true)
 Starts the signal catching loop. More...
 
virtual int install_sig_mainthread_catcher ()
 Install the SIG_MAINTHREAD signal catcher.
 
virtual int block_signal (int signum)
 Sets the signal mask to block signal signum.
 
virtual int block_sigio ()
 Sets the signal mask to block SIGIO and RTSIGIO.
 
virtual int kill_me ()
 Handle a timetodie condition upon exiting the signal catcher thread (e.g. tell main thread it is about to die) More...
 
- Public Member Functions inherited from VisAO::VisAOApp_base
 VisAOApp_base ()
 Default constructor.
 
virtual ~VisAOApp_base ()
 Virtual destructor.
 
int set_euid_called ()
 Changes the user id of the process to euid_called.
 
int set_euid_real ()
 Changes the user id fo the process to the real user id.
 
int set_RT_priority (int prio)
 Set the real-time priority of the current process. More...
 
int get_RT_priority ()
 Get the real-time priority of the current process.
 
int set_app_name (std::string an)
 Set the application name.
 
virtual int setup_baseApp (bool usethreads=false)
 Install fifo channels. More...
 
virtual int setup_baseApp (bool remfifo, bool locfifo, bool scrfifo, bool autfifo, bool usethreads=false)
 Create fifo names, then installs the fifo channels. More...
 
int setup_fifo_list (int nfifos)
 Allocate the fifo_list. More...
 
int connect_fifo_list ()
 Connect the fifo_list with exclusive locking. More...
 
int connect_fifo_list_nolock ()
 Connect the fifo_list without exclusive locking. More...
 
int setup_sigio ()
 Setup the SIGIO signal handling. More...
 
int setup_RTsigio ()
 Setup SIGIO signal handling using realtime signals. More...
 
int check_fifo_list_RTpending ()
 Check for pending reads for the fifo list while using the RT signals.
 
int write_fifo_channel (int ch, const char *com, int comlen, std::string *resp)
 Write data to a fifo_channel, and get a response if desired. More...
 
int write_fifo_channel (int ch, const char *com, int comlen, std::string *resp, char *sm)
 Write data to a fifo_channel, with a sequence message attached, and get a response if desired. More...
 
int get_fifo_channel_response (std::string *resp, int ch)
 Check, and wait if neccessary, for data on a fifo channel. More...
 
int set_wait_to (double to)
 Set the wait timeout for fifo channel responses. More...
 
double get_wait_to ()
 Get the wait timeout for fifo channel responses. More...
 
virtual int request_control (int cmode)
 Calls request_control(cmode, 0).
 
virtual int request_control (int cmode, bool override)
 Attempts to change the control type. More...
 
virtual std::string __remote_command (std::string com, char *seqmsg)
 Processing for remote commands. More...
 
virtual std::string remote_command (std::string com, char *seqmsg)
 
virtual std::string __local_command (std::string com, char *seqmsg)
 Processing for local commands. More...
 
virtual std::string local_command (std::string com, char *seqmsg)
 
virtual std::string __script_command (std::string com, char *seqmsg)
 Processing for script commands - not normally overriden. More...
 
virtual std::string script_command (std::string com, char *seqmsg)
 
virtual std::string auto_command (std::string com, char *seqmsg)
 Processing for auto commands - to be overriden. More...
 
virtual std::string post_auto_command (std::string com, char *seqmsg=0)
 Processing for auto commands - not normally overriden. More...
 
std::string control_mode_string ()
 Convenience function to return the control type string, e.g. "REMOTE".
 
std::string control_mode_response ()
 Convenience function to return the control type response string, e.g. "A\n".
 
virtual void error_report (int LogLevel, std::string emsg)
 Report an error. Also calls log_msg. More...
 
VisAO::profilerget_profile ()
 
int get_use_profiler ()
 
int start_profiler ()
 
void * get_statusboard_shmemptr ()
 Get the status board shared memory pointer. More...
 
int set_statusboard_shmemkey (key_t mkey)
 Set the status board shared memory key. Does nothing else. More...
 
key_t get_statusboard_shmemkey ()
 Get the status board shared memory key. More...
 

Protected Attributes

std::string ip_addr
 ip address of the serial converter
 
int ip_port
 ip port on which the motor controllers are connected
 
int curState
 The current controller state (READY, etc.)
 
int postHoming
 When 1, the gimbal will center after homing.
 
int x_addr
 The controller address of the x axis.
 
int y_addr
 The controller address of the y axis.
 
int xAxisNo
 The axis number of x, e.g. 0.
 
int yAxisNo
 The axis number of y, e.g. 1.
 
int power_outlet
 Configuration variable, setting which power outlet to monitor.
 
intpowerOutletState
 The power strip outlet controlling shutter power.
 
power_status_boardpsb
 This is for monitoring power outlet state.
 
double scale
 The conversion scale from encoder mm to arcsec on the CCD47, i.e. arcsec/mm.
 
double x_center
 The configurable location of the default x-center.
 
double x_dark
 The configurable location of the x dark location.
 
int xMoving
 Status of moving in the x direction.
 
double y_center
 The configurable location of the default x-center.
 
double y_dark
 The configurable location of the y dark location.
 
bool isMoving
 True if moving - set when move starts and updating data logger.
 
pthread_mutex_t comMutex
 Mutex for communicating with the controllers.
 
VisAO::filterwheel_status_boardfw2sb
 pointer to status board of F/W 2 (for presets)
 
VisAO::filterwheel_status_boardfw3sb
 pointer to status board of F/W 3 (for presets)
 
VisAO::wollaston_status_boardwsb
 pointer to status board of wollaston (for presets)
 
VisAO::aosystem_status_boardaosb
 pointer to status board of VisAOI (for presets)
 
- Protected Attributes inherited from VisAO::ESPMotorCtrl
std::stringstream errStr
 
int numAxes
 Number of motor controllers.
 
std::vector< intaxisAddress
 The controller address of each axis.
 
std::vector< std::string > stageName
 The names of the connected motors.
 
int default_timeout
 
- Protected Attributes inherited from VisAO::VisAOApp_standalone
std::string init_file
 
Config_File * init_vars
 
pthread_t main_thread
 Identifier for the main thread.
 
pthread_t signal_thread
 Identifier for the separate signal handling thread.
 
pthread_mutex_t signal_mutex
 Mutex for the condition signaling.
 
pthread_cond_t signal_cond
 Condition for telling main thread that something changed.
 
double signalth_sleeptime
 
- Protected Attributes inherited from VisAO::VisAOApp_base
std::string app_name
 The name of the application.
 
double pause_time
 Time to pause during application main loop.
 
fifo_list fl
 The list of named-pipe fifos used for inter-process comms.
 
std::string com_path
 The control fifo path base name.
 
std::string com_path_remote
 The path for the remote control fifos.
 
std::string com_path_local
 The path for the local control fifos.
 
std::string com_path_script
 The path for the script control fifos.
 
std::string com_path_auto
 The path for the auto control fifos.
 
double wait_to
 The timeout for waiting on responses from FIFOs in seconds.
 
std::ostringstream logss
 Conveninence string stream for building log messages.
 
VisAO::profilerprofile
 
std::string profile_path
 
int use_profiler
 
void * statusboard_shmemptr
 The pointer to the shared memory block for the statusboard.
 
key_t statusboard_shmemkey
 The key used to lookup the shared memory.
 
int statusboard_shmemid
 The ID of the shared memory block.
 
std::ofstream dataof
 
bool dataFileOpen
 
double dataFileOpenTime
 
double data_log_time_length
 
std::string data_save_path
 
std::string data_file_prefix
 

Additional Inherited Members

- Public Types inherited from VisAO::VisAOApp_base
enum  control_modes {
  CMODE_NONE, CMODE_REMOTE, CMODE_LOCAL, CMODE_SCRIPT,
  CMODE_AUTO, CMODE_max
}
 The control modes.
 
- Static Public Member Functions inherited from VisAO::VisAOApp_standalone
static const std::string & ConfigFile ()
 
static const std::string & MyName ()
 
static const std::string & MyFullName ()
 
static int ID ()
 
static Config_File & ConfigDictionary ()
 
static int Verbosity ()
 
static string getConffile (string identity)
 Return configuration file path based on identity.
 
- Public Attributes inherited from VisAO::VisAOApp_base
pthread_mutex_t my_mutex
 Mutex used by the threaded versions of the standard command handlers.
 
- Protected Member Functions inherited from VisAO::ESPMotorCtrl
void getStageName (int axis, std::string &sname)
 
- Protected Member Functions inherited from VisAO::VisAOApp_base
int create_statusboard (size_t sz)
 Creates and attaches to the statusboard shared memory. More...
 
std::string getDataFileName ()
 
int checkDataFileOpen ()
 
- Static Protected Member Functions inherited from VisAO::VisAOApp_standalone
static void SetMyName (const std::string &name)
 
static void SetConfigFile (const std::string &conffile) throw (Config_File_Exception)
 
static void SetID (int id)
 
- Static Protected Attributes inherited from VisAO::VisAOApp_standalone
static Logger * _logger = NULL
 
- Static Protected Attributes inherited from VisAO::VisAOApp_base
static int control_mode = VisAOApp_base::CMODE_NONE
 The current control mode. More...
 
static int default_control_mode = -1
 The default control mode. More...
 

Detailed Description

Manages the X and Y axis controllers of the Gimbal mirror. This is a standalone VisAOApp, so it doesn't depend on MsgD. In addition to the optional standard config options inherited from VisAOApp_standalone this class REQUIRES:

  • x_addr int - the address of the x axis controller
  • y_addr int - the address of teh y axis controller
  • power_outlet int - the number of the power strip outlet the controllers are plugged in to.
  • scale double (arcsec/mm) - the conversion from encoder mm to arcsec on the CCD47
  • x_center double (arcsec) - the scaled encoder position of the x center of travel
  • y_center double (arcsec) - the scaled encoder position of the y senter of travel

See VisAOApp_standalone for command line arguments. There are no additional command line arguments for GimbalCtrl.

This app exposes the remote, local, and script command fifos. The following commands are recognized on all channels:

  • "state?" returns a state string "A,B,C,D,E,F,E\n" where the letters have the following meaning
    • A = a one character representation of control mode, N, R, L, or S.
    • B = the connection status with the controllers (STATE_READY, etc.)
    • C = the power state of the controllers, derived from the power outlet status.
      • 0 = off
      • 1 = on
      • -1 = unknown
    • D = x moving state.
      • 0 = not moving
      • 1 = moving
    • E = x position (arcsec)
    • F = y moving state.
      • 0 = not moving
      • 1 = moving
    • G = y position (arcsec)
    • E = scale (arcsec/mm)
  • "xpos?" returns the x position in mm
  • "xmoving?" returns the x moving state
    • 0 = not moving
    • 1 = moving
  • "ypos?" returns the y position in mm
  • "ymoving?" returns the y moving state
    • 0 = not moving
    • 1 = moving
  • "stop" stops motion on all axes
  • "stopx" stops motion on the x axis
  • "stopy" stops motion on the axis
  • "center" - center both axes
  • "savepreset" - save current position as preset
  • "xrel x" moves x by a relative amount x, in mm.
  • "xabs x" moves x to the absolute position x, in mm
  • "yrel x" moves y by a relative amount x, in mm.
  • "yabs x" moves y to the absolute position x, in mm

Definition at line 80 of file GimbalMotorCtrl.h.

Member Function Documentation

int VisAO::GimbalMotorCtrl::setupNetwork ( )

Closes any existing connection, and then attempts to establish the link.

Definition at line 209 of file GimbalMotorCtrl.cpp.

References comMutex, curState, getPowerStatus(), ip_addr, ip_port, and VisAO::VisAOApp_base::logss.

Referenced by Run().

int VisAO::GimbalMotorCtrl::checkConnStat ( )
Return values
0on success
-1on error (other than not being connected).

Definition at line 248 of file GimbalMotorCtrl.cpp.

References curState, getPowerStatus(), isMoving, VisAO::VisAOApp_base::logss, moveStop(), postHoming, xAxisNo, and yAxisNo.

Referenced by Run().

int VisAO::GimbalMotorCtrl::getPowerStatus ( )
Return values
1if on
0if off
-1if no status available

Definition at line 422 of file GimbalMotorCtrl.cpp.

References attach_shm(), get_curr_time(), power_outlet, powerOutletState, psb, and ts_to_curr_time().

Referenced by checkConnStat(), get_state_str(), setupNetwork(), and update_statusboard().

std::string VisAO::GimbalMotorCtrl::get_state_str ( )

The state string encodes the current state of the controller as:

Definition at line 940 of file GimbalMotorCtrl.cpp.

References VisAO::VisAOApp_base::control_mode_response(), curState, get_x_pos(), get_y_pos(), getPowerStatus(), getXMoving(), getYMoving(), and scale.

Referenced by common_command().


The documentation for this class was generated from the following files: