/// <summary> /// Execute the scan of the ADCP. /// </summary> private void ExecuteScanAdcp() { if (_pm.IsProjectSelected) { _pm.SelectedProject = _adcpConnection.SetAdcpConfiguration(_pm.SelectedProject); } Application.Current.Dispatcher.BeginInvoke(new System.Action(() => { // Set the deployment days if it has changed //DeploymentDays = _pm.SelectedProject.Configuration.DeploymentOptions.Duration; if (_pm.SelectedProject.Configuration.DeploymentOptions.Duration <= 0) { DeploymentDays = 1.0; } else { DeploymentDays = _pm.SelectedProject.Configuration.DeploymentOptions.Duration; } // Clear the previous list and then populate it SubsystemConfigList.Clear(); // Create temp variables long dataSize = 0; double numberBattery = 0.0; foreach (AdcpSubsystemConfig ssCfg in _pm.SelectedProject.Configuration.SubsystemConfigDict.Values) { // Create the VM and add it to the list AdcpSubsystemConfigurationViewModel ssVM = new AdcpSubsystemConfigurationViewModel(ssCfg, this); //ssVM.Predictor.DeploymentDuration = _pm.SelectedProject.Configuration.DeploymentOptions.Duration; //ssVM.Predictor.BatteryType = _pm.SelectedProject.Configuration.DeploymentOptions.BatteryType; // Add the vm to the list SubsystemConfigList.Add(ssVM); // Calculate the prediction model ssVM.CalcPrediction(); // Accumluate the data sizes and number batteries for each subsystem configuration dataSize += ssVM.GetDataSize(); numberBattery += ssVM.NumberBatteryPacks; } // Update the deployment duration to include all the new configurations // The duration needs to be divided amoung all the configuration UpdateDeploymentDuration(); // Set the combined values NumberBatteryPacks = numberBattery.ToString("0.00"); PredictedStorageUsed = dataSize + InternalStorageUsed; DataSize = MathHelper.MemorySizeString(dataSize); UpdateProperties(); // Turn off flag IsScanning = false; })); }
/// <summary> /// Remove the configuration from the list. /// </summary> /// <param name="ssConfigVM">ViewModel to remove from the list.</param> public void RemoveConfiguration(AdcpSubsystemConfigurationViewModel ssConfigVM) { // Shutdown the view model ssConfigVM.Dispose(); // Remove from the list SubsystemConfigList.Remove(ssConfigVM); if (_pm.IsProjectSelected) { // Remove the subsystem config from the project if (_pm.SelectedProject.Configuration.SubsystemConfigDict.ContainsKey(ssConfigVM.ConfigKey)) { _pm.SelectedProject.Configuration.RemoveAdcpSubsystemConfig(_pm.SelectedProject.Configuration.SubsystemConfigDict[ssConfigVM.ConfigKey]); } // Save the new configuration _pm.SelectedProject.Save(); } // Update the display this.NotifyOfPropertyChange(() => this.SubsystemConfigList); this.NotifyOfPropertyChange(() => this.CEPO); this.NotifyOfPropertyChange(() => this.CEPO_DescStr); this.NotifyOfPropertyChange(() => this.SerialNumberStr); // this will update the predictions UpdateDeploymentDays(_DeploymentDays); // Create a new Ping Model UpdatePingModel(); }
/// <summary> /// Get the configuration from the selected project. /// </summary> private void GetConfiguation() { if (_pm.IsProjectSelected) { // Create temp variables long dataSize = 0; double numberBattery = 0.0; foreach (AdcpSubsystemConfig ssCfg in _pm.SelectedProject.Configuration.SubsystemConfigDict.Values) { // Create the VM and add it to the list AdcpSubsystemConfigurationViewModel ssVM = new AdcpSubsystemConfigurationViewModel(ssCfg, this); // ssVM.Predictor.DeploymentDuration = _pm.SelectedProject.Configuration.DeploymentOptions.Duration; // ssVM.Predictor.BatteryType = _pm.SelectedProject.Configuration.DeploymentOptions.BatteryType; // Add the vm to the list SubsystemConfigList.Add(ssVM); // Accumluate the data sizes and number batteries for each subsystem configuration dataSize += ssVM.GetDataSize(); numberBattery += ssVM.NumberBatteryPacks; } // Set the combined values NumberBatteryPacks = numberBattery.ToString("0.00"); PredictedStorageUsed = dataSize + InternalStorageUsed; DataSize = MathHelper.MemorySizeString(dataSize); } }