public async Task <UaValue> ReadUaValueAsync(string serverUrl, VariableNode variableNode) { Session session = await GetSessionAsync(serverUrl); var typeManager = new DataTypeManager(session); return(typeManager.GetUaValue(variableNode)); }
private void OnMonitorNotification(MonitoredItem monitoreditem, MonitoredItemNotificationEventArgs e) { VariableNode varNode = (VariableNode)monitoreditem.Subscription.Session.ReadNode(monitoreditem.StartNodeId); foreach (var value in monitoreditem.DequeueValues()) { Console.WriteLine("Got a value"); var typeManager = new DataTypeManager(monitoreditem.Subscription.Session); UaValue opcvalue = typeManager.GetUaValue(varNode, value, false); dynamic monitorInfoPair; lock (_monitorPublishInfo) { monitorInfoPair = _monitorPublishInfo .SelectMany(pair => pair.Value, (parent, child) => new { ServerUrl = parent.Key, Info = child }) .First(couple => couple.Info.Subscription == monitoreditem.Subscription); } var message = $"[TOPIC: {monitorInfoPair.Info.Topic}] \t ({monitoreditem.DisplayName}): {opcvalue.Value}"; monitorInfoPair.Info.Forward(message); Console.WriteLine(message); } }