2 * FILE: $Header: /home/egg/src/RCS/eggui.c,v 1.8 1999/02/28 20:02:54 ghn Exp $
3 * PURPOSE: EGG site user interface
9 * Revision 1.8 1999/02/28 20:02:54 ghn
10 * Version 5.1: The user interface now leaves the cursor at the bottom of
11 * the screen and responds to ^L to redraw the entire screen.
13 * Revision 1.7 1999/01/01 23:58:56 ghn
14 * Take out "CPU_BOUND" conditionals; we won't run CPU_BOUND any more.
16 * Revision 1.6 1998/12/31 22:07:56 ghn
17 * Rev 5 code: includes multi-reg support, HTML, etc.
19 * Revision 1.5 1998/08/03 20:36:28 kelvin
20 * Show time of last data collection by basket.
22 * Revision 1.4 1998/08/01 21:33:28 ghn
23 * Added real implementation for ncursed() based UI for egg.
25 * Revision 1.3 1998/08/01 18:51:25 ghn
26 * Added John's byte-order-independence changes.
28 * Revision 1.2 1998/08/01 17:05:48 ghn
29 * Trivial additions of curses related code.
31 * Revision 1.1 1998/07/21 11:41:23 ghn
34 * Copyright 1998 - Greg Nelson
43 /* Curses takes it upon itself to define TRUE and FALSE,
44 incompatibly, as it happens, with the definitions in
45 global.h. So, clear out the CURSES definitions. */
60 static int32 inittm = 0;
63 extern int32 lastDataSent;
64 extern int32 time_latency, time_housekeeping;
66 /* Initialize user interface, as needed. */
72 intrflush(stdscr, FALSE);
77 printw("Please wait, initializing...");
84 /* Close down user interface */
92 /* Update user interface once on every data collection, receiving the
93 current collection result and CollectRecord. */
94 int32 UIUpdate(int32 cres, CollectRecord *coll) {
98 static double grandavg = 0;
99 static int32 totsamp = 0;
102 if ((i = getch()) != ERR) {
103 if (i == 12) clear();
107 inittm = getzulutime(NULL);
113 if (coll->sampct == 1) {
115 move(line++, 5); printw("Samples per record: %3d", (int)coll->opts.samp_rec);
116 move(line++, 5); printw("Seconds per record: %3d", (int)coll->opts.sec_rec);
117 move(line++, 5); printw("Records per packet: %3d", (int)coll->opts.rec_pkt);
118 move(line++, 5); printw("Bits per trial: %3d", (int)coll->opts.trialsz);
122 if (cres < 0) return ERR_NONE;
126 printw("EGG %s ID %d REG %s %s", eggtable[0].name, eggtable[0].id,
127 configuredREG->reg_name, Version);
129 tmstr = ctime(&inittm); tmstr[strlen(tmstr)-1] = 0;
131 printw("Up since %25s", tmstr);
134 now = getzulutime(NULL);
135 tmstr = ctime(&now); tmstr[strlen(tmstr)-1] = 0;
136 printw("Last sample at %25s", tmstr);
139 tmstr = ctime(&lastDataSent);
140 tmstr[strlen(tmstr)-1] = 0;
141 printw("Last packet at %25s", lastDataSent == 0 ? "Never" : tmstr);
143 /* Note that for a non-CPU_BOUND built, UIUpdate is passed a
144 collection record filled with the last 10 samples collected.
145 Since missing samples do not figure in this record, there
146 is no need to test EGG_MISSING_DATA when computing the
149 /* Show mean since egg started and, each time 10 samples
150 are collected, the mean for the last 10 samples. */
154 grandavg += coll->data.trials[coll->sampct-1]; totsamp++;
157 printw("Grand mean: %6.2f", grandavg);
160 for (recavg = 0, i = 0; i < coll->opts.samp_rec; i++)
161 recavg += coll->data.trials[i];
162 recavg /= coll->opts.samp_rec;
164 printw("Last record mean: %6.2f (%d seconds)", recavg, coll->opts.sec_rec);
166 line++; /* Advance whether we show record mean or not */
168 /* Show latency (lapse between start of second as measured by
169 the computer's clock and when collection of the sample
170 actually began) and time elapsed in housekeeping (saving
171 packets in local files, talking to the basket, updating
172 the user interface, etc.) following collection of the sample.
173 If housekeeping time frequently consumes a substantial portion
174 of the inter-sample interval, the probability of lost
175 samples increases. Both times are shown in milliseconds. */
179 printw("Sampling latency: ");
181 printw("%.3f ms", time_latency / 1000.0);
183 printw("Housekeeping time: ");
185 printw("%.3f ms", time_housekeeping / 1000.0);