Exemple #1
0
 public static NewOpcServer GetInstance()
 {
     if (_instance == null)
     {
         _instance = new NewOpcServer();
     }
     return(_instance);
 }
Exemple #2
0
        public static OpcValue ReadTag(NewOpcServer.OpcList obj, string tag)
        {
            if (!string.IsNullOrEmpty(tag))
            {
                var result = NewOpcServer.GetInstance().GetOpc(obj)?.ReadNode(tag.ToNode(), OpcAttribute.Value);
                return(result);
            }

            return(null);
        }
Exemple #3
0
        public static bool WriteTags(NewOpcServer.OpcList obj, Dictionary <ApiOpcParameter, string> parameters)
        {
            var opcWriteNodeList = new List <OpcWriteNode>();

            foreach (var parameter in parameters)
            {
                var opcWriteNode = GetOpcWriteNode(parameter.Value, parameter.Key);
                opcWriteNodeList.Add(opcWriteNode);
            }

            var commands   = opcWriteNodeList.ToArray();
            var results    = NewOpcServer.GetInstance().GetOpc(obj)?.WriteNodes(commands);
            var goodResult = (results ?? throw new InvalidOperationException()).Count(x => x.Code == 0);

            return(goodResult == parameters.Count);
        }