1 | #include "StateMachineDimControl.h"
|
---|
2 | #include "RemoteControl.h"
|
---|
3 |
|
---|
4 | using namespace std;
|
---|
5 |
|
---|
6 | // ------------------------------------------------------------------------
|
---|
7 |
|
---|
8 | #include "Main.h"
|
---|
9 |
|
---|
10 | template<class T>
|
---|
11 | int RunShell(Configuration &conf)
|
---|
12 | {
|
---|
13 | StateMachineDimControl::fIsServer = conf.Get<bool>("server");
|
---|
14 | return Main::execute<T, StateMachineDimControl>(conf);
|
---|
15 | }
|
---|
16 |
|
---|
17 | void 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 | ("user,u", var<string>(""), "A user name - just for logging purposes (default is ${USER})")
|
---|
29 | ;
|
---|
30 |
|
---|
31 | conf.AddEnv("user", "USER");
|
---|
32 |
|
---|
33 | conf.AddOptions(control);
|
---|
34 | }
|
---|
35 |
|
---|
36 | /*
|
---|
37 | Extract usage clause(s) [if any] for SYNOPSIS.
|
---|
38 | Translators: "Usage" and "or" here are patterns (regular expressions) which
|
---|
39 | are used to match the usage synopsis in program output. An example from cp
|
---|
40 | (GNU coreutils) which contains both strings:
|
---|
41 | Usage: cp [OPTION]... [-T] SOURCE DEST
|
---|
42 | or: cp [OPTION]... SOURCE... DIRECTORY
|
---|
43 | or: cp [OPTION]... -t DIRECTORY SOURCE...
|
---|
44 | */
|
---|
45 | void PrintUsage()
|
---|
46 | {
|
---|
47 | cout <<
|
---|
48 | "The feedback control the BIAS voltages based on the calibration signal.\n"
|
---|
49 | "\n"
|
---|
50 | "The default is that the program is started without user intercation. "
|
---|
51 | "All actions are supposed to arrive as DimCommands. Using the -c "
|
---|
52 | "option, a local shell can be initialized. With h or help a short "
|
---|
53 | "help message about the usuage can be brought to the screen.\n"
|
---|
54 | "\n"
|
---|
55 | "Usage: feedback [-c type] [OPTIONS]\n"
|
---|
56 | " or: feedback [OPTIONS]\n";
|
---|
57 | cout << endl;
|
---|
58 | }
|
---|
59 |
|
---|
60 | void PrintHelp()
|
---|
61 | {
|
---|
62 | Main::PrintHelp<StateMachineDimControl>();
|
---|
63 |
|
---|
64 | /* Additional help text which is printed after the configuration
|
---|
65 | options goes here */
|
---|
66 |
|
---|
67 | /*
|
---|
68 | cout << "bla bla bla" << endl << endl;
|
---|
69 | cout << endl;
|
---|
70 | cout << "Environment:" << endl;
|
---|
71 | cout << "environment" << endl;
|
---|
72 | cout << endl;
|
---|
73 | cout << "Examples:" << endl;
|
---|
74 | cout << "test exam" << endl;
|
---|
75 | cout << endl;
|
---|
76 | cout << "Files:" << endl;
|
---|
77 | cout << "files" << endl;
|
---|
78 | cout << endl;
|
---|
79 | */
|
---|
80 | }
|
---|
81 |
|
---|
82 | int main(int argc, const char* argv[])
|
---|
83 | {
|
---|
84 | Configuration conf(argv[0]);
|
---|
85 | conf.SetPrintUsage(PrintUsage);
|
---|
86 | Main::SetupConfiguration(conf);
|
---|
87 | SetupConfiguration(conf);
|
---|
88 |
|
---|
89 | if (!conf.DoParse(argc, argv, PrintHelp))
|
---|
90 | return 127;
|
---|
91 |
|
---|
92 | //return RunShell<LocalStream>(conf);
|
---|
93 |
|
---|
94 | if (!conf.Has("console"))
|
---|
95 | return RunShell<RemoteStream>(conf);
|
---|
96 |
|
---|
97 | if (conf.Get<int>("console")==0)
|
---|
98 | return RunShell<RemoteShell>(conf);
|
---|
99 | else
|
---|
100 | return RunShell<RemoteConsole>(conf);
|
---|
101 | }
|
---|