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.

Form1.cs 2.7 KiB

2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using System.Text;
  2. using UHFHelper;
  3. namespace test
  4. {
  5. public partial class Form1 : Form
  6. {
  7. public Form1()
  8. {
  9. InitializeComponent();
  10. }
  11. private void button1_Click(object sender, EventArgs e)
  12. {
  13. //жϴǷ
  14. if (!UHFCardHelper.GetInstance().ComOpen)
  15. {
  16. Resultoutput resultoutput = UHFCardHelper.GetInstance().OpenPort();
  17. if (resultoutput.Res)
  18. {
  19. MessageBox.Show(resultoutput.ResMes);
  20. }
  21. else
  22. {
  23. MessageBox.Show(resultoutput.ResMes);
  24. }
  25. }
  26. }
  27. private void button2_Click(object sender, EventArgs e)
  28. {
  29. if (!UHFCardHelper.GetInstance().ComOpen)
  30. {
  31. MessageBox.Show("δ");
  32. return;
  33. }
  34. string res = UHFCardHelper.GetInstance().ReadCard();
  35. label1.Text = res;
  36. }
  37. private void button3_Click(object sender, EventArgs e)
  38. {
  39. UHFCardHelper.GetInstance().ClosePort();
  40. }
  41. private void button4_Click(object sender, EventArgs e)
  42. {
  43. var res = UHFCardHelper.GetInstance().WriteCard(textBox1.Text);
  44. MessageBox.Show(res.ResMes);
  45. }
  46. private void Form1_Load(object sender, EventArgs e)
  47. {
  48. //// 鿴ô
  49. //foreach (var val in UHF_RS485_Helper.GetLocalSerialPortNames())
  50. //{
  51. // this.comboBox1.Items.Add(val);
  52. //}
  53. }
  54. UHF_RS485_Helper uHF_RS485_Helper;
  55. private void button5_Click(object sender, EventArgs e)
  56. {
  57. // ʼ
  58. UHF_RS485_Helper.GetInstance().Open(new SerialParam
  59. {
  60. PortName = "COM5",
  61. BaudRate = 57600,
  62. DataBits = 8
  63. });
  64. if (!UHF_RS485_Helper.GetInstance().GetSerialPortState())
  65. {
  66. MessageBox.Show("ʧ");
  67. }
  68. }
  69. private async void button6_Click(object sender, EventArgs e)
  70. {
  71. if (UHF_RS485_Helper.GetInstance().GetSerialPortState())
  72. {
  73. var oldss = await UHF_RS485_Helper.GetInstance().ReadCard(01);
  74. var sss = oldss?.ResData;
  75. textBox4.Text = sss;
  76. label2.Text = sss;
  77. }
  78. }
  79. private void button7_Click(object sender, EventArgs e)
  80. {
  81. UHFCardHelper.GetInstance().WorkMode();
  82. }
  83. private void button8_Click(object sender, EventArgs e)
  84. {
  85. UHF_RS485_Helper.GetInstance().OpenBeep(1);
  86. }
  87. }
  88. }