/* jawsd - connects to AWS datalogger over serial connection and provides
 *         weather information to the network
 * Copyright (C) 2003-2004 Jeffrey Grafton <jgrafton@tjhsst.edu>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
 */

#include <time.h>

/* 
00	hour min sec month	day year in_temp in_temp	out_temp out_temp aux_temp aux_temp	humidity humidity barometer barometer
10	light light daily_rain daily_rain	wind_speed wind_dir rainfall_rate avg_wind_speed	avg_wind_dir in_temp_rate in_temp_rate out_temp_rate	out_temp_rate aux_temp_rate aux_temp_rate barometer_rate 
20	barometer_rate hum_rate hum_rate light_rate	light_rate
*/

struct curobs_raw
{
	unsigned char hour;
	unsigned char minute;
	unsigned char second;
	unsigned char month;
	unsigned char day;
	unsigned char year;
	unsigned short indoor_temperature;
	unsigned short outdoor_temperature;
	unsigned short auxiliary_temperature;
	unsigned short humidity;
	unsigned short barometer;
	unsigned short light;
	unsigned short daily_rain;
	unsigned char wind_speed;
	unsigned char wind_direction;
	unsigned char rainfall_rate;
	unsigned char average_wind_speed;
	unsigned char average_wind_direction;
	unsigned short indoor_temperature_rate;
	unsigned short outdoor_temperature_rate;
	unsigned short auxiliary_temperature_rate;
	unsigned short barometer_rate;
	unsigned short humidity_rate;
	unsigned short light_rate;
	unsigned char wind_speed_supplement;
	unsigned char average_wind_speed_supplement;
} __attribute__ ((packed));

typedef struct curobs_raw curobs_raw;

/*
00	in_temp_high in_temp_high in_temp_high_hour in_temp_high_min	in_temp_low in_temp_low in_temp_low_hour in_temp_low_min	out_temp_high out_temp_high out_temp_high_hour out_temp_high_min	out_temp_low out_temp_low out_temp_low_hour out_temp_low_min
10	aux_temp_high aux_temp_high aux_temp_high_hour aux_temp_high_min	aux_temp_low aux_temp_low aux_temp_low_hour aux_temp_low_min	humidity_high humidity_high humidity_high_hour humidity_high_min	humidity_low humidity_low humidity_low_hour humidity_low_min
20	barometer_high barometer_high barometer_high_hour barometer_high_min	barometer_low barometer_low barometer_low_hour barometer_low_min	wind_speed_high wind_speed_high_hour wind_speed_high_minute wind_direction_high	rain_rate_high rain_rate_high_hour rain_rate_high_min light_high
30	light_high light_high_hour light_high_min light_low	light_low light_low_hour light_low_min monthly_rain	,monthly_rain yearly_rain yearly_rain 
*/

struct hilo_raw_pack
{
	unsigned short high;
	unsigned char high_hour;
	unsigned char high_minute;
	unsigned short low;
	unsigned char low_hour;
	unsigned char low_minute;
} __attribute__ ((packed));

struct hilo_raw
{
	struct hilo_raw_pack indoor_temperature;
	struct hilo_raw_pack outdoor_temperature;
	struct hilo_raw_pack auxiliary_temperature;
	struct hilo_raw_pack humidity;
	struct hilo_raw_pack barometer;

	unsigned char wind_speed_high;
	unsigned char wind_speed_high_hour;
	unsigned char wind_speed_high_minute;
	unsigned char wind_direction_high;
	
	unsigned char rainfall_rate_high;
	unsigned char rainfall_rate_high_hour;
	unsigned char rainfall_rate_high_minute;
	
	struct hilo_raw_pack light;
	
	unsigned short monthly_rain;
	unsigned short yearly_rain;
	unsigned char wind_speed_high_supplement;
} __attribute__ ((packed));

typedef struct hilo_raw hilo_raw;
	
struct processed_pack
{
	double current;
	double high;
	unsigned char high_hour;
	unsigned char high_minute;
	double low;
	unsigned char low_hour;
	unsigned char low_minute;
	double rate;
};

struct processed_wind_pack
{
	double current_speed;
	char current_direction[4];
   double current_direction_degrees;
	double high_speed;
	char high_direction[4];
   double high_direction_degrees;
	char high_hour;
	char high_minute;
	double average_speed;
	char average_direction[4];
   double average_direction_degrees;
   	double current_wind_chill;
   	double average_wind_chill;
};

struct processed_rain_pack
{
	double daily;
	double monthly;
	double yearly;
	double rate;
	double rate_high;
	char rate_high_hour;
	char rate_high_minute;
};

typedef struct
{
	time_t datetime;
	struct processed_pack indoor_temperature;
	struct processed_pack outdoor_temperature;
	struct processed_pack auxiliary_temperature;
	struct processed_pack humidity;
	struct processed_pack barometer;
	struct processed_pack light;
	struct processed_wind_pack wind;
	struct processed_rain_pack rain;
	double dew_point;
} data_processed;
