void ahelpkey() { int x,i,lgscr,page; byte ch; if (vstate(0)==4) smallscr(NO); if (equipment(0)==7) { page =0; smallscr(NO); } else { page =3; } vpage(page); crttim=0; lgscr = (tvmaxc==39) ? TRUE:FALSE; for (i=0; i<10; ++i) { helptop(page); for (x=0;;++x) { ch=*(helpkey[i]+x); if (ch==0) break; if (ch=='_') { if (lgscr) rprints(foreg,page,"\n \t \t "); else rputcinc(' ',0,foreg,NO,page); } else rputcinc(ch,0,foreg,NO,page); if ((ch==LF) && (lgscr)) putch(LF); /* 2nd LF */ } curset(23,5,page); if (i<9) { rprints(foreg,page,"Do you want the next page (Y/N) ? "); x=getyn(); if (x==NO) break; } else { rprints(foreg,page,"Hit any key to return "); getkey(); } } bright; /* Restore page 0 */ if (page==0) { if (SMALLMSK(maskp)) smallscr(NO); else largescr(NO); dspmsk(); } }
//! List a range of SAVED records. //! Checks that the time specified is not later than device time // void listRecordsSince(const char* since) { struct weatherRecord record; char datestr[17]; // convert date/time given to time_t time_t since_t = cvtStr2Time_t(since); // get current date and time - getDateTime() found in header.h char* devtimestr = (char*) getDateTime(); //printf("DEBUG: device date = %s\n", devtimestr); time_t devtime = cvtStr2Time_t(devtimestr); // check for since date in the future if (since_t > devtime) { printf("Date %s is in the future, date now is %s\n", since, getDateTime()); exit(1); } // maximum number of records, getRecordsStored() in header.h int guard = getRecordsStored(); //printf("DEBUG: (main.c) there are %d records stored\n", guard); int headings = (options.verbose == 1) ? 1 : 0; // Record 0 is the current reading, it is continually overwritten until the // polling period is reached, at which time a new current record is started // with a 0 second delay. int recordidx = 0; // skip the 0 record as it is the current value and should be read using // -r 0 // (rread() found in wrecord.h) weatherRecordPtr p = rread(&record, recordidx++); // calculate time of the first saved record time_t tmptime = devtime - (record.interval * 60); // starting with the first saved record (recordidx == 1) // while the record time is greater than the time since (and there are records!) // output the result while((tmptime > since_t) && (recordidx < guard)) { // read the record p = rread(&record, recordidx++); // calculate its date/time tmptime -= (record.interval * 60); // if it is later than since then print it if (tmptime > since_t) { cvtTime2Str(datestr, 17, &tmptime); // tell getDateTime() to use our date/time (usedate is external, see header.h) usedate = datestr; if (options.verbose == 0) { rprints(&record, recordPrintSpecification, fieldseparator); } else { rprintv(&record, recordPrintSpecification, fieldseparator, headings); } // reset getDateTime() to use device time usedate = NULL; // no more headings for this list headings = 0; } } }
//! List a range of records. //! Checks that the end is not greater than the number of records stored // void listRecords(int start, int end) { struct weatherRecord record; //printf("DEBUG: -r %d:%d\n", start, end); if (end < start) { end = start; } int numrecs = getRecordsStored(); //printf("DEBUG: (main.c) there are %d records stored\n", numrecs); if (end >= numrecs) { printf("invalid end record number %d\n", end); return; } // set up for storing the time of readings // convert date/time given to time_t // get current date and time using getDateTime() (see header.h) char* devtimestr = (char*) getDateTime(); //printf("DEBUG: device date = %s\n", devtimestr); time_t devtime = cvtStr2Time_t(devtimestr); // prepare, get a record pointer and a record counter and temp time weatherRecordPtr p = NULL; int recordidx = 0; time_t tmptime = devtime; if (daterequired()) { // read up to the starting record, adjusting time while(recordidx < start) { // calculate time of the first stored record using rread() (see wrecord.h) p = rread(&record, recordidx++); tmptime -= (record.interval * 60); } } else { recordidx = start; } // now recordidx is pointing at the first record to be listed // and tmptime is holding the time of that record // get date string storage char datestr[17]; // see if headings are to be printed, for options see cmdline.h int headings = (options.verbose == 1) ? 1 : 0; // loop through the records to be listed while(recordidx <= end) { // read the record (see wrecord.h) p = rread(&record, recordidx++); // convert the date to a string cvtTime2Str(datestr, 17, &tmptime); // tell getDateTime() to use our date/time (usedate is external, see header.h) usedate = datestr; // print the record using functions specified in wrecord.h if (options.verbose == 0) { rprints(&record, recordPrintSpecification, fieldseparator); } else { rprintv(&record, recordPrintSpecification, fieldseparator, headings); } // calculate date/time of next saved record tmptime -= (record.interval * 60); // reset getDateTime() to use device time usedate = NULL; // no more headings for this list headings = 0; } /* int headings = (options.verbose == 1) ? 1 : 0; for(int i = end; i >= 0 && i >= start; i--) { rread(&record, i); if (options.verbose == 0) { rprints(&record, recordPrintSpecification, fieldseparator); } else { rprintv(&record, recordPrintSpecification, fieldseparator, headings); } headings = 0; } */ }