Пример #1
0
 private void BatteryManagement()
 {
     new Thread(() =>
     {
         while (true)
         {
             if ((ClockModel.Time.Hour >= 3) && (ClockModel.Time.Hour < 6))
             {
                 battery.StartCharging();
             }
             else if ((ClockModel.Time.Hour >= 14) && (ClockModel.Time.Hour <= 17))
             {
                 battery.StartDischarging();
             }
             else
             {
                 battery.StartIdle();
             }
             lock (BatteryViewModel.Batteries)
             {
                 BatteryViewModel.Refresh();
             }
         }
     }).Start();
 }
Пример #2
0
        public BatteryPage()
        {
            InitializeComponent();

            On <Xamarin.Forms.PlatformConfiguration.iOS>().SetUseSafeArea(true);

            BindingContext = new BatteryViewModel();
        }
Пример #3
0
        public void TimeCountStart()
        {
            selectedBattery = ComboboxBattery.SelectedItem as BatteryViewModel;
            ViewModel.GetTestData();

            timer4Stopwatch.Tick += TimerTicking;
            timer4Stopwatch.Start();
            stopwatch.Start();
        }
Пример #4
0
 public SHES(BatteryViewModel bt, UtilityViewModel ut, SolarPanelViewModel sp, ConsumerViewModel cs, eVehicleChargerViewModel ev, ChartViewModel ch)
 {
     battery  = bt;
     utility  = ut;
     solar    = sp;
     consumer = cs;
     vehicle  = ev;
     chart    = ch;
     BatteryManagement();
     eVehicleManagement();
 }
Пример #5
0
        public SHES(BatteryViewModel batteryViewModel, UtilityViewModel utilityViewModel, SolarPanelViewModel solarPanelViewModel, ConsumersViewModel consumersViewModel)
        {
            battery   = batteryViewModel;
            utility   = utilityViewModel;
            solar     = solarPanelViewModel;
            consumers = consumersViewModel;

            LoadDevices();

            BatteryManagement();
            createListener();
            MakeLog();
        }
Пример #6
0
        private void ButtonAdd_Click(object sender, RoutedEventArgs e)
        {
            if (Validate(textBoxName) && Validate(textBoxMaxPower) && Validate(textBoxCapacity))
            {
                bool   p = false, c = false;
                double pp = 0, cc = 0;
                p = double.TryParse(textBoxMaxPower.Text, out pp);
                c = double.TryParse(textBoxCapacity.Text, out cc);
                if (p && c && pp >= 0 && cc >= 0)
                {
                    lock (BatteryViewModel.Batteries)
                    {
                        BatteryViewModel.Batteries.Add(new BatteryModel(textBoxName.Text, Double.Parse(textBoxMaxPower.Text), Double.Parse(textBoxCapacity.Text), 0));

                        using (dbSHESEntities entity = new dbSHESEntities())
                        {
                            BatteryTable bmt = new BatteryTable()
                            {
                                Name            = textBoxName.Text,
                                MaxPower        = Double.Parse(textBoxMaxPower.Text),
                                Capacity        = Double.Parse(textBoxCapacity.Text),
                                CurrentCapacity = 0,
                                CapacityMin     = 0,
                                State           = Enums.BatteryEnum.IDLE.ToString()
                            };
                            entity.BatteryTables.Add(bmt);
                            entity.SaveChanges();
                        }

                        BatteryViewModel.Refresh();
                    }
                }
                else
                {
                    MessageBox.Show("Incorrect input", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                MessageBox.Show("Incorrect input", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Пример #7
0
        public BatteryListView(bool isDataEditable)
        {
            _isDataEditable = isDataEditable;
            //
            InitializeComponent();

            vm             = new BatteryViewModel();
            BindingContext = vm;

            // Load the Activity Log report into ListView class.
            vm.LoadBatteryList();
            //
            ToolbarItem tbi = null;

            if (Device.OS == TargetPlatform.iOS)
            {
                tbi = new ToolbarItem("+", null, () => {
                    var RCItem = new InventoryItemList();
                    // create a new details view with the item
                    var view = new RCInventoryDetailsView(RCItem, App.ItemCategory_BATTERY);
                    //// tell the navigator to show the new view
                    Navigation.PushAsync(view);
                }, 0, 0);
            }
            if (Device.OS == TargetPlatform.Android)
            { // BUG: Android doesn't support the icon being null
                tbi = new ToolbarItem("+", "plus", () =>
                {
                    var RCItem = new InventoryItemList();
                    // create a new details view with the item
                    var view = new RCInventoryDetailsView(RCItem, App.ItemCategory_BATTERY);
                    //// tell the navigator to show the new view
                    Navigation.PushAsync(view);
                }, 0, 0);
            }
            //
            ToolbarItems.Add(tbi);
            //
            lblNoOfItems.Text = "No. of Batteries: " + vm.BatteryLV.Count.ToString();
        }
Пример #8
0
 private void ComboboxBattery_DropDownClosed(object sender, object e)
 {
     if (ComboboxBattery.SelectedItem != null)
     {
         selectedBattery = ComboboxBattery.SelectedItem as BatteryViewModel;
         if (selectedBattery?.Name == "Add New Battery...")
         {
             NewBatteryFlyout.ShowAt((FrameworkElement)sender);
         }
         else if (selectedBattery != null)
         {
             TextDate.Text         = " " + DateTime.Today.ToShortDateString();
             TextBatteryName.Text  = " " + selectedBattery.Name;
             TextCapacity.Text     = " " + selectedBattery.Capacity.ToString() + "mAh";
             TextImpedance.Text    = " " + selectedBattery.InitInternalImpedance.ToString() + "mΩ";
             TextCyclelife.Text    = " " + selectedBattery.NominalCycleLife.ToString();
             TextCurrentCycle.Text = " " + selectedBattery.PerformedCycle.ToString();
             TextVoltage.Text      = " " + selectedBattery.Voltage.ToString() + "V";
             TextDOD.Visibility    = Visibility.Visible;
         }
     }
 }
Пример #9
0
        public Edit(int id)
        {
            InitializeComponent();
            this.Battery     = ContextToViewModel.Convert(_AppContext.Batteries.Single(t => t.Id == id));
            this.DataContext = this.Battery;

            var trays = _AppContext.Trays.ToList();

            this.proctray.Items.Add("——未知——");
            trays.ForEach(o => this.proctray.Items.Add(o.Code));
            var proctray_index = -1;

            if (this.Battery.ProcTrayId < 1)
            {
                proctray_index = 0;
            }
            else
            {
                var procTray = GetObject.GetById <Model.ProcTray>(this.Battery.ProcTrayId);
                proctray_index = trays.IndexOf(trays.FirstOrDefault(o => o.Id == procTray.TrayId)) + 1;
            }
            this.proctray.SelectedIndex = proctray_index;
        }
Пример #10
0
        private async void NewBatteryButton_Click(object sender, RoutedEventArgs e)
        {
            Battery          _newBattery          = new Battery();
            BatteryViewModel _newBatteryViewModel = new BatteryViewModel(_newBattery);

            _newBatteryViewModel.IsNewBattery = true;

            _newBatteryViewModel.Name     = newBatteryName.Text;
            _newBatteryViewModel.Voltage  = float.Parse(newBatteryVoltage.Text, CultureInfo.InvariantCulture.NumberFormat);
            _newBatteryViewModel.Capacity = Convert.ToInt32(newBatteryCapacity.Text);
            _newBatteryViewModel.InitInternalImpedance = Convert.ToInt32(newBatteryImpedence.Text);
            _newBatteryViewModel.NominalCycleLife      = Convert.ToInt32(newBatteryCycleLife.Text);

            NewBatteryFlyout.Hide();

            await _newBatteryViewModel.SaveBatteryAsync();



            // Show notification of new Battery has been saved successfully
            int duration = 2000;

            NewBatteryNotification.Show("New Battery has been saved successfully", duration);
        }
Пример #11
0
        public BatteryView()
        {
            InitializeComponent();

            BindingContext = new BatteryViewModel();
        }
Пример #12
0
        public async Task <IActionResult> ReceiveBatteryData([FromBody] BatteryViewModel batteryData)
        {
            await _hubContext.Clients.All.SendAsync("BatteryReceive", batteryData.BatteryPct, batteryData.IsCharging);

            return(Ok());
        }
Пример #13
0
 public Details(int id)
 {
     InitializeComponent();
     this.Battery     = ContextToViewModel.Convert(_AppContext.Batteries.Single(t => t.Id == id));
     this.DataContext = this.Battery;
 }