KTK_DeviceBase.cs
6.2 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
using log4net;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
namespace OnlineStore.DeviceLibrary
{
public abstract class KTK_DeviceBase
{
/// <summary>
/// 料仓单个调试状态(默认不是调试状态)
/// </summary>
public bool IsDebug = false;
public Dictionary<string, ConfigIO> DIList { get; set; }
public Dictionary<string, ConfigIO> DOList { get; set; }
/// <summary>
///1=设备联机(正常就绪)(入库后,BOX恢复原始状态)(出库后,移载装置恢复原始状态),
///2=急停,3=故障,4=警告,5=调试
/// 6=入库执行中,7=入仓完成,8=入仓失败
/// 9=出库执行,10=出仓完成,11=出库失败
/// </summary>
public StoreStatus storeStatus = StoreStatus.StoreOnline;
/// <summary>
/// 提示消息,一般发给服务器后清空(LineBean表示报警提示消息,BoxBean表示出入库失败的原因记录)
/// </summary>
public string WarnMsg = "";
/// <summary>
/// 日志颜色
/// </summary>
protected static Color storeMoveColor = Color.Blue;
protected static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public string StoreName { get; set; }
public int StoreID { get; set; }
/// <summary>
/// 料仓状态
/// </summary>
private StoreRunStatus storerunstatus = StoreRunStatus.Wait;
/// <summary>
/// 定时器
/// </summary>
protected System.Timers.Timer timersTimer;
private bool isInit = false;
/// <summary>
/// 初始化
/// </summary>
protected virtual void Init()
{
if (!isInit)
{
StoreMove = new StoreMoveInfo(StoreID);
timersTimer = new System.Timers.Timer();
timersTimer.Enabled = false;
timersTimer.Interval = 300;
timersTimer.Elapsed += timersTimer_Elapsed;
timersTimer.AutoReset = true;
isInit = true;
}
}
public StoreRunStatus storeRunStatus
{
get
{
return storerunstatus;
}
set
{
StoreRunStatus oldStatus = storerunstatus;
storerunstatus = value;
}
}
/// <summary>
/// 移动信息
/// </summary>
public StoreMoveInfo StoreMove = null;
/// <summary>
/// 定时处理,监听信号,监听IO
/// </summary>
protected abstract void timersTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e);
#region 出库
/// <summary>
/// 开始出库运动
/// </summary>
public abstract void StartOutStoreMove(InOutStoreParam param);
protected abstract void OutStoreProcess();
#endregion
#region 入库
/// <summary>
/// 开始入库移动移动
/// </summary>
public abstract void StartInStoreMove(InOutStoreParam param);
protected abstract void InStoreProcess();
#endregion
public string GetRunStr()
{
string sta = "运行中";
string aa = "";
switch (storeRunStatus)
{
case StoreRunStatus.Busy:
sta = "忙碌";
break;
case StoreRunStatus.HomeMoving:
sta = "原点返回";
break;
case StoreRunStatus.Reset:
sta = "重置";
break;
case StoreRunStatus.Runing:
sta = "运行中";
break;
case StoreRunStatus.Wait:
sta = "等待启动";
break;
}
if (storeRunStatus > StoreRunStatus.Wait)
{
//"0":"急停中", "1":"设备联机", "2":"故障中", "3":"入库执行中", "4":"出库执行中", 5":"料盘入仓位完成", "6":"料盘出仓位完成", 7":"设备调试中",
switch (storeStatus)
{
case StoreStatus.Debugging:
aa = "设备调试中";
break;
case StoreStatus.InStoreEnd:
aa = "料盘入仓位完成";
break;
case StoreStatus.InStoreExecute:
aa = "入库执行中";
break;
case StoreStatus.InTrouble:
aa = "故障中";
break;
case StoreStatus.OutStoreBoxEnd:
aa = "料盘出仓位完成";
break;
case StoreStatus.OutStoreExecute:
aa = "出库执行中";
break;
case StoreStatus.StoreOnline:
aa = "设备联机";
break;
case StoreStatus.SuddenStop:
aa = "急停中";
break;
case StoreStatus.OutMoveExecute:
aa = "出库完成";
break;
case StoreStatus.InStoreFaild:
aa = "入库失败(" + WarnMsg + ")";
break;
case StoreStatus.OutStoreFaild:
aa = "出库失败(" + WarnMsg + ")";
break;
}
if (!aa.Equals(""))
{
return sta + "_" + aa;
}
else
{
return sta;
}
}
else
{
return sta;
}
}
}
}