コード例 #1
0
        public void CommandAcknowledgedDataFrameTest()
        {
            bool result = false;

            try
            {
                var data = Data();
                CommandAcknowledgedDataFrame ack = new CommandAcknowledgedDataFrame(data);
                result = true;
            }
            catch (InvalidDataFrameException)
            {
            }
            Assert.AreEqual(true, result);
        }
コード例 #2
0
ファイル: DebugWindow.cs プロジェクト: vlasel/PC_Scope
        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;
                }
            }
        }