コード例 #1
0
        private void TestConnection()
        {
            var info = new TestConnectionInfo();

            info.Address = Address;
            int port = 0;

            if (int.TryParse(Port, out port))
            {
            }
            else
            {
                port = 80;
            }
            info.Port       = port;
            info.DeviceName = DeviceName;

            if (!string.IsNullOrEmpty(info.Address) && port > 0 && !string.IsNullOrEmpty(info.DeviceName))
            {
                ConnectionTestLoading    = true;
                ConnectionTestResult     = 0;
                ConnectionTestResultText = null;

                // Create Agent Url
                var protocol = "http://";
                var adr      = info.Address;
                if (adr.IndexOf(protocol) >= 0)
                {
                    adr = adr.Substring(protocol.Length);
                }
                else
                {
                    adr = protocol + adr;
                }
                var url = adr;
                if (port > 0 && port != 80)
                {
                    url += ":" + port;
                }

                // Send Probe Request
                var probe = new MTConnect.Clients.Probe(url, info.DeviceName);
                probe.Successful      += Probe_Successful;
                probe.Error           += Probe_Error;
                probe.ConnectionError += Probe_ConnectionError;
                probe.ExecuteAsync();
            }
            else
            {
                ConnectionTestResult     = -1;
                ConnectionTestResultText = "Incorrect Information. Be sure to enter in the IP Address, Port, and Device Name and Try Again.";
            }
        }
コード例 #2
0
        private void TestConnection()
        {
            var info = new TestConnectionInfo();

            info.Address = Address;
            int port = 0;

            if (int.TryParse(Port, out port))
            {
            }
            else
            {
                port = 80;
            }
            info.Port       = port;
            info.DeviceName = DeviceName;

            if (!string.IsNullOrEmpty(info.Address) && port > 0 && !string.IsNullOrEmpty(info.DeviceName))
            {
                ConnectionTestLoading    = true;
                ConnectionTestResult     = 0;
                ConnectionTestResultText = null;

                if (testConnectionThread != null)
                {
                    testConnectionThread.Abort();
                }

                testConnectionThread = new Thread(new ParameterizedThreadStart(TestConnection_Worker));
                testConnectionThread.Start(info);
            }
            else
            {
                ConnectionTestResult     = -1;
                ConnectionTestResultText = "Incorrect Information. Be sure to enter in the IP Address, Port, and Device Name and Try Again.";
            }
        }
コード例 #3
0
        private void TestConnection()
        {
            var info = new TestConnectionInfo();
            info.Address = Address;
            int port = 0;
            if (int.TryParse(Port, out port)) { }
            else port = 80;
            info.Port = port;
            info.DeviceName = DeviceName;

            if (!string.IsNullOrEmpty(info.Address) && port > 0 && !string.IsNullOrEmpty(info.DeviceName))
            {
                ConnectionTestLoading = true;
                ConnectionTestResult = 0;
                ConnectionTestResultText = null;

                if (testConnectionThread != null) testConnectionThread.Abort();

                testConnectionThread = new Thread(new ParameterizedThreadStart(TestConnection_Worker));
                testConnectionThread.Start(info);
            }
            else
            {
                ConnectionTestResult = -1;
                ConnectionTestResultText = "Incorrect Information. Be sure to enter in the IP Address, Port, and Device Name and Try Again.";
            }
        }