source: fact/FADctrl/FADctrl.cc@ 11014

Last change on this file since 11014 was 10813, checked in by ogrimm, 14 years ago
Corrected dcm_ready and dcm_lock bit evaluation
File size: 1.6 KB
Line 
1//
2// FADctrl
3//
4
5#include <stdio.h>
6#include <readline/history.h>
7#include <string>
8
9#include "FAD.h"
10
11using namespace std;
12
13const string READLINE_HIST_FILE = string(getenv("HOME"))+"/.history_FADctrl";
14
15// ================
16// Main program
17// ================
18
19int main(int argc, char *argv[]) {
20
21 std::vector<std::string> List;
22
23 // Board list from command line?
24 for (int i=1; i<argc; i++) List.push_back(argv[i]);
25
26 // Uses getc() for readline library (allows interruption by signal) and load history buffer
27 rl_getc_function = getc;
28 read_history(READLINE_HIST_FILE.c_str());
29
30 system("clear");
31 printf("\n*** FADctrl (built %s, %s, revision %s) *** \n\n",__DATE__, __TIME__, REVISION);
32
33 // Construct main instance (static ensures destructor is called with exit())
34 static class FAD M(List);
35
36 // Do not kill process if writing to closed socket
37 signal(SIGPIPE, SIG_IGN);
38
39 // Command loop
40 char *Command;
41 std::string LastHist;
42
43 while (!M.ExitRequest) {
44 Command = readline("FADctrl> ");
45
46 // Check for interruption by signal
47 if (Command == NULL) continue;
48
49 // Add command to history
50 if(strlen(Command) > 0 && LastHist != Command) {
51 add_history(Command);
52 LastHist = Command;
53 }
54
55 // Process command (use SendCommandNB(), see mail from C. Gaspar 18/2/2011)
56 DimClient::sendCommandNB(SERVER_NAME"/Command", Command);
57 free(Command);
58 }
59
60 // Save history buffer
61 int Ret = write_history(READLINE_HIST_FILE.c_str());
62 if (Ret != 0 ) printf("Error writing history file to '%s' (%s)\n", READLINE_HIST_FILE.c_str(), strerror(Ret));
63}
Note: See TracBrowser for help on using the repository browser.