Ejemplo n.º 1
0
        private void buttonDebugWaitForValueRising_Click(object sender, EventArgs e)
        {
            byte   ch;
            UInt16 latency;
            float  value, gain;

            if (checkBoxDebugUseDefGain.Checked)
            {
                // Use gain that is inferred from configuration file
                try
                {
                    ch = InputValidatorHelperClass.GetChModeFromComboBox(comboBoxDebugWaitForValueRising);
                    //latency = Convert.ToUInt16(textBoxDebugWaitForValueRisingLatency.Text);
                    string corectedValue = textBoxDebugWaitForValueRisingValue.Text;
                    string correctedGain = textBoxDebugWaitForValueRisingGain.Text;
                    value = float.Parse(corectedValue);
                    if (ch == 0)
                    {
                        gain = ConfigClass.deviceGainCH0;
                    }
                    else
                    {
                        gain = ConfigClass.deviceGainCH1;
                    }
                    value = value / gain;
                }
                catch (Exception)
                {
                    MessageBox.Show("Insert valid values!");
                    return;
                }
            }
            else
            {
                // Use gain that is parsed from textbox
                try
                {
                    ch = InputValidatorHelperClass.GetChModeFromComboBox(comboBoxDebugWaitForValueRising);
                    //latency = Convert.ToUInt16(textBoxDebugWaitForValueRisingLatency.Text);
                    string corectedValue = textBoxDebugWaitForValueRisingValue.Text;
                    string correctedGain = textBoxDebugWaitForValueRisingGain.Text;
                    value = float.Parse(corectedValue);
                    gain  = float.Parse(correctedGain);
                    value = value / gain;
                }
                catch (Exception)
                {
                    MessageBox.Show("Insert valid values!");
                    return;
                }
            }

            // parse latency
            try
            {
                latency = Convert.ToUInt16(textBoxDebugWaitForValueRisingLatency.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("Insert valid value for latency!");
                return;
            }


            com.AppendWaitForValueRising(ch, latency, value);
            textBoxDebugInstructionPool.Text += "WaitForValueRising(" + comboBoxDebugWaitForValueRising.Text + ", " + latency +
                                                ", " + value.ToString() + ")\r\n";
            FormCustomConsole.WriteLine("WaitForValueRising(" + comboBoxDebugWaitForValueRising.Text + ", " + latency +
                                        ", " + value.ToString() + ")");
        }