Standby.cs
2.0 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class Standby
{
/// <summary>
/// 待机位
/// </summary>
public List<string> Station;
private const int Station_CNT = 4;
public Standby()
{
Station = new List<string>();
Station.AddRange(new string[Station_CNT]);
}
/// <summary>
/// 在空的待机位添加占用小车
/// </summary>
/// <param name="standName">占用待机位的名称</param>
/// <returns></returns>
public bool AddOccupyInfo(string standName)
{
if (standName.Equals(""))
return false;
int i = Station.FindIndex(s => (s == null || s.Equals("")));
if (i > -1)
{
Station[i] = standName;
return true;
}
return false;
}
/// <summary>
/// 清除占用信息
/// </summary>
/// <param name="standName"></param>
/// <returns></returns>
public bool DelOccupyInfo(string standName)
{
if (standName.Equals(""))
return false;
int i = Station.FindIndex(s => s != null && s.Equals(standName));
if (i > -1)
{
Station[i] = "";
return true;
}
return false;
}
public void ClearAllInfo()
{
if (Station != null && Station.Count > 0)
{
Station.Clear();
Station = new List<string>();
Station.AddRange(new string[Station_CNT]);
}
}
public string GetInfoByID(int index)
{
if (Station ==null ||index<0 || index >= Station_CNT || Station[index] ==null)
return "";
else
return Station[index];
}
}
}