FrmDbLineIO.cs
7.2 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
using OnlineStore.DeviceLibrary;
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 OnlineStore.DoubleLineClient
{
public partial class FrmDbLineIO : FrmBase
{
public FrmDbLineIO()
{
InitializeComponent();
}
private List<Control> DILabel = new List<Control>();
private List<Control> doList = new List<Control>();
private List<Control> rfidList = new List<Control>();
private void FrmDbLineIO_Load(object sender, EventArgs e)
{
}
private void FrmDbLineIO_Shown(object sender, EventArgs e)
{
if (DILabel.Count <= 0)
{
DILabel = new List<Control>();
doList = new List<Control>();
rfidList = new List<Control>();
foreach (Control con in this.Controls)
{
if (con is GroupBox)
{
foreach (Control c in con.Controls)
{
if (c is Label)
{
if (LineManager.Line.Config.DIList.ContainsKey(c.Name))
{
DILabel.Add(c);
}
else if( c.Tag !=null && LineManager.Line.RfidIpList.Contains(c.Tag.ToString()))
{
rfidList.Add(c);
}
}
else if (c is Button)
{
if (LineManager.Line.Config.DOList.ContainsKey(c.Name))
{
doList.Add(c);
}
}
}
}
}
}
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
if (!this.Visible)
{
return;
}
//Task.Factory.StartNew();
this.Invoke(new Action(() =>
{
if (!lblA5State.Text.Equals(LineManager.packageLine.A5_State))
lblA5State.Text = LineManager.packageLine.A5_State;
if (!lblA6State.Text.Equals(LineManager.packageLine.A6_State))
lblA6State.Text = LineManager.packageLine.A6_State;
}));
foreach (Control labl in DILabel)
{
IO_VALUE value = LineManager.Line.IOValue(labl.Name);
if (value.Equals(IO_VALUE.HIGH))
{
labl.BackColor = Color.LawnGreen;
}
else if (value.Equals(IO_VALUE.LOW))
{
labl.BackColor = Color.LightGray;
}
}
foreach (Control labl in doList)
{
IO_VALUE value = LineManager.Line.IOValue(labl.Name);
if (value.Equals(IO_VALUE.HIGH))
{
labl.BackColor = Color.LawnGreen;
}
else if (value.Equals(IO_VALUE.LOW))
{
labl.BackColor = labl.Parent.BackColor;
//labl.BackColor = Color.LightGray;
}
}
foreach (Control lbl in rfidList)
{
string tmpRfid = RFIDManager.ReadRFID(lbl.Tag.ToString()).NumStr();
if(!tmpRfid.Equals(lbl.Text))
{
lbl.Text = string.Format("{0}:{1}", lbl.Tag.ToString(), tmpRfid);
}
}
}
private void Line_StopCylinder_Click(object sender, EventArgs e)
{
Control c = (Control)sender;
string ioType = c.Name;
IO_VALUE value = LineManager.Line.IOValue(c.Name);
if (value.Equals(IO_VALUE.LOW))
{
LineManager.Line.IOMove(ioType, IO_VALUE.HIGH);
c.BackColor = Color.LawnGreen;
}
else
{
LineManager.Line.IOMove(ioType, IO_VALUE.LOW);
c.BackColor = c.Parent.BackColor;
}
}
private void btnS1Up_Click(object sender, EventArgs e)
{
LineManager.Line.CylinderMove(null, IO_Type.S1_TopCylinderDown, IO_Type.S1_TopCylinderUp);
}
private void btnS1Down_Click(object sender, EventArgs e)
{
LineManager.Line.CylinderMove(null, IO_Type.S1_TopCylinderUp, IO_Type.S1_TopCylinderDown);
}
private void btnLUp_Click(object sender, EventArgs e)
{
LineManager.Line.CylinderMove(null, IO_Type.L_Updown_Down, IO_Type.L_Updown_Up);
}
private void btnLDown_Click(object sender, EventArgs e)
{
LineManager.Line.CylinderMove(null, IO_Type.L_Updown_Up, IO_Type.L_Updown_Down);
}
private void btnMUp_Click(object sender, EventArgs e)
{
LineManager.Line.CylinderMove(null, IO_Type.M_Updown_Down, IO_Type.M_Updown_Up);
}
private void btnMDown_Click(object sender, EventArgs e)
{
LineManager.Line.CylinderMove(null, IO_Type.M_Updown_Up, IO_Type.M_Updown_Down);
}
private void btnS2Up_Click(object sender, EventArgs e)
{
// LineManager.Line.CylinderMove(null, IO_Type.S2_TopCylinderDown, IO_Type.S2_TopCylinderUp);
}
private void btnS2Down_Click(object sender, EventArgs e)
{
// LineManager.Line.CylinderMove(null, IO_Type.S2_TopCylinderUp, IO_Type.S2_TopCylinderDown);
}
private void btnRUp_Click(object sender, EventArgs e)
{
LineManager.Line.CylinderMove(null, IO_Type.R_Updown_Down, IO_Type.R_Updown_Up);
}
private void btnRDown_Click(object sender, EventArgs e)
{
LineManager.Line.CylinderMove(null, IO_Type.R_Updown_Up, IO_Type.R_Updown_Down);
}
private void btnS1StopDown_Click(object sender, EventArgs e)
{
LineManager.Line.S1_StopMove(null, IO_VALUE.LOW, true);
}
private void S1StopDown_Click(object sender, EventArgs e)
{
LineManager.Line.S1_StopMove(null, IO_VALUE.HIGH, true);
}
private void btnS1Stop_Click(object sender, EventArgs e)
{
LineManager.Line.IOMove(IO_Type.S1_LineBackRun, IO_VALUE.LOW);
LineManager.Line.IOMove(IO_Type.S1_LineRun, IO_VALUE.LOW);
}
private void btnOpenRFID_Click(object sender, EventArgs e)
{
RFIDManager.Open(LineManager.Line.RfidIpList.ToArray());
Common.LogUtil.info("手动开启RFID");
}
private void button2_Click(object sender, EventArgs e)
{
RFIDManager.Close();
Common.LogUtil.info("手动关闭RFID");
}
}
}