Beispiel #1
0
        /// <summary>
        /// Load the project and get all the data.
        /// </summary>
        /// <param name="fileName">File path of the project.</param>
        /// <param name="ssConfig">Subsystem configuration. If Null display all the data</param>
        /// <param name="minIndex">Minimum ensemble index to display.</param>
        /// <param name="maxIndex">Minimum ensemble index to display.</param>
        public virtual void LoadProject(string fileName, SubsystemConfiguration ssConfig, int minIndex = 0, int maxIndex = 0)
        {
            // Set the selected values
            _ProjectFilePath = fileName;
            this.NotifyOfPropertyChange(() => this.ProjectFilePath);

            // Set the select Subsystem configuration
            SubsystemConfig = ssConfig;

            // Reset settings
            _firstLoad = true;

            // Clear the current list and get the new file list from the project
            Application.Current.Dispatcher.Invoke((Action) delegate
            {
                ProjectFileList.Clear();
            });

            GetFileList(fileName);

            // Clear the current list and get the new subsystem configurations list from the project
            Application.Current.Dispatcher.Invoke((Action) delegate
            {
                SubsystemConfigList.Clear();
            });

            // Populate the list of all available subsystem configurations
            GetSubsystemConfigList(fileName);

            // Select the configuration based off the subsystem configuration given
            SelectSubsystemConfig(ssConfig);
        }
        /// <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>
        /// 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>
        /// 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);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Populate the list with all the available unique subsystem configurations in the project.
        /// </summary>
        /// <param name="fileName">File path of project.</param>
        protected void GetSubsystemConfigList(string fileName)
        {
            try
            {
                // Create data Source string
                string dataSource = string.Format("Data Source={0};Version=3;", fileName);

                // Create a new database connection:
                using (SQLiteConnection cnn = new SQLiteConnection(dataSource))
                {
                    // Open the connection:
                    cnn.Open();

                    // Ensure a connection was made
                    if (cnn == null)
                    {
                        return;
                    }

                    // Create a command to query
                    using (DbCommand cmd = cnn.CreateCommand())
                    {
                        string query = string.Format("SELECT DISTINCT Subsystem,CepoIndex FROM {0};", "tblEnsemble");
                        cmd.CommandText = query;

                        // Get all the results
                        DbDataReader reader = cmd.ExecuteReader();
                        while (reader.Read())
                        {
                            if (reader == null)
                            {
                                break;
                            }

                            // Subsystem
                            string subsystem = reader["Subsystem"].ToString();
                            string cepoIndex = reader["CepoIndex"].ToString();
                            string result    = string.Format("[{0}]-{1}", subsystem, cepoIndex);

                            // Add file name to list
                            SubsystemConfigList.Add(new SubsystemEntry()
                            {
                                IsCheckable = true, IsChecked = true, Command = SubsystemSelectionCommand, Subsystem = subsystem, CepoIndex = cepoIndex
                            });
                        }
                    }
                }
            }
            catch (SQLiteException e)
            {
                Debug.WriteLine("Error using database to get file names", e);
                return;
            }
            catch (Exception e)
            {
                Debug.WriteLine("Error using database to get file names", e);
                return;
            }
        }
 /// <summary>
 /// Add a configuration to the dictionary of subsystem configuraitons.
 /// </summary>
 /// <param name="ssConfig">Subystem Configuration</param>
 private void AddConfiguration(SubsystemConfiguration ssConfig)
 {
     // Add an entry to the dictionary
     if (!SubsysOptions.ContainsKey(ssConfig.IndexCodeString()))
     {
         SubsysOptions.Add(ssConfig.IndexCodeString(), new SubsystemOptions(ssConfig));
         SubsystemConfigList.Add(ssConfig);
     }
 }
        /// <summary>
        /// Clear the list of all the configurations.
        /// This will properly shutdown the view model
        /// and then clear the list.
        /// </summary>
        private void ClearConfigurationList()
        {
            // Shutdown all the view models
            for (int x = 0; x < SubsystemConfigList.Count; x++)
            {
                SubsystemConfigList[x].Dispose();
            }

            // Clear the list
            SubsystemConfigList.Clear();
        }
        /// <summary>
        /// Get the Average options from the dictionary.  This will
        /// check if the subsystem configuration is in the hashset.
        /// If it is in the hashset, it will get the Average options.
        /// If it is not, it will return a default configuration.
        /// </summary>
        /// <param name="ssConfig">Subsystem configuration to check.</param>
        /// <returns>Screen options.</returns>
        public AverageSubsystemConfigOptions GetAverageOptions(SubsystemConfiguration ssConfig)
        {
            AverageSubsystemConfigOptions options = null;

            if (SubsystemConfigList.Contains(ssConfig))
            {
                options = SubsysOptions[ssConfig.IndexCodeString()].AverageOptions;
            }
            else
            {
                options = new AverageSubsystemConfigOptions();
            }

            return(options);
        }
        /// <summary>
        /// Get the Screen options from the dictionary.  This will
        /// check if the subsystem configuration is in the hashset.
        /// If it is in the hashset, it will get the Screen options.
        /// If it is not, it will return a default configuration.
        /// </summary>
        /// <param name="ssConfig">Subsystem configuration to check.</param>
        /// <returns>Screen options.</returns>
        public ScreenSubsystemConfigOptions GetScreenOptions(SubsystemConfiguration ssConfig)
        {
            ScreenSubsystemConfigOptions options = null;

            if (SubsystemConfigList.Contains(ssConfig))
            {
                options = SubsysOptions[ssConfig.IndexCodeString()].ScreenOptions;
            }
            else
            {
                options = new ScreenSubsystemConfigOptions();
            }

            return(options);
        }
        /// <summary>
        /// Get the Graphical options from the dictionary.  This will
        /// check if the subsystem configuration is in the hashset.
        /// If it is in the hashset, it will get the Graphical options.
        /// If it is not, it will return a default configuration.
        /// </summary>
        /// <param name="ssConfig">Subsystem configuration to check.</param>
        /// <returns>Graphical options.</returns>
        public ViewDataGraphicalOptions GetGraphicalOptions(SubsystemConfiguration ssConfig)
        {
            ViewDataGraphicalOptions options = null;

            if (SubsystemConfigList.Contains(ssConfig))
            {
                options = SubsysOptions[ssConfig.IndexCodeString()].GraphicalOptions;
            }
            else
            {
                options = new ViewDataGraphicalOptions();
            }

            return(options);
        }
        /// <summary>
        /// Get the text options from the hashset.  This will
        /// check if the subsystem configuration is in the hashset.
        /// If it is in the hashset, it will get the text options.
        /// If it is not, it will return a default configuration.
        /// </summary>
        /// <param name="ssConfig">Subsystem configuration to check.</param>
        /// <returns>Text options.</returns>
        public TextSubsystemConfigOptions GetTextOptions(SubsystemConfiguration ssConfig)
        {
            TextSubsystemConfigOptions options = null;

            if (SubsystemConfigList.Contains(ssConfig))
            {
                options = SubsysOptions[ssConfig.IndexCodeString()].TextOptions;
            }
            else
            {
                options = new TextSubsystemConfigOptions();
            }

            return(options);
        }
        /// <summary>
        /// Save the Average SubsystemConfiguration options to the project database.
        /// This will store the options so the user can retreive them when the project
        /// is loaded again.
        /// </summary>
        /// <param name="ssConfig">Subsystem Configuration.</param>
        /// <param name="options">Average SubsystemConfiguration options.</param>
        public void SaveAverageOptions(SubsystemConfiguration ssConfig, AverageSubsystemConfigOptions options)
        {
            // Check if the subsystem exist in the dictionary
            if (SubsystemConfigList.Contains(ssConfig))
            {
                // Store the graphical options to the SubsystemConfig entry
                SubsysOptions[ssConfig.IndexCodeString()].AverageOptions = options;
            }
            else
            {
                // Add new subsystem configuration
                AddConfiguration(ssConfig);

                // Store the new options if the entry could be made
                if (SubsystemConfigList.Contains(ssConfig))
                {
                    // Store the graphical options to the SubsystemConfig entry
                    SubsysOptions[ssConfig.IndexCodeString()].AverageOptions = options;
                }
            }

            // Store the new options to the project DB
            SaveOptions();
        }
        /// <summary>
        /// Get the Validation View options from the dictionary.  This will
        /// check if the subsystem configuration is in the hashset.
        /// If it is in the hashset, it will get the Validation View options.
        /// If it is not, it will return a default configuration.
        /// </summary>
        /// <param name="ssConfig">Subsystem configuration to check.</param>
        /// <returns>Validation View options.</returns>
        public ValidationTestViewOptions GetValidationViewOptions(SubsystemConfiguration ssConfig)
        {
            ValidationTestViewOptions options = null;

            if (SubsystemConfigList.Contains(ssConfig))
            {
                options = SubsysOptions[ssConfig.IndexCodeString()].ValidationViewOptions;
            }
            else
            {
                // If there are any exist, use the first one
                if (SubsystemConfigList.Count > 0)
                {
                    options = SubsysOptions.First().Value.ValidationViewOptions;
                }
                else
                {
                    // No exist, so create a default option
                    options = new ValidationTestViewOptions();
                }
            }

            return(options);
        }