climate/climate.h

Go to the documentation of this file.
00001 
00008 #ifndef _CLIMATE_H
00009 #define _CLIMATE_H
00010 
00011 #include <stdarg.h>
00012 #include "gridlabd.h"
00013 
00014 typedef enum{
00015     CP_S  = 0,
00016     CP_SE = 1,
00017     CP_SW = 2,
00018     CP_E  = 3,
00019     CP_W  = 4,
00020     CP_NE = 5,
00021     CP_NW = 6,
00022     CP_N  = 7,
00023     CP_H  = 8,
00024     CP_LAST = 9
00025 } COMPASS_PTS;
00026 
00027 typedef struct s_tmy {
00028     double temp; // F
00029     double temp_raw; // C
00030     double rh; // %rh
00031     double solar[CP_LAST]; // W/sf
00032 } TMYDATA;
00033 
00034 class csv {
00035 private:
00036     unsigned line;
00037     unsigned cols;
00038     int *hdr;
00039     char **data;
00040     char buffer[4096];
00041     FILE *fp;
00042 public:
00043     csv();
00044     ~csv();
00045     int open(const char *file, const unsigned n, ...);
00046     int next();
00047     char *read(unsigned n);
00048 };
00049 
00057 class tmy2_reader{
00058 private:
00059     // Header information
00060     char data_city[75];
00061     char data_state[3];
00062     int lat_degrees;
00063     int lat_minutes;
00064     int long_degrees;
00065     int long_minutes;
00066 
00067     
00068 
00069     FILE *fp;
00070     char buf[500]; // buffer to hold line data.
00071 
00072 public:
00073     int tz_offset;
00074     tmy2_reader(){}
00075 
00076     void close();
00077 
00086     int open(const char *file);
00087 
00091     int next();
00092 
00101     int header_info(char* city, char* state, int* degrees, int* minutes, int* long_deg, int* long_min);
00102 
00113     int read_data(double *dnr, double *dhr, double *tdb, double *rh, int* month, int* day, int* hour);
00114 
00115     double calc_solar(COMPASS_PTS cpt, short doy, double lat, double sol_time, double dnr, double dhr,double vert_angle);
00116 
00117 };
00118 
00119 
00120 
00121 class climate {
00122 public:
00123     char32 city; 
00124     char1024 tmyfile; 
00125     double temperature; 
00126     double temperature_raw; 
00127     double humidity; 
00128     double solar_flux[CP_LAST]; 
00129 private:
00130     tmy2_reader file;
00131     TMYDATA *tmy;
00132 public:
00133     static CLASS *oclass;
00134     static climate *defaults;
00135 public:
00136     climate(MODULE *module);
00137     int create(void);
00138     int init(OBJECT *parent);
00139     TIMESTAMP sync(TIMESTAMP t0);
00140 }; 
00141 
00142 #endif
00143 

GridLAB-DTM Version 1.0
An open-source project initiated by the US Department of Energy