#include "nmlwatch.h"#include "rcs.hh"#include <stdio.h>#include <string.h>#include <stdlib.h>#include <signal.h>Include dependency graph for nmlwatch.cc:

Go to the source code of this file.
Functions | |
| int | main (int argc, char **argv) |
| void | stop_watching_nml (int sig) |
| int | format_stub (NMLTYPE type, void *buffer, CMS *cms) |
| int | nml_watch (char *config_file, char *buffer, double sample_period) |
Variables | |
| unsigned char | stop = 1 |
|
||||||||||||
|
Definition at line 18 of file nmlwatch.cc. 00019 {
00020 static char config_file_buf[256];
00021 static char buffer_name_buf[256];
00022 static char sample_period_buf[40];
00023 static char *config_file = NULL;
00024 static char *buffer_name = NULL;
00025 double sample_period = -1;
00026
00027 if (argc > 1)
00028 {
00029 config_file = argv[1];
00030 }
00031 if (argc > 2)
00032 {
00033 buffer_name = argv[2];
00034 }
00035 if (argc > 3)
00036 {
00037 sample_period = strtod (argv[3], NULL);
00038 }
00039
00040 if (NULL == config_file)
00041 {
00042 config_file = config_file_buf;
00043 printf ("Configuration File?\n");
00044 fgets (config_file_buf, 256, stdin);
00045 }
00046 if (NULL == buffer_name)
00047 {
00048 buffer_name = buffer_name_buf;
00049 printf ("Buffer Name?\n");
00050 fgets (buffer_name_buf, 256, stdin);
00051 }
00052 if (sample_period < 0)
00053 {
00054 printf ("Sample Period?\n");
00055 fgets (sample_period_buf, 256, stdin);
00056 sample_period = strtod (sample_period_buf, NULL);
00057 }
00058 nml_watch (config_file, buffer_name, sample_period);
00059 }
|
|
|
Definition at line 63 of file nmlwatch.cc. 00064 {
00065 stop = 1;
00066 }
|
|
||||||||||||||||
|
Definition at line 69 of file nmlwatch.cc. 00070 {
00071 return (0);
00072 }
|
|
||||||||||||||||
|
Definition at line 75 of file nmlwatch.cc. 00076 {
00077 NML *nml;
00078 RCS_TIMER *timer;
00079 NMLmsg *nmlmsg;
00080 NMLTYPE peek_ret;
00081 double start_time;
00082 rcs_print ("NMLWATCH(%s,%s,%lf) called.\n",
00083 config_file, buffer, sample_period);
00084 timer = new RCS_TIMER (sample_period);
00085 stop = 0;
00086 nml = new NML (format_stub, buffer, "nmlwatch", config_file);
00087 if (NULL == nml)
00088 {
00089 rcs_print_error ("NMLWATCH: Can't create nml channel.\n");
00090 delete timer;
00091 return -1;
00092 }
00093 if (!nml->valid ())
00094 {
00095 rcs_print_error ("NMLWATCH: Can't create nml channel.\n");
00096 delete nml;
00097 delete timer;
00098 return -1;
00099 }
00100 #ifdef sparcworks_sun4
00101 signal (SIGINT, (void (*)(int,...)) stop_watching_nml);
00102 #else
00103 signal (SIGINT, stop_watching_nml);
00104 #endif
00105 rcs_print ("Waiting for messages.\n");
00106 start_time = etime ();
00107 while (!stop)
00108 {
00109 peek_ret = nml->peek ();
00110 switch (peek_ret)
00111 {
00112 case 0:
00113 break;
00114
00115 case -1:
00116 rcs_print_error ("NMLWATCH: Can`t read nml channel.\n");
00117 delete nml;
00118 delete timer;
00119 return (-1);
00120
00121 default:
00122 nmlmsg = nml->get_address ();
00123 rcs_print ("NML message %ld of size %ld recieved at t=%lf.\n",
00124 nmlmsg->type, nmlmsg->size, etime () - start_time);
00125 break;
00126 }
00127 timer->wait ();
00128 }
00129 rcs_print ("NMLWATCH is quitting.\n");
00130 delete nml;
00131 delete timer;
00132 return (0);
00133 }
|
|
|
Definition at line 14 of file nmlwatch.cc. |
1.2.11.1 written by Dimitri van Heesch,
© 1997-2001