FrmMesConfig.cs
5.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
using LineSoldering.Common;
using LineSoldering.DeviceLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace LineSoldering.Client
{
public partial class FrmMesConfig : FrmBase
{
public FrmMesConfig()
{
InitializeComponent();
}
private void btnSaveSetting_Click(object sender, EventArgs e)
{
saveValue();
}
private void getValue()
{
this.txtEMSIP.Text = RobotManager.SolderingRobot.MesIp.ToString();
this.txtPort.Text = RobotManager.SolderingRobot.MesPort.ToString();
}
private void saveValue()
{
try
{
int port = FormUtil.GetIntValue(txtPort);
string ip = FormUtil.getValue(txtEMSIP);
if (!FormUtil.IsIp(ip))
{
MessageBox.Show("请输入正确IP");
txtEMSIP.Focus();
txtEMSIP.SelectAll();
return;
}
if (port <= 0)
{
MessageBox.Show("请输入正确端口号");
txtPort.Focus();
txtPort.SelectAll();
return;
}
ConfigAppSettings.SaveValue(Setting_Init.Mes_IP, ip);
ConfigAppSettings.SaveValue(Setting_Init.Mes_Port, port);
ConfigAppSettings.SaveValue(Setting_Init.Mes_IsConnect, chbIsConnect.Checked);
MesUtil.NeedConnect = chbIsConnect.Checked;
RobotManager.SolderingRobot.MesIp = ip;
RobotManager.SolderingRobot.MesPort = port;
MessageBox.Show("保存成功!");
this.Close();
}
catch
{
MessageBox.Show("保存失败!");
}
}
private void FrmRobotSetting_Load(object sender, EventArgs e)
{
LogUtil.logBox = this.richTextBox1;
this.chbIsConnect.Checked = MesUtil.NeedConnect;
getValue();
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnConnect_Click(object sender, EventArgs e)
{
MesUtil.RivetInit(RobotManager.SolderingRobot.MesIp, RobotManager.SolderingRobot.MesPort);
}
private void btnStop_Click(object sender, EventArgs e)
{
MesUtil.Close();
}
private void FrmConfig_FormClosed(object sender, FormClosedEventArgs e)
{
MesUtil.Close();
LogUtil.logBox = null;
}
string preCode = "";
private void btnCheckCode_Click(object sender, EventArgs e)
{
string code = FormUtil.getValue(txtCode);
LogUtil.info("铆压发送二维码验证: 【" + code + "】 ");
MesUtil.ConfirmCode(code, CodeResult);
preCode = code;
}
private void CodeResult(string code1, string result1, string code2, string result2)
{
LogUtil.info( "收到验证结果, 【" + code1 + "】【" + result1 + "】【" + code2 + "】【" + result2 + "】 ");
preCode = code1;
}
private void btnSendResult_Click(object sender, EventArgs e)
{
int result = FormUtil.GetIntValue(txtResult);
double value = FormUtil.getDoubleValue(txtPressValue);
MesUtil.UploadRivetResult(preCode, result, value);
LogUtil.info("上传铆压结果, 二维码【" + preCode + "】结果【" + result + "】压力值【"+value+"】 ");
}
private void btnClear_Click(object sender, EventArgs e)
{
this.richTextBox1.Clear();
}
private void btnSConnect_Click(object sender, EventArgs e)
{
MesUtil.SolderInit(RobotManager.SolderingRobot.MesIp, RobotManager.SolderingRobot.MesPort);
}
private void btnSStop_Click(object sender, EventArgs e)
{
MesUtil.Close();
}
private void btnSCheck_Click(object sender, EventArgs e)
{
string code = FormUtil.getValue(txtCode);
string code2 = FormUtil.getValue(txtSCode2);
LogUtil.info("焊接发送二维码验证: 【" + code + "】【"+code2+"】 ");
MesUtil.ConfirmSolderCode(code,code2, CodeResult);
preCode = code2;
}
private void btnSSend_Click(object sender, EventArgs e)
{
int result = FormUtil.GetIntValue(txtResult );
MesUtil.UploadSolderResult(FormUtil.getValue(txtCode), FormUtil.getValue(txtSCode2), result);
LogUtil.info("上传焊接结果, 二维码【" + preCode + "】结果【" + result + "】 ");
}
private void btnScrewStop_Click(object sender, EventArgs e)
{
MesUtil.Close();
}
private void btnScrewConnect_Click(object sender, EventArgs e)
{
MesUtil.ScrewInit(RobotManager.SolderingRobot.MesIp, RobotManager.SolderingRobot.MesPort);
}
private void btnScrewCheck_Click(object sender, EventArgs e)
{
string code = FormUtil.getValue(txtCode);
LogUtil.info("锁付发送二维码验证: 【" + code + "】 ");
MesUtil.ConfirmCode(code, CodeResult);
preCode = code;
}
private void btnScrewSend_Click(object sender, EventArgs e)
{
int result = FormUtil.GetIntValue(txtResult);
MesUtil.UploadScrewResult(preCode, RESULT.OK, new List<double> { 11.1, 22.2, 33.3, 44.4, 55.5 });
LogUtil.info("上传焊接结果, 二维码【" + preCode + "】结果【" + result + "】 ");
}
}
}