2018-12-08 23:02:24 +11:00
|
|
|
/*
|
|
|
|
* essai.c
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
2019-01-18 04:37:30 +11:00
|
|
|
#include <string.h>
|
2019-01-31 05:14:40 +11:00
|
|
|
#include <curses.h>
|
2019-01-19 01:39:07 +11:00
|
|
|
#include <time.h>
|
2018-12-08 23:02:24 +11:00
|
|
|
|
2019-01-18 04:37:30 +11:00
|
|
|
#include "core/utils.h"
|
2019-01-29 02:57:45 +11:00
|
|
|
#include "core/sysmetrics.h"
|
2019-01-31 05:14:40 +11:00
|
|
|
#include "viz/curses/ecran.h"
|
2018-12-08 23:02:24 +11:00
|
|
|
|
2019-01-18 04:37:30 +11:00
|
|
|
int verbosity;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------- */
|
2019-01-31 05:14:40 +11:00
|
|
|
int affiche_loadavg(int nbloops, int k)
|
|
|
|
{
|
|
|
|
int idx, foo;
|
|
|
|
float lds[3];
|
|
|
|
|
|
|
|
for (idx=0; idx<nbloops; idx++) {
|
|
|
|
|
|
|
|
foo = get_loadavg(lds);
|
|
|
|
if (foo) fprintf(stderr, "get loadavg -> %d\n", foo);
|
|
|
|
|
|
|
|
foo = aff7segs_float(stdscr, 4, 9, lds[0]);
|
|
|
|
foo = aff7segs_float(stdscr, 14, 9, lds[1]);
|
|
|
|
foo = aff7segs_float(stdscr, 24, 9, lds[2]);
|
|
|
|
|
|
|
|
usleep(200*1000);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------- */
|
|
|
|
static void finish(int signal)
|
|
|
|
{
|
|
|
|
endwin(); exit(0);
|
|
|
|
}
|
2018-12-08 23:02:24 +11:00
|
|
|
/* --------------------------------------------------------------- */
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int opt, foo;
|
|
|
|
|
2019-01-18 04:37:30 +11:00
|
|
|
while ((opt = getopt(argc, argv, "v")) != -1) {
|
2018-12-08 23:02:24 +11:00
|
|
|
switch (opt) {
|
|
|
|
case 'v': verbosity++; break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-31 05:14:40 +11:00
|
|
|
initscr();
|
|
|
|
nonl(); cbreak(); noecho();
|
|
|
|
keypad(stdscr, TRUE); /* acces aux touches 'curseur' */
|
|
|
|
fond_ecran(" Demonstrator ");
|
|
|
|
|
|
|
|
affiche_loadavg(10000, 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* plop, on a fini, il faut restaurer la console
|
|
|
|
*/
|
|
|
|
finish(0);
|
|
|
|
|
2018-12-08 23:02:24 +11:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------- */
|