Beispiel #1
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);
        }
Beispiel #2
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));
        }
Beispiel #3
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);
        }