Example #1
0
        public void MonitorDataChange(RemoteDataMonitor monitor, RemoteObject remoteObject)
        {
            var monitoredItems = new List <MonitoredItem>
            {
                new DataMonitoredItem(BrowseNodeId(_parentNode, monitor.Name))
                {
                    UserData          = monitor,
                    DataChangeTrigger = DataChangeTrigger.StatusValue
                }
            };

            remoteObject.SessionHandle.ClientSubscription().CreateMonitoredItems(monitoredItems,
                                                                                 new RequestSettings {
                OperationTimeout = 10000
            });

            remoteObject.SessionHandle.SetDataChangeHandler(
                (ss, args) =>
            {
                Logger.Info("Received DATA CHANGE ...");
                foreach (var dataChange in args.DataChanges)
                {
                    var remoteDataMonitor = (RemoteDataMonitor)dataChange.MonitoredItem.UserData;
                    remoteDataMonitor?.DataChange(dataChange.Value.WrappedValue);
                }
            });

            remoteObject.SessionHandle.MonitoredItems.AddRange(monitoredItems);
        }
Example #2
0
 public RemoteHelper(RemoteObject remoteObject) : this(remoteObject.SessionHandle.Session)
 {
     if (remoteObject.MyNodeId == NodeId.Null)
     {
         remoteObject.MyNodeId = BrowseNodeId(null, remoteObject.Name);
     }
     _parentNode = remoteObject.MyNodeId;
 }
Example #3
0
 public void Monitor(RemoteObject remoteObject)
 {
     remoteObject.Execute(() =>
     {
         var invoker = new RemoteHelper(remoteObject);
         return(invoker.WriteVariable(this));
     });
 }
Example #4
0
 public Variant Write(RemoteObject remoteObject)
 {
     return(remoteObject.Execute(() =>
     {
         var invoker = new RemoteHelper(remoteObject);
         return invoker.WriteVariable(this);
     }));
 }
Example #5
0
 public void Announce(RemoteObject remoteObject)
 {
     remoteObject.Execute(() =>
     {
         var remoteHelper = new RemoteHelper(remoteObject);
         remoteHelper.MonitorDataChange(this, remoteObject);
         return(Variant.Null);
     });
 }
Example #6
0
        public Variant Invoke(RemoteObject remoteObject)
        {
            var methodNodeId = NodeId.Null;

            if (remoteObject.NodeIdCache.ContainsKey(Name))
            {
                methodNodeId = remoteObject.NodeIdCache[Name];
            }

            var result = remoteObject.Execute(() =>
            {
                var invoker = new RemoteHelper(remoteObject);
                return(invoker.CallMethod(this, ref methodNodeId));
            });

            if (methodNodeId != NodeId.Null && !remoteObject.NodeIdCache.ContainsKey(Name))
            {
                remoteObject.NodeIdCache[Name] = methodNodeId;
            }

            return(result);
        }