adding option not to draw a chart.

master
Steffen Pohle 4 years ago
parent 422a6a0c46
commit c1ab440a33

@ -16,12 +16,13 @@ void help() {
printf (" Client for accessing the fritzbox smart home devices.\n");
printf (" Most parameters can be set in a seperate config file.\n");
printf ("Commands:\n");
printf ("\thelp displays this helptext.\n");
printf ("\tconnect connect to the device, it will save the SID file.\n");
printf ("\tlist lists all devices, connection will be recovered from SID.\n");
printf ("\t If silent parameter is set, we will not be asked for credentials\n");
printf ("\tgethzr AIN reads heating control device\n");
printf ("\tsaveconfig save configfile.\n");
printf ("\thelp displays this helptext.\n");
printf ("\tconnect connect to the device, it will save the SID file.\n");
printf ("\tlist lists all devices, connection will be recovered from SID.\n");
printf ("\t If silent parameter is set, we will not be asked for credentials\n");
printf ("\tgethzr AIN options reads heating control device\n");
printf ("\t -nochart display no history chart\n");
printf ("\tsaveconfig save configfile.\n");
printf ("\n");
printf ("Parameters:\n");
printf ("\t-config <CONFIGGILE> configfile to use\n");
@ -68,7 +69,7 @@ void getlist(int argpos, int argc, char **argv) {
}
#define CHARTSIZE 20
void gethzr(char *ain) {
void gethzr(int argci, int argc, char **argv) {
FBSmartHomeHZR hzr;
list<float>::iterator iter;
float fmin, fmax;
@ -77,6 +78,13 @@ void gethzr(char *ain) {
char t[64];
struct tm *tmp;
time_t ctime = time(NULL);
char *ain = argv[++argci];
bool nochart = false;
for (argci++; argci < argc; argci++) {
if (strcmp(argv[argci], "-nochart") == 0)
nochart = true;
}
if (ain == NULL) return;
connect();
@ -91,29 +99,31 @@ void gethzr(char *ain) {
printf (" Offset: %d\n", hzr.offset);
printf (" Grid: %d\n", hzr.statsgrid);
for (iter = hzr.stats.begin(); iter != hzr.stats.end(); iter++) {
if (iter == hzr.stats.begin()) fmin = fmax = *iter;
if (fmin > *iter) fmin = *iter;
if (fmax < *iter) fmax = *iter;
}
if (!nochart) {
for (iter = hzr.stats.begin(); iter != hzr.stats.end(); iter++) {
if (iter == hzr.stats.begin()) fmin = fmax = *iter;
if (fmin > *iter) fmin = *iter;
if (fmax < *iter) fmax = *iter;
}
printf (" %-2.1f %-2.1f\n", fmin/10.0, fmax/10.0);
printf (" %-2.1f %-2.1f\n", fmin/10.0, fmax/10.0);
ctime = (ctime / hzr.statsgrid) * hzr.statsgrid;
ctime = (ctime / hzr.statsgrid) * hzr.statsgrid;
for (iter = hzr.stats.begin(); iter != hzr.stats.end(); iter++) {
s = " ";
c = ((float)(CHARTSIZE * (*iter - fmin) / (fmax-fmin)));
for (i = 0; i < c; i++) s += " ";
s += "*";
for (i = c+1; i <= CHARTSIZE; i++) s += " ";
for (iter = hzr.stats.begin(); iter != hzr.stats.end(); iter++) {
s = " ";
c = ((float)(CHARTSIZE * (*iter - fmin) / (fmax-fmin)));
for (i = 0; i < c; i++) s += " ";
s += "*";
for (i = c+1; i <= CHARTSIZE; i++) s += " ";
ctime -= hzr.statsgrid;
tmp = localtime(&ctime);
strftime(t, 64, "%H:%M", tmp);
printf (" %s |%s|\n", t, s.c_str());
ctime -= hzr.statsgrid;
tmp = localtime(&ctime);
strftime(t, 64, "%H:%M", tmp);
printf (" %s |%s|\n", t, s.c_str());
}
printf (" %-2.1f %-2.1f\n", fmin/10.0, fmax/10.0);
}
printf (" %-2.1f %-2.1f\n", fmin/10.0, fmax/10.0);
}
@ -145,7 +155,7 @@ int main(int argc, char** argv) {
break;
}
else if (strcmp(argv[i], "gethzr") == 0) {
gethzr(argv[++i]);
gethzr(i, argc, argv);
}
//

Loading…
Cancel
Save