FrmSendWire.cs
4.5 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
using log4net;
using System;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using URSoldering.Common;
using URSoldering.DeviceLibrary;
using URSoldering.LoadCSVLibrary;
namespace URSoldering.Client
{
public partial class FrmSendWire : FrmBase
{
public FrmSendWire()
{
CheckForIllegalCrossThreadCalls = false;
InitializeComponent();
}
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private void btnStopSend_Click(object sender, EventArgs e)
{
SendWireManager.StopSend();
}
protected override void OnVisibleChanged(EventArgs e)
{
base.OnVisibleChanged(e);
if (!IsHandleCreated)
{
this.Close();
}
}
private void formStatus(bool isOpen)
{
btnSetSold.Enabled = isOpen;
btnOpenSold.Enabled = !isOpen;
btnCloseSold.Enabled = isOpen;
btnStartSend.Enabled = isOpen;
btnStartSend.Enabled = isOpen;
btnStartBack.Enabled = isOpen;
btnReadError.Enabled = isOpen;
}
private void btnOpenSold_Click(object sender, EventArgs e)
{
if (SendWireManager.Init(WeldRobotBean.RobotConfig.JBC_SendWire_Port))
{
formStatus(true);
}
else
{
MessageBox.Show("打开送丝机失败!");
}
}
private void btnCloseSold_Click(object sender, EventArgs e)
{
SendWireManager.Release();
formStatus(false);
}
private void btnSetSold_Click(object sender, EventArgs e)
{
double speed = FormUtil.getDoubleValue(txtSpeed);
double length = FormUtil.getDoubleValue(txtLength);
SendWireManager.setLength(length);
SendWireManager.setSpeed(speed);
}
private void btnCloseForm_Click(object sender, EventArgs e)
{
this.Close();
}
private void timer2_Tick(object sender, EventArgs e)
{
if (RobotBean.KNDIOValue(IO_Type.SuddenStop_Single).Equals(IO_VALUE.LOW))
{
lblMsg.Text = "急停未开";
}
else
{
lblMsg.Text = "";
}
}
private void btnReadError_Click(object sender, EventArgs e)
{
int error = SendWireManager.ReadPortError();
txtPortError.Text = error.ToString();
}
private void btnStartSend_Click(object sender, EventArgs e)
{
SendWireManager.StartFSend();
}
private void btnStartBack_Click(object sender, EventArgs e)
{
SendWireManager.StartBSend();
}
private void btnStop_Click(object sender, EventArgs e)
{
SendWireManager.StopSend();
}
private void FrmSendWire_Load(object sender, EventArgs e)
{
txtSoldingCom.Text = WeldRobotBean.RobotConfig.JBC_SendWire_Port;
if (SendWireManager.IsRun)
{
formStatus(true);
}
else
{
formStatus(false);
}
}
private void btnReadError_Click_1(object sender, EventArgs e)
{
double speed = SendWireManager.querySpeed();
txtSpeed.Text = speed.ToString();
double length = SendWireManager.queryLength();
txtLength.Text = length.ToString();
int value = SendWireManager.ReadPortError();
txtPortError.Text = value.ToString();
}
private void btnReset_Click(object sender, EventArgs e)
{
SendWireManager.Reset();
}
private void btnSend_Click(object sender, EventArgs e)
{
txtRevice.Text = "";
string text = txtSend.Text;
bool isOk = false;
byte[] reviceData = SendWireManager.parseCommand(text, out isOk);
if (reviceData != null && reviceData.Length > 0)
{
int length = reviceData.Length - 3;
if (length <= 0)
{
length = reviceData.Length;
}
string rawMsg = Encoding.ASCII.GetString(reviceData, 1, length);
txtRevice.Text = rawMsg;
}
}
}
}