|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- using System.Text;
- using UHFHelper;
-
- namespace test
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
-
- private void button1_Click(object sender, EventArgs e)
- {
- //жϴǷ
- if (!UHFCardHelper.GetInstance().ComOpen)
- {
- Resultoutput resultoutput = UHFCardHelper.GetInstance().OpenPort();
- if (resultoutput.Res)
- {
- MessageBox.Show(resultoutput.ResMes);
- }
- else
- {
- MessageBox.Show(resultoutput.ResMes);
- }
- }
- }
-
- private void button2_Click(object sender, EventArgs e)
- {
- if (!UHFCardHelper.GetInstance().ComOpen)
- {
- MessageBox.Show("δ");
- return;
- }
- string res = UHFCardHelper.GetInstance().ReadCard();
- label1.Text = res;
- }
-
- private void button3_Click(object sender, EventArgs e)
- {
- UHFCardHelper.GetInstance().ClosePort();
- }
-
- private void button4_Click(object sender, EventArgs e)
- {
- var res = UHFCardHelper.GetInstance().WriteCard(textBox1.Text);
- MessageBox.Show(res.ResMes);
- }
-
- private void Form1_Load(object sender, EventArgs e)
- {
-
- //// 鿴ô
- //foreach (var val in UHF_RS485_Helper.GetLocalSerialPortNames())
- //{
- // this.comboBox1.Items.Add(val);
- //}
- }
- UHF_RS485_Helper uHF_RS485_Helper;
- private void button5_Click(object sender, EventArgs e)
- {
- // ʼ
- UHF_RS485_Helper.GetInstance().Open(new SerialParam
- {
- PortName = "COM5",
- BaudRate = 57600,
- DataBits = 8
- });
- if (!UHF_RS485_Helper.GetInstance().GetSerialPortState())
- {
- MessageBox.Show("ʧ");
- }
- }
-
- private async void button6_Click(object sender, EventArgs e)
- {
- if (UHF_RS485_Helper.GetInstance().GetSerialPortState())
- {
- var oldss = await UHF_RS485_Helper.GetInstance().ReadCard(01);
- var sss = oldss?.ResData;
- textBox4.Text = sss;
- label2.Text = sss;
- }
- }
-
- private void button7_Click(object sender, EventArgs e)
- {
- UHFCardHelper.GetInstance().WorkMode();
- }
-
- private void button8_Click(object sender, EventArgs e)
- {
- UHF_RS485_Helper.GetInstance().OpenBeep(1);
- }
- }
- }
|