2019-01-10 11:44:47 +11:00
|
|
|
/*
|
|
|
|
* DD2 Monitoring
|
|
|
|
*
|
|
|
|
* ncurses waterfall interface
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <strings.h>
|
|
|
|
#include <getopt.h>
|
|
|
|
#include <ncurses.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "ecran.h"
|
|
|
|
|
|
|
|
extern int verbosity;
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
WINDOW *open_waterfall(char *title, int flags)
|
|
|
|
{
|
|
|
|
WINDOW *win;
|
|
|
|
int l, c, w, h;
|
|
|
|
|
2019-01-11 00:07:56 +11:00
|
|
|
l = 1; c = 1;
|
|
|
|
w = COLS - 2; h = LINES - 3;
|
2019-01-10 11:44:47 +11:00
|
|
|
|
|
|
|
win = newwin(h, w, l, c);
|
2019-01-11 00:07:56 +11:00
|
|
|
scrollok(win, 1);
|
|
|
|
waddstr(win, title); waddch(win, '\n');
|
|
|
|
wrefresh(win);
|
2019-01-10 11:44:47 +11:00
|
|
|
|
|
|
|
return win;
|
|
|
|
}
|
|
|
|
/* ---------------------------------------------------------------- */
|
2019-01-11 00:07:56 +11:00
|
|
|
int plot_waterfall(WINDOW *wf, int mode, float values[4])
|
2019-01-10 11:44:47 +11:00
|
|
|
{
|
|
|
|
#define TL 1000
|
2019-01-11 00:07:56 +11:00
|
|
|
int foo, idx;
|
|
|
|
char tag, ligne[TL+1];
|
|
|
|
float coef_w;
|
|
|
|
static long iter;
|
2019-01-10 11:44:47 +11:00
|
|
|
|
2019-01-11 00:07:56 +11:00
|
|
|
if (0 == (iter%10)) {
|
|
|
|
memset(ligne, '-', TL);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
memset(ligne, ' ', TL);
|
|
|
|
}
|
|
|
|
for (foo=0; foo<500; foo+=10) {
|
|
|
|
ligne[foo] = '|';
|
|
|
|
}
|
|
|
|
ligne[COLS-4] = '\0';
|
|
|
|
|
|
|
|
iter++;
|
|
|
|
|
|
|
|
coef_w = (float)(COLS-2) / 1024.0;
|
|
|
|
|
|
|
|
#if TRACE
|
|
|
|
sprintf(ligne, "coef_w = %f\n", coef_w);
|
|
|
|
waddstr(wf, ligne); waddch(wf, '\n');
|
|
|
|
#endif
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
|
|
|
|
case 0: default:
|
|
|
|
sprintf(ligne, "%11.3f %11.3f %11.3f %11.3f",
|
|
|
|
values[0], values[1], values[2], values[3]);
|
|
|
|
#if TRACE
|
|
|
|
fprintf(stderr, "%s [%s]\n", __func__, ligne);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
for(foo=0; foo<4; foo++) {
|
|
|
|
tag = "ATOX"[foo];
|
|
|
|
idx = (int)(values[foo]*coef_w);
|
|
|
|
ligne[idx] = tag;
|
|
|
|
}
|
|
|
|
ligne[COLS-4] = '\0';
|
|
|
|
break;
|
2019-01-10 11:44:47 +11:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-01-11 00:07:56 +11:00
|
|
|
|
|
|
|
|
|
|
|
/* poke the text in the curses window */
|
|
|
|
// scroll(wf);
|
|
|
|
waddstr(wf, ligne); waddch(wf, '\n');
|
|
|
|
wrefresh(wf);
|
|
|
|
|
2019-01-10 11:44:47 +11:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
int close_waterfall(WINDOW *wf, int notused)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (NULL == wf) {
|
|
|
|
fprintf(stderr, "%s wf is null\n", __func__);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* ---------------------------------------------------------------- */
|