UnlockedShelf.cs
2.8 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Common;
namespace DeviceLibrary
{
public class UnlockedShelf
{
/// <summary>
/// 已解绑料架信息
/// </summary>
/// <param name="nodeName"></param>
public UnlockedShelf()
{
Rfids = new Dictionary<string, string>();
}
/// <summary>
/// 空料架数量
/// </summary>
public int EmptyCnt { get; set; }
public string NodeName;
/// <summary>
/// 解绑的RFID及时间
/// </summary>
public Dictionary<string, string> Rfids { get; set; }
public List<string> GetRfids()
{
if (Rfids == null || Rfids.Count <= 0)
return new List<string>();
return Rfids.Keys.ToList<string>();
}
public Dictionary<string, string> GetRfidWithTime()
{
if (Rfids == null || Rfids.Count <= 0)
return new Dictionary<string, string>();
return Rfids;
}
/// <summary>
///添加解绑的空料架,如果RFID相同,不增加数量
/// </summary>
public bool Add(string rfid)
{
if (!rfid.Equals("") && !Rfids.Keys.Contains(rfid))
{
if (EmptyCnt < 0)
{
EmptyCnt = 0;
if (Rfids.Count > 0)
Rfids.Clear();
}
int tmp = EmptyCnt;
System.Threading.Interlocked.Increment(ref tmp);
EmptyCnt = tmp;
Rfids.Add(rfid, DateTime.Now.ToString("yyyy/MM/dd/HH:mm:ss,fff"));
return true;
}
return false;
}
/// <summary>
/// 删除一个解绑任务
/// </summary>
public bool Delete(string rfid)
{
if (EmptyCnt > 0)
{
if (!rfid.Equals("") && Rfids.Keys.Contains(rfid))
{
int tmp = EmptyCnt;
System.Threading.Interlocked.Decrement(ref tmp);
EmptyCnt = tmp;
if (EmptyCnt.Equals(0) && Rfids.Count > 0)
{
Rfids.Clear();
}
if (rfid.Equals(SettingString.RoomCFeederOut) || rfid.Equals(SettingString.RoomDFeederOut))
Rfids.Remove(rfid);
return true;
}
}
else if (Rfids.Count > 0)
{
EmptyCnt = 0;
Rfids.Clear();
return true;
}
return false;
}
}
}