A class to provide Filter Wheel functionality for the VisAO Camera. More...
#include <FilterWheelLocal.h>
Public Member Functions | |
FilterWheelLocal (std::string name, const std::string &conffile) throw (AOException) | |
Standard adopt style config file constructor. | |
FilterWheelLocal (int argc, char **argv) throw (AOException) | |
Standard adopt style command line constructor. | |
void | signal_catcher () |
Signal loop, normally won't need to be overridden. 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... | |
int | ChangePos (double pos) |
An interface to SimpleMotorCtrl::PosReqChanged for the fifo command processors. More... | |
double | getAbortPos () |
Exposes the abort Position (_abortPos) for use in PosReqChanged (which is static) | |
virtual std::string | remote_command (std::string com) |
VisAO remote command fifo handler. More... | |
virtual std::string | local_command (std::string com) |
VisAO local command fifo handler. | |
virtual std::string | script_command (std::string com) |
VisAO script command fifo handler. | |
std::string | common_command (std::string com, int) |
Where the command logic actually happens, since it is common. | |
std::string | get_state_str () |
Produce the state string for response to state? | |
virtual int | update_statusboard () |
Update the status board. 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 std::string | get_app_name () |
Get 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 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... | |
virtual void | log_msg (int LogLevel, std::string lmsg) |
Log a message. More... | |
VisAO::profiler * | get_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... | |
virtual void | dataLogger (timeval tv) |
Log data at intervals. | |
Static Public Member Functions | |
static int | CModeCurChanged (void *pt, Variable *msgb) |
RTDB handler for a control mode change request from the AO Supervisor. | |
static int | PosCurChanged (void *pt, Variable *msgb) |
RTDB handler for a position change by the AO Supervisor. More... | |
static int | PosReqChanged (void *pt, Variable *msgb) |
static int | StatusChanged (void *pt, Variable *msgb) |
Protected Member Functions | |
void | setupVisAOApp () |
Basic setup of the class, called by both constructors. More... | |
void | readFilterConfig () |
Read the corresponding filter wheel controller configuration file. | |
void | SetupVars () |
Virtual function to setup variables in RTDB. | |
std::string | GetPosName (double pos) |
Get the position name from wheel position. | |
int | GetType (double pos) |
Get the position type from the wheel position. | |
void | Run () |
The main loop. | |
int | DoFSM () |
Local FSM. | |
virtual void | updatePos (double pos) |
Update position variables in RTDB. | |
virtual void | updateReq (double pos) |
Update req position variables in RTDB. | |
void | set_control_mode (int cmode) |
void | set_status (int stat) |
virtual int | start_signal_catcher (bool inherit_sched=true) |
Starts the signal catching loop. More... | |
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 () |
Protected Attributes | |
RTDBvar | var_status |
The current status of the controller, STATE_CONNECTED, STATE_OPERATING,STATE_HOMING, etc. | |
RTDBvar | var_cmode_cur |
The current control mode in the RTDB. | |
RTDBvar | var_cmode_req |
The requested control mode in the RTDB. | |
RTDBvar | var_pos_cur |
The current position. | |
RTDBvar | var_pos_req |
The requested position. | |
RTDBvar | var_pos_local_req |
Position requester for local control. | |
RTDBvar | var_pos_script_req |
Position requester for script control. | |
double | _abortPos |
double | _homingPos |
float | _startingPos |
map< string, float > | _customPos |
int | cur_state |
double | cur_pos |
double | req_pos |
std::string | aoapp_name |
map< std::string, float >::iterator | cpos_it |
An iterator for accessing the custom pos list. | |
multimap< int, float > | _customTypes |
Custom filter types list. | |
multimap< int, float >::iterator | ctype_it |
An iterator for accessing the custom pos list. | |
pthread_t | signal_thread |
The thread where fifo async signals are caught. | |
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::profiler * | profile |
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. | |
Public Attributes inherited from VisAO::VisAOApp_base | |
pthread_mutex_t | my_mutex |
Mutex used by the threaded versions of the standard command handlers. | |
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... | |
Exposes Local and Script fifos, and passes commands on the the F/W controllers on the supervisor via the MsgD.
Definition at line 36 of file FilterWheelLocal.h.
|
protected |
Reads the com_path parameter from config, and sets up the fifo_list to have local and script command fifos. Also established the COMMODE RTDB varialbe and its notifier.
Definition at line 35 of file FilterWheelLocal.cpp.
References VisAO::VisAOApp_base::com_path, VisAO::VisAOApp_base::create_statusboard(), VisAO::VisAOApp_base::pause_time, readFilterConfig(), VisAO::VisAOApp_base::set_app_name(), VisAO::VisAOApp_base::setup_baseApp(), VisAO::VisAOApp_base::setup_fifo_list(), VisAO::VisAOApp_base::statusboard_shmemkey, and VisAO::VisAOApp_base::statusboard_shmemptr.
void VisAO::FilterWheelLocal::signal_catcher | ( | ) |
This does need to be started by the Run() function if it is desired. Before starting, must have setup and connected the fifo list. Can be started with start_signal_catcher(). The main loop should then block SIGIO and RTSIGIO.
Definition at line 407 of file FilterWheelLocal.cpp.
References VisAO::VisAOApp_base::check_fifo_list_RTpending(), VisAO::VisAOApp_base::connect_fifo_list(), VisAO::VisAOApp_base::error_report(), VisAO::VisAOApp_base::fl, get_curr_time(), global_fifo_list, VisAO::VisAOApp_base::log_msg(), VisAO::VisAOApp_base::logss, VisAO::VisAOApp_base::pause_time, VisAO::VisAOApp_base::setup_RTsigio(), TimeToDie, and update_statusboard().
|
protectedvirtual |
inherit_sched | if true (default) then the signal_catcher is started with the same RT priority as the main loop. |
Definition at line 463 of file FilterWheelLocal.cpp.
References signal_thread.
Referenced by Run().
cmode | The requested control mode |
override | If not true, forces the change no matter what current mode is. |
control_mode | if successful. |
-1 | if unsuccessful. |
Reimplemented from VisAO::VisAOApp_base.
Definition at line 497 of file FilterWheelLocal.cpp.
References var_cmode_req.
|
static |
After checking if control_mode == CMODE_REMOTE, just calls SimpleMotorCtrl::PosReqChanged.
Definition at line 527 of file FilterWheelLocal.cpp.
References updatePos().
Referenced by SetupVars().
int VisAO::FilterWheelLocal::ChangePos | ( | double | pos | ) |
We don't actually reimplement any motor control logic.
Definition at line 564 of file FilterWheelLocal.cpp.
References VisAO::VisAOApp_base::control_mode, getAbortPos(), updateReq(), var_pos_local_req, and var_pos_script_req.
Referenced by common_command().
|
virtual |
Though no fifo is created, this is used to process the RTDB control mode changes.
Reimplemented from VisAO::VisAOApp_base.
Definition at line 605 of file FilterWheelLocal.cpp.
References common_command().
|
virtual |
Calls this as VisAOApp_base::update_statusboard so the basics are taken care of.
0 | on success |
-1 | on failure |
Reimplemented from VisAO::VisAOApp_base.
Definition at line 789 of file FilterWheelLocal.cpp.
References GetPosName(), GetType(), VisAO::VisAOApp_base::statusboard_shmemptr, VisAO::VisAOApp_base::update_statusboard(), and var_pos_cur.
Referenced by signal_catcher().