using System; using OpcLabs.EasyOpc.UA; using OpcLabs.BaseLib.Instrumentation; namespace SimpleCapture { class Program { static void Main(string[] args) { Program p = new Program(); p.Run(); } #region member functions void Run() { //Initialize OPC communication // Hook static events EasyUAClient.LogEntry += EasyUAClientOnLogEntry; // Instantiate the client object var client = new EasyUAClient(); try { //Quick OPC Client UAEndpointDescriptor endpointDescriptor = "opc.tcp://192.168.2.6"; UANodeDescriptor nodeDescriptorPhotoID = "ns=6;s=::Main:OPC_Photo_ID"; Console.WriteLine("Subscribing to OPC_Photo_ID..."); // The callback is a lambda expression the displays the value int nodeHandle = 0; nodeHandle = client.SubscribeDataChange(endpointDescriptor, nodeDescriptorPhotoID, 10, (sender, eventArgs) => { if (eventArgs.Succeeded) { Console.WriteLine("Value: {0}", eventArgs.AttributeData.Value); //photoName = eventArgs.AttributeData.Value.ToString(); } else { Console.WriteLine("*** Failure: {0}", eventArgs.ErrorMessage); } }); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } bool i = true; while (i) ; } //Event handler static void EasyUAClientOnLogEntry(object sender, LogEntryEventArgs logEntryEventArgs) { Console.WriteLine(logEntryEventArgs); } #endregion } }