示例#1
0
        public void fetchData(int interval, WindData wd)
        {
            try
            {
                DateTime          endInterval   = DateTime.Now;
                DateTime          beginInterval = GetStartInterval(interval, endInterval);
                List <float>      dirValues     = new List <float>();
                List <string>     timeLabels    = new List <string>();
                List <float>      speedValues   = new List <float>();
                List <float>      minValues     = new List <float>();
                List <float>      maxValues     = new List <float>();
                List <WindRecord> windData      = wd.GetListBetweenDate2(beginInterval, endInterval);

                foreach (WindRecord w in windData)
                {
                    minValues.Add(w.MinSpeed);
                    maxValues.Add(w.MaxSpeed);
                    speedValues.Add(w.AverageSpeed);
                    timeLabels.Add(w.Time.ToShortDateString() + "*" + w.Time.ToShortTimeString());
                    dirValues.Add(w.AverageDirection);
                }
                this.dirValues      = dirValues.ToArray();
                this.speedValues    = speedValues.ToArray();
                this.timeLabels     = timeLabels.ToArray();
                this.minSpeedValues = minValues.ToArray();
                this.maxSpeedValues = maxValues.ToArray();
            }catch
            {
            }
        }
示例#2
0
        public void generateGraph(int interval, String imei, WindData wd)
        {
            Start = DateTime.Now;
            try
            {
                DateTime endInterval   = DateTime.Now;
                DateTime beginInterval = GetStartInterval(interval, endInterval);
                LogTime();

                WindRecord currentWind = wd.GetCurrentWind();
                if (currentWind.Time < DateTime.Now.AddHours(-1))
                {
                    currentWind.AverageSpeed     = 0;
                    currentWind.MinSpeed         = 0;
                    currentWind.MaxSpeed         = 0;
                    currentWind.AverageDirection = 0;
                    currentWind.MinDirection     = 0;
                    currentWind.MaxDirection     = 0;
                }
                List <float>  dirValues   = new List <float>();
                List <string> timeLabels  = new List <string>();
                List <float>  speedValues = new List <float>();
                List <float>  minValues   = new List <float>();
                List <float>  maxValues   = new List <float>();
                LogTime();
                List <WindRecord> windData = wd.GetListBetweenDate2(beginInterval, endInterval);
                LogTime();

                foreach (WindRecord w in windData)
                {
                    minValues.Add(w.MinSpeed);
                    maxValues.Add(w.MaxSpeed);
                    speedValues.Add(w.AverageSpeed);
                    timeLabels.Add(w.Time.ToShortDateString() + "*" + w.Time.ToShortTimeString());
                    dirValues.Add(w.AverageDirection);
                }
                LogTime();

                this.dirValues      = dirValues.ToArray();
                this.speedValues    = speedValues.ToArray();
                this.timeLabels     = timeLabels.ToArray();
                this.minSpeedValues = minValues.ToArray();
                this.maxSpeedValues = maxValues.ToArray();
                LogTime();

                /* TODO, move this functionality to an own method since we only need to do this once
                 * For no, lets settle with a check if this is the first time for any given location
                 */
                if (interval == 0)
                {
                    String path = HttpContext.Current.Server.MapPath("~/") + "Images/" + imei;
                    if (!System.IO.Directory.Exists(path))
                    {
                        System.IO.Directory.CreateDirectory(path);
                    }

                    Helper.GetWindSpeedPic(currentWind.AverageSpeed, currentWind.MinSpeed, currentWind.MaxSpeed, Server).Save(Server.MapPath("~/Images/" + imei + "_img_speed.png"));
                    LogTime();
                    Helper.GetCompassPic(currentWind.AverageDirection, currentWind.MinDirection, currentWind.MaxDirection, Server).Save(Server.MapPath("~/Images/" + imei + "_img_compass.png"));
                    LogTime();

                    /* Create temperature images */
                    int water_temp;
                    int air_temp;

                    water_temp = currentWind.AverageWaterTemp;
                    air_temp   = currentWind.AverageAirTemp;
                    String test = Server.MapPath("~/Images/" + imei + "_img_water_temp.png");
                    Helper.getTempImage(water_temp).Save(Server.MapPath("~/Images/" + imei + "_img_water_temp.png"));
                    Helper.getTempImage(air_temp).Save(Server.MapPath("~/Images/" + imei + "_img_air_temp.png"));
                }
            }
            catch
            {
                int a = 0;
                a++;
                Debug.WriteLine("Problem1");
            }
        }