Exemplo n.º 1
0
        private void btnRead_Click(object sender, EventArgs e)
        {
            ClearIfTextBoxOverFlow();
            string    result;
            Stopwatch stopwatch = Stopwatch.StartNew();

            try
            {
                if (isAsciiCommand)
                {
                    result = portOperatorBase.ReadLine();
                }
                else
                {
                    result = portOperatorBase.ReadLine().ToHexString();
                }
            }
            catch (IOTimeoutException)
            {
                result = Resources.ReadTimeout;
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }
            DisplayToTextBox($"[Time:{stopwatch.ElapsedMilliseconds}ms] Read:  {result}");
        }
Exemplo n.º 2
0
        private void readData(PortOperatorBase opBase)
        {
            string    result;
            Stopwatch stopwatch = Stopwatch.StartNew();

            try
            {
                result = opBase.ReadLine();
            }
            catch (IOTimeoutException)
            {
                result = "Time Out!";
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }
            listBox1.Items.Add($"[Time:{stopwatch.ElapsedMilliseconds}ms] Read:  {result}");
        }