M182轴承端盖外观缺陷AOI
kingno
2025-05-26 5a405c7dce20d8c79a733c9c786cc42eb59fe81c
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
using Bro.Common.Helper;
using Bro.UI.Model.Winform;
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;
using Windows.UI.Composition.Interactions;
 
namespace Bro.M141.Process.UI
{
    [MenuNode("ProductStatus", "PLC状态显示界面", 1, EnumHelper.TopMenu.SystemInfo, MenuNodeType.Form)]
 
    //public partial class PLCstate : UserControl
    public partial class PLCstate : MenuFormBase
    {
        public PLCstate()
        {
            InitializeComponent();
        }
 
        M141Process M141Process => Process as M141Process;
        public override void OnProcessUpdated()
        {
            base.OnProcessUpdated();
 
            M141Process.RefreshUIplc -= RefreshUI;
            M141Process.RefreshUIplc += RefreshUI;
 
 
            //lab11 皮带速度
            //lab12 单位mm/s
 
        }
 
 
        Dictionary<int, string> address = new Dictionary<int, string>();
 
        private void button1_Click(object sender, EventArgs e)
        {
            M141Process.PlcWrite(3021, State_now[1] == 1 ? 0 : 1);
        }
 
        private void button3_Click(object sender, EventArgs e)
        {
            M141Process.PlcWrite(3023, State_now[3] == 1 ? 0 : 1);
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            M141Process.PlcWrite(3022, State_now[2] == 1 ? 0 : 1);
        }
 
        private void button4_Click(object sender, EventArgs e)
        {
            M141Process.PlcWrite(3020, State_now[0] == 1 ? 0 : 1);
        }
 
        private void button5_Click(object sender, EventArgs e)
        {
            M141Process.PlcWrite(3024, State_now[7] == 1 ? 0 : 1);
        }
 
        List<int> State_now = new List<int>() { };
        public void RefreshUI(List<int> Intstate)
        {
            this.Invoke(new Action(() =>
            {
                if (Intstate.Count == 17)
                {
                    State_now = Intstate;
 
                    label4.Text = "阻挡气缸当前状态:    " + (Intstate[0] == 1 ? "伸出" : "缩回");
                    button4.Text = "阻挡气缸" + (Intstate[0] == 0 ? "伸出" : "缩回");
 
                    label1.Text = "收料气缸1当前状态:    " + (Intstate[1] == 0 ? "伸出" : "缩回");
                    button1.Text = "收料气缸1" + (Intstate[1] == 1 ? "伸出" : "缩回");
 
                    label2.Text = "收料气缸2当前状态:    " + (Intstate[2] == 0 ? "伸出" : "缩回");
                    button2.Text = "收料气缸2" + (Intstate[2] == 1 ? "伸出" : "缩回");
 
                    label3.Text = "收料气缸3当前状态:    " + (Intstate[3] == 0 ? "伸出" : "缩回");
                    button3.Text = "收料气缸3" + (Intstate[3] == 1 ? "伸出" : "缩回");
 
 
                    label10.Text = "皮带当前状态:    " + (Intstate[7] == 0 ? "停止" : "旋转");
                    button5.Text = "皮带" + (Intstate[7] == 1 ? "停止" : "旋转");
 
 
                    label5.Text = "通道1有无料:    " + (Intstate[4] == 0 ? "无料" : "有料");
                    label6.Text = "通道2有无料:    " + (Intstate[5] == 0 ? "无料" : "有料");
                    label7.Text = "通道3有无料:    " + (Intstate[6] == 0 ? "无料" : "有料");
 
                    string Alarmstr = "";
                    for (int i = 10; i <= 16; i++)
                    {
                        if (Intstate[i] == 1)
                        {
                            Alarmstr += address[i] + "\r\n";
                        }
                    }
                    if (string.IsNullOrEmpty(Alarmstr))
                    {
                        label9.Text = "无";
                        label9.BackColor = Color.Transparent;
                    }
                    else
                    {
                        label9.Text = Alarmstr;
                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"PLC报警信息: {Alarmstr}");
                        label9.BackColor = Color.Red;
                    }
                }
                else if (Intstate.Count == 8)
                {
                    label18.Text = Intstate[0].ToString();
                    label19.Text = Intstate[4].ToString();
                    label17.Text = Intstate[6].ToString();
                }
            }));
        }
 
        private void PLCstate_Load(object sender, EventArgs e)
        {
            address[0] = "阻挡气缸";
            address[1] = "收缩气缸1";
            address[2] = "收缩气缸2";
            address[3] = "收缩气缸3";
 
            address[4] = "通道1有无料";
            address[5] = "通道2有无料";
            address[6] = "通道3有无料";
 
            address[10] = "阻挡气缸原点报警";
            address[11] = "收料气缸1动点报警";
            address[12] = "收料气缸2动点报警";
            address[13] = "收料气缸3动点报警";
            address[14] = "急停报警";
            address[15] = "皮带轴报警";
            address[16] = "上位机通讯报警";
        }
 
        private void button6_Click(object sender, EventArgs e)
        {
            int speed = 0;
            try
            {
                speed = Convert.ToInt32(textBox1.Text);
                M141Process.PlcWrite(3010, speed);
            }
            catch
            {
                MessageBox.Show("请输入有效数字");
                return;
            }
        }
 
        private void button7_Click(object sender, EventArgs e)
        {
            int speed = 0;
            try
            {
                speed = Convert.ToInt32(textBox2.Text);
                //M141Process.PlcWrite(3012, speed / 100);
                M141Process.PlcWrite(3014, speed);
            }
            catch
            {
                MessageBox.Show("请输入有效数字");
                return;
            }
        }
 
        private void label9_Click(object sender, EventArgs e)
        {
 
        }
        private void label8_Click(object sender, EventArgs e)
        {
 
        }
 
        private void button8_Click(object sender, EventArgs e)
        {
            int speed = 0;
            try
            {
                speed = Convert.ToInt32(textBox3.Text);
                //M141Process.PlcWrite(3012, speed / 100);
                M141Process.PlcWrite(3016, speed);
            }
            catch
            {
                MessageBox.Show("请输入有效数字");
                return;
            }
        }
 
 
        int linestate = 1;
 
        private void button9_Click(object sender, EventArgs e)
        {
            M141Process.PlcWrite(3026, linestate);
            linestate = linestate == 1 ? 0 : 1;
        }
 
        private void button10_Click(object sender, EventArgs e)
        {
            M141Process.PlcWrite(3025, 1);
        }
    }
}