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