private void Sniffer_DeviceFound(TrakHound.MTConnectSniffer.MTConnectDevice device) { if (device != null && device.IpAddress != null && !string.IsNullOrEmpty(device.DeviceName)) { // Create Agent Url var protocol = "http://"; var adr = device.IpAddress.ToString(); if (adr.IndexOf(protocol) >= 0) { adr = adr.Substring(protocol.Length); } else { adr = protocol + adr; } var url = adr; if (device.Port > 0 && device.Port != 80) { url += ":" + device.Port; } // Run Probe Request var probe = new MTConnect.Clients.Probe(url, device.DeviceName); probe.Successful += Probe_Successful; probe.UserObject = device; probe.ExecuteAsync(); } }
//class Probe_Info //{ // public string address; // public int port; // public string deviceName; // //public MTConnect.HTTP.ProxySettings proxy; //} void RunProbe(string address, int port, string deviceName) { // Create Agent Url var protocol = "http://"; var adr = 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; } // Run Probe Request var probe = new MTConnect.Clients.Probe(url, deviceName); probe.Successful += Probe_Successful; probe.ExecuteAsync(); }
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."; } }
private void SendProbe(IPAddress address, int port) { var uri = new UriBuilder("http", address.ToString(), port); var probe = new MTConnect.Clients.Probe(uri.ToString()); probe.UserObject = new ProbeSender(address, port); probe.Successful += Probe_Successful; probe.Error += Probe_Error; probe.ConnectionError += Probe_ConnectionError; sentProbeRequests++; probe.ExecuteAsync(); }