From a980444c62a22019482f5b0f1c16ef0a633eff84 Mon Sep 17 00:00:00 2001 From: Patrick Ritchie Date: Wed, 1 May 2024 23:23:59 -0400 Subject: [PATCH] Update 6.3.2 - Updated ReadMe files - Added DotNet CLI template project --- MTConnect.NET.sln | 13 ++++ README.md | 24 +++++-- agent/MTConnect.NET-Agent/agent.config.yaml | 58 ++++++++--------- .../README-Nuget.md | 2 +- .../README.md | 2 +- agent/README.md | 13 ++++ build/AssemblyInfo.cs | 4 +- .../MTConnect.NET-Agent-Embedded/Program.cs | 4 +- .../agent.config.yaml | 2 +- .../MTConnect-NET-Agent-Template.csproj | 45 +++++++++++++ templates/mtconnect.net-agent/README.md | 41 ++++++++++++ .../.template.config/template.json | 13 ++++ .../MTConnect.NET-Embedded-Agent/Agent.csproj | 32 +++++++++ .../MTConnect.NET-Embedded-Agent/NLog.config | 58 +++++++++++++++++ .../MTConnect.NET-Embedded-Agent/Program.cs | 65 +++++++++++++++++++ .../MTConnect.NET-Embedded-Agent/README.md | 41 ++++++++++++ .../agent.config.yaml | 8 +++ 17 files changed, 384 insertions(+), 41 deletions(-) create mode 100644 templates/mtconnect.net-agent/MTConnect-NET-Agent-Template.csproj create mode 100644 templates/mtconnect.net-agent/README.md create mode 100644 templates/mtconnect.net-agent/content/MTConnect.NET-Embedded-Agent/.template.config/template.json create mode 100644 templates/mtconnect.net-agent/content/MTConnect.NET-Embedded-Agent/Agent.csproj create mode 100644 templates/mtconnect.net-agent/content/MTConnect.NET-Embedded-Agent/NLog.config create mode 100644 templates/mtconnect.net-agent/content/MTConnect.NET-Embedded-Agent/Program.cs create mode 100644 templates/mtconnect.net-agent/content/MTConnect.NET-Embedded-Agent/README.md create mode 100644 templates/mtconnect.net-agent/content/MTConnect.NET-Embedded-Agent/agent.config.yaml diff --git a/MTConnect.NET.sln b/MTConnect.NET.sln index 042d73fe..29f3d309 100644 --- a/MTConnect.NET.sln +++ b/MTConnect.NET.sln @@ -113,6 +113,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MTConnect.NET-Client-SHDR", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MTConnect.NET-Agent-Embedded", "examples\MTConnect.NET-Agent-Embedded\MTConnect.NET-Agent-Embedded.csproj", "{24C98CF3-CC93-4696-A036-8FD1E16F2E7E}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Templates", "Templates", "{D7873DF2-16DB-4B19-A100-C0089DF37488}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Agent", "templates\mtconnect.net-agent\content\MTConnect.NET-Embedded-Agent\Agent.csproj", "{FF3FACB1-C470-4C7F-9A4B-F364BE1E32B3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -401,6 +405,14 @@ Global {24C98CF3-CC93-4696-A036-8FD1E16F2E7E}.Package|Any CPU.Build.0 = Debug|Any CPU {24C98CF3-CC93-4696-A036-8FD1E16F2E7E}.Release|Any CPU.ActiveCfg = Release|Any CPU {24C98CF3-CC93-4696-A036-8FD1E16F2E7E}.Release|Any CPU.Build.0 = Release|Any CPU + {FF3FACB1-C470-4C7F-9A4B-F364BE1E32B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FF3FACB1-C470-4C7F-9A4B-F364BE1E32B3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FF3FACB1-C470-4C7F-9A4B-F364BE1E32B3}.Docker|Any CPU.ActiveCfg = Debug|Any CPU + {FF3FACB1-C470-4C7F-9A4B-F364BE1E32B3}.Docker|Any CPU.Build.0 = Debug|Any CPU + {FF3FACB1-C470-4C7F-9A4B-F364BE1E32B3}.Package|Any CPU.ActiveCfg = Debug|Any CPU + {FF3FACB1-C470-4C7F-9A4B-F364BE1E32B3}.Package|Any CPU.Build.0 = Debug|Any CPU + {FF3FACB1-C470-4C7F-9A4B-F364BE1E32B3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FF3FACB1-C470-4C7F-9A4B-F364BE1E32B3}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -444,6 +456,7 @@ Global {5F1E0B6F-FFD6-4E6C-88BF-B9B0F5574BDE} = {FFF032D3-7446-4CAF-A3E3-CF9C4E1A5DCC} {A9DF36FC-4EF7-4BFB-B47D-F1C10227631A} = {FFF032D3-7446-4CAF-A3E3-CF9C4E1A5DCC} {24C98CF3-CC93-4696-A036-8FD1E16F2E7E} = {FFF032D3-7446-4CAF-A3E3-CF9C4E1A5DCC} + {FF3FACB1-C470-4C7F-9A4B-F364BE1E32B3} = {D7873DF2-16DB-4B19-A100-C0089DF37488} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {CC13D3AD-18BF-4695-AB2A-087EF0885B20} diff --git a/README.md b/README.md index ff5ccb0d..c6d01512 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![MTConnect.NET](https://github.com/TrakHound/MTConnect.NET/actions/workflows/dotnet.yml/badge.svg)](https://github.com/TrakHound/MTConnect.NET/actions/workflows/dotnet.yml) -> 12/4/2023 : Version 6.0 Released with new Agent, Adapter, & SysML Import +> 5/1/2024 : Version 6.4 Released with new Agent, Adapter, & SysML Import ## Download @@ -95,17 +95,31 @@ A live demo of the MTConnect Gateway HTTP Agent (AspNetCore) application is runn ## Agents -#### Module Agent Application -A preconfigured [Application](https://github.com/TrakHound/MTConnect.NET/tree/version-6.0/agent/MTConnect.NET-Agent) & [Library](https://github.com/TrakHound/MTConnect.NET/tree/version-6.0/agent/MTConnect.NET-Applications-Agents) to build an Agent is available and supports: +#### Embedded Agent Application +An MTConnect Agent can be embedded into an application where the DataSource(s) can be read and the MTConnect Agent can be combined into the same application. This eliminates the need to transfer data from an Adapter to an Agent (typically using the SHDR protocol). + +##### Option #1 : [DotNet Template](https://github.com/TrakHound/MTConnect.NET/tree/version-6.0) +``` +dotnet new mtconnect.net-agent +``` + +##### Option #2 : [Nuget Package](https://github.com/TrakHound/MTConnect.NET/tree/version-6.0) +``` +dotnet add package MTConnect.NET-Applications-Agents +``` + +#### Standalone Agent Application +A standalone preconfigured [Application](https://github.com/TrakHound/MTConnect.NET/tree/version-6.0/agent/MTConnect.NET-Agent) ready to download is available and supports: - Modular architecture - HTTP Server Module - - SHDR Adapter Module(s) + - SHDR Adapter Module - MQTT Broker Module - MQTT Relay Module - etc. - Easy Windows Installer - Linux Compatible - Run as a Windows Service +- Transform input data using Python scripts - Extensible configuration file and monitors for changes #### Agent Classes @@ -114,7 +128,7 @@ A preconfigured [Application](https://github.com/TrakHound/MTConnect.NET/tree/ve ## Adapters -#### Modular Adapter Application +#### Standalone Modular Adapter Application A preconfigured [Application](https://github.com/TrakHound/MTConnect.NET/tree/version-6.0/adapter/MTConnect.NET-Adapter) & [Library](https://github.com/TrakHound/MTConnect.NET/tree/version-6.0/adapter/MTConnect.NET-Applications-Adapter) to build an Adapter is available and supports: - Modular architecture - SHDR Module (export data to an MTConnect Agent using the SHDR protocol) diff --git a/agent/MTConnect.NET-Agent/agent.config.yaml b/agent/MTConnect.NET-Agent/agent.config.yaml index d5d3300e..ccf70478 100644 --- a/agent/MTConnect.NET-Agent/agent.config.yaml +++ b/agent/MTConnect.NET-Agent/agent.config.yaml @@ -27,32 +27,32 @@ modules: - path: styles/favicon.ico location: favicon.ico -- http-server: # - Add HTTP Server module - port: 5001 - indentOutput: true - documentFormat: xml - accept: - text/xml: xml - application/json: json - responseCompression: - - gzip - - br - tls: - # pfx: - # certificatePath: c:\test-cert\trakhound.pfx - # certificatePassword: trakhound - pem: - certificateAuthority: c:\test-cert\rootCA.crt - certificatePath: c:\test-cert\trakhound.crt - privateKeyPath: c:\test-cert\trakhound.key - privateKeyPassword: trakhound - files: - - path: schemas - location: schemas - - path: styles - location: styles - - path: styles/favicon.ico - location: favicon.ico +# - http-server: # - Add HTTP Server module +# port: 5001 +# indentOutput: true +# documentFormat: xml +# accept: +# text/xml: xml +# application/json: json +# responseCompression: +# - gzip +# - br +# tls: +# # pfx: +# # certificatePath: c:\test-cert\trakhound.pfx +# # certificatePassword: trakhound +# pem: +# certificateAuthority: c:\test-cert\rootCA.crt +# certificatePath: c:\test-cert\trakhound.crt +# privateKeyPath: c:\test-cert\trakhound.key +# privateKeyPassword: trakhound +# files: +# - path: schemas +# location: schemas +# - path: styles +# location: styles +# - path: styles/favicon.ico +# location: favicon.ico # - mqtt-broker: # - Add MQTT Broker module (Document Structure) # port: 1883 @@ -114,7 +114,7 @@ modules: - shdr-adapter: # - Add SHDR Adapter module for Device = Okuma and Port = 7878 deviceKey: Okuma - hostname: localhost + # hostname: localhost port: 7878 heartbeat: 1000 reconnectInterval: 1000 @@ -122,8 +122,8 @@ modules: - shdr-adapter: # - Add SHDR Adapter module for Device = Mazak and Port = 7879 deviceKey: Mazak - hostname: localhost - port: 7878 + # hostname: localhost + port: 7879 heartbeat: 1000 reconnectInterval: 1000 connectionTimeout: 1000 diff --git a/agent/Modules/MTConnect.NET-AgentModule-MqttRelay/README-Nuget.md b/agent/Modules/MTConnect.NET-AgentModule-MqttRelay/README-Nuget.md index bd66994d..1a44b285 100644 --- a/agent/Modules/MTConnect.NET-AgentModule-MqttRelay/README-Nuget.md +++ b/agent/Modules/MTConnect.NET-AgentModule-MqttRelay/README-Nuget.md @@ -7,7 +7,7 @@ This Agent Module writes data to an **External** MQTT Broker ```yaml - mqtt-relay: server: localhost - port: 7878 + port: 1883 topic: enterprise/site/area/line/cell/MTConnect topicStructure: Document ``` diff --git a/agent/Modules/MTConnect.NET-AgentModule-MqttRelay/README.md b/agent/Modules/MTConnect.NET-AgentModule-MqttRelay/README.md index a174a689..1e842bb1 100644 --- a/agent/Modules/MTConnect.NET-AgentModule-MqttRelay/README.md +++ b/agent/Modules/MTConnect.NET-AgentModule-MqttRelay/README.md @@ -25,7 +25,7 @@ This Agent Module writes data to an **External** MQTT Broker ```yaml - mqtt-relay: server: localhost - port: 7878 + port: 1883 topic: enterprise/site/area/line/cell/MTConnect topicStructure: Document ``` diff --git a/agent/README.md b/agent/README.md index 4449e89d..2512ac14 100644 --- a/agent/README.md +++ b/agent/README.md @@ -1,6 +1,19 @@ # Standalone MTConnect Agent > https://github.com/TrakHound/MTConnect.NET/tree/version-6.0/agent/MTConnect.NET-Agent +A standalone preconfigured application ready to download is available and supports: +- Modular architecture + - HTTP Server Module + - SHDR Adapter Module + - MQTT Broker Module + - MQTT Relay Module + - etc. +- Easy Windows Installer +- Linux Compatible +- Run as a Windows Service +- Transform input data using Python scripts +- Extensible configuration file and monitors for changes + # Embedded MTConnect Agent An MTConnect Agent can be embedded into an application where the DataSource(s) can be read and the MTConnect Agent can be combined into the same application. This eliminates the need to transfer data from an Adapter to an Agent (typically using the SHDR protocol). diff --git a/build/AssemblyInfo.cs b/build/AssemblyInfo.cs index c194b594..cc90b4f2 100644 --- a/build/AssemblyInfo.cs +++ b/build/AssemblyInfo.cs @@ -1,6 +1,6 @@ using System.Reflection; -[assembly: AssemblyVersion("6.3.1")] -[assembly: AssemblyFileVersion("6.3.1")] +[assembly: AssemblyVersion("6.3.2")] +[assembly: AssemblyFileVersion("6.3.2")] [assembly: AssemblyCompany("TrakHound Inc.")] [assembly: AssemblyCopyright("Copyright (c) 2024 TrakHound Inc., All Rights Reserved.")] diff --git a/examples/MTConnect.NET-Agent-Embedded/Program.cs b/examples/MTConnect.NET-Agent-Embedded/Program.cs index ee3794c6..d9e833cb 100644 --- a/examples/MTConnect.NET-Agent-Embedded/Program.cs +++ b/examples/MTConnect.NET-Agent-Embedded/Program.cs @@ -27,8 +27,8 @@ public class ModuleConfiguration // This is the module that runs your code public class Module : MTConnectInputAgentModule { - public const string ConfigurationTypeId = "demo"; // This must match the module section in the 'agent.config.yaml' file - public const string DefaultId = "Demo Module"; // The ID is mainly just used for logging. + public const string ConfigurationTypeId = "datasource"; // This must match the module section in the 'agent.config.yaml' file + public const string DefaultId = "DataSource Module"; // The ID is mainly just used for logging. private readonly ModuleConfiguration _configuration; diff --git a/examples/MTConnect.NET-Agent-Embedded/agent.config.yaml b/examples/MTConnect.NET-Agent-Embedded/agent.config.yaml index 057a74d4..4dcf9a59 100644 --- a/examples/MTConnect.NET-Agent-Embedded/agent.config.yaml +++ b/examples/MTConnect.NET-Agent-Embedded/agent.config.yaml @@ -1,6 +1,6 @@ modules: -- demo: +- datasource: deviceUuid: 7E647B2D-C6A3-40BF-9CE9-FB09834850C9 deviceName: dev-001 serialNumber: 123456 diff --git a/templates/mtconnect.net-agent/MTConnect-NET-Agent-Template.csproj b/templates/mtconnect.net-agent/MTConnect-NET-Agent-Template.csproj new file mode 100644 index 00000000..36168f57 --- /dev/null +++ b/templates/mtconnect.net-agent/MTConnect-NET-Agent-Template.csproj @@ -0,0 +1,45 @@ + + + + + + MTConnect.NET-Agent-Template + 1.0.4 + MTConnect.NET Agent Template + trakhound + Template to create an embedded MTConnect Agent using the MTConnect.NET project + mtconnect agent dotnet + www.TrakHound.com + https://raw.githubusercontent.com/TrakHound/MTConnect.NET/version-6.0/img/mtconnect-net-03-nuget.png + MIT + https://github.com/TrakHound/MTConnect.NET + + + Template + net8.0 + true + false + content + $(NoWarn);NU5128 + true + README.md + + + + false + + + + + + + + + + + + + + + + diff --git a/templates/mtconnect.net-agent/README.md b/templates/mtconnect.net-agent/README.md new file mode 100644 index 00000000..77599f90 --- /dev/null +++ b/templates/mtconnect.net-agent/README.md @@ -0,0 +1,41 @@ +# MTConnect.NET-Agent-Template +An MTConnect Agent can be embedded into an application where the DataSource(s) can be read and the MTConnect Agent can be combined into the same application. This eliminates the need to transfer data from an Adapter to an Agent (typically using the SHDR protocol). + +## Setup + +#### Install Template +Use the **[dotnet CLI](https://learn.microsoft.com/en-us/dotnet/core/tools/)** to install the MTConnect.NET-Agent-Template using the below command: +``` +dotnet new install MTConnect.NET-Agent-Template +``` + +#### Create New Project +This will create a new project using the template in the current working directory +``` +dotnet new mtconnect.net-agent +``` + +## Build & Develop + +#### dotnet CLI +Use the **[dotnet CLI](https://learn.microsoft.com/en-us/dotnet/core/tools/)** to build the project using the below command: +``` +dotnet build -c:Debug +``` + +#### Run +``` +dotnet run -c:Debug +``` + +## Create Installer +Use the **[dotnet CLI](https://learn.microsoft.com/en-us/dotnet/core/tools/)** to build the project using the *Release** configuration using the below command: +``` +dotnet build -c:Release +``` + +#### Install InnoSetup (if not already installed) +information - https://jrsoftware.org/isinfo.php +download - https://jrsoftware.org/isdl.php#stable + + diff --git a/templates/mtconnect.net-agent/content/MTConnect.NET-Embedded-Agent/.template.config/template.json b/templates/mtconnect.net-agent/content/MTConnect.NET-Embedded-Agent/.template.config/template.json new file mode 100644 index 00000000..359b2e0f --- /dev/null +++ b/templates/mtconnect.net-agent/content/MTConnect.NET-Embedded-Agent/.template.config/template.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json.schemastore.org/template", + "author": "TrakHound Inc.", + "classifications": [ "Common", "Console" ], + "identity": "MTConnect.NET-Agent-Template", + "name": "Template to create an embedded MTConnect Agent using the MTConnect.NET project", + "shortName": "mtconnect.net-agent", + "sourceName":"MTConnect.NET-Agent-Template", + "tags": { + "language": "C#", + "type": "project" + } + } \ No newline at end of file diff --git a/templates/mtconnect.net-agent/content/MTConnect.NET-Embedded-Agent/Agent.csproj b/templates/mtconnect.net-agent/content/MTConnect.NET-Embedded-Agent/Agent.csproj new file mode 100644 index 00000000..dc284e4a --- /dev/null +++ b/templates/mtconnect.net-agent/content/MTConnect.NET-Embedded-Agent/Agent.csproj @@ -0,0 +1,32 @@ + + + + net8.0 + full + + + net461;net48;net6.0;net7.0;net8.0 + false + None + true + + + + Exe + agent + + + + + + + + + Always + + + Always + + + + diff --git a/templates/mtconnect.net-agent/content/MTConnect.NET-Embedded-Agent/NLog.config b/templates/mtconnect.net-agent/content/MTConnect.NET-Embedded-Agent/NLog.config new file mode 100644 index 00000000..2cfe9cfa --- /dev/null +++ b/templates/mtconnect.net-agent/content/MTConnect.NET-Embedded-Agent/NLog.config @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/templates/mtconnect.net-agent/content/MTConnect.NET-Embedded-Agent/Program.cs b/templates/mtconnect.net-agent/content/MTConnect.NET-Embedded-Agent/Program.cs new file mode 100644 index 00000000..d01f46e3 --- /dev/null +++ b/templates/mtconnect.net-agent/content/MTConnect.NET-Embedded-Agent/Program.cs @@ -0,0 +1,65 @@ +using MTConnect.Agents; +using MTConnect.Applications; +using MTConnect.Configurations; +using MTConnect.Devices; +using MTConnect.Devices.DataItems; +using MTConnect.Observations.Events; + +namespace MTConnectAgent +{ + public class Program + { + static void Main(string[] args) + { + var app = new MTConnectAgentApplication(); + app.Run(args, true); + } + + + public class ModuleConfiguration : DataSourceConfiguration + { + public string PlcAddress { get; set; } + } + + + public class DataSourceModule : MTConnectInputAgentModule + { + public const string ConfigurationTypeId = "datasource"; // This must match the module section in the 'agent.config.yaml' file + public const string DefaultId = "DataSource Module"; // The ID is mainly just used for logging. + private readonly ModuleConfiguration _configuration; + + + public DataSourceModule(IMTConnectAgentBroker agent, object configuration) : base(agent) + { + Id = DefaultId; + + _configuration = AgentApplicationConfiguration.GetConfiguration(configuration); + Configuration = _configuration; + } + + + protected override IDevice OnAddDevice() + { + var device = new Device(); + device.Uuid = "demo-agent-device"; + device.Id = "demo"; + device.Name = "demo"; + + device.AddDataItem(new AvailabilityDataItem() { Name = "avail" }); + device.AddDataItem(new DateCodeDataItem() { Name = "date" }); + + return device; + } + + + protected override void OnRead() + { + Log(MTConnect.Logging.MTConnectLogLevel.Information, $"Read PLC Data from ({_configuration.PlcAddress})"); + + AddValueObservation("avail", Availability.AVAILABLE); + AddValueObservation("date", System.DateTime.Now.ToString("o")); + } + + } + } +} diff --git a/templates/mtconnect.net-agent/content/MTConnect.NET-Embedded-Agent/README.md b/templates/mtconnect.net-agent/content/MTConnect.NET-Embedded-Agent/README.md new file mode 100644 index 00000000..77599f90 --- /dev/null +++ b/templates/mtconnect.net-agent/content/MTConnect.NET-Embedded-Agent/README.md @@ -0,0 +1,41 @@ +# MTConnect.NET-Agent-Template +An MTConnect Agent can be embedded into an application where the DataSource(s) can be read and the MTConnect Agent can be combined into the same application. This eliminates the need to transfer data from an Adapter to an Agent (typically using the SHDR protocol). + +## Setup + +#### Install Template +Use the **[dotnet CLI](https://learn.microsoft.com/en-us/dotnet/core/tools/)** to install the MTConnect.NET-Agent-Template using the below command: +``` +dotnet new install MTConnect.NET-Agent-Template +``` + +#### Create New Project +This will create a new project using the template in the current working directory +``` +dotnet new mtconnect.net-agent +``` + +## Build & Develop + +#### dotnet CLI +Use the **[dotnet CLI](https://learn.microsoft.com/en-us/dotnet/core/tools/)** to build the project using the below command: +``` +dotnet build -c:Debug +``` + +#### Run +``` +dotnet run -c:Debug +``` + +## Create Installer +Use the **[dotnet CLI](https://learn.microsoft.com/en-us/dotnet/core/tools/)** to build the project using the *Release** configuration using the below command: +``` +dotnet build -c:Release +``` + +#### Install InnoSetup (if not already installed) +information - https://jrsoftware.org/isinfo.php +download - https://jrsoftware.org/isdl.php#stable + + diff --git a/templates/mtconnect.net-agent/content/MTConnect.NET-Embedded-Agent/agent.config.yaml b/templates/mtconnect.net-agent/content/MTConnect.NET-Embedded-Agent/agent.config.yaml new file mode 100644 index 00000000..1c4db0d4 --- /dev/null +++ b/templates/mtconnect.net-agent/content/MTConnect.NET-Embedded-Agent/agent.config.yaml @@ -0,0 +1,8 @@ +modules: + +- datasource: + readInterval: 5000 + plcAddress: 0.0.0.1 + +- http-server: + port: 5000 \ No newline at end of file