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 void Start(DeviceConfiguration config) { if (!started) { stop = new ManualResetEvent(false); started = true; probeData = null; var requestsThread = new Thread(new ParameterizedThreadStart(Worker)); requestsThread.Start(config); } }
private void RunRequests(DeviceConfiguration config) { var ac = config.Agent; if (ac != null) { // Run a Probe request and get the returned data if (probeData == null) { probeData = GetProbe(ac); // Send the Probe data to other plugins SendProbeData(probeData, config); } if (probeData != null) { // Run a Current request and get the returned data currentData = GetCurrent(ac); if (currentData != null && currentData.Header != null) { // Send the Current data to other plugins SendCurrentData(currentData, config); //Run a Sample request and get the returned data var sampleData = GetSample(currentData.Header, ac, config); //Send the Sample data to other plugins if (sampleData != null) { SendSampleData(sampleData, config); } UpdateAgentData(currentData.Header.InstanceId, currentData.Header.LastSequence); } else { probeData = null; SendAvailability(false, ac.Heartbeat, config); } } else { SendAvailability(false, ac.Heartbeat, config); } } }
private void SendProbeData(MTConnect.Application.Components.ReturnData returnData, DeviceConfiguration config) { if (returnData != null && returnData.Header != null) { if (returnData.Header.InstanceId != agentInstanceId) { SendAgentReset(config); } agentInstanceId = returnData.Header.InstanceId; } var data = new EventData(this); data.Id = "MTCONNECT_PROBE"; data.Data01 = config; data.Data02 = returnData; SendData?.Invoke(data); }
private static List <string> GetDataItemIds(MTConnect.Application.Components.ReturnData returnData) { var result = new List <string>(); var dataItems = returnData.Devices[0].GetAllDataItems(); // Conditions ------------------------------------------------------------------------- foreach (var dataItem in dataItems.FindAll(x => x.Category == MTConnect.DataItemCategory.CONDITION)) { string name = dataItem.Id.ToUpper(); if (!result.Contains(name)) { result.Add(name); } } // ------------------------------------------------------------------------------------ // Events ----------------------------------------------------------------------------- foreach (var dataItem in dataItems.FindAll(x => x.Category == MTConnect.DataItemCategory.EVENT)) { string name = dataItem.Id.ToUpper(); if (!result.Contains(name)) { result.Add(name); } } // ------------------------------------------------------------------------------------ // Samples ---------------------------------------------------------------------------- foreach (var dataItem in dataItems.FindAll(x => x.Category == MTConnect.DataItemCategory.SAMPLE)) { string name = dataItem.Id.ToUpper(); if (!result.Contains(name)) { result.Add(name); } } // ------------------------------------------------------------------------------------ return(result); }
private void RunRequests(DeviceConfiguration config) { var ac = config.Agent; if (ac != null) { // Run a Probe request and get the returned data if (probeData == null) { probeData = GetProbe(ac); // Send the Probe data to other plugins SendProbeData(probeData, config); } if (probeData != null) { // Run a Current request and get the returned data currentData = GetCurrent(ac); if (currentData != null && currentData.Header != null) { // Send the Current data to other plugins SendCurrentData(currentData, config); //Run a Sample request and get the returned data var sampleData = GetSample(currentData.Header, ac, config); //Send the Sample data to other plugins if (sampleData != null) SendSampleData(sampleData, config); UpdateAgentData(currentData.Header.InstanceId, currentData.Header.LastSequence); } else { probeData = null; SendAvailability(false, ac.Heartbeat, config); } } else SendAvailability(false, ac.Heartbeat, config); } }