/// <summary>
        /// Returns the default selected index.
        /// </summary>
        /// <returns>The default selected index.</returns>
        public int GetDefaultSelectedIndex()
        {
            if (!ParsingUtils.IsHexadecimal(DefaultValue))
            {
                return(0);
            }

            return(ParsingUtils.HexStringToInt(DefaultValue));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns the XBee value (value stored in the XBee module) of the baud rate setting of the firmware.
        /// </summary>
        /// <returns>The XBee value of the baud rate setting of the firmware.</returns>
        public int GetSerialBaudRate()
        {
            AbstractXBeeSetting atSetting = GetAtSetting(SERIAL_SETTING_BAUD_RATE);

            if (atSetting != null)
            {
                // Do not specify the network stack of the BD parameter by the moment (it's a common value).
                // TODO: [DUAL] When this setting is implemented individually for each network stack, update this code to
                //       specify the network ID from which this parameter should be read.
                string settingValue = atSetting.GetXBeeValue();
                if (!ParsingUtils.IsHexadecimal(atSetting.GetXBeeValue()))
                {
                    return(DEFAULT_SERIAL_BAUD_RATE);
                }

                switch (ParsingUtils.HexStringToInt(settingValue))
                {
                case 0:
                    return(1200);

                case 1:
                    return(2400);

                case 2:
                    return(4800);

                case 3:
                    return(9600);

                case 4:
                    return(19200);

                case 5:
                    return(38400);

                case 6:
                    return(57600);

                case 7:
                    return(115200);

                case 8:
                    return(230400);

                case 9:
                    return(460800);

                case 10:
                    return(921600);

                default:
                    return(DEFAULT_SERIAL_BAUD_RATE);
                }
            }
            return(DEFAULT_SERIAL_BAUD_RATE);
        }