Exemplo n.º 1
0
        private static void OnTimerElapsed(object sender, ElapsedEventArgs e)
        {
            DateTime timeStamp = DateTime.UtcNow;
            //double randomPowerScouts = 0;

            int divisor = 1;

            Console.WriteLine("Going to enter time entry: " + timeStamp.ToString());
            for (int building = 0; building < GetPowerGridView.BuildingName.Length; building++)
            {
                Building         buildingInfo  = new Building(GetPowerGridView.BuildingName[building]);
                GetPowerGridView powerGridView = new GetPowerGridView();
                if (k % 60 == 0)
                {
                    divisor = k / 60;
                    powerGridView.AddPowerGridView(buildingInfo, timeStamp, true, divisor);
                }
                powerGridView.AddPowerGridView(buildingInfo, timeStamp, false, divisor);
            }
            GetSensorData sensorData = new GetSensorData();

            sensorData.AddSensorData(timeStamp);
            GetWeather weatherData = new GetWeather();

            weatherData.AddWeatherData(timeStamp);
            Console.WriteLine("Complete time entry: " + timeStamp.ToString());
            k++;
        }
Exemplo n.º 2
0
        private static void OnTimerElapsed(object sender, ElapsedEventArgs e)
        {
            try
            {
                DateTime timeStamp = DateTime.UtcNow;
                DateTime startDate = timeStamp;

                ///Get Previous Data///////////////
                if (!IsBacklogFinished)
                {
                    using (SqlConnection sqlConnection = new SqlConnection(ConfigurationSetting.ConnectionString))
                    {
                        DateTime dbLastDate = DateTime.MinValue;
                        sqlConnection.Open();
                        string getMaxTimeStampQuery = "select MAX(TimeStamp) from PowergridView";
                        using (SqlCommand cmd = new SqlCommand(getMaxTimeStampQuery, sqlConnection))
                        {
                            DateTime.TryParse(cmd.ExecuteScalar().ToString(), out dbLastDate);
                        }
                        string getMaxIdQuery = "select MAX(Id) from PowergridView";
                        using (SqlCommand cmd = new SqlCommand(getMaxIdQuery, sqlConnection))
                        {
                            object maxId = cmd.ExecuteScalar();
                            Id = maxId != DBNull.Value ? Convert.ToInt32(maxId) : 0;
                        }

                        //Date Handling
                        if (!(dbLastDate == null || dbLastDate == DateTime.MinValue || dbLastDate == default(DateTime)))
                        {
                            startDate = dbLastDate;
                        }
                        AddPreviousData(timeStamp, startDate);
                        IsBacklogFinished = true;
                    }
                }
                else //real time data population
                {
                    Console.WriteLine("Going to enter time entry: " + timeStamp.ToString());
                    for (int building = 0; building < GetPowerGridView.BuildingName.Length; building++)
                    {
                        Building         buildingInfo  = new Building(GetPowerGridView.BuildingName[building]);
                        GetPowerGridView powerGridView = new GetPowerGridView();
                        powerGridView.AddPowerGridView(buildingInfo, timeStamp);
                    }
                    GetWeather weatherData = new GetWeather();
                    weatherData.AddWeatherData(timeStamp);

                    GetSensorData sensorData = new GetSensorData();
                    for (int i = 0; i < RuntimeSensors.Count; i++)
                    {
                        sensorData.AddSensorData(timeStamp, RuntimeSensors.ElementAt(i));
                    }
                }
                Console.WriteLine("Complete time entry: " + timeStamp.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception occured " + ex.Message);
            }
        }
Exemplo n.º 3
0
        private static void OnTimerElapsed(object sender, ElapsedEventArgs e)
        {
            GetPowerGridView powerGridView = new GetPowerGridView();

            powerGridView.AddPowerGridView();
            GetSensorData sensorData = new GetSensorData();

            sensorData.AddSensorData();
            GetWeather weatherData = new GetWeather();

            weatherData.AddWeatherData();
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            GetPowerGridView powerGridView = new GetPowerGridView();

            powerGridView.AddPowerGridView();
            GetSensorData sensorData = new GetSensorData();

            sensorData.AddSensorData();
            GetWeather weatherData = new GetWeather();

            weatherData.AddWeatherData();
            //ThreadStart t1 = new ThreadStart(repeatProcess);
            //Thread childMeterThread = new Thread(t1);
            //childMeterThread.Start();
        }
Exemplo n.º 5
0
        static void AddPreviousData(DateTime currentDate, DateTime previousDate)
        {
            int minutesDifference = Convert.ToInt32((currentDate - previousDate).TotalMinutes);

            for (int i = 1; i <= minutesDifference; i++)
            {
                DateTime entryTime = previousDate.AddMinutes(i);
                for (int building = 0; building < GetPowerGridView.BuildingName.Length; building++)
                {
                    Building         buildingInfo  = new Building(GetPowerGridView.BuildingName[building]);
                    GetPowerGridView powerGridView = new GetPowerGridView();
                    powerGridView.AddPowerGridView(buildingInfo, entryTime);
                }
                Console.Write("\r Inserted value for the Day {0} ", entryTime.Date);
                GetWeather weatherData = new GetWeather();
                weatherData.AddWeatherData(entryTime);
            }
        }
Exemplo n.º 6
0
        private static void OnTimerElapsed(object sender, ElapsedEventArgs e)
        {
            DateTime timeStamp = DateTime.UtcNow;

            Console.WriteLine("Going to enter time entry: " + timeStamp.ToString());
            for (int building = 0; building < GetPowerGridView.BuildingName.Length; building++)
            {
                Building         buildingInfo  = new Building(GetPowerGridView.BuildingName[building]);
                GetPowerGridView powerGridView = new GetPowerGridView();
                powerGridView.AddPowerGridView(buildingInfo, timeStamp);
            }
            GetSensorData sensorData = new GetSensorData();

            sensorData.AddSensorData(timeStamp);
            GetWeather weatherData = new GetWeather();

            weatherData.AddWeatherData(timeStamp);
            Console.WriteLine("Complete time entry: " + timeStamp.ToString());
        }