Form1.cs
3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Test
{
public partial class Form1 : Form
{
private Asa.RFID.ReadAll read;
public Form1()
{
InitializeComponent();
}
PuYueRFID_C2S py;
private void Form1_Load(object sender, EventArgs e)
{
//read = new Asa.RFID.ReadAll(new string[] {"192.168.3.7" },"log");
//read.Type = Asa.RFID.DeviceType.PuYue;
//read.Start(10001);
//read.Start();
//read.Received += Read_Received;
py = new PuYueRFID_C2S("192.168.3.7");
//py.ID_Changed_Event += Py_ID_Changed_Event;
py.Open();
}
private void Py_ID_Changed_Event(object sender, string e)
{
this.Invoke((EventHandler)delegate
{
textBox1.Text += $"{(sender as PuYueRFID_C2S).IP}:{e}\r\n";
});
}
private void Read_Received(string ip, string id)
{
this.Invoke((EventHandler)delegate
{
textBox1.Text += $"{ip}:{id}\r\n";
});
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
read.Stop();
}
private void timer1_Tick(object sender, EventArgs e)
{
//int c= py.TryRead(out string id, out double ms);
//textBox1.Text = $"{c},{id},{ms}";
}
int i = 0;
string txtdata = "aaaaaaaaaaqqqqqqqqqqaaaaaaaaaaqqqqqqqqqzzz";
private void button1_Click(object sender, EventArgs e)
{
i++;
txtdata += i.ToString();
var d = Encoding.ASCII.GetBytes(txtdata);
byte[] data;
while (!py.ReadByte(0x200, 1, out data))
{
textBox1.Text += "1";
Thread.Sleep(100);
}
textBox1.Text = "get tag;";
while (!py.WriteByte(0x255, d)) {
textBox1.Text += "e";
Thread.Sleep(100);
}
Thread.Sleep(500);
while (!py.ReadByte(0x255, (short)d.Length, out data))
{
textBox1.Text += "1";
Thread.Sleep(100);
}
textBox1.Text += Encoding.ASCII.GetString(data);
}
private void button2_Click(object sender, EventArgs e)
{
byte[] data;
while (!py.ReadByte(0x255, 14, out data))
{
textBox1.Text += "1";
Thread.Sleep(100);
}
textBox1.Text += Encoding.ASCII.GetString(data);
}
private void button3_Click(object sender, EventArgs e)
{
i++;
txtdata += i.ToString();
var d = Encoding.ASCII.GetBytes(txtdata);
byte[] data;
while (!py.ReadByte(0x200, 1, out data))
{
textBox1.Text += "1";
Thread.Sleep(100);
}
textBox1.Text = "get tag;";
while (!py.WriteByte(0x20, d))
{
textBox1.Text += "e";
Thread.Sleep(100);
}
Thread.Sleep(500);
while (!py.ReadByte(0x255, (short)d.Length, out data))
{
textBox1.Text += "1";
Thread.Sleep(100);
}
textBox1.Text += Encoding.ASCII.GetString(data);
}
}
}