private MTConnect.Application.Components.ReturnData GetProbe(Data.AgentInfo config) { MTConnect.Application.Components.ReturnData result = null; string address = config.Address; int port = config.Port; string deviceName = config.DeviceName; // Set Proxy Settings var proxy = new HTTP.ProxySettings(); proxy.Address = config.ProxyAddress; proxy.Port = config.ProxyPort; DateTime requestTimestamp = DateTime.Now; string url = HTTP.GetUrl(address, port, deviceName) + "probe"; result = MTConnect.Application.Components.Requests.Get(url, proxy, 2000, 1); if (result != null) { if (verbose) Logger.Log("Probe Successful : " + url + " @ " + requestTimestamp.ToString("o"), LogLineType.Console); } else { Logger.Log("Probe Error : " + url + " @ " + requestTimestamp.ToString("o") + " : Retrying in " + (config.Heartbeat / 1000) + " sec.."); } return result; }
private MTConnect.Application.Streams.ReturnData GetCurrent(Data.AgentInfo config) { MTConnect.Application.Streams.ReturnData result = null; string address = config.Address; int port = config.Port; string deviceName = config.DeviceName; // Set Proxy Settings var proxy = new HTTP.ProxySettings(); proxy.Address = config.ProxyAddress; proxy.Port = config.ProxyPort; DateTime requestTimestamp = DateTime.Now; string url = HTTP.GetUrl(address, port, deviceName) + "current"; result = MTConnect.Application.Streams.Requests.Get(url, proxy, 2000, 1); if (result != null) { if (verbose) { Logger.Log("Current Successful : " + url + " @ " + requestTimestamp.ToString("o") + " : " + result.Header.LastSequence, LogLineType.Console); } } else { Logger.Log("Current Error : " + url + " @ " + requestTimestamp.ToString("o") + " : Retrying in " + (config.Heartbeat / 1000) + " sec.."); } return(result); }
private MTConnect.Application.Streams.ReturnData GetSample(Streams header, Data.AgentInfo ac, DeviceConfiguration config) { MTConnect.Application.Streams.ReturnData result = null; string address = ac.Address; int port = ac.Port; string deviceName = ac.DeviceName; // Set Proxy Settings var proxy = new HTTP.ProxySettings(); proxy.Address = ac.ProxyAddress; proxy.Port = ac.ProxyPort; SampleInfo info = GetSampleInfo(header, config); if (info != null) { if (info.Count > 0) { DateTime requestTimestamp = DateTime.Now; string url = HTTP.GetUrl(address, port, deviceName) + "sample?from=" + info.From.ToString() + "&count=" + info.Count.ToString(); result = MTConnect.Application.Streams.Requests.Get(url, proxy, ac.Heartbeat / 2, 2); if (result != null) { UpdateAgentData(header.InstanceId, info.From + info.Count); if (verbose) { Logger.Log("Sample Successful : " + url + " @ " + requestTimestamp.ToString("o"), LogLineType.Console); } } else { Logger.Log("Sample Error : " + url + " @ " + requestTimestamp.ToString("o")); } } else { UpdateAgentData(header.InstanceId, header.LastSequence); } } return(result); }
private MTConnect.Application.Streams.ReturnData GetSample(Streams header, Data.AgentInfo ac, DeviceConfiguration config) { MTConnect.Application.Streams.ReturnData result = null; string address = ac.Address; int port = ac.Port; string deviceName = ac.DeviceName; // Set Proxy Settings var proxy = new HTTP.ProxySettings(); proxy.Address = ac.ProxyAddress; proxy.Port = ac.ProxyPort; SampleInfo info = GetSampleInfo(header, config); if (info != null) { if (info.Count > 0) { DateTime requestTimestamp = DateTime.Now; string url = HTTP.GetUrl(address, port, deviceName) + "sample?from=" + info.From.ToString() + "&count=" + info.Count.ToString(); result = MTConnect.Application.Streams.Requests.Get(url, proxy, ac.Heartbeat / 2, 2); if (result != null) { UpdateAgentData(header.InstanceId, info.From + info.Count); if (verbose) Logger.Log("Sample Successful : " + url + " @ " + requestTimestamp.ToString("o"), LogLineType.Console); } else { Logger.Log("Sample Error : " + url + " @ " + requestTimestamp.ToString("o")); } } else UpdateAgentData(header.InstanceId, header.LastSequence); } return result; }