Ejemplo n.º 1
0
        public WeatherStation(int currentWindSpeedScanDelayMS, int commPort = 8)
            : base(currentWindSpeedScanDelayMS)
        {
            data = new Weather_Data(0, " ", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

            InitializeStation(commPort);

            ReloadWeatherDataThread          = new Thread(() => { ReloadWeatherDataRoutine(); });
            KeepReloadWeatherDataThreadAlive = true;
            ReloadWeatherDataThread.Start();
        }
        public SimulationWeatherStation(int currentWindSpeedScanDelayMS)
            : base(currentWindSpeedScanDelayMS)
        {
            Rand                 = new Random();
            lastRefreshTime      = (DateTime.Now).AddSeconds(-70);
            windDirectionCounter = 0;
            data                 = new Weather_Data(0, " ", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);


            ReloadWeatherDataThread          = null;
            KeepReloadWeatherDataThreadAlive = false;
        }
Ejemplo n.º 3
0
        public IHttpActionResult UpdateWeather_DataById(int id, Weather_Data Weather_Data)
        {
            Task <IHttpActionResult> httpActionResult = Task <IHttpActionResult> .Factory.StartNew(() =>
            {
                try
                {
                    db.Entry(Weather_Data).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    return(Ok(Weather_Data));
                }
                catch (Exception ex)
                {
                    return(BadRequest(string.Format("Error:{0}", ex.Message)));
                }
            });

            return(httpActionResult.Result);
        }
Ejemplo n.º 4
0
        public IHttpActionResult AddNewWeather_Data(Weather_Data Weather_Data)
        {
            Task <IHttpActionResult> httpActionResult = Task <IHttpActionResult> .Factory.StartNew(() =>
            {
                try
                {
                    db.Weather_Data.Add(Weather_Data);
                    db.SaveChanges();
                    return(Ok(Weather_Data));
                }
                catch (Exception ex)
                {
                    return(BadRequest(string.Format("Error:{0}", ex.Message)));
                }
            });

            return(httpActionResult.Result);
        }
Ejemplo n.º 5
0
        public IHttpActionResult UpdateWeather_DataById(int id)
        {
            Task <IHttpActionResult> httpActionResult = Task <IHttpActionResult> .Factory.StartNew(() =>
            {
                try
                {
                    Weather_Data Weather_Data = db.Weather_Data.Find(id);
                    if (Weather_Data == null)
                    {
                        return(NotFound());
                    }

                    db.Weather_Data.Remove(Weather_Data);
                    db.SaveChanges();
                    return(Ok(Weather_Data));
                }
                catch (Exception ex)
                {
                    return(BadRequest(string.Format("Error:{0}", ex.Message)));
                }
            });

            return(httpActionResult.Result);
        }