M
mdpfyp
Guest
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO.Ports;
namespace WindowsFormsApplication5
{
public partial class <g class="gr_ gr_40 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" data-gr-id="40" id="40">Form1 :</g> Form
{
string datain;
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
try
{
serialPort1.Open();
button2.Enabled = false;
serialPort1.DtrEnable = true;
}
catch (Exception err)
{
MessageBox.Show(err.Message, "error");
}
}
private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
datain = serialPort1.ReadExisting();
this.Invoke(new EventHandler(showdata));
}
private void showdata(object sender, EventArgs e)
{
// throw new NotImplementedException();
string s = datain+",";
string[] somestring = s.Split(',');
float z = Convert.ToSingle(somestring[2]);
try
{
textBox2.Text = datain;
arcScaleNeedleComponent1.Value = z;
}
catch (IndexOutOfRangeException)
{
}
finally
{
textBox2.Text = datain;
arcScaleNeedleComponent1.Value = z;
}
return;
}
}
}
Continue reading...
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO.Ports;
namespace WindowsFormsApplication5
{
public partial class <g class="gr_ gr_40 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" data-gr-id="40" id="40">Form1 :</g> Form
{
string datain;
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
try
{
serialPort1.Open();
button2.Enabled = false;
serialPort1.DtrEnable = true;
}
catch (Exception err)
{
MessageBox.Show(err.Message, "error");
}
}
private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
datain = serialPort1.ReadExisting();
this.Invoke(new EventHandler(showdata));
}
private void showdata(object sender, EventArgs e)
{
// throw new NotImplementedException();
string s = datain+",";
string[] somestring = s.Split(',');
float z = Convert.ToSingle(somestring[2]);
try
{
textBox2.Text = datain;
arcScaleNeedleComponent1.Value = z;
}
catch (IndexOutOfRangeException)
{
}
finally
{
textBox2.Text = datain;
arcScaleNeedleComponent1.Value = z;
}
return;
}
}
}
Continue reading...