FrmBoardSelect.cs
9.1 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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using TSA_V.Common;
using TSA_V.DeviceLibrary;
namespace TSA_V
{
public partial class FrmBoardSelect : FrmBase
{
//1=插件,2=焊接,3=检测
public int WorkType = 1;
private bool IsInitOk = false;
public FrmBoardSelect()
{
InitializeComponent();
}
public FrmBoardSelect(int type)
{
this.WorkType = type;
InitializeComponent();
}
private void FrmBoardSelect_Load(object sender, EventArgs e)
{
FormEn(true);
SetSkin(this);
LanguageProcess();
LoadCom();
txtCode.Focus();
SetScreen();
IsInitOk = true;
}
private void LoadCom()
{
cmbBoardList.DataSource = null;
List<BoardInfo> list = new List<BoardInfo>(BoardManager.boardList);
BoardInfo board = new BoardInfo();
board.boardId = -1;
board.boardName = "";
list.Insert(0, board);
cmbBoardList.DataSource = list;
cmbBoardList.DisplayMember = "boardShowName";
cmbBoardList.ValueMember = "boardId";
}
int preIndex = -1;
private void cmbBoardList_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmbBoardList.Text != "" && cmbBoardList.SelectedIndex >= 0 && (!cmbBoardList.SelectedIndex.Equals(preIndex)))
{
preIndex = cmbBoardList.SelectedIndex;
BoardInfo board = (BoardInfo)cmbBoardList.SelectedItem;
if (board.boardId.Equals(-1))
{
lblBoardMsg.Text = ResourceCulture.GetString(ResourceCulture.SelectP, "请选择程序");
lblBoardMsg.ForeColor = Color.Red;
return;
}
if (board != null)
{
lblBoardMsg.Text = board.GetDes();
this.lblBoardMsg.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
BoardManager.CurrBoard = board;
LogUtil.info("切换到新板子:" + board.boardName);
FrmProjectorScreen.instance.ShowPoint(false, board.GetSmtList().ToArray());
}
}
}
private void btnBack_Click(object sender, EventArgs e)
{
if (ChangeWidthTask != null && ChangeWidthTask.IsCompleted.Equals(false))
{
LWidthManager.StopChangeWidth();
LogUtil.info(Name + "返回之前,停止调宽");
}
FormEn(true);
this.Close();
}
private void BtnNext_Click(object sender, EventArgs e)
{
if (CanStart())
{
WorkInfo.LastDBId = 0;
FrmWork fw = new FrmWork();
this.Hide();
fw.ShowDialog();
this.Close();
}
}
private void txtCode_TextChanged(object sender, EventArgs e)
{
string code = FormUtil.getValue(txtCode).Trim();
if (!code.Equals(""))
{
int index = -1;
List<BoardInfo> list = (from m in BoardManager.boardList where m.boardCode.StartsWith(code) select m).ToList<BoardInfo>();
if (list.Count <= 0)
{
list = (from m in BoardManager.boardList where code.StartsWith(m.boardCode) select m).ToList<BoardInfo>();
}
if (list.Count > 0)
{
foreach (BoardInfo board in BoardManager.boardList)
{
index++;
if (board.boardCode.Equals(list[0].boardCode))
{
cmbBoardList.SelectedIndex = index + 1;
break;
}
}
}
else
{
cmbBoardList.SelectedIndex = 0;
}
}
else
{
cmbBoardList.SelectedIndex = 0;
}
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (!IsInitOk)
{
return base.ProcessCmdKey(ref msg, keyData); // 其他键按默认处理
}
//Enter键
if (keyData.Equals(Keys.Enter))
{
BtnNext_Click(null, null);
}
return base.ProcessCmdKey(ref msg, keyData); // 其他键按默认处理
}
private void FrmBoardSelect_Shown(object sender, EventArgs e)
{
txtCode.Focus();
}
private bool CanStart()
{
if (this.cmbBoardList.SelectedIndex < 0)
{
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.ConfigProduct, "请先配置程序"));
this.Close();
}
else if (this.cmbBoardList.SelectedIndex.Equals(0))
{
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.ConfigProduct, "请先选择程序"));
}
else
{
TSAVBean.OnlyGuoBan = chbGuoban.Checked;
LogUtil.info("选择程序,是否流水线过板=" + TSAVBean.OnlyGuoBan);
if (WorkType.Equals(1))
{
if (BoardManager.CurrBoard.GetSmtList().Count <= 0)
{
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.CanotFindInfo, "电路板【{0}】没有组装信息,请选择其他程序!", BoardManager.CurrBoard.boardName));
return false;
}
return true;
}
//else if (WorkType.Equals(2))
//{
// if (BoardManager.CurrBoard.GetSolderingSMTList().Count <= 0)
// {
// MessageBox.Show("电路板【" + BoardManager.CurrBoard.boardName + "】没有配置焊接信息,请选择其他程序!");
// return false;
// }
// return true;
//}
//else if (WorkType.Equals(3))
//{
// if (BoardManager.CurrBoard.GetCheckSMTList().Count <= 0)
// {
// MessageBox.Show("电路板【" + BoardManager.CurrBoard.boardName + "】没有配置检测信息,请选择其他程序!");
// return false;
// }
// return true;
//}
}
return false;
}
Task ChangeWidthTask = null;
private void btnChangeW_Click(object sender, EventArgs e)
{
if (CanStart())
{
int w = BoardManager.CurrBoard.LineWidth;
int p = LWidthManager.GetWidthPosition(w);
LogUtil.info(" 选择程序[" + BoardManager.CurrBoard.boardName + "]后,开始轨道调宽:【" + w + "】【" + p + "】");
DialogResult result = MessageBox.Show("当前宽度["+LWidthManager.Line_LastWidth+"],目标宽度["+ w + "],是否开始调宽", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (!result.Equals(DialogResult.OK))
{
return;
}
if (!LWidthManager.CanStartChWidth())
{
MessageBox.Show("启动调宽失败");
return;
}
FormEn(false);
Task.Factory.StartNew(delegate
{
ChangeWidthTask = Task.Factory.StartNew(delegate
{
string ok = LWidthManager.StartChangeWidth(w, p);
LogUtil.info("调宽" + w + "=" + p + "结束:" + ok);
if (String.IsNullOrEmpty(ok))
{
MessageBox.Show("调宽" + w + "=" + p + "完成");
}
else
{
MessageBox.Show("调宽" + w + "=" + p + "结束:" + ok);
}
//Thread.Sleep(5000);
});
ChangeWidthTask.Wait();
FormEn(true);
});
}
}
private void FormEn(bool en)
{
lblWait.Visible = !en;
txtCode.Enabled = en;
cmbBoardList.Enabled = en;
btnChangeW.Enabled = en;
btnNext.Enabled = en;
chbGuoban.Enabled = en;
btnBack.Enabled = true;
}
}
}