jace.tang
2023-02-11 ed8d469ccdc0e627d8f180bb92a9d78dbdb008b1
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
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.Windows.Forms;
 
namespace M423project
{
    public partial class FormPlcOperation : Form
    {
        private OPC _opc;
        public FormPlcOperation(OPC opc)
        {
            InitializeComponent();
            _opc = opc;
 
            object result = new object();
 
            _opc.ReadOneItem_Wrapper(OPCOutputTag.PingbiGuangShan, ref result);
            cbPingbiGuangshan.Checked = result != null && (bool)result ? true : false;
 
            _opc.ReadOneItem_Wrapper(OPCOutputTag.PingbiSafeGuard, ref result);
            cbPingbiSafeGuard.Checked = result != null && (bool)result ? true : false;
 
            this.Load += (s, e) =>
              {
                  cbPingbiGuangshan.CheckedChanged += cbPingbiGuangshan_CheckedChanged;
                  cbPingbiSafeGuard.CheckedChanged += cbPingbiSafeGuard_CheckedChanged;
              };
        }
 
        private void cbLoadRbtAlarm_CheckedChanged(object sender, EventArgs e)
        {
            _opc.Write(OPCOutputTag.LoadRbtAlarm, cbLoadRbtAlarm.Checked);
            cbLoadRbtAlarm.Checked = false;
        }
 
        private void cbUnloadRbtAlarm_CheckedChanged(object sender, EventArgs e)
        {
            _opc.Write(OPCOutputTag.UnloadRbtAlarm, cbUnloadRbtAlarm.Checked);
            cbUnloadRbtAlarm.Checked = false;
        }
 
        private void btnCloseAlarm_Click(object sender, EventArgs e)
        {
            _opc.Write(OPCOutputTag.CloseAlarm, true);
        }
 
        private void btnTailingEmpty_Click(object sender, EventArgs e)
        {
            _opc.Write(OPCOutputTag.TailingEmpty, true);
            Thread.Sleep(500);
            _opc.Write(OPCOutputTag.TailingEmpty, false);
            Thread.Sleep(10);
        }
 
        private void cbPingbiGuangshan_CheckedChanged(object sender, EventArgs e)
        {
            if (new ConfigPassword("").ShowDialog() == DialogResult.OK)
            {
                _opc.Write(OPCOutputTag.PingbiGuangShan, cbPingbiGuangshan.Checked);
            }
        }
 
        private void cbPingbiSafeGuard_CheckedChanged(object sender, EventArgs e)
        {
            if (new ConfigPassword("").ShowDialog() == DialogResult.OK)
            {
                _opc.Write(OPCOutputTag.PingbiSafeGuard, cbPingbiSafeGuard.Checked);
            }
        }
    }
}