adding option not to draw a chart.

master
Steffen Pohle 4 years ago
parent 422a6a0c46
commit c1ab440a33

@ -20,7 +20,8 @@ void help() {
printf ("\tconnect connect to the device, it will save the SID file.\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 ("\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 ("\t If silent parameter is set, we will not be asked for credentials\n");
printf ("\tgethzr AIN reads heating control device\n"); printf ("\tgethzr AIN options reads heating control device\n");
printf ("\t -nochart display no history chart\n");
printf ("\tsaveconfig save configfile.\n"); printf ("\tsaveconfig save configfile.\n");
printf ("\n"); printf ("\n");
printf ("Parameters:\n"); printf ("Parameters:\n");
@ -68,7 +69,7 @@ void getlist(int argpos, int argc, char **argv) {
} }
#define CHARTSIZE 20 #define CHARTSIZE 20
void gethzr(char *ain) { void gethzr(int argci, int argc, char **argv) {
FBSmartHomeHZR hzr; FBSmartHomeHZR hzr;
list<float>::iterator iter; list<float>::iterator iter;
float fmin, fmax; float fmin, fmax;
@ -77,6 +78,13 @@ void gethzr(char *ain) {
char t[64]; char t[64];
struct tm *tmp; struct tm *tmp;
time_t ctime = time(NULL); 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; if (ain == NULL) return;
connect(); connect();
@ -91,6 +99,7 @@ void gethzr(char *ain) {
printf (" Offset: %d\n", hzr.offset); printf (" Offset: %d\n", hzr.offset);
printf (" Grid: %d\n", hzr.statsgrid); printf (" Grid: %d\n", hzr.statsgrid);
if (!nochart) {
for (iter = hzr.stats.begin(); iter != hzr.stats.end(); iter++) { for (iter = hzr.stats.begin(); iter != hzr.stats.end(); iter++) {
if (iter == hzr.stats.begin()) fmin = fmax = *iter; if (iter == hzr.stats.begin()) fmin = fmax = *iter;
if (fmin > *iter) fmin = *iter; if (fmin > *iter) fmin = *iter;
@ -115,6 +124,7 @@ void gethzr(char *ain) {
} }
printf (" %-2.1f %-2.1f\n", fmin/10.0, fmax/10.0); printf (" %-2.1f %-2.1f\n", fmin/10.0, fmax/10.0);
} }
}
int main(int argc, char** argv) { int main(int argc, char** argv) {
@ -145,7 +155,7 @@ int main(int argc, char** argv) {
break; break;
} }
else if (strcmp(argv[i], "gethzr") == 0) { else if (strcmp(argv[i], "gethzr") == 0) {
gethzr(argv[++i]); gethzr(i, argc, argv);
} }
// //

Loading…
Cancel
Save