You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.3 KiB

  1. using UHFHelper;
  2. namespace test
  3. {
  4. public partial class Form1 : Form
  5. {
  6. public Form1()
  7. {
  8. InitializeComponent();
  9. }
  10. private void button1_Click(object sender, EventArgs e)
  11. {
  12. //判断串口是否打开
  13. if (!UHFCardHelper.GetInstance().ComOpen)
  14. {
  15. Resultoutput resultoutput = UHFCardHelper.GetInstance().OpenPort();
  16. if (resultoutput.Res)
  17. {
  18. MessageBox.Show(resultoutput.ResMes);
  19. }
  20. else
  21. {
  22. MessageBox.Show(resultoutput.ResMes);
  23. }
  24. }
  25. }
  26. private void button2_Click(object sender, EventArgs e)
  27. {
  28. if (!UHFCardHelper.GetInstance().ComOpen)
  29. {
  30. MessageBox.Show("串口未打开");
  31. return;
  32. }
  33. string res = UHFCardHelper.GetInstance().ReadCard();
  34. label1.Text = res;
  35. }
  36. private void button3_Click(object sender, EventArgs e)
  37. {
  38. UHFCardHelper.GetInstance().ClosePort();
  39. }
  40. private void button4_Click(object sender, EventArgs e)
  41. {
  42. var res = UHFCardHelper.GetInstance().WriteCard(textBox1.Text);
  43. MessageBox.Show(res.ResMes);
  44. }
  45. }
  46. }