public static void Subscribe_OPC_UA() { UAEndpointDescriptor endpointDescriptor = "opc.tcp://10.92.XXX.XXX:4861"; var client = new EasyUAClient(); client.DataChangeNotification += client_DataChangeNotification_Main1; Console.WriteLine("Subscribing..."); client.SubscribeMultipleMonitoredItems(new[] { new EasyUAMonitoredItemArguments(null, endpointDescriptor, "ns=3;s=DB98_HEIZUNG_ISTWERTE_DR_EING_SEK_WT1_HEIZ", 1000), new EasyUAMonitoredItemArguments(null, endpointDescriptor, "ns=3;s=DB98_HEIZUNG_ISTWERTE_TEMP_AUSG_SEK_WT1_HEIZ", 1000), new EasyUAMonitoredItemArguments(null, endpointDescriptor, "ns=3;s=DB98_HEIZUNG_ISTWERTE_TEMP_EING_SEK_WT1_HEIZ", 1000), new EasyUAMonitoredItemArguments(null, endpointDescriptor, "ns=3;s=DB99_KÜHLUNG_ISTWERTE_DR_EING_SEK_WT1_KUEHL", 1000), new EasyUAMonitoredItemArguments(null, endpointDescriptor, "ns=3;s=DB99_KÜHLUNG_ISTWERTE_TEMP_AUSG_SEK_WT1_KUEHL", 1000), new EasyUAMonitoredItemArguments(null, endpointDescriptor, "ns=3;s=DB99_KÜHLUNG_ISTWERTE_TEMP_EING_SEK_WT1_KUEHL", 1000), new EasyUAMonitoredItemArguments(null, endpointDescriptor, "ns=3;s=DB98_HEIZUNG_ISTWERTE_DR_EING_SEK_WT2_HEIZ", 1000), new EasyUAMonitoredItemArguments(null, endpointDescriptor, "ns=3;s=DB98_HEIZUNG_ISTWERTE_TEMP_AUSG_SEK_WT2_HEIZ", 1000) }); Console.WriteLine("Processing monitored item changed events for 10 seconds..."); System.Threading.Thread.Sleep(10 * 1000); Console.WriteLine("Unsubscribing..."); client.UnsubscribeAllMonitoredItems(); Console.WriteLine("Waiting for 5 seconds..."); System.Threading.Thread.Sleep(5 * 1000); Console.WriteLine("Finished."); } static void client_DataChangeNotification_Main1(object sender, EasyUADataChangeNotificationEventArgs e) { // Display value. if (e.Succeeded) { Console.WriteLine($"{e.Arguments.NodeDescriptor}: {e.AttributeData.Value}"); using (StreamWriter sw = File.AppendText(OPC_Log)) { sw.WriteLine("value" + " " + Convert.ToString(DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture))); } } else { Console.WriteLine($"{e.Arguments.NodeDescriptor} *** Failure: {e.ErrorMessageBrief}"); using (StreamWriter sw = File.AppendText(OPC_Log)) { sw.WriteLine("error" + " " + Convert.ToString(DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture))); } } }