source: trunk/FACT++/src/dimctrl.cc@ 14379

Last change on this file since 14379 was 14214, checked in by tbretz, 12 years ago
Added the --msg command line option
File size: 3.3 KB
Line 
1#include "StateMachineDimControl.h"
2#include "RemoteControl.h"
3
4using namespace std;
5
6// ------------------------------------------------------------------------
7
8#include "Main.h"
9
10template<class T>
11int RunShell(Configuration &conf)
12{
13 StateMachineDimControl::fIsServer = conf.Get<bool>("server");
14 return Main::execute<T, StateMachineDimControl>(conf);
15}
16
17void SetupConfiguration(Configuration &conf)
18{
19 po::options_description control("Dim control options");
20 control.add_options()
21 ("server", po_bool(false), "Start dimctrl as a dim server")
22 // ("verbosity,v", var<uint32_t>()->implicit_value(0), "Set a new verbosity level (see MessageImp)")
23 // ("quiet,q", po_bool(false), "Suppress all output except comments (log-level>=90)")
24 ("debug", po_bool(false), "Print the labels for debugging purpose")
25 ("start", var<string>(), "Start a java script with the given name")
26 ("batch", var<string>(), "Start a batch script with the given name at the given label (script.dim[:N])")
27 ("stop", po_switch(), "Stop a currently running script")
28 ("msg", var<string>(), "Send a messageto the chat server.")
29 ("user,u", var<string>(""), "A user name - just for logging purposes (default is ${USER})")
30 ;
31
32 conf.AddEnv("user", "USER");
33
34 conf.AddOptions(control);
35}
36
37/*
38 Extract usage clause(s) [if any] for SYNOPSIS.
39 Translators: "Usage" and "or" here are patterns (regular expressions) which
40 are used to match the usage synopsis in program output. An example from cp
41 (GNU coreutils) which contains both strings:
42 Usage: cp [OPTION]... [-T] SOURCE DEST
43 or: cp [OPTION]... SOURCE... DIRECTORY
44 or: cp [OPTION]... -t DIRECTORY SOURCE...
45 */
46void PrintUsage()
47{
48 cout <<
49 "The feedback control the BIAS voltages based on the calibration signal.\n"
50 "\n"
51 "The default is that the program is started without user intercation. "
52 "All actions are supposed to arrive as DimCommands. Using the -c "
53 "option, a local shell can be initialized. With h or help a short "
54 "help message about the usuage can be brought to the screen.\n"
55 "\n"
56 "Usage: feedback [-c type] [OPTIONS]\n"
57 " or: feedback [OPTIONS]\n";
58 cout << endl;
59}
60
61void PrintHelp()
62{
63 Main::PrintHelp<StateMachineDimControl>();
64
65 /* Additional help text which is printed after the configuration
66 options goes here */
67
68 /*
69 cout << "bla bla bla" << endl << endl;
70 cout << endl;
71 cout << "Environment:" << endl;
72 cout << "environment" << endl;
73 cout << endl;
74 cout << "Examples:" << endl;
75 cout << "test exam" << endl;
76 cout << endl;
77 cout << "Files:" << endl;
78 cout << "files" << endl;
79 cout << endl;
80 */
81}
82
83int main(int argc, const char* argv[])
84{
85 Configuration conf(argv[0]);
86 conf.SetPrintUsage(PrintUsage);
87 Main::SetupConfiguration(conf);
88 SetupConfiguration(conf);
89
90 if (!conf.DoParse(argc, argv, PrintHelp))
91 return 127;
92
93 //return RunShell<LocalStream>(conf);
94
95 if (!conf.Has("console"))
96 return RunShell<RemoteStream>(conf);
97
98 if (conf.Get<int>("console")==0)
99 return RunShell<RemoteShell>(conf);
100 else
101 return RunShell<RemoteConsole>(conf);
102}
Note: See TracBrowser for help on using the repository browser.