BoardInfo.cs
16.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
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
using TSA_V.Common;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TSA_V.LoadCSVLibrary;
using System.Reflection;
namespace TSA_V.DeviceLibrary
{
public class BoardInfo
{
public string boardShowName
{
get
{
if (String.IsNullOrEmpty(boardCode))
{
return boardName;
}
return boardName + "(" + boardCode + ")";
}
set { }
}
/// <summary>
/// 电路板ID
/// </summary>
public int boardId { get; set; }
/// <summary>
/// 元器件库名称
/// </summary>
public string bomName { get; set; }
/// <summary>
/// 电路板名称
/// </summary>
public string boardName { get; set; }
/// <summary>
/// 电路板条形码
/// </summary>
public string boardCode { get; set; }
/// <summary>
/// 宽度(显示的长度→)
/// </summary>
public int boardWidth { get; set; }
/// <summary>
/// 高度(显示的高度↑)
/// </summary>
public int boardLength { get; set; }
/// <summary>
/// 元器件列表
/// </summary>
public List<SMTPointInfo> smtList { get; set; }
// 新增:多PCB模式配置
/// <summary>
/// 多PCB模式-行数
/// </summary>
public int pcbRow { get; set; } = 1;
/// <summary>
/// 多PCB模式-列数
/// </summary>
public int pcbCol { get; set; } = 1;
/// <summary>
/// 多PCB模式-行间距(mm)
/// </summary>
public int pcbRowValue { get; set; } = 1;
/// <summary>
/// 多PCB模式-列间距(mm)
/// </summary>
public int pcbColValue { get; set; } = 1;
/// <summary>
/// 多点位投射功能,=true所有点位同时显示。
/// </summary>
public bool mPointsProjection { get; set; } = false;
/// <summary>
/// 多pcb模式,每个PCB针对PCB1的偏移坐标。key=pcb索引号,value =偏移坐标
/// </summary>
public Dictionary<int, PcbOffsetInfo> mPCbOffsetMap = new Dictionary<int, PcbOffsetInfo>();
public PcbOffsetInfo GetPCBOffsetPoint(int pcbIndex)
{
if (mPCbOffsetMap.ContainsKey(pcbIndex))
{
return mPCbOffsetMap[pcbIndex];
}
else
{
return new PcbOffsetInfo(0, 0,0);
}
}
public void SetPCBOffset(int pcbIndex, PcbOffsetInfo value)
{
mPCbOffsetMap[pcbIndex] = value;
}
public int PointColor = Color.White.ToArgb();
public List<SMTPointInfo> GetSmtList()
{
List<SMTPointInfo> needWorkSmtList = (from m in smtList where m.Disable.Equals(false) select m).ToList<SMTPointInfo>();
return needWorkSmtList;
}
/// <summary>
/// 基准点坐标X
/// </summary>
public double originX = 800;
/// <summary>
/// 基准点坐标Y
/// </summary>
public double originY = 800;
/// <summary>
/// 图片名称
/// </summary>
public string imgName { get; set; }
/// <summary>
/// 固定原点的位置,1=左上角,2=左下角,3=右上角,4=右下角
/// </summary>
public int orgType { get; set; }
/// <summary>
/// 线体宽度
/// </summary>
public int LineWidth { get; set; }
//public double BaseX = 0;
//public double BaseY = 0;
//public double BaseImageX = 0;
//public double BaseImageY = 0;
public string AOIProName = "";
public Image myImage = null;
public List<ComponetInfo> componetList { get; set; } = null;
public string GetImgPath(bool isCheck = false)
{
string path = ConfigAppSettings.GetValue(Setting_Init.BOARD_IMAGE_PATH);
string imagePath = Application.StartupPath + "/" + path + "/" + imgName;
if (isCheck)
{
if (imgName != null && File.Exists(imagePath))
{
return imagePath;
}
else
{
imagePath = Application.StartupPath + @"/" + path + ConfigAppSettings.GetValue(Setting_Init.BOARD_IMAGE_PATH);
}
}
return imagePath;
}
public Image GetImage()
{
if (myImage == null)
{
string imagePath = GetImgPath();
if (imgName != null && File.Exists(imagePath))
{
System.Drawing.Image img = System.Drawing.Image.FromFile(imagePath);
myImage = new System.Drawing.Bitmap(img);
img.Dispose();
}
else
{
return BoardManager.defaultImage;
}
}
if (myImage == null)
{
return BoardManager.defaultImage;
}
else
{
return myImage;
}
}
public string GetDes()
{
//Length: 175mm
//Width:190mm
//Component Qty:
return " " + ResourceControl.GetString(ResourceControl.Length, "长度") + ":" + boardLength +"mm"+
"\r\n" + ResourceControl.GetString(ResourceControl.Width, "宽度") + ":" + boardWidth +"mm"+
//"," + ResourceControl.GetString(ResourceControl.LineWidth, "线体宽度") + ":" + LineWidth +
"\r\n" + ResourceControl.GetString(ResourceControl.InfoCount, "组件数量") +":" + GetSmtList().Count;
//return "电路板名称:" + boardName + ",长度:" + boardLength + ",宽度:" + boardWidth + ",组装信息数量:" + pointList.Count;
}
public string GetAoiFileName()
{
string path = Application.StartupPath + ConfigAppSettings.GetValue(Setting_Init.AOIFileConfig)+AOIProName;
return path;
}
public int GetNextPNum()
{
int maxNum = 0;
foreach(SMTPointInfo p in smtList)
{
if (p.pointNum > maxNum)
{
maxNum = p.pointNum;
}
}
maxNum++;
return maxNum;
}
/// <summary>
/// 导出导入程序时使用
/// </summary>
public byte[] imageByte { get; set; }
public string imageBase64Data { get; set; }
public bool IsValid()
{
if (String.IsNullOrEmpty(boardName))
{
return false;
}
if (this.smtList==null)
{
return false;
}
if (this.smtList.Count <= 0)
{
return false;
}
if (this.LineWidth <= 0 && this.boardLength <= 0)
{
return false;
}
return true;
}
public List<SMTPointInfo> getCalPoint()
{
try
{
SMTPointInfo lefup = new SMTPointInfo();
lefup.PositionX = 0;
lefup.PositionY = 0;
lefup.NodePositionX = calInfo.leftUpPoint.X;
lefup.NodePositionY = calInfo.leftUpPoint.Y;
SMTPointInfo right = new SMTPointInfo();
right.PositionX = boardWidth;
right.PositionY = boardLength;
right.NodePositionX = calInfo.rightBottomPoint.X;
right.NodePositionY = calInfo.rightBottomPoint.Y;
List<SMTPointInfo> checkOKList = new List<SMTPointInfo>() { lefup, right };
return checkOKList;
}
catch (Exception ex)
{
LogUtil.error(boardName + "获取校准点列表出错:" + ex.ToString());
}
return new List<SMTPointInfo>();
}
public CalibrateBean calInfo = null;
public int PCBCount
{
get
{
int count = this.pcbRow * pcbCol;
if (count <= 0) { count = 1; }
return count;
}
}
}
public class CalibrateBean
{
public Point leftUpPoint = new Point();
public Point rightBottomPoint = new Point();
/// <summary>
/// 1=已确认左上角位置
/// 2=已确认右下角位置
/// 3=正在校准中
/// </summary>
public int CurrStep = 0;
}
/// <summary>
///组装信息信息
/// </summary>
public class SMTPointInfo
{
public SMTPointInfo()
{
PositionNum = "";
pointNum = 0;
PN = "";
PositionX = 0;
PositionY = 0;
}
public SMTPointInfo(int num, string partNum, string name, double positionX, double positionY, string PositionNum,string showText,
int pointType=1,int pointSizex=1,int pointSizeY=1,int penWidth =2, int PolaritiesType=0,
bool needs = false, bool needc = false, int sTemp = 0, double sTime = 0)
{
this.TagNo = partNum;
this.pointNum = num;
this.PN = name;
this.PositionX = positionX;
this.PositionY = positionY;
this.PositionNum = PositionNum;
this.NeedCheck = needc;
this.NeedSoldering = needs;
this.WeldTemp = sTemp;
this.WeldTime = sTime;
this.PointType = pointType;
this.PointSizeX = pointSizex;
this.PointSizeY = pointSizeY;
this.PenWidth = penWidth;
this.ShowText = showText;
this.PolaritiesType = PolaritiesType;
this.imgP=new DrawPointInfo(pointSizex, pointSizeY,penWidth);
//if (String.IsNullOrEmpty(this.ShowText))
//{
// this.ShowText = name;
//}
}
public SMTPointInfo(SMTPointInfo oldPointInfo)
{
// 使用反射获取属性并复制值
PropertyInfo[] properties = typeof(SMTPointInfo).GetProperties();
foreach (PropertyInfo property in properties)
{
if (property.CanWrite)
{
property.SetValue(this, property.GetValue(oldPointInfo));
}
}
}
/// <summary>
///组装信息编号
/// </summary>
public int pointNum { get; set; }
/// <summary>
/// 位号 原来的PartNum
/// </summary>
public string TagNo { get; set; }
/// <summary>
/// 物料编码 原来的pointName
/// </summary>
public string PN { get; set; }
/// <summary>
///已过时。 位号/编号,与元器件库中的编号一致,不可以修改,作为关联关系
/// </summary>
public string PartNum { get; set; }
/// <summary>
///已过时。物料编码/组装信息名字
/// </summary>
public string pointName { get; set; }
/// <summary>
/// 料格的位置信息
/// </summary>
public string PositionNum { get; set; }
/// <summary>
/// 图片上显示的x坐标
/// </summary>
public double PositionX { get; set; }
/// <summary>
///图片上显示的 y坐标
/// </summary>
public double PositionY { get; set; }
private double nodePositionX;
private double nodePositionY;
/// <summary>
/// X轴的移动坐标
/// </summary>
public double NodePositionX
{
get { return nodePositionX; }
set
{
nodePositionX = Math.Round(value, 2);
}
}
/// <summary>
/// Y轴的移动坐标
/// </summary>
public double NodePositionY
{
get { return nodePositionY; }
set
{
nodePositionY = Math.Round(value, 2);
}
}
/// <summary>
/// 是否需要焊接
/// </summary>
public bool NeedSoldering { get; set; } = false;
/// <summary>
/// 焊接温度
/// </summary>
public int WeldTemp { get; set; } = 0;
/// <summary>
/// 焊接时间,秒,可以小数
/// </summary>
public double WeldTime { get; set; } = 0;
/// <summary>
/// 是否需要检测
/// </summary>
public bool NeedCheck { get; set; } = false;
/// <summary>
/// 是否已经校准
/// </summary>
public bool CheckOK = false;
/// <summary>
/// 复制点位时自动设置组
/// </summary>
public int Group { get; set; } = 0;
public long pUTime { get; set; } = 0;
public string ToCSVStr()
{
string spilt = ",";
return PN + spilt + "1" + spilt + "2" + spilt + PositionX + spilt + PositionY + spilt + "CRD" + spilt + NodePositionX + spilt + NodePositionY;
}
public string GetDisplayStr()
{
string text = PN;
if (Setting_NInit.Work_PointDisplayType.Equals(1))
{
text = TagNo;
}
return text;
}
public void UpdateImgP(ProjectorPInfo p)
{
PositionX = p.PX;
PositionY = p.PY;
PointType = p.PType;
PointSizeX = p.SizeX;
PointSizeY=p.SizeY;
PenWidth = p.PenWidth;
this.ShowText = p.ShowText;
this.PolaritiesType = p.PolaritiesType;
this.PolarityAngle= p.PolarityAngle;
}
public ProjectorPInfo GetShowPInfo(float imageXiShu=1,float imageYShu=1)
{
ProjectorPInfo p = new ProjectorPInfo(PositionX*imageXiShu, PositionY * imageYShu, PointType, PolaritiesType,PolarityAngle, (int)(PointSizeX * imageXiShu), (int)(PointSizeY * imageYShu), (int)(PenWidth * imageXiShu), ShowText);
return p;
}
public ProjectorPInfo GetScreenShowPInfo(float imageXiShu = 1, float imageYShu=1)
{
ProjectorPInfo p = new ProjectorPInfo(NodePositionX * imageXiShu, NodePositionY * imageYShu, PointType, PolaritiesType, PolarityAngle, (int)(PointSizeX * imageXiShu), (int)(PointSizeY * imageYShu), (int)(PenWidth * imageXiShu), ShowText);
return p;
}
/// <summary>
/// 点大小
/// </summary>
public int PointSizeX { get; set; } = 1;
public int PointSizeY { get; set; } = 1;
public int PenWidth { get; set; } = 2;
/// <summary>
/// 图片上的点的信息
/// </summary>
public DrawPointInfo imgP { get; set; } = null;
/// <summary>
/// 点类型,1=点,2=+,3=|,3=-,4=方形,5=圆圈
/// </summary>
public int PointType { get; set; } = 1;
public string ShowText = "";
/// <summary>
/// 是否禁用,默认0
/// </summary>
public bool Disable = false;
/// <summary>
/// 是否编辑成功
/// </summary>
public bool IsEdit =false;
/// <summary>
/// 极性,
/// </summary>
public int PolaritiesType { get; set; } = 0;
/// <summary>
/// 极性角度,
/// </summary>
public int PolarityAngle { get; set; } = 0;
/// <summary>
/// 导出导入程序时使用
/// </summary>
public ComponetInfo componet;
}
public class DrawPointInfo
{
public DrawPointInfo()
{
}
public DrawPointInfo(int sizeX, int sizeY, int pWidth )
{
SizeX = sizeX;
SizeY = sizeY;
PWidth = pWidth;
this.uTime = DateTime.Now.Ticks;
}
public int SizeX = 5;
public int SizeY = 5;
public int PWidth = 1;
/// <summary>
/// 最后一次更新时间
/// </summary>
public long uTime;
}
public class PcbOffsetInfo
{
public PcbOffsetInfo() { }
public PcbOffsetInfo(int x, int y, int a)
{
this.X = x;
this.Y = y;
this.A = a;
}
public int X { get; set; }
public int Y { get; set; }
public int A { get; set; }
}
}