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 = ClientDriverHelper.GetInstance().GetReadService();
                client.Connect(XCollection.CURRENT_MACHINE);
                Dictionary <string, DriverBase.Devices.Tag> tags = ClientDriverHelper.GetInstance().GetReadServiceWeb().GetCollection();

                foreach (KeyValuePair <string, DriverBase.Devices.Tag> item in tags)
                {
                }
            }
            catch (CommunicationException ex)
            {
                EventscadaException?.Invoke(GetType().Name, ex.Message);
            }
            InitializeComponent();
        }
Beispiel #2
0
        public void SetCreateChannel()
        {
            try
            {
                InstanceContext 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 = ClientDriverHelper.GetInstance().GetReadService(ic);
                client.Connect(XCollection.CURRENT_MACHINE);

                IsConnected = true;
            }
            catch (Exception ex)
            {
                EventscadaException?.Invoke(GetType().Name, ex.Message);
            }
        }
        public static void Write(string PLCAddressClick, dynamic Value)
        {
            try
            {
                lock (myLockRead)
                {
                    client = ClientDriverHelper.GetInstance().GetReadService();
                    if (client != null)
                    {
                        client.WriteTag(PLCAddressClick, Value);
                    }
                }

                Thread.Sleep(50);
            }
            catch (Exception ex)
            {
                EventscadaException?.Invoke("WCFChannelFactory", ex.Message);
            }
        }
        public void GetWCF()
        {
            InstanceContext 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 = ClientDriverHelper.GetInstance().GetReadService(ic);
            client.Connect(XCollection.CURRENT_MACHINE);
        }