123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- using ProjectBase.Data.Logs;
- using SIMDP.Device;
- using ProjectBase.Util;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using SIMDP.Model;
- namespace SIMDP.Project
- {
- /// <summary>
- /// 仅用于代码测试
- /// </summary>
- class OpcUaDemo : PlcOpcUA
- {
- #region 数据定义
- #endregion
- #region 重写父类函数
- public override void actionStart() { }
- public override void actionStop() { }
- public override void actionConnected() { }
- public override void actionTimer()
- {
- try
- {
- // 轮询监控节点
- foreach (var p in monitorPoints)
- {
- object value;
- if (!Read(p, out value)) continue;
- if (!value.Equals(p.value))
- {
- p.value = value;
- if (p.proc != null)
- p.proc.Invoke(this, new object[] { value });
- }
- }
- redis.Publish<string>(SysEnvironment.OpcDataChannel, "");
- // 处理无线按钮呼叫信号
- //DealWirelessButtonCall();
- }
- catch (Exception ex)
- {
- LogHelper.log.Error("读取PLC(" + m_OpcUaClient.OpcUaName + ")信号(" + ")发生异常:" + ex.Message);
- m_OpcUaClient.Disconnect();
- SetRedisPlcDisConnect();
- }
- }
- #endregion
- }
- }
|