The VisAO Camera
VisAO::CCD47Ctrl Class Reference

The controller for the VisAO CCD47 via its Little Joe. More...

#include <CCD47Ctrl.h>

+ Inheritance diagram for VisAO::CCD47Ctrl:

Public Member Functions

 CCD47Ctrl (std::string name, const std::string &conffile) throw (AOException)
 Name and config file constructor.
 
 CCD47Ctrl (int argc, char **argv) throw (AOException)
 Command line constructor.
 
std::string get_ccdNetAddr ()
 Return the network address of the CCD.
 
int get_ccdNetPort ()
 Returns the TCP/IP port of the CCD at its network address.
 
int __ReprogramJoe (int program_set, int program, int gain, int rep, int force=0)
 This function does the actual reprogramming, based on the adopt version.
 
int set_imtype (int it)
 Set the image type.
 
int Run ()
 Overriden virtual function, called by Exec().
 
virtual std::string remote_command (std::string com)
 Called by __remote_command after control state logic. More...
 
virtual std::string local_command (std::string com)
 Called by __local_command after control state logic. More...
 
virtual std::string script_command (std::string com)
 Called by __script_command after control state logic. More...
 
std::string common_command (std::string com, int cmode)
 Called by all the command handlers, to perform common command processing.
 
virtual int update_statusboard ()
 Update the CCD47 Status Board shared memory.
 
- 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...
 
virtual void dataLogger (timeval tv)
 Log data at intervals.
 

Protected Member Functions

void Create (void) throw (AOException)
 Common creation tasks, called by constructors.
 
void init_VisAOApp ()
 Initialize the details of the VisAOApp.
 
int LoadJoeDiskFiles (void)
 Load the configuration files specifying the different program sets that can be uploaded to LittleJoe.
 
littlejoe_programset ReadProgramSet (Config_File &cfg)
 Read a configuration file with the parameters of a little Joe Program SET.
 
littlejoe_program ReadProgram (Config_File &cfg)
 Read a configuration file with the parameters of a single LittleJoe program.
 
int Start (void)
 Start sequencing and start the framegrabber.
 
int Stop (void)
 Stop sequencing and stop the framegrabber.
 
int FirstJoeConfig (void)
 Sets the LittleJoe controller in a known state. More...
 
int ReadJoeStatus ()
 Check the LittleJoe CCD camera status. More...
 
int ReadJoeTemps (void)
 Read the LittleJoe CCD camera temperatures. More...
 
int GetFramegrabberStatus ()
 Checks whether the framegrabber process is running, and what its current status is.
 
int SetupNetwork (void)
 Setup network connection with LittleJoe. More...
 
int ReprogramJoe (int program_set, int program, int gain, int rep, int force=0)
 Reprogram the little joe, including file uploads as necessary. More...
 
int swonly_reprogram (int program_set, int program, int gain, int rep)
 Only change the settings in this software, do not reprogram the little joe. More...
 
int ComputeFramerate ()
 Computes the current framerate from the current state of LittleJoe control variables. More...
 
int ComputeRepsFrameRate (double fr)
 Computes the reps required to match a requested framerate.
 
int ComputeRepsExpTime (double et)
 Computes the reps required to match a requested exptime.
 
std::string getCompletePath (std::string filename)
 Get the complete path of a program/pattern file.
 
int DoFSM (void)
 Performs controller functions and manages states. More...
 
int load_EDT_config (std::string)
 Loads the EDT configuration file. 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

std::string adopt_cfg_file
 Name of the adopt config file (this is specified in the main config file)
 
Config_File * adopt_cfg
 The dictionary of config details from the adopt config file.
 
std::string _ccdName
 CCD name.
 
std::string _ccdNetAddr
 CCD network address.
 
int _ccdNetPort
 The TCP/IP port of the CCD at its network address.
 
int _ccdDx
 CCD x dimension.
 
int _ccdDy
 CCD y dimension.
 
unsigned int _ccdNumSpeeds
 Number of speeds.
 
int _maxNumSpeeds
 Maximum number of speeds.
 
int _maxNumBins
 Maximum number of bins.
 
int _ccdBlacksNum
 Number of blacks.
 
int _minRep
 Minimum repetitions.
 
int _maxRep
 Maximum repetitions.
 
std::string EDT_cfgdir
 EDT configuration files directory. More...
 
std::string FrameGrabberName
 Process name of the relevant framegrabber.
 
std::string FrameWriterName
 Process name of the relevant framewriter.
 
int _ccdDefaultXbin
 Default x binning.
 
int _ccdDefaultYbin
 Default y binning.
 
int _ccdDefaultSpeed
 Default speed.
 
int _ccdDefaultBlack
 Default black levels.
 
int cur_State
 Current state.
 
int FGrunning
 Whether or not the framegrabber is running.
 
int FGsaving
 Whether or not the framegrabber is saving, and how many to save. More...
 
int FGremaining
 How many saves are remaining.
 
int FGskipping
 Whether or not the framegrabber is skipping, and how many frames to skip.
 
std::string FWsubdir
 The current subdirectory of the framewriter.
 
int imtype
 Image type, 0=science (default), 1=acquisition, 2=dark, 3=sky.
 
basic_status_boardfw47sb
 The Framewriter47 status board is used to check if framewriter is running before saving.
 
int cur_ProgramSet
 The currently loaded program set.
 
int cur_Program
 The currently running program.
 
int cur_Gain
 The currently loaded gain.
 
int cur_Reps
 The currently loaded repetitions.
 
int cur_xbin
 Current x binning.
 
int cur_ybin
 Current y binning.
 
int cur_windowx
 Current x window size.
 
int cur_windowy
 Current y window size.
 
int cur_speed
 Current speed.
 
double cur_framerate
 Current frame rate.
 
double temps [3]
 Current temperatures.
 
int blackLevel [2]
 Current blacklevels.
 
std::vector< littlejoe_programsetondisk
 Struct array representing files that can be uploaded to LittleJoe.
 
int _startProgramSet
 
int _startProgram
 
int _startGain
 
int _startReps
 
pthread_t load_thread
 Identifier for the __ReprogramJoe thread.
 
pthread_mutex_t reprogMutex
 Mutex for the __ReprogramJoe thread. More...
 
int joe_loading
 Tells the main thread that the __ReprogramJoe thread is working. More...
 
Logger * _tempsLogger
 Temperature logger.
 
- 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.
 
- 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

Mostly based on the Arcetri JoeCtrl class. This is the VisAO specific CCD47 controller. Instead of trying to calculate the correct program (as the adopt version does) we expect this to be explicitly set by the user, along with gain and repititions. We'll eventually have to adapt this for arbitrary integrations.

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

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:

  • ccd47_name string - name of the ccd, usually ccd47, used to find the adopt config file, e.g. ccd47.conf
  • EDT_cfgdir string - directory where the EDT configuration files are stored.

The config file referenced by ccd47_name must have the following values in it:

  • ccdName string - Name of the ccd, in this case always ccd47, used for conf file lookup.
  • ccdNetAddr string - IP address, or host name, of the port server
  • ccdNetPort int - Port number of the ccd on the port server
  • ccdXdim int
  • ccdYdim int
  • ccdDefaultXbin int
  • ccdDefaultYbin int
  • ccdDefaultSpeed int
  • ccdDefaultBlack int
  • ccdBlacksNum int
  • minRep int
  • maxRep int
  • maxNumSpeeds int
  • maxNumBins int
  • startProgramSet int
  • startProgram int
  • startGain int
  • startReps int

Definition at line 128 of file CCD47Ctrl.h.

Member Function Documentation

int VisAO::CCD47Ctrl::FirstJoeConfig ( void  )
protected
Return values
NO_ERRORon success
Todo:
Make this do something usefule.

Definition at line 384 of file CCD47Ctrl.cpp.

References cur_Gain, cur_Program, cur_ProgramSet, and cur_Reps.

int VisAO::CCD47Ctrl::ReadJoeStatus ( )
protected

Gets the CCD status from the serial interface and checks the status of the frame grabber process.

Return values
NO_ERRORon success

Definition at line 794 of file CCD47Ctrl.cpp.

References blackLevel, cur_Program, cur_ProgramSet, cur_State, FGrunning, GetFramegrabberStatus(), load_EDT_config(), ondisk, Start(), and Stop().

Referenced by DoFSM().

int VisAO::CCD47Ctrl::ReadJoeTemps ( void  )
protected

Reads the CCD temperature from the serial interface and logs them to a file.

Return values
NO_ERRORon success

Definition at line 878 of file CCD47Ctrl.cpp.

References _tempsLogger, cur_State, and temps.

Referenced by DoFSM().

int VisAO::CCD47Ctrl::SetupNetwork ( void  )
protected

This function sets up the network connection with the LittleJoe CCD Camera. After the network is up, the communication is tested with the TestJoe() function.

Return values
0on success
<0otherwise (errordb.h code)

Definition at line 763 of file CCD47Ctrl.cpp.

References _ccdNetAddr, and _ccdNetPort.

Referenced by DoFSM().

int VisAO::CCD47Ctrl::ReprogramJoe ( int  program_set,
int  program,
int  gain,
int  rep,
int  force = 0 
)
protected

Actually launches a thread, which does the work using __ReprogramJoe which is necessary to prevent uploads from being interrupted by signals.

Definition at line 537 of file CCD47Ctrl.cpp.

References joe_loading, load_thread, reprogMutex, and VisAO::ReprogramJoeThreadWorker().

Referenced by common_command().

int VisAO::CCD47Ctrl::swonly_reprogram ( int  program_set,
int  program,
int  gain,
int  rep 
)
protected

This is useful if a software restart is necessary, but the Little Joe is still running.

Definition at line 718 of file CCD47Ctrl.cpp.

References ComputeFramerate(), cur_Gain, cur_Program, cur_ProgramSet, cur_Reps, cur_speed, cur_windowx, cur_windowy, cur_xbin, cur_ybin, and ondisk.

Referenced by common_command().

int VisAO::CCD47Ctrl::ComputeFramerate ( )
protected
Return values
NO_ERRORon success

Definition at line 446 of file CCD47Ctrl.cpp.

References cur_framerate, cur_Program, cur_ProgramSet, cur_Reps, cur_speed, cur_xbin, cur_ybin, and ondisk.

Referenced by __ReprogramJoe(), Create(), and swonly_reprogram().

int VisAO::CCD47Ctrl::DoFSM ( void  )
protected

Switches the controller from one state to another. States can be changed asynchronously from this thread or the listening thread, and this function will properly react to a new state. Some states include a sleep() function to slow down the thread when immediate action is not necessary

Definition at line 931 of file CCD47Ctrl.cpp.

References cur_State, ReadJoeStatus(), ReadJoeTemps(), SetupNetwork(), and VisAO::VisAOApp_base::write_fifo_channel().

Referenced by Run().

int VisAO::CCD47Ctrl::load_EDT_config ( std::string  fname)
protected
Parameters
fnameis the path to the config file
Return values
0on success

Definition at line 1101 of file CCD47Ctrl.cpp.

References EDT_cfgdir, and initcam().

Referenced by __ReprogramJoe(), and ReadJoeStatus().

std::string VisAO::CCD47Ctrl::remote_command ( std::string  com)
virtual

This should be overriden by derived classes.

Parameters
comis the command string to be processed.
Returns
the application response.

Reimplemented from VisAO::VisAOApp_base.

Definition at line 1128 of file CCD47Ctrl.cpp.

References common_command().

std::string VisAO::CCD47Ctrl::local_command ( std::string  com)
virtual

This should be overriden by derived classes.

Parameters
comis the command string to be processed.
Returns
the application response.

Reimplemented from VisAO::VisAOApp_base.

Definition at line 1133 of file CCD47Ctrl.cpp.

References common_command().

std::string VisAO::CCD47Ctrl::script_command ( std::string  com)
virtual

This should be overriden by derived classes.

Parameters
comis the command string to be processed.
Returns
the application response.

Reimplemented from VisAO::VisAOApp_base.

Definition at line 1138 of file CCD47Ctrl.cpp.

References common_command().

Member Data Documentation

std::string VisAO::CCD47Ctrl::EDT_cfgdir
protected

EDT configuration file directory

Definition at line 171 of file CCD47Ctrl.h.

Referenced by Create(), and load_EDT_config().

int VisAO::CCD47Ctrl::FGsaving
protected

If -1 then saving indefinately.

Definition at line 190 of file CCD47Ctrl.h.

Referenced by common_command(), Create(), GetFramegrabberStatus(), and update_statusboard().

pthread_mutex_t VisAO::CCD47Ctrl::reprogMutex
protected

Prevents multiple simultaneous reprograms.

Definition at line 291 of file CCD47Ctrl.h.

Referenced by __ReprogramJoe(), common_command(), init_VisAOApp(), and ReprogramJoe().

int VisAO::CCD47Ctrl::joe_loading
protected

is true until the main thread can try_join on load_thread.

Definition at line 296 of file CCD47Ctrl.h.

Referenced by ReprogramJoe(), and Run().


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