diff --git a/MTConnect.NET.sln b/MTConnect.NET.sln index a11214e4..31da1c2e 100644 --- a/MTConnect.NET.sln +++ b/MTConnect.NET.sln @@ -30,8 +30,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Adapter", "Adapter", "{5C17 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Modules", "Modules", "{494ACCF3-8FB7-429D-9119-92F7DD646B5F}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Clients", "Clients", "{B7D0BB51-FC51-4CB8-B612-2AED2A2233C1}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{B7CCD58C-A3F3-43BE-BBF8-2B20D118C39D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MTConnect.NET-Common", "libraries\MTConnect.NET-Common\MTConnect.NET-Common.csproj", "{5AF3BDBE-AE71-42A8-B05F-034220EC0F6D}" @@ -90,7 +88,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MTConnect.NET-AdapterModule EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MTConnect.NET-AdapterModule-SHDR", "adapter\Modules\MTConnect.NET-AdapterModule-SHDR\MTConnect.NET-AdapterModule-SHDR.csproj", "{D2125645-0149-4D2D-BBF6-5E36E6EBB6C1}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MTConnect.NET-Protobuf", "libraries\MTConnect.NET-Protobuf\MTConnect.NET-Protobuf.csproj", "{B4A1AFBE-5D57-45BA-B735-A2C2C20A971C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MTConnect.NET-Protobuf", "libraries\MTConnect.NET-Protobuf\MTConnect.NET-Protobuf.csproj", "{B4A1AFBE-5D57-45BA-B735-A2C2C20A971C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MTConnect.NET-AgentModule-MqttAdapter", "agent\Modules\MTConnect.NET-AgentModule-MqttAdapter\MTConnect.NET-AgentModule-MqttAdapter.csproj", "{ACD5D3A4-0474-4E24-BF18-1F699CDB101F}" EndProject diff --git a/applications/Adapters/MTConnect-Adapter-Shdr/AdapterApplication.cs b/applications/Adapters/MTConnect-Adapter-Shdr/AdapterApplication.cs deleted file mode 100644 index 8b92916b..00000000 --- a/applications/Adapters/MTConnect-Adapter-Shdr/AdapterApplication.cs +++ /dev/null @@ -1,57 +0,0 @@ -using MTConnect.Adapters.Shdr; -using MTConnect.Applications.Adapters; -using MTConnect.Configurations; - -namespace MTConnect.Applications -{ - // This is an implementation of the MTConnectShdrAdapterApplication using the custom configuration file type - - internal class AdapterApplication : MTConnectShdrAdapterApplication - { - private AdapterConfiguration _configuration; - - - public AdapterConfiguration Configuration => _configuration; - - - public AdapterApplication(MTConnectShdrAdapterEngine engine) : base(engine) - { - ConfigurationType = typeof(AdapterConfiguration); - } - - - protected override void OnStartAdapter() - { - // Start Engine - if (Engine != null) - { - Engine.Configuration = Configuration; - - Engine.Start(); - } - } - - protected override void OnStopAdapter() - { - // Stop Engine - if (Engine != null) Engine.Stop(); - } - - - protected override IShdrAdapterApplicationConfiguration OnConfigurationFileRead(string configurationPath) - { - _configuration = ShdrAdapterApplicationConfiguration.Read(configurationPath); - return _configuration; - } - - protected override void OnAdapterConfigurationUpdated(ShdrAdapterApplicationConfiguration configuration) - { - _configuration = configuration as AdapterConfiguration; - } - - protected override void OnAdapterConfigurationWatcherInitialize(IShdrAdapterApplicationConfiguration configuration) - { - _adapterConfigurationWatcher = new AdapterConfigurationFileWatcher(configuration.Path, configuration.ConfigurationFileRestartInterval * 1000); - } - } -} diff --git a/applications/Adapters/MTConnect-Adapter-Shdr/AdapterConfiguration.cs b/applications/Adapters/MTConnect-Adapter-Shdr/AdapterConfiguration.cs deleted file mode 100644 index 64146154..00000000 --- a/applications/Adapters/MTConnect-Adapter-Shdr/AdapterConfiguration.cs +++ /dev/null @@ -1,16 +0,0 @@ -using MTConnect.Configurations; - -namespace MTConnect.Applications -{ - // This is a custom Configuration file for your own Adapter. - // Simply add Properties and they will be Serialized/Deserialized in the configuration file - - // Example properties could include Address for PLC connection, Variables, Labels, etc. - - public class AdapterConfiguration : ShdrAdapterApplicationConfiguration - { - public string PlcAddress { get; set; } - - public int PlcPort { get; set; } - } -} diff --git a/applications/Adapters/MTConnect-Adapter-Shdr/AdapterEngine.cs b/applications/Adapters/MTConnect-Adapter-Shdr/AdapterEngine.cs deleted file mode 100644 index 3f93b47c..00000000 --- a/applications/Adapters/MTConnect-Adapter-Shdr/AdapterEngine.cs +++ /dev/null @@ -1,77 +0,0 @@ -using MTConnect.Adapters.Shdr; -using MTConnect.Assets.CuttingTools; -using MTConnect.NET_Adapter_SHDR.Simulator; -using MTConnect.Observations.Events.Values; -using NLog; -using System; - -namespace MTConnect.Applications -{ - // This class is used for reading from your DataSource (ex. PLC) and writing to the "Adapter" object that is included in the base class - - // OnRead() : Gets called at the specfied Interval in the Configuration and would be where you can scan the PLC variables that you want to write to the MTConnect Agent - - // OnReadAsync() : Same as OnRead() but is an async method - - - internal class AdapterEngine : MTConnectShdrAdapterEngine - { - protected readonly Logger _engineLogger = LogManager.GetLogger("engine-logger"); - private PlcSimulator _dataSource; - private CuttingToolAsset asset = Examples.CuttingTool(); - - - protected override void OnStart() - { - _engineLogger.Info($"Connected to PLC @ {Configuration.PlcAddress} : Port = {Configuration.PlcPort}"); - - _dataSource = new PlcSimulator(Configuration.PlcAddress, Configuration.PlcPort, 10); - _dataSource.Connect(); - } - - protected override void OnStop() - { - Adapter.SetUnavailable(); - - _dataSource.Disconnect(); - - _engineLogger.Info($"Disconnected from PLC @ {Configuration.PlcAddress} : Port = {Configuration.PlcPort}"); - } - - protected override void OnRead() - { - // Using a single Timestamp (per OnRead() call) can consolidate the SHDR output as well as make MTConnect data more "aligned" and easier to process - var ts = UnixDateTime.Now; - - Adapter.AddDataItem("avail", _dataSource.Connected ? Availability.AVAILABLE : Availability.UNAVAILABLE, ts); - - Adapter.AddDataItem("estop", _dataSource.EmergencyStop ? EmergencyStop.ARMED : EmergencyStop.TRIGGERED, ts); - - switch (_dataSource.Mode) - { - case 0: Adapter.AddDataItem("mode", ControllerMode.MANUAL, ts); break; - case 1: Adapter.AddDataItem("mode", ControllerMode.SEMI_AUTOMATIC, ts); break; - case 2: Adapter.AddDataItem("mode", ControllerMode.AUTOMATIC, ts); break; - case 3: Adapter.AddDataItem("mode", ControllerMode.EDIT, ts); break; - } - - Adapter.AddDataItem("program", _dataSource.ProcessDatas[0].Program, ts); - Adapter.AddDataItem("tool", _dataSource.ProcessDatas[0].ToolNumber, ts); - Adapter.AddDataItem("tool_offset", _dataSource.ProcessDatas[0].ToolOffset, ts); - - for (var i = 0; i < _dataSource.AxisDatas.Length; i++) - { - var axis = _dataSource.AxisDatas[i]; - Adapter.AddDataItem($"axis_{i}_pos", axis.MachinePosition, ts); - } - - asset.CuttingToolLifeCycle.ToolLife.Value++; - foreach (var asset in _dataSource.ToolAssets) - { - Adapter.AddAsset(asset); - } - - // The Adapter (ShdrAdapter) handles sending the data to the MTConnect Agent using the SHDR Protocol - } - } -} diff --git a/applications/Adapters/MTConnect-Adapter-Shdr/Examples/CuttingToolAsset.cs b/applications/Adapters/MTConnect-Adapter-Shdr/Examples/CuttingToolAsset.cs deleted file mode 100644 index 85822e7f..00000000 --- a/applications/Adapters/MTConnect-Adapter-Shdr/Examples/CuttingToolAsset.cs +++ /dev/null @@ -1,40 +0,0 @@ -using MTConnect.Assets.CuttingTools; -using MTConnect.Assets.CuttingTools.Measurements; - -namespace MTConnect.Applications -{ - internal static partial class Examples - { - public static CuttingToolAsset CuttingTool() - { - var tool = new CuttingToolAsset(); - tool.SerialNumber = "12345678946"; - tool.AssetId = "5.12"; - tool.ToolId = "12"; - tool.CuttingToolLifeCycle = new CuttingToolLifeCycle - { - Location = new Location - { - Type = LocationType.SPINDLE - }, - ProgramToolNumber = "12", - ProgramToolGroup = "5" - }; - tool.CuttingToolLifeCycle.Measurements.Add(new FunctionalLengthMeasurement(7.6543)); - tool.CuttingToolLifeCycle.Measurements.Add(new CuttingDiameterMaxMeasurement(0.375)); - tool.CuttingToolLifeCycle.CuttingItems.Add(new CuttingItem - { - ItemId = "12.1", - Indices = "1", - Locus = CuttingItemLocas.FLUTE.ToString() - }); - tool.CuttingToolLifeCycle.CutterStatus.Add(CutterStatus.AVAILABLE); - tool.CuttingToolLifeCycle.CutterStatus.Add(CutterStatus.NEW); - tool.CuttingToolLifeCycle.CutterStatus.Add(CutterStatus.MEASURED); - tool.CuttingToolLifeCycle.ToolLife = new ToolLife(); - tool.Timestamp = UnixDateTime.Now; - - return tool; - } - } -} diff --git a/applications/Adapters/MTConnect-Adapter-Shdr/Examples/FileAsset.cs b/applications/Adapters/MTConnect-Adapter-Shdr/Examples/FileAsset.cs deleted file mode 100644 index 041c869f..00000000 --- a/applications/Adapters/MTConnect-Adapter-Shdr/Examples/FileAsset.cs +++ /dev/null @@ -1,18 +0,0 @@ -using MTConnect.Assets.Files; - -namespace MTConnect.Applications -{ - internal static partial class Examples - { - public static FileAsset FileAsset() - { - var programFile = new FileAsset(); - programFile.AssetId = "114905-105-30"; - programFile.Timestamp = UnixDateTime.Now; - programFile.Size = 1234514; - programFile.FileLocation = new FileLocation(@"\\server\114905-105-30.NC"); - - return programFile; - } - } -} diff --git a/applications/Adapters/MTConnect-Adapter-Shdr/Examples/RawMaterialAsset.cs b/applications/Adapters/MTConnect-Adapter-Shdr/Examples/RawMaterialAsset.cs deleted file mode 100644 index 3a4c3e50..00000000 --- a/applications/Adapters/MTConnect-Adapter-Shdr/Examples/RawMaterialAsset.cs +++ /dev/null @@ -1,25 +0,0 @@ -using MTConnect.Assets.RawMaterials; - -namespace MTConnect.Applications -{ - internal static partial class Examples - { - public static RawMaterialAsset RawMaterialAsset() - { - var rawMaterial = new RawMaterialAsset(); - rawMaterial.AssetId = "789456-A2"; - rawMaterial.Timestamp = UnixDateTime.Now; - rawMaterial.Name = "6061 Aluminum"; - rawMaterial.SerialNumber = "789456-A2"; - rawMaterial.Material = new Material - { - Id = "m-al-123456", - Name = "6061 Aluminum", - Lot = "B-45", - Type = "Aluminum" - }; - - return rawMaterial; - } - } -} diff --git a/applications/Adapters/MTConnect-Adapter-Shdr/Examples/ToolTable.cs b/applications/Adapters/MTConnect-Adapter-Shdr/Examples/ToolTable.cs deleted file mode 100644 index 9175a8d4..00000000 --- a/applications/Adapters/MTConnect-Adapter-Shdr/Examples/ToolTable.cs +++ /dev/null @@ -1,37 +0,0 @@ -using MTConnect.Observations; -using MTConnect.Shdr; -using System.Collections.Generic; - -namespace MTConnect.Applications -{ - internal static partial class Examples - { - public static ShdrTable ToolTable() - { - var tableEntries = new List(); - - // Tool 1 - var t1Cells = new List(); - t1Cells.Add(new TableCell("LENGTH", 7.123)); - t1Cells.Add(new TableCell("DIAMETER", 0.494)); - t1Cells.Add(new TableCell("TOOL_LIFE", 0.35)); - tableEntries.Add(new TableEntry("T1", t1Cells)); - - // Tool 2 - var t2Cells = new List(); - t2Cells.Add(new TableCell("LENGTH", 10.456)); - t2Cells.Add(new TableCell("DIAMETER", 0.125)); - t2Cells.Add(new TableCell("TOOL_LIFE", 1)); - tableEntries.Add(new TableEntry("T2", t2Cells)); - - // Tool 3 - var t3Cells = new List(); - t3Cells.Add(new TableCell("LENGTH", 6.251)); - t3Cells.Add(new TableCell("DIAMETER", 1.249)); - t3Cells.Add(new TableCell("TOOL_LIFE", 0.93)); - tableEntries.Add(new TableEntry("T3", t3Cells)); - - return new ShdrTable("L2p1ToolTable", tableEntries); - } - } -} diff --git a/applications/Adapters/MTConnect-Adapter-Shdr/Examples/VariablesDataSet.cs b/applications/Adapters/MTConnect-Adapter-Shdr/Examples/VariablesDataSet.cs deleted file mode 100644 index b36cec30..00000000 --- a/applications/Adapters/MTConnect-Adapter-Shdr/Examples/VariablesDataSet.cs +++ /dev/null @@ -1,20 +0,0 @@ -using MTConnect.Observations; -using MTConnect.Shdr; -using System.Collections.Generic; - -namespace MTConnect.Applications -{ - internal static partial class Examples - { - public static ShdrDataSet VariablesDataSet() - { - var dataSetEntries = new List(); - dataSetEntries.Add(new DataSetEntry("V1", 5)); - dataSetEntries.Add(new DataSetEntry("V2", 205)); - dataSetEntries.Add(new DataSetEntry("V3", "DUMMY")); - dataSetEntries.Add(new DataSetEntry("V4", 147.1234)); - - return new ShdrDataSet("vars", dataSetEntries); - } - } -} diff --git a/applications/Adapters/MTConnect-Adapter-Shdr/Examples/WorkOffsetTable.cs b/applications/Adapters/MTConnect-Adapter-Shdr/Examples/WorkOffsetTable.cs deleted file mode 100644 index ed242a59..00000000 --- a/applications/Adapters/MTConnect-Adapter-Shdr/Examples/WorkOffsetTable.cs +++ /dev/null @@ -1,37 +0,0 @@ -using MTConnect.Observations; -using MTConnect.Shdr; -using System.Collections.Generic; - -namespace MTConnect.Applications -{ - internal static partial class Examples - { - public static ShdrTable WorkOffsetTable() - { - var tableEntries = new List(); - - // G54 - var g54Cells = new List(); - g54Cells.Add(new TableCell("X", 7.123)); - g54Cells.Add(new TableCell("Y", 0.494)); - g54Cells.Add(new TableCell("Z", 0.35)); - tableEntries.Add(new TableEntry("G54", g54Cells)); - - // G55 - var g55Cells = new List(); - g55Cells.Add(new TableCell("X", 7.123)); - g55Cells.Add(new TableCell("Y", 0.494)); - g55Cells.Add(new TableCell("Z", 0.35)); - tableEntries.Add(new TableEntry("G55", g55Cells)); - - // G56 - var g56Cells = new List(); - g56Cells.Add(new TableCell("X", 7.123)); - g56Cells.Add(new TableCell("Y", 0.494)); - g56Cells.Add(new TableCell("Z", 0.35)); - tableEntries.Add(new TableEntry("G56", g56Cells)); - - return new ShdrTable("workOffsetTable", tableEntries); - } - } -} diff --git a/applications/Adapters/MTConnect-Adapter-Shdr/MTConnect-Adapter-SHDR.csproj b/applications/Adapters/MTConnect-Adapter-Shdr/MTConnect-Adapter-SHDR.csproj deleted file mode 100644 index 90215730..00000000 --- a/applications/Adapters/MTConnect-Adapter-Shdr/MTConnect-Adapter-SHDR.csproj +++ /dev/null @@ -1,51 +0,0 @@ - - - - net6.0 - full - - - net461;net48;net6.0;net7.0 - false - None - true - - - net461;net462;net47;net471;net472;net48;netstandard2.0;netcoreapp3.1;net5.0;net6.0 - - - - Debug;Release;Docker - false - adapter - Exe - MTConnect - MTConnect.Applications.Program - disable - - - - - - - - - - - - - - - - - - - Always - - - \ - True - - - - diff --git a/applications/Adapters/MTConnect-Adapter-Shdr/Program.cs b/applications/Adapters/MTConnect-Adapter-Shdr/Program.cs deleted file mode 100644 index f019084f..00000000 --- a/applications/Adapters/MTConnect-Adapter-Shdr/Program.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Reflection; - -namespace MTConnect.Applications -{ - public class Program - { - // This is the Application Name shown in the Console header information - // If you are implementing this into your own application, you can change this to be more specific (ex. Fanuc MTConnect Adapter, Mazak MTConnect Adapter, etc.) - private const string ApplicationName = "MTConnect SDHR Adapter"; - - // Copyright statement for the application. If you are implementing this into your own application, you can change this to your own copyright, or set it to 'null'. - // This is just what is shown in the console header. - private const string ApplicationCopyright = "Copyright 2023"; - - public static void Main(string[] args) - { - // Print an application header to the console - PrintConsoleHeader(); - - var engine = new AdapterEngine(); - - // Create a new MTConnect Adapter Application - var app = new AdapterApplication(engine); - - // Run the Agent ('true' parameter blocks the call so the application does not continue) - app.Run(args, true); - } - - - private static void PrintConsoleHeader() - { - var assembly = Assembly.GetExecutingAssembly(); - var version = assembly.GetName().Version; - - Console.WriteLine("--------------------"); - if (!string.IsNullOrEmpty(ApplicationCopyright)) Console.WriteLine(ApplicationCopyright); - Console.WriteLine(ApplicationName + " : Version " + version.ToString()); - Console.WriteLine("--------------------"); - Console.WriteLine("This application is licensed under the MIT License (https://choosealicense.com/licenses/mit/)"); - Console.WriteLine("Source code available at Github.com (https://github.com/TrakHound/MTConnect.NET)"); - Console.WriteLine("--------------------"); - } - } -} diff --git a/applications/Adapters/MTConnect-Adapter-Shdr/Properties/launchSettings.json b/applications/Adapters/MTConnect-Adapter-Shdr/Properties/launchSettings.json deleted file mode 100644 index 023b91b8..00000000 --- a/applications/Adapters/MTConnect-Adapter-Shdr/Properties/launchSettings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "profiles": { - "MTConnect-Adapter-SHDR": { - "commandName": "Project", - "commandLineArgs": "debug" - } - } -} \ No newline at end of file diff --git a/applications/Adapters/MTConnect-Adapter-Shdr/README.md b/applications/Adapters/MTConnect-Adapter-Shdr/README.md deleted file mode 100644 index 9f81df05..00000000 --- a/applications/Adapters/MTConnect-Adapter-Shdr/README.md +++ /dev/null @@ -1,204 +0,0 @@ -![MTConnect.NET Logo](https://raw.githubusercontent.com/TrakHound/MTConnect.NET/dev/img/mtconnect-net-03-md.png) - -# MTConnect SHDR Adapter - -[![MTConnect.NET](https://github.com/TrakHound/MTConnect.NET/actions/workflows/dotnet.yml/badge.svg)](https://github.com/TrakHound/MTConnect.NET/actions/workflows/dotnet.yml) - -## Overview -This project is a full implementation of an MTConnect SHDR Adapter used to send data from a PLC (or other Data Source) to an MTConnect Agent. -This project is designed to be used by a developer to serve as a "shell" application for an Adapter solution. -Contained in this project is the functionality to: -- Send data using the SHDR Protocol -- Run / Install / Remove as a Windows Service -- Read and detect changes to a customizable configuration file -- Tools to build as a Windows Installer exe - -## Develop -To develop an Adapter using this project, edit the [AdapterEngine.cs](https://github.com/TrakHound/MTConnect.NET/tree/master/applications/Adapters/MTConnect-Adapter-Shdr/AdapterEngine.cs) file so that it follows the pattern below: - -```c# -class AdapterEngine : MTConnectShdrAdapterEngine -{ - protected readonly Logger _engineLogger = LogManager.GetLogger("engine-logger"); - private PlcSimulator _dataSource; - - - protected override void OnStart() - { - _engineLogger.Info($"Connected to PLC @ {Configuration.PlcAddress} : Port = {Configuration.PlcPort}"); - - _dataSource = new PlcSimulator(Configuration.PlcAddress, Configuration.PlcPort, 50); - _dataSource.Connect(); - } - - protected override void OnStop() - { - Adapter.SetUnavailable(); - - _dataSource.Disconnect(); - - _engineLogger.Info($"Disconnected from PLC @ {Configuration.PlcAddress} : Port = {Configuration.PlcPort}"); - } - - protected override void OnRead() - { - // Using a single Timestamp (per OnRead() call) can consolidate the SHDR output as well as make MTConnect data more "aligned" and easier to process - var ts = UnixDateTime.Now; - - Adapter.AddDataItem("avail", _dataSource.Connected ? Availability.AVAILABLE : Availability.UNAVAILABLE, ts); - - Adapter.AddDataItem("estop", _dataSource.EmergencyStop ? EmergencyStop.ARMED : EmergencyStop.TRIGGERED, ts); - - switch (_dataSource.Mode) - { - case 0: Adapter.AddDataItem("mode", ControllerMode.MANUAL, ts); break; - case 1: Adapter.AddDataItem("mode", ControllerMode.SEMI_AUTOMATIC, ts); break; - case 2: Adapter.AddDataItem("mode", ControllerMode.AUTOMATIC, ts); break; - case 3: Adapter.AddDataItem("mode", ControllerMode.EDIT, ts); break; - } - - Adapter.AddDataItem("program", _dataSource.ProcessDatas[0].Program, ts); - Adapter.AddDataItem("tool", _dataSource.ProcessDatas[0].ToolNumber, ts); - Adapter.AddDataItem("tool_offset", _dataSource.ProcessDatas[0].ToolOffset, ts); - - for (var i = 0; i < _dataSource.AxisDatas.Length; i++) - { - var axis = _dataSource.AxisDatas[i]; - Adapter.AddDataItem($"axis_{i}_pos", axis.MachinePosition, ts); - } - - Adapter.AddAsset(Examples.CuttingTool()); - - - // The Adapter (ShdrAdapter) handles sending the data to the MTConnect Agent using the SHDR Protocol - } -``` - -### OnStart() -The OnStart() method is used to contain code to allow a developer to call a method to connect to the PLC or data source. - -### OnStop() -The OnStop() method is used to contain code to allow a developer to call a method to disconnect from the PLC or data source. - -### OnRead() -The OnRead() method is used to contain code to allow a developer to add data to the underlying **Adapter** property. -The OnRead() method runs at the **Interval** specified in the configuration file. -This method is run on a separate worker thread than the underlying ShdrAdapter. The thread is exited when the AdapterEngine is stopped. - -### OnReadAsync() -The OnReadAsync() method has the same functionality of OnRead() but runs as an Async method. - -## Usage -The Adapter can be run from a command line prompt or as a Windows Service using the format below: -``` -adapter [help|install|install-start|start|stop|remove|debug|run|run-service] [configuration_file] [tcp_port] - --------------------- - -Options : - - help | Prints usage information - install | Install as a Service - install-start | Install as a Service and Start the Service - start | Start the Service - stop | Stop the Service - remove | Remove the Service - debug | Runs the Adapter in the terminal (with verbose logging) - run | Runs the Adapter in the terminal - run-service | Runs the Adapter as a Service - -Arguments : --------------------- - - configuration_file | Specifies the Adapter Configuration file to load - Default : agent.config.json - - tcp_port | Specifies the TCP Port to use for the SHDR communication - Note : This overrides what is read from the Configuration file -``` -#### Example 1: -Install the Adapter as a Windows Service (Note: requires Administrator Privileges) - > adapter install - -#### Example 2: -Install the Adapter as a Windows Service using the configuration file "adapter-config.yaml" and Starts the service (Note: requires Administrator Privileges) -> adapter install-start agent-config.json - -#### Example 3: -Starts the Windows Service (Note: requires Administrator Privileges) -> adapter start - -#### Example 4: -Runs the Adapter in the command line prompt using verbose logging and overrides the TCP Port to 7579 -> adapter debug "" 7579 - -## Configuration -More information about [Configurations](https://github.com/TrakHound/MTConnect.NET/tree/master/src/MTConnect.NET-Common/Configurations). The default configuration file is shown below : -```yaml -id: CustomAdapter -deviceKey: OKUMA-Lathe -heartbeat: 10000 -timeout: 5000 -readInterval: 50 -writeInterval: 100 -outputTimestamps: true -enableBuffer: false -filterDuplicates: true -plcAddress: pallet_pool # Customizable Property -plcPort: 7679 # Customizable Property -``` - - -## Logging -Logging is done using [NLog](https://github.com/NLog/NLog) which allows for customized logging through the NLog.config file located in the application's install directory. The loggers are setup so that there is a separate logger for: -- **(adapter-logger)** MTConnect Adapter - -The default [NLog Configuration File](https://github.com/TrakHound/MTConnect.NET/blob/master/src/MTConnect.NET-Applications-Adapter-SHDR/NLog.config) is shown below: - -```xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -``` - -## Releases -Releases for this application are located under the Releases tab. The current release is listed below: -- [MTConnect Agent Current Release](https://github.com/TrakHound/MTConnect.NET/releases) - -## Source Code -This project uses the MTConnect.NET-Applications-Adapters-SHDR library (available on [Nuget](https://www.nuget.org/packages/MTConnect.NET-Applications-Adapter-SHDR)) to create an MTConnect SHDR Adapter application. - -## Contribution / Feedback -- Please use the [Issues](https://github.com/TrakHound/MTConnect.NET/issues) tab to create issues for specific problems that you may encounter -- Please feel free to use the [Pull Requests](https://github.com/TrakHound/MTConnect.NET/pulls) tab for any suggested improvements to the source code -- For any other questions or feedback, please contact TrakHound directly at **info@trakhound.com**. - -## License -This application and it's source code is licensed under the [MIT License](https://choosealicense.com/licenses/mit/) and is free to use. diff --git a/applications/Adapters/MTConnect-Adapter-Shdr/Simulator/ControllerSimulator.cs b/applications/Adapters/MTConnect-Adapter-Shdr/Simulator/ControllerSimulator.cs deleted file mode 100644 index 2f8de105..00000000 --- a/applications/Adapters/MTConnect-Adapter-Shdr/Simulator/ControllerSimulator.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace MTConnect.Applications.Adapters.Shdr.Simulator -{ - public class ControllerSimulator - { - public bool EmergencyStop { get; set; } - - public string CommunicationsAlarm { get; set; } - - public string LogicAlarm { get; set; } - - public string SystemAlarm { get; set; } - - public string PalletId { get; set; } - } -} diff --git a/applications/Adapters/MTConnect-Adapter-Shdr/Simulator/DeviceSimulator.cs b/applications/Adapters/MTConnect-Adapter-Shdr/Simulator/DeviceSimulator.cs deleted file mode 100644 index 31026adc..00000000 --- a/applications/Adapters/MTConnect-Adapter-Shdr/Simulator/DeviceSimulator.cs +++ /dev/null @@ -1,182 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -namespace MTConnect.Applications.Adapters.Shdr.Simulator -{ - public class DeviceSimulator - { - private CancellationTokenSource cancellationTokenSource; - - private int variableState = 0; - - - public bool Connected { get; set; } - - public int UpdateInterval { get; set; } - - - public ControllerSimulator Controller { get; set; } - public PathSimulator Path { get; set; } - - public List LinearAxes { get; set; } - public List RotaryAxes { get; set; } - - - public DeviceSimulator(string deviceName, int updateInterval = 100) - { - UpdateInterval = updateInterval; - - Controller = new ControllerSimulator(); - Path = new PathSimulator(); - - LinearAxes = new List(); - LinearAxes.Add(new LinearAxisSimulator("X")); - LinearAxes.Add(new LinearAxisSimulator("Y")); - LinearAxes.Add(new LinearAxisSimulator("Z")); - } - - - public void Connect() - { - cancellationTokenSource = new CancellationTokenSource(); - - Connected = true; - - _ = Task.Run(() => Worker(cancellationTokenSource.Token)); - } - - public void Disconnect() - { - if (cancellationTokenSource != null) cancellationTokenSource.Cancel(); - - Connected = false; - } - - private async Task Worker(CancellationToken cancellationToken) - { - var rnd = new Random(); - - while (!cancellationToken.IsCancellationRequested) - { - Controller.EmergencyStop = false; - Controller.CommunicationsAlarm = null; - Controller.LogicAlarm = null; - Controller.SystemAlarm = "Testing a new Alarm"; - Controller.PalletId = "15"; - - Path.Execution = 1; - Path.WaitState = 0; - Path.ControllerMode = 1; - Path.MachineAxisLock = false; - Path.SingleBlock = false; - Path.DryRun = false; - Path.MotionAlarm = null; - Path.SystemAlarm = null; - Path.Feedrate = rnd.Next(0, 600); - Path.CuttingSpeed = rnd.Next(0, 600); - Path.FeedrateOverride = rnd.Next(0, 100); - Path.RapidOverride = rnd.Next(0, 100); - Path.SpindleOverride = rnd.Next(0, 125); - - Path.MainProgram = "TEST-01.NC"; - Path.MainProgramComment = "Testing a New Program"; - Path.ActiveProgram = "TEST-01-SUB-04.NC"; - Path.ActiveProgramComment = "A Subprogram of TEST-01.NC"; - Path.ProgramEdit = 0; - Path.ProgramEditName = string.Empty; - Path.LineLabel = "N3543 G01 X432.2345 Y123.1523"; - Path.LineNumber = 3543; - - // Initialize Variables - if (variableState < 1) - { - Path.Variables = new List> - { - new KeyValuePair("v1", "25"), - new KeyValuePair("v2", "50"), - new KeyValuePair("v3", "75"), - new KeyValuePair("v4", "100") - }; - } - - if (variableState == 1) - { - Path.Variables = new List> - { - new KeyValuePair("v2", "51") - }; - } - - if (variableState == 2) - { - Path.Variables = new List> - { - new KeyValuePair("v3", "") - }; - } - - if (variableState == 3) - { - Path.Variables = new List> - { - new KeyValuePair("v2", "52") - }; - } - - if (variableState == 4) - { - Path.Variables = new List> - { - new KeyValuePair("v3", "0") - }; - } - - if (variableState == 5) - { - Path.Variables = new List> - { - new KeyValuePair("v5", "125") - }; - } - - variableState++; - if (variableState > 5) variableState = 0; - - - Path.PartCount = rnd.Next(0, 100); - Path.PartNumber = StringFunctions.RandomString(10); - Path.PartSerialNumber = StringFunctions.RandomString(15); - - Path.ChuckState = 1; - - // X Axis - LinearAxes[0].MachinePosition = (double)rnd.Next(10000, 100000) / 10000; - LinearAxes[0].WorkPosition = (double)rnd.Next(10000, 100000) / 10000; - LinearAxes[0].Feedrate = rnd.Next(0, 600); - LinearAxes[0].Load = rnd.Next(0, 100); - LinearAxes[0].Temperature = rnd.Next(0, 100); - LinearAxes[0].State = 3; - - // Y Axis - LinearAxes[1].MachinePosition = (double)rnd.Next(10000, 100000) / 10000; - LinearAxes[1].WorkPosition = (double)rnd.Next(10000, 100000) / 10000; - LinearAxes[1].Feedrate = rnd.Next(0, 600); - LinearAxes[1].Load = rnd.Next(0, 100); - LinearAxes[1].Temperature = rnd.Next(0, 100); - LinearAxes[1].State = 3; - - // Z Axis - LinearAxes[2].MachinePosition = (double)rnd.Next(10000, 100000) / 10000; - LinearAxes[2].WorkPosition = (double)rnd.Next(10000, 100000) / 10000; - LinearAxes[2].Feedrate = rnd.Next(0, 600); - LinearAxes[2].Load = rnd.Next(0, 100); - LinearAxes[2].Temperature = rnd.Next(0, 100); - LinearAxes[2].State = 3; - - await Task.Delay(UpdateInterval); - } - } - } -} diff --git a/applications/Adapters/MTConnect-Adapter-Shdr/Simulator/LinearAxisSimulator.cs b/applications/Adapters/MTConnect-Adapter-Shdr/Simulator/LinearAxisSimulator.cs deleted file mode 100644 index 626dc2eb..00000000 --- a/applications/Adapters/MTConnect-Adapter-Shdr/Simulator/LinearAxisSimulator.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace MTConnect.Applications.Adapters.Shdr.Simulator -{ - public class LinearAxisSimulator - { - public string Name { get; set; } - - public double MachinePosition { get; set; } - - public double WorkPosition { get; set; } - - public bool Overtravel { get; set; } - - public double Load { get; set; } - - public double Feedrate { get; set; } - - public double Temperature { get; set; } - - public int State { get; set; } - - - public LinearAxisSimulator(string name) - { - Name = name; - } - } -} diff --git a/applications/Adapters/MTConnect-Adapter-Shdr/Simulator/PathSimulator.cs b/applications/Adapters/MTConnect-Adapter-Shdr/Simulator/PathSimulator.cs deleted file mode 100644 index e1dc7474..00000000 --- a/applications/Adapters/MTConnect-Adapter-Shdr/Simulator/PathSimulator.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace MTConnect.Applications.Adapters.Shdr.Simulator -{ - public class PathSimulator - { - public int Execution { get; set; } - public int WaitState { get; set; } - public int ControllerMode { get; set; } - public bool MachineAxisLock { get; set; } - public bool SingleBlock { get; set; } - public bool DryRun { get; set; } - - - public string MotionAlarm { get; set; } - public string SystemAlarm { get; set; } - - - public double Feedrate { get; set; } - public double CuttingSpeed { get; set; } - - public double FeedrateOverride { get; set; } - public double RapidOverride { get; set; } - public double SpindleOverride { get; set; } - - - public string MainProgram { get; set; } - public string ActiveProgram { get; set; } - public string MainProgramComment { get; set; } - public string ActiveProgramComment { get; set; } - public int ProgramEdit { get; set; } - public string ProgramEditName { get; set; } - - public string LineLabel { get; set; } - public int LineNumber { get; set; } - - - public int ToolNumber { get; set; } - public int ToolGroup { get; set; } - - - public string WorkOffset { get; set; } - public double[] Position { get; set; } - public double[] Orientation { get; set; } - public double[] WorkOffsetTranslation { get; set; } - public double[] WorkOffsetRotation { get; set; } - public string[] ActiveAxes { get; set; } - - - public List> Variables { get; set; } - - - public int PartCount { get; set; } - public string PartNumber { get; set; } - public string PartSerialNumber { get; set; } - - - public int ChuckState { get; set; } - } -} diff --git a/applications/Adapters/MTConnect-Adapter-Shdr/Simulator/PlcSimulator.cs b/applications/Adapters/MTConnect-Adapter-Shdr/Simulator/PlcSimulator.cs deleted file mode 100644 index b7159682..00000000 --- a/applications/Adapters/MTConnect-Adapter-Shdr/Simulator/PlcSimulator.cs +++ /dev/null @@ -1,153 +0,0 @@ -using MTConnect.Applications; -using MTConnect.Assets.CuttingTools; -using System.Collections.Generic; -using System.IO; -using System.Threading; -using System.Threading.Tasks; - -namespace MTConnect.NET_Adapter_SHDR.Simulator -{ - internal class PlcSimulator - { - private CancellationTokenSource cancellationTokenSource; - private readonly string _hostname; - private readonly int _port; - private readonly int _interval; - - public bool Connected; - public bool EmergencyStop; // true = ARMED, false = TRIGGERED - public int Mode; // 1 = Auto, 2 = SingleBlock, 0 = Jog - public int Status; // 0 = Stop, 1 = Idle, 2 = Active - public SpindleData[] SpindleDatas; // [0] = Main Spindle - public AxisData[] AxisDatas; // [0] = X, [1] = Y, [2] = Z - public ProcessData[] ProcessDatas; // [0] = Main Process - public ToolTableData[] ToolTable; - public CuttingToolAsset[] ToolAssets; - - public class SpindleData - { - public double ProgrammedSpeed { get; set; } - public double ActualSpeed { get; set; } - } - - public class AxisData - { - public double MachinePosition { get; set; } - public double WorkPosition { get; set; } - public double ProgrammedPosition { get; set; } - public double DistanceToGo { get; set; } - } - - public class ProcessData - { - public string Program { get; set; } - public string SubProgram { get; set; } - public int ToolNumber { get; set; } - public int ToolOffset { get; set; } - } - - public class ToolTableData - { - public int Tool { get; set; } - public double Length { get; set; } - public double Diameter { get; set; } - } - - - public PlcSimulator(string hostName, int port, int interval = 100) - { - _hostname = hostName; - _port = port; - _interval = interval; - - - SpindleDatas = new SpindleData[1]; - SpindleDatas[0] = new SpindleData(); - - AxisDatas = new AxisData[3]; - AxisDatas[0] = new AxisData(); - AxisDatas[1] = new AxisData(); - AxisDatas[2] = new AxisData(); - - ProcessDatas = new ProcessData[1]; - ProcessDatas[0] = new ProcessData(); - - ToolTable = new ToolTableData[100]; - ToolTable[5] = new ToolTableData - { - Tool = 5, - Length = 6.123, - Diameter = 0.498 - }; - ToolTable[10] = new ToolTableData - { - Tool = 10, - Length = 10.354, - Diameter = 0.375 - }; - - var tools = new List(); - for (var i = 0; i < 100; i++) - { - var tool = Examples.CuttingTool(); - tool.AssetId = $"tool.{i + 1}"; - tools.Add(tool); - } - ToolAssets = tools.ToArray(); - } - - public void Connect() - { - cancellationTokenSource = new CancellationTokenSource(); - - Connected = true; - - _ = Task.Run(() => Worker(cancellationTokenSource.Token)); - } - - public void Disconnect() - { - if (cancellationTokenSource != null) cancellationTokenSource.Cancel(); - - Connected = false; - } - - private async Task Worker(CancellationToken cancellationToken) - { - while (!cancellationToken.IsCancellationRequested) - { - Mode += 1; - if (Mode > 2) Mode = 0; - - Status += 1; - if (Status > 2) Status = 0; - - if (ProcessDatas[0].ToolNumber < 10) - { - ProcessDatas[0].ToolNumber = 10; - ProcessDatas[0].ToolOffset = 10; - } - else if (ProcessDatas[0].ToolNumber == 10) - { - ProcessDatas[0].ToolNumber = 5; - ProcessDatas[0].ToolOffset = 5; - } - - for (var i = 0; i < 10; i++) - { - EmergencyStop = true; - - ProcessDatas[0].Program = "PRT_011.NC"; - - SpindleDatas[0].ProgrammedSpeed = 5500; - SpindleDatas[0].ActualSpeed = 5499; - - AxisDatas[0].MachinePosition = 123.45678 + (double)i / 1000; - AxisDatas[0].WorkPosition = 45.12345 + (double)i / 1000; - - await Task.Delay(_interval); - } - } - } - } -} diff --git a/applications/Adapters/MTConnect-Adapter-Shdr/Simulator/RotaryAxisSimulator.cs b/applications/Adapters/MTConnect-Adapter-Shdr/Simulator/RotaryAxisSimulator.cs deleted file mode 100644 index 0174b96c..00000000 --- a/applications/Adapters/MTConnect-Adapter-Shdr/Simulator/RotaryAxisSimulator.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace MTConnect.Applications.Adapters.Shdr.Simulator -{ - public class RotaryAxisSimulator - { - public string Name { get; set; } - - public double MachinePosition { get; set; } - - public double WorkPosition { get; set; } - - public bool Overtravel { get; set; } - - public double AxisLoad { get; set; } - - public double Feedrate { get; set; } - - public double Temperature { get; set; } - - public int State { get; set; } - - public int Mode { get; set; } - - - public RotaryAxisSimulator() { } - - public RotaryAxisSimulator(string name) - { - Name = name; - } - } -} diff --git a/applications/Adapters/MTConnect-Adapter-Shdr/Simulator/SpindleAxisSimulator.cs b/applications/Adapters/MTConnect-Adapter-Shdr/Simulator/SpindleAxisSimulator.cs deleted file mode 100644 index be53dcb3..00000000 --- a/applications/Adapters/MTConnect-Adapter-Shdr/Simulator/SpindleAxisSimulator.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace MTConnect.Applications.Adapters.Shdr.Simulator -{ - public class SpindleAxisSimulator : RotaryAxisSimulator - { - public double SpindleLoad { get; set; } - - public double SpindleSpeed { get; set; } - - - public SpindleAxisSimulator(string name) - { - Name = name; - } - } -} diff --git a/applications/Adapters/MTConnect-Adapter-Shdr/adapter.config.default.yaml b/applications/Adapters/MTConnect-Adapter-Shdr/adapter.config.default.yaml deleted file mode 100644 index e11d93ff..00000000 --- a/applications/Adapters/MTConnect-Adapter-Shdr/adapter.config.default.yaml +++ /dev/null @@ -1,2 +0,0 @@ -id: PatrickAdapter -deviceKey: OKUMA-Lathe \ No newline at end of file diff --git a/applications/Adapters/MTConnect-Adapter-Shdr/build.bat b/applications/Adapters/MTConnect-Adapter-Shdr/build.bat deleted file mode 100644 index 65498a7e..00000000 --- a/applications/Adapters/MTConnect-Adapter-Shdr/build.bat +++ /dev/null @@ -1,3 +0,0 @@ -dotnet build -c:Release -r:win-x86 --no-self-contained -dotnet build -c:Release -r:win-x64 --no-self-contained -"c:\Program Files (x86)\Inno Setup 6\iscc" installer.iss diff --git a/applications/Adapters/MTConnect-Adapter-Shdr/installer.iss b/applications/Adapters/MTConnect-Adapter-Shdr/installer.iss deleted file mode 100644 index 800b7108..00000000 --- a/applications/Adapters/MTConnect-Adapter-Shdr/installer.iss +++ /dev/null @@ -1,107 +0,0 @@ -; MTConnect SHDR Adapter Installer -; ------------------------------ - -#define MyAppName "MTConnect SHDR Adapter" -#define MyAppVersion "1.0.0" -#define MyAppPublisher "MTConnect" -#define MyAppURL "" -#define MyAppVerName MyAppName + " " + MyAppVersion - -; File Names -#define ExeName "MTConnect-SHDR-Adapter.exe" - - -[Setup] -; NOTE: The value of AppId uniquely identifies this application. -; Do not use the same AppId value in installers for other applications. -; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) -AppId={{F526CCEA-232A-4B5B-BCEA-8168665333EC} - -AppName={#MyAppName} -AppVersion={#MyAppVersion} -AppVerName={#MyAppName} {#MyAppVersion} -AppPublisher={#MyAppPublisher} -AppPublisherURL={#MyAppURL} -AppSupportURL={#MyAppURL} -AppUpdatesURL={#MyAppURL} -AppReadmeFile=https://github.com/TrakHound/MTConnect.NET -VersionInfoVersion={#MyAppVersion} -ArchitecturesInstallIn64BitMode=x64 - -PrivilegesRequired=admin -DisableProgramGroupPage=no -Compression=lzma -SolidCompression=yes - -; Names -DisableDirPage=auto -DisableReadyPage=no -DisableFinishedPage=no -OutputDir=bin\Publish -DefaultDirName={autopf}\{#MyAppPublisher}\MTConnect-SHDR-Adapter -UsePreviousAppDir=false -OutputBaseFilename=MTConnect-SHDR-Adapter-Install-v{#MyAppVersion} -UninstallDisplayName={#MyAppName} v{#MyAppVersion} -UninstallFilesDir={app}\Uninstall - -[Types] -Name: "win64net7"; Description: "Windows x64 .NET 7" -Name: "win86net7"; Description: "Windows x86 .NET 7" -Name: "win64net6"; Description: "Windows x64 .NET 6" -Name: "win86net6"; Description: "Windows x86 .NET 6" -Name: "win64net48"; Description: "Windows x64 .NET 4.8 Framework" -Name: "win86net48"; Description: "Windows x86 .NET 4.8 Framework" -Name: "win64net461"; Description: "Windows x64 .NET 4.6.1 Framework" -Name: "win86net461"; Description: "Windows x86 .NET 4.6.1 Framework" - -[Components] -Name: "win64net7"; Description: "{#MyAppVerName}"; Types: win64net7 -Name: "win86net7"; Description: "{#MyAppVerName}"; Types: win86net7 -Name: "win64net6"; Description: "{#MyAppVerName}"; Types: win64net6 -Name: "win86net6"; Description: "{#MyAppVerName}"; Types: win86net6 -Name: "win64net48"; Description: "{#MyAppVerName}"; Types: win64net48 -Name: "win86net48"; Description: "{#MyAppVerName}"; Types: win86net48 -Name: "win64net461"; Description: "{#MyAppVerName}"; Types: win64net461 -Name: "win86net461"; Description: "{#MyAppVerName}"; Types: win86net461 -Name: "configuration"; Description: "Configuration Files"; Types: win86net461 win64net461 win86net48 win64net48 win86net6 win64net6 win86net7 win64net7 - - -[Languages] -Name: "english"; MessagesFile: "compiler:Default.isl" - -[Dirs] -Name: "{app}"; Permissions: everyone-full -Name: "{app}\logs"; Permissions: everyone-full - -[Files] - -; Program Files -Source: "bin\release\net7.0\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net7; -Source: "bin\release\net7.0\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net7; -Source: "bin\release\net6.0\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net6; -Source: "bin\release\net6.0\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net6; -Source: "bin\release\net48\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net48; -Source: "bin\release\net48\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net48; -Source: "bin\release\net461\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net461; -Source: "bin\release\net461\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net461; - - -[Run] - -; Install and Run Windows Service -Filename: {sys}\cmd.exe; Parameters: "/c adapter.exe ""stop""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Stopping Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c adapter.exe ""remove""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Uninstalling Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c adapter.exe ""install""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Installing Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c adapter.exe ""start""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Starting Windows Service..."; - -; Start Browser -Filename: {sys}\cmd.exe; Parameters: "/c explorer ""adapter.config.yaml""" ; WorkingDir: {app}; Flags: runhidden postinstall unchecked; Description: Open Adapter Configuration File; -Filename: {sys}\cmd.exe; Parameters: "/c explorer ""NLog.config""" ; WorkingDir: {app}; Flags: runhidden postinstall unchecked; Description: Open Log Configuration File; -Filename: {sys}\cmd.exe; Parameters: "/c explorer ""{app}""" ; Flags: runhidden postinstall unchecked; Description: Open Install Directory; - - -[UninstallRun] - -; Stop Server Service -Filename: {sys}\cmd.exe; Parameters: "/c adapter.exe ""stop""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Stopping Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c adapter.exe ""remove""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Uninstalling Windows Service..."; diff --git a/applications/Agents/MTConnect-Agent-Http-AspNetCore/.config/dotnet-tools.json b/applications/Agents/MTConnect-Agent-Http-AspNetCore/.config/dotnet-tools.json deleted file mode 100644 index 0d1da733..00000000 --- a/applications/Agents/MTConnect-Agent-Http-AspNetCore/.config/dotnet-tools.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "version": 1, - "isRoot": true, - "tools": { - "dotnet-ef": { - "version": "6.0.1", - "commands": [ - "dotnet-ef" - ] - } - } -} \ No newline at end of file diff --git a/applications/Agents/MTConnect-Agent-Http-AspNetCore/Configurations/HttpShdrAgentConfiguration.cs b/applications/Agents/MTConnect-Agent-Http-AspNetCore/Configurations/HttpShdrAgentConfiguration.cs deleted file mode 100644 index f8bd8758..00000000 --- a/applications/Agents/MTConnect-Agent-Http-AspNetCore/Configurations/HttpShdrAgentConfiguration.cs +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. -// TrakHound Inc. licenses this file to you under the MIT license. - -using System.Text.Json.Serialization; - -namespace MTConnect.Configurations -{ - /// - /// Configuration for an MTConnect Http-Shdr Agent - /// - public class HttpShdrAgentConfiguration : ShdrAgentConfiguration - { - /// - /// The Path to look for the file(s) that represent the Device Information Models to load into the Agent. - /// The path can either be a single file or a directory. The path can be absolute or relative to the executable's directory - /// - [JsonPropertyName("devices")] - public string Devices { get; set; } - - - /// - /// Changes the service name when installing or removing the service. This allows multiple agents to run as services on the same machine. - /// - [JsonPropertyName("serviceName")] - public string ServiceName { get; set; } - - /// - /// Sets the Service Start Type. True = Auto | False = Manual - /// - [JsonPropertyName("serviceAutoStart")] - public bool ServiceAutoStart { get; set; } - - - /// - /// Gets or Sets whether the Agent buffers are durable and retain state after restart - /// - [JsonPropertyName("durable")] - public bool Durable { get; set; } - - - /// - /// Gets or Sets whether Configuration files are monitored. If enabled and a configuration file is changed, the Agent will restart - /// - [JsonPropertyName("monitorConfigurationFiles")] - public bool MonitorConfigurationFiles { get; set; } - - /// - /// Gets or Sets the minimum time (in seconds) between Agent restarts when MonitorConfigurationFiles is enabled - /// - [JsonPropertyName("configurationFileRestartInterval")] - public int ConfigurationFileRestartInterval { get; set; } - - - public HttpShdrAgentConfiguration() : base() - { - Devices = "devices"; - ServiceName = null; - ServiceAutoStart = true; - MonitorConfigurationFiles = true; - ConfigurationFileRestartInterval = 2; - } - } -} diff --git a/applications/Agents/MTConnect-Agent-Http-AspNetCore/Loggers/AdapterLogger.cs b/applications/Agents/MTConnect-Agent-Http-AspNetCore/Loggers/AdapterLogger.cs deleted file mode 100644 index 3ebeaf98..00000000 --- a/applications/Agents/MTConnect-Agent-Http-AspNetCore/Loggers/AdapterLogger.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. -// TrakHound Inc. licenses this file to you under the MIT license. - -using Microsoft.Extensions.Logging; -using MTConnect.Adapters.Shdr; -using System; - -namespace MTConnect.Applications.Loggers -{ - public class AdapterLogger - { - private readonly ILogger _logger; - - - public AdapterLogger(ILogger logger) - { - _logger = logger; - } - - - public void AdapterConnected(object sender, string message) - { - var adapterClient = (ShdrAdapterClient)sender; - _logger.LogInformation($"[Adapter] : ID = " + adapterClient.Id + " : " + message); - } - - public void AdapterDisconnected(object sender, string message) - { - var adapterClient = (ShdrAdapterClient)sender; - _logger.LogInformation($"[Adapter] : ID = " + adapterClient.Id + " : " + message); - } - - public void AdapterConnectionError(object sender, Exception exception) - { - var adapterClient = (ShdrAdapterClient)sender; - _logger.LogInformation($"[Adapter] : ID = " + adapterClient.Id + " : " + exception.Message); - } - - public void AdapterPingSent(object sender, string message) - { - var adapterClient = (ShdrAdapterClient)sender; - _logger.LogInformation($"[Adapter] : ID = " + adapterClient.Id + " : " + message); - } - - public void AdapterPongReceived(object sender, string message) - { - var adapterClient = (ShdrAdapterClient)sender; - _logger.LogInformation($"[Adapter] : ID = " + adapterClient.Id + " : " + message); - } - } -} diff --git a/applications/Agents/MTConnect-Agent-Http-AspNetCore/Loggers/AdapterShdrLogger.cs b/applications/Agents/MTConnect-Agent-Http-AspNetCore/Loggers/AdapterShdrLogger.cs deleted file mode 100644 index 30b5b785..00000000 --- a/applications/Agents/MTConnect-Agent-Http-AspNetCore/Loggers/AdapterShdrLogger.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. -// TrakHound Inc. licenses this file to you under the MIT license. - -using Microsoft.Extensions.Logging; -using MTConnect.Adapters.Shdr; - -namespace MTConnect.Applications.Loggers -{ - public class AdapterShdrLogger - { - private readonly ILogger _logger; - - - public AdapterShdrLogger(ILogger logger) - { - _logger = logger; - } - - - public void AdapterProtocolReceived(object sender, string message) - { - var adapterClient = (ShdrAdapterClient)sender; - _logger.LogDebug($"[Adapter-SHDR] : ID = " + adapterClient.Id + " : " + message); - } - } -} diff --git a/applications/Agents/MTConnect-Agent-Http-AspNetCore/Loggers/AgentLogger.cs b/applications/Agents/MTConnect-Agent-Http-AspNetCore/Loggers/AgentLogger.cs deleted file mode 100644 index 4019d9c9..00000000 --- a/applications/Agents/MTConnect-Agent-Http-AspNetCore/Loggers/AgentLogger.cs +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. -// TrakHound Inc. licenses this file to you under the MIT license. - -using Microsoft.Extensions.Logging; -using MTConnect.Assets; -using MTConnect.Devices; -using MTConnect.Streams; -using System; -using System.Collections.Generic; -using System.Linq; - -namespace MTConnect.Applications.Loggers -{ - public class AgentLogger - { - private readonly ILogger _logger; - - - public AgentLogger(ILogger logger) - { - _logger = logger; - } - - - public void LogInformation(string message) - { - _logger.LogInformation(message); - } - - - public void DevicesRequested(string deviceName) - { - _logger.LogInformation($"[Agent] : MTConnectDevices Requested : {deviceName}"); - } - - public void DevicesResponseSent(IDevicesResponseDocument document) - { - _logger.LogInformation($"[Agent] : MTConnectDevices Response Document Returned : {document.Header.CreationTime}"); - } - - - public void StreamsRequested(string deviceName) - { - _logger.LogInformation($"[Agent] : MTConnectStreams Requested : {deviceName}"); - } - - public void StreamsResponseSent(object sender, EventArgs args) - { - _logger.LogInformation($"[Agent] : MTConnectStreams Response Document Returned"); - } - - - public void AssetsRequested(IEnumerable assetIds) - { - var ids = ""; - if (!assetIds.IsNullOrEmpty()) - { - string.Join(";", assetIds.ToArray()); - } - - _logger.LogDebug($"[Agent] : MTConnectAssets Requested : AssetIds = " + ids); - } - - public void DeviceAssetsRequested(string deviceUuid) - { - _logger.LogDebug($"[Agent] : MTConnectAssets Requested : DeviceUuid = " + deviceUuid); - } - - public void AssetsResponseSent(IAssetsResponseDocument document) - { - _logger.LogInformation($"[Agent] : MTConnectAssets Response Document Returned : {document.Header.CreationTime}"); - } - } -} diff --git a/applications/Agents/MTConnect-Agent-Http-AspNetCore/Loggers/AgentMetricLogger.cs b/applications/Agents/MTConnect-Agent-Http-AspNetCore/Loggers/AgentMetricLogger.cs deleted file mode 100644 index 1329ff2d..00000000 --- a/applications/Agents/MTConnect-Agent-Http-AspNetCore/Loggers/AgentMetricLogger.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. -// TrakHound Inc. licenses this file to you under the MIT license. - -using Microsoft.Extensions.Logging; - -namespace MTConnect.Applications.Loggers -{ - public class AgentMetricLogger - { - private readonly ILogger _logger; - - - public AgentMetricLogger(ILogger logger) - { - _logger = logger; - } - - - public void LogInformation(string message) - { - _logger.LogInformation(message); - } - } -} diff --git a/applications/Agents/MTConnect-Agent-Http-AspNetCore/Loggers/AgentValidationLogger.cs b/applications/Agents/MTConnect-Agent-Http-AspNetCore/Loggers/AgentValidationLogger.cs deleted file mode 100644 index 24254c18..00000000 --- a/applications/Agents/MTConnect-Agent-Http-AspNetCore/Loggers/AgentValidationLogger.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. -// TrakHound Inc. licenses this file to you under the MIT license. - -using Microsoft.Extensions.Logging; -using MTConnect.Devices; -using MTConnect.Devices.DataItems; - -namespace MTConnect.Applications.Loggers -{ - public class AgentValidationLogger - { - private readonly ILogger _logger; - - - public AgentValidationLogger(ILogger logger) - { - _logger = logger; - } - - - public void InvalidDataItemAdded(string deviceUuid, IDataItem dataItem, ValidationResult result) - { - _logger.LogWarning($"[Agent-Validation] : Validation Failed : {deviceUuid} : {result.Message}"); - } - } -} diff --git a/applications/Agents/MTConnect-Agent-Http-AspNetCore/MTConnect-Agent-Http-AspNetCore.csproj b/applications/Agents/MTConnect-Agent-Http-AspNetCore/MTConnect-Agent-Http-AspNetCore.csproj deleted file mode 100644 index 39dd2cc6..00000000 --- a/applications/Agents/MTConnect-Agent-Http-AspNetCore/MTConnect-Agent-Http-AspNetCore.csproj +++ /dev/null @@ -1,68 +0,0 @@ - - - - net6.0 - - - netcoreapp3.1;net5.0;net6.0 - - - - MTConnect.Applications - - - - en - - - - - - - - - - - <_WebToolingArtifacts Remove="Properties\PublishProfiles\NET-6-win-x64.pubxml" /> - <_WebToolingArtifacts Remove="Properties\PublishProfiles\NET-6-win-x86.pubxml" /> - - - - - - - - - Always - - - Always - - - - - - - - - - - - - - - - Always - - - Always - - - Always - - - Always - - - - diff --git a/applications/Agents/MTConnect-Agent-Http-AspNetCore/MTConnectAgentService.cs b/applications/Agents/MTConnect-Agent-Http-AspNetCore/MTConnectAgentService.cs deleted file mode 100644 index 4c108039..00000000 --- a/applications/Agents/MTConnect-Agent-Http-AspNetCore/MTConnectAgentService.cs +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. -// TrakHound Inc. licenses this file to you under the MIT license. - -using Microsoft.Extensions.Hosting; -using MTConnect.Adapters.Shdr; -using MTConnect.Agents; -using MTConnect.Applications.Loggers; -using MTConnect.Configurations; -using MTConnect.Devices; -using MTConnect.Devices.Components; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; - -namespace MTConnect.Applications -{ - public class MTConnectAgentService : IHostedService - { - private readonly HttpShdrAgentConfiguration _configuration; - private readonly IMTConnectAgentBroker _mtconnectAgent; - private IAgentConfigurationFileWatcher _agentConfigurationWatcher; - private readonly AgentLogger _agentLogger; - private readonly AgentMetricLogger _agentMetricLogger; - private readonly AdapterLogger _adapterLogger; - private readonly AdapterShdrLogger _adapterShdrLogger; - private readonly List _adapterClients = new List(); - private System.Timers.Timer _metricsTimer; - - - public MTConnectAgentService( - HttpShdrAgentConfiguration configuration, - IMTConnectAgentBroker mtconnectAgent, - AgentLogger agentLogger, - AgentMetricLogger agentMetricLogger, - AgentValidationLogger agentValidationLogger, - AdapterLogger adapterLogger, - AdapterShdrLogger adapterShdrLogger - ) - { - _configuration = configuration; - _mtconnectAgent = mtconnectAgent; - _agentLogger = agentLogger; - _agentMetricLogger = agentMetricLogger; - _adapterLogger = adapterLogger; - _adapterShdrLogger = adapterShdrLogger; - - _mtconnectAgent.DevicesRequestReceived += _agentLogger.DevicesRequested; - _mtconnectAgent.DevicesResponseSent += _agentLogger.DevicesResponseSent; - _mtconnectAgent.StreamsRequestReceived += _agentLogger.StreamsRequested; - _mtconnectAgent.StreamsResponseSent += _agentLogger.StreamsResponseSent; - _mtconnectAgent.AssetsRequestReceived += _agentLogger.AssetsRequested; - _mtconnectAgent.DeviceAssetsRequestReceived += _agentLogger.DeviceAssetsRequested; - _mtconnectAgent.AssetsResponseSent += _agentLogger.AssetsResponseSent; - - _mtconnectAgent.InvalidDataItemAdded += agentValidationLogger.InvalidDataItemAdded; - } - - - public async Task StartAsync(CancellationToken cancellationToken) - { - _adapterClients.Clear(); - - if (_configuration != null) - { - // Add Adapter Clients - if (!_configuration.Adapters.IsNullOrEmpty()) - { - var devices = await DeviceConfiguration.FromFileAsync(_configuration.Devices, DocumentFormat.XML); - if (!devices.IsNullOrEmpty()) - { - // Add Device(s) to Agent - foreach (var device in devices) - { - _mtconnectAgent.AddDevice(device); - } - - // Device Specific Adapters (DeviceKey specified) - var deviceAdapters = _configuration.Adapters.Where(o => o.DeviceKey != ShdrClientConfiguration.DeviceKeyWildcard); - if (!deviceAdapters.IsNullOrEmpty()) - { - foreach (var adapter in deviceAdapters) - { - // Find Device matching DeviceKey - var device = devices?.FirstOrDefault(o => o.Uuid == adapter.DeviceKey || o.Name == adapter.DeviceKey); - if (device != null) AddAdapter(adapter, device); - } - } - - // Wildcard Adapters (DeviceKey = '*') - var wildCardAdapters = _configuration.Adapters.Where(o => o.DeviceKey == ShdrClientConfiguration.DeviceKeyWildcard); - if (!wildCardAdapters.IsNullOrEmpty()) - { - foreach (var adapter in wildCardAdapters) - { - // Add Adapter for each Device (every device reads from the same adapter) - foreach (var device in devices) AddAdapter(adapter, device, true, device.Id); - } - } - } - else if (_configuration.AllowShdrDevice) // Prevent accidental generic Adapter creation - { - foreach (var adapter in _configuration.Adapters) - { - // Add a generic Adapter Client (no Device) - // Typically used if the Device Model is sent using SHDR - AddAdapter(adapter, null); - } - } - } - } - - StartMetrics(); - } - - public async Task StopAsync(CancellationToken cancellationToken) - { - if (!_adapterClients.IsNullOrEmpty()) - { - foreach (var adapterClient in _adapterClients) - { - adapterClient.Stop(); - } - } - - if (_metricsTimer != null) _metricsTimer.Dispose(); - } - - - private void AddAdapter(IShdrAdapterClientConfiguration configuration, IDevice device, bool initializeDataItems = true, string idSuffix = null) - { - if (configuration != null) - { - var adapterComponent = new ShdrAdapterComponent(configuration, idSuffix, device, device); - - // Add Adapter Component to Agent Device - _mtconnectAgent.Agent.AddAdapterComponent(adapterComponent); - - // Create new SHDR Adapter Client to read from SHDR stream - var adapterClient = new ShdrAdapterClient(configuration, _mtconnectAgent, device); - adapterClient.Connected += _adapterLogger.AdapterConnected; - adapterClient.Disconnected += _adapterLogger.AdapterDisconnected; - adapterClient.ConnectionError += _adapterLogger.AdapterConnectionError; - adapterClient.PingSent += _adapterLogger.AdapterPingSent; - adapterClient.PongReceived += _adapterLogger.AdapterPongReceived; - adapterClient.ProtocolReceived += _adapterShdrLogger.AdapterProtocolReceived; - _adapterClients.Add(adapterClient); - - adapterClient.Start(); - } - } - - - private void StartMetrics() - { - if (_configuration.EnableMetrics) - { - int observationLastCount = 0; - int observationDelta = 0; - int assetLastCount = 0; - int assetDelta = 0; - var updateInterval = _mtconnectAgent.Metrics.UpdateInterval.TotalSeconds; - var windowInterval = _mtconnectAgent.Metrics.WindowInterval.TotalMinutes; - - _metricsTimer = new System.Timers.Timer(); - _metricsTimer.Interval = updateInterval * 1000; - _metricsTimer.Elapsed += (s, e) => - { - // Observations - var observationCount = _mtconnectAgent.Metrics.GetObservationCount(); - var observationAverage = _mtconnectAgent.Metrics.ObservationAverage; - observationDelta = observationCount - observationLastCount; - - _agentMetricLogger.LogInformation("[Agent] : Observations - Delta for last " + updateInterval + " seconds: " + observationDelta); - _agentMetricLogger.LogInformation("[Agent] : Observations - Average for last " + windowInterval + " minutes: " + Math.Round(observationAverage, 5)); - - // Assets - var assetCount = _mtconnectAgent.Metrics.GetAssetCount(); - var assetAverage = _mtconnectAgent.Metrics.AssetAverage; - assetDelta = assetCount - assetLastCount; - - _agentMetricLogger.LogInformation("[Agent] : Assets - Delta for last " + updateInterval + " seconds: " + assetDelta); - _agentMetricLogger.LogInformation("[Agent] : Assets - Average for last " + windowInterval + " minutes: " + Math.Round(assetAverage, 5)); - - observationLastCount = observationCount; - assetLastCount = assetCount; - }; - _metricsTimer.Start(); - } - } - } -} diff --git a/applications/Agents/MTConnect-Agent-Http-AspNetCore/NLog.config b/applications/Agents/MTConnect-Agent-Http-AspNetCore/NLog.config deleted file mode 100644 index 62dd222f..00000000 --- a/applications/Agents/MTConnect-Agent-Http-AspNetCore/NLog.config +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/applications/Agents/MTConnect-Agent-Http-AspNetCore/Program.cs b/applications/Agents/MTConnect-Agent-Http-AspNetCore/Program.cs deleted file mode 100644 index 2875974c..00000000 --- a/applications/Agents/MTConnect-Agent-Http-AspNetCore/Program.cs +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. -// TrakHound Inc. licenses this file to you under the MIT license. - -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.ResponseCompression; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Hosting.WindowsServices; -using Microsoft.Extensions.Logging; -using MTConnect.Agents; -using MTConnect.Applications.Loggers; -using MTConnect.Configurations; -using NLog.Web; -using System; -using System.IO; -using System.IO.Compression; -using System.Linq; - -namespace MTConnect.Applications -{ - public class Program - { - private static HttpShdrAgentConfiguration _configuration; - - - public static void Main(string[] args) - { - var logger = NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger(); - try - { - // Set WebApplication Options - var options = new WebApplicationOptions - { - Args = args, - ContentRootPath = WindowsServiceHelpers.IsWindowsService() ? AppContext.BaseDirectory : default - }; - - // Create WebApplication Builder - var builder = WebApplication.CreateBuilder(options); - ConfigureBuilder(builder); - AddServices(builder); - - // Create WebApplication - var app = builder.Build(); - ConfigureServices(app); - - // Run WebApplication - app.Run(); - } - catch (Exception exception) - { - //NLog: catch setup errors - logger.Error(exception, "Stopped program because of exception"); - throw; - } - finally - { - // Ensure to flush and stop internal timers/threads before application-exit (Avoid segmentation fault on Linux) - NLog.LogManager.Shutdown(); - } - } - - // This is the method that should be able to be used instead of CreateHostBuilder() - private static void ConfigureBuilder(WebApplicationBuilder builder) - { - // Set to allow Windows Service - builder.Host.UseWindowsService(); - - // Add Logging - builder.Host.UseNLog(); - builder.Logging.AddConsole(); - } - - private static void AddServices(WebApplicationBuilder builder) - { - // Copy Default Configuration File - string configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AgentConfiguration.JsonFilename); - string defaultPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AgentConfiguration.DefaultJsonFilename); - if (!File.Exists(configPath) && File.Exists(defaultPath)) - { - File.Copy(defaultPath, configPath); - } - - _configuration = AgentConfiguration.ReadJson(configPath); - if (_configuration != null) - { - // Create MTConnectAgent - var agent = new MTConnectAgentBroker(_configuration); - agent.MTConnectVersion = MTConnectVersions.Max; - agent.Start(); - builder.Services.AddSingleton(agent); - - // Individual Logger Classes - builder.Services.AddSingleton(_configuration); - builder.Services.AddSingleton(_configuration); - builder.Services.AddSingleton(); - builder.Services.AddSingleton(); - builder.Services.AddSingleton(); - builder.Services.AddSingleton(); - builder.Services.AddSingleton(); - - // Add the MTConnectAgentService that handles the MTConnect Agent - builder.Services.AddHostedService(); - - if (!_configuration.ResponseCompression.IsNullOrEmpty()) - { - // Add Compression Services - builder.Services.AddResponseCompression(options => - { - options.EnableForHttps = true; - - // Gzip - if (_configuration.ResponseCompression.Any(o => o == Http.HttpResponseCompression.Gzip)) - { - options.Providers.Add(); - } - - // Brotli - if (_configuration.ResponseCompression.Any(o => o == Http.HttpResponseCompression.Br)) - { - options.Providers.Add(); - } - }); - - // Gzip - if (_configuration.ResponseCompression.Any(o => o == Http.HttpResponseCompression.Gzip)) - { - builder.Services.Configure(options => { options.Level = CompressionLevel.Optimal; }); - } - - // Brotli - if (_configuration.ResponseCompression.Any(o => o == Http.HttpResponseCompression.Br)) - { - builder.Services.Configure(options => { options.Level = CompressionLevel.Optimal; }); - } - } - - builder.WebHost.UseKestrel(o => - { - o.ListenAnyIP(_configuration.Port); - }); - } - - // Add Controllers - builder.Services.AddControllers(); - } - - private static void ConfigureServices(WebApplication app) - { - if (app.Environment.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - else - { - app.UseExceptionHandler("/Error"); - } - - app.UseStaticFiles(); - app.UseRouting(); - - if (_configuration != null && !_configuration.ResponseCompression.IsNullOrEmpty()) - { - app.UseResponseCompression(); - } - - app.UseEndpoints(endpoints => - { - endpoints.MapControllers(); - }); - } - } -} diff --git a/applications/Agents/MTConnect-Agent-Http-AspNetCore/Properties/launchSettings.json b/applications/Agents/MTConnect-Agent-Http-AspNetCore/Properties/launchSettings.json deleted file mode 100644 index 5248397d..00000000 --- a/applications/Agents/MTConnect-Agent-Http-AspNetCore/Properties/launchSettings.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:47510", - "sslPort": 0 - } - }, - "profiles": { - "MTConnect_Agent_AspNetCore": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": true, - "applicationUrl": "http://localhost:5216", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } -} diff --git a/applications/Agents/MTConnect-Agent-Http-AspNetCore/agent.config.default.json b/applications/Agents/MTConnect-Agent-Http-AspNetCore/agent.config.default.json deleted file mode 100644 index b7db91d0..00000000 --- a/applications/Agents/MTConnect-Agent-Http-AspNetCore/agent.config.default.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "devices": "devices.xml", - "port": 5005, - "adapters": [ - { - "host": "localhost", - "port": 7878 - } - ] -} \ No newline at end of file diff --git a/applications/Agents/MTConnect-Agent-Http-AspNetCore/appsettings.Development.json b/applications/Agents/MTConnect-Agent-Http-AspNetCore/appsettings.Development.json deleted file mode 100644 index 770d3e93..00000000 --- a/applications/Agents/MTConnect-Agent-Http-AspNetCore/appsettings.Development.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "DetailedErrors": true, - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - } -} diff --git a/applications/Agents/MTConnect-Agent-Http-AspNetCore/appsettings.json b/applications/Agents/MTConnect-Agent-Http-AspNetCore/appsettings.json deleted file mode 100644 index 10f68b8c..00000000 --- a/applications/Agents/MTConnect-Agent-Http-AspNetCore/appsettings.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - }, - "AllowedHosts": "*" -} diff --git a/applications/Agents/MTConnect-Agent-Http-AspNetCore/devices.xml b/applications/Agents/MTConnect-Agent-Http-AspNetCore/devices.xml deleted file mode 100644 index 8bedff24..00000000 --- a/applications/Agents/MTConnect-Agent-Http-AspNetCore/devices.xml +++ /dev/null @@ -1,164 +0,0 @@ - - -
- - - - Okuma MT Connect Adapter - Lathe - - - - - - - - - - - - - - - - - - SPINDLE - - - - - - - - - - - - - - - SPINDLE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/applications/Agents/MTConnect-Agent-Http-AspNetCore/devices/device-mazak.xml b/applications/Agents/MTConnect-Agent-Http-AspNetCore/devices/device-mazak.xml deleted file mode 100644 index 051c4435..00000000 --- a/applications/Agents/MTConnect-Agent-Http-AspNetCore/devices/device-mazak.xml +++ /dev/null @@ -1,450 +0,0 @@ - - Mill w/SMooth-G - - - - - 0 0 0 - 0 0 0 - - - - - 0 0 0 - 0 0 0 - - - - - - - 2.0 3.0 4.0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - spindle_speed - - - - - - - - 3 - - - - - - - - - - 0.5 - - - - - - - - - - - - 200.0 - 0.0 - - - - - - - - - - - - 3 - - - - - - 0.5 - - - - - - - - - - - - - - - - - 3 - - - - - - 0.5 - - - - - - - - - - - The linears Z kinematics - 100.0 101.0 102.0 - 0.0 0.1 1.0 - - - - - - - - 3 - - - - - - - - - CONTOUR - INDEX - - - - - - - - - - - - - 3 - - - - - 3 - - - - - - - 5 - - - - - 0.5 - - - - - - - SPINDLE - INDEX - - - - - - - - - - - - - - - - The spindle kinematics - - 10.0 20.0 30.0 - 90.0 0.0 180 - - 0.0 0.5 1.0 - - - - 10000 - 100 - 1000 - - - 1000 - -1000 - 100 - 500 - -500 - 200 - -200 - - - - 500 - 50 - -500 - - - 500 - -500 - 10 - 200 - -200 - - - 500 - -500 - 200 - -200 - - - - - - - - - - - - - - - - - - - - - 101 102 103 - - - - 10 10 10 - 90 0 90 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - A Complex Workpiece Offset Table - - - Some Pressure thing - - - Pressure of the P - - - - - - - - - - - - - - Spindle Angle - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0.5 - - - - - - - - - - - - - - - - - - - - - - - - 0.5 - - - - - - - - 2.02 - 2010-05-16 - 2010-05-16 - WS - - - A/D With Thermister - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/applications/Agents/MTConnect-Agent-Http-AspNetCore/devices/device-okuma.xml b/applications/Agents/MTConnect-Agent-Http-AspNetCore/devices/device-okuma.xml deleted file mode 100644 index dd745114..00000000 --- a/applications/Agents/MTConnect-Agent-Http-AspNetCore/devices/device-okuma.xml +++ /dev/null @@ -1,165 +0,0 @@ - - - Okuma MT Connect Adapter - Lathe - - - - - - - - - - - - - - - - - - - SPINDLE - - - - OPEN - - - - - - - - - - - - - - - - SPINDLE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/.config/dotnet-tools.json b/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/.config/dotnet-tools.json deleted file mode 100644 index 0d1da733..00000000 --- a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/.config/dotnet-tools.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "version": 1, - "isRoot": true, - "tools": { - "dotnet-ef": { - "version": "6.0.1", - "commands": [ - "dotnet-ef" - ] - } - } -} \ No newline at end of file diff --git a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/Configurations/AgentGatewayConfiguration.cs b/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/Configurations/AgentGatewayConfiguration.cs deleted file mode 100644 index 9712c81c..00000000 --- a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/Configurations/AgentGatewayConfiguration.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. -// TrakHound Inc. licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.IO; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace MTConnect.Configurations -{ - public class AgentGatewayConfiguration : HttpAgentConfiguration - { - /// - /// - /// - [JsonPropertyName("clients")] - public List Clients { get; set; } - - - public new static AgentGatewayConfiguration Read(string path = null) - { - var configurationPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, JsonFilename); - if (path != null) configurationPath = path; - - if (!string.IsNullOrEmpty(configurationPath)) - { - try - { - var text = File.ReadAllText(configurationPath); - if (!string.IsNullOrEmpty(text)) - { - return JsonSerializer.Deserialize(text); - } - } - catch { } - } - - return null; - } - } -} diff --git a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/Loggers/AdapterLogger.cs b/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/Loggers/AdapterLogger.cs deleted file mode 100644 index 268c31d8..00000000 --- a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/Loggers/AdapterLogger.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. -// TrakHound Inc. licenses this file to you under the MIT license. - -using Microsoft.Extensions.Logging; -using System; - -namespace MTConnect.Applications.Loggers -{ - public class AdapterLogger - { - private readonly ILogger _logger; - - - public AdapterLogger(ILogger logger) - { - _logger = logger; - } - - - public void AdapterConnected(object sender, string message) - { - var adapterClient = (ShdrAdapterClient)sender; - _logger.LogInformation($"[Adapter] : ID = " + adapterClient.Id + " : " + message); - } - - public void AdapterDisconnected(object sender, string message) - { - var adapterClient = (ShdrAdapterClient)sender; - _logger.LogInformation($"[Adapter] : ID = " + adapterClient.Id + " : " + message); - } - - public void AdapterConnectionError(object sender, Exception exception) - { - var adapterClient = (ShdrAdapterClient)sender; - _logger.LogInformation($"[Adapter] : ID = " + adapterClient.Id + " : " + exception.Message); - } - - public void AdapterPingSent(object sender, string message) - { - var adapterClient = (ShdrAdapterClient)sender; - _logger.LogInformation($"[Adapter] : ID = " + adapterClient.Id + " : " + message); - } - - public void AdapterPongReceived(object sender, string message) - { - var adapterClient = (ShdrAdapterClient)sender; - _logger.LogInformation($"[Adapter] : ID = " + adapterClient.Id + " : " + message); - } - } -} diff --git a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/Loggers/AdapterShdrLogger.cs b/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/Loggers/AdapterShdrLogger.cs deleted file mode 100644 index 30b5b785..00000000 --- a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/Loggers/AdapterShdrLogger.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. -// TrakHound Inc. licenses this file to you under the MIT license. - -using Microsoft.Extensions.Logging; -using MTConnect.Adapters.Shdr; - -namespace MTConnect.Applications.Loggers -{ - public class AdapterShdrLogger - { - private readonly ILogger _logger; - - - public AdapterShdrLogger(ILogger logger) - { - _logger = logger; - } - - - public void AdapterProtocolReceived(object sender, string message) - { - var adapterClient = (ShdrAdapterClient)sender; - _logger.LogDebug($"[Adapter-SHDR] : ID = " + adapterClient.Id + " : " + message); - } - } -} diff --git a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/Loggers/AgentLogger.cs b/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/Loggers/AgentLogger.cs deleted file mode 100644 index 4019d9c9..00000000 --- a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/Loggers/AgentLogger.cs +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. -// TrakHound Inc. licenses this file to you under the MIT license. - -using Microsoft.Extensions.Logging; -using MTConnect.Assets; -using MTConnect.Devices; -using MTConnect.Streams; -using System; -using System.Collections.Generic; -using System.Linq; - -namespace MTConnect.Applications.Loggers -{ - public class AgentLogger - { - private readonly ILogger _logger; - - - public AgentLogger(ILogger logger) - { - _logger = logger; - } - - - public void LogInformation(string message) - { - _logger.LogInformation(message); - } - - - public void DevicesRequested(string deviceName) - { - _logger.LogInformation($"[Agent] : MTConnectDevices Requested : {deviceName}"); - } - - public void DevicesResponseSent(IDevicesResponseDocument document) - { - _logger.LogInformation($"[Agent] : MTConnectDevices Response Document Returned : {document.Header.CreationTime}"); - } - - - public void StreamsRequested(string deviceName) - { - _logger.LogInformation($"[Agent] : MTConnectStreams Requested : {deviceName}"); - } - - public void StreamsResponseSent(object sender, EventArgs args) - { - _logger.LogInformation($"[Agent] : MTConnectStreams Response Document Returned"); - } - - - public void AssetsRequested(IEnumerable assetIds) - { - var ids = ""; - if (!assetIds.IsNullOrEmpty()) - { - string.Join(";", assetIds.ToArray()); - } - - _logger.LogDebug($"[Agent] : MTConnectAssets Requested : AssetIds = " + ids); - } - - public void DeviceAssetsRequested(string deviceUuid) - { - _logger.LogDebug($"[Agent] : MTConnectAssets Requested : DeviceUuid = " + deviceUuid); - } - - public void AssetsResponseSent(IAssetsResponseDocument document) - { - _logger.LogInformation($"[Agent] : MTConnectAssets Response Document Returned : {document.Header.CreationTime}"); - } - } -} diff --git a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/Loggers/AgentMetricLogger.cs b/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/Loggers/AgentMetricLogger.cs deleted file mode 100644 index 1329ff2d..00000000 --- a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/Loggers/AgentMetricLogger.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. -// TrakHound Inc. licenses this file to you under the MIT license. - -using Microsoft.Extensions.Logging; - -namespace MTConnect.Applications.Loggers -{ - public class AgentMetricLogger - { - private readonly ILogger _logger; - - - public AgentMetricLogger(ILogger logger) - { - _logger = logger; - } - - - public void LogInformation(string message) - { - _logger.LogInformation(message); - } - } -} diff --git a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/Loggers/AgentValidationLogger.cs b/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/Loggers/AgentValidationLogger.cs deleted file mode 100644 index 24254c18..00000000 --- a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/Loggers/AgentValidationLogger.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. -// TrakHound Inc. licenses this file to you under the MIT license. - -using Microsoft.Extensions.Logging; -using MTConnect.Devices; -using MTConnect.Devices.DataItems; - -namespace MTConnect.Applications.Loggers -{ - public class AgentValidationLogger - { - private readonly ILogger _logger; - - - public AgentValidationLogger(ILogger logger) - { - _logger = logger; - } - - - public void InvalidDataItemAdded(string deviceUuid, IDataItem dataItem, ValidationResult result) - { - _logger.LogWarning($"[Agent-Validation] : Validation Failed : {deviceUuid} : {result.Message}"); - } - } -} diff --git a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/Loggers/ApplicationLogger.cs b/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/Loggers/ApplicationLogger.cs deleted file mode 100644 index 086c6646..00000000 --- a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/Loggers/ApplicationLogger.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. -// TrakHound Inc. licenses this file to you under the MIT license. - -using Microsoft.Extensions.Logging; -using System; - -namespace MTConnect.Applications.Loggers -{ - public class ApplicationLogger - { - private readonly ILogger _logger; - - - public ApplicationLogger(ILogger logger) - { - _logger = logger; - } - - - public void ApplicationException(Exception ex) - { - _logger.LogCritical($"[Application] : {ex.Message}"); - } - } -} diff --git a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/MTConnect-Agent-Http-Gateway-AspNetCore.csproj b/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/MTConnect-Agent-Http-Gateway-AspNetCore.csproj deleted file mode 100644 index f2a13258..00000000 --- a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/MTConnect-Agent-Http-Gateway-AspNetCore.csproj +++ /dev/null @@ -1,73 +0,0 @@ - - - - net6.0 - - - net6.0 - - - net6.0 - - - - MTConnect.Applications - - - - en - - - - - - - - - - - - - - - - <_WebToolingArtifacts Remove="Properties\PublishProfiles\NET-6-win-x64.pubxml" /> - <_WebToolingArtifacts Remove="Properties\PublishProfiles\NET-6-win-x86.pubxml" /> - - - - - - - - - Always - - - - - Always - - - - - - - - - - - - - - - - - Always - - - Always - - - - diff --git a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/MTConnectAgentService.cs b/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/MTConnectAgentService.cs deleted file mode 100644 index 95b18d5b..00000000 --- a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/MTConnectAgentService.cs +++ /dev/null @@ -1,305 +0,0 @@ -// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. -// TrakHound Inc. licenses this file to you under the MIT license. - -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using MTConnect.Agents; -using MTConnect.Applications.Loggers; -using MTConnect.Assets; -using MTConnect.Clients; -using MTConnect.Configurations; -using MTConnect.Devices; -using MTConnect.Devices.Components; -using MTConnect.Devices.DataItems.Events; -using MTConnect.Errors; -using MTConnect.Observations.Input; -using MTConnect.Streams; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; - -namespace MTConnect.Applications -{ - public class MTConnectAgentService : IHostedService - { - private readonly AgentGatewayConfiguration _configuration; - private readonly IMTConnectAgentBroker _mtconnectAgent; - private readonly ILogger _logger; - private readonly AgentLogger _agentLogger; - private readonly AgentMetricLogger _agentMetricLogger; - private readonly AgentValidationLogger _agentValidationLogger; - private readonly List _clients = new List(); - private System.Timers.Timer _metricsTimer; - - - public MTConnectAgentService( - AgentGatewayConfiguration configuration, - IMTConnectAgentBroker mtconnectAgent, - AgentLogger agentLogger, - AgentMetricLogger agentMetricLogger, - AgentValidationLogger agentValidationLogger, - ILogger logger - ) - { - _configuration = configuration; - _mtconnectAgent = mtconnectAgent; - _logger = logger; - _agentLogger = agentLogger; - _agentMetricLogger = agentMetricLogger; - _agentValidationLogger = agentValidationLogger; - - _mtconnectAgent.DevicesRequestReceived += agentLogger.DevicesRequested; - _mtconnectAgent.DevicesResponseSent += agentLogger.DevicesResponseSent; - _mtconnectAgent.StreamsRequestReceived += agentLogger.StreamsRequested; - _mtconnectAgent.StreamsResponseSent += agentLogger.StreamsResponseSent; - _mtconnectAgent.AssetsRequestReceived += agentLogger.AssetsRequested; - _mtconnectAgent.DeviceAssetsRequestReceived += agentLogger.DeviceAssetsRequested; - _mtconnectAgent.AssetsResponseSent += agentLogger.AssetsResponseSent; - - _mtconnectAgent.InvalidDataItemAdded += agentValidationLogger.InvalidDataItemAdded; - } - - - public async Task StartAsync(CancellationToken cancellationToken) - { - if (_mtconnectAgent.Configuration != null) - { - // Add Agent Clients - if (!_configuration.Clients.IsNullOrEmpty()) - { - foreach (var clientConfiguration in _configuration.Clients) - { - if (!string.IsNullOrEmpty(clientConfiguration.Address)) - { - var baseUri = HttpClientConfiguration.CreateBaseUri(clientConfiguration); - - var adapterComponent = new HttpAdapterComponent(clientConfiguration); - - // Add Adapter Component to Agent Device - _mtconnectAgent.Agent.AddAdapterComponent(adapterComponent); - - if (!adapterComponent.DataItems.IsNullOrEmpty()) - { - // Initialize Adapter URI Observation - var adapterUriDataItem = adapterComponent.DataItems.FirstOrDefault(o => o.Type == AdapterUriDataItem.TypeId); - if (adapterUriDataItem != null) - { - _mtconnectAgent.AddObservation(_mtconnectAgent.Uuid, adapterUriDataItem.Id, adapterComponent.Uri); - } - } - - - var agentClient = new MTConnectHttpClient(baseUri, clientConfiguration.DeviceKey); - agentClient.Interval = clientConfiguration.Interval; - agentClient.Heartbeat = clientConfiguration.Heartbeat; - _clients.Add(agentClient); - - // Subscribe to the Event handlers to receive status events - agentClient.ClientStarting += (s, e) => ClientStarting(((MTConnectHttpClient)s).Authority); - agentClient.ClientStarted += (s, e) => ClientStarted(((MTConnectHttpClient)s).Authority); - agentClient.ClientStopping += (s, e) => ClientStopping(((MTConnectHttpClient)s).Authority); - agentClient.ClientStopped += (s, e) => ClientStopped(((MTConnectHttpClient)s).Authority); - agentClient.StreamStarting += (s, streamUrl) => StreamStarting(streamUrl); - agentClient.StreamStarted += (s, streamUrl) => StreamStarted(streamUrl); - agentClient.StreamStopping += (s, streamUrl) => StreamStopping(streamUrl); - agentClient.StreamStopped += (s, streamUrl) => StreamStopped(streamUrl); - - // Subscribe to the Event handlers to receive the MTConnect documents - agentClient.ProbeReceived += (s, doc) => DevicesDocumentReceived(doc); - agentClient.CurrentReceived += (s, doc) => StreamsDocumentReceived(doc); - agentClient.SampleReceived += (s, doc) => StreamsDocumentReceived(doc); - agentClient.AssetsReceived += (s, doc) => AssetsDocumentReceived(doc); - - agentClient.Start(); - } - } - } - } - - StartMetrics(); - } - - public async Task StopAsync(CancellationToken cancellationToken) - { - // Stop all of the MTConnectClients - if (!_clients.IsNullOrEmpty()) - { - foreach (var client in _clients) - { - if (client != null) client.Stop(); - } - } - - // Stop the Metrics Timer - if (_metricsTimer != null) _metricsTimer.Dispose(); - } - - - private void AgentClientError(IErrorResponseDocument errorDocument) - { - _logger?.LogError($"MTConnect Connection : MTConnect Error Received from MTConnect Agent"); - } - - private void AgentClientConnectionError(Exception ex) - { - _logger?.LogError($"MTConnect Connection : Error Connecting to MTConnect Agent : {ex.Message}"); - } - - private void AgentClientInternalError(Exception ex) - { - _logger?.LogDebug($"MTConnect Connection : Error in MTConnectClient : {ex.Message}"); - } - - - private void ClientStarting(string url) - { - _logger?.LogInformation($"MTConnect Connection : {url} : MTConnect Client Starting.."); - } - - private void ClientStarted(string url) - { - _logger?.LogInformation($"MTConnect Connection : {url} : MTConnect Client Started"); - } - - private void ClientStopping(string url) - { - _logger?.LogInformation($"MTConnect Connection : {url} : MTConnect Client Stopping.."); - } - - private void ClientStopped(string url) - { - _logger?.LogInformation($"MTConnect Connection : {url} : MTConnect Client Stopped"); - } - - - private void StreamStarting(string url) - { - _logger?.LogInformation($"MTConnect Connection : {url} : MTConnect Stream Starting.."); - } - - private void StreamStarted(string url) - { - _logger?.LogInformation($"MTConnect Connection : {url} : MTConnect Stream Started"); - } - - private void StreamStopping(string url) - { - _logger?.LogInformation($"MTConnect Connection : {url} : MTConnect Stream Stopping.."); - } - - private void StreamStopped(string url) - { - _logger?.LogInformation($"MTConnect Connection : {url} : MTConnect Stream Stopped"); - } - - - private void DevicesDocumentReceived(IDevicesResponseDocument document) - { - if (document != null && !document.Devices.IsNullOrEmpty()) - { - foreach (var device in document.Devices) - { - _mtconnectAgent.AddDevice(device); - } - } - } - - private void StreamsDocumentReceived(IStreamsResponseDocument document) - { - if (document != null && !document.Streams.IsNullOrEmpty()) - { - foreach (var stream in document.Streams) - { - var observations = stream.Observations; - if (!observations.IsNullOrEmpty()) - { - foreach (var observation in observations) - { - var input = new ObservationInput(); - input.DataItemKey = observation.DataItemId; - input.DeviceKey = stream.Uuid; - input.Timestamp = observation.Timestamp.ToUnixTime(); - input.Values = observation.Values; - - _mtconnectAgent.AddObservation(stream.Name, input); - } - } - } - } - } - - private void AssetsDocumentReceived(IAssetsResponseDocument document) - { - if (document != null && !document.Assets.IsNullOrEmpty()) - { - foreach (var asset in document.Assets) - { - _mtconnectAgent.AddAsset(asset.DeviceUuid, asset); - } - } - } - - - private void StartMetrics() - { - if (_configuration.EnableMetrics) - { - int observationLastCount = 0; - int observationDelta = 0; - int assetLastCount = 0; - int assetDelta = 0; - var updateInterval = _mtconnectAgent.Metrics.UpdateInterval.TotalSeconds; - var windowInterval = _mtconnectAgent.Metrics.WindowInterval.TotalMinutes; - - _metricsTimer = new System.Timers.Timer(); - _metricsTimer.Interval = updateInterval * 1000; - _metricsTimer.Elapsed += (s, e) => - { - // Observations - var observationCount = _mtconnectAgent.Metrics.GetObservationCount(); - var observationAverage = _mtconnectAgent.Metrics.ObservationAverage; - observationDelta = observationCount - observationLastCount; - - _agentLogger.LogInformation("[Agent] : Observations - Delta for last " + updateInterval + " seconds: " + observationDelta); - _agentLogger.LogInformation("[Agent] : Observations - Average for last " + windowInterval + " minutes: " + Math.Round(observationAverage, 5)); - - // Assets - var assetCount = _mtconnectAgent.Metrics.GetAssetCount(); - var assetAverage = _mtconnectAgent.Metrics.AssetAverage; - assetDelta = assetCount - assetLastCount; - - _agentLogger.LogInformation("[Agent] : Assets - Delta for last " + updateInterval + " seconds: " + assetDelta); - _agentLogger.LogInformation("[Agent] : Assets - Average for last " + windowInterval + " minutes: " + Math.Round(assetAverage, 5)); - - observationLastCount = observationCount; - assetLastCount = assetCount; - }; - _metricsTimer.Start(); - } - } - - - private static string AddPort(string url, int port) - { - if (!string.IsNullOrEmpty(url) && port > 0) - { - if (url.Contains('/')) - { - var p = url.Split('/'); - if (p.Length > 1) - { - p[0] = $"{p[0]}:{port}"; - } - - return string.Join('/', p); - } - - return $"{url}:{port}"; - } - - return url; - } - } -} diff --git a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/NLog.config b/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/NLog.config deleted file mode 100644 index 791795ff..00000000 --- a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/NLog.config +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/Program.cs b/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/Program.cs deleted file mode 100644 index 9f204e22..00000000 --- a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/Program.cs +++ /dev/null @@ -1,183 +0,0 @@ -// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. -// TrakHound Inc. licenses this file to you under the MIT license. - -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.ResponseCompression; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Hosting.WindowsServices; -using Microsoft.Extensions.Logging; -using MTConnect.Agents; -using MTConnect.Applications.Loggers; -using MTConnect.Configurations; -using NLog.Web; -using System; -using System.IO; -using System.IO.Compression; -using System.Linq; - -namespace MTConnect.Applications -{ - public class Program - { - private static AgentGatewayConfiguration _configuration; - - - public static void Main(string[] args) - { - var logger = NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger(); - try - { - // Set WebApplication Options - var options = new WebApplicationOptions - { - Args = args, - ContentRootPath = WindowsServiceHelpers.IsWindowsService() ? AppContext.BaseDirectory : default - }; - - // Create WebApplication Builder - var builder = WebApplication.CreateBuilder(options); - ConfigureBuilder(builder); - AddServices(builder); - - // Create WebApplication - var app = builder.Build(); - ConfigureServices(app); - - // Run WebApplication - app.Run(); - } - catch (Exception exception) - { - //NLog: catch setup errors - logger.Fatal(exception, "Stopped program because of exception"); - throw; - } - finally - { - // Ensure to flush and stop internal timers/threads before application-exit (Avoid segmentation fault on Linux) - NLog.LogManager.Shutdown(); - } - } - - // This is the method that should be able to be used instead of CreateHostBuilder() - private static void ConfigureBuilder(WebApplicationBuilder builder) - { - // Set to allow Windows Service - builder.Host.UseWindowsService(); - - // Add Logging - builder.Host.UseNLog(); - builder.Logging.AddConsole(); - } - - private static void AddServices(WebApplicationBuilder builder) - { - // Copy Default Configuration File - string configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AgentConfiguration.JsonFilename); - string defaultPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AgentConfiguration.DefaultJsonFilename); - if (!File.Exists(configPath) && File.Exists(defaultPath)) - { - File.Copy(defaultPath, configPath); - } - - _configuration = AgentConfiguration.ReadJson(); - if (_configuration != null) - { - // Read Agent Information File - var agentInformation = MTConnectAgentInformation.Read(); - if (agentInformation == null) - { - agentInformation = new MTConnectAgentInformation(); - agentInformation.Save(); - } - - // Create MTConnectAgent - var agent = new MTConnectAgentBroker(_configuration, agentInformation.Uuid); - agent.MTConnectVersion = MTConnectVersions.Max; - agent.Start(); - builder.Services.AddSingleton(agent); - - // Individual Logger Classes - builder.Services.AddSingleton(_configuration); - builder.Services.AddSingleton(_configuration); - builder.Services.AddSingleton(); - builder.Services.AddSingleton(); - builder.Services.AddSingleton(); - - // Add the MTConnectAgentService that handles the MTConnect Agent - builder.Services.AddHostedService(); - - if (!_configuration.ResponseCompression.IsNullOrEmpty()) - { - // Add Compression Services - builder.Services.AddResponseCompression(options => - { - options.EnableForHttps = true; - - // Gzip - if (_configuration.ResponseCompression.Any(o => o == Http.HttpResponseCompression.Gzip)) - { - options.Providers.Add(); - } - - // Brotli - if (_configuration.ResponseCompression.Any(o => o == Http.HttpResponseCompression.Br)) - { - options.Providers.Add(); - } - }); - - // Gzip - if (_configuration.ResponseCompression.Any(o => o == Http.HttpResponseCompression.Gzip)) - { - builder.Services.Configure(options => { options.Level = CompressionLevel.Optimal; }); - } - - // Brotli - if (_configuration.ResponseCompression.Any(o => o == Http.HttpResponseCompression.Br)) - { - builder.Services.Configure(options => { options.Level = CompressionLevel.Optimal; }); - } - } - - if (_configuration.Port > 0) - { - builder.WebHost.UseKestrel(o => - { - o.ListenAnyIP(_configuration.Port); - }); - } - } - - // Add Controllers - builder.Services.AddControllers(); - } - - private static void ConfigureServices(WebApplication app) - { - if (app.Environment.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - else - { - app.UseExceptionHandler("/Error"); - } - - app.UseStaticFiles(); - app.UseRouting(); - - if (_configuration != null && !_configuration.ResponseCompression.IsNullOrEmpty()) - { - app.UseResponseCompression(); - } - - app.UseEndpoints(endpoints => - { - endpoints.MapControllers(); - }); - } - } -} diff --git a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/Properties/launchSettings.json b/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/Properties/launchSettings.json deleted file mode 100644 index 5248397d..00000000 --- a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/Properties/launchSettings.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:47510", - "sslPort": 0 - } - }, - "profiles": { - "MTConnect_Agent_AspNetCore": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": true, - "applicationUrl": "http://localhost:5216", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } -} diff --git a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/agent.config.default.json b/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/agent.config.default.json deleted file mode 100644 index 5d3a3047..00000000 --- a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/agent.config.default.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "port": 5002, - "serverIp": "localhost", - "clients": [ - { - "address": "https://smstestbed.nist.gov/vds/", - "port": 443, - "deviceKey": "GFAgie01", - "useSSL": true, - "heartbeat": 0 - }, - { - "address": "https://smstestbed.nist.gov/vds/", - "port": 443, - "deviceKey": "Mazak01", - "useSSL": true, - "heartbeat": 0 - }, - { - "address": "https://smstestbed.nist.gov/vds/", - "port": 443, - "deviceKey": "Mazak03", - "useSSL": true, - "heartbeat": 0 - }, - { - "address": "https://smstestbed.nist.gov/vds/", - "port": 443, - "deviceKey": "Hurco01", - "useSSL": true, - "heartbeat": 0 - } - ] -} \ No newline at end of file diff --git a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/appsettings.Development.json b/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/appsettings.Development.json deleted file mode 100644 index 770d3e93..00000000 --- a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/appsettings.Development.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "DetailedErrors": true, - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - } -} diff --git a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/appsettings.json b/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/appsettings.json deleted file mode 100644 index 10f68b8c..00000000 --- a/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore/appsettings.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - }, - "AllowedHosts": "*" -} diff --git a/applications/Agents/MTConnect-Agent-Http-Gateway/MTConnect-Agent-Http-Gateway.csproj b/applications/Agents/MTConnect-Agent-Http-Gateway/MTConnect-Agent-Http-Gateway.csproj deleted file mode 100644 index 2c815329..00000000 --- a/applications/Agents/MTConnect-Agent-Http-Gateway/MTConnect-Agent-Http-Gateway.csproj +++ /dev/null @@ -1,53 +0,0 @@ - - - - net6.0 - - - net461;net48;net6.0;net7.0 - false - None - true - - - - agent - false - Exe - MTConnect - - - - - - - - - - - - - - - - - - - - - - - Always - - - Never - - - Always - - - Never - - - - diff --git a/applications/Agents/MTConnect-Agent-Http-Gateway/Program.cs b/applications/Agents/MTConnect-Agent-Http-Gateway/Program.cs deleted file mode 100644 index 5781c277..00000000 --- a/applications/Agents/MTConnect-Agent-Http-Gateway/Program.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. -// TrakHound Inc. licenses this file to you under the MIT license. - -using MTConnect.Applications.Agents; -using System; -using System.Reflection; - -namespace MTConnect.Applications -{ - public class Program - { - // This is the Application Name shown in the Console header information - // If you are implementing this into your own application, you can change this to be more specific (ex. Fanuc MTConnect Agent, Mazak MTConnect Agent, etc.) - private const string ApplicationName = "MTConnect HTTP Gateway Agent"; - - // Copyright statement for the application. If you are implementing this into your own application, you can change this to your own copyright. - // This is just what is shown in the console header. If you want to show support for the MTConnect.NET project, you can reference it using the links in the default header - private const string ApplicationCopyright = "Copyright 2023 TrakHound Inc., All Rights Reserved"; - - public static void Main(string[] args) - { - // Print an application header to the console - PrintConsoleHeader(); - - // Create a new MTConnect Agent Application - // This handles all MTConnect Agent functionality along with - // an HTTP server, HTTP MTConnect clients, Command line arguments, Device management, Buffer management, Logging, Windows Service, and Configuration File management - var agentApplication = new MTConnectHttpAgentGatewayApplication(); - - // Run the Agent ('true' parameter blocks the call so the application does not continue) - agentApplication.Run(args, true); - } - - - private static void PrintConsoleHeader() - { - var assembly = Assembly.GetExecutingAssembly(); - var version = assembly.GetName().Version; - - Console.WriteLine("--------------------"); - Console.WriteLine(ApplicationCopyright); - Console.WriteLine(ApplicationName + " : Version " + version.ToString()); - Console.WriteLine("--------------------"); - Console.WriteLine("This application is licensed under the MIT License (https://choosealicense.com/licenses/mit/)"); - Console.WriteLine("Source code available at Github.com (https://github.com/TrakHound/MTConnect.NET)"); - Console.WriteLine("--------------------"); - } - } -} diff --git a/applications/Agents/MTConnect-Agent-Http-Gateway/ReadMe.md b/applications/Agents/MTConnect-Agent-Http-Gateway/ReadMe.md deleted file mode 100644 index cd25c90f..00000000 --- a/applications/Agents/MTConnect-Agent-Http-Gateway/ReadMe.md +++ /dev/null @@ -1,283 +0,0 @@ -![MTConnect.NET Logo](https://raw.githubusercontent.com/TrakHound/MTConnect.NET/dev/img/mtconnect-net-03-md.png) - -# MTConnect Http Gateway Agent - -[![MTConnect.NET](https://github.com/TrakHound/MTConnect.NET/actions/workflows/dotnet.yml/badge.svg)](https://github.com/TrakHound/MTConnect.NET/actions/workflows/dotnet.yml) - -## Overview -This project is a full implementation of an MTConnect Agent used to read data from industrial machine tools and devices. -This MTConnect Agent application is fully compatible with the latest **Version 2.2 of the MTConnect Standard**. -It receives data from other MTConnect Agents using HTTP, an in-memory buffer with an optional durable file system based buffer, and an Http REST interface for retrieving data. - -#### Features -- Easy setup with Windows Installers availble in the latest [Releases](https://github.com/TrakHound/MTConnect.NET/releases) -- Options to run as Windows Service or as a console application (typically for testing/debugging) -- Optional 'Durable' buffer used to retain the Agent data between application/machine restarts -- High performance / Low resource usage -- Flexible Device configurations (traditional 'devices.xml' file or 'devices' directory with individual Device files) -- On-Demand MTConnect Versioning allowing for older clients to request the version of MTConnect they are compatible with using HTTP Url parameters -- Configuration File monitoring to automatically restart the Agent upon configuration file changes -- Flexible Logging using NLog which can be used to output log information to separate files for easier analysis - - -![Traditional Agent Architecture](https://raw.githubusercontent.com/TrakHound/MTConnect.NET/master/img/mtconnect-agent-http-http-communication-white.png) - -## Download -To download the latest release as a Windows Installer, use the link below: -- [Download Latest Release Windows Installer](https://github.com/TrakHound/MTConnect.NET/releases/download/v5.1.0/TrakHound-MTConnect-Http-Gateway-Agent-Install-v5.1.0.exe) - -## Releases -Releases for this application are located under the Releases tab. The current release is listed below: -- [MTConnect Agent Current Release](https://github.com/TrakHound/MTConnect.NET/releases) - -## Source Code -This project uses the MTConnect.NET-Applications-Agents library (available on [Nuget](https://www.nuget.org/packages/MTConnect.NET-Applications-Agents)) to create an MTConnect Agent application. More information about this library can be found [Here](https://github.com/TrakHound/MTConnect.NET/tree/master/src/MTConnect.NET-Applications-Agents). The MTConnect.NET-Applications-Agents library makes creating an MTConnect Agent application simple as well as makes it easy to keep updated using Nuget. A fully functionaly MTConnect Application can be created in just a few lines of code. - -## Usage -The Agent can be run from a command line prompt or as a Windows Service using the format below: -``` -agent [help|install|install-start|start|stop|remove|debug|run|run-service] [configuration_file] [http_port] - --------------------- - -Options : - - help | Prints usage information - install | Install as a Service - install-start | Install as a Service and Start the Service - start | Start the Service - stop | Stop the Service - remove | Remove the Service - debug | Runs the Agent in the terminal (with verbose logging) - run | Runs the Agent in the terminal - run-service | Runs the Agent as a Service - -Arguments : --------------------- - - configuration_file | Specifies the Agent Configuration file to load - Default : agent.config.json - - http_port | Specifies the TCP Port to use for the HTTP Server - Note : This overrides what is read from the Configuration file -``` -#### Example 1: -Install the Agent as a Windows Service (Note: requires Administrator Privileges) - > agent install - -#### Example 2: -Install the Agent as a Windows Service using the configuration file "agent-config.json" and Starts the service (Note: requires Administrator Privileges) -> agent install-start agent-config.json - -#### Example 3: -Starts the Windows Service (Note: requires Administrator Privileges) -> agent start - -#### Example 4: -Runs the Agent in the command line prompt using verbose logging and overrides the Http Port to 5001 -> agent debug "" 5001 - -## Configuration -More information about [Configurations](https://github.com/TrakHound/MTConnect.NET/tree/master/src/MTConnect.NET-Common/Configurations). The default configuration file is shown below : -```yaml -# - HTTP Client Adapter Configuration - -# The Agent is able to receive data by reading from other MTConnect HTTP Agents -clients: -- address: https://smstestbed.nist.gov/vds/ - port: 443 - deviceKey: GFAgie01 - useSSL: true - heartbeat: 0 -- address: https://smstestbed.nist.gov/vds/ - port: 443 - deviceKey: Mazak01 - useSSL: true - heartbeat: 0 - -The server Hostname to bind to. -# Change this to the server's IP Address or hostname -server: localhost - -# The port number the agent binds to for requests. -port: 5000 - -# Configuration for Static Files that can be served from the Http Server -files: -- path: schemas - location: schemas - -# The maximum number of Observations the agent can hold in its buffer -observationBufferSize: 150000 - -# The maximum number of assets the agent can hold in its buffer -assetBufferSize: 1000 - -# Sets whether the Agent buffers are durable and retain state after restart -durable: false - -# Sets the default MTConnect version to output response documents for. -defaultVersion: 2.2 -``` - -#### HTTP Configuration - -* `port` - The port number the agent binds to for requests. - -* `serverIp` - The server IP Address to bind to. Can be used to select the interface in IPV4 or IPV6. - -* `responseCompression` - Sets the List of Encodings (ex. gzip, br, deflate) to pass to the Accept-Encoding HTTP Header - -* `maxStreamingThreads` - The maximum number of Threads to use for the Http Stream Requests - -* `allowPut` - Allow HTTP PUT or POST of data item values or assets. - -* `allowPutFrom` - Allow HTTP PUT or POST from a specific host or list of hosts. - -* `indentOutput` - Sets the default response document indendation - -* `outputComments` - Sets the default response document comments output. Comments contain descriptions from the MTConnect standard - -* `outputValidationLevel` - Sets the default response document validation level. 0 = Ignore, 1 = Warning, 2 = Strict - -* `files` - Sets the configuration for Static Files that can be served from the Http Server. For more information see () - - -#### Agent Configuration - -* `observationBufferSize` - The maximum number of Observations the agent can hold in its buffer - -* `assetBufferSize` - The maximum number of assets the agent can hold in its buffer - -* `durable` - Sets whether the Agent buffers are durable and retain state after restart - -* `useBufferCompression` - Sets whether the durable Agent buffers use Compression - -* `ignoreTimestamps` - Overwrite timestamps with the agent time. This will correct clock drift but will not give as accurate relative time since it will not take into consideration network latencies. This can be overridden on a per adapter basis. - -* `defaultVersion` - Sets the default MTConnect version to output response documents for. - -* `convertUnits` - Sets the default for Converting Units when adding Observations - -* `ignoreObservationCase` - Sets the default for Ignoring the case of Observation values. Applicable values will be converted to uppercase - -* `inputValidationLevel` - Sets the default input validation level when new Observations are added to the Agent. 0 = Ignore, 1 = Warning, 2 = Strict - -* `monitorConfigurationFiles` - Sets whether Configuration files are monitored. If enabled and a configuration file is changed, the Agent will restart - -* `configurationFileRestartInterval` - Sets the minimum time (in seconds) between Agent restarts when MonitorConfigurationFiles is enabled - -* `enableMetrics` - Sets whether Agent Metrics are captured (ex. ObserationUpdateRate, AssetUpdateRate) - - -#### Device Configuration - -* `devices` - The Path to look for the file(s) that represent the Device Information Models to load into the Agent. The path can either be a single file or a directory. The path can be absolute or relative to the executable's directory - -#### Client Configuration - -* `clients` - List of MTConnect Client connection configurations. For more information see() - -#### XML Configuration - -* `devicesNamespaces` - List of extended XML namespaces to use with MTConnectDevicesResponse documents - -* `streamsNamespaces` - List of extended XML namespaces to use with MTConnectStreamsResponse documents - -* `assetsNamespaces` - List of extended XML namespaces to use with MTConnectAssetsResponse documents - -* `errorNamespaces` - List of extended XML namespaces to use with MTConnectErrorResponse documents - - -* `devicesStyle` - List of XSLT Stylesheets to use with MTConnectDevicesResponse documents - -* `streamsStyle` - List of XSLT Stylesheets to use with MTConnectStreamsResponse documents - -* `assetsStyle` - List of XSLT Stylesheets to use with MTConnectAssetsResponse documents - -* `errorStyle` - List of XSLT Stylesheets to use with MTConnectErrorResponse documents - -#### Windows Service Configuration - -* `serviceName` - Changes the service name when installing or removing the service. This allows multiple agents to run as services on the same machine. - -* `serviceAutoStart` - Sets the Service Start Type. True = Auto | False = Manual - - -## Logging -Logging is done using [NLog](https://github.com/NLog/NLog) which allows for customized logging through the NLog.config file located in the application's install directory. The loggers are setup so that there is a separate logger for: -- **(agent-logger)** MTConnect Agent -- **(agent-validation-logger)** MTConnect Data Validation Errors -- **(http-logger)** Http Server -- **(adapter-logger)** MTConnect Adapters -- **(adapter-shdr-logger)** Raw SHDR lines read by the Adapter (used for debugging adapters) - -The default [NLog Configuration File](https://github.com/TrakHound/MTConnect.NET/blob/master/src/MTConnect.NET-Applications-Agents/NLog.config) is shown below: - -```xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -``` - -## Contribution / Feedback -- Please use the [Issues](https://github.com/TrakHound/MTConnect.NET/issues) tab to create issues for specific problems that you may encounter -- Please feel free to use the [Pull Requests](https://github.com/TrakHound/MTConnect.NET/pulls) tab for any suggested improvements to the source code -- For any other questions or feedback, please contact TrakHound directly at **info@trakhound.com**. - -## License -This application and it's source code is licensed under the [MIT License](https://choosealicense.com/licenses/mit/) and is free to use. diff --git a/applications/Agents/MTConnect-Agent-Http-Gateway/agent.config.default.yaml b/applications/Agents/MTConnect-Agent-Http-Gateway/agent.config.default.yaml deleted file mode 100644 index 3901ef57..00000000 --- a/applications/Agents/MTConnect-Agent-Http-Gateway/agent.config.default.yaml +++ /dev/null @@ -1,120 +0,0 @@ -# - HTTP Client Adapter Configuration - -# The Agent is able to receive data by reading from other MTConnect HTTP Agents -clients: -- address: https://smstestbed.nist.gov/vds/ - port: 443 - deviceKey: GFAgie01 - useSSL: true - heartbeat: 0 -- address: https://smstestbed.nist.gov/vds/ - port: 443 - deviceKey: Mazak01 - useSSL: true - heartbeat: 0 -- address: https://smstestbed.nist.gov/vds/ - port: 443 - deviceKey: Mazak03 - useSSL: true - heartbeat: 0 -- address: https://smstestbed.nist.gov/vds/ - port: 443 - deviceKey: Hurco01 - useSSL: true - heartbeat: 0 - - -# - Windows Service Configuration - -# Changes the service name when installing or removing the service. This allows multiple agents to run as services on the same machine. -serviceName: MTConnect-Agent-HTTP-Gateway - -# Sets the Service Start Type. True = Auto | False = Manual -serviceAutoStart: true - - -# - HTTP Server Configuration - -# The Agent is able to respond to requests using the Http REST protocol described in the MTConnect Standard. -# The server supports response compression and serving of Static files (Files configuration) - -# The server Hostname to bind to. -# Change this to the server's IP Address or hostname -#server: localhost - -# The port number the agent binds to for requests. -port: 5000 - -# List of Encodings (ex. gzip, br, deflate) to pass to the Accept-Encoding HTTP Header -responseCompression: -- gzip -- br - -# Allow HTTP PUT or POST of data item values or assets. -allowPut: true - -# The maximum number of Threads to use for the Http Stream Requests -# If client receives Service Unavailable : 503 HTTP Status Code, this value can be increased as needed. CPU and Memory resource usage increases as this value increases -maxStreamingThreads: 5 - -# Sets the default response document indendation -indentOutput: true - -# Sets the default response document comments output. Comments contain descriptions from the MTConnect standard -# This is typically just used for debugging or for demo purposes -outputComments: false - -# Configuration for Static Files that can be served from the Http Server -files: -- path: schemas - location: schemas -#- path: styles -# location: styles -#- path: styles/favicon.ico -# location: favicon.ico - -# Configuration for XML Stylesheets for MTConnectStreamsResponse documents (Current and Samples requests) -#streamsStyle: -# location: styles/stylesheet-streams.xsl - - -# - Buffer Configuration - -# The Agent has an internal buffer that retains the information that the Agent can respond with according to the MTConnect Standard. -# There is also a Durable File backed buffer that can retain the information in the Agent between Agent restarts - -# The maximum number of Observations the agent can hold in its buffer -observationBufferSize: 150000 - -# The maximum number of assets the agent can hold in its buffer -assetBufferSize: 1000 - -# Sets whether the Agent buffers are durable and retain state after restart -durable: false - -# Sets whether the durable Agent buffers use Compression -useBufferCompression: false - - -# - Agent Configuration - - -# Sets the default MTConnect version to output response documents for. -defaultVersion: 2.1 - -# Overwrite timestamps with the agent time. This will correct clock drift but will not give as accurate relative time since it will not take into consideration network latencies. This can be overridden on a per adapter basis. -ignoreTimestamps: false - -# Sets the default for Converting Units when adding Observations -convertUnits: true - -# Sets the default for Ignoring the case of Observation values. Applicable values will be converted to uppercase -ignoreObservationCase: true - -# Sets the default input validation level when new Observations are added to the Agent. 0 = Ignore, 1 = Warning, 2 = Strict -inputValidationLevel: Ignore - -# Sets whether Configuration files are monitored. If enabled and a configuration file is changed, the Agent will restart -monitorConfigurationFiles: true - -# Sets the minimum time (in seconds) between Agent restarts when MonitorConfigurationFiles is enabled -configurationFileRestartInterval: 2 - -# Sets whether Agent Metrics are captured (ex. ObserationUpdateRate, AssetUpdateRate) -enableMetrics: true diff --git a/applications/Agents/MTConnect-Agent-Http-Gateway/build.bat b/applications/Agents/MTConnect-Agent-Http-Gateway/build.bat deleted file mode 100644 index 65498a7e..00000000 --- a/applications/Agents/MTConnect-Agent-Http-Gateway/build.bat +++ /dev/null @@ -1,3 +0,0 @@ -dotnet build -c:Release -r:win-x86 --no-self-contained -dotnet build -c:Release -r:win-x64 --no-self-contained -"c:\Program Files (x86)\Inno Setup 6\iscc" installer.iss diff --git a/applications/Agents/MTConnect-Agent-Http-Gateway/installer.iss b/applications/Agents/MTConnect-Agent-Http-Gateway/installer.iss deleted file mode 100644 index 8bcf5310..00000000 --- a/applications/Agents/MTConnect-Agent-Http-Gateway/installer.iss +++ /dev/null @@ -1,110 +0,0 @@ -; MTConnect HTTP Gateway Agent Installer -; ------------------------------ - -#define MyAppName "MTConnect HTTP Gateway Agent" -#define MyAppVersion "1.0.0" -#define MyAppPublisher "MTConnect" -#define MyAppURL "" -#define MyAppVerName MyAppName + " " + MyAppVersion - -; File Names -#define ExeName "MTConnect-HTTP-Gateway-Agent.exe" - - -[Setup] -; NOTE: The value of AppId uniquely identifies this application. -; Do not use the same AppId value in installers for other applications. -; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) -AppId={{DE86FD16-7F02-4590-8BF0-03198CD0EB26} - -AppName={#MyAppName} -AppVersion={#MyAppVersion} -AppVerName={#MyAppName} {#MyAppVersion} -AppPublisher={#MyAppPublisher} -AppPublisherURL={#MyAppURL} -AppSupportURL={#MyAppURL} -AppUpdatesURL={#MyAppURL} -AppReadmeFile=https://github.com/TrakHound/MTConnect.NET -VersionInfoVersion={#MyAppVersion} -ArchitecturesInstallIn64BitMode=x64 - -PrivilegesRequired=admin -DisableProgramGroupPage=no -Compression=lzma -SolidCompression=yes - -; Names -DisableDirPage=auto -DisableReadyPage=no -DisableFinishedPage=no -OutputDir=bin\Publish -DefaultDirName={autopf}\{#MyAppPublisher}\MTConnect-HTTP-Gateway-Agent -UsePreviousAppDir=false -OutputBaseFilename=MTConnect-Http-Gateway-Agent-Install-v{#MyAppVersion} -UninstallDisplayName={#MyAppName} v{#MyAppVersion} -UninstallFilesDir={app}\Uninstall - -[Types] -Name: "win64net7"; Description: "Windows x64 .NET 7" -Name: "win86net7"; Description: "Windows x86 .NET 7" -Name: "win64net6"; Description: "Windows x64 .NET 6" -Name: "win86net6"; Description: "Windows x86 .NET 6" -Name: "win64net48"; Description: "Windows x64 .NET 4.8 Framework" -Name: "win86net48"; Description: "Windows x86 .NET 4.8 Framework" -Name: "win64net461"; Description: "Windows x64 .NET 4.6.1 Framework" -Name: "win86net461"; Description: "Windows x86 .NET 4.6.1 Framework" - -[Components] -Name: "win64net7"; Description: "{#MyAppVerName}"; Types: win64net7 -Name: "win86net7"; Description: "{#MyAppVerName}"; Types: win86net7 -Name: "win64net6"; Description: "{#MyAppVerName}"; Types: win64net6 -Name: "win86net6"; Description: "{#MyAppVerName}"; Types: win86net6 -Name: "win64net48"; Description: "{#MyAppVerName}"; Types: win64net48 -Name: "win86net48"; Description: "{#MyAppVerName}"; Types: win86net48 -Name: "win64net461"; Description: "{#MyAppVerName}"; Types: win64net461 -Name: "win86net461"; Description: "{#MyAppVerName}"; Types: win86net461 - - -[Languages] -Name: "english"; MessagesFile: "compiler:Default.isl" - -[Dirs] -Name: "{app}"; Permissions: everyone-full -Name: "{app}\logs"; Permissions: everyone-full -Name: "{app}\devices"; Permissions: everyone-full -Name: "{app}\styles"; Permissions: everyone-full - -[Files] - -; Program Files -Source: "bin\release\net7.0\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net7; -Source: "bin\release\net7.0\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net7; -Source: "bin\release\net6.0\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net6; -Source: "bin\release\net6.0\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net6; -Source: "bin\release\net48\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net48; -Source: "bin\release\net48\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net48; -Source: "bin\release\net461\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net461; -Source: "bin\release\net461\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net461; - - -[Run] - -; Install and Run Windows Service -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""stop""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Stopping Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""remove""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Uninstalling Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""install""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Installing Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""start""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Starting Windows Service..."; - -; Start Browser -Filename: {sys}\cmd.exe; Parameters: "/c explorer ""http://localhost:5000?outputComments=true&indentOutput=true""" ; Flags: runhidden postinstall unchecked; Description: Open Probe in Web Browser; -Filename: {sys}\cmd.exe; Parameters: "/c explorer ""http://localhost:5000/current?outputComments=true&indentOutput=true""" ; Flags: runhidden postinstall unchecked; Description: Open Current in Web Browser; -Filename: {sys}\cmd.exe; Parameters: "/c explorer ""agent.config.yaml""" ; WorkingDir: {app}; Flags: runhidden postinstall unchecked; Description: Open Agent Configuration File; -Filename: {sys}\cmd.exe; Parameters: "/c explorer ""NLog.config""" ; WorkingDir: {app}; Flags: runhidden postinstall unchecked; Description: Open Log Configuration File; -Filename: {sys}\cmd.exe; Parameters: "/c explorer ""{app}""" ; Flags: runhidden postinstall unchecked; Description: Open Install Directory; - - -[UninstallRun] - -; Stop Server Service -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""stop""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Stopping Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""remove""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Uninstalling Windows Service..."; diff --git a/applications/Agents/MTConnect-Agent-Http/MTConnect-Agent-Http.csproj b/applications/Agents/MTConnect-Agent-Http/MTConnect-Agent-Http.csproj deleted file mode 100644 index 2cf17e85..00000000 --- a/applications/Agents/MTConnect-Agent-Http/MTConnect-Agent-Http.csproj +++ /dev/null @@ -1,69 +0,0 @@ - - - - net6.0 - full - - - net461;net48;net6.0;net7.0 - false - None - true - - - net461;net462;net47;net471;net472;net48;netstandard2.0;netcoreapp3.1;net5.0;net6.0 - - - - Debug;Release;Docker - false - agent - Exe - MTConnect - MTConnect.Applications.Program - disable - - - - - - - - - - - - - - - - - - - Always - - - Never - - - Always - - - Never - - - Never - - - Never - - - Never - - - True - \ - - - - \ No newline at end of file diff --git a/applications/Agents/MTConnect-Agent-Http/Program.cs b/applications/Agents/MTConnect-Agent-Http/Program.cs deleted file mode 100644 index 58b79894..00000000 --- a/applications/Agents/MTConnect-Agent-Http/Program.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. -// TrakHound Inc. licenses this file to you under the MIT license. - -using MTConnect.Applications.Agents; -using System; -using System.Reflection; - -namespace MTConnect.Applications -{ - public class Program - { - // This is the Application Name shown in the Console header information - // If you are implementing this into your own application, you can change this to be more specific (ex. Fanuc MTConnect Agent, Mazak MTConnect Agent, etc.) - private const string ApplicationName = "MTConnect HTTP Agent"; - - // Copyright statement for the application. If you are implementing this into your own application, you can change this to your own copyright. - // This is just what is shown in the console header. If you want to show support for the MTConnect.NET project, you can reference it using the links in the default header - private const string ApplicationCopyright = "Copyright 2023 TrakHound Inc., All Rights Reserved"; - - public static void Main(string[] args) - { - // Print an application header to the console - PrintConsoleHeader(); - - // Create a new MTConnect Agent Application - // This handles all MTConnect Agent functionality along with - // an HTTP server, SHDR Adapters, Command line arguments, Device management, Buffer management, Logging, Windows Service, and Configuration File management - var agentApplication = new MTConnectShdrHttpAgentApplication(); - - // Use the regular MTConnectHttpAgentApplication if you are not using SHDR Adapters - ///var agentApplication = new MTConnectHttpAgentApplication(); - - // Run the Agent ('true' parameter blocks the call so the application does not continue) - agentApplication.Run(args, true); - - // Use the 'false' parameter if you are implementing this into an existing application or are handling blocking elsewhere - //agentApplication.Run(args, false); - - // ** This is where the rest of your application can go. ** - // For example, if you are developing the Agent to read directly from a PLC, this would be where you can place the PLC reading code - } - - - private static void PrintConsoleHeader() - { - var assembly = Assembly.GetExecutingAssembly(); - var version = assembly.GetName().Version; - - Console.WriteLine("--------------------"); - Console.WriteLine(ApplicationCopyright); - Console.WriteLine(ApplicationName + " : Version " + version.ToString()); - Console.WriteLine("--------------------"); - Console.WriteLine("This application is licensed under the MIT License (https://choosealicense.com/licenses/mit/)"); - Console.WriteLine("Source code available at Github.com (https://github.com/TrakHound/MTConnect.NET)"); - Console.WriteLine("--------------------"); - } - } -} diff --git a/applications/Agents/MTConnect-Agent-Http/Properties/launchSettings.json b/applications/Agents/MTConnect-Agent-Http/Properties/launchSettings.json deleted file mode 100644 index c9318f60..00000000 --- a/applications/Agents/MTConnect-Agent-Http/Properties/launchSettings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "profiles": { - "MTConnect-Agent-Http": { - "commandName": "Project", - "commandLineArgs": "debug" - } - } -} \ No newline at end of file diff --git a/applications/Agents/MTConnect-Agent-Http/README.md b/applications/Agents/MTConnect-Agent-Http/README.md deleted file mode 100644 index f9f2993b..00000000 --- a/applications/Agents/MTConnect-Agent-Http/README.md +++ /dev/null @@ -1,342 +0,0 @@ -![MTConnect.NET Logo](https://raw.githubusercontent.com/TrakHound/MTConnect.NET/dev/img/mtconnect-net-03-md.png) - -# MTConnect Http Agent - -[![MTConnect.NET](https://github.com/TrakHound/MTConnect.NET/actions/workflows/dotnet.yml/badge.svg)](https://github.com/TrakHound/MTConnect.NET/actions/workflows/dotnet.yml) - -## Overview -This project is a full implementation of an MTConnect Agent used to read data from industrial machine tools and devices. This MTConnect Agent application is fully compatible with the latest **Version 2.2 of the MTConnect Standard**. It uses the SHDR protocol to receive data from Adapters, an in-memory buffer with an optional durable file system based buffer, and an Http REST interface for retrieving data. - -#### Features -- Easy setup with Windows Installers availble in the latest [Releases](https://github.com/TrakHound/MTConnect.NET/releases) -- Options to run as Windows Service or as a console application (typically for testing/debugging) -- Optional 'Durable' buffer used to retain the Agent data between application/machine restarts -- High performance / Low resource usage -- Flexible Device configurations (traditional 'devices.xml' file or 'devices' directory with individual Device files) -- SHDR protocol compatibility for easy implementation with existing MTConnect Adapters -- On-Demand MTConnect Versioning allowing for older clients to request the version of MTConnect they are compatible with using HTTP Url parameters -- Configuration File monitoring to automatically restart the Agent upon configuration file changes -- Flexible Logging using NLog which can be used to output log information to separate files for easier analysis - - -![Traditional Agent Architecture](https://raw.githubusercontent.com/TrakHound/MTConnect.NET/master/img/mtconnect-agent-http-shdr-communication-white.png) - -## Download -To download the latest release as a Windows Installer, use the link below: - -- [Download Latest Release Windows Installer](https://github.com/TrakHound/MTConnect.NET/releases/download/v5.1.0/TrakHound-MTConnect-Http-Agent-Install-v5.1.0.exe) - -## Installation -Follow the steps below to install the MTConnect Agent HTTP application. - -*Note: Installer (Innosetup) source code is available and will be added to repo this in a future version* - -### Step #1 -Read through the license agreement (MIT License) and click **"I accept the agreement"** if you agree with the terms. -Then click **"Next"** to proceed to the next page. -*For more information about the MIT license click [Here](https://choosealicense.com/licenses/mit/)* - - -![screenshot](https://raw.githubusercontent.com/TrakHound/MTConnect.NET/master/img/MTConnect-Agent-HTTP/Installation/installer-license.png) - -### Step #2 -Select the directory to install the application in using the **"Browse"** button or accept the default. -Then click **"Next"** to proceed to the next page. - - -![screenshot](https://raw.githubusercontent.com/TrakHound/MTConnect.NET/master/img/MTConnect-Agent-HTTP/Installation/installer-directory.png) - -### Step #3 -Select the .NET version and Architecture (x64 or x86) to install the application for -Then click **"Next"** to proceed to the next page. - - -![screenshot](https://raw.githubusercontent.com/TrakHound/MTConnect.NET/master/img/MTConnect-Agent-HTTP/Installation/installer-components.png) - -### Step #4 -Review the list of components that will be installed and if correct then click **"Install"** to begin -Then click **"Next"** to proceed to the next page. - - -![screenshot](https://raw.githubusercontent.com/TrakHound/MTConnect.NET/master/img/MTConnect-Agent-HTTP/Installation/installer-review.png) - -### Step #5 -Select the **"Open Probe in Web Browser"** and/or **"Open Current in Web Browser"** to view the Agent output and verify access -Then click **"Next"** to proceed to the next page. - - -![screenshot](https://raw.githubusercontent.com/TrakHound/MTConnect.NET/master/img/MTConnect-Agent-HTTP/Installation/installer-finish.png) - -### Step #6 -View the Probe and Current requests in a Web Browser -- [Probe - http://localhost:5000](http://localhost:5000/) -- [Current - http://localhost:5000/current](http://localhost:5000/current) - -#### Probe Request -![screenshot](https://raw.githubusercontent.com/TrakHound/MTConnect.NET/master/img/MTConnect-Agent-HTTP/Browser/probe-request-web-browser.png) - -#### Current Request -![screenshot](https://raw.githubusercontent.com/TrakHound/MTConnect.NET/master/img/MTConnect-Agent-HTTP/Browser/current-request-web-browser.png) - - -## Usage -The Agent can be run from a command line prompt or as a Windows Service using the format below: -``` -agent [help|install|install-start|start|stop|remove|debug|run|run-service] [configuration_file] [http_port] - --------------------- - -Options : - - help | Prints usage information - install | Install as a Service - install-start | Install as a Service and Start the Service - start | Start the Service - stop | Stop the Service - remove | Remove the Service - debug | Runs the Agent in the terminal (with verbose logging) - run | Runs the Agent in the terminal - run-service | Runs the Agent as a Service - -Arguments : --------------------- - - configuration_file | Specifies the Agent Configuration file to load - Default : agent.config.json - - http_port | Specifies the TCP Port to use for the HTTP Server - Note : This overrides what is read from the Configuration file -``` -#### Example 1: -Install the Agent as a Windows Service (Note: requires Administrator Privileges) - > agent install - -#### Example 2: -Install the Agent as a Windows Service using the configuration file "agent-config.json" and Starts the service (Note: requires Administrator Privileges) -> agent install-start agent-config.json - -#### Example 3: -Starts the Windows Service (Note: requires Administrator Privileges) -> agent start - -#### Example 4: -Runs the Agent in the command line prompt using verbose logging and overrides the Http Port to 5001 -> agent debug "" 5001 - -## Configuration -More information about [Configurations](https://github.com/TrakHound/MTConnect.NET/tree/master/src/MTConnect.NET-Common/Configurations). The default configuration file is shown below : -```yaml -# - Device Configuration - -devices: devices - -# - SHDR Adapter Configuration - -# The Agent is able to receive data through a TCP port using the SHDR protocol -adapters: -- hostname: localhost - port: 7878 - reconnectInterval: 1000 - -# The server Hostname to bind to. -# Change this to the server's IP Address or hostname -server: localhost - -# The port number the agent binds to for requests. -port: 5000 - -# Configuration for Static Files that can be served from the Http Server -files: -- path: schemas - location: schemas - -# The maximum number of Observations the agent can hold in its buffer -observationBufferSize: 150000 - -# The maximum number of assets the agent can hold in its buffer -assetBufferSize: 1000 - -# Sets whether the Agent buffers are durable and retain state after restart -durable: false - -# Sets the default MTConnect version to output response documents for. -defaultVersion: 2.2 -``` - -#### HTTP Configuration - -* `port` - The port number the agent binds to for requests. - -* `serverIp` - The server IP Address to bind to. Can be used to select the interface in IPV4 or IPV6. - -* `responseCompression` - Sets the List of Encodings (ex. gzip, br, deflate) to pass to the Accept-Encoding HTTP Header - -* `maxStreamingThreads` - The maximum number of Threads to use for the Http Stream Requests - -* `allowPut` - Allow HTTP PUT or POST of data item values or assets. - -* `allowPutFrom` - Allow HTTP PUT or POST from a specific host or list of hosts. - -* `indentOutput` - Sets the default response document indendation - -* `outputComments` - Sets the default response document comments output. Comments contain descriptions from the MTConnect standard - -* `outputValidationLevel` - Sets the default response document validation level. 0 = Ignore, 1 = Warning, 2 = Strict - -* `files` - Sets the configuration for Static Files that can be served from the Http Server. For more information see () - - -#### Agent Configuration - -* `observationBufferSize` - The maximum number of Observations the agent can hold in its buffer - -* `assetBufferSize` - The maximum number of assets the agent can hold in its buffer - -* `durable` - Sets whether the Agent buffers are durable and retain state after restart - -* `useBufferCompression` - Sets whether the durable Agent buffers use Compression - -* `ignoreTimestamps` - Overwrite timestamps with the agent time. This will correct clock drift but will not give as accurate relative time since it will not take into consideration network latencies. This can be overridden on a per adapter basis. - -* `defaultVersion` - Sets the default MTConnect version to output response documents for. - -* `convertUnits` - Sets the default for Converting Units when adding Observations - -* `ignoreObservationCase` - Sets the default for Ignoring the case of Observation values. Applicable values will be converted to uppercase - -* `inputValidationLevel` - Sets the default input validation level when new Observations are added to the Agent. 0 = Ignore, 1 = Warning, 2 = Strict - -* `monitorConfigurationFiles` - Sets whether Configuration files are monitored. If enabled and a configuration file is changed, the Agent will restart - -* `configurationFileRestartInterval` - Sets the minimum time (in seconds) between Agent restarts when MonitorConfigurationFiles is enabled - -* `enableMetrics` - Sets whether Agent Metrics are captured (ex. ObserationUpdateRate, AssetUpdateRate) - - -#### Device Configuration - -* `devices` - The Path to look for the file(s) that represent the Device Information Models to load into the Agent. The path can either be a single file or a directory. The path can be absolute or relative to the executable's directory - -#### Adapter Configuration - -* `adapters` - List of SHDR Adapter connection configurations. For more information see() - -* `allowShdrDevice` - Sets whether a Device Model can be sent from an SHDR Adapter - -* `preserveUuid` - Do not overwrite the UUID with the UUID from the adapter, preserve the UUID for the Device. This can be overridden on a per adapter basis. - -* `suppressIpAddress` - Suppress the Adapter IP Address and port when creating the Agent Device ids and names for 1.7. This applies to all adapters. - -* `timeout` - The amount of time (in milliseconds) an adapter can be silent before it is disconnected. - -* `reconnectInterval` - The amount of time (in milliseconds) between adapter reconnection attempts. - -#### XML Configuration - -* `devicesNamespaces` - List of extended XML namespaces to use with MTConnectDevicesResponse documents - -* `streamsNamespaces` - List of extended XML namespaces to use with MTConnectStreamsResponse documents - -* `assetsNamespaces` - List of extended XML namespaces to use with MTConnectAssetsResponse documents - -* `errorNamespaces` - List of extended XML namespaces to use with MTConnectErrorResponse documents - - -* `devicesStyle` - List of XSLT Stylesheets to use with MTConnectDevicesResponse documents - -* `streamsStyle` - List of XSLT Stylesheets to use with MTConnectStreamsResponse documents - -* `assetsStyle` - List of XSLT Stylesheets to use with MTConnectAssetsResponse documents - -* `errorStyle` - List of XSLT Stylesheets to use with MTConnectErrorResponse documents - -#### Windows Service Configuration - -* `serviceName` - Changes the service name when installing or removing the service. This allows multiple agents to run as services on the same machine. - -* `serviceAutoStart` - Sets the Service Start Type. True = Auto | False = Manual - - -## Logging -Logging is done using [NLog](https://github.com/NLog/NLog) which allows for customized logging through the NLog.config file located in the application's install directory. The loggers are setup so that there is a separate logger for: -- **(agent-logger)** MTConnect Agent -- **(agent-validation-logger)** MTConnect Data Validation Errors -- **(http-logger)** Http Server -- **(adapter-logger)** MTConnect Adapters -- **(adapter-shdr-logger)** Raw SHDR lines read by the Adapter (used for debugging adapters) - -The default [NLog Configuration File](https://github.com/TrakHound/MTConnect.NET/blob/master/src/MTConnect.NET-Applications-Agents/NLog.config) is shown below: - -```xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -``` - -## Releases -Releases for this application are located under the Releases tab. The current release is listed below: -- [MTConnect Agent Current Release](https://github.com/TrakHound/MTConnect.NET/releases) - -## Source Code -This project uses the MTConnect.NET-Applications-Agents library (available on [Nuget](https://www.nuget.org/packages/MTConnect.NET-Applications-Agents)) to create an MTConnect Agent application. More information about this library can be found [Here](https://github.com/TrakHound/MTConnect.NET/tree/master/src/MTConnect.NET-Applications-Agents). The MTConnect.NET-Applications-Agents library makes creating an MTConnect Agent application simple as well as makes it easy to keep updated using Nuget. A fully functionaly MTConnect Application can be created in just a few lines of code. - -## Contribution / Feedback -- Please use the [Issues](https://github.com/TrakHound/MTConnect.NET/issues) tab to create issues for specific problems that you may encounter -- Please feel free to use the [Pull Requests](https://github.com/TrakHound/MTConnect.NET/pulls) tab for any suggested improvements to the source code -- For any other questions or feedback, please contact TrakHound directly at **info@trakhound.com**. - -## License -This application and it's source code is licensed under the [MIT License](https://choosealicense.com/licenses/mit/) and is free to use. diff --git a/applications/Agents/MTConnect-Agent-Http/agent.config.default.yaml b/applications/Agents/MTConnect-Agent-Http/agent.config.default.yaml deleted file mode 100644 index 89649e10..00000000 --- a/applications/Agents/MTConnect-Agent-Http/agent.config.default.yaml +++ /dev/null @@ -1,112 +0,0 @@ -# - Device Configuration - -# The Path to look for the file(s) that represent the Device Information Models to load into the Agent. -# The path can either be a single file or a directory. -# The path can be absolute or relative to the executable's directory -devices: devices - -# - SHDR Adapter Configuration - -# The Agent is able to receive data through a TCP port using the SHDR protocol -adapters: -- hostname: localhost - port: 7878 - reconnectInterval: 1000 - -# Sets whether a Device Model can be sent from an SHDR Adapter -allowShdrDevice: false - - -# - Windows Service Configuration - -# Changes the service name when installing or removing the service. This allows multiple agents to run as services on the same machine. -serviceName: MTConnect-Agent-HTTP - -# Sets the Service Start Type. True = Auto | False = Manual -serviceAutoStart: true - - -# - HTTP Server Configuration - -# The Agent is able to respond to requests using the Http REST protocol described in the MTConnect Standard. -# The server supports response compression and serving of Static files (Files configuration) - -# The server Hostname to bind to. -# Change this to the server's IP Address or hostname -#server: localhost - -# The port number the agent binds to for requests. -port: 5000 - -# List of Encodings (ex. gzip, br, deflate) to pass to the Accept-Encoding HTTP Header -responseCompression: -- gzip -- br - -# Allow HTTP PUT or POST of data item values or assets. -allowPut: true - -# The maximum number of Threads to use for the Http Stream Requests -# If client receives Service Unavailable : 503 HTTP Status Code, this value can be increased as needed. CPU and Memory resource usage increases as this value increases -maxStreamingThreads: 5 - -# Sets the default response document indendation -indentOutput: true - -# Sets the default response document comments output. Comments contain descriptions from the MTConnect standard -# This is typically just used for debugging or for demo purposes -outputComments: false - -# Configuration for Static Files that can be served from the Http Server -files: -- path: schemas - location: schemas -#- path: styles -# location: styles -#- path: styles/favicon.ico -# location: favicon.ico - -# Configuration for XML Stylesheets for MTConnectStreamsResponse documents (Current and Samples requests) -#streamsStyle: -# location: styles/stylesheet-streams.xsl - - -# - Buffer Configuration - -# The Agent has an internal buffer that retains the information that the Agent can respond with according to the MTConnect Standard. -# There is also a Durable File backed buffer that can retain the information in the Agent between Agent restarts - -# The maximum number of Observations the agent can hold in its buffer -observationBufferSize: 150000 - -# The maximum number of assets the agent can hold in its buffer -assetBufferSize: 1000 - -# Sets whether the Agent buffers are durable and retain state after restart -durable: false - -# Sets whether the durable Agent buffers use Compression -useBufferCompression: false - - -# - Agent Configuration - - -# Sets the default MTConnect version to output response documents for. -defaultVersion: 2.1 - -# Overwrite timestamps with the agent time. This will correct clock drift but will not give as accurate relative time since it will not take into consideration network latencies. This can be overridden on a per adapter basis. -ignoreTimestamps: false - -# Sets the default for Converting Units when adding Observations -convertUnits: true - -# Sets the default for Ignoring the case of Observation values. Applicable values will be converted to uppercase -ignoreObservationCase: true - -# Sets the default input validation level when new Observations are added to the Agent. 0 = Ignore, 1 = Warning, 2 = Strict -inputValidationLevel: Ignore - -# Sets whether Configuration files are monitored. If enabled and a configuration file is changed, the Agent will restart -monitorConfigurationFiles: true - -# Sets the minimum time (in seconds) between Agent restarts when MonitorConfigurationFiles is enabled -configurationFileRestartInterval: 2 - -# Sets whether Agent Metrics are captured (ex. ObserationUpdateRate, AssetUpdateRate) -enableMetrics: true diff --git a/applications/Agents/MTConnect-Agent-Http/build.bat b/applications/Agents/MTConnect-Agent-Http/build.bat deleted file mode 100644 index 65498a7e..00000000 --- a/applications/Agents/MTConnect-Agent-Http/build.bat +++ /dev/null @@ -1,3 +0,0 @@ -dotnet build -c:Release -r:win-x86 --no-self-contained -dotnet build -c:Release -r:win-x64 --no-self-contained -"c:\Program Files (x86)\Inno Setup 6\iscc" installer.iss diff --git a/applications/Agents/MTConnect-Agent-Http/devices/device-mazak.xml b/applications/Agents/MTConnect-Agent-Http/devices/device-mazak.xml deleted file mode 100644 index f25afa33..00000000 --- a/applications/Agents/MTConnect-Agent-Http/devices/device-mazak.xml +++ /dev/null @@ -1,450 +0,0 @@ - - Mill w/SMooth-G - - - - - 0 0 0 - 0 0 0 - - - - - 0 0 0 - 0 0 0 - - - - - - - 2.0 3.0 4.0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - spindle_speed - - - - - - - - - - - - - - - - 0.5 - - - - - - - - - - - - 200.0 - 0.0 - - - - - - - - - - - - - - - - 0.5 - - - - - - - - - - - - - - - - - 3 - - - - - - 0.5 - - - - - - - - - - - The linears Z kinematics - 100.0 101.0 102.0 - 0.0 0.1 1.0 - - - - - - - - 3 - - - - - - - - - CONTOUR - INDEX - - - - - - - - - - - - - 3 - - - - - 3 - - - - - - - 5 - - - - - 0.5 - - - - - - - SPINDLE - INDEX - - - - - - - - - - - - - - - - The spindle kinematics - - 10.0 20.0 30.0 - 90.0 0.0 180 - - 0.0 0.5 1.0 - - - - 10000 - 100 - 1000 - - - 1000 - -1000 - 100 - 500 - -500 - 200 - -200 - - - - 500 - 50 - -500 - - - 500 - -500 - 10 - 200 - -200 - - - 500 - -500 - 200 - -200 - - - - - - - - - - - - - - - - - - - - - 101 102 103 - - - - 10 10 10 - 90 0 90 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - A Complex Workpiece Offset Table - - - Some Pressure thing - - - Pressure of the P - - - - - - - - - - - - - - Spindle Angle - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0.5 - - - - - - - - - - - - - - - - - - - - - - - - 0.5 - - - - - - - - 2.02 - 2010-05-16 - 2010-05-16 - WS - - - A/D With Thermister - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/applications/Agents/MTConnect-Agent-Http/devices/device-okuma.xml b/applications/Agents/MTConnect-Agent-Http/devices/device-okuma.xml deleted file mode 100644 index 54444a05..00000000 --- a/applications/Agents/MTConnect-Agent-Http/devices/device-okuma.xml +++ /dev/null @@ -1,163 +0,0 @@ - - - Okuma MT Connect Adapter - Lathe - - - - - - - - - - - - - - - - - - SPINDLE - - - - - - - - - - - - - - - - SPINDLE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/applications/Agents/MTConnect-Agent-Http/devices/dummy.xml b/applications/Agents/MTConnect-Agent-Http/devices/dummy.xml deleted file mode 100644 index fba4fd3a..00000000 --- a/applications/Agents/MTConnect-Agent-Http/devices/dummy.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - Okuma MT Connect Adapter - Lathe - - - - - - - - - - - - - - SPINDLE - - - - - - - - - - - - - - - - SPINDLE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/applications/Agents/MTConnect-Agent-Http/installer.iss b/applications/Agents/MTConnect-Agent-Http/installer.iss deleted file mode 100644 index 689e669b..00000000 --- a/applications/Agents/MTConnect-Agent-Http/installer.iss +++ /dev/null @@ -1,111 +0,0 @@ -; MTConnect HTTP Agent Installer -; ------------------------------ - -#define MyAppName "MTConnect HTTP Agent" -#define MyAppVersion "1.0.0" -#define MyAppPublisher "MTConnect" -#define MyAppURL "" -#define MyAppVerName MyAppName + " " + MyAppVersion - -; File Names -#define ExeName "MTConnect-HTTP-Agent.exe" - - -[Setup] -; NOTE: The value of AppId uniquely identifies this application. -; Do not use the same AppId value in installers for other applications. -; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) -AppId={{CB240583-B854-42D3-BBAC-2C80F179D48D} - -AppName={#MyAppName} -AppVersion={#MyAppVersion} -AppVerName={#MyAppName} {#MyAppVersion} -AppPublisher={#MyAppPublisher} -AppPublisherURL={#MyAppURL} -AppSupportURL={#MyAppURL} -AppUpdatesURL={#MyAppURL} -AppReadmeFile=https://github.com/TrakHound/MTConnect.NET -VersionInfoVersion={#MyAppVersion} -ArchitecturesInstallIn64BitMode=x64 - -PrivilegesRequired=admin -DisableProgramGroupPage=no -Compression=lzma -SolidCompression=yes - -; Names -DisableDirPage=auto -DisableReadyPage=no -DisableFinishedPage=no -OutputDir=bin\Publish -DefaultDirName={autopf}\{#MyAppPublisher}\MTConnect-HTTP-Agent -UsePreviousAppDir=false -OutputBaseFilename=MTConnect-Http-Agent-Install-v{#MyAppVersion} -UninstallDisplayName={#MyAppName} v{#MyAppVersion} -UninstallFilesDir={app}\Uninstall - -[Types] -Name: "win64net7"; Description: "Windows x64 .NET 7" -Name: "win86net7"; Description: "Windows x86 .NET 7" -Name: "win64net6"; Description: "Windows x64 .NET 6" -Name: "win86net6"; Description: "Windows x86 .NET 6" -Name: "win64net48"; Description: "Windows x64 .NET 4.8 Framework" -Name: "win86net48"; Description: "Windows x86 .NET 4.8 Framework" -Name: "win64net461"; Description: "Windows x64 .NET 4.6.1 Framework" -Name: "win86net461"; Description: "Windows x86 .NET 4.6.1 Framework" - -[Components] -Name: "win64net7"; Description: "{#MyAppVerName}"; Types: win64net7 -Name: "win86net7"; Description: "{#MyAppVerName}"; Types: win86net7 -Name: "win64net6"; Description: "{#MyAppVerName}"; Types: win64net6 -Name: "win86net6"; Description: "{#MyAppVerName}"; Types: win86net6 -Name: "win64net48"; Description: "{#MyAppVerName}"; Types: win64net48 -Name: "win86net48"; Description: "{#MyAppVerName}"; Types: win86net48 -Name: "win64net461"; Description: "{#MyAppVerName}"; Types: win64net461 -Name: "win86net461"; Description: "{#MyAppVerName}"; Types: win86net461 -Name: "configuration"; Description: "Configuration Files"; Types: win86net461 win64net461 win86net48 win64net48 win86net6 win64net6 win86net7 win64net7 - - -[Languages] -Name: "english"; MessagesFile: "compiler:Default.isl" - -[Dirs] -Name: "{app}"; Permissions: everyone-full -Name: "{app}\logs"; Permissions: everyone-full -Name: "{app}\devices"; Permissions: everyone-full -Name: "{app}\styles"; Permissions: everyone-full - -[Files] - -; Program Files -Source: "bin\release\net7.0\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net7; -Source: "bin\release\net7.0\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net7; -Source: "bin\release\net6.0\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net6; -Source: "bin\release\net6.0\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net6; -Source: "bin\release\net48\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net48; -Source: "bin\release\net48\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net48; -Source: "bin\release\net461\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net461; -Source: "bin\release\net461\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net461; - - -[Run] - -; Install and Run Windows Service -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""stop""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Stopping Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""remove""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Uninstalling Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""install""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Installing Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""start""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Starting Windows Service..."; - -; Start Browser -Filename: {sys}\cmd.exe; Parameters: "/c explorer ""http://localhost:5000?outputComments=true&indentOutput=true""" ; Flags: runhidden postinstall unchecked; Description: Open Probe in Web Browser; -Filename: {sys}\cmd.exe; Parameters: "/c explorer ""http://localhost:5000/current?outputComments=true&indentOutput=true""" ; Flags: runhidden postinstall unchecked; Description: Open Current in Web Browser; -Filename: {sys}\cmd.exe; Parameters: "/c explorer ""agent.config.yaml""" ; WorkingDir: {app}; Flags: runhidden postinstall unchecked; Description: Open Agent Configuration File; -Filename: {sys}\cmd.exe; Parameters: "/c explorer ""NLog.config""" ; WorkingDir: {app}; Flags: runhidden postinstall unchecked; Description: Open Log Configuration File; -Filename: {sys}\cmd.exe; Parameters: "/c explorer ""{app}""" ; Flags: runhidden postinstall unchecked; Description: Open Install Directory; - - -[UninstallRun] - -; Stop Server Service -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""stop""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Stopping Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""remove""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Uninstalling Windows Service..."; diff --git a/applications/Agents/MTConnect-Agent-MQTT-Broker-Gateway/MTConnect-Agent-MQTT-Broker-Gateway.csproj b/applications/Agents/MTConnect-Agent-MQTT-Broker-Gateway/MTConnect-Agent-MQTT-Broker-Gateway.csproj deleted file mode 100644 index f3054d38..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Broker-Gateway/MTConnect-Agent-MQTT-Broker-Gateway.csproj +++ /dev/null @@ -1,47 +0,0 @@ - - - - net6.0 - - - net461;net48;net6.0;net7.0 - false - None - true - - - - agent - false - Exe - MTConnect - - - - - - - - - - - - - - - - - - - - - - - Always - - - Always - - - - diff --git a/applications/Agents/MTConnect-Agent-MQTT-Broker-Gateway/Program.cs b/applications/Agents/MTConnect-Agent-MQTT-Broker-Gateway/Program.cs deleted file mode 100644 index c1e9ceef..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Broker-Gateway/Program.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. -// TrakHound Inc. licenses this file to you under the MIT license. - -using MTConnect.Applications.Agents; -using System; -using System.Reflection; - -namespace MTConnect.Applications -{ - public class Program - { - // This is the Application Name shown in the Console header information - // If you are implementing this into your own application, you can change this to be more specific (ex. Fanuc MTConnect Agent, Mazak MTConnect Agent, etc.) - private const string ApplicationName = "MTConnect MQTT Broker Gateway Agent"; - - // Copyright statement for the application. If you are implementing this into your own application, you can change this to your own copyright. - // This is just what is shown in the console header. If you want to show support for the MTConnect.NET project, you can reference it using the links in the default header - private const string ApplicationCopyright = "Copyright 2023 TrakHound Inc., All Rights Reserved"; - - public static void Main(string[] args) - { - // Print an application header to the console - PrintConsoleHeader(); - - // Create a new MTConnect Agent Application - // This handles all MTConnect Agent functionality along with - // an MQTT server, HTTP MTConnect clients, Command line arguments, Device management, Buffer management, Logging, Windows Service, and Configuration File management - var agentApplication = new MTConnectMqttBrokerAgentGatewayApplication(); - - // Run the Agent ('true' parameter blocks the call so the application does not continue) - agentApplication.Run(args, true); - } - - - private static void PrintConsoleHeader() - { - var assembly = Assembly.GetExecutingAssembly(); - var version = assembly.GetName().Version; - - Console.WriteLine("--------------------"); - Console.WriteLine(ApplicationCopyright); - Console.WriteLine(ApplicationName + " : Version " + version.ToString()); - Console.WriteLine("--------------------"); - Console.WriteLine("This application is licensed under the MIT License (https://choosealicense.com/licenses/mit/)"); - Console.WriteLine("Source code available at Github.com (https://github.com/TrakHound/MTConnect.NET)"); - Console.WriteLine("--------------------"); - } - } -} diff --git a/applications/Agents/MTConnect-Agent-MQTT-Broker-Gateway/Properties/launchSettings.json b/applications/Agents/MTConnect-Agent-MQTT-Broker-Gateway/Properties/launchSettings.json deleted file mode 100644 index 8b9ba22a..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Broker-Gateway/Properties/launchSettings.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "profiles": { - "MTConnect-Agent-MQTT-Broker-Gateway": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "https://localhost:59481;http://localhost:59482" - } - } -} \ No newline at end of file diff --git a/applications/Agents/MTConnect-Agent-MQTT-Broker-Gateway/ReadMe.md b/applications/Agents/MTConnect-Agent-MQTT-Broker-Gateway/ReadMe.md deleted file mode 100644 index c6933886..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Broker-Gateway/ReadMe.md +++ /dev/null @@ -1,285 +0,0 @@ -![MTConnect.NET Logo](https://raw.githubusercontent.com/TrakHound/MTConnect.NET/dev/img/mtconnect-net-03-md.png) - -# MTConnect MQTT Broker Gateway Agent - -[![MTConnect.NET](https://github.com/TrakHound/MTConnect.NET/actions/workflows/dotnet.yml/badge.svg)](https://github.com/TrakHound/MTConnect.NET/actions/workflows/dotnet.yml) - -## Overview -This project is a full implementation of an MTConnect Agent used to read data from industrial machine tools and devices. -This MTConnect Agent application is fully compatible with the latest **Version 2.2 of the MTConnect Standard**. -It receives data from other MTConnect Agents using HTTP and a built-in MQTT broker. - -#### Features -- MQTT support with built-in broker -- Reads from other HTTP MTConnect Agents for easy implementation of MQTT with existing MTConnect Agents -- Easy setup with Windows Installers availble in the latest [Releases](https://github.com/TrakHound/MTConnect.NET/releases) -- Options to run as Windows Service or as a console application (typically for testing/debugging) -- High performance / Low resource usage -- Configuration File monitoring to automatically restart the Agent upon configuration file changes -- Flexible Logging using NLog which can be used to output log information to separate files for easier analysis - - -![Traditional Agent Architecture](https://raw.githubusercontent.com/TrakHound/MTConnect.NET/master/img/mtconnect-agent-http-mqtt-communication-white.png) - -## Download -To download the latest release as a Windows Installer, use the link below: -- [Download Latest Release Windows Installer](https://github.com/TrakHound/MTConnect.NET/releases/download/v5.1.0/TrakHound-MTConnect-Mqtt-Broker-Gateway-Agent-Install-v5.1.0.exe) - -## Releases -Releases for this application are located under the Releases tab. The current release is listed below: -- [MTConnect Agent Current Release](https://github.com/TrakHound/MTConnect.NET/releases) - -## Source Code -This project uses the MTConnect.NET-Applications-Agents library (available on [Nuget](https://www.nuget.org/packages/MTConnect.NET-Applications-Agents)) to create an MTConnect Agent application. More information about this library can be found [Here](https://github.com/TrakHound/MTConnect.NET/tree/master/src/MTConnect.NET-Applications-Agents). The MTConnect.NET-Applications-Agents library makes creating an MTConnect Agent application simple as well as makes it easy to keep updated using Nuget. A fully functionaly MTConnect Application can be created in just a few lines of code. - -## Usage -The Agent can be run from a command line prompt or as a Windows Service using the format below: -``` -agent [help|install|install-start|start|stop|remove|debug|run|run-service] [configuration_file] [mqtt_port] - --------------------- - -Options : - - help | Prints usage information - install | Install as a Service - install-start | Install as a Service and Start the Service - start | Start the Service - stop | Stop the Service - remove | Remove the Service - debug | Runs the Agent in the terminal (with verbose logging) - run | Runs the Agent in the terminal - run-service | Runs the Agent as a Service - -Arguments : --------------------- - - configuration_file | Specifies the Agent Configuration file to load - Default : agent.config.json - - mqtt_port | Specifies the TCP Port to use for the MQTT broker - Note : This overrides what is read from the Configuration file -``` -#### Example 1: -Install the Agent as a Windows Service (Note: requires Administrator Privileges) - > agent install - -#### Example 2: -Install the Agent as a Windows Service using the configuration file "agent-config.json" and Starts the service (Note: requires Administrator Privileges) -> agent install-start agent-config.json - -#### Example 3: -Starts the Windows Service (Note: requires Administrator Privileges) -> agent start - -#### Example 4: -Runs the Agent in the command line prompt using verbose logging and overrides the MQTT Port to 1884 -> agent debug "" 1884 - -## MQTT Topic Structure -For more information on MQTT Topics [Click Here](https://github.com/TrakHound/MTConnect.NET/tree/master/src/MTConnect.NET-MQTT) - -#### Devices -``` -MTConnect/Devices/[DEVICE_UUID]/Device -``` - -#### Observations -``` -MTConnect/Devices/[DEVICE_UUID]/Observations/[COMPONENT_TYPE]/[COMPONENT_ID]/[DATA_ITEM_CATEGORY]/[DATA_ITEM_TYPE]/[DATA_ITEM_ID] -MTConnect/Devices/[DEVICE_UUID]/Observations/[COMPONENT_TYPE]/[COMPONENT_ID]/[DATA_ITEM_CATEGORY]/[DATA_ITEM_TYPE]/SubTypes/[DATA_ITEM_SUBTYPE]/[DATA_ITEM_ID] -``` -##### Conditions -Condition messages are sent as an array of Observations since a Condition may have multiple Fault States. This is similar to how the Current request functions in an HTTP Agent. - -#### Assets -``` -MTConnect/Devices/[DEVICE_UUID]/Assets/[ASSET_TYPE]/[ASSET_ID] -MTConnect/Assets/[ASSET_TYPE]/[ASSET_ID] -``` -> Note: Assets are sent to two topics. One for the "Global" assets and one for the Device that the Asset was added to - -#### Agent -The Agent topic contains information that would normally be in the Header of a Response Document from an HTTP Agent. -``` -MTConnect/Assets/[AGENT_UUID] -``` - -## Configuration -More information about [Configurations](https://github.com/TrakHound/MTConnect.NET/tree/master/src/MTConnect.NET-Common/Configurations). The default configuration file is shown below : - -```yaml -# - HTTP Client Adapter Configuration - -# The Agent is able to receive data by reading from other MTConnect HTTP Agents -clients: -- address: https://smstestbed.nist.gov/vds/ - port: 443 - deviceKey: GFAgie01 - useSSL: true - heartbeat: 0 -- address: https://smstestbed.nist.gov/vds/ - port: 443 - deviceKey: Mazak01 - useSSL: true - heartbeat: 0 - -# - MQTT Configuration - - -# The hostname of the MQTT broker to publish messages to -server: localhost - -# The port number of the MQTT broker to publish messages to -port: 1883 -``` - -#### MQTT Configuration - -* `port` - The port number of the MQTT broker. - -* `server` - The server hostname of the MQTT broker. - -* `username` - The username of the MQTT broker. - -* `password` - The password of the MQTT broker. - -* `useTls` - Sets whether to use TLS in connections to the MQTT broker. - -#### Agent Configuration - -* `observationBufferSize` - The maximum number of Observations the agent can hold in its buffer - -* `assetBufferSize` - The maximum number of assets the agent can hold in its buffer - -* `durable` - Sets whether the Agent buffers are durable and retain state after restart - -* `useBufferCompression` - Sets whether the durable Agent buffers use Compression - -* `ignoreTimestamps` - Overwrite timestamps with the agent time. This will correct clock drift but will not give as accurate relative time since it will not take into consideration network latencies. This can be overridden on a per adapter basis. - -* `defaultVersion` - Sets the default MTConnect version to output response documents for. - -* `convertUnits` - Sets the default for Converting Units when adding Observations - -* `ignoreObservationCase` - Sets the default for Ignoring the case of Observation values. Applicable values will be converted to uppercase - -* `inputValidationLevel` - Sets the default input validation level when new Observations are added to the Agent. 0 = Ignore, 1 = Warning, 2 = Strict - -* `monitorConfigurationFiles` - Sets whether Configuration files are monitored. If enabled and a configuration file is changed, the Agent will restart - -* `configurationFileRestartInterval` - Sets the minimum time (in seconds) between Agent restarts when MonitorConfigurationFiles is enabled - -* `enableMetrics` - Sets whether Agent Metrics are captured (ex. ObserationUpdateRate, AssetUpdateRate) - - -#### Device Configuration - -* `devices` - The Path to look for the file(s) that represent the Device Information Models to load into the Agent. The path can either be a single file or a directory. The path can be absolute or relative to the executable's directory - -#### Client Configuration - -* `clients` - List of MTConnect Client connection configurations. For more information see() - -#### XML Configuration - -* `devicesNamespaces` - List of extended XML namespaces to use with MTConnectDevicesResponse documents - -* `streamsNamespaces` - List of extended XML namespaces to use with MTConnectStreamsResponse documents - -* `assetsNamespaces` - List of extended XML namespaces to use with MTConnectAssetsResponse documents - -* `errorNamespaces` - List of extended XML namespaces to use with MTConnectErrorResponse documents - - -* `devicesStyle` - List of XSLT Stylesheets to use with MTConnectDevicesResponse documents - -* `streamsStyle` - List of XSLT Stylesheets to use with MTConnectStreamsResponse documents - -* `assetsStyle` - List of XSLT Stylesheets to use with MTConnectAssetsResponse documents - -* `errorStyle` - List of XSLT Stylesheets to use with MTConnectErrorResponse documents - -#### Windows Service Configuration - -* `serviceName` - Changes the service name when installing or removing the service. This allows multiple agents to run as services on the same machine. - -* `serviceAutoStart` - Sets the Service Start Type. True = Auto | False = Manual - - -## Logging -Logging is done using [NLog](https://github.com/NLog/NLog) which allows for customized logging through the NLog.config file located in the application's install directory. The loggers are setup so that there is a separate logger for: -- **(agent-logger)** MTConnect Agent -- **(agent-validation-logger)** MTConnect Data Validation Errors -- **(http-logger)** Http Server -- **(adapter-logger)** MTConnect Adapters -- **(adapter-shdr-logger)** Raw SHDR lines read by the Adapter (used for debugging adapters) - -The default [NLog Configuration File](https://github.com/TrakHound/MTConnect.NET/blob/master/src/MTConnect.NET-Applications-Agents/NLog.config) is shown below: - -```xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -``` - -## Contribution / Feedback -- Please use the [Issues](https://github.com/TrakHound/MTConnect.NET/issues) tab to create issues for specific problems that you may encounter -- Please feel free to use the [Pull Requests](https://github.com/TrakHound/MTConnect.NET/pulls) tab for any suggested improvements to the source code -- For any other questions or feedback, please contact TrakHound directly at **info@trakhound.com**. - -## License -This application and it's source code is licensed under the [MIT License](https://choosealicense.com/licenses/mit/) and is free to use. diff --git a/applications/Agents/MTConnect-Agent-MQTT-Broker-Gateway/agent.config.default.yaml b/applications/Agents/MTConnect-Agent-MQTT-Broker-Gateway/agent.config.default.yaml deleted file mode 100644 index 42f58c17..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Broker-Gateway/agent.config.default.yaml +++ /dev/null @@ -1,68 +0,0 @@ -# - HTTP Client Adapter Configuration - -# The Agent is able to receive data by reading from other MTConnect HTTP Agents -clients: -- address: localhost - port: 5000 - deviceKey: OKUMA-Lathe - - -# - Windows Service Configuration - -# Changes the service name when installing or removing the service. This allows multiple agents to run as services on the same machine. -serviceName: MTConnect-Agent-MQTT-Gateway - -# Sets the Service Start Type. True = Auto | False = Manual -serviceAutoStart: true - - -# - MQTT Configuration - - -# The hostname of the MQTT broker to publish messages to -server: localhost - -# The port number of the MQTT broker to publish messages to -port: 1883 - - -# - Buffer Configuration - -# The Agent has an internal buffer that retains the information that the Agent can respond with according to the MTConnect Standard. -# There is also a Durable File backed buffer that can retain the information in the Agent between Agent restarts - -# The maximum number of Observations the agent can hold in its buffer -observationBufferSize: 150000 - -# The maximum number of assets the agent can hold in its buffer -assetBufferSize: 1000 - -# Sets whether the Agent buffers are durable and retain state after restart -durable: false - -# Sets whether the durable Agent buffers use Compression -useBufferCompression: false - - -# - Agent Configuration - - -# Sets the default MTConnect version to output response documents for. -defaultVersion: 2.1 - -# Overwrite timestamps with the agent time. This will correct clock drift but will not give as accurate relative time since it will not take into consideration network latencies. This can be overridden on a per adapter basis. -ignoreTimestamps: false - -# Sets the default for Converting Units when adding Observations -convertUnits: true - -# Sets the default for Ignoring the case of Observation values. Applicable values will be converted to uppercase -ignoreObservationCase: true - -# Sets the default input validation level when new Observations are added to the Agent. 0 = Ignore, 1 = Warning, 2 = Strict -inputValidationLevel: Ignore - -# Sets whether Configuration files are monitored. If enabled and a configuration file is changed, the Agent will restart -monitorConfigurationFiles: true - -# Sets the minimum time (in seconds) between Agent restarts when MonitorConfigurationFiles is enabled -configurationFileRestartInterval: 2 - -# Sets whether Agent Metrics are captured (ex. ObserationUpdateRate, AssetUpdateRate) -enableMetrics: true diff --git a/applications/Agents/MTConnect-Agent-MQTT-Broker-Gateway/build.bat b/applications/Agents/MTConnect-Agent-MQTT-Broker-Gateway/build.bat deleted file mode 100644 index 65498a7e..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Broker-Gateway/build.bat +++ /dev/null @@ -1,3 +0,0 @@ -dotnet build -c:Release -r:win-x86 --no-self-contained -dotnet build -c:Release -r:win-x64 --no-self-contained -"c:\Program Files (x86)\Inno Setup 6\iscc" installer.iss diff --git a/applications/Agents/MTConnect-Agent-MQTT-Broker-Gateway/installer.iss b/applications/Agents/MTConnect-Agent-MQTT-Broker-Gateway/installer.iss deleted file mode 100644 index 09b17b0a..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Broker-Gateway/installer.iss +++ /dev/null @@ -1,107 +0,0 @@ -; MTConnect MQTT Broker Gateway Agent Installer -; ------------------------------ - -#define MyAppName "MTConnect MQTT Broker Gateway Agent" -#define MyAppVersion "1.0.0" -#define MyAppPublisher "MTConnect" -#define MyAppURL "" -#define MyAppVerName MyAppName + " " + MyAppVersion - -; File Names -#define ExeName "MTConnect-MQTT-Broker-Gateway-Agent.exe" - - -[Setup] -; NOTE: The value of AppId uniquely identifies this application. -; Do not use the same AppId value in installers for other applications. -; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) -AppId={{C8E8645E-D497-4064-84A5-D4219390BBD8} - -AppName={#MyAppName} -AppVersion={#MyAppVersion} -AppVerName={#MyAppName} {#MyAppVersion} -AppPublisher={#MyAppPublisher} -AppPublisherURL={#MyAppURL} -AppSupportURL={#MyAppURL} -AppUpdatesURL={#MyAppURL} -AppReadmeFile=https://github.com/TrakHound/MTConnect.NET -VersionInfoVersion={#MyAppVersion} -ArchitecturesInstallIn64BitMode=x64 - -PrivilegesRequired=admin -DisableProgramGroupPage=no -Compression=lzma -SolidCompression=yes - -; Names -DisableDirPage=auto -DisableReadyPage=no -DisableFinishedPage=no -OutputDir=bin\Publish -DefaultDirName={autopf}\{#MyAppPublisher}\MTConnect-MQTT-Broker-Gateway-Agent -UsePreviousAppDir=false -OutputBaseFilename=MTConnect-MQTT-Broker-Gateway-Agent-Install-v{#MyAppVersion} -UninstallDisplayName={#MyAppName} v{#MyAppVersion} -UninstallFilesDir={app}\Uninstall - -[Types] -Name: "win64net7"; Description: "Windows x64 .NET 7" -Name: "win86net7"; Description: "Windows x86 .NET 7" -Name: "win64net6"; Description: "Windows x64 .NET 6" -Name: "win86net6"; Description: "Windows x86 .NET 6" -Name: "win64net48"; Description: "Windows x64 .NET 4.8 Framework" -Name: "win86net48"; Description: "Windows x86 .NET 4.8 Framework" -Name: "win64net461"; Description: "Windows x64 .NET 4.6.1 Framework" -Name: "win86net461"; Description: "Windows x86 .NET 4.6.1 Framework" - -[Components] -Name: "win64net7"; Description: "{#MyAppVerName}"; Types: win64net7 -Name: "win86net7"; Description: "{#MyAppVerName}"; Types: win86net7 -Name: "win64net6"; Description: "{#MyAppVerName}"; Types: win64net6 -Name: "win86net6"; Description: "{#MyAppVerName}"; Types: win86net6 -Name: "win64net48"; Description: "{#MyAppVerName}"; Types: win64net48 -Name: "win86net48"; Description: "{#MyAppVerName}"; Types: win86net48 -Name: "win64net461"; Description: "{#MyAppVerName}"; Types: win64net461 -Name: "win86net461"; Description: "{#MyAppVerName}"; Types: win86net461 -Name: "configuration"; Description: "Configuration Files"; Types: win86net461 win64net461 win86net48 win64net48 win86net6 win64net6 win86net7 win64net7 - - -[Languages] -Name: "english"; MessagesFile: "compiler:Default.isl" - -[Dirs] -Name: "{app}"; Permissions: everyone-full -Name: "{app}\logs"; Permissions: everyone-full - -[Files] - -; Program Files -Source: "bin\release\net7.0\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net7; -Source: "bin\release\net7.0\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net7; -Source: "bin\release\net6.0\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net6; -Source: "bin\release\net6.0\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net6; -Source: "bin\release\net48\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net48; -Source: "bin\release\net48\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net48; -Source: "bin\release\net461\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net461; -Source: "bin\release\net461\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net461; - - -[Run] - -; Install and Run Windows Service -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""stop""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Stopping Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""remove""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Uninstalling Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""install""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Installing Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""start""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Starting Windows Service..."; - -; Start Browser -Filename: {sys}\cmd.exe; Parameters: "/c explorer ""agent.config.yaml""" ; WorkingDir: {app}; Flags: runhidden postinstall unchecked; Description: Open Agent Configuration File; -Filename: {sys}\cmd.exe; Parameters: "/c explorer ""NLog.config""" ; WorkingDir: {app}; Flags: runhidden postinstall unchecked; Description: Open Log Configuration File; -Filename: {sys}\cmd.exe; Parameters: "/c explorer ""{app}""" ; Flags: runhidden postinstall unchecked; Description: Open Install Directory; - - -[UninstallRun] - -; Stop Server Service -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""stop""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Stopping Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""remove""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Uninstalling Windows Service..."; diff --git a/applications/Agents/MTConnect-Agent-MQTT-Broker/MTConnect-Agent-MQTT-Broker.csproj b/applications/Agents/MTConnect-Agent-MQTT-Broker/MTConnect-Agent-MQTT-Broker.csproj deleted file mode 100644 index fd362a1f..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Broker/MTConnect-Agent-MQTT-Broker.csproj +++ /dev/null @@ -1,62 +0,0 @@ - - - - net6.0 - - - net461;net48;net6.0;net7.0 - false - None - true - - - net461;net462;net47;net471;net472;net48;netstandard2.0;netcoreapp3.1;net5.0;net6.0 - - - - Debug;Release;Docker - false - agent - Exe - MTConnect - MTConnect.Applications.Program - disable - - - - - - - - - - - - - - - - - - - - Always - - - Never - - - Always - - - Always - - - Always - - - Never - - - - diff --git a/applications/Agents/MTConnect-Agent-MQTT-Broker/Program.cs b/applications/Agents/MTConnect-Agent-MQTT-Broker/Program.cs deleted file mode 100644 index 412235f7..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Broker/Program.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. -// TrakHound Inc. licenses this file to you under the MIT license. - -using MTConnect.Applications.Agents; -using System; -using System.Reflection; - -namespace MTConnect.Applications -{ - public class Program - { - // This is the Application Name shown in the Console header information - // If you are implementing this into your own application, you can change this to be more specific (ex. Fanuc MTConnect Agent, Mazak MTConnect Agent, etc.) - private const string ApplicationName = "MTConnect MQTT Broker Agent"; - - // Copyright statement for the application. If you are implementing this into your own application, you can change this to your own copyright. - // This is just what is shown in the console header. If you want to show support for the MTConnect.NET project, you can reference it using the links in the default header - private const string ApplicationCopyright = "Copyright 2023 TrakHound Inc., All Rights Reserved"; - - public static void Main(string[] args) - { - // Print an application header to the console - PrintConsoleHeader(); - - // Create a new MTConnect Agent Application - // This handles all MTConnect Agent functionality along with - // an HTTP server, SHDR Adapters, Command line arguments, Device management, Buffer management, Logging, Windows Service, and Configuration File management - var agentApplication = new MTConnectShdrMqttBrokerAgentApplication(); - - // Use the regular MTConnectMqttAgentApplication if you are not using SHDR Adapters - ///var agentApplication = new MTConnectMqttAgentApplication(); - - // Run the Agent ('true' parameter blocks the call so the application does not continue) - agentApplication.Run(args, true); - - // Use the 'false' parameter if you are implementing this into an existing application or are handling blocking elsewhere - //agentApplication.Run(args, false); - - // ** This is where the rest of your application can go. ** - // For example, if you are developing the Agent to read directly from a PLC, this would be where you can place the PLC reading code - } - - - private static void PrintConsoleHeader() - { - var assembly = Assembly.GetExecutingAssembly(); - var version = assembly.GetName().Version; - - Console.WriteLine("--------------------"); - Console.WriteLine(ApplicationCopyright); - Console.WriteLine(ApplicationName + " : Version " + version.ToString()); - Console.WriteLine("--------------------"); - Console.WriteLine("This application is licensed under the MIT License (https://choosealicense.com/licenses/mit/)"); - Console.WriteLine("Source code available at Github.com (https://github.com/TrakHound/MTConnect.NET)"); - Console.WriteLine("--------------------"); - } - } -} diff --git a/applications/Agents/MTConnect-Agent-MQTT-Broker/Properties/launchSettings.json b/applications/Agents/MTConnect-Agent-MQTT-Broker/Properties/launchSettings.json deleted file mode 100644 index 616b8f1e..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Broker/Properties/launchSettings.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "profiles": { - "MTConnect-Agent-MQTT-Broker": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "https://localhost:59473;http://localhost:59474" - } - } -} \ No newline at end of file diff --git a/applications/Agents/MTConnect-Agent-MQTT-Broker/README.md b/applications/Agents/MTConnect-Agent-MQTT-Broker/README.md deleted file mode 100644 index 9db39cfc..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Broker/README.md +++ /dev/null @@ -1,278 +0,0 @@ -![MTConnect.NET Logo](https://raw.githubusercontent.com/TrakHound/MTConnect.NET/dev/img/mtconnect-net-03-md.png) - -# MTConnect MQTT Broker Agent - -[![MTConnect.NET](https://github.com/TrakHound/MTConnect.NET/actions/workflows/dotnet.yml/badge.svg)](https://github.com/TrakHound/MTConnect.NET/actions/workflows/dotnet.yml) - -## Overview -This project is a full implementation of an MTConnect Agent used to read data from industrial machine tools and devices. -This MTConnect Agent application is fully compatible with the latest **Version 2.2 of the MTConnect Standard**. -It uses the SHDR protocol to receive data from Adapters and a built-in MQTT broker. - -#### Features -- MQTT support with built-in broker -- Easy setup with Windows Installers availble in the latest [Releases](https://github.com/TrakHound/MTConnect.NET/releases) -- Options to run as Windows Service or as a console application (typically for testing/debugging) -- Optional 'Durable' buffer used to retain the Agent data between application/machine restarts -- High performance / Low resource usage -- Flexible Device configurations (traditional 'devices.xml' file or 'devices' directory with individual Device files) -- SHDR protocol compatibility for easy implementation with existing MTConnect Adapters -- Configuration File monitoring to automatically restart the Agent upon configuration file changes -- Flexible Logging using NLog which can be used to output log information to separate files for easier analysis - - -![MQTT Agent Architecture](https://raw.githubusercontent.com/TrakHound/MTConnect.NET/master/img/mtconnect-agent-shdr-mqtt-communication-white.png) - -## Download -To download the latest release as a Windows Installer, use the link below: - -- [Download Latest Release Windows Installer](https://github.com/TrakHound/MTConnect.NET/releases/download/v5.1.0/TrakHound-MTConnect-MQTT-Broker-Agent-Install-v5.1.0.exe) - - -## Usage -The Agent can be run from a command line prompt or as a Windows Service using the format below: -``` -agent [help|install|install-start|start|stop|remove|debug|run|run-service] [configuration_file] [mqtt_port] - --------------------- - -Options : - - help | Prints usage information - install | Install as a Service - install-start | Install as a Service and Start the Service - start | Start the Service - stop | Stop the Service - remove | Remove the Service - debug | Runs the Agent in the terminal (with verbose logging) - run | Runs the Agent in the terminal - run-service | Runs the Agent as a Service - -Arguments : --------------------- - - configuration_file | Specifies the Agent Configuration file to load - Default : agent.config.json - - mqtt_port | Specifies the TCP Port to use for the MQTT broker - Note : This overrides what is read from the Configuration file -``` -#### Example 1: -Install the Agent as a Windows Service (Note: requires Administrator Privileges) - > agent install - -#### Example 2: -Install the Agent as a Windows Service using the configuration file "agent-config.json" and Starts the service (Note: requires Administrator Privileges) -> agent install-start agent-config.json - -#### Example 3: -Starts the Windows Service (Note: requires Administrator Privileges) -> agent start - -#### Example 4: -Runs the Agent in the command line prompt using verbose logging and overrides the MQTT Port to 1884 -> agent debug "" 1884 - - -## MQTT Topic Structure -For more information on MQTT Topics [Click Here](https://github.com/TrakHound/MTConnect.NET/tree/master/src/MTConnect.NET-MQTT) - -#### Devices -``` -MTConnect/Devices/[DEVICE_UUID]/Device -``` - -#### Observations -``` -MTConnect/Devices/[DEVICE_UUID]/Observations/[COMPONENT_TYPE]/[COMPONENT_ID]/[DATA_ITEM_CATEGORY]/[DATA_ITEM_TYPE]/[DATA_ITEM_ID] -MTConnect/Devices/[DEVICE_UUID]/Observations/[COMPONENT_TYPE]/[COMPONENT_ID]/[DATA_ITEM_CATEGORY]/[DATA_ITEM_TYPE]/SubTypes/[DATA_ITEM_SUBTYPE]/[DATA_ITEM_ID] -``` -##### Conditions -Condition messages are sent as an array of Observations since a Condition may have multiple Fault States. This is similar to how the Current request functions in an HTTP Agent. - -#### Assets -``` -MTConnect/Devices/[DEVICE_UUID]/Assets/[ASSET_TYPE]/[ASSET_ID] -MTConnect/Assets/[ASSET_TYPE]/[ASSET_ID] -``` -> Note: Assets are sent to two topics. One for the "Global" assets and one for the Device that the Asset was added to - -#### Agent -The Agent topic contains information that would normally be in the Header of a Response Document from an HTTP Agent. -``` -MTConnect/Assets/[AGENT_UUID] -``` - - -## Configuration -More information about [Configurations](https://github.com/TrakHound/MTConnect.NET/tree/master/src/MTConnect.NET-Common/Configurations). The default configuration file is shown below : -```yaml -# - Device Configuration - -devices: devices - -# - SHDR Adapter Configuration - -# The Agent is able to receive data through a TCP port using the SHDR protocol -adapters: -- hostname: localhost - port: 7878 - reconnectInterval: 1000 - -# - MQTT Configuration - - -# The hostname of the MQTT broker to publish messages to -server: localhost - -# The port number of the MQTT broker to publish messages to -port: 1883 -``` - -#### MQTT Configuration - -* `port` - The port number of the MQTT broker. - -* `server` - The server hostname of the MQTT broker. - -* `username` - The username of the MQTT broker. - -* `password` - The password of the MQTT broker. - -* `useTls` - Sets whether to use TLS in connections to the MQTT broker. - - -#### Agent Configuration - -* `observationBufferSize` - The maximum number of Observations the agent can hold in its buffer - -* `assetBufferSize` - The maximum number of assets the agent can hold in its buffer - -* `durable` - Sets whether the Agent buffers are durable and retain state after restart - -* `useBufferCompression` - Sets whether the durable Agent buffers use Compression - -* `ignoreTimestamps` - Overwrite timestamps with the agent time. This will correct clock drift but will not give as accurate relative time since it will not take into consideration network latencies. This can be overridden on a per adapter basis. - -* `defaultVersion` - Sets the default MTConnect version to output response documents for. - -* `convertUnits` - Sets the default for Converting Units when adding Observations - -* `ignoreObservationCase` - Sets the default for Ignoring the case of Observation values. Applicable values will be converted to uppercase - -* `inputValidationLevel` - Sets the default input validation level when new Observations are added to the Agent. 0 = Ignore, 1 = Warning, 2 = Strict - -* `monitorConfigurationFiles` - Sets whether Configuration files are monitored. If enabled and a configuration file is changed, the Agent will restart - -* `configurationFileRestartInterval` - Sets the minimum time (in seconds) between Agent restarts when MonitorConfigurationFiles is enabled - -* `enableMetrics` - Sets whether Agent Metrics are captured (ex. ObserationUpdateRate, AssetUpdateRate) - - -#### Device Configuration - -* `devices` - The Path to look for the file(s) that represent the Device Information Models to load into the Agent. The path can either be a single file or a directory. The path can be absolute or relative to the executable's directory - -#### Adapter Configuration - -* `adapters` - List of SHDR Adapter connection configurations. For more information see() - -* `allowShdrDevice` - Sets whether a Device Model can be sent from an SHDR Adapter - -* `preserveUuid` - Do not overwrite the UUID with the UUID from the adapter, preserve the UUID for the Device. This can be overridden on a per adapter basis. - -* `suppressIpAddress` - Suppress the Adapter IP Address and port when creating the Agent Device ids and names for 1.7. This applies to all adapters. - -* `timeout` - The amount of time (in milliseconds) an adapter can be silent before it is disconnected. - -* `reconnectInterval` - The amount of time (in milliseconds) between adapter reconnection attempts. - -#### Windows Service Configuration - -* `serviceName` - Changes the service name when installing or removing the service. This allows multiple agents to run as services on the same machine. - -* `serviceAutoStart` - Sets the Service Start Type. True = Auto | False = Manual - - -## Logging -Logging is done using [NLog](https://github.com/NLog/NLog) which allows for customized logging through the NLog.config file located in the application's install directory. The loggers are setup so that there is a separate logger for: -- **(agent-logger)** MTConnect Agent -- **(agent-validation-logger)** MTConnect Data Validation Errors -- **(http-logger)** Http Server -- **(adapter-logger)** MTConnect Adapters -- **(adapter-shdr-logger)** Raw SHDR lines read by the Adapter (used for debugging adapters) - -The default [NLog Configuration File](https://github.com/TrakHound/MTConnect.NET/blob/master/src/MTConnect.NET-Applications-Agents/NLog.config) is shown below: - -```xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -``` - -## Releases -Releases for this application are located under the Releases tab. The current release is listed below: -- [MTConnect Agent Current Release](https://github.com/TrakHound/MTConnect.NET/releases) - -## Source Code -This project uses the MTConnect.NET-Applications-Agents-MQTT library (available on [Nuget](https://www.nuget.org/packages/MTConnect.NET-Applications-Agents-MQTT)) to create an MTConnect Agent application. More information about this library can be found [Here](https://github.com/TrakHound/MTConnect.NET/tree/master/src/MTConnect.NET-Applications-Agents-MQTT). The MTConnect.NET-Applications-Agents-MQTT library makes creating an MTConnect MQTT Agent application simple as well as makes it easy to keep updated using Nuget. A fully functionaly MTConnect Application can be created in just a few lines of code. - -## Contribution / Feedback -- Please use the [Issues](https://github.com/TrakHound/MTConnect.NET/issues) tab to create issues for specific problems that you may encounter -- Please feel free to use the [Pull Requests](https://github.com/TrakHound/MTConnect.NET/pulls) tab for any suggested improvements to the source code -- For any other questions or feedback, please contact TrakHound directly at **info@trakhound.com**. - -## License -This application and it's source code is licensed under the [MIT License](https://choosealicense.com/licenses/mit/) and is free to use. diff --git a/applications/Agents/MTConnect-Agent-MQTT-Broker/agent.config.default.yaml b/applications/Agents/MTConnect-Agent-MQTT-Broker/agent.config.default.yaml deleted file mode 100644 index 09697b25..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Broker/agent.config.default.yaml +++ /dev/null @@ -1,66 +0,0 @@ -# - Device Configuration - -# The Path to look for the file(s) that represent the Device Information Models to load into the Agent. -# The path can either be a single file or a directory. -# The path can be absolute or relative to the executable's directory -devices: devices - -# - SHDR Adapter Configuration - -# The Agent is able to receive data through a TCP port using the SHDR protocol -adapters: -- hostname: localhost - port: 7878 - reconnectInterval: 1000 - -# Sets whether a Device Model can be sent from an SHDR Adapter -allowShdrDevice: false - - -# - Windows Service Configuration - -# Changes the service name when installing or removing the service. This allows multiple agents to run as services on the same machine. -serviceName: MTConnect-Agent-MQTT-Broker - -# Sets the Service Start Type. True = Auto | False = Manual -serviceAutoStart: true - - -# - MQTT Configuration - - -# The hostname of the MQTT broker to publish messages to -server: localhost - -# The port number of the MQTT broker to publish messages to -port: 1883 - -# The Intervals to publish Observations at (in milliseconds) -observationIntervals: -- 0 -- 100 -- 1000 - - -# - Agent Configuration - - -# Sets the default MTConnect version to output response documents for. -defaultVersion: 2.1 - -# Overwrite timestamps with the agent time. This will correct clock drift but will not give as accurate relative time since it will not take into consideration network latencies. This can be overridden on a per adapter basis. -ignoreTimestamps: false - -# Sets the default for Converting Units when adding Observations -convertUnits: true - -# Sets the default for Ignoring the case of Observation values. Applicable values will be converted to uppercase -ignoreObservationCase: true - -# Sets the default input validation level when new Observations are added to the Agent. 0 = Ignore, 1 = Warning, 2 = Strict -inputValidationLevel: Ignore - -# Sets whether Configuration files are monitored. If enabled and a configuration file is changed, the Agent will restart -monitorConfigurationFiles: true - -# Sets the minimum time (in seconds) between Agent restarts when MonitorConfigurationFiles is enabled -configurationFileRestartInterval: 2 - -# Sets whether Agent Metrics are captured (ex. ObserationUpdateRate, AssetUpdateRate) -enableMetrics: true diff --git a/applications/Agents/MTConnect-Agent-MQTT-Broker/build.bat b/applications/Agents/MTConnect-Agent-MQTT-Broker/build.bat deleted file mode 100644 index 65498a7e..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Broker/build.bat +++ /dev/null @@ -1,3 +0,0 @@ -dotnet build -c:Release -r:win-x86 --no-self-contained -dotnet build -c:Release -r:win-x64 --no-self-contained -"c:\Program Files (x86)\Inno Setup 6\iscc" installer.iss diff --git a/applications/Agents/MTConnect-Agent-MQTT-Broker/devices/device-mazak.xml b/applications/Agents/MTConnect-Agent-MQTT-Broker/devices/device-mazak.xml deleted file mode 100644 index f25afa33..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Broker/devices/device-mazak.xml +++ /dev/null @@ -1,450 +0,0 @@ - - Mill w/SMooth-G - - - - - 0 0 0 - 0 0 0 - - - - - 0 0 0 - 0 0 0 - - - - - - - 2.0 3.0 4.0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - spindle_speed - - - - - - - - - - - - - - - - 0.5 - - - - - - - - - - - - 200.0 - 0.0 - - - - - - - - - - - - - - - - 0.5 - - - - - - - - - - - - - - - - - 3 - - - - - - 0.5 - - - - - - - - - - - The linears Z kinematics - 100.0 101.0 102.0 - 0.0 0.1 1.0 - - - - - - - - 3 - - - - - - - - - CONTOUR - INDEX - - - - - - - - - - - - - 3 - - - - - 3 - - - - - - - 5 - - - - - 0.5 - - - - - - - SPINDLE - INDEX - - - - - - - - - - - - - - - - The spindle kinematics - - 10.0 20.0 30.0 - 90.0 0.0 180 - - 0.0 0.5 1.0 - - - - 10000 - 100 - 1000 - - - 1000 - -1000 - 100 - 500 - -500 - 200 - -200 - - - - 500 - 50 - -500 - - - 500 - -500 - 10 - 200 - -200 - - - 500 - -500 - 200 - -200 - - - - - - - - - - - - - - - - - - - - - 101 102 103 - - - - 10 10 10 - 90 0 90 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - A Complex Workpiece Offset Table - - - Some Pressure thing - - - Pressure of the P - - - - - - - - - - - - - - Spindle Angle - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0.5 - - - - - - - - - - - - - - - - - - - - - - - - 0.5 - - - - - - - - 2.02 - 2010-05-16 - 2010-05-16 - WS - - - A/D With Thermister - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/applications/Agents/MTConnect-Agent-MQTT-Broker/devices/device-okuma.xml b/applications/Agents/MTConnect-Agent-MQTT-Broker/devices/device-okuma.xml deleted file mode 100644 index dd745114..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Broker/devices/device-okuma.xml +++ /dev/null @@ -1,165 +0,0 @@ - - - Okuma MT Connect Adapter - Lathe - - - - - - - - - - - - - - - - - - - SPINDLE - - - - OPEN - - - - - - - - - - - - - - - - SPINDLE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/applications/Agents/MTConnect-Agent-MQTT-Broker/installer.iss b/applications/Agents/MTConnect-Agent-MQTT-Broker/installer.iss deleted file mode 100644 index c513f538..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Broker/installer.iss +++ /dev/null @@ -1,109 +0,0 @@ -; MTConnect MQTT Broker Agent Installer -; ------------------------------ - -#define MyAppName "MTConnect MQTT Broker Agent" -#define MyAppVersion "1.0.0" -#define MyAppPublisher "MTConnect" -#define MyAppURL "" -#define MyAppVerName MyAppName + " " + MyAppVersion - -; File Names -#define ExeName "MTConnect-MQTT-Broker-Agent.exe" - - -[Setup] -; NOTE: The value of AppId uniquely identifies this application. -; Do not use the same AppId value in installers for other applications. -; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) -AppId={{C8E8645E-D497-4064-84A5-D4219390BBD8} - -AppName={#MyAppName} -AppVersion={#MyAppVersion} -AppVerName={#MyAppName} {#MyAppVersion} -AppPublisher={#MyAppPublisher} -AppPublisherURL={#MyAppURL} -AppSupportURL={#MyAppURL} -AppUpdatesURL={#MyAppURL} -AppReadmeFile=https://github.com/TrakHound/MTConnect.NET -VersionInfoVersion={#MyAppVersion} -ArchitecturesInstallIn64BitMode=x64 - -PrivilegesRequired=admin -DisableProgramGroupPage=no -Compression=lzma -SolidCompression=yes - -; Names -DisableDirPage=auto -DisableReadyPage=no -DisableFinishedPage=no -OutputDir=bin\Publish -DefaultDirName={autopf}\{#MyAppPublisher}\MTConnect-MQTT-Broker-Agent -UsePreviousAppDir=false -OutputBaseFilename=MTConnect-MQTT-Broker-Agent-Install-v{#MyAppVersion} -UninstallDisplayName={#MyAppName} v{#MyAppVersion} -UninstallFilesDir={app}\Uninstall - -[Types] -Name: "win64net7"; Description: "Windows x64 .NET 7" -Name: "win86net7"; Description: "Windows x86 .NET 7" -Name: "win64net6"; Description: "Windows x64 .NET 6" -Name: "win86net6"; Description: "Windows x86 .NET 6" -Name: "win64net48"; Description: "Windows x64 .NET 4.8 Framework" -Name: "win86net48"; Description: "Windows x86 .NET 4.8 Framework" -Name: "win64net461"; Description: "Windows x64 .NET 4.6.1 Framework" -Name: "win86net461"; Description: "Windows x86 .NET 4.6.1 Framework" - -[Components] -Name: "win64net7"; Description: "{#MyAppVerName}"; Types: win64net7 -Name: "win86net7"; Description: "{#MyAppVerName}"; Types: win86net7 -Name: "win64net6"; Description: "{#MyAppVerName}"; Types: win64net6 -Name: "win86net6"; Description: "{#MyAppVerName}"; Types: win86net6 -Name: "win64net48"; Description: "{#MyAppVerName}"; Types: win64net48 -Name: "win86net48"; Description: "{#MyAppVerName}"; Types: win86net48 -Name: "win64net461"; Description: "{#MyAppVerName}"; Types: win64net461 -Name: "win86net461"; Description: "{#MyAppVerName}"; Types: win86net461 -Name: "configuration"; Description: "Configuration Files"; Types: win86net461 win64net461 win86net48 win64net48 win86net6 win64net6 win86net7 win64net7 - - -[Languages] -Name: "english"; MessagesFile: "compiler:Default.isl" - -[Dirs] -Name: "{app}"; Permissions: everyone-full -Name: "{app}\logs"; Permissions: everyone-full -Name: "{app}\devices"; Permissions: everyone-full -Name: "{app}\styles"; Permissions: everyone-full - -[Files] - -; Program Files -Source: "bin\release\net7.0\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net7; -Source: "bin\release\net7.0\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net7; -Source: "bin\release\net6.0\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net6; -Source: "bin\release\net6.0\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net6; -Source: "bin\release\net48\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net48; -Source: "bin\release\net48\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net48; -Source: "bin\release\net461\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net461; -Source: "bin\release\net461\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net461; - - -[Run] - -; Install and Run Windows Service -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""stop""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Stopping Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""remove""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Uninstalling Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""install""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Installing Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""start""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Starting Windows Service..."; - -; Start Browser -Filename: {sys}\cmd.exe; Parameters: "/c explorer ""agent.config.yaml""" ; WorkingDir: {app}; Flags: runhidden postinstall unchecked; Description: Open Agent Configuration File; -Filename: {sys}\cmd.exe; Parameters: "/c explorer ""NLog.config""" ; WorkingDir: {app}; Flags: runhidden postinstall unchecked; Description: Open Log Configuration File; -Filename: {sys}\cmd.exe; Parameters: "/c explorer ""{app}""" ; Flags: runhidden postinstall unchecked; Description: Open Install Directory; - - -[UninstallRun] - -; Stop Server Service -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""stop""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Stopping Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""remove""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Uninstalling Windows Service..."; diff --git a/applications/Agents/MTConnect-Agent-MQTT-Relay-Gateway/MTConnect-Agent-MQTT-Relay-Gateway.csproj b/applications/Agents/MTConnect-Agent-MQTT-Relay-Gateway/MTConnect-Agent-MQTT-Relay-Gateway.csproj deleted file mode 100644 index 4b2fbec9..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Relay-Gateway/MTConnect-Agent-MQTT-Relay-Gateway.csproj +++ /dev/null @@ -1,47 +0,0 @@ - - - - net6.0 - - - net461;net48;net6.0;net7.0 - false - None - true - - - - agent - false - Exe - MTConnect - - - - - - - - - - - - - - - - - - - - - - - Always - - - Always - - - - diff --git a/applications/Agents/MTConnect-Agent-MQTT-Relay-Gateway/Program.cs b/applications/Agents/MTConnect-Agent-MQTT-Relay-Gateway/Program.cs deleted file mode 100644 index 9982f9d6..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Relay-Gateway/Program.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. -// TrakHound Inc. licenses this file to you under the MIT license. - -using MTConnect.Applications.Agents; -using System; -using System.Reflection; - -namespace MTConnect.Applications -{ - public class Program - { - // This is the Application Name shown in the Console header information - // If you are implementing this into your own application, you can change this to be more specific (ex. Fanuc MTConnect Agent, Mazak MTConnect Agent, etc.) - private const string ApplicationName = "MTConnect MQTT Relay Gateway Agent"; - - // Copyright statement for the application. If you are implementing this into your own application, you can change this to your own copyright. - // This is just what is shown in the console header. If you want to show support for the MTConnect.NET project, you can reference it using the links in the default header - private const string ApplicationCopyright = "Copyright 2023 TrakHound Inc., All Rights Reserved"; - - public static void Main(string[] args) - { - // Print an application header to the console - PrintConsoleHeader(); - - // Create a new MTConnect Agent Application - // This handles all MTConnect Agent functionality along with - // an MQTT broker connection, HTTP MTConnect clients, Command line arguments, Device management, Buffer management, Logging, Windows Service, and Configuration File management - var agentApplication = new MTConnectMqttRelayAgentGatewayApplication(); - - // Run the Agent ('true' parameter blocks the call so the application does not continue) - agentApplication.Run(args, true); - } - - - private static void PrintConsoleHeader() - { - var assembly = Assembly.GetExecutingAssembly(); - var version = assembly.GetName().Version; - - Console.WriteLine("--------------------"); - Console.WriteLine(ApplicationCopyright); - Console.WriteLine(ApplicationName + " : Version " + version.ToString()); - Console.WriteLine("--------------------"); - Console.WriteLine("This application is licensed under the MIT License (https://choosealicense.com/licenses/mit/)"); - Console.WriteLine("Source code available at Github.com (https://github.com/TrakHound/MTConnect.NET)"); - Console.WriteLine("--------------------"); - } - } -} diff --git a/applications/Agents/MTConnect-Agent-MQTT-Relay-Gateway/Properties/launchSettings.json b/applications/Agents/MTConnect-Agent-MQTT-Relay-Gateway/Properties/launchSettings.json deleted file mode 100644 index e241a20e..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Relay-Gateway/Properties/launchSettings.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "profiles": { - "MTConnect-Agent-MQTT-Relay-Gateway": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "https://localhost:59483;http://localhost:59484" - } - } -} \ No newline at end of file diff --git a/applications/Agents/MTConnect-Agent-MQTT-Relay-Gateway/README.md b/applications/Agents/MTConnect-Agent-MQTT-Relay-Gateway/README.md deleted file mode 100644 index 491312da..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Relay-Gateway/README.md +++ /dev/null @@ -1,282 +0,0 @@ -![MTConnect.NET Logo](https://raw.githubusercontent.com/TrakHound/MTConnect.NET/dev/img/mtconnect-net-03-md.png) - -# MTConnect MQTT Relay Gateway Agent - -[![MTConnect.NET](https://github.com/TrakHound/MTConnect.NET/actions/workflows/dotnet.yml/badge.svg)](https://github.com/TrakHound/MTConnect.NET/actions/workflows/dotnet.yml) - -## Overview -This project is a full implementation of an MTConnect Agent used to read data from industrial machine tools and devices. -This MTConnect Agent application is fully compatible with the latest **Version 2.2 of the MTConnect Standard**. -It receives data from other MTConnect Agents using HTTP and an MQTT client to publish messages to an external MQTT Broker - -#### Features -- MQTT client to publish to an external broker -- Reads from other HTTP MTConnect Agents for easy implementation of MQTT with existing MTConnect Agents -- Easy setup with Windows Installers availble in the latest [Releases](https://github.com/TrakHound/MTConnect.NET/releases) -- Options to run as Windows Service or as a console application (typically for testing/debugging) -- Optional 'Durable' buffer used to retain the Agent data between application/machine restarts -- High performance / Low resource usage -- Flexible Device configurations (traditional 'devices.xml' file or 'devices' directory with individual Device files) -- Configuration File monitoring to automatically restart the Agent upon configuration file changes -- Flexible Logging using NLog which can be used to output log information to separate files for easier analysis - - -![MQTT Agent Architecture](https://raw.githubusercontent.com/TrakHound/MTConnect.NET/master/img/mtconnect-agent-http-mqtt-communication-white.png) - -## Download -To download the latest release as a Windows Installer, use the link below: - -- [Download Latest Release Windows Installer](https://github.com/TrakHound/MTConnect.NET/releases/download/v5.1.0/TrakHound-MTConnect-MQTT-Relay-Gateway-Agent-Install-v5.1.0.exe) - - -## Usage -The Agent can be run from a command line prompt or as a Windows Service using the format below: -``` -agent [help|install|install-start|start|stop|remove|debug|run|run-service] [configuration_file] [mqtt_port] - --------------------- - -Options : - - help | Prints usage information - install | Install as a Service - install-start | Install as a Service and Start the Service - start | Start the Service - stop | Stop the Service - remove | Remove the Service - debug | Runs the Agent in the terminal (with verbose logging) - run | Runs the Agent in the terminal - run-service | Runs the Agent as a Service - -Arguments : --------------------- - - configuration_file | Specifies the Agent Configuration file to load - Default : agent.config.json - - mqtt_port | Specifies the TCP Port to use for the MQTT client - Note : This overrides what is read from the Configuration file -``` -#### Example 1: -Install the Agent as a Windows Service (Note: requires Administrator Privileges) - > agent install - -#### Example 2: -Install the Agent as a Windows Service using the configuration file "agent-config.json" and Starts the service (Note: requires Administrator Privileges) -> agent install-start agent-config.json - -#### Example 3: -Starts the Windows Service (Note: requires Administrator Privileges) -> agent start - -#### Example 4: -Runs the Agent in the command line prompt using verbose logging and overrides the MQTT Port to 1884 -> agent debug "" 1884 - - -## MQTT Topic Structure -For more information on MQTT Topics [Click Here](https://github.com/TrakHound/MTConnect.NET/tree/master/src/MTConnect.NET-MQTT) - -#### Devices -``` -MTConnect/Devices/[DEVICE_UUID]/Device -``` - -#### Observations -``` -MTConnect/Devices/[DEVICE_UUID]/Observations/[COMPONENT_TYPE]/[COMPONENT_ID]/[DATA_ITEM_CATEGORY]/[DATA_ITEM_TYPE]/[DATA_ITEM_ID] -MTConnect/Devices/[DEVICE_UUID]/Observations/[COMPONENT_TYPE]/[COMPONENT_ID]/[DATA_ITEM_CATEGORY]/[DATA_ITEM_TYPE]/SubTypes/[DATA_ITEM_SUBTYPE]/[DATA_ITEM_ID] -``` -##### Conditions -Condition messages are sent as an array of Observations since a Condition may have multiple Fault States. This is similar to how the Current request functions in an HTTP Agent. - -#### Assets -``` -MTConnect/Devices/[DEVICE_UUID]/Assets/[ASSET_TYPE]/[ASSET_ID] -MTConnect/Assets/[ASSET_TYPE]/[ASSET_ID] -``` -> Note: Assets are sent to two topics. One for the "Global" assets and one for the Device that the Asset was added to - -#### Agent -The Agent topic contains information that would normally be in the Header of a Response Document from an HTTP Agent. -``` -MTConnect/Assets/[AGENT_UUID] -``` - - -## Configuration -More information about [Configurations](https://github.com/TrakHound/MTConnect.NET/tree/master/src/MTConnect.NET-Common/Configurations). The default configuration file is shown below : -```yaml -# - HTTP Client Adapter Configuration - -# The Agent is able to receive data by reading from other MTConnect HTTP Agents -clients: -- address: https://smstestbed.nist.gov/vds/ - port: 443 - deviceKey: GFAgie01 - useSSL: true - heartbeat: 0 -- address: https://smstestbed.nist.gov/vds/ - port: 443 - deviceKey: Mazak01 - useSSL: true - heartbeat: 0 - -# - MQTT Configuration - - -# The hostname of the MQTT broker to publish messages to -server: localhost - -# The port number of the MQTT broker to publish messages to -port: 1883 -``` - -#### MQTT Configuration - -* `port` - The port number of the external MQTT broker to publish messages to. - -* `server` - The server hostname of the external MQTT broker to publish messages to. - -* `username` - The username of the external MQTT broker to publish messages to. - -* `password` - The password of the external MQTT broker to publish messages to. - -* `useTls` - Sets whether to use TLS in the connection to the external MQTT broker to publish messages to. - - -#### Agent Configuration - -* `observationBufferSize` - The maximum number of Observations the agent can hold in its buffer - -* `assetBufferSize` - The maximum number of assets the agent can hold in its buffer - -* `durable` - Sets whether the Agent buffers are durable and retain state after restart - -* `useBufferCompression` - Sets whether the durable Agent buffers use Compression - -* `ignoreTimestamps` - Overwrite timestamps with the agent time. This will correct clock drift but will not give as accurate relative time since it will not take into consideration network latencies. This can be overridden on a per adapter basis. - -* `defaultVersion` - Sets the default MTConnect version to output response documents for. - -* `convertUnits` - Sets the default for Converting Units when adding Observations - -* `ignoreObservationCase` - Sets the default for Ignoring the case of Observation values. Applicable values will be converted to uppercase - -* `inputValidationLevel` - Sets the default input validation level when new Observations are added to the Agent. 0 = Ignore, 1 = Warning, 2 = Strict - -* `monitorConfigurationFiles` - Sets whether Configuration files are monitored. If enabled and a configuration file is changed, the Agent will restart - -* `configurationFileRestartInterval` - Sets the minimum time (in seconds) between Agent restarts when MonitorConfigurationFiles is enabled - -* `enableMetrics` - Sets whether Agent Metrics are captured (ex. ObserationUpdateRate, AssetUpdateRate) - - -#### Device Configuration - -* `devices` - The Path to look for the file(s) that represent the Device Information Models to load into the Agent. The path can either be a single file or a directory. The path can be absolute or relative to the executable's directory - -#### Adapter Configuration - -* `adapters` - List of SHDR Adapter connection configurations. For more information see() - -* `allowShdrDevice` - Sets whether a Device Model can be sent from an SHDR Adapter - -* `preserveUuid` - Do not overwrite the UUID with the UUID from the adapter, preserve the UUID for the Device. This can be overridden on a per adapter basis. - -* `suppressIpAddress` - Suppress the Adapter IP Address and port when creating the Agent Device ids and names for 1.7. This applies to all adapters. - -* `timeout` - The amount of time (in milliseconds) an adapter can be silent before it is disconnected. - -* `reconnectInterval` - The amount of time (in milliseconds) between adapter reconnection attempts. - -#### Windows Service Configuration - -* `serviceName` - Changes the service name when installing or removing the service. This allows multiple agents to run as services on the same machine. - -* `serviceAutoStart` - Sets the Service Start Type. True = Auto | False = Manual - - -## Logging -Logging is done using [NLog](https://github.com/NLog/NLog) which allows for customized logging through the NLog.config file located in the application's install directory. The loggers are setup so that there is a separate logger for: -- **(agent-logger)** MTConnect Agent -- **(agent-validation-logger)** MTConnect Data Validation Errors -- **(http-logger)** Http Server -- **(adapter-logger)** MTConnect Adapters -- **(adapter-shdr-logger)** Raw SHDR lines read by the Adapter (used for debugging adapters) - -The default [NLog Configuration File](https://github.com/TrakHound/MTConnect.NET/blob/master/src/MTConnect.NET-Applications-Agents/NLog.config) is shown below: - -```xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -``` - -## Releases -Releases for this application are located under the Releases tab. The current release is listed below: -- [MTConnect Agent Current Release](https://github.com/TrakHound/MTConnect.NET/releases) - -## Source Code -This project uses the MTConnect.NET-Applications-Agents-MQTT library (available on [Nuget](https://www.nuget.org/packages/MTConnect.NET-Applications-Agents-MQTT)) to create an MTConnect Agent application. More information about this library can be found [Here](https://github.com/TrakHound/MTConnect.NET/tree/master/src/MTConnect.NET-Applications-Agents-MQTT). The MTConnect.NET-Applications-Agents-MQTT library makes creating an MTConnect MQTT Agent application simple as well as makes it easy to keep updated using Nuget. A fully functionaly MTConnect Application can be created in just a few lines of code. - -## Contribution / Feedback -- Please use the [Issues](https://github.com/TrakHound/MTConnect.NET/issues) tab to create issues for specific problems that you may encounter -- Please feel free to use the [Pull Requests](https://github.com/TrakHound/MTConnect.NET/pulls) tab for any suggested improvements to the source code -- For any other questions or feedback, please contact TrakHound directly at **info@trakhound.com**. - -## License -This application and it's source code is licensed under the [MIT License](https://choosealicense.com/licenses/mit/) and is free to use. diff --git a/applications/Agents/MTConnect-Agent-MQTT-Relay-Gateway/agent.config.default.yaml b/applications/Agents/MTConnect-Agent-MQTT-Relay-Gateway/agent.config.default.yaml deleted file mode 100644 index 42f58c17..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Relay-Gateway/agent.config.default.yaml +++ /dev/null @@ -1,68 +0,0 @@ -# - HTTP Client Adapter Configuration - -# The Agent is able to receive data by reading from other MTConnect HTTP Agents -clients: -- address: localhost - port: 5000 - deviceKey: OKUMA-Lathe - - -# - Windows Service Configuration - -# Changes the service name when installing or removing the service. This allows multiple agents to run as services on the same machine. -serviceName: MTConnect-Agent-MQTT-Gateway - -# Sets the Service Start Type. True = Auto | False = Manual -serviceAutoStart: true - - -# - MQTT Configuration - - -# The hostname of the MQTT broker to publish messages to -server: localhost - -# The port number of the MQTT broker to publish messages to -port: 1883 - - -# - Buffer Configuration - -# The Agent has an internal buffer that retains the information that the Agent can respond with according to the MTConnect Standard. -# There is also a Durable File backed buffer that can retain the information in the Agent between Agent restarts - -# The maximum number of Observations the agent can hold in its buffer -observationBufferSize: 150000 - -# The maximum number of assets the agent can hold in its buffer -assetBufferSize: 1000 - -# Sets whether the Agent buffers are durable and retain state after restart -durable: false - -# Sets whether the durable Agent buffers use Compression -useBufferCompression: false - - -# - Agent Configuration - - -# Sets the default MTConnect version to output response documents for. -defaultVersion: 2.1 - -# Overwrite timestamps with the agent time. This will correct clock drift but will not give as accurate relative time since it will not take into consideration network latencies. This can be overridden on a per adapter basis. -ignoreTimestamps: false - -# Sets the default for Converting Units when adding Observations -convertUnits: true - -# Sets the default for Ignoring the case of Observation values. Applicable values will be converted to uppercase -ignoreObservationCase: true - -# Sets the default input validation level when new Observations are added to the Agent. 0 = Ignore, 1 = Warning, 2 = Strict -inputValidationLevel: Ignore - -# Sets whether Configuration files are monitored. If enabled and a configuration file is changed, the Agent will restart -monitorConfigurationFiles: true - -# Sets the minimum time (in seconds) between Agent restarts when MonitorConfigurationFiles is enabled -configurationFileRestartInterval: 2 - -# Sets whether Agent Metrics are captured (ex. ObserationUpdateRate, AssetUpdateRate) -enableMetrics: true diff --git a/applications/Agents/MTConnect-Agent-MQTT-Relay-Gateway/build.bat b/applications/Agents/MTConnect-Agent-MQTT-Relay-Gateway/build.bat deleted file mode 100644 index 65498a7e..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Relay-Gateway/build.bat +++ /dev/null @@ -1,3 +0,0 @@ -dotnet build -c:Release -r:win-x86 --no-self-contained -dotnet build -c:Release -r:win-x64 --no-self-contained -"c:\Program Files (x86)\Inno Setup 6\iscc" installer.iss diff --git a/applications/Agents/MTConnect-Agent-MQTT-Relay-Gateway/installer.iss b/applications/Agents/MTConnect-Agent-MQTT-Relay-Gateway/installer.iss deleted file mode 100644 index 87416d6c..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Relay-Gateway/installer.iss +++ /dev/null @@ -1,107 +0,0 @@ -; MTConnect MQTT Relay Gateway Agent Installer -; ------------------------------ - -#define MyAppName "MTConnect MQTT Relay Gateway Agent" -#define MyAppVersion "1.0.0" -#define MyAppPublisher "MTConnect" -#define MyAppURL "" -#define MyAppVerName MyAppName + " " + MyAppVersion - -; File Names -#define ExeName "MTConnect-MQTT-Relay-Gateway-Agent.exe" - - -[Setup] -; NOTE: The value of AppId uniquely identifies this application. -; Do not use the same AppId value in installers for other applications. -; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) -AppId={{F5F94031-BFAD-4E9C-9A36-A36D8CD5AB36} - -AppName={#MyAppName} -AppVersion={#MyAppVersion} -AppVerName={#MyAppName} {#MyAppVersion} -AppPublisher={#MyAppPublisher} -AppPublisherURL={#MyAppURL} -AppSupportURL={#MyAppURL} -AppUpdatesURL={#MyAppURL} -AppReadmeFile=https://github.com/TrakHound/MTConnect.NET -VersionInfoVersion={#MyAppVersion} -ArchitecturesInstallIn64BitMode=x64 - -PrivilegesRequired=admin -DisableProgramGroupPage=no -Compression=lzma -SolidCompression=yes - -; Names -DisableDirPage=auto -DisableReadyPage=no -DisableFinishedPage=no -OutputDir=bin\Publish -DefaultDirName={autopf}\{#MyAppPublisher}\MTConnect-MQTT-Relay-Gateway-Agent -UsePreviousAppDir=false -OutputBaseFilename=MTConnect-MQTT-Relay-Gateway-Agent-Install-v{#MyAppVersion} -UninstallDisplayName={#MyAppName} v{#MyAppVersion} -UninstallFilesDir={app}\Uninstall - -[Types] -Name: "win64net7"; Description: "Windows x64 .NET 7" -Name: "win86net7"; Description: "Windows x86 .NET 7" -Name: "win64net6"; Description: "Windows x64 .NET 6" -Name: "win86net6"; Description: "Windows x86 .NET 6" -Name: "win64net48"; Description: "Windows x64 .NET 4.8 Framework" -Name: "win86net48"; Description: "Windows x86 .NET 4.8 Framework" -Name: "win64net461"; Description: "Windows x64 .NET 4.6.1 Framework" -Name: "win86net461"; Description: "Windows x86 .NET 4.6.1 Framework" - -[Components] -Name: "win64net7"; Description: "{#MyAppVerName}"; Types: win64net7 -Name: "win86net7"; Description: "{#MyAppVerName}"; Types: win86net7 -Name: "win64net6"; Description: "{#MyAppVerName}"; Types: win64net6 -Name: "win86net6"; Description: "{#MyAppVerName}"; Types: win86net6 -Name: "win64net48"; Description: "{#MyAppVerName}"; Types: win64net48 -Name: "win86net48"; Description: "{#MyAppVerName}"; Types: win86net48 -Name: "win64net461"; Description: "{#MyAppVerName}"; Types: win64net461 -Name: "win86net461"; Description: "{#MyAppVerName}"; Types: win86net461 -Name: "configuration"; Description: "Configuration Files"; Types: win86net461 win64net461 win86net48 win64net48 win86net6 win64net6 win86net7 win64net7 - - -[Languages] -Name: "english"; MessagesFile: "compiler:Default.isl" - -[Dirs] -Name: "{app}"; Permissions: everyone-full -Name: "{app}\logs"; Permissions: everyone-full - -[Files] - -; Program Files -Source: "bin\release\net7.0\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net7; -Source: "bin\release\net7.0\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net7; -Source: "bin\release\net6.0\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net6; -Source: "bin\release\net6.0\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net6; -Source: "bin\release\net48\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net48; -Source: "bin\release\net48\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net48; -Source: "bin\release\net461\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net461; -Source: "bin\release\net461\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net461; - - -[Run] - -; Install and Run Windows Service -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""stop""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Stopping Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""remove""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Uninstalling Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""install""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Installing Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""start""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Starting Windows Service..."; - -; Start Browser -Filename: {sys}\cmd.exe; Parameters: "/c explorer ""agent.config.yaml""" ; WorkingDir: {app}; Flags: runhidden postinstall unchecked; Description: Open Agent Configuration File; -Filename: {sys}\cmd.exe; Parameters: "/c explorer ""NLog.config""" ; WorkingDir: {app}; Flags: runhidden postinstall unchecked; Description: Open Log Configuration File; -Filename: {sys}\cmd.exe; Parameters: "/c explorer ""{app}""" ; Flags: runhidden postinstall unchecked; Description: Open Install Directory; - - -[UninstallRun] - -; Stop Server Service -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""stop""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Stopping Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""remove""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Uninstalling Windows Service..."; diff --git a/applications/Agents/MTConnect-Agent-MQTT-Relay/MTConnect-Agent-MQTT-Relay.csproj b/applications/Agents/MTConnect-Agent-MQTT-Relay/MTConnect-Agent-MQTT-Relay.csproj deleted file mode 100644 index 2ad93c11..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Relay/MTConnect-Agent-MQTT-Relay.csproj +++ /dev/null @@ -1,62 +0,0 @@ - - - - net6.0 - - - net461;net48;net6.0;net7.0 - false - None - true - - - net461;net462;net47;net471;net472;net48;netstandard2.0;netcoreapp3.1;net5.0;net6.0 - - - - Debug;Release;Docker - false - agent - Exe - MTConnect - MTConnect.Applications.Program - disable - - - - - - - - - - - - - - - - - - - - Always - - - Never - - - Always - - - Always - - - Always - - - Never - - - - diff --git a/applications/Agents/MTConnect-Agent-MQTT-Relay/Program.cs b/applications/Agents/MTConnect-Agent-MQTT-Relay/Program.cs deleted file mode 100644 index 3f8beb7b..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Relay/Program.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. -// TrakHound Inc. licenses this file to you under the MIT license. - -using MTConnect.Applications.Agents; -using System; -using System.Reflection; - -namespace MTConnect.Applications -{ - public class Program - { - // This is the Application Name shown in the Console header information - // If you are implementing this into your own application, you can change this to be more specific (ex. Fanuc MTConnect Agent, Mazak MTConnect Agent, etc.) - private const string ApplicationName = "MTConnect MQTT Relay Agent"; - - // Copyright statement for the application. If you are implementing this into your own application, you can change this to your own copyright. - // This is just what is shown in the console header. If you want to show support for the MTConnect.NET project, you can reference it using the links in the default header - private const string ApplicationCopyright = "Copyright 2023 TrakHound Inc., All Rights Reserved"; - - public static void Main(string[] args) - { - // Print an application header to the console - PrintConsoleHeader(); - - // Create a new MTConnect Agent Application - // This handles all MTConnect Agent functionality along with - // an HTTP server, SHDR Adapters, Command line arguments, Device management, Buffer management, Logging, Windows Service, and Configuration File management - var agentApplication = new MTConnectShdrMqttRelayAgentApplication(); - - // Use the regular MTConnectMqttAgentApplication if you are not using SHDR Adapters - ///var agentApplication = new MTConnectMqttAgentApplication(); - - // Run the Agent ('true' parameter blocks the call so the application does not continue) - agentApplication.Run(args, true); - - // Use the 'false' parameter if you are implementing this into an existing application or are handling blocking elsewhere - //agentApplication.Run(args, false); - - // ** This is where the rest of your application can go. ** - // For example, if you are developing the Agent to read directly from a PLC, this would be where you can place the PLC reading code - } - - - private static void PrintConsoleHeader() - { - var assembly = Assembly.GetExecutingAssembly(); - var version = assembly.GetName().Version; - - Console.WriteLine("--------------------"); - Console.WriteLine(ApplicationCopyright); - Console.WriteLine(ApplicationName + " : Version " + version.ToString()); - Console.WriteLine("--------------------"); - Console.WriteLine("This application is licensed under the MIT License (https://choosealicense.com/licenses/mit/)"); - Console.WriteLine("Source code available at Github.com (https://github.com/TrakHound/MTConnect.NET)"); - Console.WriteLine("--------------------"); - } - } -} diff --git a/applications/Agents/MTConnect-Agent-MQTT-Relay/README.md b/applications/Agents/MTConnect-Agent-MQTT-Relay/README.md deleted file mode 100644 index f146d1f6..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Relay/README.md +++ /dev/null @@ -1,276 +0,0 @@ -![MTConnect.NET Logo](https://raw.githubusercontent.com/TrakHound/MTConnect.NET/dev/img/mtconnect-net-03-md.png) - -# MTConnect MQTT Relay Agent - -[![MTConnect.NET](https://github.com/TrakHound/MTConnect.NET/actions/workflows/dotnet.yml/badge.svg)](https://github.com/TrakHound/MTConnect.NET/actions/workflows/dotnet.yml) - -## Overview -This project is a full implementation of an MTConnect Agent used to read data from industrial machine tools and devices. This MTConnect Agent application is fully compatible with the latest **Version 2.2 of the MTConnect Standard**. It uses the SHDR protocol to receive data from Adapters and an MQTT client to publish messages to an external MQTT Broker. - -#### Features -- MQTT client to publish to an external broker -- Easy setup with Windows Installers availble in the latest [Releases](https://github.com/TrakHound/MTConnect.NET/releases) -- Options to run as Windows Service or as a console application (typically for testing/debugging) -- Optional 'Durable' buffer used to retain the Agent data between application/machine restarts -- High performance / Low resource usage -- Flexible Device configurations (traditional 'devices.xml' file or 'devices' directory with individual Device files) -- SHDR protocol compatibility for easy implementation with existing MTConnect Adapters -- Configuration File monitoring to automatically restart the Agent upon configuration file changes -- Flexible Logging using NLog which can be used to output log information to separate files for easier analysis - - -![MQTT Agent Architecture](https://raw.githubusercontent.com/TrakHound/MTConnect.NET/master/img/mtconnect-agent-shdr-mqtt-communication-white.png) - -## Download -To download the latest release as a Windows Installer, use the link below: - -- [Download Latest Release Windows Installer](https://github.com/TrakHound/MTConnect.NET/releases/download/v5.1.0/TrakHound-MTConnect-MQTT-Relay-Agent-Install-v5.1.0.exe) - - -## Usage -The Agent can be run from a command line prompt or as a Windows Service using the format below: -``` -agent [help|install|install-start|start|stop|remove|debug|run|run-service] [configuration_file] [mqtt_port] - --------------------- - -Options : - - help | Prints usage information - install | Install as a Service - install-start | Install as a Service and Start the Service - start | Start the Service - stop | Stop the Service - remove | Remove the Service - debug | Runs the Agent in the terminal (with verbose logging) - run | Runs the Agent in the terminal - run-service | Runs the Agent as a Service - -Arguments : --------------------- - - configuration_file | Specifies the Agent Configuration file to load - Default : agent.config.json - - mqtt_port | Specifies the TCP Port to use for the MQTT client - Note : This overrides what is read from the Configuration file -``` -#### Example 1: -Install the Agent as a Windows Service (Note: requires Administrator Privileges) - > agent install - -#### Example 2: -Install the Agent as a Windows Service using the configuration file "agent-config.json" and Starts the service (Note: requires Administrator Privileges) -> agent install-start agent-config.json - -#### Example 3: -Starts the Windows Service (Note: requires Administrator Privileges) -> agent start - -#### Example 4: -Runs the Agent in the command line prompt using verbose logging and overrides the MQTT Port to 1884 -> agent debug "" 1884 - - -## MQTT Topic Structure -For more information on MQTT Topics [Click Here](https://github.com/TrakHound/MTConnect.NET/tree/master/src/MTConnect.NET-MQTT) - -#### Devices -``` -MTConnect/Devices/[DEVICE_UUID]/Device -``` - -#### Observations -``` -MTConnect/Devices/[DEVICE_UUID]/Observations/[COMPONENT_TYPE]/[COMPONENT_ID]/[DATA_ITEM_CATEGORY]/[DATA_ITEM_TYPE]/[DATA_ITEM_ID] -MTConnect/Devices/[DEVICE_UUID]/Observations/[COMPONENT_TYPE]/[COMPONENT_ID]/[DATA_ITEM_CATEGORY]/[DATA_ITEM_TYPE]/SubTypes/[DATA_ITEM_SUBTYPE]/[DATA_ITEM_ID] -``` -##### Conditions -Condition messages are sent as an array of Observations since a Condition may have multiple Fault States. This is similar to how the Current request functions in an HTTP Agent. - -#### Assets -``` -MTConnect/Devices/[DEVICE_UUID]/Assets/[ASSET_TYPE]/[ASSET_ID] -MTConnect/Assets/[ASSET_TYPE]/[ASSET_ID] -``` -> Note: Assets are sent to two topics. One for the "Global" assets and one for the Device that the Asset was added to - -#### Agent -The Agent topic contains information that would normally be in the Header of a Response Document from an HTTP Agent. -``` -MTConnect/Assets/[AGENT_UUID] -``` - - -## Configuration -More information about [Configurations](https://github.com/TrakHound/MTConnect.NET/tree/master/src/MTConnect.NET-Common/Configurations). The default configuration file is shown below : -```yaml -# - Device Configuration - -devices: devices - -# - SHDR Adapter Configuration - -# The Agent is able to receive data through a TCP port using the SHDR protocol -adapters: -- hostname: localhost - port: 7878 - reconnectInterval: 1000 - -# - MQTT Configuration - - -# The hostname of the MQTT broker to publish messages to -server: localhost - -# The port number of the MQTT broker to publish messages to -port: 1883 -``` - -#### MQTT Configuration - -* `port` - The port number of the external MQTT broker to publish messages to. - -* `server` - The server hostname of the external MQTT broker to publish messages to. - -* `username` - The username of the external MQTT broker to publish messages to. - -* `password` - The password of the external MQTT broker to publish messages to. - -* `useTls` - Sets whether to use TLS in the connection to the external MQTT broker to publish messages to. - - -#### Agent Configuration - -* `observationBufferSize` - The maximum number of Observations the agent can hold in its buffer - -* `assetBufferSize` - The maximum number of assets the agent can hold in its buffer - -* `durable` - Sets whether the Agent buffers are durable and retain state after restart - -* `useBufferCompression` - Sets whether the durable Agent buffers use Compression - -* `ignoreTimestamps` - Overwrite timestamps with the agent time. This will correct clock drift but will not give as accurate relative time since it will not take into consideration network latencies. This can be overridden on a per adapter basis. - -* `defaultVersion` - Sets the default MTConnect version to output response documents for. - -* `convertUnits` - Sets the default for Converting Units when adding Observations - -* `ignoreObservationCase` - Sets the default for Ignoring the case of Observation values. Applicable values will be converted to uppercase - -* `inputValidationLevel` - Sets the default input validation level when new Observations are added to the Agent. 0 = Ignore, 1 = Warning, 2 = Strict - -* `monitorConfigurationFiles` - Sets whether Configuration files are monitored. If enabled and a configuration file is changed, the Agent will restart - -* `configurationFileRestartInterval` - Sets the minimum time (in seconds) between Agent restarts when MonitorConfigurationFiles is enabled - -* `enableMetrics` - Sets whether Agent Metrics are captured (ex. ObserationUpdateRate, AssetUpdateRate) - - -#### Device Configuration - -* `devices` - The Path to look for the file(s) that represent the Device Information Models to load into the Agent. The path can either be a single file or a directory. The path can be absolute or relative to the executable's directory - -#### Adapter Configuration - -* `adapters` - List of SHDR Adapter connection configurations. For more information see() - -* `allowShdrDevice` - Sets whether a Device Model can be sent from an SHDR Adapter - -* `preserveUuid` - Do not overwrite the UUID with the UUID from the adapter, preserve the UUID for the Device. This can be overridden on a per adapter basis. - -* `suppressIpAddress` - Suppress the Adapter IP Address and port when creating the Agent Device ids and names for 1.7. This applies to all adapters. - -* `timeout` - The amount of time (in milliseconds) an adapter can be silent before it is disconnected. - -* `reconnectInterval` - The amount of time (in milliseconds) between adapter reconnection attempts. - -#### Windows Service Configuration - -* `serviceName` - Changes the service name when installing or removing the service. This allows multiple agents to run as services on the same machine. - -* `serviceAutoStart` - Sets the Service Start Type. True = Auto | False = Manual - - -## Logging -Logging is done using [NLog](https://github.com/NLog/NLog) which allows for customized logging through the NLog.config file located in the application's install directory. The loggers are setup so that there is a separate logger for: -- **(agent-logger)** MTConnect Agent -- **(agent-validation-logger)** MTConnect Data Validation Errors -- **(http-logger)** Http Server -- **(adapter-logger)** MTConnect Adapters -- **(adapter-shdr-logger)** Raw SHDR lines read by the Adapter (used for debugging adapters) - -The default [NLog Configuration File](https://github.com/TrakHound/MTConnect.NET/blob/master/src/MTConnect.NET-Applications-Agents/NLog.config) is shown below: - -```xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -``` - -## Releases -Releases for this application are located under the Releases tab. The current release is listed below: -- [MTConnect Agent Current Release](https://github.com/TrakHound/MTConnect.NET/releases) - -## Source Code -This project uses the MTConnect.NET-Applications-Agents-MQTT library (available on [Nuget](https://www.nuget.org/packages/MTConnect.NET-Applications-Agents-MQTT)) to create an MTConnect Agent application. More information about this library can be found [Here](https://github.com/TrakHound/MTConnect.NET/tree/master/src/MTConnect.NET-Applications-Agents-MQTT). The MTConnect.NET-Applications-Agents-MQTT library makes creating an MTConnect MQTT Agent application simple as well as makes it easy to keep updated using Nuget. A fully functionaly MTConnect Application can be created in just a few lines of code. - -## Contribution / Feedback -- Please use the [Issues](https://github.com/TrakHound/MTConnect.NET/issues) tab to create issues for specific problems that you may encounter -- Please feel free to use the [Pull Requests](https://github.com/TrakHound/MTConnect.NET/pulls) tab for any suggested improvements to the source code -- For any other questions or feedback, please contact TrakHound directly at **info@trakhound.com**. - -## License -This application and it's source code is licensed under the [MIT License](https://choosealicense.com/licenses/mit/) and is free to use. diff --git a/applications/Agents/MTConnect-Agent-MQTT-Relay/agent.config.default.yaml b/applications/Agents/MTConnect-Agent-MQTT-Relay/agent.config.default.yaml deleted file mode 100644 index f118f076..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Relay/agent.config.default.yaml +++ /dev/null @@ -1,66 +0,0 @@ -# - Device Configuration - -# The Path to look for the file(s) that represent the Device Information Models to load into the Agent. -# The path can either be a single file or a directory. -# The path can be absolute or relative to the executable's directory -devices: devices - -# - SHDR Adapter Configuration - -# The Agent is able to receive data through a TCP port using the SHDR protocol -adapters: -- hostname: localhost - port: 7878 - reconnectInterval: 1000 - -# Sets whether a Device Model can be sent from an SHDR Adapter -allowShdrDevice: false - - -# - Windows Service Configuration - -# Changes the service name when installing or removing the service. This allows multiple agents to run as services on the same machine. -serviceName: MTConnect-Agent-MQTT-Relay - -# Sets the Service Start Type. True = Auto | False = Manual -serviceAutoStart: true - - -# - MQTT Configuration - - -# The hostname of the MQTT broker to publish messages to -server: localhost - -# The port number of the MQTT broker to publish messages to -port: 1883 - -# The Intervals to publish Observations at (in milliseconds) -observationIntervals: -- 0 -- 100 -- 1000 - - -# - Agent Configuration - - -# Sets the default MTConnect version to output response documents for. -defaultVersion: 2.1 - -# Overwrite timestamps with the agent time. This will correct clock drift but will not give as accurate relative time since it will not take into consideration network latencies. This can be overridden on a per adapter basis. -ignoreTimestamps: false - -# Sets the default for Converting Units when adding Observations -convertUnits: true - -# Sets the default for Ignoring the case of Observation values. Applicable values will be converted to uppercase -ignoreObservationCase: true - -# Sets the default input validation level when new Observations are added to the Agent. 0 = Ignore, 1 = Warning, 2 = Strict -inputValidationLevel: Ignore - -# Sets whether Configuration files are monitored. If enabled and a configuration file is changed, the Agent will restart -monitorConfigurationFiles: true - -# Sets the minimum time (in seconds) between Agent restarts when MonitorConfigurationFiles is enabled -configurationFileRestartInterval: 2 - -# Sets whether Agent Metrics are captured (ex. ObserationUpdateRate, AssetUpdateRate) -enableMetrics: true diff --git a/applications/Agents/MTConnect-Agent-MQTT-Relay/build.bat b/applications/Agents/MTConnect-Agent-MQTT-Relay/build.bat deleted file mode 100644 index 65498a7e..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Relay/build.bat +++ /dev/null @@ -1,3 +0,0 @@ -dotnet build -c:Release -r:win-x86 --no-self-contained -dotnet build -c:Release -r:win-x64 --no-self-contained -"c:\Program Files (x86)\Inno Setup 6\iscc" installer.iss diff --git a/applications/Agents/MTConnect-Agent-MQTT-Relay/devices/device-mazak.xml b/applications/Agents/MTConnect-Agent-MQTT-Relay/devices/device-mazak.xml deleted file mode 100644 index f25afa33..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Relay/devices/device-mazak.xml +++ /dev/null @@ -1,450 +0,0 @@ - - Mill w/SMooth-G - - - - - 0 0 0 - 0 0 0 - - - - - 0 0 0 - 0 0 0 - - - - - - - 2.0 3.0 4.0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - spindle_speed - - - - - - - - - - - - - - - - 0.5 - - - - - - - - - - - - 200.0 - 0.0 - - - - - - - - - - - - - - - - 0.5 - - - - - - - - - - - - - - - - - 3 - - - - - - 0.5 - - - - - - - - - - - The linears Z kinematics - 100.0 101.0 102.0 - 0.0 0.1 1.0 - - - - - - - - 3 - - - - - - - - - CONTOUR - INDEX - - - - - - - - - - - - - 3 - - - - - 3 - - - - - - - 5 - - - - - 0.5 - - - - - - - SPINDLE - INDEX - - - - - - - - - - - - - - - - The spindle kinematics - - 10.0 20.0 30.0 - 90.0 0.0 180 - - 0.0 0.5 1.0 - - - - 10000 - 100 - 1000 - - - 1000 - -1000 - 100 - 500 - -500 - 200 - -200 - - - - 500 - 50 - -500 - - - 500 - -500 - 10 - 200 - -200 - - - 500 - -500 - 200 - -200 - - - - - - - - - - - - - - - - - - - - - 101 102 103 - - - - 10 10 10 - 90 0 90 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - A Complex Workpiece Offset Table - - - Some Pressure thing - - - Pressure of the P - - - - - - - - - - - - - - Spindle Angle - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0.5 - - - - - - - - - - - - - - - - - - - - - - - - 0.5 - - - - - - - - 2.02 - 2010-05-16 - 2010-05-16 - WS - - - A/D With Thermister - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/applications/Agents/MTConnect-Agent-MQTT-Relay/devices/device-okuma.xml b/applications/Agents/MTConnect-Agent-MQTT-Relay/devices/device-okuma.xml deleted file mode 100644 index 2ca2b65b..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Relay/devices/device-okuma.xml +++ /dev/null @@ -1,168 +0,0 @@ - - - Okuma MT Connect Adapter - Lathe - - - - - - - - - - - - - - - - - - - SPINDLE - - - - OPEN - - - - - - - - - - - - - - - - SPINDLE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/applications/Agents/MTConnect-Agent-MQTT-Relay/installer.iss b/applications/Agents/MTConnect-Agent-MQTT-Relay/installer.iss deleted file mode 100644 index ca820f30..00000000 --- a/applications/Agents/MTConnect-Agent-MQTT-Relay/installer.iss +++ /dev/null @@ -1,109 +0,0 @@ -; MTConnect MQTT Relay Agent Installer -; ------------------------------ - -#define MyAppName "MTConnect MQTT Relay Agent" -#define MyAppVersion "1.0.0" -#define MyAppPublisher "MTConnect" -#define MyAppURL "" -#define MyAppVerName MyAppName + " " + MyAppVersion - -; File Names -#define ExeName "MTConnect-MQTT-Relay-Agent.exe" - - -[Setup] -; NOTE: The value of AppId uniquely identifies this application. -; Do not use the same AppId value in installers for other applications. -; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) -AppId={{F5F94031-BFAD-4E9C-9A36-A36D8CD5AB36} - -AppName={#MyAppName} -AppVersion={#MyAppVersion} -AppVerName={#MyAppName} {#MyAppVersion} -AppPublisher={#MyAppPublisher} -AppPublisherURL={#MyAppURL} -AppSupportURL={#MyAppURL} -AppUpdatesURL={#MyAppURL} -AppReadmeFile=https://github.com/TrakHound/MTConnect.NET -VersionInfoVersion={#MyAppVersion} -ArchitecturesInstallIn64BitMode=x64 - -PrivilegesRequired=admin -DisableProgramGroupPage=no -Compression=lzma -SolidCompression=yes - -; Names -DisableDirPage=auto -DisableReadyPage=no -DisableFinishedPage=no -OutputDir=bin\Publish -DefaultDirName={autopf}\{#MyAppPublisher}\MTConnect-MQTT-Relay-Agent -UsePreviousAppDir=false -OutputBaseFilename=MTConnect-MQTT-Relay-Agent-Install-v{#MyAppVersion} -UninstallDisplayName={#MyAppName} v{#MyAppVersion} -UninstallFilesDir={app}\Uninstall - -[Types] -Name: "win64net7"; Description: "Windows x64 .NET 7" -Name: "win86net7"; Description: "Windows x86 .NET 7" -Name: "win64net6"; Description: "Windows x64 .NET 6" -Name: "win86net6"; Description: "Windows x86 .NET 6" -Name: "win64net48"; Description: "Windows x64 .NET 4.8 Framework" -Name: "win86net48"; Description: "Windows x86 .NET 4.8 Framework" -Name: "win64net461"; Description: "Windows x64 .NET 4.6.1 Framework" -Name: "win86net461"; Description: "Windows x86 .NET 4.6.1 Framework" - -[Components] -Name: "win64net7"; Description: "{#MyAppVerName}"; Types: win64net7 -Name: "win86net7"; Description: "{#MyAppVerName}"; Types: win86net7 -Name: "win64net6"; Description: "{#MyAppVerName}"; Types: win64net6 -Name: "win86net6"; Description: "{#MyAppVerName}"; Types: win86net6 -Name: "win64net48"; Description: "{#MyAppVerName}"; Types: win64net48 -Name: "win86net48"; Description: "{#MyAppVerName}"; Types: win86net48 -Name: "win64net461"; Description: "{#MyAppVerName}"; Types: win64net461 -Name: "win86net461"; Description: "{#MyAppVerName}"; Types: win86net461 -Name: "configuration"; Description: "Configuration Files"; Types: win86net461 win64net461 win86net48 win64net48 win86net6 win64net6 win86net7 win64net7 - - -[Languages] -Name: "english"; MessagesFile: "compiler:Default.isl" - -[Dirs] -Name: "{app}"; Permissions: everyone-full -Name: "{app}\logs"; Permissions: everyone-full -Name: "{app}\devices"; Permissions: everyone-full -Name: "{app}\styles"; Permissions: everyone-full - -[Files] - -; Program Files -Source: "bin\release\net7.0\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net7; -Source: "bin\release\net7.0\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net7; -Source: "bin\release\net6.0\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net6; -Source: "bin\release\net6.0\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net6; -Source: "bin\release\net48\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net48; -Source: "bin\release\net48\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net48; -Source: "bin\release\net461\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win64net461; -Source: "bin\release\net461\win-x86\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Permissions: everyone-full; Components: win86net461; - - -[Run] - -; Install and Run Windows Service -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""stop""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Stopping Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""remove""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Uninstalling Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""install""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Installing Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""start""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Starting Windows Service..."; - -; Start Browser -Filename: {sys}\cmd.exe; Parameters: "/c explorer ""agent.config.yaml""" ; WorkingDir: {app}; Flags: runhidden postinstall unchecked; Description: Open Agent Configuration File; -Filename: {sys}\cmd.exe; Parameters: "/c explorer ""NLog.config""" ; WorkingDir: {app}; Flags: runhidden postinstall unchecked; Description: Open Log Configuration File; -Filename: {sys}\cmd.exe; Parameters: "/c explorer ""{app}""" ; Flags: runhidden postinstall unchecked; Description: Open Install Directory; - - -[UninstallRun] - -; Stop Server Service -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""stop""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Stopping Windows Service..."; -Filename: {sys}\cmd.exe; Parameters: "/c agent.exe ""remove""" ; WorkingDir: {app}; Flags: runhidden; StatusMsg: "Uninstalling Windows Service..."; diff --git a/applications/Agents/README.md b/applications/Agents/README.md deleted file mode 100644 index d56876f3..00000000 --- a/applications/Agents/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# MTConnect.NET Agent Applications - -### Recommended (General purpose Windows or Linux) - -- [MTConnect HTTP Agent](https://github.com/TrakHound/MTConnect.NET/tree/master/applications/Agents/MTConnect-Agent-Http) : This MTConnect Agent application is fully compatible with the latest Version 2.2 of the MTConnect Standard. It uses the SHDR protocol to receive data from Adapters, an in-memory buffer with an optional durable file system based buffer, and an Http REST interface for retrieving data. - -- [MTConnect HTTP Gateway Agent](https://github.com/TrakHound/MTConnect.NET/tree/master/applications/Agents/MTConnect-Agent-Http-Gateway) : This MTConnect Agent application is fully compatible with the latest Version 2.2 of the MTConnect Standard. It receives data from other MTConnect Agents using HTTP, an in-memory buffer with an optional durable file system based buffer, and an Http REST interface for retrieving data. - -- [MTConnect MQTT Relay Agent](https://github.com/TrakHound/MTConnect.NET/tree/master/applications/Agents/MTConnect-Agent-MQTT-Relay) : This MTConnect Agent application is fully compatible with the latest Version 2.2 of the MTConnect Standard. It uses the SHDR protocol to receive data from Adapters, an in-memory buffer with an optional durable file system based buffer, and an MQTT client to publish messages to an external MQTT Broker. - -- [MTConnect MQTT Broker Agent](https://github.com/TrakHound/MTConnect.NET/tree/master/applications/Agents/MTConnect-Agent-MQTT-Broker) : This MTConnect Agent application is fully compatible with the latest Version 2.2 of the MTConnect Standard. It uses the SHDR protocol to receive data from Adapters, an in-memory buffer with an optional durable file system based buffer, and a built-in MQTT broker. - -- [MTConnect MQTT Relay Gateway Agent](https://github.com/TrakHound/MTConnect.NET/tree/master/applications/Agents/MTConnect-Agent-MQTT-Relay-Gateway) : This MTConnect Agent application is fully compatible with the latest Version 2.2 of the MTConnect Standard. It receives data from other MTConnect Agents using HTTP and an MQTT client to publish messages to an external MQTT Broker. - -- [MTConnect MQTT Broker Gateway Agent](https://github.com/TrakHound/MTConnect.NET/tree/master/applications/Agents/MTConnect-Agent-MQTT-Broker-Gateway) : This MTConnect Agent application is fully compatible with the latest Version 2.2 of the MTConnect Standard. It receives data from other MTConnect Agents using HTTP and a built-in MQTT broker. - -### Specialized (For use with IIS) - -- [MTConnect HTTP Agent - AspNetCore](https://github.com/TrakHound/MTConnect.NET/tree/master/applications/Agents/MTConnect-Agent-Http-AspNetCore) : Similar to the MTConnect Agent application but uses either the built-in Kestrel server or can be setup through IIS (Internet Information Services). This allows the agent to be used with all of the features available through ASP.NET and IIS such as security, permissions, monitoring, etc. - -- [MTConnect HTTP Gateway Agent - AspNetCore](https://github.com/TrakHound/MTConnect.NET/tree/master/applications/Agents/MTConnect-Agent-Http-Gateway-AspNetCore) : An Agent that runs mulitple MTConnectClients on the backend and passes that data to an MTConnectAgent. This can be used to access MTConnect data on a central server. Uses either the built-in Kestrel server or can be setup through IIS (Internet Information Services). This allows the agent to be used with all of the features available through ASP.NET and IIS such as security, permissions, monitoring, etc. diff --git a/applications/Clients/MTConnect.NET-Client-Example-01/Assets.cs b/applications/Clients/MTConnect.NET-Client-Example-01/Assets.cs deleted file mode 100644 index 1c0f3f14..00000000 --- a/applications/Clients/MTConnect.NET-Client-Example-01/Assets.cs +++ /dev/null @@ -1,39 +0,0 @@ -using MTConnect.Clients.Rest; - -var agentUrl = "localhost:5000"; -//var agentUrl = "mtconnect.mazakcorp.com:5719"; - -var client = new MTConnectAssetClient(agentUrl, MTConnect.DocumentFormat.XML); -while (true) -{ - var stpw = System.Diagnostics.Stopwatch.StartNew(); - - var doc = await client.GetAsync(CancellationToken.None); - - stpw.Stop(); - var ms = (double)((double)stpw.ElapsedTicks / 10000); - - if (doc != null) - { - if (doc.Assets.Count() > 0) - { - Console.WriteLine(doc.Assets.Count() + " Assets Found in " + ms + "ms"); - Console.WriteLine("---------------"); - - foreach (var asset in doc.Assets) - { - Console.WriteLine(asset.AssetId); - } - } - else - { - Console.WriteLine("No Assets Found in " + ms + "ms"); - } - } - else - { - Console.WriteLine("Error During Request in " + ms + "ms"); - } - - Console.ReadLine(); -} diff --git a/applications/Clients/MTConnect.NET-Client-Example-01/CertTest.cs b/applications/Clients/MTConnect.NET-Client-Example-01/CertTest.cs deleted file mode 100644 index 3d1ea33e..00000000 --- a/applications/Clients/MTConnect.NET-Client-Example-01/CertTest.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.IO; -using System.Security.Cryptography; -using System.Security.Cryptography.X509Certificates; - -public class CertificateUtil -{ - public static void MakeCert() - { - var ecdsa = ECDsa.Create(); // generate asymmetric key pair - var req = new CertificateRequest("cn=foobar", ecdsa, HashAlgorithmName.SHA256); - var cert = req.CreateSelfSigned(DateTimeOffset.Now, DateTimeOffset.Now.AddYears(5)); - - // Create PFX (PKCS #12) with private key - File.WriteAllBytes("c:\\temp\\mycert.pfx", cert.Export(X509ContentType.Pfx, "P@55w0rd")); - - // Create Base 64 encoded CER (public key only) - File.WriteAllText("c:\\temp\\mycert.cer", - "-----BEGIN CERTIFICATE-----\r\n" - + Convert.ToBase64String(cert.Export(X509ContentType.Cert), Base64FormattingOptions.InsertLineBreaks) - + "\r\n-----END CERTIFICATE-----"); - } -} \ No newline at end of file diff --git a/applications/Clients/MTConnect.NET-Client-Example-01/ClientRequests.cs b/applications/Clients/MTConnect.NET-Client-Example-01/ClientRequests.cs deleted file mode 100644 index fa885c46..00000000 --- a/applications/Clients/MTConnect.NET-Client-Example-01/ClientRequests.cs +++ /dev/null @@ -1,38 +0,0 @@ -using MTConnect.Clients.Rest; - -//var deviceName = "OKUMA-Lathe"; -//var deviceName = "M12346"; - -var agentUrl = "127.0.0.1:5005"; -//var agentUrl = "127.0.0.1:5005"; -//var agentUrl = "localhost:5000"; -//var agentUrl = "mtconnect.mazakcorp.com:5719"; - -var client = new MTConnectClient(agentUrl); -//var client = new MTConnectClient(agentUrl, deviceName); - - -var probe = client.GetProbe(); -if (probe != null) -{ - -} - -Console.ReadLine(); - - -var current = client.GetCurrent(); -if (current != null) -{ - -} - -Console.ReadLine(); - -var sample = client.GetSample(); -if (sample != null) -{ - -} - -Console.ReadLine(); diff --git a/applications/Clients/MTConnect.NET-Client-Example-01/CppAgentJsonClient.cs b/applications/Clients/MTConnect.NET-Client-Example-01/CppAgentJsonClient.cs deleted file mode 100644 index e6d81bcf..00000000 --- a/applications/Clients/MTConnect.NET-Client-Example-01/CppAgentJsonClient.cs +++ /dev/null @@ -1,76 +0,0 @@ -using MTConnect.Clients; -using MTConnect.Observations; - -var agentUrl = "localhost:5001"; - -var client = new MTConnectHttpClient(agentUrl); -client.Interval = 100; -client.Heartbeat = 10000; -client.ContentType = "application/json"; -client.DocumentFormat = "json-cppagent"; -client.DeviceReceived += (sender, device) => -{ - Console.WriteLine($"Device Received : {device.Uuid}"); -}; -client.ObservationReceived += (sender, observation) => -{ - switch (observation.Representation) - { - case MTConnect.Devices.DataItemRepresentation.VALUE: - Console.WriteLine($"Observation Received : {observation.DataItemId} = {observation.GetValue("Result")} @ {observation.Timestamp}"); - break; - - case MTConnect.Devices.DataItemRepresentation.DATA_SET: - if (!observation.IsUnavailable) - { - var entries = DataSetObservation.GetEntries(observation.Values); - foreach (var entry in entries) - { - Console.WriteLine($"Observation Received : {observation.DataItemId} : DATA_SET : {entry.Key} = {entry.Value} @ {observation.Timestamp}"); - } - } - else - { - Console.WriteLine($"Observation Received : {observation.DataItemId} = {observation.GetValue("Result")} @ {observation.Timestamp}"); - } - break; - - case MTConnect.Devices.DataItemRepresentation.TABLE: - if (!observation.IsUnavailable) - { - var entries = TableObservation.GetEntries(observation.Values); - foreach (var entry in entries) - { - foreach (var cell in entry.Cells) - { - Console.WriteLine($"Observation Received : {observation.DataItemId} : TABLE : {entry.Key} : {cell.Key} = {cell.Value} @ {observation.Timestamp}"); - } - } - } - else - { - Console.WriteLine($"Observation Received : {observation.DataItemId} = {observation.GetValue("Result")} @ {observation.Timestamp}"); - } - break; - - case MTConnect.Devices.DataItemRepresentation.TIME_SERIES: - if (!observation.IsUnavailable) - { - var samples = TimeSeriesObservation.GetSamples(observation.Values).ToList(); - Console.WriteLine($"Observation Received : {observation.DataItemId} : TIME_SERIES : {string.Join(" ", samples)} @ {observation.Timestamp}"); - } - else - { - Console.WriteLine($"Observation Received : {observation.DataItemId} = {observation.GetValue("Result")} @ {observation.Timestamp}"); - } - break; - } -}; -client.AssetReceived += (sender, asset) => -{ - Console.WriteLine($"Asset Received : {asset.AssetId}"); -}; - -client.Start(); - -Console.ReadLine(); diff --git a/applications/Clients/MTConnect.NET-Client-Example-01/CppAgentMqttClient.cs b/applications/Clients/MTConnect.NET-Client-Example-01/CppAgentMqttClient.cs deleted file mode 100644 index d5e78a41..00000000 --- a/applications/Clients/MTConnect.NET-Client-Example-01/CppAgentMqttClient.cs +++ /dev/null @@ -1,116 +0,0 @@ -using MTConnect; -using MTConnect.Clients; -using MTConnect.Observations; - -var server = "localhost"; - -var i = -1; - -var client = new MTConnectMqtt2Client(server, clientId: "patrick-test"); -//client.Interval = 100; -//client.Heartbeat = 10000; -//client.ContentType = "application/json"; -//client.DocumentFormat = "json-cppagent"; -client.DeviceReceived += (sender, device) => -{ - Console.WriteLine($"Device Received : {device.Uuid}"); -}; -client.ObservationReceived += (sender, observation) => -{ - switch (observation.Representation) - { - case MTConnect.Devices.DataItemRepresentation.VALUE: - Console.WriteLine($"Observation Received : {observation.DataItemId} = {observation.GetValue("Result")} @ {observation.Timestamp}"); - - //if (observation.DataItemId == "PartCountAct" && observation.GetValue("Result") != Observation.Unavailable) - if (observation.DataItemId == "PartCountAct" && !observation.IsUnavailable) - { - if (!observation.IsUnavailable) - { - if (i < 0) - { - i = observation.GetValue("Result").ToInt(); - } - else - { - if (observation.GetValue("Result").ToInt() != i) - { - if (observation != null) - { - - } - } - } - - i++; - } - else - { - i = -1; - } - } - - break; - - case MTConnect.Devices.DataItemRepresentation.DATA_SET: - if (!observation.IsUnavailable) - { - var entries = DataSetObservation.GetEntries(observation.Values); - foreach (var entry in entries) - { - Console.WriteLine($"Observation Received : {observation.DataItemId} : DATA_SET : {entry.Key} = {entry.Value} @ {observation.Timestamp}"); - } - } - else - { - Console.WriteLine($"Observation Received : {observation.DataItemId} = {observation.GetValue("Result")} @ {observation.Timestamp}"); - } - break; - - case MTConnect.Devices.DataItemRepresentation.TABLE: - if (!observation.IsUnavailable) - { - var entries = TableObservation.GetEntries(observation.Values); - foreach (var entry in entries) - { - foreach (var cell in entry.Cells) - { - Console.WriteLine($"Observation Received : {observation.DataItemId} : TABLE : {entry.Key} : {cell.Key} = {cell.Value} @ {observation.Timestamp}"); - } - } - } - else - { - Console.WriteLine($"Observation Received : {observation.DataItemId} = {observation.GetValue("Result")} @ {observation.Timestamp}"); - } - break; - - case MTConnect.Devices.DataItemRepresentation.TIME_SERIES: - if (!observation.IsUnavailable) - { - var samples = TimeSeriesObservation.GetSamples(observation.Values).ToList(); - Console.WriteLine($"Observation Received : {observation.DataItemId} : TIME_SERIES : {string.Join(" ", samples)} @ {observation.Timestamp}"); - } - else - { - Console.WriteLine($"Observation Received : {observation.DataItemId} = {observation.GetValue("Result")} @ {observation.Timestamp}"); - } - break; - } -}; -client.AssetReceived += (sender, asset) => -{ - Console.WriteLine($"Asset Received : {asset.AssetId}"); -}; -client.ClientStarted += (sender, asset) => -{ - Console.WriteLine($"Client Started."); -}; -client.ClientStopped += (sender, asset) => -{ - Console.WriteLine($"Client Stopped."); -}; - -client.Start(); - -Console.ReadLine(); diff --git a/applications/Clients/MTConnect.NET-Client-Example-01/CppAgentMqttExpander.cs b/applications/Clients/MTConnect.NET-Client-Example-01/CppAgentMqttExpander.cs deleted file mode 100644 index 33d641d3..00000000 --- a/applications/Clients/MTConnect.NET-Client-Example-01/CppAgentMqttExpander.cs +++ /dev/null @@ -1,36 +0,0 @@ -using MTConnect.Clients; - -var expander = new MTConnectMqttExpander("localhost"); - -var client = new MTConnectMqtt2Client("localhost"); - - -client.DeviceReceived += async (sender, device) => -{ - await expander.PublishDevice(device); - - Console.WriteLine($"Device Received : {device.Uuid}"); -}; -client.CurrentReceived += async (sender, document) => -{ - await expander.PublishCurrent(document.GetObservations()); -}; -client.SampleReceived += async (sender, document) => -{ - await expander.PublishSample(document.GetObservations()); -}; - - -//client.ObservationReceived += async (sender, observation) => -//{ -// await expander.Publish(observation); -//}; -client.AssetReceived += (sender, asset) => -{ - Console.WriteLine($"Asset Received : {asset.AssetId}"); -}; - -expander.Start(); -client.Start(); - -Console.ReadLine(); diff --git a/applications/Clients/MTConnect.NET-Client-Example-01/CurrentStream.cs b/applications/Clients/MTConnect.NET-Client-Example-01/CurrentStream.cs deleted file mode 100644 index 685c7190..00000000 --- a/applications/Clients/MTConnect.NET-Client-Example-01/CurrentStream.cs +++ /dev/null @@ -1,98 +0,0 @@ -using MTConnect.Clients.Rest; - -var agentUrl = "localhost:5000"; -//var agentUrl = "mtconnect.mazakcorp.com:5719"; - -for (int i = 0; i < 1; i++) -{ - var client = new MTConnectClient(agentUrl); - //var client = new MTConnectClient(baseUrl, deviceName); - client.Interval = 100; - client.Heartbeat = 10000; - client.CurrentOnly = true; - //client.ContentEncodings = null; - //client.ContentType = null; - client.ProbeReceived += (sender, document) => - { - Console.WriteLine("Probe Received"); - - foreach (var device in document.Devices) - { - // Device - Console.WriteLine(device.Id); - - //// DataItems - //foreach (var dataItem in device.DataItems) - //{ - // Console.WriteLine($"DataItemId = {dataItem.Id}"); - // Console.WriteLine($"Type = {dataItem.Type} : {dataItem.TypeDescription}"); - // Console.WriteLine($"SubType = {dataItem.SubType} : {dataItem.SubTypeDescription}"); - // Console.WriteLine("----------------"); - //} - - //// Components - //foreach (var component in device.Components) - //{ - // Console.WriteLine(component.Id); - //} - } - }; - client.CurrentReceived += (sender, document) => - { - Console.WriteLine($"MTConnectStreams : Current : {document.GetObservations().Count()} Observations"); - - //foreach (var deviceStream in document.Streams) - //{ - // // Device - // Console.WriteLine(deviceStream.Name); - - // // Component Streams - // foreach (var componentStream in deviceStream.ComponentStreams) - // { - // Console.WriteLine(componentStream.Name); - - // // DataItems - // foreach (var dataItem in componentStream.DataItems) - // { - // Console.WriteLine(dataItem.DataItemId); - // } - // } - //} - }; - client.SampleReceived += (sender, document) => - { - Console.WriteLine($"MTConnectStreams : Sample : {document.GetObservations().Count()} Observations"); - - //foreach (var deviceStream in document.Streams) - //{ - // // Device - // Console.WriteLine(deviceStream.Name); - - // // Component Streams - // foreach (var componentStream in deviceStream.ComponentStreams) - // { - // Console.WriteLine(componentStream.Name); - - // // DataItems - // foreach (var dataItem in componentStream.DataItems) - // { - // Console.WriteLine(dataItem.DataItemId); - // } - // } - //} - }; - client.AssetsReceived += (sender, document) => - { - Console.WriteLine($"MTConnectAssets : {document.Assets.Count()} Assets"); - - foreach (var asset in document.Assets) - { - //Console.WriteLine(asset.GetType().ToString()); - } - }; - client.StartFromBuffer(); - //client.Start(); - //client.Start("//*[@type=\"PATH_POSITION\"]"); -} - -Console.ReadLine(); diff --git a/applications/Clients/MTConnect.NET-Client-Example-01/EntityClient.cs b/applications/Clients/MTConnect.NET-Client-Example-01/EntityClient.cs deleted file mode 100644 index 2f1d3a4e..00000000 --- a/applications/Clients/MTConnect.NET-Client-Example-01/EntityClient.cs +++ /dev/null @@ -1,45 +0,0 @@ -using MTConnect.Clients; - -//var deviceName = "OKUMA-Lathe"; -//var deviceName = "M12346"; - -//var agentUrl = "localhost:5006"; -//var agentUrl = "localhost:5005"; -//var agentUrl = "http://localhost:5001"; -//var agentUrl = "http://DESKTOP-HV74M4N:5001"; -//var agentUrl = "https://localhost:5002"; -//var agentUrl = "https://DESKTOP-HV74M4N:5002"; -var agentUrl = "localhost:5000"; -//var agentUrl = "192.168.1.136:5000"; -//var agentUrl = "mtconnect.mazakcorp.com:5719"; -//var agentUrl = "https://trakhound.com"; - - -for (int i = 0; i < 1; i++) -{ - var client = new MTConnectMqttClient("localhost", interval: 1000); - //var client = new MTConnectHttpClient(agentUrl); - //var client = new MTConnectClient(agentUrl, deviceName); - //client.Interval = 100; - //client.Heartbeat = 10000; - //client.ContentEncodings = null; - //client.ContentType = null; - client.DeviceReceived += (sender, device) => - { - Console.WriteLine($"Device Received : {device.Uuid}"); - }; - client.ObservationReceived += (sender, observation) => - { - Console.WriteLine($"Observation Received : {observation.DataItemId} = {observation.GetValue("Result")} @ {observation.Timestamp}"); - }; - client.AssetReceived += (sender, asset) => - { - Console.WriteLine($"Asset Received : {asset.AssetId}"); - }; - - client.Start(); - //client.StartFromBuffer(); - //client.Start("//*[@type=\"PATH_POSITION\"]"); -} - -Console.ReadLine(); diff --git a/applications/Clients/MTConnect.NET-Client-Example-01/MTConnect.NET-Client-Example-01.csproj b/applications/Clients/MTConnect.NET-Client-Example-01/MTConnect.NET-Client-Example-01.csproj deleted file mode 100644 index dccc2130..00000000 --- a/applications/Clients/MTConnect.NET-Client-Example-01/MTConnect.NET-Client-Example-01.csproj +++ /dev/null @@ -1,37 +0,0 @@ - - - - Exe - net6.0 - MTConnect.NET_Client_Example_02 - enable - enable - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/applications/Clients/MTConnect.NET-Client-Example-01/SampleStream.cs b/applications/Clients/MTConnect.NET-Client-Example-01/SampleStream.cs deleted file mode 100644 index df9ffd3b..00000000 --- a/applications/Clients/MTConnect.NET-Client-Example-01/SampleStream.cs +++ /dev/null @@ -1,106 +0,0 @@ -using MTConnect.Clients; - -//var deviceName = "OKUMA-Lathe"; -//var deviceName = "M12346"; - -//var agentUrl = "localhost:5006"; -//var agentUrl = "localhost:5005"; -//var agentUrl = "http://localhost:5001"; -//var agentUrl = "http://DESKTOP-HV74M4N:5001"; -//var agentUrl = "https://localhost:5002"; -//var agentUrl = "https://DESKTOP-HV74M4N:5002"; -var agentUrl = "localhost:5000"; -//var agentUrl = "192.168.1.136:5000"; -//var agentUrl = "mtconnect.mazakcorp.com:5719"; -//var agentUrl = "https://trakhound.com"; - - -for (int i = 0; i < 1; i++) -{ - var client = new MTConnectHttpClient(agentUrl); - //var client = new MTConnectClient(agentUrl, deviceName); - client.Interval = 1000; - client.Heartbeat = 10000; - //client.ContentEncodings = null; - //client.ContentType = null; - client.ProbeReceived += (sender, document) => - { - Console.WriteLine("Probe Received"); - - foreach (var device in document.Devices) - { - //// DataItems - //foreach (var dataItem in device.DataItems) - //{ - // Console.WriteLine($"DataItemId = {dataItem.Id}"); - // Console.WriteLine($"Type = {dataItem.Type} : {dataItem.TypeDescription}"); - // Console.WriteLine($"SubType = {dataItem.SubType} : {dataItem.SubTypeDescription}"); - // Console.WriteLine("----------------"); - //} - - //// Components - //foreach (var component in device.Components) - //{ - // Console.WriteLine(component.Id); - //} - } - }; - client.CurrentReceived += (sender, document) => - { - Console.WriteLine($"MTConnectStreams : Current : {document.GetObservations().Count()} Observations"); - - //foreach (var deviceStream in document.Streams) - //{ - // // Device - // Console.WriteLine(deviceStream.Name); - - // // Component Streams - // foreach (var componentStream in deviceStream.ComponentStreams) - // { - // Console.WriteLine(componentStream.Name); - - // // DataItems - // foreach (var dataItem in componentStream.DataItems) - // { - // Console.WriteLine(dataItem.DataItemId); - // } - // } - //} - }; - client.SampleReceived += (sender, document) => - { - Console.WriteLine($"MTConnectStreams : Sample : {document.GetObservations().Count()} Observations"); - - //foreach (var deviceStream in document.Streams) - //{ - // // Device - // Console.WriteLine(deviceStream.Name); - - // // Component Streams - // foreach (var componentStream in deviceStream.ComponentStreams) - // { - // Console.WriteLine(componentStream.Name); - - // // DataItems - // foreach (var dataItem in componentStream.DataItems) - // { - // Console.WriteLine(dataItem.DataItemId); - // } - // } - //} - }; - client.AssetsReceived += (sender, document) => - { - Console.WriteLine($"MTConnectAssets : {document.Assets.Count()} Assets"); - - foreach (var asset in document.Assets) - { - //Console.WriteLine(asset.GetType().ToString()); - } - }; - client.Start(); - //client.StartFromBuffer(); - //client.Start("//*[@type=\"PATH_POSITION\"]"); -} - -Console.ReadLine(); diff --git a/applications/Clients/MTConnect.NET-Client-Http-Sample/ConsoleWriteStream.cs b/applications/Clients/MTConnect.NET-Client-Http-Sample/ConsoleWriteStream.cs deleted file mode 100644 index 14f89aa0..00000000 --- a/applications/Clients/MTConnect.NET-Client-Http-Sample/ConsoleWriteStream.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. - -// This file is subject to the terms and conditions defined in -// file 'LICENSE', which is part of this source code package. - -using MTConnect.Clients; - -namespace MTConnect.Client.Http.Sample -{ - class ConsoleWriteStream : MTConnectHttpClientStream - { - public ConsoleWriteStream(string url) : base (url) { } - - protected override void ProcessResponseBody(byte[] responseBytes, string contentEncoding = null) - { - var response = System.Text.Encoding.UTF8.GetString(responseBytes); - - Console.WriteLine(response); - Console.WriteLine(); - Console.WriteLine(); - } - } -} diff --git a/applications/Clients/MTConnect.NET-Client-Http-Sample/MTConnect.NET-Client-Http-Sample.csproj b/applications/Clients/MTConnect.NET-Client-Http-Sample/MTConnect.NET-Client-Http-Sample.csproj deleted file mode 100644 index 82b54bd4..00000000 --- a/applications/Clients/MTConnect.NET-Client-Http-Sample/MTConnect.NET-Client-Http-Sample.csproj +++ /dev/null @@ -1,14 +0,0 @@ - - - - Exe - net6.0 - MTConnect.Client.Http.Sample - enable - - - - - - - diff --git a/applications/Clients/MTConnect.NET-Client-Http-Sample/Program.cs b/applications/Clients/MTConnect.NET-Client-Http-Sample/Program.cs deleted file mode 100644 index 9e36a85f..00000000 --- a/applications/Clients/MTConnect.NET-Client-Http-Sample/Program.cs +++ /dev/null @@ -1,15 +0,0 @@ - -//var url = "http://mtconnect.mazakcorp.com:5719/sample?interval=100&count=1000"; -var url = "http://localhost:5000/sample?interval=100&count=1000"; -//var url = "http://localhost:5005/current?interval=1000"; -var stream = new MTConnect.Client.Http.Sample.ConsoleWriteStream(url); -stream.ContentEncodings = null; - -while (true) -{ - await stream.Run(CancellationToken.None); - - Console.WriteLine("Stream Ended"); - await Task.Delay(3000); -} - diff --git a/applications/Clients/MTConnect.NET-Client-MQTT-Example/MTConnect.NET-Client-MQTT-Example.csproj b/applications/Clients/MTConnect.NET-Client-MQTT-Example/MTConnect.NET-Client-MQTT-Example.csproj deleted file mode 100644 index 7ff69200..00000000 --- a/applications/Clients/MTConnect.NET-Client-MQTT-Example/MTConnect.NET-Client-MQTT-Example.csproj +++ /dev/null @@ -1,27 +0,0 @@ - - - - Exe - net6.0 - MTConnect.NET_Client_MQTT_Example - enable - enable - - - - - - - - - - - - - - - - - - - diff --git a/applications/Clients/MTConnect.NET-Client-MQTT-Example/Program - Copy.cs b/applications/Clients/MTConnect.NET-Client-MQTT-Example/Program - Copy.cs deleted file mode 100644 index 3a3289db..00000000 --- a/applications/Clients/MTConnect.NET-Client-MQTT-Example/Program - Copy.cs +++ /dev/null @@ -1,66 +0,0 @@ -using MQTTnet; -using MQTTnet.Client; -using MQTTnet.Formatter; -using MQTTnet.Protocol; -using System.Text; - - -var topics = new List(); - -//var topic = "MTConnect/Devices/#/L2p1/#"; -topics.Add("MTConnect/Devices/OKUMA.Lathe.123456/Observations/#"); -//topics.Add("MTConnect/Devices/OKUMA.Lathe.123456/Observations/Linear/L2x1/#"); -//topics.Add("MTConnect/Devices/OKUMA.Lathe.123456/Observations/Linear/L2z1/#"); -//var topic = "MTConnect/Devices/Device/OKUMA.Lathe.123456/Observations/Path/L2p1/#"; -//var topic = "MTConnect/Devices/Device/OKUMA.Lathe.123456/Observations/Device/#"; - - -var mqttFactory = new MqttFactory(); - -using (var mqttClient = mqttFactory.CreateMqttClient()) -{ - var mqttClientOptions = new MqttClientOptionsBuilder() - .WithTcpServer("localhost") - .Build(); - - // Setup message handling before connecting so that queued messages - // are also handled properly. When there is no event handler attached all - // received messages get lost. - mqttClient.ApplicationMessageReceivedAsync += e => - { - Console.WriteLine("Received application message."); - if (e.ApplicationMessage.Payload != null && e.ApplicationMessage.Payload.Length > 0) - { - Console.WriteLine(Encoding.ASCII.GetString(e.ApplicationMessage.Payload)); - } - - return Task.CompletedTask; - }; - - await mqttClient.ConnectAsync(mqttClientOptions, CancellationToken.None); - - var mqttSubscribeOptionsBuilder = mqttFactory.CreateSubscribeOptionsBuilder(); - foreach (var topic in topics) - { - mqttSubscribeOptionsBuilder.WithTopicFilter(topic); - } - var mqttSubscribeOptions = mqttSubscribeOptionsBuilder.Build(); - - //var mqttSubscribeOptions = mqttFactory.CreateSubscribeOptionsBuilder() - // .WithTopicFilter(f => { - // //f.WithAtLeastOnceQoS(); - // f.WithTopic(topic); - // }) - // .Build(); - - await mqttClient.SubscribeAsync(mqttSubscribeOptions, CancellationToken.None); - - Console.WriteLine($"MQTT client subscribed.."); - - Console.WriteLine("Press enter to exit."); - Console.ReadLine(); -} - - - -Console.ReadLine(); \ No newline at end of file diff --git a/applications/Clients/MTConnect.NET-Client-MQTT-Example/Program.cs b/applications/Clients/MTConnect.NET-Client-MQTT-Example/Program.cs deleted file mode 100644 index ec074053..00000000 --- a/applications/Clients/MTConnect.NET-Client-MQTT-Example/Program.cs +++ /dev/null @@ -1,40 +0,0 @@ -using MTConnect.Clients; -using MTConnect.Configurations; -using MTConnect.Observations; - - -var topics = new List(); - -//var topic = "MTConnect/Devices/#/L2p1/#"; -//topics.Add("MTConnect/Devices/OKUMA.Lathe.123456/Observations/#"); -//topics.Add("MTConnect/Devices/OKUMA.Lathe.123456/Observations/Linear/L2x1/#"); -//topics.Add("MTConnect/Devices/OKUMA.Lathe.123456/Observations/Linear/L2z1/#"); -//var topic = "MTConnect/Devices/Device/OKUMA.Lathe.123456/Observations/Path/L2p1/#"; -//var topic = "MTConnect/Devices/Device/OKUMA.Lathe.123456/Observations/Device/#"; - -var configuration = new MTConnectMqttClientConfiguration(); -configuration.Server = "localhost"; -configuration.Port = 1883; -//configuration.Interval = 100; -configuration.DeviceUuid = "OKUMA.Lathe.123456"; - -var client = new MTConnectMqttClient(configuration, topics: topics); -client.DeviceReceived += (s, o) => -{ - Console.WriteLine($"Device Received : {o.Uuid}"); -}; -client.ObservationReceived += (s, o) => -{ - Console.WriteLine($"Observation Received : {o.DataItemId} :: {o.GetValue(ValueKeys.Result)}"); -}; -client.AssetReceived += (s, o) => -{ - Console.WriteLine($"Asset Received : {o.AssetId} : {o.Type}"); -}; - -client.Start(); - -Console.WriteLine("Press enter to exit."); -Console.ReadLine(); - -client.Stop(); \ No newline at end of file diff --git a/applications/Clients/MTConnect.NET-Client-MQTT-Example/Properties/launchSettings.json b/applications/Clients/MTConnect.NET-Client-MQTT-Example/Properties/launchSettings.json deleted file mode 100644 index 33504c94..00000000 --- a/applications/Clients/MTConnect.NET-Client-MQTT-Example/Properties/launchSettings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "profiles": { - "WSL": { - "commandName": "WSL2", - "distributionName": "" - } - } -} \ No newline at end of file diff --git a/applications/Clients/README.md b/applications/Clients/README.md deleted file mode 100644 index 3703778d..00000000 --- a/applications/Clients/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Client Applications -These applications are used as examples for Client development and are available for use under the Apache 2.0 License and are free to use for both personal and commercial purposes. - -## MTConnect-Client-Console-Example - -## MTConnect-Client-Dashboard diff --git a/applications/Clients/MTConnect.NET-Client-SHDR/MTConnect.NET-Client-SHDR.csproj b/clients/MTConnect.NET-Client-SHDR/MTConnect.NET-Client-SHDR.csproj similarity index 100% rename from applications/Clients/MTConnect.NET-Client-SHDR/MTConnect.NET-Client-SHDR.csproj rename to clients/MTConnect.NET-Client-SHDR/MTConnect.NET-Client-SHDR.csproj diff --git a/applications/Clients/MTConnect.NET-Client-SHDR/Program.cs b/clients/MTConnect.NET-Client-SHDR/Program.cs similarity index 100% rename from applications/Clients/MTConnect.NET-Client-SHDR/Program.cs rename to clients/MTConnect.NET-Client-SHDR/Program.cs