There are two historical files that WUHU maintains.
It's basically an image of the memory in case of power failure. It contains every reading your station has made in the past X hours where X is set in your general settings. You can specify up to 1 week of data that can be kept in memory. This setting effects how much data you can chart and display statistics for.
For use with other programs, always use the history.dat file output by WUHU.
Here is the format of the history.dat file that is output by WUHU. This matches the file format output by the Heavyweather Pro application. The HW Pro application supports WS-36XX stations. We use the HW Pro application to graph the history files output by WUHU.
This format was chosen because it contains more fields than the old HW Beta 2.0 format.
New records are added to the end of the file, there is no header or trailing record.
The [X] field denotes the number of bytes in the field.
Wind Direction
Wind direction is encoded as an integer between 0 and 15. To get the wind direction in degrees, multiply the value by 22.5. To get compass directions (moving clockwise) 0 is North, 1 is North-Northeast, 2 is Northeast, etc…
. 0 N . 1 NNE . 2 NE . 3 ENE . 4 E . 5 ESE . 6 SE . 7 SSE . 8 S . 9 SSW . 10 SW . 11 WSW . 12 W . 13 WNW . 14 NW . 15 NNW
C data structure that mimics this format:
struct WeatherRecord3600 { double fTimeStamp; float fOutdoorAbsolutePressure; float fOutdoorRelativePressure; float fOutdoorWindSpeed; unsigned long ulOutdoorWindDirection; float fOutdoorWindGust; float fOutdoorTotalRainfall; float fOutdoorNewRainfall; float fIndoorTemperature; float fOutdoorTemperature; float fIndoorHumidity; float fOutdoorHumidity; unsigned long ulUnknown; };
The fTimeStamp is an odd field. It represents the days since a epoch time (12/30/1899 00:00:00) in UTC local time. The fractional part is used to obtain hours, minutes, and seconds. There are a few functions that are needed to convert back and forth between that timestamp format and the normal local time format, they are given below.
To convert from a normal time_t to this format you would use:
time_t t; WeatherRecord3600 wr3600; wr3600.fTimeStamp=Convert_time_t_To_DateTime2(ConvertLocalToUTCLocal(t));
To convert from this odd timestamp to a time_t:
t=ConvertUTCLocalToLocal(Convert_DateTime2_To_time_t(wr3600.fTimeStamp)); ----------------------- double Convert_time_t_To_DateTime2(time_t vtime_t) { double fresult; // 25569 days from Saturday, December 30, 1899 to Sunday, January 1, 1970 (where time_t seconds counts from) double fDeltaDays = 25569 + (vtime_t / (60 * 60 * 24)); double fFractionDays = (vtime_t % (60 * 60 * 24)) / (double)(60 * 60 * 24); fresult = fDeltaDays+fFractionDays; return (fresult); } //---- time_t Convert_DateTime2_To_time_t(double fTime) { return (time_t)((fTime - 25569.0) * 86400.0); } //---- time_t ConvertUTCLocalToLocal(time_t t) { // Aquire a local time and a gmt time. struct tm tm_localtime; memcpy(&tm_localtime,localtime(&t),sizeof(tm_localtime)); // Aquire UTC time. struct tm tm_gmtime; memcpy(&tm_gmtime,gmtime(&t),sizeof(tm_gmtime)); // Convert them back to time_t types. time_t t1=mktime(&tm_localtime); time_t t2=mktime(&tm_gmtime); // Subtract from local time the difference between local time and gmt time. t1 += (t2-t1); // If daylight saving time in effect, subtract an hour. if (tm_localtime.tm_isdst) t1 -= 60*60; return(t1); } //---- time_t ConvertLocalToUTCLocal(time_t t) { // Aquire a local time and a gmt time. struct tm tm_localtime; memcpy(&tm_localtime,localtime(&t),sizeof(tm_localtime)); // Aquire UTC time. struct tm tm_gmtime; memcpy(&tm_gmtime,gmtime(&t),sizeof(tm_gmtime)); // Convert them back to time_t types. time_t t1=mktime(&tm_localtime); time_t t2=mktime(&tm_gmtime); // Subtract from local time the difference between local time and gmt time. t1 -= (t2-t1); // If daylight saving time in effect, add an hour. if (tm_localtime.tm_isdst) t1 += 60*60; return(t1); }