/// <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);
            }
        }
Ejemplo n.º 3
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);
     }
 }