-
Notifications
You must be signed in to change notification settings - Fork 2
/
TagEventHandler.cs
87 lines (76 loc) · 2.63 KB
/
TagEventHandler.cs
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
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using Symbol.RFID3;
namespace RFID_Manager
{
public class TagEventHandler
{
private Hashtable _ExistingTable;
private RFIDReader _ReaderAPI;
private string _DeviceID;
private ITagProcessor _Processor;
public TagEventHandler(RFIDReader API, string ID)
{
_ExistingTable = new Hashtable();
_ReaderAPI = API;
_DeviceID = ID;
_Processor = new DefaultTagProcessor();
}
public RFIDReader ReaderAPI
{
get { return _ReaderAPI; }
}
public Hashtable ExistingTable
{
set { _ExistingTable = value; }
}
public ITagProcessor Processor
{
set { _Processor = value; }
}
public void newTagEvent(string stringData)
{
if (stringData == "BUFFER_FULL_WARNING_EVENT")
{
//userNotification.Text = "Buffer Full Warning";
//userNotification.Visible = true;
}
else if (stringData == "DISCONNECTION_EVENT")
{
//userNotification.Text = "Radio Disconnected";
//userNotification.Visible = true;
_ReaderAPI.Reconnect();
}
else
{
TagData[] tagData = _ReaderAPI.Actions.GetReadTags(1000);
if (tagData != null)
{
for (int nIndex = 0; nIndex < tagData.Length; nIndex++)
{
TagData tag = tagData[nIndex];
string tagID = tag.TagID;
string tagIDshort = tagID.Substring(tag.TagID.Length - 8);
if (tag.TagID != _DeviceID )
{
if (tag.OpCode == ACCESS_OPERATION_CODE.ACCESS_OPERATION_READ &&
tag.OpStatus == ACCESS_OPERATION_STATUS.ACCESS_SUCCESS &&
_ExistingTable.ContainsKey(tagIDshort))
{
_Processor.updateTag(tag);
}
if (tag.OpCode == ACCESS_OPERATION_CODE.ACCESS_OPERATION_NONE &&
!_ExistingTable.ContainsKey(tagIDshort))
{
_Processor.processTag(tag);
}
}
}//for
}
}
}
}
}