Example #1
0
        /// <summary>
        /// Get the CEPO configuration character and index within the CEPO command.
        /// The configuration character is the Subsystem code for the configuration.  It
        /// represents the system type.  The Index represents where in teh CEPO command
        /// the configuration was located.  This determines the ping order of the configurations.
        /// It also make the configuration unique for a SubsystemConfiguration for a Subsystem.
        /// Get the Subsystem using the serial number and subsystem code.
        ///
        /// SubsystemConfiguaration CommandSetup: Index of the Configuration within Subsystem.  (Based off counting configurations for a subsystem)
        /// index: Location in CEPO for the Subsystem configuration.
        /// </summary>
        /// <param name="ssCode">Subsystem Code from the CEPO command.</param>
        /// <param name="cepoIndex">Location in the CEPO command of the Subsystem Code.</param>
        /// <param name="serial">Serial number for the ADCP.</param>
        /// <returns>Return the AdcpSubsystemConfig created or null if one could not be created.</returns>
        private AdcpSubsystemConfig AddConfig(byte ssCode, int cepoIndex, SerialNumber serial)
        {
            AdcpSubsystemConfig asConfig = null;

            // Get the Subsystem index from the serial number
            // If it cannot be found in the serial number, then it is
            // a bad Subsystem and we can not use the command.
            Subsystem ss = serial.GetSubsystem(ssCode);

            if (!ss.IsEmpty())
            {
                // Determine how many of the given subsystem have been added to the dictionary
                // We need to generate SubsystemConfiguration index value.
                // SubsystemConfiguration index is based off the number of SubsystemConfigurations already
                // in the dictionary before this configuration is added.
                ushort ssCount = 0;
                foreach (AdcpSubsystemConfig configuration in SubsystemConfigDict.Values)
                {
                    // If the subsystems are the same, then increment the value
                    if (configuration.SubsystemConfig.SubSystem.Code == ssCode)
                    {
                        ssCount++;
                    }
                }

                // Create all the subsystem configurations and add to the dictionary
                SubsystemConfiguration ssConfig = new SubsystemConfiguration(ss, (byte)cepoIndex, (byte)ssCount);   // SubsystemConfiguration with the CEPO index and Index of the SubsystemConfiguration
                asConfig = new AdcpSubsystemConfig(ssConfig);                                                       // AdcpSubsystemConfig with the Subsystem, SubsystemConfig and CEPO index
                SubsystemConfigDict.Add(asConfig.ToString(), asConfig);                                             // Add to the dictionary the configuration with the string as the key
            }

            return(asConfig);
        }
Example #2
0
        /// <summary>
        /// Add a configuration to the dictionary.  This will create an AdcpSubsystemConfig based
        /// off the Subsystem and CEPO index given.  It will then add it to the dictionary.  It will
        /// then return the created AdcpSubsystemConfig.  If the AdcpSubsystemConfig could not be
        /// created, null will be returned.
        /// </summary>
        /// <param name="ss">Subsystem to add a configuration.</param>
        /// <param name="cepoIndex">CEPO index.</param>
        /// <returns>AdcpSubsystemConfig created with the given settings or null if one could not be created.</returns>
        private AdcpSubsystemConfig AddConfig(Subsystem ss, int cepoIndex)
        {
            AdcpSubsystemConfig asConfig = null;

            // If a bad Subsystem is given, we cannot use it
            if (!ss.IsEmpty())
            {
                // Determine how many of the given subsystem have been added to the dictionary
                // We need to generate SubsystemConfiguration index value.
                // SubsystemConfiguration index is based off the number of SubsystemConfigurations already
                // in the dictionary before this configuration is added.
                ushort ssCount = 0;
                foreach (AdcpSubsystemConfig configuration in SubsystemConfigDict.Values)
                {
                    // If the subsystems are the same, then increment the value
                    if (configuration.SubsystemConfig.SubSystem.Code == ss.Code)
                    {
                        ssCount++;
                    }
                }

                // Create all the subsystem configurations and add to the dictionary
                SubsystemConfiguration ssConfig = new SubsystemConfiguration(ss, (byte)cepoIndex, (byte)ssCount); // SubsystemConfiguration with the Index of the SubsystemConfiguration
                asConfig = new AdcpSubsystemConfig(ssConfig);                                                     // AdcpSubsystemConfig with the Subsystem, SubsystemConfig and CEPO index
                if (!SubsystemConfigDict.ContainsKey(asConfig.ToString()))
                {
                    SubsystemConfigDict.Add(asConfig.ToString(), asConfig);
                }
            }

            return(asConfig);
        }
Example #3
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>
        /// Initialize the values and set the default values.
        /// </summary>
        /// <param name="ssConfig">Subsystem configuration for these options.</param>
        public AverageSubsystemConfigOptions(SubsystemConfiguration ssConfig)
        {
            // Initialize values
            SubsystemConfig = ssConfig;

            // Set the default values
            AvgOptions = new AverageOptions();
        }
        /// <summary>
        /// Validation view options.
        /// </summary>
        /// <param name="ssConfig">Subsystem Configuration.</param>
        public ValidationTestViewOptions(SubsystemConfiguration ssConfig)
        {
            // Set the subsystem
            SubsystemConfig = ssConfig;

            // Set default values
            SetDefaults();
        }
Example #6
0
        /// <summary>
        /// Use this constructor if all the settings are going to be
        /// set by the user.
        ///
        /// Need to set the subsystem after contructing.
        /// Subsystem will be set to empty when constructed.
        /// </summary>
        public TextSubsystemConfigOptions()
        {
            // Set empty subsystem.
            SubsystemConfig = new SubsystemConfiguration();

            // Set default values
            SetDefaults();
        }
Example #7
0
        /// <summary>
        /// Set the subsystem and set the
        /// default values.
        /// </summary>
        /// <param name="ssConfig">SubsystemConfiguration associated these options.</param>
        public TextSubsystemConfigOptions(SubsystemConfiguration ssConfig)
        {
            // Set the subsystem
            SubsystemConfig = ssConfig;

            // Set default values
            SetDefaults();
        }
Example #8
0
        /// <summary>
        /// Use this constructor if all the settings are going to be
        /// set by the user.
        ///
        /// Need to set the subsystem after contructing.
        /// Subsystem will be set to empty when constructed.
        /// </summary>
        public BackscatterOptions()
        {
            // Set the subsystem
            SubsystemConfig = new SubsystemConfiguration();

            // Set default values
            SetDefaults();
        }
Example #9
0
        /// <summary>
        /// Set the subsystem and set the
        /// default values.
        /// </summary>
        /// <param name="ssConfig">SubsystemConfiguration associated these options.</param>
        public BackscatterOptions(SubsystemConfiguration ssConfig)
        {
            // Set the subsystem
            SubsystemConfig = ssConfig;

            // Set default values
            SetDefaults();
        }
        /// <summary>
        /// Load the project.  Use the selected min and max index to select the ensemble range to display.
        /// </summary>
        /// <param name="fileName">Project file path.</param>
        /// <param name="minIndex">Minimum Ensemble index.</param>
        /// <param name="maxIndex">Maximum Ensemble index.</param>
        public override void LoadProject(string fileName, SubsystemConfiguration ssConfig, int minIndex = 0, int maxIndex = 0)
        {
            // Load the base calls
            base.LoadProject(fileName, ssConfig, minIndex, maxIndex);

            // Plot the data
            ReplotData(minIndex, maxIndex);
        }
Example #11
0
        /// <summary>
        /// Initialize the values and set the default values.
        /// </summary>
        /// <param name="ssConfig">Subsystem configuration for these options.</param>
        public ScreenSubsystemConfigOptions(SubsystemConfiguration ssConfig)
        {
            // Initialize values
            SubsystemConfig = ssConfig;

            // Set the default values
            SetDefaults();
        }
 /// <summary>
 /// Initialize the object.
 /// </summary>
 /// <param name="ssConfig">Set the Subsystem Configuration.</param>
 public SubsystemOptions(SubsystemConfiguration ssConfig)
 {
     TextOptions           = new TextSubsystemConfigOptions(ssConfig);
     GraphicalOptions      = new ViewDataGraphicalOptions(ssConfig);
     ScreenOptions         = new ScreenSubsystemConfigOptions(ssConfig);
     AverageOptions        = new AverageSubsystemConfigOptions(ssConfig);
     ValidationViewOptions = new ValidationTestViewOptions(ssConfig);
 }
        /// <summary>
        /// Get the options for this subsystem display
        /// from the database.  If the options have not
        /// been set to the database yet, default values
        /// will be used.
        /// </summary>
        private void GetOptionsFromDatabase()
        {
            var ssConfig = new SubsystemConfiguration(_Config.SubSystem, _Config.CepoIndex, _Config.SubsystemConfigIndex);

            _Options = _pm.AppConfiguration.GetScreenOptions(ssConfig);

            // Notify all the properties
            this.NotifyOfPropertyChange();
        }
 /// <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>
        /// Save the options to the project.
        /// </summary>
        private void SaveOptions()
        {
            // SubsystemDataConfig needs to be converted to a SubsystemConfiguration
            // because the SubsystemConfig will be compared in AppConfiguration to determine
            // where to save the settings.  Because SubsystemDataConfig and SubsystemConfiguration
            // are not the same type, it will not pass Equal()
            var ssConfig = new SubsystemConfiguration(_Config.SubSystem, _Config.CepoIndex, _Config.SubsystemConfigIndex);

            _pm.AppConfiguration.SaveScreenOptions(ssConfig, _Options);
        }
Example #16
0
        /// <summary>
        /// Generate the string for a AdcpSubsystemConfig. Typically the
        /// ToString() is used as a key for the AdcpSubsystemConfig object.
        /// This will generate a string for the key so that an AdcpSubsystemConfig
        /// can be found in a dictionary.
        ///
        /// [SSCONFIG] SSDesc
        ///
        /// NOTE
        /// If the subsystem is an old revision of firmware,
        /// the subsystem code will be an index
        /// instead of the code.  Use the index and the
        /// serial number to determine the string.
        ///
        /// </summary>
        /// <param name="ssConfig">SubsystemConfiguration for the AdcpSubsystemConfig.</param>
        /// <returns>String for the AdcpSubsystemConfig if it used the given Subsystem and SubsystemConfiguration.</returns>
        public static string GetString(SubsystemConfiguration ssConfig)
        {
            // NOTE
            // If the subsystem is an old revision of firmware,
            // the subsystem code will be an index
            // instead of the code.  Use the index and the
            // serial number to determine the string

            return(ssConfig.DescString());
        }
        /// <summary>
        /// Set the subsystem and set the
        /// default values.
        /// </summary>
        /// <param name="ssConfig">SubsystemConfiguration associated these options.</param>
        public ViewDataGraphicalOptions(SubsystemConfiguration ssConfig)
        {
            // Set the subsystem
            SubsystemConfig = ssConfig;

            // Set default values
            SetDefaults();

            // Create a list of all the color options.
            //SetupColorOptions();
        }
Example #18
0
        public void AdcpSubsystemConfigExist()
        {
            AdcpConfiguration config = new AdcpConfiguration();
            SerialNumber serial = new SerialNumber("01200000000000000000000000000004");
            Dictionary<string, AdcpSubsystemConfig> result = config.SetCepo("2", serial);

            Subsystem ss = new Subsystem("2", 0);                                   // Subsystem code and Index within serial number
            SubsystemConfiguration ssConfig = new SubsystemConfiguration(ss, 0, 0);        // Number of configurations for a given subsystem

            Assert.AreEqual(true, config.AdcpSubsystemConfigExist(ssConfig), "AdcpSubsystemConfigExist() is incorrect.");
        }
Example #19
0
        /// <summary>
        /// Check if the given object is
        /// equal to this object.
        /// </summary>
        /// <param name="obj">Object to check.</param>
        /// <returns>If the codes are the same, then they are equal.</returns>
        public override bool Equals(object obj)
        {
            //Check for null and compare run-time types.
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }

            SubsystemConfiguration p = (SubsystemConfiguration)obj;

            return(SubSystem == p.SubSystem && CepoIndex == p.CepoIndex && SubsystemConfigIndex == p.SubsystemConfigIndex);
        }
Example #20
0
        /// <summary>
        /// Determine if the AdcpSubsystemConfig exist in the dictionary.  This will generate
        /// a key based off the Subsystem and SubsystemConfiguration given.  It will then
        /// check if the key exist in the dictionary.
        /// </summary>
        /// <param name="ssConfig">SubsystemConfiguration.</param>
        /// <returns>TRUE = Subsystem and SubsystemConfiguration key found.  /  FALSE = No AdcpSubsystemConfig key.</returns>
        public bool AdcpSubsystemConfigExist(SubsystemConfiguration ssConfig)
        {
            // Check for null
            if (ssConfig == null)
            {
                return(false);
            }

            string str = ssConfig.DescString();

            //return SubsystemConfigDict.ContainsKey(AdcpSubsystemConfig.GetString(ssConfig));
            return(SubsystemConfigDict.ContainsKey(str));
        }
Example #21
0
 /// <summary>
 /// PD0 Subsystem.  This will include a little more details because
 /// the PD0 dataset does not include a separate value for the configuration index.
 /// </summary>
 /// <param name="ssConfig"></param>
 /// <param name="numBeams"></param>
 /// <param name="numBins"></param>
 /// <param name="binSize"></param>
 /// <param name="blank"></param>
 /// <param name="numPings">Number of pings.</param>
 ///
 public Pd0Subsystem(SubsystemConfiguration ssConfig,
                     int numBeams,
                     int numBins,
                     float binSize,
                     float blank,
                     int numPings)
 {
     this.SsConfig = ssConfig;
     this.NumBeams = numBeams;
     this.NumBins  = numBins;
     this.BinSize  = binSize;
     this.Blank    = blank;
     this.NumPings = numPings;
 }
        /// <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>
        /// 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);
        }
Example #26
0
        public void TestConstructor()
        {
            Subsystem ss = new Subsystem(Subsystem.SUB_1_2MHZ_4BEAM_20DEG_PISTON_2, 0);         // 1200kHz
            SubsystemConfiguration ssConfig = new SubsystemConfiguration(ss, 0, 0);                    // 0 Config
            int cepoIndex = 0;
            AdcpSubsystemConfig asConfig = new AdcpSubsystemConfig(ssConfig);
            string asConfigStr = AdcpSubsystemConfig.GetString(ssConfig);

            Assert.AreEqual(asConfig.SubsystemConfig.CepoIndex, cepoIndex, "CepoIndex is incorrect.");
            //Assert.AreEqual(asConfig.Commands.CepoIndex, cepoIndex, "Commands CEPO index is incorrect.");
            Assert.AreEqual(asConfig.SubsystemConfig.SubSystem, ss, "Subsystem is incorrect.");
            Assert.AreEqual(asConfig.SubsystemConfig, ssConfig, "SubsystemConfiguration is incorrect.");
            Assert.AreEqual(asConfig.ToString(), "[0] 1.2 MHz 4 beam 20 degree piston", "ToString is incorrect.");
            Assert.AreEqual(asConfigStr, "[0] 1.2 MHz 4 beam 20 degree piston", "GetString is incorrect.");
        }
Example #27
0
        public void TestConstructor()
        {
            Subsystem ss = new Subsystem(Subsystem.SUB_1_2MHZ_4BEAM_20DEG_PISTON_2, 0);         // 1200kHz
            SubsystemConfiguration ssConfig = new SubsystemConfiguration(ss, 0, 0);             // 0 Config
            int cepoIndex = 0;
            AdcpSubsystemConfig asConfig = new AdcpSubsystemConfig(ssConfig);
            string asConfigStr           = AdcpSubsystemConfig.GetString(ssConfig);


            Assert.AreEqual(asConfig.SubsystemConfig.CepoIndex, cepoIndex, "CepoIndex is incorrect.");
            //Assert.AreEqual(asConfig.Commands.CepoIndex, cepoIndex, "Commands CEPO index is incorrect.");
            Assert.AreEqual(asConfig.SubsystemConfig.SubSystem, ss, "Subsystem is incorrect.");
            Assert.AreEqual(asConfig.SubsystemConfig, ssConfig, "SubsystemConfiguration is incorrect.");
            Assert.AreEqual(asConfig.ToString(), "[0] 1.2 MHz 4 beam 20 degree piston", "ToString is incorrect.");
            Assert.AreEqual(asConfigStr, "[0] 1.2 MHz 4 beam 20 degree piston", "GetString is incorrect.");
        }
Example #28
0
        private void SelectSubsystemConfig(SubsystemConfiguration ssConfig)
        {
            if (ssConfig == null)
            {
                return;
            }

            // Uncheck all the subsystem configs that do match the CEPO index and Subsystem code.
            foreach (var ss in SubsystemConfigList)
            {
                if (ss.CepoIndex != SubsystemConfig.CepoIndex.ToString() || ss.Subsystem != SubsystemConfig.SubSystem.CodeToString())
                {
                    ss.IsChecked = false;
                }
            }
        }
Example #29
0
        /// <summary>
        /// Get the AdcpSubsystemConfig from the dictionary if it exist.  If it does not
        /// exist in the dictionary, null will be returned.
        /// </summary>
        /// <param name="ssConfig">SubsystemConfiguration.</param>
        /// <returns>If the AdcpSubystemConfig is found, it will return the AdcpSubsystemConfig.  If it is not found, it will return null.</returns>
        public AdcpSubsystemConfig GetAdcpSubsystemConfig(SubsystemConfiguration ssConfig)
        {
            // Check for null
            if (ssConfig == null)
            {
                return(null);
            }

            // Generate the key for the Subsystem and SubsystemConfiguration
            string key = AdcpSubsystemConfig.GetString(ssConfig);

            // If the key exist, return the object
            if (SubsystemConfigDict.ContainsKey(key))
            {
                return(SubsystemConfigDict[key]);
            }

            // The key did not exist so return null
            return(null);
        }
Example #30
0
        public void TestJSON1()
        {
            Subsystem ss = new Subsystem(Subsystem.SUB_1_2MHZ_VERT_PISTON_A, 0);                // 1200kHz
            SubsystemConfiguration ssConfig = new SubsystemConfiguration(ss, 3, 3);             // 3 Config
            int cepoIndex = 3;
            AdcpSubsystemConfig asConfig = new AdcpSubsystemConfig(ssConfig);

            string json = Newtonsoft.Json.JsonConvert.SerializeObject(asConfig);                                        // Serialize object to JSON
            AdcpSubsystemConfig newConfig = Newtonsoft.Json.JsonConvert.DeserializeObject <AdcpSubsystemConfig>(json);  // Deserialize the JSON

            Assert.AreEqual(asConfig.SubsystemConfig.CepoIndex, cepoIndex, "CepoIndex is incorrect.");
            Assert.AreEqual(asConfig.SubsystemConfig.SubSystem, ss, "Subsystem is incorrect.");
            Assert.AreEqual(asConfig.SubsystemConfig, ssConfig, "SubsystemConfiguration is incorrect.");
            Assert.AreEqual(asConfig.ToString(), "[3] 1.2 MHz vertical beam piston", "ToString is incorrect.");

            Assert.AreEqual(newConfig.SubsystemConfig.CepoIndex, cepoIndex, "CepoIndex is incorrect.");
            Assert.AreEqual(newConfig.SubsystemConfig.SubSystem, ss, "Subsystem is incorrect.");
            Assert.AreEqual(newConfig.SubsystemConfig, ssConfig, "SubsystemConfiguration is incorrect.");
            Assert.AreEqual(newConfig.ToString(), "[3] 1.2 MHz vertical beam piston", "ToString is incorrect.");
        }
Example #31
0
        public void TestJSON()
        {
            Subsystem ss = new Subsystem(Subsystem.SUB_1_2MHZ_4BEAM_20DEG_PISTON_2, 0);         // 1200kHz
            SubsystemConfiguration ssConfig = new SubsystemConfiguration(ss, 0, 0);                    // 0 Config
            int cepoIndex = 0;
            AdcpSubsystemConfig asConfig = new AdcpSubsystemConfig(ssConfig);

            string json = Newtonsoft.Json.JsonConvert.SerializeObject(asConfig);                                        // Serialize object to JSON
            AdcpSubsystemConfig newConfig = Newtonsoft.Json.JsonConvert.DeserializeObject<AdcpSubsystemConfig>(json);   // Deserialize the JSON

            Assert.AreEqual(asConfig.SubsystemConfig.CepoIndex, cepoIndex, "CepoIndex is incorrect.");
            //Assert.AreEqual(asConfig.Commands.CepoIndex, cepoIndex, "Commands CEPO index is incorrect.");
            Assert.AreEqual(asConfig.SubsystemConfig.SubSystem, ss, "Subsystem is incorrect.");
            Assert.AreEqual(asConfig.SubsystemConfig, ssConfig, "SubsystemConfiguration is incorrect.");
            Assert.AreEqual(asConfig.ToString(), "[0] 1.2 MHz 4 beam 20 degree piston", "ToString is incorrect.");

            Assert.AreEqual(newConfig.SubsystemConfig.CepoIndex, cepoIndex, "CepoIndex is incorrect.");
            //Assert.AreEqual(newConfig.Commands.CepoIndex, cepoIndex, "Commands CEPO index is incorrect.");
            Assert.AreEqual(newConfig.SubsystemConfig.SubSystem, ss, "Subsystem is incorrect.");
            Assert.AreEqual(newConfig.SubsystemConfig, ssConfig, "SubsystemConfiguration is incorrect.");
            Assert.AreEqual(newConfig.ToString(), "[0] 1.2 MHz 4 beam 20 degree piston", "ToString is incorrect.");
        }
Example #32
0
        public void TestJSON()
        {
            Subsystem ss = new Subsystem(Subsystem.SUB_1_2MHZ_4BEAM_20DEG_PISTON_2, 0);         // 1200kHz
            SubsystemConfiguration ssConfig = new SubsystemConfiguration(ss, 0, 0);             // 0 Config
            int cepoIndex = 0;
            AdcpSubsystemConfig asConfig = new AdcpSubsystemConfig(ssConfig);

            string json = Newtonsoft.Json.JsonConvert.SerializeObject(asConfig);                                        // Serialize object to JSON
            AdcpSubsystemConfig newConfig = Newtonsoft.Json.JsonConvert.DeserializeObject <AdcpSubsystemConfig>(json);  // Deserialize the JSON

            Assert.AreEqual(asConfig.SubsystemConfig.CepoIndex, cepoIndex, "CepoIndex is incorrect.");
            //Assert.AreEqual(asConfig.Commands.CepoIndex, cepoIndex, "Commands CEPO index is incorrect.");
            Assert.AreEqual(asConfig.SubsystemConfig.SubSystem, ss, "Subsystem is incorrect.");
            Assert.AreEqual(asConfig.SubsystemConfig, ssConfig, "SubsystemConfiguration is incorrect.");
            Assert.AreEqual(asConfig.ToString(), "[0] 1.2 MHz 4 beam 20 degree piston", "ToString is incorrect.");

            Assert.AreEqual(newConfig.SubsystemConfig.CepoIndex, cepoIndex, "CepoIndex is incorrect.");
            //Assert.AreEqual(newConfig.Commands.CepoIndex, cepoIndex, "Commands CEPO index is incorrect.");
            Assert.AreEqual(newConfig.SubsystemConfig.SubSystem, ss, "Subsystem is incorrect.");
            Assert.AreEqual(newConfig.SubsystemConfig, ssConfig, "SubsystemConfiguration is incorrect.");
            Assert.AreEqual(newConfig.ToString(), "[0] 1.2 MHz 4 beam 20 degree piston", "ToString is incorrect.");
        }
        /// <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();
        }
Example #34
0
        /// <summary>
        /// Test the AddConfiguration() method.
        /// </summary>
        public void AddConfiguration()
        {
            AdcpConfiguration config = new AdcpConfiguration();
            SerialNumber serial = new SerialNumber("01200000000000000000000000000004");
            Dictionary<string, AdcpSubsystemConfig> result = config.SetCepo("2", serial);

            Subsystem ss = new Subsystem("2", 0);                                   // Subsystem code and Index within serial number
            SubsystemConfiguration ssConfig0 = new SubsystemConfiguration(ss, 0, 0);       // Number of configurations for a given subsystem
            SubsystemConfiguration ssConfig1 = new SubsystemConfiguration(ss, 1, 1);       // A second configuration for a subsystem

            AdcpSubsystemConfig asConfig1 = null;                                   // Create an AdcpSubsystemConfig to get the result
            bool addConfigResult = config.AddConfiguration(ss, out asConfig1);      // Add another configuration for Subsystem 2

            Assert.IsTrue(addConfigResult, "AddConfiguration() is incorrect.");
            Assert.IsNotNull(asConfig1, "asConfig1 is incorrect.");
            Assert.AreEqual(ss, asConfig1.SubsystemConfig.SubSystem, "asConfig1 Subsystem is incorrect.");
            Assert.AreEqual(1, asConfig1.SubsystemConfig.CepoIndex, "asConfig1 CEPO index is incorrect.");
            Assert.AreEqual(ssConfig1, asConfig1.SubsystemConfig, "asConfig1 SubsystemConfiguration is incorrect.");
            Assert.IsNotNull(asConfig1.Commands, "asConfig1 Commands is incorrect.");
            Assert.AreEqual(ss, asConfig1.Commands.SubsystemConfig.SubSystem, "asConfig1 Commands Subsystem is incorrect.");
            Assert.AreEqual(1, asConfig1.Commands.SubsystemConfig.CepoIndex, "asConfig1 Commands CEPO index is incorrect.");

            Assert.AreEqual("22", config.Commands.CEPO, "Commands CEPO is incorrect.");
            Assert.AreEqual(2, config.SubsystemConfigDict.Count, "SubsystemConfigDict Count is incorrect.");
            Assert.AreEqual(true, config.AdcpSubsystemConfigExist(ssConfig0), "AdcpSubsystemConfigExist() 2 0 is incorrect.");
            Assert.AreEqual(true, config.AdcpSubsystemConfigExist(ssConfig1), "AdcpSubsystemConfigExist() 2 1 is incorrect.");
            Assert.NotNull(config.GetAdcpSubsystemConfig(ssConfig0), "GetAdcpSubsystemConfig() 2 0  is incorrect.");
            Assert.NotNull(config.GetAdcpSubsystemConfig(ssConfig1), "GetAdcpSubsystemConfig() 2 1  is incorrect.");
        }
Example #35
0
        /// <summary>
        /// Called when [sentence changed].
        /// </summary>
        /// <remarks></remarks>
        protected override void OnSentenceChanged()
        {
            // Parse the basic sentence information
            base.OnSentenceChanged();

            // Cache the words
            string[] words = Words;
            int wordCount = words.Length;

            #region Start Time

            // Do we have enough data to process the Start time?
            if (wordCount >= 1 && words[0].Length != 0)
            {
                _startTime = int.Parse(words[0], NmeaCultureInfo);
            }
            else
            {
                _startTime = 0;
            }

            #endregion

            #region Sample Number

            // Do we have enough data to process the Sample number?
            if (wordCount >= 2 && words[1].Length != 0)
            {
                _sampleNumber =  int.Parse(words[1], NmeaCultureInfo);
            }
            else
            {
                _sampleNumber = 0;
            }

            #endregion

            #region Temperature

            // Do we have enough data to process the Temperature?
            if (wordCount >= 3 && words[2].Length != 0)
            {
                _temperature = int.Parse(words[2], NmeaCultureInfo);
            }
            else
            {
                _temperature = 0;
            }

            #endregion

            #region Bottom Track X Velocity

            // Do we have enough data to process the Bottom Track X Velocity?
            if (wordCount >= 4 && words[3].Length != 0)
            {
                _btVelocityX = new Speed(
                                        // Parse the numeric portion
                                        int.Parse(words[3], NmeaCultureInfo),
                                        // Use mm/s
                                        SpeedUnit.MillimetersPerSecond);
            }
            else
            {
                _btVelocityX = Speed.Empty;
            }

            #endregion

            #region Bottom Track Y Velocity

            // Do we have enough data to process the Bottom Track Y Velocity?
            if (wordCount >= 5 && words[4].Length != 0)
            {
                _btVelocityY = new Speed(
                                        // Parse the numeric portion
                                        int.Parse(words[4], NmeaCultureInfo),
                                        // Use mm/s
                                        SpeedUnit.MillimetersPerSecond);
            }
            else
            {
                _btVelocityY = Speed.Empty;
            }

            #endregion

            #region Bottom Track Z Velocity

            // Do we have enough data to process the Bottom Track Z Velocity?
            if (wordCount >= 6 && words[5].Length != 0)
            {
                _btVelocityZ = new Speed(
                                        // Parse the numeric portion
                                        int.Parse(words[5], NmeaCultureInfo),
                                        // Use mm/s
                                        SpeedUnit.MillimetersPerSecond);
            }
            else
            {
                _btVelocityZ = Speed.Empty;
            }

            #endregion

            #region Depth

            // Do we have enough data to process the Depth?
            if (wordCount >= 7 && words[6].Length != 0)
            {
                _depth = new Distance(int.Parse(words[6], NmeaCultureInfo), DistanceUnit.Millimeters);
            }
            else
            {
                // Bottom not detected
                _depth = Distance.BottomNotDetectedDVL;
            }

            #endregion

            #region Water Mass X Velocity

            // Do we have enough data to process the Water Mass X Velocity?
            if (wordCount >= 8 && words[7].Length != 0)
            {
                _wmVelocityX = new Speed(
                                        // Parse the numeric portion
                                        int.Parse(words[7], NmeaCultureInfo),
                                        // Use mm/s
                                        SpeedUnit.MillimetersPerSecond);
            }
            else
            {
                _wmVelocityX = Speed.Empty;
            }

            #endregion

            #region Water Mass Y Velocity

            // Do we have enough data to process the Water Mass Y Velocity?
            if (wordCount >= 9 && words[8].Length != 0)
            {
                _wmVelocityY = new Speed(
                                        // Parse the numeric portion
                                        int.Parse(words[8], NmeaCultureInfo),
                                        // Use mm/s
                                        SpeedUnit.MillimetersPerSecond);
            }
            else
            {
                _wmVelocityY = Speed.Empty;
            }

            #endregion

            #region Water Mass Z Velocity

            // Do we have enough data to process the Water Mass Z Velocity?
            if (wordCount >= 10 && words[9].Length != 0)
            {
                _wmVelocityZ = new Speed(
                                        // Parse the numeric portion
                                        int.Parse(words[9], NmeaCultureInfo),
                                        // Use mm/s
                                        SpeedUnit.MillimetersPerSecond);
            }
            else
            {
                _wmVelocityZ = Speed.Empty;
            }

            #endregion

            #region Water Mass Depth

            // Do we have enough data to process the Depth?
            if (wordCount >= 11 && words[10].Length != 0)
            {
                _wmDepth = new Distance(int.Parse(words[10], NmeaCultureInfo), DistanceUnit.Millimeters);
            }
            else
            {
                // Water Mass depth not found
                _wmDepth = Distance.Empty;
            }

            #endregion

            #region Status

            // Do we have enough data to process the Status?
            if (wordCount >= 12 && words[11].Length != 0)
            {
                // Convert the hex string to an int
                int status = Convert.ToInt32(words[11], 16);

                _status = new Status(status);
            }
            else
            {
                // Status not found
                _status = new Status(0);
            }

            #endregion

            #region Subsystem Configuration

            // Do we have enough data to process the Subsystem Configuration?
            if (wordCount >= 14 && words[12].Length != 0 && words[13].Length != 0)
            {
                byte ssConfig = 0;
                byte.TryParse(words[13], out ssConfig);         // Subsystem configuration index in CEPO

                _SubsystemConfig = new SubsystemConfiguration(new Subsystem(words[12], 0), ssConfig, ssConfig);
            }
            else
            {
                // Subsystem configuration not found
                _SubsystemConfig = new SubsystemConfiguration();
            }

            #endregion
        }
Example #36
0
        /// <summary>
        /// Called when [sentence changed].
        /// </summary>
        /// <remarks></remarks>
        protected override void OnSentenceChanged()
        {
            // Parse the basic sentence information
            base.OnSentenceChanged();

            // Cache the words
            string[] words = Words;
            int wordCount = words.Length;

            #region Heading

            // Do we have enough data to process the Heading?
            if (wordCount >= 1 && words[0].Length != 0)
            {
                _Heading = float.Parse(words[0], NmeaCultureInfo);
            }
            else
            {
                _Heading = 0.0f;
            }

            #endregion

            #region Pitch

            // Do we have enough data to process the Pitch?
            if (wordCount >= 2 && words[1].Length != 0)
            {
                _Pitch =  float.Parse(words[1], NmeaCultureInfo);
            }
            else
            {
                _Pitch = 0.0f;
            }

            #endregion

            #region Roll

            // Do we have enough data to process the Roll?
            if (wordCount >= 3 && words[2].Length != 0)
            {
                _Roll = float.Parse(words[2], NmeaCultureInfo);
            }
            else
            {
                _Roll = 0.0f;
            }

            #endregion

            #region Subsystem Configuration

            // Do we have enough data to process the Subsystem Configuration?
            if (wordCount >= 5 && words[3].Length != 0 && words[4].Length != 0)
            {
                byte ssConfig = 0;
                byte.TryParse(words[4], out ssConfig);         // Subsystem configuration index in CEPO

                _SubsystemConfig = new SubsystemConfiguration(new Subsystem(words[3], 0), ssConfig, ssConfig);
            }
            else
            {
                // Subsystem configuration not found
                _SubsystemConfig = new SubsystemConfiguration();
            }

            #endregion
        }
Example #37
0
        /// <summary>
        /// Get the AdcpSubsystemConfig from the dictionary if it exist.  If it does not
        /// exist in the dictionary, null will be returned.
        /// </summary>
        /// <param name="ssConfig">SubsystemConfiguration.</param>
        /// <returns>If the AdcpSubystemConfig is found, it will return the AdcpSubsystemConfig.  If it is not found, it will return null.</returns>
        public AdcpSubsystemConfig GetAdcpSubsystemConfig(SubsystemConfiguration ssConfig)
        {
            // Check for null
            if (ssConfig == null)
            {
                return null;
            }

            // Generate the key for the Subsystem and SubsystemConfiguration
            string key = AdcpSubsystemConfig.GetString(ssConfig);

            // If the key exist, return the object
            if (SubsystemConfigDict.ContainsKey(key))
            {
                return SubsystemConfigDict[key];
            }

            // The key did not exist so return null
            return null;
        }
Example #38
0
        /// <summary>
        /// Get the CEPO configuration character and index within the CEPO command.
        /// The configuration character is the Subsystem code for the configuration.  It
        /// represents the system type.  The Index represents where in teh CEPO command
        /// the configuration was located.  This determines the ping order of the configurations.
        /// It also make the configuration unique for a SubsystemConfiguration for a Subsystem.
        /// Get the Subsystem using the serial number and subsystem code.
        /// 
        /// SubsystemConfiguaration CommandSetup: Index of the Configuration within Subsystem.  (Based off counting configurations for a subsystem)
        /// index: Location in CEPO for the Subsystem configuration.
        /// </summary>
        /// <param name="ssCode">Subsystem Code from the CEPO command.</param>
        /// <param name="cepoIndex">Location in the CEPO command of the Subsystem Code.</param>
        /// <param name="serial">Serial number for the ADCP.</param>
        /// <returns>Return the AdcpSubsystemConfig created or null if one could not be created.</returns>
        private AdcpSubsystemConfig AddConfig(byte ssCode, int cepoIndex, SerialNumber serial)
        {
            AdcpSubsystemConfig asConfig = null;

            // Get the Subsystem index from the serial number
            // If it cannot be found in the serial number, then it is
            // a bad Subsystem and we can not use the command.
            Subsystem ss = serial.GetSubsystem(ssCode);
            if (!ss.IsEmpty())
            {

                // Determine how many of the given subsystem have been added to the dictionary
                // We need to generate SubsystemConfiguration index value.
                // SubsystemConfiguration index is based off the number of SubsystemConfigurations already
                // in the dictionary before this configuration is added.
                ushort ssCount = 0;
                foreach (AdcpSubsystemConfig configuration in SubsystemConfigDict.Values)
                {
                    // If the subsystems are the same, then increment the value
                    if (configuration.SubsystemConfig.SubSystem.Code == ssCode)
                    {
                        ssCount++;
                    }
                }

                // Create all the subsystem configurations and add to the dictionary
                SubsystemConfiguration ssConfig = new SubsystemConfiguration(ss, (byte)cepoIndex, (byte)ssCount);   // SubsystemConfiguration with the CEPO index and Index of the SubsystemConfiguration
                asConfig = new AdcpSubsystemConfig(ssConfig);                                                       // AdcpSubsystemConfig with the Subsystem, SubsystemConfig and CEPO index
                SubsystemConfigDict.Add(asConfig.ToString(), asConfig);                                             // Add to the dictionary the configuration with the string as the key
            }

            return asConfig;
        }
Example #39
0
 /// <summary>
 /// Firmware 2.12 and older:
 /// In Firmware version 2.12 and previous versions, the Firmware data in EnsembleDataSet set contained
 /// the SubsystemIndex.  Now it contains the SubsystemCode.  This will check for a SubsystemCode of 0.  0
 /// is not a possible SubsystemCode and is a sign of older firmware.  If this is older firmware, then change
 /// the SubsystemCode to the correct value based off the Index and the serial number.
 /// 
 /// 
 /// </summary>
 /// <param name="ensemble">Ensemble to the Subsystem and Serial number.</param>
 /// <param name="ss">Subsystem if the value needs to change.</param>
 /// <param name="ssConfig">SubsystemConfiguration if the value needs to change.</param>
 private void CheckSubsystemCompatibility(DataSet.Ensemble ensemble, ref Subsystem ss, ref SubsystemConfiguration ssConfig)
 {
     // In firmware version greater than 2.12, a code of 0 is not possible
     // It used to be that the code was the index from the serial number.
     // So now get the code from the serial number.
     // This can only work if the older system has 1 configuration.
     if (ss.Code == 0)
     {
         if (ensemble.IsEnsembleAvail)
         {
             if (ensemble.EnsembleData.SysSerialNumber.SubsystemsString().Length > 0)
             {
                 ss.Code = Convert.ToByte(ensemble.EnsembleData.SysSerialNumber.SubsystemsString()[0]);
                 ss.Index = 0;
             }
         }
     }
 }
Example #40
0
        /// <summary>
        /// Add a configuration to the dictionary.  This will create an AdcpSubsystemConfig based
        /// off the Subsystem and CEPO index given.  It will then add it to the dictionary.  It will
        /// then return the created AdcpSubsystemConfig.  If the AdcpSubsystemConfig could not be
        /// created, null will be returned.
        /// </summary>
        /// <param name="ss">Subsystem to add a configuration.</param>
        /// <param name="cepoIndex">CEPO index.</param>
        /// <returns>AdcpSubsystemConfig created with the given settings or null if one could not be created.</returns>
        private AdcpSubsystemConfig AddConfig(Subsystem ss, int cepoIndex)
        {
            AdcpSubsystemConfig asConfig = null;

            // If a bad Subsystem is given, we cannot use it
            if (!ss.IsEmpty())
            {
                // Determine how many of the given subsystem have been added to the dictionary
                // We need to generate SubsystemConfiguration index value.
                // SubsystemConfiguration index is based off the number of SubsystemConfigurations already
                // in the dictionary before this configuration is added.
                ushort ssCount = 0;
                foreach (AdcpSubsystemConfig configuration in SubsystemConfigDict.Values)
                {
                    // If the subsystems are the same, then increment the value
                    if (configuration.SubsystemConfig.SubSystem.Code == ss.Code)
                    {
                        ssCount++;
                    }
                }

                // Create all the subsystem configurations and add to the dictionary
                SubsystemConfiguration ssConfig = new SubsystemConfiguration(ss, (byte)cepoIndex, (byte)ssCount);    // SubsystemConfiguration with the Index of the SubsystemConfiguration
                asConfig = new AdcpSubsystemConfig(ssConfig);                        // AdcpSubsystemConfig with the Subsystem, SubsystemConfig and CEPO index
                if (!SubsystemConfigDict.ContainsKey(asConfig.ToString()))
                {
                    SubsystemConfigDict.Add(asConfig.ToString(), asConfig);
                }
            }

            return asConfig;
        }
Example #41
0
        public void AdcpSubsystemConfigExist1()
        {
            AdcpConfiguration config = new AdcpConfiguration();
            SerialNumber serial = new SerialNumber("01230000000000000000000000000004");
            Dictionary<string, AdcpSubsystemConfig> result = config.SetCepo("23", serial);

            Subsystem ss2 = new Subsystem("2", 0);                                   // Subsystem code and Index within serial number
            Subsystem ss3 = new Subsystem("3", 1);                                   // Subsystem code and Index within serial number
            SubsystemConfiguration ssConfig20 = new SubsystemConfiguration(ss2, 0, 0);         // Configuration SS2 with Config Number 0
            SubsystemConfiguration ssConfig21 = new SubsystemConfiguration(ss2, 1, 1);         // Configuration SS2 with Config Number 1
            SubsystemConfiguration ssConfig30 = new SubsystemConfiguration(ss3, 0, 0);         // Configuration SS3 with Config Number 0
            SubsystemConfiguration ssConfig31 = new SubsystemConfiguration(ss3, 1, 1);         // Configuration SS3 with Config Number 1

            Assert.AreEqual(true, config.AdcpSubsystemConfigExist(ssConfig20), "AdcpSubsystemConfigExist() 2 0 is incorrect.");
            Assert.AreEqual(false, config.AdcpSubsystemConfigExist(ssConfig30), "AdcpSubsystemConfigExist() 3 0 is incorrect.");
            Assert.AreEqual(false, config.AdcpSubsystemConfigExist(ssConfig21), "AdcpSubsystemConfigExist() 2 1 is incorrect.");
            Assert.AreEqual(true, config.AdcpSubsystemConfigExist(ssConfig31), "AdcpSubsystemConfigExist() 3 1 is incorrect.");
        }
Example #42
0
        public void GetAdcpSubsystemConfig5()
        {
            AdcpConfiguration config = new AdcpConfiguration();
            SerialNumber serial = new SerialNumber("0123000000000000000000000000004");
            Dictionary<string, AdcpSubsystemConfig> result = config.SetCepo("232332", serial);

            Subsystem ss2 = new Subsystem("2", 0);                                   // Subsystem code and Index within serial number
            Subsystem ss3 = new Subsystem("3", 1);                                   // Subsystem code and Index within serial number
            SubsystemConfiguration ssConfig20 = new SubsystemConfiguration(ss2, 0, 0);         // Configuration SS2 with Config Number 0
            SubsystemConfiguration ssConfig21 = new SubsystemConfiguration(ss2, 2, 2);         // Configuration SS2 with Config Number 1
            SubsystemConfiguration ssConfig22 = new SubsystemConfiguration(ss2, 5, 5);         // Configuration SS2 with Config Number 2
            SubsystemConfiguration ssConfig30 = new SubsystemConfiguration(ss3, 1, 1);         // Configuration SS3 with Config Number 0
            SubsystemConfiguration ssConfig31 = new SubsystemConfiguration(ss3, 3, 3);         // Configuration SS3 with Config Number 1
            SubsystemConfiguration ssConfig32 = new SubsystemConfiguration(ss3, 4, 4);         // Configuration SS3 with Config Number 2

            Assert.NotNull(config.GetAdcpSubsystemConfig(ssConfig20), "GetAdcpSubsystemConfig() 2 0 is incorrect.");
            Assert.NotNull(config.GetAdcpSubsystemConfig(ssConfig30), "GetAdcpSubsystemConfig() 3 0 is incorrect.");
            Assert.NotNull(config.GetAdcpSubsystemConfig(ssConfig21), "GetAdcpSubsystemConfig() 2 1 is incorrect.");
            Assert.NotNull(config.GetAdcpSubsystemConfig(ssConfig31), "GetAdcpSubsystemConfig() 3 1 is incorrect.");
            Assert.NotNull(config.GetAdcpSubsystemConfig(ssConfig22), "GetAdcpSubsystemConfig() 2 2 is incorrect.");
            Assert.NotNull(config.GetAdcpSubsystemConfig(ssConfig32), "GetAdcpSubsystemConfig() 3 2 is incorrect.");
        }
Example #43
0
        public void GetAdcpSubsystemConfigNull2()
        {
            AdcpConfiguration config = new AdcpConfiguration();

            Subsystem ss2 = new Subsystem("2", 0);                                   // Subsystem code and Index within serial number
            SubsystemConfiguration ssConfig0 = new SubsystemConfiguration(ss2, 0, 0);        // Number of configurations for a given subsystem

            Assert.IsNull(config.GetAdcpSubsystemConfig(ssConfig0), "GetAdcpSubsystemConfig() is incorrect.");
        }
Example #44
0
        public void GetAdcpSubsystemConfig()
        {
            AdcpConfiguration config = new AdcpConfiguration();
            SerialNumber serial = new SerialNumber("01200000000000000000000000000004");
            Dictionary<string, AdcpSubsystemConfig> result = config.SetCepo("2", serial);

            Subsystem ss = new Subsystem("2", 0);                                   // Subsystem code and Index within serial number
            SubsystemConfiguration ssConfig = new SubsystemConfiguration(ss, 0 , 0);        // Number of configurations for a given subsystem

            AdcpSubsystemConfig asConfig = config.GetAdcpSubsystemConfig(ssConfig);

            Assert.NotNull(asConfig, "GetAdcpSubsystemConfig() is incorrect.");
        }
Example #45
0
        /// <summary>
        /// Test the AddConfiguration() method.
        /// 
        /// Add bad Subsystem.
        /// </summary>
        public void AddConfiguration3()
        {
            AdcpConfiguration config = new AdcpConfiguration();
            SerialNumber serial = new SerialNumber("01200000000000000000000000000004");
            Dictionary<string, AdcpSubsystemConfig> result = config.SetCepo("22", serial);

            Subsystem ss2 = new Subsystem("2", 0);                                   // Subsystem code and Index within serial number
            Subsystem ss3 = new Subsystem("3", 1);                                   // Subsystem code and Index within serial number
            SubsystemConfiguration ssConfig20 = new SubsystemConfiguration(ss2, 0, 0);         // Configuration SS2 with Config Number 0
            SubsystemConfiguration ssConfig21 = new SubsystemConfiguration(ss2, 1, 1);         // Configuration SS2 with Config Number 1
            SubsystemConfiguration ssConfig30 = new SubsystemConfiguration(ss3, 0, 0);         // Configuration SS3 with Config Number 0
            SubsystemConfiguration ssConfig31 = new SubsystemConfiguration(ss3, 1, 1);         // Configuration SS3 with Config Number 1

            AdcpSubsystemConfig asConfig1 = null;
            bool addConfigResult = config.AddConfiguration(ss3, out asConfig1);      // Add another configuration for Subsystem 2

            Assert.IsTrue(addConfigResult, "AddConfiguration() is incorrect.");
            Assert.IsNotNull(asConfig1, "asConfig1 is incorrect.");
            Assert.AreEqual(ss3, asConfig1.SubsystemConfig.SubSystem, "asConfig1 Subsystem is incorrect.");
            Assert.AreEqual(2, asConfig1.SubsystemConfig.CepoIndex, "asConfig1 CEPO index is incorrect.");
            Assert.AreEqual(ssConfig31, asConfig1.SubsystemConfig, "asConfig1 SubsystemConfiguration is incorrect.");
            Assert.IsNotNull(asConfig1.Commands, "asConfig1 Commands is incorrect.");
            Assert.AreEqual(ss3, asConfig1.Commands.SubsystemConfig.SubSystem, "asConfig1 Commands Subsystem is incorrect.");
            Assert.AreEqual(2, asConfig1.Commands.SubsystemConfig.CepoIndex, "asConfig1 Commands CEPO index is incorrect.");

            Assert.AreEqual("22", config.Commands.CEPO, "Commands CEPO is incorrect.");
            Assert.AreEqual(2, config.SubsystemConfigDict.Count, "SubsystemConfigDict Count is incorrect.");
            Assert.AreEqual(true, config.AdcpSubsystemConfigExist(ssConfig20), "AdcpSubsystemConfigExist() 2 0 is incorrect.");
            Assert.AreEqual(true, config.AdcpSubsystemConfigExist(ssConfig21), "AdcpSubsystemConfigExist() 2 1 is incorrect.");
            Assert.AreEqual(false, config.AdcpSubsystemConfigExist(ssConfig30), "AdcpSubsystemConfigExist() 3 0 is incorrect.");
            Assert.AreEqual(false, config.AdcpSubsystemConfigExist(ssConfig31), "AdcpSubsystemConfigExist() 3 1 is incorrect.");
            Assert.NotNull(config.GetAdcpSubsystemConfig(ssConfig20), "GetAdcpSubsystemConfig() 2 0  is incorrect.");
            Assert.NotNull(config.GetAdcpSubsystemConfig(ssConfig21), "GetAdcpSubsystemConfig() 2 1  is incorrect.");
            Assert.IsNull(config.GetAdcpSubsystemConfig(ssConfig30), "GetAdcpSubsystemConfig() 3 0  is incorrect.");
            Assert.IsNull(config.GetAdcpSubsystemConfig(ssConfig31), "GetAdcpSubsystemConfig() 3 1  is incorrect.");
        }
Example #46
0
        public void TestRemoveConfigurationBad()
        {
            AdcpConfiguration config = new AdcpConfiguration();
            SerialNumber serial = new SerialNumber("01230000000000000000000000000004");
            Dictionary<string, AdcpSubsystemConfig> result = config.SetCepo("233", serial);

            Subsystem ss2 = new Subsystem("2", 0);                                   // Subsystem code and Index within serial number
            Subsystem ss3 = new Subsystem("3", 1);                                   // Subsystem code and Index within serial number
            SubsystemConfiguration ssConfig20 = new SubsystemConfiguration(ss2, 0, 0);         // Configuration SS2 with Config Number 0
            //SubsystemConfiguration ssConfig21 = new SubsystemConfiguration(ss2, 1, 1);         // Configuration SS2 with Config Number 1
            //SubsystemConfiguration ssConfig22 = new SubsystemConfiguration(ss2, 2, 2);         // Configuration SS2 with Config Number 2
            SubsystemConfiguration ssConfig30 = new SubsystemConfiguration(ss3, 1, 1);         // Configuration SS3 with Config Number 0
            SubsystemConfiguration ssConfig31 = new SubsystemConfiguration(ss3, 2, 2);         // Configuration SS3 with Config Number 1
            SubsystemConfiguration ssConfig32 = new SubsystemConfiguration(ss3, 3, 3);         // Configuration SS3 with Config Number 2

            AdcpSubsystemConfig asConfig3_2 = config.GetAdcpSubsystemConfig(ssConfig32);        // Get the Subsystem 3 Configuration 0

            bool resultRemove = config.RemoveAdcpSubsystemConfig(asConfig3_2);

            Assert.IsNull(asConfig3_2, "Config 3_2 is incorrect.");
            Assert.AreEqual(false, resultRemove, "ResultRemove is incorrect.");
            Assert.AreEqual("233", config.Commands.CEPO, "Commands CEPO is incorrect.");
        }
Example #47
0
        public void AdcpSubsystemConfigExistNull2()
        {
            AdcpConfiguration config = new AdcpConfiguration();
            Subsystem ss2 = new Subsystem("2", 0);                                   // Subsystem code and Index within serial number
            SubsystemConfiguration ssConfig0 = new SubsystemConfiguration(ss2, 0, 0);        // Number of configurations for a given subsystem

            Assert.AreEqual(false, config.AdcpSubsystemConfigExist(ssConfig0), "AdcpSubsystemConfigExist() is incorrect.");
        }
Example #48
0
        public void TestRemoveConfigurationMultiple()
        {
            AdcpConfiguration config = new AdcpConfiguration();
            SerialNumber serial = new SerialNumber("01230000000000000000000000000004");
            Dictionary<string, AdcpSubsystemConfig> result = config.SetCepo("233232", serial);

            Subsystem ss2 = new Subsystem("2", 0);                                   // Subsystem code and Index within serial number
            Subsystem ss3 = new Subsystem("3", 1);                                   // Subsystem code and Index within serial number
            SubsystemConfiguration ssConfig20 = new SubsystemConfiguration(ss2, 0, 0);         // Configuration SS2 with Config Number 0
            SubsystemConfiguration ssConfig21 = new SubsystemConfiguration(ss2, 3, 3);         // Configuration SS2 with Config Number 1
            SubsystemConfiguration ssConfig22 = new SubsystemConfiguration(ss2, 5, 5);         // Configuration SS2 with Config Number 2
            SubsystemConfiguration ssConfig30 = new SubsystemConfiguration(ss3, 1, 1);         // Configuration SS3 with Config Number 0
            SubsystemConfiguration ssConfig31 = new SubsystemConfiguration(ss3, 2, 2);         // Configuration SS3 with Config Number 1
            SubsystemConfiguration ssConfig32 = new SubsystemConfiguration(ss3, 4, 4);         // Configuration SS3 with Config Number 2

            AdcpSubsystemConfig asConfig3_0 = config.GetAdcpSubsystemConfig(ssConfig30);        // Get the Subsystem 3 Configuration 0
            AdcpSubsystemConfig asConfig3_1 = config.GetAdcpSubsystemConfig(ssConfig31);        // Get the Subsystem 3 Configuration 0
            AdcpSubsystemConfig asConfig3_2 = config.GetAdcpSubsystemConfig(ssConfig32);        // Get the Subsystem 3 Configuration 2

            // Verify 3 configuration exist for Subsystem 3 and Subsystem 2
            Assert.AreEqual(true, config.AdcpSubsystemConfigExist(ssConfig20), "Config Exist 2_0 True is incorrect.");
            Assert.AreEqual(true, config.AdcpSubsystemConfigExist(ssConfig21), "Config Exist 2_1 True is incorrect.");
            Assert.AreEqual(true, config.AdcpSubsystemConfigExist(ssConfig22), "Config Exist 2_2 True is incorrect.");
            Assert.AreEqual(true, config.AdcpSubsystemConfigExist(ssConfig30), "Config Exist 3_0 True is incorrect.");
            Assert.AreEqual(true, config.AdcpSubsystemConfigExist(ssConfig31), "Config Exist 3_1 True is incorrect.");
            Assert.AreEqual(true, config.AdcpSubsystemConfigExist(ssConfig32), "Config Exist 3_2 True is incorrect.");
            Assert.AreEqual(6, config.SubsystemConfigDict.Count, "SubsystemConfigDict pre count is incorrect.");
            Assert.AreEqual(0, config.GetAdcpSubsystemConfig(ssConfig20).SubsystemConfig.CepoIndex, "CEPO index 2_0 pre is incorrect.");
            Assert.AreEqual(0, config.GetAdcpSubsystemConfig(ssConfig20).Commands.SubsystemConfig.CepoIndex, "Commands CEPO index 2_0 pre is incorrect.");
            Assert.AreEqual(1, config.GetAdcpSubsystemConfig(ssConfig30).SubsystemConfig.CepoIndex, "CEPO index 3_0 pre is incorrect.");
            Assert.AreEqual(1, config.GetAdcpSubsystemConfig(ssConfig30).Commands.SubsystemConfig.CepoIndex, "Commands CEPO index 3_0 pre is incorrect.");
            Assert.AreEqual(2, config.GetAdcpSubsystemConfig(ssConfig31).SubsystemConfig.CepoIndex, "CEPO index 3_1 pre is incorrect.");
            Assert.AreEqual(2, config.GetAdcpSubsystemConfig(ssConfig31).Commands.SubsystemConfig.CepoIndex, "Commands CEPO index 3_1 pre is incorrect.");
            Assert.AreEqual(3, config.GetAdcpSubsystemConfig(ssConfig21).SubsystemConfig.CepoIndex, "CEPO index 2_1 pre is incorrect.");
            Assert.AreEqual(3, config.GetAdcpSubsystemConfig(ssConfig21).Commands.SubsystemConfig.CepoIndex, "Commands CEPO index 2_1 pre is incorrect.");
            Assert.AreEqual(4, config.GetAdcpSubsystemConfig(ssConfig32).SubsystemConfig.CepoIndex, "CEPO index 3_2 pre is incorrect.");
            Assert.AreEqual(4, config.GetAdcpSubsystemConfig(ssConfig32).Commands.SubsystemConfig.CepoIndex, "Commands CEPO index 3_2 pre is incorrect.");
            Assert.AreEqual(5, config.GetAdcpSubsystemConfig(ssConfig22).SubsystemConfig.CepoIndex, "CEPO index 2_2 pre is incorrect.");
            Assert.AreEqual(5, config.GetAdcpSubsystemConfig(ssConfig22).Commands.SubsystemConfig.CepoIndex, "Commands CEPO index 2_2 pre is incorrect.");

            //bool resultRemove0 = config.RemoveAdcpSubsystemConfig(asConfig3_0);                                                      // Remove the first Subsystem 3 Configuration
            //bool resultRemove1 = config.RemoveAdcpSubsystemConfig(asConfig3_1);                                                      // Remove the first Subsystem 3 Configuration
            //bool resultRemove2 = config.RemoveAdcpSubsystemConfig(asConfig3_2);                                                      // Remove the first Subsystem 3 Configuration

            //Assert.AreEqual(true, resultRemove0, "ResultRemove is incorrect.");
            //Assert.AreEqual(true, resultRemove1, "ResultRemove is incorrect.");
            //Assert.AreEqual(true, resultRemove2, "ResultRemove is incorrect.");
            //Assert.AreEqual("222", config.Commands.CEPO, "Commands CEPO is incorrect.");
            //Assert.AreEqual(true, config.AdcpSubsystemConfigExist(ssConfig20), "Config Exist 2_0 True 1 is incorrect.");
            //Assert.AreEqual(true, config.AdcpSubsystemConfigExist(ssConfig21), "Config Exist 2_1 True 1 is incorrect.");
            //Assert.AreEqual(true, config.AdcpSubsystemConfigExist(ssConfig22), "Config Exist 2_2 True 1 is incorrect.");
            //Assert.AreEqual(false, config.AdcpSubsystemConfigExist(ssConfig30), "Config Exist 3_0 True 1 is incorrect.");
            //Assert.AreEqual(false, config.AdcpSubsystemConfigExist(ssConfig31), "Config Exist 3_1 True 1 is incorrect.");
            //Assert.AreEqual(false, config.AdcpSubsystemConfigExist(ssConfig32), "Config Exist 3_2 False 1 is incorrect.");
            //Assert.AreEqual(3, config.SubsystemConfigDict.Count, "SubsystemConfigDict post count is incorrect.");
            //Assert.AreEqual(0, config.GetAdcpSubsystemConfig(ssConfig20).SubsystemConfig.CepoIndex, "CEPO index 2_0 is incorrect.");
            //Assert.AreEqual(0, config.GetAdcpSubsystemConfig(ssConfig20).Commands.SubsystemConfig.CepoIndex, "Commands CEPO index 2_0 is incorrect.");
            //Assert.AreEqual(1, config.GetAdcpSubsystemConfig(ssConfig21).SubsystemConfig.CepoIndex, "CEPO index 2_1 is incorrect.");
            //Assert.AreEqual(1, config.GetAdcpSubsystemConfig(ssConfig21).Commands.SubsystemConfig.CepoIndex, "Commands CEPO index 2_1 is incorrect.");
            //Assert.AreEqual(2, config.GetAdcpSubsystemConfig(ssConfig22).SubsystemConfig.CepoIndex, "CEPO index 2_2 is incorrect.");
            //Assert.AreEqual(2, config.GetAdcpSubsystemConfig(ssConfig22).Commands.SubsystemConfig.CepoIndex, "Commands CEPO index 2_2 is incorrect.");
        }
Example #49
0
        public void TestJSON1()
        {
            Subsystem ss = new Subsystem(Subsystem.SUB_1_2MHZ_VERT_PISTON_A, 0);                // 1200kHz
            SubsystemConfiguration ssConfig = new SubsystemConfiguration(ss, 3, 3);                    // 3 Config
            int cepoIndex = 3;
            AdcpSubsystemConfig asConfig = new AdcpSubsystemConfig(ssConfig);

            string json = Newtonsoft.Json.JsonConvert.SerializeObject(asConfig);                                        // Serialize object to JSON
            AdcpSubsystemConfig newConfig = Newtonsoft.Json.JsonConvert.DeserializeObject<AdcpSubsystemConfig>(json);   // Deserialize the JSON

            Assert.AreEqual(asConfig.SubsystemConfig.CepoIndex, cepoIndex, "CepoIndex is incorrect.");
            Assert.AreEqual(asConfig.SubsystemConfig.SubSystem, ss, "Subsystem is incorrect.");
            Assert.AreEqual(asConfig.SubsystemConfig, ssConfig, "SubsystemConfiguration is incorrect.");
            Assert.AreEqual(asConfig.ToString(), "[3] 1.2 MHz vertical beam piston", "ToString is incorrect.");

            Assert.AreEqual(newConfig.SubsystemConfig.CepoIndex, cepoIndex, "CepoIndex is incorrect.");
            Assert.AreEqual(newConfig.SubsystemConfig.SubSystem, ss, "Subsystem is incorrect.");
            Assert.AreEqual(newConfig.SubsystemConfig, ssConfig, "SubsystemConfiguration is incorrect.");
            Assert.AreEqual(newConfig.ToString(), "[3] 1.2 MHz vertical beam piston", "ToString is incorrect.");
        }
Example #50
0
        /// <summary>
        /// Determine if the AdcpSubsystemConfig exist in the dictionary.  This will generate
        /// a key based off the Subsystem and SubsystemConfiguration given.  It will then
        /// check if the key exist in the dictionary.
        /// </summary>
        /// <param name="ssConfig">SubsystemConfiguration.</param>
        /// <returns>TRUE = Subsystem and SubsystemConfiguration key found.  /  FALSE = No AdcpSubsystemConfig key.</returns>
        public bool AdcpSubsystemConfigExist(SubsystemConfiguration ssConfig)
        {
            // Check for null
            if (ssConfig == null)
            {
                return false;
            }

            string str = ssConfig.DescString();
            //return SubsystemConfigDict.ContainsKey(AdcpSubsystemConfig.GetString(ssConfig));
            return SubsystemConfigDict.ContainsKey(str);
        }