CIDebugControl.cs
5.3 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
using OnlineStore;
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;
using System.Threading.Tasks;
using System.Windows.Forms;
using ConfigHelper;
namespace TheMachine.device
{
public partial class CIDebugControl : UserControl
{
public CIDebugControl()
{
InitializeComponent();
RobotManage.LoadFinishEvent += RobotManage_LoadFinishEvent;
//Config.PropertyBind(Setting_Init.VJCounter_COMPORT.Key, cb_com, "SelectedItem", "SelectedIndexChanged");
//Config.PropertyBind(Setting_Init.VJCounter_BaudRate.Key, cb_bitrate, "SelectedItem", "SelectedIndexChanged");
}
private void RobotManage_LoadFinishEvent(bool state, string msg)
{
if (!TrayStop.DeviceList.ContainsKey("CI"))
return;
CI.DeviceList["CI"].ReelReady += CIDebugControl_ReelReady;
CI.DeviceList["CI"].XRayStep += CIDebugControl_XRayStep;
CI.DeviceList["CI"].ManualCount = cb_manualcount.Checked;
}
XRayStepE currentstep= XRayStepE.Finish;
private void CIDebugControl_XRayStep(object sender, XRayStepE e)
{
currentstep = e;
LogUtil.info("CID:CI测试界面接受到步骤:" + e);
this.Invoke((EventHandler)delegate
{
switch (e)
{
case XRayStepE.WaitMTtoVJ:
btn_start.Enabled = true;
break;
case XRayStepE.Counting:
btn_start.Enabled = false;
break;
case XRayStepE.WaitVJtoMT:
btn_finishcount.Enabled = true;
break;
case XRayStepE.Finish:
btn_finishcount.Enabled = false;
btn_start.Enabled = false;
break;
}
});
}
private void CIDebugControl_ReelReady(object sender, string e)
{
this.Invoke((EventHandler)delegate {
LogUtil.info("CID:CI测试界面接受到条码:" + e);
txt_barcode.Text = e;
});
}
private void timer1_Tick(object sender, EventArgs e)
{
if (!TrayStop.DeviceList.ContainsKey("CI"))
return;
string status = "";
if (TrayStop.DeviceList["CI"].IOValue(IO_Type.CI_Count_Finished).Equals(IO_VALUE.HIGH))
{
status = "Ready";
}
else
{
status = "Counting";
}
label_status.Text = status+", "+ currentstep;
label_watchstatus.Text = $"Last SN:{RobotManage.folderWatcher.LastSN}, QTY:{RobotManage.folderWatcher.LastQty}, " + RobotManage.folderWatcher.LastUpdateTime.ToString();
}
private void btn_start_Click(object sender, EventArgs e)
{
if (CI.DeviceList["CI"].MoveInfo.MoveStep == MoveStep.MI_01)
CI.DeviceList["CI"].MoveInfo.NextMoveStep(MoveStep.MI_02);
else
MessageBox.Show("没有准备点料的托盘");
return;
if (TrayStop.DeviceList["CI"].IOValue(IO_Type.CI_Count_Finished).Equals(IO_VALUE.HIGH))
{
if (VJCounter.CheckConnect())
{
VJCounter.SendBarcode(txt_barcode.Text.Trim());
Thread.Sleep(500);
TrayStop.DeviceList["CI"].IOMove(IO_Type.CI_Start, IO_VALUE.HIGH, 500);
LogUtil.info("CID:手动点击开始点料");
}
else {
MessageBox.Show(crc.GetString("Res0117.c9f109fe","未成功连接VJ点料机"));
}
}
else
{
MessageBox.Show(crc.GetString("Res0118.f955ef4e","点料机没有准备好,不能启动."));
}
}
private void cb_manualcount_CheckedChanged(object sender, EventArgs e)
{
CI.DeviceList["CI"].ManualCount = cb_manualcount.Checked;
}
private void btn_finishcount_Click(object sender, EventArgs e)
{
LogUtil.info("CID:用户确认放料完成");
CI.DeviceList["CI"].StartOutStore();
}
private void btn_manualsend_Click(object sender, EventArgs e)
{
LogUtil.info("CID:手动点击SendBarcode");
var bc = txt_barcode.Text.Trim() + VJCounter.newline;
VJCounter.SendBarcode(bc);
MessageBox.Show("send: \"" + bc.Replace("\r","\\r").Replace("\n","\\n")+"\"");
}
private void btn_reopen_Click(object sender, EventArgs e)
{
if (!VJCounter.Connect(Setting_Init.VJCounter_COMPORT, Setting_Init.VJCounter_BaudRate, out string msgs))
{
MessageBox.Show(msgs);
}
}
private void button_start_Click(object sender, EventArgs e)
{
LogUtil.info("CID:手动点击startbtn");
TrayStop.DeviceList["CI"].IOMove(IO_Type.CI_Start, IO_VALUE.HIGH, 500);
}
}
}