17 #ifndef __VisAOApp_base_h__
18 #define __VisAOApp_base_h__
35 extern std::string global_app_name;
113 virtual int setup_baseApp(
bool remfifo,
bool locfifo,
bool scrfifo,
bool autfifo,
bool usethreads =
false);
196 int write_fifo_channel(
int ch,
const char *com,
int comlen, std::string * resp,
char *sm);
233 enum control_modes{CMODE_NONE, CMODE_REMOTE, CMODE_LOCAL, CMODE_SCRIPT, CMODE_AUTO, CMODE_max};
261 virtual std::string
remote_command(std::string com,
char *seqmsg);
279 virtual std::string
local_command(std::string com,
char *seqmsg);
297 virtual std::string
script_command(std::string com,
char *seqmsg);
305 virtual std::string
auto_command(std::string com,
char *seqmsg);
334 virtual void error_report(
int LogLevel, std::string emsg);
340 virtual void log_msg(
int LogLevel, std::string lmsg);
349 std::string profile_path;
354 int get_use_profiler(){
return use_profiler;}
355 int start_profiler();
404 std::ofstream dataof;
407 double dataFileOpenTime;
409 double data_log_time_length;
410 std::string data_save_path;
411 std::string data_file_prefix;
413 std::string getDataFileName();
415 int checkDataFileOpen();
473 int getnextline(std::string *comln, std::string * com);
479 void * __start_profiler(
void * ptr);
482 #endif //__VisAOApp_base_h__
virtual ~VisAOApp_base()
Virtual destructor.
int get_RT_priority()
Get the real-time priority of the current process.
std::string control_mode_string()
Convenience function to return the control type string, e.g. "REMOTE".
void * __com_remote_thread_handler(void *ptr)
The start function for remote handling with a thread.
int statusboard_shmemid
The ID of the shared memory block.
int com_local_handler(fifo_channel *fc)
fifo_channel handler for local commands
int com_remote_thread_handler(fifo_channel *fc)
Thread version of the fifo_channel handler for remote commands.
int com_auto_thread_handler(fifo_channel *fc)
Thread version of the fifo_channel handler for auto commands.
control_modes
The control modes.
static int default_control_mode
The default control mode.
double wait_to
The timeout for waiting on responses from FIFOs in seconds.
void * __com_auto_thread_handler(void *ptr)
The start function for auto handling with a thread.
int TimeToDie
Global set by SIGTERM.
int setup_sigio()
Setup the SIGIO signal handling.
pthread_mutex_t my_mutex
Mutex used by the threaded versions of the standard command handlers.
std::ostringstream logss
Conveninence string stream for building log messages.
void * statusboard_shmemptr
The pointer to the shared memory block for the statusboard.
virtual void error_report(int LogLevel, std::string emsg)
Report an error. Also calls log_msg.
virtual std::string __local_command(std::string com, char *seqmsg)
Processing for local commands.
int RT_priority
The real-time scheduling priority. Default is 0.
int set_RT_priority(int prio)
Set the real-time priority of the current process.
A structure to hold a list of fifo_channels.
std::string com_path
The control fifo path base name.
virtual int update_statusboard()
Update the status board.
virtual int setup_baseApp(bool usethreads=false)
Install fifo channels.
int check_fifo_list_RTpending()
Check for pending reads for the fifo list while using the RT signals.
uid_t euid_real
The real user id of the proces.
std::string com_path_local
The path for the local control fifos.
std::string app_name
The name of the application.
int setup_fifo_list(int nfifos)
Allocate the fifo_list.
VisAOApp_base()
Default constructor.
key_t get_statusboard_shmemkey()
Get the status board shared memory key.
Declarations for the VisAO status information structures.
uid_t euid_called
The user id of the process as called (that is when the constructor gets called).
std::string com_path_remote
The path for the remote control fifos.
std::string com_path_script
The path for the script control fifos.
virtual std::string __script_command(std::string com, char *seqmsg)
Processing for script commands - not normally overriden.
VisAO software utilitites, declarations.
key_t statusboard_shmemkey
The key used to lookup the shared memory.
virtual std::string auto_command(std::string com, char *seqmsg)
Processing for auto commands - to be overriden.
int getnextline(std::string *comln, std::string *com)
Utility function for parsing command buffers line by line.
std::string control_mode_response()
Convenience function to return the control type response string, e.g. "A\n".
int com_script_handler(fifo_channel *fc)
fifo_channel handler for script commands
fifo_list fl
The list of named-pipe fifos used for inter-process comms.
std::string com_path_auto
The path for the auto control fifos.
The base class for VisAO applications.
int get_fifo_channel_response(std::string *resp, int ch)
Check, and wait if neccessary, for data on a fifo channel.
double pause_time
Time to pause during application main loop.
virtual std::string remote_command(std::string com)
Called by __remote_command after control state logic.
virtual int request_control(int cmode)
Calls request_control(cmode, 0).
int com_script_thread_handler(fifo_channel *fc)
Thread version of the fifo_channel handler for script commands.
int com_local_thread_handler(fifo_channel *fc)
Thread version of the fifo_channel handler for local commands.
int set_app_name(std::string an)
Set the application name.
uid_t suid
The save-set user id of the process.
virtual void dataLogger(timeval tv)
Log data at intervals.
int set_statusboard_shmemkey(key_t mkey)
Set the status board shared memory key. Does nothing else.
virtual std::string __remote_command(std::string com, char *seqmsg)
Processing for remote commands.
virtual std::string script_command(std::string com)
Called by __script_command after control state logic.
void * __com_script_thread_handler(void *ptr)
The start function for script handling with a thread.
int set_wait_to(double to)
Set the wait timeout for fifo channel responses.
int create_statusboard(size_t sz)
Creates and attaches to the statusboard shared memory.
virtual std::string get_app_name()
Get the application name.
double get_wait_to()
Get the wait timeout for fifo channel responses.
int set_euid_called()
Changes the user id of the process to euid_called.
int connect_fifo_list()
Connect the fifo_list with exclusive locking.
static int control_mode
The current control mode.
int setup_RTsigio()
Setup SIGIO signal handling using realtime signals.
virtual std::string local_command(std::string com)
Called by __local_command after control state logic.
int com_auto_handler(fifo_channel *fc)
fifo_channel handler for auto commands
int connect_fifo_list_nolock()
Connect the fifo_list without exclusive locking.
void * __com_local_thread_handler(void *ptr)
The start function for local handling with a thread.
The namespace of VisAO software.
virtual std::string post_auto_command(std::string com, char *seqmsg=0)
Processing for auto commands - not normally overriden.
void * get_statusboard_shmemptr()
Get the status board shared memory pointer.
virtual void log_msg(int LogLevel, std::string lmsg)
Log a message.
int set_euid_real()
Changes the user id fo the process to the real user id.
int com_remote_handler(fifo_channel *fc)
fifo_channel handler for remote commands
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.