VisionStoreDetect.cs
5.4 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
using DeviceLibrary;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TheMachine
{
public partial class VisionStoreDetect : UserControl
{
public VisionStoreDetect()
{
InitializeComponent();
RobotManage.LoadFinishEvent += RobotManage_LoadFinishEvent; ;
CameraPointTest.TestStorePointEvent += CameraPointTest_TestStorePointEvent;
}
private void RobotManage_LoadFinishEvent(bool state, string msg)
{
return;
if (!this.Created)
return;
this.Invoke((EventHandler)delegate
{
LogUtil.info("开始采集");
PictureBox p1 = new PictureBox();
PictureBox p2 = new PictureBox();
PictureBox p3 = new PictureBox();
PictureBox p4 = new PictureBox();
RobotManage.CameraA.PreviewImage("monitorA", p1.Handle);
RobotManage.CameraA.PreviewImage("monitorB", p2.Handle);
RobotManage.CameraA.PreviewImage("monitorC", p3.Handle);
RobotManage.CameraA.PreviewImage("monitorD", p4.Handle);
RobotManage.CameraA.Open();
RobotManage.CameraA.GetPictureBoxEvent += CameraA_GetPictureBoxEvent;
});
}
private Bitmap CameraA_GetPictureBoxEvent(int index)
{
switch (index) {
case 0:
return Common.DeepClone((Bitmap)pictureBox1.Image);
case 1:
return Common.DeepClone((Bitmap)pictureBox2.Image);
case 2:
return Common.DeepClone((Bitmap)pictureBox3.Image);
case 3:
return Common.DeepClone((Bitmap)pictureBox4.Image);
}
return null;
}
private void timer1_Tick(object sender, EventArgs e)
{
return;
if (!this.Visible)
return;
Task.Run(() =>
{
//LogUtil.info("开始采集1");
CameraPointTest.GetThingStoreName(TestStorePointPort.入口);
CameraPointTest.GetThingStoreName(TestStorePointPort.出口);
CameraPointTest.GetThingStoreName(TestStorePointPort.上层左侧);
CameraPointTest.GetThingStoreName(TestStorePointPort.下层右侧);
});
}
private void CameraPointTest_TestStorePointEvent(object sender, Bitmap e)
{
if (!this.Created)
return;
this.Invoke((EventHandler<Bitmap>)delegate {
var b = e;// Common.DeepClone(e);
TestStorePointPort tp = (TestStorePointPort)sender;
switch (tp)
{
case TestStorePointPort.入口:
pictureBox1.Image = b;
break;
case TestStorePointPort.出口:
pictureBox2.Image = b;
break;
case TestStorePointPort.上层左侧:
case TestStorePointPort.下层左侧:
pictureBox3.Image = b;
break;
case TestStorePointPort.上层右侧:
case TestStorePointPort.下层右侧:
pictureBox4.Image = b;
break;
}
}, sender,e);
}
private void VisionStoreDetect_Load(object sender, EventArgs e)
{
}
private void TestALL_Click(object sender, EventArgs e)
{
//RobotManage.CameraA.GetImage(0).Save("test.bmp");
Task.Run(() =>
{
// LogUtil.info("1");
//Common.DeepClone((Bitmap)pictureBox1.Image).Save("test.bmp");
var haslistStoreName = CameraPointTest.GetThingStoreName(TestStorePointPort.入口);
LogUtil.info("入口:" + string.Join(",", haslistStoreName));
haslistStoreName = CameraPointTest.GetThingStoreName(TestStorePointPort.出口);
LogUtil.info("出口:" + string.Join(",", haslistStoreName));
if (IOManager.IOValue(IO_Type.Tside_Right).Equals(IO_VALUE.HIGH))
{
haslistStoreName=CameraPointTest.GetThingStoreName(TestStorePointPort.上层右侧);
LogUtil.info("上层右侧:" + string.Join(",", haslistStoreName));
haslistStoreName =CameraPointTest.GetThingStoreName(TestStorePointPort.下层左侧);
LogUtil.info("下层左侧:" + string.Join(",", haslistStoreName));
} else {
haslistStoreName = CameraPointTest.GetThingStoreName(TestStorePointPort.上层左侧);
LogUtil.info("上层左侧:" + string.Join(",", haslistStoreName));
haslistStoreName = CameraPointTest.GetThingStoreName(TestStorePointPort.下层右侧);
LogUtil.info("下层右侧:" + string.Join(",", haslistStoreName));
}
});
RobotManage.mainMachine.ScanCode();
}
}
}