Exemplo n.º 1
0
        public void CalculateProduction()
        {
            new Thread(() =>
            {
                while (true)
                {
                    Thread.Sleep(500);
                    double product = SolarPanelViewModel.SolarPanelProduction() + BatteryViewModel.BatteryProduction();
                    double cons    = ConsumerViewModel.ConsumerConsumption() + BatteryViewModel.BatteryConsumption() + eVehicleChargerViewModel.VehicleConsumption();

                    Utilities[0].Production    = product;
                    Utilities[0].Consumption   = cons;
                    Utilities[0].ExchangePower = product - cons;
                    Utilities[0].Price         = Utilities[0].ExchangePower * 0.2;

                    Thread.Sleep(500);
                }
            }).Start();
        }
Exemplo n.º 2
0
        public void CalculateChartProduction()
        {
            int    date            = DateTime.Now.Date.Day;
            double panels          = 0;
            double product         = 0;
            double cons            = 0;
            double batteryPositive = 0;
            double batteryNegative = 0;
            double exhangePositive = 0;
            double exhangeNegative = 0;
            double consumers       = 0;
            double price           = 0;
            double temp            = 0;
            double cnt             = 0;

            new Thread(() =>
            {
                while (true)
                {
                    if (temp == 60)
                    {
                        temp = 0;
                        cnt++;
                    }
                    else
                    {
                        temp += ClockModel.Time.Minute;
                    }
                    if (cnt == 23)
                    {
                        cnt  = 0;
                        temp = 0;
                        using (dbSHESEntities entity = new dbSHESEntities())
                        {
                            ChartTable ct = new ChartTable()
                            {
                                Date               = date.ToString(),
                                SolarPanel         = price,
                                BaterryProduction  = batteryPositive,
                                BatteryConsumption = batteryNegative,
                                ExchangePositive   = exhangePositive,
                                ExchangeNegative   = exhangeNegative,
                                Consumer           = consumers,
                                Price              = price
                            };
                            entity.ChartTables.Add(ct);
                            entity.SaveChanges();
                        }
                        date++;
                    }
                    panels          += SolarPanelViewModel.SolarPanelProduction();
                    product          = SolarPanelViewModel.SolarPanelProduction() + BatteryViewModel.BatteryProduction();
                    cons             = ConsumerViewModel.ConsumerConsumption() + BatteryViewModel.BatteryConsumption() + eVehicleChargerViewModel.VehicleConsumption();
                    exhangePositive += product;
                    exhangeNegative += cons;
                    batteryPositive += BatteryViewModel.BatteryProduction();
                    batteryNegative += BatteryViewModel.BatteryConsumption();
                    consumers       += ConsumerViewModel.ConsumerConsumption();
                    price            = price + (product - cons) * 0.2;
                    Thread.Sleep(1000);
                }
            }).Start();
        }