Beispiel #1
0
        private DSO.DataFrames.DataFrame GetResponse(DataFrame frame, SerialPort port)
        {
            port.DiscardInBuffer();
            WriteFrame(frame, port);
            System.Threading.Thread.Sleep(2 * (Convert.ToInt16(cbxReadDelay.Text)));
            var bytes = InstReadBuffer(port);

            try
            {
                ScopeReady config = new ScopeReady(bytes);
                return(config);
            }
            catch (InvalidDataFrameException)
            {
            }

            try
            {
                DSO.DataFrames.DSO068.CurrConfigDataFrame config = new DSO.DataFrames.DSO068.CurrConfigDataFrame(bytes);
                return(config);
            }
            catch (InvalidDataFrameException)
            {
            }
            catch (IndexOutOfRangeException)
            {
            }


            try
            {
                DSO.DataFrames.DSO112.CurrConfigDataFrame config = new DSO.DataFrames.DSO112.CurrConfigDataFrame(bytes);
                return(config);
            }
            catch (InvalidDataFrameException)
            {
            }
            catch (IndexOutOfRangeException)
            {
            }

            return(null);
        }
Beispiel #2
0
        private void btnApply_Click(object sender, EventArgs e)
        {
            foreach (var cb in this.Controls)
            {
                if (cb is CheckBox)
                {
                    ((CheckBox)cb).Checked = false;
                }
            }

            txtBufferOutput.Clear();
            var port = GetSerialPort();


            if (port != null)
            {
                if (txtEditCommand.Text != "")
                {
                    var         bytes  = txtEditCommand.Text.Split(' ');
                    List <byte> proper = new List <byte>();
                    foreach (var value in bytes)
                    {
                        if (value != "")
                        {
                            proper.Add(byte.Parse(value, System.Globalization.NumberStyles.HexNumber));
                        }
                    }
                    port.Write(proper.ToArray(), 0, proper.ToArray().Count());
                }
                else
                {
                    // WriteFrame((DataFrame)cbxCommandSelect.SelectedItem, port);
                }
                System.Threading.Thread.Sleep(Convert.ToInt16(cbxReadDelay.Text));
                output = InstReadBuffer(port);
                port.Dispose();
                var tempText = "";
                foreach (byte val in output)
                {
                    tempText += val + ", ";
                }
                if (tempText.Length > 0)
                {
                    txtBufferOutput.Text = (tempText.Remove(tempText.Length - 2));
                }
                port.Close();
                port.Dispose();

                try
                {
                    DSO.DataFrames.DSO068.CurrConfigDataFrame config = new DSO.DataFrames.DSO068.CurrConfigDataFrame(output);
                    cbCurrConf.Checked = true;
                }
                catch (InvalidDataFrameException)
                {
                    cbCurrConf.Checked = false;
                }
                try
                {
                    DSO.DataFrames.DSO112.CurrConfigDataFrame config = new DSO.DataFrames.DSO112.CurrConfigDataFrame(output);
                    cbCurrConf.Checked = true;
                }
                catch (InvalidDataFrameException)
                {
                    cbCurrConf.Checked = false;
                }
                try
                {
                    CurrParamDataFrame config = new CurrParamDataFrame(output);
                    SetParamToComboboxes(config);
                    EnableConfigComboboxes(false);
                    cbCurrParam.Checked = true;
                }
                catch (InvalidDataFrameException)
                {
                    cbCurrParam.Checked = false;
                }
                try
                {
                    DataBlockDataFrame config = new DataBlockDataFrame(output);
                    cbDataBlock.Checked = true;
                }
                catch (InvalidDataFrameException)
                {
                    cbDataBlock.Checked = false;
                }
                try
                {
                    DataSampleDataFrame config = new DataSampleDataFrame(output);
                    cbDataSample.Checked = true;
                }
                catch (InvalidDataFrameException)
                {
                    cbDataSample.Checked = false;
                }
                try
                {
                    ScopeReady config = new ScopeReady(output);
                    cbScopeReady.Checked = true;
                }
                catch (InvalidDataFrameException)
                {
                    cbScopeReady.Checked = false;
                }
                try
                {
                    USBScopeModeExited config = new USBScopeModeExited(output);
                    cbExitedScope.Checked = true;
                }
                catch (InvalidDataFrameException)
                {
                    cbExitedScope.Checked = false;
                }
                try
                {
                    CommandAcknowledgedDataFrame config = new CommandAcknowledgedDataFrame(output);
                    cbCommandAck.Checked = true;
                }
                catch (InvalidDataFrameException)
                {
                    cbCommandAck.Checked = false;
                }
            }
        }