WorkBean_PN.cs
10.9 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
using PUSICANLibrary;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Threading;
using TSA_V.Common;
using TSA_V.LoadCSVLibrary;
namespace TSA_V.DeviceLibrary
{
public class WorkBean_PN : WorkInfo
{
public override void StartWork(BoardInfo boardInfo)
{
workedPnList = new List<string>();
currWorkSmtList = new List<SMTPointInfo>();
//StatusClient.instance.SendNew(Color.Green, "扫码成功:" + BoardManager.CurrBoard.boardCode);
beginWorkTime = DateTime.Now;
//开始工作
LogUtil.info("开始程序【" + boardInfo.boardName + "】的插件");
currBoard = boardInfo;
needWorkSmtList = currBoard.GetSmtList();
currIndex = -1;
if (isContinue)
{
LogUtil.info("开始程序【" + boardInfo.boardName + "】的插件 , 继续之前的工作,索引号=" + currIndex);
currIndex = Convert.ToInt32(Setting_NInit.Work_TagNumber);
//for(int i = 0; i < needWorkSmtList.Count; i++)
//{
// if (!workedPnList.Contains(needWorkSmtList[i].PN))
// {
// workedPnList.Add(needWorkSmtList[i].PN);
// }
//}
ResetWorkPnList(currIndex, true);
isContinue = false;
}
else
{
//统计缺料情况
ShortageCheck(boardInfo);
LogUtil.info("开始程序【" + boardInfo.boardName + "】的插件,重置手势统计," + LastShortageMsg);
HandRecordManager.Reset();
//LedLabelController.CloseAll();
}
IsShowAOI = false;
currPoint = null;
IsWorking = true;
endWorkTime = DateTime.Now;
IsWaitMove = false;
BoardCount = 0;
PTipSoundProcess.PlayFile(Setting_NInit.Set_NewBoardSound);
}
private void ResetWorkPnList(int workIndex, bool isNext)
{
workedPnList = new List<string>();
needWorkSmtList = currBoard.GetSmtList();
for (int i = 0; i < needWorkSmtList.Count; i++)
{
if (i < workIndex)
{
if (!workedPnList.Contains(needWorkSmtList[i].PN))
{
workedPnList.Add(needWorkSmtList[i].PN);
}
}
}
}
public override bool MoveToNextPoint(bool isNext, bool isReset)
{
waitList = new List<WaitResultInfo>();
IsWaitMove = true;
LastSetpTime = DateTime.Now;
if (isNext)
{
currIndex++;
}
else
{
currIndex--;
}
if (currIndex > GetSmtList().Count)
{
if (isReset)
{
if (IsCycleDebug)
{
LogUtil.info("程序【" + currBoard.boardName + "】已到达最后一个焊点,重新开始工作");
StartWork(BoardManager.CurrBoard);
return true;
}
else
{
LogUtil.info("程序【" + currBoard.boardName + "】已到达最后一个焊点,停止工作");
StopWork();
return true;
}
}
else
{
return false;
}
}
if (currIndex < 0)
{
currIndex = GetSmtList().Count - 1;
}
if (currIndex == GetSmtList().Count)
{
if (WorkType.Equals(1))
{
LogUtil.info(" 程序【" + currBoard.boardName + "】所有位置已走完 ");
ClosePrePos();
if (IOBase.NoLine)
{
LogUtil.info(" 程序【" + currBoard.boardName + "】工作完成,无线体模式,记录工作次数");
WorkCountManager.AddWorkCount();
}
//if (TSAVBean.IsNeedSoldering)
//{
// LogUtil.info(" 程序【" + currBoard.boardName + "】需要焊接,打开烙铁灯 ");
// LedManager.LedOFFALL();
// LedManager.OpenSoldering();
// waitList.Add(WaitResultInfo.WaitTime(5000));
//}
}
}
else
{
currPoint = GetSmtList()[currIndex];
ResetWorkPnList(currIndex,isNext);
if (workedPnList.Contains(currPoint.PN))
{
LogUtil.info(" 程序【" + currBoard.boardName + "】isNext="+isNext+",索引【" + currIndex+"】插件【" + currPoint.TagNo + "】PN=【"+currPoint.PN+"】已投影过,跳过");
MoveToNextPoint(isNext, isReset);
}
//LogUtil.info(" 程序【" + currBoard.boardName + "】插件【" + currPoint.pointName + "】");
currWorkSmtList = currBoard.GetSmtList(currPoint.PN);
ComponetInfo com = CSVBomManager.GetCom(currBoard.bomName, currPoint, true);
TSAVPosition position = null;
if (com != null)
{
#region 2023-10-31添加
position = CSVPositionReader<TSAVPosition>.GetPositonByNum(com.PositionNum);
Setting_NInit.Work_ProcedureName = currBoard.boardName;
Setting_NInit.Work_TagNumber = currIndex;
if (currPoint.pointNum == 1)
{
Setting_NInit.Work_ProcedureName = currBoard.boardName;
Setting_NInit.Work_TagNumber = currIndex;
}
#endregion
for (int i = 1; i <= currBoard.PCBCount; i++)
{
for(int j = 1; j < currWorkSmtList.Count; j++)
{
useComponets.Add(com);
}
}
}
else
{
position = CSVPositionReader<TSAVPosition>.GetPositonByNum(currPoint.PositionNum);
}
if (position == null)
{
LogUtil.info(" 程序【" + currBoard.boardName + "】插件【" + currPoint.PN + "】未找到对应的位置[" + currPoint.PositionNum + "]");
}
else
{
this.currPosition = position;
if (!workedPnList.Contains(currPoint.PN))
{
workedPnList.Add(currPoint.PN);
}
XYMove();
//插件机工作
if (WorkType.Equals(1))
{
LogUtil.info(" 程序【" + currBoard.boardName + "】isNext=" + isNext + ",索引【" + currIndex+ "】 插件【" + currPoint.TagNo + "】PN=【" + currPoint.PN + "】 库位【" + position.PositionName + "】X轴【" + currPoint.NodePositionX + "】,Y轴【" + currPoint.NodePositionY + "】");
MoveToBag(position);
//如果是下一个并且当前是最后一个,其实是切换了新程序,需要减去刚刚的数量
if (isNext && (currIndex == 0))
{
BoardCount++;
CSVBomManager.DelUseCount(currBoard, useComponets);
useComponets = new List<ComponetInfo>();
}
}
//焊接工作
else if (WorkType.Equals(2))
{
PTipSoundProcess.PlayFile(Setting_NInit.Set_PointChangeSound);
if (isNext && (currIndex == 0))
{
BoardCount++;
}
int temp = currPoint.WeldTemp;
LogUtil.info(" 程序【" + currBoard.boardName + "】焊接【" + currPoint.PN + "】,温度【" + temp + "】");
}
else if (WorkType.Equals(3))
{
PTipSoundProcess.PlayFile(Setting_NInit.Set_PointChangeSound);
if (isNext && (currIndex == 0))
{
BoardCount++;
}
int temp = currPoint.WeldTemp;
LogUtil.info(" 程序【" + currBoard.boardName + "】检测【" + currPoint.PN + "】");
}
}
}
return true;
}
public override void XYMove()
{
//获取当前pn所有的点位列表,全部投影
currWorkSmtList = currBoard.GetSmtList(currPoint.PN);
List<SMTPointInfo> needShowXyPoint = new List<SMTPointInfo>();
string msg = "";
foreach (SMTPointInfo smt in currWorkSmtList)
{
if (TSAVBean.IsValidPosition(smt.NodePositionX, smt.NodePositionY))
{
needShowXyPoint.Add(smt);
msg += smt.TagNo + "_" + smt.PN + "_" + smt.NodePositionX + "_" + smt.NodePositionY + " ";
}
}
LogUtil.info(" 程序【" + currBoard.boardName + "】索引【" + currIndex + "】插件【" + currPoint.TagNo + "】PN=【" + currPoint.PN + "】插件【" + msg + "】显示投影光标");
TSAVBean.ShowPoint(currBoard, needShowXyPoint.ToArray());
waitList.Add(WaitResultInfo.WaitTime(1000));
////xy轴运动到固定点
//if (TSAVBean.IsValidPosition(currPoint.NodePositionX, currPoint.NodePositionY))
//{
// LogUtil.info(" 程序【" + currBoard.boardName + "】插件【" + currPoint.TagNo + "_" + currPoint.PN + "】,X轴【" + currPoint.NodePositionX + "】,Y轴【" + currPoint.NodePositionY + "】显示投影光标");
// TSAVBean.ShowPoint(currBoard, currPoint);
// waitList.Add(WaitResultInfo.WaitTime(1000));
//}
//else
//{
// LogUtil.info(" 程序【" + currBoard.boardName + "】插件【" + currPoint.TagNo + "_" + currPoint.PN + "】,X轴【" + currPoint.NodePositionX + "】,Y轴【" + currPoint.NodePositionY + "】坐标无效,不移动光标");
//}
}
}
}