public void SetCreateChannel() { try { var ic = new InstanceContext(this); XCollection.CURRENT_MACHINE = new Machine { MachineName = Environment.MachineName, Description = "Free" }; IPAddress[] hostAddresses = Dns.GetHostAddresses(Dns.GetHostName()); foreach (IPAddress iPAddress in hostAddresses) { if (iPAddress.AddressFamily == AddressFamily.InterNetwork) { XCollection.CURRENT_MACHINE.IPAddress = $"{iPAddress}"; break; } } client = DriverHelper.GetInstance().GetReadService(ic); client.Connect(XCollection.CURRENT_MACHINE); IsConnected = true; } catch (Exception ex) { EventscadaException?.Invoke(this.GetType().Name, ex.Message); } }
public MainForm() { try { ReadServiceCallbackClient.LoadTagCollection(); XCollection.CURRENT_MACHINE = new Machine { MachineName = Environment.MachineName, Description = "Free" }; IPAddress[] hostAddresses = Dns.GetHostAddresses(Dns.GetHostName()); foreach (IPAddress iPAddress in hostAddresses) { if (iPAddress.AddressFamily == AddressFamily.InterNetwork) { XCollection.CURRENT_MACHINE.IPAddress = $"{iPAddress}"; break; } } client = DriverHelper.GetInstance().GetReadService(); client.Connect(XCollection.CURRENT_MACHINE); } catch (CommunicationException ex) { EventscadaException?.Invoke(this.GetType().Name, ex.Message); } InitializeComponent(); }
public static void Write(string PLCAddressClick, dynamic Value) { try { lock (myLockRead) { client = DriverHelper.GetInstance().GetReadService(); if (client != null) { client.WriteTag(PLCAddressClick, Value); } } Thread.Sleep(50); } catch (Exception ex) { EventscadaException?.Invoke("WCFChannelFactory", ex.Message); } }
public void GetWCF() { var ic = new InstanceContext(this); XCollection.CURRENT_MACHINE = new Machine { MachineName = Environment.MachineName, Description = "Free" }; IPAddress[] hostAddresses = Dns.GetHostAddresses(Dns.GetHostName()); foreach (IPAddress iPAddress in hostAddresses) { if (iPAddress.AddressFamily == AddressFamily.InterNetwork) { XCollection.CURRENT_MACHINE.IPAddress = $"{iPAddress}"; break; } } client = DriverHelper.GetInstance().GetReadService(ic); client.Connect(XCollection.CURRENT_MACHINE); }