source: fact/FADctrl/FADctrl.cc @ 10813

Last change on this file since 10813 was 10813, checked in by ogrimm, 9 years ago
Corrected dcm_ready and dcm_lock bit evaluation
File size: 1.6 KB
RevLine 
[10036]1//
2//  FADctrl
3//
4
5#include <stdio.h>
6#include <readline/history.h>
[10101]7#include <string>
[10036]8
9#include "FAD.h"
10
[10101]11using namespace std;
[10036]12
[10101]13const string READLINE_HIST_FILE = string(getenv("HOME"))+"/.history_FADctrl";
[10036]14
15// ================
16//   Main program
17// ================
18
[10186]19int main(int argc, char *argv[]) {
[10036]20
[10186]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 
[10120]26  // Uses getc() for readline library (allows interruption by signal) and load history buffer
[10036]27  rl_getc_function = getc;
[10101]28  read_history(READLINE_HIST_FILE.c_str());
[10036]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())
[10186]34  static class FAD M(List);
[10036]35
36  // Do not kill process if writing to closed socket
[10128]37  signal(SIGPIPE, SIG_IGN);
[10036]38
39  // Command loop
40  char *Command;
41  std::string LastHist;
42
43  while (!M.ExitRequest) {
[10813]44    Command = readline("FADctrl> ");
45       
[10036]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
[10164]55    // Process command (use SendCommandNB(), see mail from C. Gaspar 18/2/2011)
56        DimClient::sendCommandNB(SERVER_NAME"/Command", Command);
[10036]57    free(Command);
58  }
59 
60  // Save history buffer 
[10101]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));
[10036]63}
Note: See TracBrowser for help on using the repository browser.