source: fact/FADctrl/FADctrl.cc@ 10174

Last change on this file since 10174 was 10164, checked in by ogrimm, 14 years ago
Moved board initalisation to thread, added 'reconnect' command
File size: 1.4 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() {
20
21 // Uses getc() for readline library (allows interruption by signal) and load history buffer
22 rl_getc_function = getc;
23 read_history(READLINE_HIST_FILE.c_str());
24
25 system("clear");
26 printf("\n*** FADctrl (built %s, %s, revision %s) *** \n\n",__DATE__, __TIME__, REVISION);
27
28 // Construct main instance (static ensures destructor is called with exit())
29 static class FAD M;
30
31 // Do not kill process if writing to closed socket
32 signal(SIGPIPE, SIG_IGN);
33
34 // Command loop
35 char *Command;
36 std::string LastHist;
37
38 while (!M.ExitRequest) {
39 Command = readline("\rFADctrl> ");
40
41 // Check for interruption by signal
42 if (Command == NULL) continue;
43
44 // Add command to history
45 if(strlen(Command) > 0 && LastHist != Command) {
46 add_history(Command);
47 LastHist = Command;
48 }
49
50 // Process command (use SendCommandNB(), see mail from C. Gaspar 18/2/2011)
51 DimClient::sendCommandNB(SERVER_NAME"/Command", Command);
52 free(Command);
53 }
54
55 // Save history buffer
56 int Ret = write_history(READLINE_HIST_FILE.c_str());
57 if (Ret != 0 ) printf("Error writing history file to '%s' (%s)\n", READLINE_HIST_FILE.c_str(), strerror(Ret));
58}
Note: See TracBrowser for help on using the repository browser.