#include <gtk/gtk.h>
#include "gddcalc.h"
#include "solpos.h"

void t1_Populate() {
	size_t lth = 64;
	char *bfr = malloc(lth);

	active_year = 1999;                // initialize Atlanta
	active_month = 7;
	active_day = 22;
	active_latitude = 33.65;
	active_longitude = -84.43;
	active_aspect = 135;
	active_tilt = 33.65;
	active_timezone = -5;
	active_hour = 9;
	active_minute = 45;
	active_second = 37;
	active_dt = 1;
	active_temp = 27;
	active_press = 1006;
	active_daynum = 203;

/* The posdata structure is defined in solpos.h and pd is defined there
 * as a posdata structure. pdat is a pointer to pd. Here we set values
 * into some quantities that are input to solpos.
 */

   pdat = &pd;
   S_init(pdat);                            // default initialization of pdat
   pdat->latitude = active_latitude;
   pdat->longitude = active_longitude;
   pdat->aspect = active_aspect;
   pdat->tilt = active_tilt;
   pdat->year = active_year;      // not a leap year in this test
   pdat->month = active_month;
   pdat->day = active_day;
   pdat->hour = active_hour;
   pdat->minute = active_minute;
   pdat->second = active_second;
   pdat->temp = active_temp;
   pdat->press = active_press;
   pdat->timezone = active_timezone;
   pdat->daynum = active_daynum;

/* Make the calculations */

   long retval = S_solpos(pdat);

/* Put the results onscreen */

	sprintf(bfr, "%.4f  (97.0329)", pdat->azim);
	gtk_entry_set_text (GTK_ENTRY (t1_entry1), (gchar*) bfr);

	sprintf(bfr, "%.5f  (0.91257)", pdat->cosinc);
	gtk_entry_set_text (GTK_ENTRY (t1_entry2), (gchar*) bfr);

	sprintf(bfr, "%.4f  (48.4099)", pdat->elevref);
	gtk_entry_set_text (GTK_ENTRY (t1_entry3), (gchar*) bfr);

	sprintf(bfr, "%.3f  (989.669)", pdat->etr);
	gtk_entry_set_text (GTK_ENTRY (t1_entry4), (gchar*) bfr);

	sprintf(bfr, "%.2f  (1323.24)", pdat->etrn);
	gtk_entry_set_text (GTK_ENTRY (t1_entry5), (gchar*) bfr);

	sprintf(bfr, "%.2f  (1207.55)", pdat->etrtilt);
	gtk_entry_set_text (GTK_ENTRY (t1_entry6), (gchar*) bfr);

	sprintf(bfr, "%.5f  (1.03704)", pdat->prime);
	gtk_entry_set_text (GTK_ENTRY (t1_entry7), (gchar*) bfr);

	sprintf(bfr, "%.5f  (1.20191)", pdat->sbcf);
	gtk_entry_set_text (GTK_ENTRY (t1_entry8), (gchar*) bfr);

	sprintf(bfr, "%.3f  (347.173)", pdat->sretr);
	gtk_entry_set_text (GTK_ENTRY (t1_entry9), (gchar*) bfr);

	sprintf(bfr, "%.2f  (1181.11)", pdat->ssetr);
	gtk_entry_set_text (GTK_ENTRY (t1_entry10), (gchar*) bfr);

	sprintf(bfr, "%.5f  (0.96428)", pdat->unprime);
	gtk_entry_set_text (GTK_ENTRY (t1_entry11), (gchar*) bfr);

	sprintf(bfr, "%.4f  (41.5901)", pdat->zenref);
	gtk_entry_set_text (GTK_ENTRY (t1_entry12), (gchar*) bfr);

	free(bfr);
}
