The VisAO Camera
VisAO_main.h
Go to the documentation of this file.
1 /************************************************************
2 * VisAO_main.h
3 *
4 * Author: Jared R. Males (jrmales@email.arizona.edu)
5 *
6 * The main program for a VisAO application.
7 *
8 * Developed as part of the Magellan Adaptive Optics system.
9 ************************************************************/
10 
11 /** \file VisAO_main.h
12  * \author Jared R. Males
13  * \brief The main program for a VisAO application.
14  *
15  * Define VISAO_APP_TYPE and VISAO_APP_CONFFILE before including this in your main program.
16  * Then just call return VisAO_main(argc, argv) as the only line in main()
17  * e.g:
18  * #define VISAO_APP_TYPE VisAO::FocusMotorCtrl
19  * #define VISAO_APP_CONFFILE "conf/FocusMotorCtrl.conf"
20  * #include "VisAO_main.h"
21  * int main(int argc, char **argv)
22  * {
23  * return VisAO_main(argc, argv);
24  * }
25  *
26 */
27 
28 
29 //Globals
31 int debug;
32 //std::string global_app_name;
33 
35 
36 int VisAO_main( int argc, char **argv)
37 {
38  TimeToDie = 0;
39 
40  #ifdef _debug
41  debug = 1;
42  #else
43  debug = 0;
44  #endif
45 
46  try
47  {
48 
49  VISAO_APP_TYPE *c;
50 
51  if (argc>1)
52  {
53  c = new VISAO_APP_TYPE( argc, argv);
54  }
55  else
56  {
57  #ifdef VISAO_APP_CONFFILE
58  //Just for backwards compat.
59  c = new VISAO_APP_TYPE(VISAO_APP_NAME, VISAO_APP_CONFFILE);
60  #else
61  std::string conffile = Utils::getConffile(VISAO_APP_NAME);
62  c = new VISAO_APP_TYPE(VISAO_APP_NAME, conffile);
63  #endif
64  }
65 
66  std::cout << "Execing\n";
67  c->Exec();
68 
69  delete c;
70 
71  return 0;
72  }
73  catch (AOException &e)
74  {
75  std::cout << "Exception: " << e.what() << std::endl;
76 
77  Logger::get()->log( Logger::LOG_LEV_FATAL, "%s:%d: %s", __FILE__, __LINE__, e.what().c_str());
78  return -1;
79  }
80 }
81 
82 
int TimeToDie
Global set by SIGTERM.
Definition: VisAO_main.h:30
A structure to hold a list of fifo_channels.
Definition: fifoutils.h:204
fifo_list * global_fifo_list
The global fifo_list, for signal handling.
Definition: VisAO_main.h:34