| | |
| | | |
| | | } |
| | | |
| | | private void OPC_OnReadItemValueChanged(OPC.Item item, int itemValue) |
| | | { |
| | | var x = (from i in _ioBindlingList |
| | | where i.OPCName == item.name |
| | | select i).FirstOrDefault(); |
| | | if (x != default(PLCIO)) |
| | | { |
| | | x.PLCValue = itemValue == 1; |
| | | dgvPLCIO.Invalidate(); |
| | | } |
| | | } |
| | | |
| | | public void OPCEventHandler(object sender, EventTool.ListenEventArgs e) |
| | | { |
| | |
| | | dgvPLCIO.Rows[i].Cells["PLCValue"].Style.BackColor = _ioList[i].PLCValue ? Color.Green : Color.White; |
| | | } |
| | | |
| | | _opc.listenEventCreater.ListenEvent += this.OPCEventHandler; |
| | | //_opc.listenEventCreater.ListenEvent += this.OPCEventHandler; |
| | | _opc.OnReadItemValueChanged += OPC_OnReadItemValueChanged; |
| | | } |
| | | |
| | | private void FormPLCIO_FormClosing(object sender, FormClosingEventArgs e) |
| | | { |
| | | |
| | | _opc.listenEventCreater.ListenEvent -= this.OPCEventHandler; |
| | | _opc.OnReadItemValueChanged -= OPC_OnReadItemValueChanged; |
| | | //_opc.listenEventCreater.ListenEvent -= this.OPCEventHandler; |
| | | |
| | | } |
| | | |