G
Guest
Hoi,
I have a problem/question. I own a weather station (a davis pro 2) with
datalogger. I like to make my own program as a learning tool for the c#
language. The question i have is: how do i read the file with the structure
as shown in this question in a c# program. I believe i have to use something
like
StreamReader reader =
File.OpenText("C:\\TEMP\\projects\\ImportIJMI\\ImportIJMI\\Weer
files\\2007-05.wlk");
I hope someone can point me in the right direction.
Greetings from the netherlands,
Ed
the structure of the file is (it is in C++ format I, i believe i know how to
convert it to c#):
// Data is stored in monthly files. Each file has the following header.
struct DayIndex
{
short recordsInDay; // includes any daily summary records
long startPos; // The index (starting at 0) of the first daily summary
record
};
// Header for each monthly file.
// The first 16 bytes are used to identify a weather database file and to
identify
// different file formats. (Used for converting older database files.)
class HeaderBlock
{
char idCode [16]; // = {'W', 'D', 'A', 'T', '5', '.', '0', 0, 0, 0, 0, 0,
0, 0, 5, 0}
long totalRecords;
DayIndex dayIndex [32]; // index records for each day. Index 0 is not used
// (i.e. the 1'st is at index 1, not index 0)
};
// After the Header are a series of 88 byte data records with one of the
following
// formats. Note that each day will begin with 2 daily summary records
// Daily Summary Record 1
struct DailySummary1
{
BYTE dataType = 2;
BYTE reserved; // this will cause the rest of the fields to start on
an even address
short dataSpan; // total # of minutes accounted for by physical records
for this day
short hiOutTemp, lowOutTemp; // tenths of a degree F
short hiInTemp, lowInTemp; // tenths of a degree F
short avgOutTemp, avgInTemp; // tenths of a degree F (integrated over the
day)
short hiChill, lowChill; // tenths of a degree F
short hiDew, lowDew; // tenths of a degree F
short avgChill, avgDew; // tenths of a degree F
short hiOutHum, lowOutHum; // tenths of a percent
short hiInHum, lowInHum; // tenths of a percent
short avgOutHum; // tenths of a percent
short hiBar, lowBar; // thousandths of an inch Hg
short avgBar; // thousandths of an inch Hg
short hiSpeed, avgSpeed; // tenths of an MPH
short dailyWindRunTotal; // 1/10'th of an mile
short hi10MinSpeed; // the highest average wind speed record
BYTE dirHiSpeed, hi10MinDir; // direction code (0-15, 255)
short dailyRainTotal; // 1/1000'th of an inch
short hiRainRate; // 1/100'th inch/hr ???
short dailyUVDose; // 1/10'th of a standard MED
BYTE hiUV; // tenth of a UV Index
BYTE timeValues[27]; // space for 18 time values (see below)
};
// Daily Summary Record 2
struct DailySummary2
{
BYTE dataType = 3;
BYTE reserved; // this will cause the rest of the fields to start on
an even address
// this field is not used now.
unsigned short todaysWeather; // bitmapped weather conditions (Fog,
T-Storm, hurricane, etc)
short numWindPackets; // # of valid packets containing wind data,
// this is used to indicate reception quality
short hiSolar; // Watts per meter squared
short dailySolarEnergy; // 1/10'th Ly
short minSunlight; // number of accumulated minutes where the avg
solar rad > 150
short dailyETTotal; // 1/1000'th of an inch
short hiHeat, lowHeat; // tenths of a degree F
short avgHeat; // tenths of a degree F
short hiTHSW, lowTHSW; // tenths of a degree F
short hiTHW, lowTHW; // tenths of a degree F
short integratedHeatDD65; // integrated Heating Degree Days (65F
threshold)
// tenths of a degree F - Day
// Wet bulb values are not calculated
short hiWetBulb, lowWetBulb; // tenths of a degree F
short avgWetBulb; // tenths of a degree F
BYTE dirBins[24]; // space for 16 direction bins
// (Used to calculate monthly dominant Dir)
BYTE timeValues[15]; // space for 10 time values (see below)
short integratedCoolDD65; // integrated Cooling Degree Days (65F
threshold)
// tenths of a degree F - Day
BYTE reserved2[11];
};
// standard archive record
struct WeatherDataRecord
{
BYTE dataType = 1;
BYTE archiveInterval; // number of minutes in the archive
// see below for more details about these next two fields)
BYTE iconFlags; // Icon associated with this record, plus Edit
flags
BYTE moreFlags; // Tx Id, etc.
short packedTime; // minutes past midnight of the end of the
archive period
short outsideTemp; // tenths of a degree F
short hiOutsideTemp; // tenths of a degree F
short lowOutsideTemp; // tenths of a degree F
short insideTemp; // tenths of a degree F
short barometer; // thousandths of an inch Hg
short outsideHum; // tenths of a percent
short insideHum; // tenths of a percent
unsigned short rain; // number of clicks + rain collector type code
short hiRainRate; // clicks per hour
short windSpeed; // tenths of an MPH
short hiWindSpeed; // tenths of an MPH
BYTE windDirection; // direction code (0-15, 255)
BYTE hiWindDirection; // direction code (0-15, 255)
short numWindSamples; // number of valid ISS packets containing wind
data
// this is a good indication of reception
short solarRad, hisolarRad;// Watts per meter squared
BYTE UV, hiUV; // tenth of a UV Index
BYTE leafTemp[4]; // (whole degrees F) + 90
short extraRad; // used to calculate extra heating effects of
the sun in THSW index
short newSensors[6]; // reserved for future use
BYTE forecast; // forecast code during the archive interval
BYTE ET; // in thousandths of an inch
BYTE soilTemp[6]; // (whole degrees F) + 90
BYTE soilMoisture[6]; // centibars of dryness
BYTE leafWetness[4]; // Leaf Wetness code (0-15, 255)
BYTE extraTemp[7]; // (whole degrees F) + 90
BYTE extraHum[7]; // whole percent
};
I have a problem/question. I own a weather station (a davis pro 2) with
datalogger. I like to make my own program as a learning tool for the c#
language. The question i have is: how do i read the file with the structure
as shown in this question in a c# program. I believe i have to use something
like
StreamReader reader =
File.OpenText("C:\\TEMP\\projects\\ImportIJMI\\ImportIJMI\\Weer
files\\2007-05.wlk");
I hope someone can point me in the right direction.
Greetings from the netherlands,
Ed
the structure of the file is (it is in C++ format I, i believe i know how to
convert it to c#):
// Data is stored in monthly files. Each file has the following header.
struct DayIndex
{
short recordsInDay; // includes any daily summary records
long startPos; // The index (starting at 0) of the first daily summary
record
};
// Header for each monthly file.
// The first 16 bytes are used to identify a weather database file and to
identify
// different file formats. (Used for converting older database files.)
class HeaderBlock
{
char idCode [16]; // = {'W', 'D', 'A', 'T', '5', '.', '0', 0, 0, 0, 0, 0,
0, 0, 5, 0}
long totalRecords;
DayIndex dayIndex [32]; // index records for each day. Index 0 is not used
// (i.e. the 1'st is at index 1, not index 0)
};
// After the Header are a series of 88 byte data records with one of the
following
// formats. Note that each day will begin with 2 daily summary records
// Daily Summary Record 1
struct DailySummary1
{
BYTE dataType = 2;
BYTE reserved; // this will cause the rest of the fields to start on
an even address
short dataSpan; // total # of minutes accounted for by physical records
for this day
short hiOutTemp, lowOutTemp; // tenths of a degree F
short hiInTemp, lowInTemp; // tenths of a degree F
short avgOutTemp, avgInTemp; // tenths of a degree F (integrated over the
day)
short hiChill, lowChill; // tenths of a degree F
short hiDew, lowDew; // tenths of a degree F
short avgChill, avgDew; // tenths of a degree F
short hiOutHum, lowOutHum; // tenths of a percent
short hiInHum, lowInHum; // tenths of a percent
short avgOutHum; // tenths of a percent
short hiBar, lowBar; // thousandths of an inch Hg
short avgBar; // thousandths of an inch Hg
short hiSpeed, avgSpeed; // tenths of an MPH
short dailyWindRunTotal; // 1/10'th of an mile
short hi10MinSpeed; // the highest average wind speed record
BYTE dirHiSpeed, hi10MinDir; // direction code (0-15, 255)
short dailyRainTotal; // 1/1000'th of an inch
short hiRainRate; // 1/100'th inch/hr ???
short dailyUVDose; // 1/10'th of a standard MED
BYTE hiUV; // tenth of a UV Index
BYTE timeValues[27]; // space for 18 time values (see below)
};
// Daily Summary Record 2
struct DailySummary2
{
BYTE dataType = 3;
BYTE reserved; // this will cause the rest of the fields to start on
an even address
// this field is not used now.
unsigned short todaysWeather; // bitmapped weather conditions (Fog,
T-Storm, hurricane, etc)
short numWindPackets; // # of valid packets containing wind data,
// this is used to indicate reception quality
short hiSolar; // Watts per meter squared
short dailySolarEnergy; // 1/10'th Ly
short minSunlight; // number of accumulated minutes where the avg
solar rad > 150
short dailyETTotal; // 1/1000'th of an inch
short hiHeat, lowHeat; // tenths of a degree F
short avgHeat; // tenths of a degree F
short hiTHSW, lowTHSW; // tenths of a degree F
short hiTHW, lowTHW; // tenths of a degree F
short integratedHeatDD65; // integrated Heating Degree Days (65F
threshold)
// tenths of a degree F - Day
// Wet bulb values are not calculated
short hiWetBulb, lowWetBulb; // tenths of a degree F
short avgWetBulb; // tenths of a degree F
BYTE dirBins[24]; // space for 16 direction bins
// (Used to calculate monthly dominant Dir)
BYTE timeValues[15]; // space for 10 time values (see below)
short integratedCoolDD65; // integrated Cooling Degree Days (65F
threshold)
// tenths of a degree F - Day
BYTE reserved2[11];
};
// standard archive record
struct WeatherDataRecord
{
BYTE dataType = 1;
BYTE archiveInterval; // number of minutes in the archive
// see below for more details about these next two fields)
BYTE iconFlags; // Icon associated with this record, plus Edit
flags
BYTE moreFlags; // Tx Id, etc.
short packedTime; // minutes past midnight of the end of the
archive period
short outsideTemp; // tenths of a degree F
short hiOutsideTemp; // tenths of a degree F
short lowOutsideTemp; // tenths of a degree F
short insideTemp; // tenths of a degree F
short barometer; // thousandths of an inch Hg
short outsideHum; // tenths of a percent
short insideHum; // tenths of a percent
unsigned short rain; // number of clicks + rain collector type code
short hiRainRate; // clicks per hour
short windSpeed; // tenths of an MPH
short hiWindSpeed; // tenths of an MPH
BYTE windDirection; // direction code (0-15, 255)
BYTE hiWindDirection; // direction code (0-15, 255)
short numWindSamples; // number of valid ISS packets containing wind
data
// this is a good indication of reception
short solarRad, hisolarRad;// Watts per meter squared
BYTE UV, hiUV; // tenth of a UV Index
BYTE leafTemp[4]; // (whole degrees F) + 90
short extraRad; // used to calculate extra heating effects of
the sun in THSW index
short newSensors[6]; // reserved for future use
BYTE forecast; // forecast code during the archive interval
BYTE ET; // in thousandths of an inch
BYTE soilTemp[6]; // (whole degrees F) + 90
BYTE soilMoisture[6]; // centibars of dryness
BYTE leafWetness[4]; // Leaf Wetness code (0-15, 255)
BYTE extraTemp[7]; // (whole degrees F) + 90
BYTE extraHum[7]; // whole percent
};