// Returns the Reference voltage , indexed by the configuration tab.
 private decimal GetRefVoltage(int refVoltageConfIndex)
 {
     CyADC_DelSigParameters prms = new CyADC_DelSigParameters(m_Component);
     // Reference voltage.
     float tempFloat = 0;
     switch (refVoltageConfIndex)
     {
         case 1:
             float.TryParse(prms.m_Ref_Voltage.Value, out tempFloat);
             if (m_cbReference.SelectedItem.ToString().Contains(INTERNAL_BYPASSED) ||
                 m_cbReference.SelectedItem.ToString().Contains(REF_INTERNAL_REF) ||
                 m_cbReference.SelectedItem.ToString().Contains(INTERNAL_VDDA_4) ||
                 m_cbReference.SelectedItem.ToString().Contains(INTERNAL_VDDA_3))
                 tempFloat = (float) m_nudRefVoltage.Value;
             break;
         case 2:
             float.TryParse(prms.m_Ref_Voltage_Config2.Value, out tempFloat);
             if (m_cbReference2.SelectedItem.ToString().Contains(INTERNAL_BYPASSED) ||
                 m_cbReference2.SelectedItem.ToString().Contains(REF_INTERNAL_REF) ||
                 m_cbReference2.SelectedItem.ToString().Contains(INTERNAL_VDDA_4) ||
                 m_cbReference2.SelectedItem.ToString().Contains(INTERNAL_VDDA_3))
                 tempFloat = (float)m_nudRefVoltage2.Value;
             break;
         case 3:
             float.TryParse(prms.m_Ref_Voltage_Config3.Value, out tempFloat);
             if (m_cbReference3.SelectedItem.ToString().Contains(INTERNAL_BYPASSED) ||
                 m_cbReference3.SelectedItem.ToString().Contains(REF_INTERNAL_REF) ||
                 m_cbReference3.SelectedItem.ToString().Contains(INTERNAL_VDDA_4) ||
                 m_cbReference3.SelectedItem.ToString().Contains(INTERNAL_VDDA_3))
                 tempFloat = (float)m_nudRefVoltage3.Value;
             break;
         case 4:
             float.TryParse(prms.m_Ref_Voltage_Config4.Value, out tempFloat);
             if (m_cbReference4.SelectedItem.ToString().Contains(INTERNAL_BYPASSED) ||
                 m_cbReference4.SelectedItem.ToString().Contains(REF_INTERNAL_REF) ||
                 m_cbReference4.SelectedItem.ToString().Contains(INTERNAL_VDDA_4) ||
                 m_cbReference4.SelectedItem.ToString().Contains(INTERNAL_VDDA_3))
                 tempFloat = (float)m_nudRefVoltage4.Value;
             break;
         default:
             // Should not fall here, as of now only 4 configuration is supported.
             tempFloat = -1;
             break;
     }
     return (decimal)tempFloat;
 }
        private void CyADC_DelSigControl_Load(object sender, EventArgs e)
        {
            CyADC_DelSigParameters prms = new CyADC_DelSigParameters(m_Component);
            string paramInputBufferGain = m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.INPUT_BUFFER_GAIN,
                prms.m_Input_Buffer_Gain.Expr);

            string prm = m_Component.ResolveEnumDisplayToId(CyADC_DelSigParameters.ADC_REFERENCE, m_cbReference.Text);
            SetAParameter(CyADC_DelSigParameters.ADC_REFERENCE, prm, false);

            prm = m_Component.ResolveEnumDisplayToId(CyADC_DelSigParameters.ADC_REFERENCE_CONFIG2,
                                                     m_cbReference2.Text);
            SetAParameter(CyADC_DelSigParameters.ADC_REFERENCE_CONFIG2, prm, false);

            prm = m_Component.ResolveEnumDisplayToId(CyADC_DelSigParameters.ADC_REFERENCE_CONFIG3,
                                                      m_cbReference3.Text);
            SetAParameter(CyADC_DelSigParameters.ADC_REFERENCE_CONFIG3, prm, false);

            prm = m_Component.ResolveEnumDisplayToId(CyADC_DelSigParameters.ADC_REFERENCE_CONFIG4,
                                                      m_cbReference4.Text);
            SetAParameter(CyADC_DelSigParameters.ADC_REFERENCE_CONFIG4, prm, false);

            prm = m_Component.ResolveEnumDisplayToId(CyADC_DelSigParameters.REF_VOLTAGE, m_nudRefVoltage.Text);
            SetAParameter(CyADC_DelSigParameters.REF_VOLTAGE, prm, false);

            prm = m_Component.ResolveEnumDisplayToId(CyADC_DelSigParameters.REF_VOLTAGE_CONFIG2,
                                                      m_nudRefVoltage2.Text);
            SetAParameter(CyADC_DelSigParameters.REF_VOLTAGE_CONFIG2, prm, false);

            prm = m_Component.ResolveEnumDisplayToId(CyADC_DelSigParameters.REF_VOLTAGE_CONFIG3,
                                                      m_nudRefVoltage3.Text);
            SetAParameter(CyADC_DelSigParameters.REF_VOLTAGE_CONFIG3, prm, false);

            prm = m_Component.ResolveEnumDisplayToId(CyADC_DelSigParameters.REF_VOLTAGE_CONFIG4,
                                                      m_nudRefVoltage4.Text);
            SetAParameter(CyADC_DelSigParameters.REF_VOLTAGE_CONFIG4, prm, false);

            // Test the input Buffer gain when loading and if not valid input buffer gain found
            // assign the default value
            if (!m_cbInputBufferGain.Items.Contains(paramInputBufferGain))
            {
                m_cbInputBufferGain.SelectedItem = "Gain_1X";
                m_cbInputBufferGain.Text = "1";
                SetAParameter(CyADC_DelSigParameters.INPUT_BUFFER_GAIN, "Gain_1X", false);
            }
        }
        // Update the ADC mode of all configuration tabs.
        private bool UpdateInputRangeList1(bool not)
        {
            float vrefValue;
            string tempStr;
            bool retVal = true;
            IEnumerable<string> InputRangeEnums = m_Component.GetPossibleEnumValues(
                                                   CyADC_DelSigParameters.INPUT_RANGE);
            CyADC_DelSigParameters prms = new CyADC_DelSigParameters(m_Component);
            float.TryParse(prms.m_Ref_Voltage.Value, out vrefValue);

            // Since we dont save the VDDA value in to symbol for input range type VDDA selection

            int index = 0;

            m_cbInputRange.Items.Clear();
            m_cbInputRange2.Items.Clear();
            m_cbInputRange3.Items.Clear();
            m_cbInputRange4.Items.Clear();

            List<string> modifiedInputRange = new List<string>();
            foreach (string str in InputRangeEnums)
            {
                tempStr = String.Format(InputRangeFormat[index], (vrefValue * adcGain[index]).ToString());
                modifiedInputRange.Add(tempStr);

                index++;
            }

            if (m_rbModeDifferential.Checked)
            {
                m_rbModeDifferential2.Checked = true;
                m_rbModeDifferential3.Checked = true;
                m_rbModeDifferential4.Checked = true;
                // ONLY show the differential options in the "Input Range" paramter.
                for (int i = 0; i < modifiedInputRange.Count; i++)
                {
                    string str = modifiedInputRange[i];
                    if (!str.Contains(INPUT_SINGLE_TYPE))
                    {
                        m_cbInputRange.Items.Add(str);
                        m_cbInputRange2.Items.Add(str);
                        m_cbInputRange3.Items.Add(str);
                        m_cbInputRange4.Items.Add(str);
                    }
                }
            }
            else
            {
                m_rbModeSingle2.Checked = true;
                m_rbModeSingle3.Checked = true;
                m_rbModeSingle4.Checked = true;
                // ONLY show the single options in the "Input Range" paramter.
                for (int i = 0; i < modifiedInputRange.Count; i++)
                {
                    string str = modifiedInputRange[i];
                    if (str.Contains(INPUT_SINGLE_TYPE))
                    {
                        m_cbInputRange.Items.Add(str);
                        m_cbInputRange2.Items.Add(str);
                        m_cbInputRange3.Items.Add(str);
                        m_cbInputRange4.Items.Add(str);
                    }
                }
            }

            UpdateInputModeSelection(m_cbInputRange, CyADC_DelSigParameters.INPUT_RANGE, prms.m_ADC_Input_Range.Expr);
            UpdateInputModeSelection(m_cbInputRange2, CyADC_DelSigParameters.INPUT_RANGE_CONFIG2,
                prms.m_ADC_Input_Range_Config2.Expr);
            UpdateInputModeSelection(m_cbInputRange3, CyADC_DelSigParameters.INPUT_RANGE_CONFIG3,
                prms.m_ADC_Input_Range_Config3.Expr);
            UpdateInputModeSelection(m_cbInputRange4, CyADC_DelSigParameters.INPUT_RANGE_CONFIG4,
                prms.m_ADC_Input_Range_Config4.Expr);

            return retVal;
        }
        // Update the ADC mode of all configuration tabs
        private void UpdateInputRangeList(int index)
        {
            float vrefValue;
            CyADC_DelSigParameters prms = new CyADC_DelSigParameters(m_Component);
            vrefValue = (float) GetRefVoltage(index);

            switch (index)
            {
                case 1:
                    UpdateInputRangeList(m_cbInputRange, vrefValue);
                    UpdateInputModeSelection(m_cbInputRange, CyADC_DelSigParameters.INPUT_RANGE,
                        prms.m_ADC_Input_Range.Expr);
                    break;
                case 2:
                    UpdateInputRangeList(m_cbInputRange2, vrefValue);
                    UpdateInputModeSelection(m_cbInputRange2, CyADC_DelSigParameters.INPUT_RANGE_CONFIG2,
                        prms.m_ADC_Input_Range_Config2.Expr);
                    break;
                case 3:
                    UpdateInputRangeList(m_cbInputRange3, vrefValue);
                    UpdateInputModeSelection(m_cbInputRange3, CyADC_DelSigParameters.INPUT_RANGE_CONFIG3,
                        prms.m_ADC_Input_Range_Config3.Expr);
                    break;
                case 4:
                    UpdateInputRangeList(m_cbInputRange4, vrefValue);
                    UpdateInputModeSelection(m_cbInputRange4, CyADC_DelSigParameters.INPUT_RANGE_CONFIG4,
                        prms.m_ADC_Input_Range_Config4.Expr);
                    break;
                default:
                    break;

            }
        }
        private void UpdateInputRangeList(ComboBox list, float vrefValue)
        {
            IEnumerable<string> InputRangeEnums = m_Component.GetPossibleEnumValues(
                                                  CyADC_DelSigParameters.INPUT_RANGE);
            CyADC_DelSigParameters prms = new CyADC_DelSigParameters(m_Component);
            int index = 0;
            string tempStr;
            List<string> modifiedInputRange = new List<string>();
            foreach (string str in InputRangeEnums)
            {
                tempStr = String.Format(InputRangeFormat[index], (vrefValue * adcGain[index]).ToString());
                modifiedInputRange.Add(tempStr);

                index++;
            }

            list.Items.Clear();
            if (m_rbModeDifferential.Checked)
            {
                // ONLY show the differential options in the "Input Range" paramter.
                for (int i = 0; i < modifiedInputRange.Count; i++)
                {
                    string str = modifiedInputRange[i];
                    if (!str.Contains(INPUT_SINGLE_TYPE))// && m_rbModeDifferential.Checked)
                    {
                        list.Items.Add(str);
                    }
                }
            }
            else
            {
                // ONLY show the single options in the "Input Range" paramter.
                for (int i = 0; i < modifiedInputRange.Count; i++)
                {
                    string str = modifiedInputRange[i];
                    if (str.Contains(INPUT_SINGLE_TYPE))
                    {
                        list.Items.Add(str);
                    }
                }
            }
        }
        public void UpdateFormFromParams(ICyInstEdit_v1 inst)
        {
            UnhookAllEvents();
            CyADC_DelSigParameters prms = new CyADC_DelSigParameters(inst);

            #region Config1
            //Set the ADC resolution
            string paramResolution = m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.RESOLUTION,
                prms.m_ADC_Resolution.Expr);
            if (m_cbResolution.Items.Contains(paramResolution))
            {
                m_cbResolution.SelectedItem = paramResolution;
                m_cbResolution.Text = prms.m_ADC_Resolution.Expr;
            }

            // set the ADC mode
            string paramAdcMode = m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.ADC_INPUT_MODE,
                prms.m_ADC_Input_Mode.Expr);
            if (!paramAdcMode.Contains(INPUT_DIFFERENTIAL))
            {
                m_rbModeSingle.Checked = true;
            }

            //Set the ADC Input Range
            string paramInputRange = m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.INPUT_RANGE,
                prms.m_ADC_Input_Range.Expr);
            if (m_cbInputRange.Items.Contains(paramInputRange))
            {
                m_cbInputRange.SelectedItem = paramInputRange;
                m_cbInputRange.Text = prms.m_ADC_Input_Range.Expr;
            }

            //Set the Input Buffer Gain
            string paramInputBufferGain = m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.INPUT_BUFFER_GAIN,
                prms.m_Input_Buffer_Gain.Expr);
            if (m_cbInputBufferGain.Items.Contains(paramInputBufferGain))
            {
                m_cbInputBufferGain.SelectedItem = paramInputBufferGain;
                m_cbInputBufferGain.Text = prms.m_Input_Buffer_Gain.Expr;
            }

            //Set the Conversion Mode
            string paramConvMode = m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.CONVERSION_MODE,
                prms.m_Conversion_Mode.Expr);
            if (m_cbConvMode.Items.Contains(paramConvMode))
            {
                m_cbConvMode.SelectedItem = paramConvMode;
                m_cbConvMode.Text = prms.m_Conversion_Mode.Expr;
            }

            //Set ADC Reference
            string paramReference = m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.ADC_REFERENCE,
                prms.m_ADC_Reference.Expr);
            if (m_cbReference.Items.Contains(paramReference))
            {
                m_cbReference.SelectedItem = paramReference;
                m_cbReference.Text = prms.m_ADC_Reference.Expr;
            }

            //Set ADC Input Buffer Mode
            string paramBufferMode = m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.INPUT_BUFFER_MODE,
                prms.m_Input_Buffer_Mode.Expr);
            if (m_cbInputBufferMode.Items.Contains(paramBufferMode))
            {
                m_cbInputBufferMode.SelectedItem = paramBufferMode;
                m_cbInputBufferMode.Text = prms.m_Input_Buffer_Mode.Expr;
            }

            //Reference voltage.
            float tempFloat;
            float.TryParse(prms.m_Ref_Voltage.Value, out tempFloat);
            m_nudRefVoltage.Value = (decimal)tempFloat;

            // Conversion/Sample Rate
            int tempSampleRate;
            int.TryParse(prms.m_Sample_Rate.Value, out tempSampleRate);
            m_nudConvRate.Value = (decimal)tempSampleRate;

            // Comment text box
            commentTextBox1.Text = prms.m_Comment_Config1.Value;

            // Config Name text box
            configNameTextBox1.Text = prms.m_Config1_Name.Value;
            nameLabel1.Text = inst.InstanceName + "_" + prms.m_Config1_Name.Value;

            #endregion

            #region Config2
            //Set the ADC resolution
            string paramResolution2 = m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.RESOLUTION_CONFIG2,
                prms.m_ADC_Resolution_Config2.Expr);
            if (m_cbResolutionConfig2.Items.Contains(paramResolution2))
            {
                m_cbResolutionConfig2.SelectedItem = paramResolution2;
                m_cbResolutionConfig2.Text = prms.m_ADC_Resolution_Config2.Expr;
            }

            //Set the ADC Input Range
            string paramInputRange2 = m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.INPUT_RANGE_CONFIG2,
                prms.m_ADC_Input_Range_Config2.Expr);
            if (m_cbInputRange2.Items.Contains(paramInputRange2))
            {
                m_cbInputRange2.SelectedItem = paramInputRange2;
                m_cbInputRange2.Text = prms.m_ADC_Input_Range_Config2.Expr;
            }

            //Set the Input Buffer Gain
            string paramInputBufferGain2 = m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.INPUT_BUFFER_GAIN,
                prms.m_Input_Buffer_Gain_Config2.Expr);
            if (m_cbInputBufferGain2.Items.Contains(paramInputBufferGain2))
            {
                m_cbInputBufferGain2.SelectedItem = paramInputBufferGain2;
                m_cbInputBufferGain2.Text = prms.m_Input_Buffer_Gain_Config2.Expr;
            }

            //Set the Conversion Mode
            string paramConvMode2 = m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.CONVERSION_MODE,
                prms.m_Conversion_Mode_Config2.Expr);
            if (m_cbConvMode2.Items.Contains(paramConvMode2))
            {
                m_cbConvMode2.SelectedItem = paramConvMode2;
                m_cbConvMode2.Text = prms.m_Conversion_Mode_Config2.Expr;
            }

            //Set ADC Reference
            string paramReference2 = m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.ADC_REFERENCE,
                prms.m_ADC_Reference_Config2.Expr);
            if (m_cbReference2.Items.Contains(paramReference2))
            {
                m_cbReference2.SelectedItem = paramReference2;
                m_cbReference2.Text = prms.m_ADC_Reference_Config2.Expr;
            }

            //Set ADC Input Buffer Mode
            string paramBufferMode2 = m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.INPUT_BUFFER_MODE,
                prms.m_Input_Buffer_Mode_Config2.Expr);
            if (m_cbInputBufferMode2.Items.Contains(paramBufferMode2))
            {
                m_cbInputBufferMode2.SelectedItem = paramBufferMode2;
                m_cbInputBufferMode2.Text = prms.m_Input_Buffer_Mode_Config2.Expr;
            }

            //Reference voltage.
            float.TryParse(prms.m_Ref_Voltage_Config2.Value, out tempFloat);
            m_nudRefVoltage2.Value = (decimal)tempFloat;

            // Conversion/Sample Rate
            int.TryParse(prms.m_Sample_Rate_Config2.Value, out tempSampleRate);
            m_nudConvRate2.Value = (decimal)tempSampleRate;

            // Comment text box
            commentTextBox2.Text = prms.m_Comment_Config2.Value;

            // Config Name text box
            configNameTextBox2.Text = prms.m_Config2_Name.Value;
            nameLabel2.Text = inst.InstanceName + "_" + prms.m_Config2_Name.Value;

            #endregion

            #region Config3
            //Set the ADC resolution
            string paramResolution3 = m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.RESOLUTION_CONFIG3,
                prms.m_ADC_Resolution_Config3.Expr);
            if (m_cbResolutionConfig3.Items.Contains(paramResolution3))
            {
                m_cbResolutionConfig3.SelectedItem = paramResolution3;
                m_cbResolutionConfig3.Text = prms.m_ADC_Resolution_Config3.Expr;
            }

            //Set the ADC Input Range
            string paramInputRange3 = m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.INPUT_RANGE_CONFIG3,
                prms.m_ADC_Input_Range_Config3.Expr);
            if (m_cbInputRange3.Items.Contains(paramInputRange3))
            {
                m_cbInputRange3.SelectedItem = paramInputRange3;
                m_cbInputRange3.Text = prms.m_ADC_Input_Range_Config3.Expr;
            }

            //Set the Input Buffer Gain
            string paramInputBufferGain3 = m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.INPUT_BUFFER_GAIN,
                prms.m_Input_Buffer_Gain_Config3.Expr);
            if (m_cbInputBufferGain3.Items.Contains(paramInputBufferGain3))
            {
                m_cbInputBufferGain3.SelectedItem = paramInputBufferGain3;
                m_cbInputBufferGain3.Text = prms.m_Input_Buffer_Gain_Config3.Expr;
            }

            //Set the Conversion Mode
            string paramConvMode3 = m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.CONVERSION_MODE,
                prms.m_Conversion_Mode_Config3.Expr);
            if (m_cbConvMode3.Items.Contains(paramConvMode3))
            {
                m_cbConvMode3.SelectedItem = paramConvMode3;
                m_cbConvMode3.Text = prms.m_Conversion_Mode_Config3.Expr;
            }

            //Set ADC Reference
            string paramReference3 = m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.ADC_REFERENCE,
                prms.m_ADC_Reference_Config3.Expr);
            if (m_cbReference3.Items.Contains(paramReference3))
            {
                m_cbReference3.SelectedItem = paramReference3;
                m_cbReference3.Text = prms.m_ADC_Reference_Config3.Expr;
            }

            //Set ADC Input Buffer Mode
            string paramBufferMode3 = m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.INPUT_BUFFER_MODE,
                prms.m_Input_Buffer_Mode_Config3.Expr);
            if (m_cbInputBufferMode3.Items.Contains(paramBufferMode3))
            {
                m_cbInputBufferMode3.SelectedItem = paramBufferMode3;
                m_cbInputBufferMode3.Text = prms.m_Input_Buffer_Mode_Config3.Expr;
            }

            //Reference voltage.
            float.TryParse(prms.m_Ref_Voltage_Config3.Value, out tempFloat);
            m_nudRefVoltage3.Value = (decimal)tempFloat;

            // Conversion/Sample Rate
            int.TryParse(prms.m_Sample_Rate_Config3.Value, out tempSampleRate);
            m_nudConvRate3.Value = (decimal)tempSampleRate;

            // Comment text box
            commentTextBox3.Text = prms.m_Comment_Config3.Value;

            // Config Name text box
            configNameTextBox3.Text = prms.m_Config3_Name.Value;
            nameLabel3.Text = inst.InstanceName + "_" + prms.m_Config3_Name.Value;

            #endregion

            #region Config4
            //Set the ADC resolution
            string paramResolution4 = m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.RESOLUTION_CONFIG4,
                prms.m_ADC_Resolution_Config4.Expr);
            if (m_cbResolutionConfig4.Items.Contains(paramResolution4))
            {
                m_cbResolutionConfig4.SelectedItem = paramResolution4;
                m_cbResolutionConfig4.Text = prms.m_ADC_Resolution_Config4.Expr;
            }

            //Set the ADC Input Range
            string paramInputRange4 = m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.INPUT_RANGE_CONFIG4,
                prms.m_ADC_Input_Range_Config4.Expr);
            if (m_cbInputRange4.Items.Contains(paramInputRange4))
            {
                m_cbInputRange4.SelectedItem = paramInputRange4;
                m_cbInputRange4.Text = prms.m_ADC_Input_Range_Config4.Expr;
            }

            //Set the Input Buffer Gain
            string paramInputBufferGain4 = m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.INPUT_BUFFER_GAIN,
                prms.m_Input_Buffer_Gain_Config4.Expr);
            if (m_cbInputBufferGain4.Items.Contains(paramInputBufferGain4))
            {
                m_cbInputBufferGain4.SelectedItem = paramInputBufferGain4;
                m_cbInputBufferGain4.Text = prms.m_Input_Buffer_Gain_Config4.Expr;
            }

            //Set the Conversion Mode
            string paramConvMode4 = m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.CONVERSION_MODE,
                prms.m_Conversion_Mode_Config4.Expr);
            if (m_cbConvMode4.Items.Contains(paramConvMode4))
            {
                m_cbConvMode4.SelectedItem = paramConvMode4;
                m_cbConvMode4.Text = prms.m_Conversion_Mode_Config4.Expr;
            }

            //Set ADC Reference
            string paramReference4 = m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.ADC_REFERENCE,
                prms.m_ADC_Reference_Config4.Expr);
            if (m_cbReference4.Items.Contains(paramReference4))
            {
                m_cbReference4.SelectedItem = paramReference4;
                m_cbReference4.Text = prms.m_ADC_Reference_Config4.Expr;
            }

            //Set ADC Input Buffer Mode
            string paramBufferMode4 = m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.INPUT_BUFFER_MODE,
                prms.m_Input_Buffer_Mode_Config4.Expr);
            if (m_cbInputBufferMode4.Items.Contains(paramBufferMode4))
            {
                m_cbInputBufferMode4.SelectedItem = paramBufferMode4;
                m_cbInputBufferMode4.Text = prms.m_Input_Buffer_Mode_Config4.Expr;
            }
            //Reference voltage.
            float.TryParse(prms.m_Ref_Voltage_Config4.Value, out tempFloat);
            m_nudRefVoltage4.Value = (decimal)tempFloat;

            // Conversion/Sample Rate
            int.TryParse(prms.m_Sample_Rate_Config4.Value, out tempSampleRate);
            m_nudConvRate4.Value = (decimal)tempSampleRate;

            // Comment text box
            commentTextBox4.Text = prms.m_Comment_Config4.Value;

            // Config Name text box
            configNameTextBox4.Text = prms.m_Config4_Name.Value;
            nameLabel4.Text = inst.InstanceName + "_" + prms.m_Config4_Name.Value;

            #endregion

            #region Common configuration
            // Clock Source check box
            if (m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.ADC_CLOCK, prms.m_ADC_Clock.Expr) ==
                CyADC_DelSigParameters.S_INTERNAL)
            {
                m_rbClockInternal.Checked = true;
                m_rbClockExternal.Checked = false;
            }
            else
            {
                m_rbClockInternal.Checked = false;
                m_rbClockExternal.Checked = true;
            }

            // Start of Conversion check box
            if (m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.START_OF_CONVERSION,
                prms.m_Start_of_Conversion.Expr) == CyADC_DelSigParameters.S_SOFTWARE)
            {
                m_cbSocHardware.Checked = false;
            }
            else
            {
                m_cbSocHardware.Checked = true;
            }

            // Configs
            int temp;
            int.TryParse(prms.m_Configs.Value, out temp);
            m_nudConfig.Value = (decimal)temp;
            UpdateConfigTabs(temp);

            // Enable Vref Vss
            m_cbEnable_Vref_Vss.Checked = m_Component.ResolveEnumIdToDisplay(CyADC_DelSigParameters.ADC_nVref,
                prms.m_Enable_Vref_Vss.Expr).Equals(Boolean.TrueString);
            #endregion

            UpdateAllBufferGain();
            CheckAllFreq(false);
            //UpdateRefVoltagesEnable();
            m_cbReference_Validating(this, new CancelEventArgs());
            DisplayInterruptMessage();
            UpdateRefVoltagesEnable();
            UpdateAllInputRangeList();
            HookAllEvents();
            CheckRefVoltage(m_nudRefVoltage, m_cbReference);
            CheckRefVoltage(m_nudRefVoltage2, m_cbReference2);
            CheckRefVoltage(m_nudRefVoltage3, m_cbReference3);
            CheckRefVoltage(m_nudRefVoltage4, m_cbReference4);
        }