Exemplo n.º 1
0
 /// <summary>
 /// Class constructor. Instantiates a new <see cref="XBeeCategory"/> with the provided parameters.
 /// </summary>
 /// <param name="name">Name of the category.</param>
 /// <param name="description">Description of the category.</param>
 /// <param name="parentCategory">Parent category.</param>
 /// <param name="ownerFirmware">XBee firmware the category belongs to.</param>
 /// <seealso cref="XBeeFirmware"/>
 public XBeeCategory(string name, string description, XBeeCategory parentCategory, XBeeFirmware ownerFirmware)
 {
     Name           = name;
     Description    = description;
     ParentCategory = parentCategory;
     OwnerFirmware  = ownerFirmware;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Clones and returns the XBee category object.
        /// </summary>
        /// <param name="parentCategory">The parent category where the cloned category should be placed.</param>
        /// <param name="ownerFirmware">The owner firmware of the cloned category.</param>
        /// <returns>The cloned XBee category object.</returns>
        public XBeeCategory CloneCategory(XBeeCategory parentCategory, XBeeFirmware ownerFirmware)
        {
            XBeeCategory clonedCategory = (XBeeCategory)Clone();

            clonedCategory.ParentCategory = parentCategory;
            clonedCategory.OwnerFirmware  = ownerFirmware;

            // Clone the settings and add them to the cloned category.
            List <AbstractXBeeSetting> clonedSettings = new List <AbstractXBeeSetting>();

            foreach (AbstractXBeeSetting setting in Settings)
            {
                clonedSettings.Add(setting.CloneSetting(clonedCategory, ownerFirmware));
            }
            clonedCategory.Settings = clonedSettings;

            // Clone the categories and add them to the cloned category.
            List <XBeeCategory> clonedCategories = new List <XBeeCategory>();

            foreach (XBeeCategory category in Categories)
            {
                clonedCategories.Add(category.CloneCategory(clonedCategory, ownerFirmware));
            }
            clonedCategory.Categories = clonedCategories;

            return(clonedCategory);
        }
 /// <summary>
 /// Class constructor. Instantiates a new <see cref="XBeeSettingNumber"/> object with the
 /// provided parameters.
 /// </summary>
 /// <param name="name">Name of the setting.</param>
 /// <param name="description">Description of the setting.</param>
 /// <param name="defaultValue">Default value of the setting.</param>
 /// <param name="category">Parent category of the setting.</param>
 /// <param name="ownerFirmware">XBee firmware the setting belongs to.</param>
 /// <param name="numNetworks">The number of networks the setting can be configured for.</param>
 /// <seealso cref="XBeeCategory"/>
 /// <seealso cref="XBeeFirmware"/>
 public XBeeSettingNumber(string name, string description, string defaultValue,
                          XBeeCategory category, XBeeFirmware ownerFirmware, int numNetworks)
     : base(name, description, defaultValue, category, ownerFirmware, numNetworks)
 {
     Type = TYPE_NUMBER;
     ReFormatDefaultValue();
 }
 /// <summary>
 /// Class constructor. Instantiates a new <see cref="XBeeSettingCombo"/> object with the
 /// provided parameters.
 /// </summary>
 /// <param name="atCommand">The AT command corresponding to the setting.</param>
 /// <param name="name">Name of the setting.</param>
 /// <param name="description">Description of the setting.</param>
 /// <param name="defaultValue">Default value of the setting.</param>
 /// <param name="category">Parent category of the setting.</param>
 /// <param name="ownerFirmware">XBee firmware the setting belongs to.</param>
 /// <param name="numNetworks">The number of networks the setting can be configured for.</param>
 /// <seealso cref="XBeeCategory"/>
 /// <seealso cref="XBeeFirmware"/>
 public XBeeSettingCombo(string atCommand, string name, string description,
                         string defaultValue, XBeeCategory category, XBeeFirmware ownerFirmware, int numNetworks)
     : base(atCommand, name, description, defaultValue, category, ownerFirmware, numNetworks)
 {
     Type = TYPE_COMBO;
     if (DefaultValue.ToLower().StartsWith("0x"))
     {
         DefaultValue = DefaultValue.Substring(2);
     }
 }
        /// <summary>
        /// Clones and returns the setting object.
        /// </summary>
        /// <param name="parentCategory">The parent category where the cloned setting should be placed.</param>
        /// <param name="ownerFirmware">The owner firmware of the cloned setting.</param>
        /// <returns>The cloned setting object.</returns>
        /// <seealso cref="AbstractXBeeSetting"/>
        public new AbstractXBeeSetting CloneSetting(XBeeCategory parentCategory, XBeeFirmware ownerFirmware)
        {
            XBeeSettingCombo clonedSetting = (XBeeSettingCombo)base.CloneSetting(parentCategory, ownerFirmware);

            // Clone the list of items and set it to the cloned setting.
            List <string> clonedItems = new List <string>();

            clonedItems.AddRange(Items);
            clonedSetting.Items = clonedItems;

            return(clonedSetting);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Clones and returns the setting object.
        /// </summary>
        /// <param name="parentCategory">The parent category where the cloned setting should be placed.</param>
        /// <param name="ownerFirmware">The owner firmware of the cloned setting.</param>
        /// <returns>The cloned setting object.</returns>
        /// <seealso cref="AbstractXBeeDevice"/>
        public new AbstractXBeeSetting CloneSetting(XBeeCategory parentCategory, XBeeFirmware ownerFirmware)
        {
            XBeeSettingText clonedSetting = (XBeeSettingText)base.CloneSetting(parentCategory, ownerFirmware);

            // Clone the attributes of this object.
            clonedSetting.MinChars       = MinChars;
            clonedSetting.MaxChars       = MaxChars;
            clonedSetting.Format         = Format;
            clonedSetting.ExceptionValue = ExceptionValue;

            return(clonedSetting);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Adds the number of settings contained in the given <paramref name="category"/> to the
        /// provided <paramref name="atSettingsNumber"/> value.
        /// </summary>
        /// <param name="category">The category to get the number of settings that it contains.</param>
        /// <param name="atSettingsNumber">The value to append the number of settings of the category.</param>
        /// <seealso cref="XBeeCategory"/>
        private void AddATSettingsNumber(XBeeCategory category, int atSettingsNumber)
        {
            foreach (AbstractXBeeSetting xbeeSetting in category.Settings)
            {
                atSettingsNumber += 1;
            }

            foreach (XBeeCategory subCategory in category.Categories)
            {
                AddATSettingsNumber(subCategory, atSettingsNumber);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Adds a setting to the list of settings of the firmware.
        /// </summary>
        /// <param name="category">The configuration category the setting belongs to.</param>
        /// <param name="atSettings">The setting to add.</param>
        /// <seealso cref="AbstractXBeeSetting"/>
        /// <seealso cref="XBeeCategory"/>
        private void AddATSettings(XBeeCategory category, List <AbstractXBeeSetting> atSettings)
        {
            foreach (AbstractXBeeSetting xbeeSetting in category.Settings)
            {
                atSettings.Add(xbeeSetting);
            }

            foreach (XBeeCategory subCategory in category.Categories)
            {
                AddATSettings(subCategory, atSettings);
            }
        }
        /// <summary>
        /// Clones and returns the setting object.
        /// </summary>
        /// <param name="parentCategory">The parent category where the cloned setting should be placed.</param>
        /// <param name="ownerFirmware">The owner firmware of the cloned setting.</param>
        /// <returns>The cloned setting object.</returns>
        /// <seealso cref="AbstractXBeeSetting"/>
        public new AbstractXBeeSetting CloneSetting(XBeeCategory parentCategory, XBeeFirmware ownerFirmware)
        {
            XBeeSettingNumber clonedSetting = (XBeeSettingNumber)base.CloneSetting(parentCategory, ownerFirmware);

            // Clone the list of items and set it to the cloned setting.
            List <string> clonedAdditionalValues = new List <string>();

            clonedAdditionalValues.AddRange(AdditionalValues);
            clonedSetting.AdditionalValues = clonedAdditionalValues;

            return(clonedSetting);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Adds the dual settings of the prvided <paramref name="category"/> to the given
        /// <paramref name="atDualSettings"/> list.
        /// </summary>
        /// <param name="category">The category to look for dual settings.</param>
        /// <param name="atDualSettings">List of settings where dual ones will be added.</param>
        /// <seealso cref="AbstractXBeeSetting"/>
        /// <seealso cref="XBeeCategory"/>
        private void AddDualATSettings(XBeeCategory category, List <AbstractXBeeSetting> atDualSettings)
        {
            foreach (AbstractXBeeSetting xbeeSetting in category.Settings)
            {
                if (xbeeSetting.SupportsMultipleNetworks())
                {
                    atDualSettings.Add(xbeeSetting);
                }
            }

            foreach (XBeeCategory subCategory in category.Categories)
            {
                AddDualATSettings(subCategory, atDualSettings);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Returns the setting corresponding to the provided <paramref name="atCommand"/> and located
        /// in the given <paramref name="category"/>.
        /// </summary>
        /// <param name="atCommand">The AT command corresponding to the setting to get.</param>
        /// <param name="category">The configuration category where the setting should be found.</param>
        /// <returns>The setting corresponding to the provided AT command and category.</returns>
        /// <seealso cref="AbstractXBeeSetting"/>
        /// <seealso cref="XBeeCategory"/>
        private AbstractXBeeSetting GetAtSetting(string atCommand, XBeeCategory category)
        {
            foreach (AbstractXBeeSetting xbeeSetting in category.Settings)
            {
                if (xbeeSetting.AtCommand != null &&
                    xbeeSetting.AtCommand.ToUpper().Equals(atCommand.ToUpper()))
                {
                    return(xbeeSetting);
                }
            }

            foreach (XBeeCategory subCategory in category.Categories)
            {
                AbstractXBeeSetting atSetting = GetAtSetting(atCommand, subCategory);
                if (atSetting != null)
                {
                    return(atSetting);
                }
            }
            return(null);
        }
        /// <summary>
        /// Clones and returns the setting object.
        /// </summary>
        /// <param name="parentCategory">The parent category where the cloned setting should be placed.</param>
        /// <param name="ownerFirmware">The owner firmware of the cloned setting.</param>
        /// <returns>The cloned setting object.</returns>
        public AbstractXBeeSetting CloneSetting(XBeeCategory parentCategory, XBeeFirmware ownerFirmware)
        {
            AbstractXBeeSetting clonedSetting = (AbstractXBeeSetting)Clone();

            clonedSetting.ParentCategory = parentCategory;
            clonedSetting.OwnerFirmware  = ownerFirmware;

            // Clone the list of current values.
            List <string> clonedCurrentValues = new List <string>();

            clonedCurrentValues.AddRange(CurrentValues);
            clonedSetting.CurrentValues = clonedCurrentValues;

            // Clone the list of XBee values.
            List <string> clonedXBeeValues = new List <string>();

            clonedXBeeValues.AddRange(XBeeValues);
            clonedSetting.XBeeValues = clonedXBeeValues;

            return(clonedSetting);
        }
        /// <summary>
        /// Class constructor. Instantiates a new <see cref="AbstractXBeeSetting"/> object with the
        /// provided parameters.
        /// </summary>
        /// <param name="atCommand">The AT command corresponding to the setting.</param>
        /// <param name="name">Name of the setting.</param>
        /// <param name="description">Description of the setting.</param>
        /// <param name="defaultValue">Default value of the setting.</param>
        /// <param name="parentCategory">Parent category of the setting.</param>
        /// <param name="ownerFirmware">XBee firmware the setting belongs to.</param>
        /// <param name="numNetworks">The number of networks the setting can be configured for.</param>
        protected AbstractXBeeSetting(string atCommand, string name, string description, string defaultValue,
                                      XBeeCategory parentCategory, XBeeFirmware ownerFirmware, int numNetworks)
        {
            AtCommand      = atCommand;
            Name           = name;
            Description    = description;
            DefaultValue   = defaultValue;
            ParentCategory = parentCategory;
            OwnerFirmware  = ownerFirmware;
            NumNetworks    = numNetworks;

            // Fill values with default value.
            for (int i = 0; i < numNetworks; i++)
            {
                CurrentValues.Add(defaultValue);
            }

            // Fill XBee values with default value.
            for (int i = 0; i < numNetworks; i++)
            {
                XBeeValues.Add(defaultValue);
            }
        }
Exemplo n.º 14
0
 /// <summary>
 /// Class constructor. Instantiates a new <see cref="XBeeSettingText"/> object with the
 /// provided parameters.
 /// </summary>
 /// <param name="atCommand">The AT command corresponding to the setting.</param>
 /// <param name="name">Name of the setting.</param>
 /// <param name="description">Description of the setting.</param>
 /// <param name="defaultValue">Default value of the setting.</param>
 /// <param name="category">Parent category of the setting.</param>
 /// <param name="ownerFirmware">XBee firmware the setting belongs to.</param>
 /// <seealso cref="XBeeCategory"/>
 /// <seealso cref="XBeeFirmware"/>
 public XBeeSettingText(string atCommand, string name, string description,
                        string defaultValue, XBeeCategory category, XBeeFirmware ownerFirmware)
     : base(atCommand, name, description, defaultValue, category, ownerFirmware, 1)
 {
 }
Exemplo n.º 15
0
 /// <summary>
 /// Class constructor. Instantiates a new <see cref="XBeeSettingText"/> object with the
 /// provided parameters.
 /// </summary>
 /// <param name="name">Name of the setting.</param>
 /// <param name="description">Description of the setting.</param>
 /// <param name="defaultValue">Default value of the setting.</param>
 /// <param name="category">Parent category of the setting.</param>
 /// <param name="ownerFirmware">XBee firmware the setting belongs to.</param>
 /// <param name="numNetworks">The number of networks the setting can be configured for.</param>
 /// <seealso cref="XBeeCategory"/>
 /// <seealso cref="XBeeFirmware"/>
 public XBeeSettingText(string name, string description, string defaultValue,
                        XBeeCategory category, XBeeFirmware ownerFirmware, int numNetworks)
     : base(name, description, defaultValue, category, ownerFirmware, numNetworks)
 {
     Type = TYPE_TEXT;
 }
Exemplo n.º 16
0
 /// <summary>
 /// Class constructor. Instantiates a new <see cref="XBeeSettingText"/> object with the
 /// provided parameters.
 /// </summary>
 /// <param name="name">Name of the setting.</param>
 /// <param name="description">Description of the setting.</param>
 /// <param name="defaultValue">Default value of the setting.</param>
 /// <param name="category">Parent category of the setting.</param>
 /// <param name="ownerFirmware">XBee firmware the setting belongs to.</param>
 /// <seealso cref="XBeeCategory"/>
 /// <seealso cref="XBeeFirmware"/>
 public XBeeSettingText(string name, string description, string defaultValue,
                        XBeeCategory category, XBeeFirmware ownerFirmware)
     : this(name, description, defaultValue, category, ownerFirmware, 1)
 {
 }
 /// <summary>
 /// Class constructor. Instantiates a new <see cref="AbstractXBeeSetting"/> object with the
 /// provided parameters.
 /// </summary>
 /// <param name="atCommand">The AT command corresponding to the setting.</param>
 /// <param name="name">Name of the setting.</param>
 /// <param name="description">Description of the setting.</param>
 /// <param name="defaultValue">Default value of the setting.</param>
 /// <param name="parentCategory">Parent category of the setting.</param>
 /// <param name="ownerFirmware">XBee firmware the setting belongs to.</param>
 protected AbstractXBeeSetting(string atCommand, string name, string description,
                               string defaultValue, XBeeCategory parentCategory, XBeeFirmware ownerFirmware)
     : this(atCommand, name, description, defaultValue, parentCategory, ownerFirmware, 1)
 {
 }
 /// <summary>
 /// Class constructor. Instantiates a new <see cref="AbstractXBeeSetting"/> object with the
 /// provided parameters.
 /// </summary>
 /// <param name="name">Name of the setting.</param>
 /// <param name="description">Description of the setting.</param>
 /// <param name="defaultValue">Default value of the setting.</param>
 /// <param name="parentCategory">Parent category of the setting.</param>
 /// <param name="ownerFirmware">XBee firmware the setting belongs to.</param>
 /// <param name="numNetworks">The number of networks the setting can be configured for.</param>
 protected AbstractXBeeSetting(string name, string description, string defaultValue,
                               XBeeCategory parentCategory, XBeeFirmware ownerFirmware, int numNetworks)
     : this(null, name, description, defaultValue, parentCategory, ownerFirmware, numNetworks)
 {
 }