Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String location = Request.QueryString["location"];

            Start = DateTime.Now;
            Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
            try
            {
                String   dbToUse  = "Surfvind_data";
                bool     isMySQL  = Convert.ToBoolean(ConfigurationManager.AppSettings["isMySQL"]);
                WindData windData = new WindData(isMySQL, dbToUse);

                List <Location> allWeatherStations = windData.GetLocations();
                allWeatherStations.Sort();

                /* Populate location scrollbar */
                populateLocationScrollbar(allWeatherStations);
                if (allWeatherStations.Count > 0)
                {
                    imei = allWeatherStations.ToArray()[ddlWhere.SelectedIndex].imei.ToString();
                }
                if (location != null)
                {
                    int index = getIndexForLocation(allWeatherStations, location);
                    if (index >= 0)
                    {
                        ddlWhere.SelectedIndex = index;
                        imei = location;
                    }
                }
                windData.SetImei(imei);
                /* Set google map location */
                addGMap(allWeatherStations[ddlWhere.SelectedIndex]);

                GenGraphs graphGenerator = new GenGraphs();
                graphGenerator.generateSensorImages(imei, windData);


                /* Get pre-stored direction and speed arrows */
                imgSpeed.ImageUrl   = "~/Images/" + imei + "_img_speed.png";
                imgCompass.ImageUrl = "~/Images/" + imei + "_img_compass.png";

                WindRecord wr = windData.GetCurrentWind();

                if (wr.Moisture != 0)
                {
                    // Set temp images
                    air_temp.ImageUrl = "~/Images/" + imei + "_img_air_temp.png";
                    power.Text        = wr.AverageWaterTemp + " V";
                    moisture.Text     = wr.Moisture + " %";

                    air_temp.ToolTip = "Air temperature: " + wr.AverageAirTemp + " °C";

                    moisture_container.Visible    = true;
                    battery_container.Visible     = true;
                    temperature_container.Visible = true;
                }
                else
                {
                    moisture_container.Visible    = false;
                    battery_container.Visible     = false;
                    temperature_container.Visible = false;
                }

                // Graphs are now generated on demand.
                graphGenerator.fetchData(2, windData);
                twentyFourHGraph.ImageUrl = graphGenerator.generateGraphOnServer(2, 1050, 250);
                graphGenerator.fetchData(1, windData);
                fiveHGraph.ImageUrl = graphGenerator.generateGraphOnServer(1, 1050, 250);
                /* Set the applet location */
                setAppletLocation(windData);
            }
            catch (Exception eee)
            {
                debug.Width  = 200;
                debug.Height = 200;
                debug.Text   = eee.Message + "\n";
                debug.Text  += eee.StackTrace;
            }
        }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String location = Request.QueryString["location"];

            Start = DateTime.Now;
            Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
            try
            {
                LogTime();
                String dbToUse = "";
                dbToUse = "Surfvind_data";

                LogTime();

                WindData wd      = new WindData(true, dbToUse);
                bool     isMySQL = Convert.ToBoolean(ConfigurationManager.AppSettings["isMySQL"]);

                List <Location> loc = wd.GetLocations();
                loc.Sort();

                locations = loc;
                /* Populate location scrollbar */
                populateLocationScrollbar(loc);
                if (loc.Count > 0)
                {
                    imei = loc.ToArray()[ddlWhere.SelectedIndex].imei.ToString();
                    wd.SetImei(imei);
                    /* Set google map location */
                    addGMap(loc[ddlWhere.SelectedIndex]);
                }

                GenGraphs t = new GenGraphs();
                t.update2(imei);


                if (location != null)
                {
                    OldSelectedIndex = ddlWhere.SelectedIndex;
                    int index = getIndexForLocation(loc, location);
                    if (index >= 0)
                    {
                        ddlWhere.SelectedIndex = index;
                        imei = location;
                        wd.SetImei(imei);
                    }
                }

                /* Get pre-stored direction and speed arrows */
                imgSpeed.ImageUrl   = "~/Images/" + imei + "_img_speed.png";
                imgCompass.ImageUrl = "~/Images/" + imei + "_img_compass.png";

                if (imei == "12345") //Set this to the IMEI nbr that you use for developement of water air and humidity temp
                {
                    // Set temp images
                    water_temp.ImageUrl = "~/Images/" + imei + "_img_water_temp.png";
                    air_temp.ImageUrl   = "~/Images/" + imei + "_img_air_temp.png";

                    int w_temp;
                    int a_temp;

                    WindRecord wr = wd.GetCurrentWind();
                    w_temp = wr.AverageWaterTemp;
                    a_temp = wr.AverageAirTemp;

                    water_temp.ToolTip = "Water temperature: " + w_temp + " °C";
                    air_temp.ToolTip   = "Air temperature: " + a_temp + " °C";
                    Label1.Text        = "Moisture: " + wr.Moisture + "%";
                }
                else
                {
                    air.Visible      = false;
                    moisture.Visible = false;
                    water.Visible    = false;
                }

                /* Set the applet location */
                setAppletLocation();


                twentyFourHGraph.ImageUrl = "~/Applet/" + imei + "/graph_2.png";
                fiveHGraph.ImageUrl       = "~/Applet/" + imei + "/graph_1.png";
            }
            catch (Exception eee)
            {
                debug.Width  = 200;
                debug.Height = 200;
                debug.Text   = eee.Message + "\n";
                debug.Text  += eee.StackTrace;
                //Response.Redirect("~/ErrorPage.aspx");
            }
        }