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); }
public RemoteHelper(RemoteObject remoteObject) : this(remoteObject.SessionHandle.Session) { if (remoteObject.MyNodeId == NodeId.Null) { remoteObject.MyNodeId = BrowseNodeId(null, remoteObject.Name); } _parentNode = remoteObject.MyNodeId; }
public void Monitor(RemoteObject remoteObject) { remoteObject.Execute(() => { var invoker = new RemoteHelper(remoteObject); return(invoker.WriteVariable(this)); }); }
public Variant Write(RemoteObject remoteObject) { return(remoteObject.Execute(() => { var invoker = new RemoteHelper(remoteObject); return invoker.WriteVariable(this); })); }
public void Announce(RemoteObject remoteObject) { remoteObject.Execute(() => { var remoteHelper = new RemoteHelper(remoteObject); remoteHelper.MonitorDataChange(this, remoteObject); return(Variant.Null); }); }
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); }