diff --git a/agent/MTConnect.NET-Agent/MTConnect.NET-Agent.csproj b/agent/MTConnect.NET-Agent/MTConnect.NET-Agent.csproj
index d467bd6c..9fa145e6 100644
--- a/agent/MTConnect.NET-Agent/MTConnect.NET-Agent.csproj
+++ b/agent/MTConnect.NET-Agent/MTConnect.NET-Agent.csproj
@@ -35,7 +35,7 @@
-
+
Always
diff --git a/agent/MTConnect.NET-Agent/agent.config.default.yaml b/agent/MTConnect.NET-Agent/agent.config.default.yaml
deleted file mode 100644
index 89649e10..00000000
--- a/agent/MTConnect.NET-Agent/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/agent/MTConnect.NET-Agent/agent.config.yaml b/agent/MTConnect.NET-Agent/agent.config.yaml
new file mode 100644
index 00000000..ee94e38e
--- /dev/null
+++ b/agent/MTConnect.NET-Agent/agent.config.yaml
@@ -0,0 +1,71 @@
+# - Device Configuration -
+devices: devices
+
+# - Processors -
+processors:
+- python: # - Add Python Processor
+ directory: processors
+
+# - Modules -
+modules:
+
+- http-server: # - Add HTTP Server module
+ # hostname: localhost
+ port: 5000
+ # allowPut: true
+ indentOutput: true
+ documentFormat: xml
+ accept:
+ text/xml: xml
+ application/json: json
+ # responseCompression:
+ # - gzip
+ # - br
+ # files:
+ # - path: schemas
+ # location: schemas
+ # - path: styles
+ # location: styles
+ # - path: styles/favicon.ico
+ # location: favicon.ico
+
+# - mqtt-relay: # - Add MQTT Relay module
+# server: localhost
+# port: 1883
+# currentInterval: 5000
+# sampleInterval: 500
+
+# - shdr-adapter: # - Add SHDR Adapter module for Device = M12346 and Port = 7878
+# deviceKey: M12346
+# hostname: localhost
+# port: 7878
+# heartbeat: 1000
+# reconnectInterval: 1000
+# connectionTimeout: 1000
+
+- shdr-adapter: # - Add SHDR Adapter module for Device = OKUMA-Lathe and Port = 7879
+ deviceKey: OKUMA-Lathe
+ hostname: localhost
+ port: 7878
+ heartbeat: 1000
+ reconnectInterval: 1000
+ connectionTimeout: 1000
+
+# - mqtt-adapter: # - Add MQTT Adapter module for Device = M12346 and Topic = cnc-01
+# deviceKey: M12346
+# server: localhost
+# port: 1883
+# topic: cnc-01
+
+
+# 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
\ No newline at end of file
diff --git a/agent/MTConnect.NET-Applications-Agents/MTConnect.NET-Applications-Agents.csproj b/agent/MTConnect.NET-Applications-Agents/MTConnect.NET-Applications-Agents.csproj
index 4aaa288c..906674f6 100644
--- a/agent/MTConnect.NET-Applications-Agents/MTConnect.NET-Applications-Agents.csproj
+++ b/agent/MTConnect.NET-Applications-Agents/MTConnect.NET-Applications-Agents.csproj
@@ -64,18 +64,18 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -83,16 +83,22 @@
-
- Always
- True
- \
-
-
- Always
- True
- \
-
+
+ Always
+ true
+ true
+ True
+ contentFiles\any\any;content
+ true
+
+
+ Always
+ true
+ true
+ True
+ contentFiles\any\any;content
+ true
+
diff --git a/agent/MTConnect.NET-Applications-Agents/MTConnectAgentApplication.cs b/agent/MTConnect.NET-Applications-Agents/MTConnectAgentApplication.cs
index 26cc40ee..17bb37b7 100644
--- a/agent/MTConnect.NET-Applications-Agents/MTConnectAgentApplication.cs
+++ b/agent/MTConnect.NET-Applications-Agents/MTConnectAgentApplication.cs
@@ -21,10 +21,10 @@
namespace MTConnect.Applications
{
- ///
- /// An MTConnect Agent Application base class supporting Command line arguments, Device management, Buffer management, Logging, Windows Service, and Configuration File management
- ///
- public class MTConnectAgentApplication : IMTConnectAgentApplication
+ ///
+ /// An MTConnect Agent Application base class supporting Command line arguments, Device management, Buffer management, Logging, Windows Service, and Configuration File management
+ ///
+ public class MTConnectAgentApplication : IMTConnectAgentApplication
{
private const string DefaultServiceName = "MTConnect.NET-Agent";
private const string DefaultServiceDisplayName = "MTConnect.NET Agent";
@@ -47,6 +47,7 @@ public class MTConnectAgentApplication : IMTConnectAgentApplication
private MTConnectAssetFileBuffer _assetBuffer;
private MTConnectAgentModules _modules;
private MTConnectAgentProcessors _processors;
+ private IAgentApplicationConfiguration _initialAgentConfiguration;
protected IAgentConfigurationFileWatcher _agentConfigurationWatcher;
private System.Timers.Timer _metricsTimer;
private bool _started = false;
@@ -65,11 +66,12 @@ public class MTConnectAgentApplication : IMTConnectAgentApplication
public event EventHandler OnRestart;
- public MTConnectAgentApplication()
+ public MTConnectAgentApplication(IAgentApplicationConfiguration agentConfiguration = null)
{
ServiceName = DefaultServiceName;
ServiceDisplayName = DefaultServiceDisplayName;
ServiceDescription = DefaultServiceDescription;
+ _initialAgentConfiguration = agentConfiguration;
}
@@ -103,6 +105,18 @@ public void Run(string[] args, bool isBlocking = false)
OnCommandLineArgumentsRead(args);
+ // Copy Default NLog Configuration File
+ string logConfigPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "NLog.config");
+ string defaultLogConfigPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "NLog.default.config");
+ if (!File.Exists(logConfigPath) && File.Exists(defaultLogConfigPath))
+ {
+ File.Copy(defaultLogConfigPath, logConfigPath);
+
+ LogManager.Configuration = LogManager.Configuration.Reload();
+ LogManager.ReconfigExistingLoggers();
+ }
+
+
// Convert Json Configuration File to YAML
string jsonConfigPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AgentConfiguration.JsonFilename);
if (File.Exists(jsonConfigPath))
@@ -113,18 +127,21 @@ public void Run(string[] args, bool isBlocking = false)
// Copy Default Configuration File
string yamlConfigPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AgentConfiguration.YamlFilename);
- string defaultPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AgentConfiguration.DefaultYamlFilename);
- if (!File.Exists(yamlConfigPath) && !File.Exists(jsonConfigPath) && File.Exists(defaultPath))
+ string defaultConfigPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AgentConfiguration.DefaultYamlFilename);
+ if (!File.Exists(yamlConfigPath) && !File.Exists(jsonConfigPath) && File.Exists(defaultConfigPath))
{
- File.Copy(defaultPath, yamlConfigPath);
+ File.Copy(defaultConfigPath, yamlConfigPath);
}
// Read the Agent Configuation File
- var configuration = OnConfigurationFileRead(configFile);
+ var configuration = _initialAgentConfiguration;
+ if (configuration == null)
+ {
+ configuration = OnConfigurationFileRead(configFile);
+ if (configuration != null) _applicationLogger.Info($"Configuration File Read Successfully from: {configuration.Path}");
+ }
if (configuration != null)
{
- _applicationLogger.Info($"Configuration File Read Successfully from: {configuration.Path}");
-
// Set Service Name
if (!string.IsNullOrEmpty(configuration.ServiceName)) serviceDisplayName = configuration.ServiceName;
@@ -395,37 +412,41 @@ public void StartAgent(IAgentApplicationConfiguration configuration, bool verbos
_modules.StartBeforeLoad(initializeDataItems);
// Read Device Configuration Files
+ IEnumerable deviceConfigurations = null;
var devicesPath = configuration.Devices;
- //if (string.IsNullOrEmpty(devicesPath)) devicesPath = "devices";
- var devices = DeviceConfiguration.FromFiles(devicesPath, DocumentFormat.XML);
- if (!devices.IsNullOrEmpty())
+ if (!string.IsNullOrEmpty(devicesPath))
{
- // Add Device(s) to Agent
- foreach (var device in devices)
+ deviceConfigurations = DeviceConfiguration.FromFiles(devicesPath, DocumentFormat.XML);
+ if (!deviceConfigurations.IsNullOrEmpty())
{
- _agentLogger.Info($"Device ({device.Name}) Read From File : {device.Path}");
+ // Add Device(s) to Agent
+ foreach (var device in deviceConfigurations)
+ {
+ _agentLogger.Info($"Device ({device.Name}) Read From File : {device.Path}");
- _mtconnectAgent.AddDevice(device, initializeDataItems);
- }
+ _mtconnectAgent.AddDevice(device, initializeDataItems);
+ }
- if (configuration.MonitorConfigurationFiles)
- {
- // Set Device Configuration File Watcher
- var paths = devices.Select(o => o.Path).Distinct();
- foreach (var path in paths)
+ if (configuration.MonitorConfigurationFiles)
{
- // Create a Device Configuration File Watcher
- var deviceConfigurationWatcher = new DeviceConfigurationFileWatcher(path, configuration.ConfigurationFileRestartInterval * 1000);
- deviceConfigurationWatcher.ConfigurationUpdated += DeviceConfigurationFileUpdated;
- deviceConfigurationWatcher.ErrorReceived += DeviceConfigurationFileError;
- _deviceConfigurationWatchers.Add(deviceConfigurationWatcher);
+ // Set Device Configuration File Watcher
+ var paths = deviceConfigurations.Select(o => o.Path).Distinct();
+ foreach (var path in paths)
+ {
+ // Create a Device Configuration File Watcher
+ var deviceConfigurationWatcher = new DeviceConfigurationFileWatcher(path, configuration.ConfigurationFileRestartInterval * 1000);
+ deviceConfigurationWatcher.ConfigurationUpdated += DeviceConfigurationFileUpdated;
+ deviceConfigurationWatcher.ErrorReceived += DeviceConfigurationFileError;
+ _deviceConfigurationWatchers.Add(deviceConfigurationWatcher);
+ }
}
}
+ else
+ {
+ _agentLogger.Warn($"No Devices Found : Reading from : {configuration.Devices}");
+ }
}
- else
- {
- _agentLogger.Warn($"No Devices Found : Reading from : {configuration.Devices}");
- }
+
// Initilialize Processors
_processors = new MTConnectAgentProcessors(configuration);
@@ -435,12 +456,6 @@ public void StartAgent(IAgentApplicationConfiguration configuration, bool verbos
_mtconnectAgent.ProcessObservationFunction = _processors.Process;
-
-
- //OnStartAgentBeforeLoad(devices, initializeDataItems);
- //_modules.StartBeforeLoad();
-
-
// Initialize Agent Current Observations/Conditions
// This updates the MTConnectAgent's cache used to determine duplicate observations
if (_observationBuffer != null)
@@ -450,7 +465,7 @@ public void StartAgent(IAgentApplicationConfiguration configuration, bool verbos
}
_modules.StartAfterLoad(initializeDataItems);
- OnStartAgentAfterLoad(devices, initializeDataItems);
+ OnStartAgentAfterLoad(deviceConfigurations, initializeDataItems);
// Save Indexes for Buffer
if (configuration.Durable)
diff --git a/agent/MTConnect.NET-Applications-Agents/NLog.config b/agent/MTConnect.NET-Applications-Agents/NLog.default.config
similarity index 81%
rename from agent/MTConnect.NET-Applications-Agents/NLog.config
rename to agent/MTConnect.NET-Applications-Agents/NLog.default.config
index 37080dc1..2cfe9cfa 100644
--- a/agent/MTConnect.NET-Applications-Agents/NLog.config
+++ b/agent/MTConnect.NET-Applications-Agents/NLog.default.config
@@ -36,23 +36,23 @@
-
+
-
+
-
+
-
+
-
-
+
+
\ No newline at end of file
diff --git a/agent/MTConnect.NET-Applications-Agents/agent.config.default.yaml b/agent/MTConnect.NET-Applications-Agents/agent.config.default.yaml
index deab9106..7077797b 100644
--- a/agent/MTConnect.NET-Applications-Agents/agent.config.default.yaml
+++ b/agent/MTConnect.NET-Applications-Agents/agent.config.default.yaml
@@ -7,6 +7,9 @@ modules:
# allowPut: true
indentOutput: true
documentFormat: xml
+ accept:
+ text/xml: xml
+ application/json: json
responseCompression:
- gzip
- br
diff --git a/agent/Modules/MTConnect.NET-AgentModule-HttpAdapter/DeviceMappingConfiguration.cs b/agent/Modules/MTConnect.NET-AgentModule-HttpAdapter/DeviceMappingConfiguration.cs
index 5933b95e..a8292fe3 100644
--- a/agent/Modules/MTConnect.NET-AgentModule-HttpAdapter/DeviceMappingConfiguration.cs
+++ b/agent/Modules/MTConnect.NET-AgentModule-HttpAdapter/DeviceMappingConfiguration.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
+// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.
namespace MTConnect
diff --git a/agent/Modules/MTConnect.NET-AgentModule-HttpAdapter/ModuleConfiguration.cs b/agent/Modules/MTConnect.NET-AgentModule-HttpAdapter/HttpAdapterModuleConfiguration.cs
similarity index 64%
rename from agent/Modules/MTConnect.NET-AgentModule-HttpAdapter/ModuleConfiguration.cs
rename to agent/Modules/MTConnect.NET-AgentModule-HttpAdapter/HttpAdapterModuleConfiguration.cs
index 050e28da..b5152a08 100644
--- a/agent/Modules/MTConnect.NET-AgentModule-HttpAdapter/ModuleConfiguration.cs
+++ b/agent/Modules/MTConnect.NET-AgentModule-HttpAdapter/HttpAdapterModuleConfiguration.cs
@@ -1,11 +1,11 @@
-// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
+// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.
using System.Collections.Generic;
namespace MTConnect.Configurations
{
- public class ModuleConfiguration : HttpClientConfiguration
+ public class HttpAdapterModuleConfiguration : HttpClientConfiguration
{
public Dictionary Devices { get; set; }
}
diff --git a/agent/Modules/MTConnect.NET-AgentModule-HttpAdapter/Module.cs b/agent/Modules/MTConnect.NET-AgentModule-HttpAdapter/Module.cs
index be9e4c84..4bd57f58 100644
--- a/agent/Modules/MTConnect.NET-AgentModule-HttpAdapter/Module.cs
+++ b/agent/Modules/MTConnect.NET-AgentModule-HttpAdapter/Module.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
+// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.
using MTConnect.Agents;
@@ -20,7 +20,7 @@ public class Module : MTConnectAgentModule
public const string ConfigurationTypeId = "http-client";
private const string ModuleId = "HTTP Adapter";
- private readonly ModuleConfiguration _configuration;
+ private readonly HttpAdapterModuleConfiguration _configuration;
private readonly IMTConnectAgentBroker _mtconnectAgent;
private readonly List _clients = new List();
private readonly Dictionary _clientInformations = new Dictionary();
@@ -32,7 +32,7 @@ public Module(IMTConnectAgentBroker mtconnectAgent, object configuration) : base
Id = ModuleId;
_mtconnectAgent = mtconnectAgent;
- _configuration = AgentApplicationConfiguration.GetConfiguration(configuration);
+ _configuration = AgentApplicationConfiguration.GetConfiguration(configuration);
}
diff --git a/agent/Modules/MTConnect.NET-AgentModule-HttpServer/ModuleConfiguration.cs b/agent/Modules/MTConnect.NET-AgentModule-HttpServer/HttpServerModuleConfiguration.cs
similarity index 77%
rename from agent/Modules/MTConnect.NET-AgentModule-HttpServer/ModuleConfiguration.cs
rename to agent/Modules/MTConnect.NET-AgentModule-HttpServer/HttpServerModuleConfiguration.cs
index 03366dc7..ad31b003 100644
--- a/agent/Modules/MTConnect.NET-AgentModule-HttpServer/ModuleConfiguration.cs
+++ b/agent/Modules/MTConnect.NET-AgentModule-HttpServer/HttpServerModuleConfiguration.cs
@@ -1,14 +1,11 @@
-// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
+// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.
using System.Collections.Generic;
namespace MTConnect.Configurations
{
- ///
- /// Configuration for an MTConnect Http Agent Module
- ///
- public class ModuleConfiguration : HttpServerConfiguration
+ public class HttpServerModuleConfiguration : HttpServerConfiguration
{
public IEnumerable DevicesNamespaces { get; set; }
diff --git a/agent/Modules/MTConnect.NET-AgentModule-HttpServer/MTConnectHttpAgentServer.cs b/agent/Modules/MTConnect.NET-AgentModule-HttpServer/MTConnectHttpAgentServer.cs
index a06d9801..06b59cda 100644
--- a/agent/Modules/MTConnect.NET-AgentModule-HttpServer/MTConnectHttpAgentServer.cs
+++ b/agent/Modules/MTConnect.NET-AgentModule-HttpServer/MTConnectHttpAgentServer.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
+// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.
using Ceen.Httpd;
@@ -27,10 +27,10 @@ public class MTConnectHttpAgentServer : MTConnectHttpServer
private static readonly Dictionary _commonSchemas = new Dictionary();
private static readonly object _lock = new object();
- private readonly ModuleConfiguration _moduleConfiguration;
+ private readonly HttpServerModuleConfiguration _moduleConfiguration;
- public MTConnectHttpAgentServer(ModuleConfiguration configuration, IMTConnectAgentBroker mtconnectAgent) : base(configuration, mtconnectAgent)
+ public MTConnectHttpAgentServer(HttpServerModuleConfiguration configuration, IMTConnectAgentBroker mtconnectAgent) : base(configuration, mtconnectAgent)
{
_moduleConfiguration = configuration;
}
@@ -41,7 +41,7 @@ protected override void OnConfigureServer(ServerConfig serverConfig)
base.OnConfigureServer(serverConfig);
}
- protected override byte[] OnProcessStatic(MTConnectStaticFileRequest request)
+ protected override Stream OnProcessStatic(MTConnectStaticFileRequest request)
{
if (request.LocalPath != null)
{
@@ -142,7 +142,7 @@ protected override List> OnCreateFormatOptions(MTCo
#region "Stylesheets"
- private static byte[] ReadDevicesStylesheet(string filePath, Version mtconnectVersion)
+ private static Stream ReadDevicesStylesheet(string filePath, Version mtconnectVersion)
{
if (filePath != null)
{
@@ -173,7 +173,7 @@ private static byte[] ReadDevicesStylesheet(string filePath, Version mtconnectVe
}
catch { }
- return Encoding.UTF8.GetBytes(s);
+ return new MemoryStream(Encoding.UTF8.GetBytes(s));
}
}
catch { }
@@ -182,7 +182,7 @@ private static byte[] ReadDevicesStylesheet(string filePath, Version mtconnectVe
return null;
}
- private static byte[] ReadStreamsStylesheet(string filePath, Version mtconnectVersion)
+ private static Stream ReadStreamsStylesheet(string filePath, Version mtconnectVersion)
{
if (filePath != null)
{
@@ -199,7 +199,7 @@ private static byte[] ReadStreamsStylesheet(string filePath, Version mtconnectVe
fileContents = Regex.Replace(fileContents, pattern, replace);
}
- return Encoding.UTF8.GetBytes(fileContents);
+ return new MemoryStream(Encoding.UTF8.GetBytes(fileContents));
}
}
catch { }
diff --git a/agent/Modules/MTConnect.NET-AgentModule-HttpServer/MTConnectShdrHttpAgentServer.cs b/agent/Modules/MTConnect.NET-AgentModule-HttpServer/MTConnectShdrHttpAgentServer.cs
index c4bd11c6..2c857712 100644
--- a/agent/Modules/MTConnect.NET-AgentModule-HttpServer/MTConnectShdrHttpAgentServer.cs
+++ b/agent/Modules/MTConnect.NET-AgentModule-HttpServer/MTConnectShdrHttpAgentServer.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
+// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.
using MTConnect.Agents;
@@ -9,6 +9,7 @@
using MTConnect.Servers;
using MTConnect.Shdr;
using System;
+using System.IO;
using System.Linq;
using System.Text;
@@ -19,7 +20,7 @@ namespace MTConnect.Modules.Http
///
public class MTConnectShdrHttpAgentServer : MTConnectHttpAgentServer
{
- public MTConnectShdrHttpAgentServer(ModuleConfiguration configuration, IMTConnectAgentBroker mtconnectAgent) : base(configuration, mtconnectAgent) { }
+ public MTConnectShdrHttpAgentServer(HttpServerModuleConfiguration configuration, IMTConnectAgentBroker mtconnectAgent) : base(configuration, mtconnectAgent) { }
protected override bool OnObservationInput(MTConnectObservationInputArgs args)
@@ -96,8 +97,8 @@ protected override bool OnAssetInput(MTConnectAssetInputArgs args)
{
if (!string.IsNullOrEmpty(args.DeviceKey) && !string.IsNullOrEmpty(args.AssetType))
{
- //var asset = Assets.Xml.XmlAsset.FromXml(assetType, );
- var result = EntityFormatter.CreateAsset(args.DocumentFormat, args.AssetType, ReadRequestBody(args.RequestBody));
+ var stream = new MemoryStream(args.RequestBody);
+ var result = EntityFormatter.CreateAsset(args.DocumentFormat, args.AssetType, ReadRequestBody(stream));
if (result.Success)
{
var asset = (Asset)result.Content;
@@ -110,18 +111,41 @@ protected override bool OnAssetInput(MTConnectAssetInputArgs args)
return false;
}
- private byte[] ReadRequestBody(byte[] bytes)
+ private Stream ReadRequestBody(Stream inputStream)
{
- if (bytes != null)
+ if (inputStream != null)
{
try
{
- return Encoding.Convert(Encoding.ASCII, Encoding.UTF8, bytes);
+ using (var memoryStream = new MemoryStream())
+ {
+ // Probably a more efficient way to do this but this probably won't get called at a high frequency
+
+ inputStream.CopyTo(memoryStream);
+ var inputBytes = memoryStream.ToArray();
+ var outputBytes = Encoding.Convert(Encoding.ASCII, Encoding.UTF8, inputBytes);
+ return new MemoryStream(outputBytes);
+ }
+
}
catch { }
}
return null;
}
+
+ //private byte[] ReadRequestBody(byte[] bytes)
+ //{
+ // if (bytes != null)
+ // {
+ // try
+ // {
+ // return Encoding.Convert(Encoding.ASCII, Encoding.UTF8, bytes);
+ // }
+ // catch { }
+ // }
+
+ // return null;
+ //}
}
}
\ No newline at end of file
diff --git a/agent/Modules/MTConnect.NET-AgentModule-HttpServer/Module.cs b/agent/Modules/MTConnect.NET-AgentModule-HttpServer/Module.cs
index 8276af90..197ede0a 100644
--- a/agent/Modules/MTConnect.NET-AgentModule-HttpServer/Module.cs
+++ b/agent/Modules/MTConnect.NET-AgentModule-HttpServer/Module.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
+// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.
using Ceen;
@@ -19,7 +19,7 @@ public class Module : MTConnectAgentModule
private const string HttpServerLogId = "HTTP-Server";
private const string ValidationLogId = "Agent-Validation";
- private readonly ModuleConfiguration _configuration;
+ private readonly HttpServerModuleConfiguration _configuration;
private readonly IMTConnectAgentBroker _mtconnectAgent;
private MTConnectHttpServer _httpServer;
@@ -28,7 +28,7 @@ public Module(IMTConnectAgentBroker mtconnectAgent, object controllerConfigurati
Id = ModuleId;
_mtconnectAgent = mtconnectAgent;
- _configuration = AgentApplicationConfiguration.GetConfiguration(controllerConfiguration);
+ _configuration = AgentApplicationConfiguration.GetConfiguration(controllerConfiguration);
}
diff --git a/agent/Modules/MTConnect.NET-AgentModule-MqttAdapter/Module.cs b/agent/Modules/MTConnect.NET-AgentModule-MqttAdapter/Module.cs
index a95e4e7e..6545e176 100644
--- a/agent/Modules/MTConnect.NET-AgentModule-MqttAdapter/Module.cs
+++ b/agent/Modules/MTConnect.NET-AgentModule-MqttAdapter/Module.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
+// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.
using MQTTnet;
@@ -29,7 +29,7 @@ public class Module : MTConnectAgentModule
private const string AssetTopic = "assets";
private const string DeviceTopic = "device";
- private readonly ModuleConfiguration _configuration;
+ private readonly MqttAdapterModuleConfiguration _configuration;
private readonly IMTConnectAgentBroker _mtconnectAgent;
private readonly MqttFactory _mqttFactory;
private readonly IMqttClient _mqttClient;
@@ -45,7 +45,7 @@ public Module(IMTConnectAgentBroker mtconnectAgent, object configuration) : base
_mqttClient = _mqttFactory.CreateMqttClient();
_mqttClient.ApplicationMessageReceivedAsync += MessageReceived;
- _configuration = AgentApplicationConfiguration.GetConfiguration(configuration);
+ _configuration = AgentApplicationConfiguration.GetConfiguration(configuration);
}
diff --git a/agent/Modules/MTConnect.NET-AgentModule-MqttAdapter/ModuleConfiguration.cs b/agent/Modules/MTConnect.NET-AgentModule-MqttAdapter/MqttAdapterModuleConfiguration.cs
similarity index 95%
rename from agent/Modules/MTConnect.NET-AgentModule-MqttAdapter/ModuleConfiguration.cs
rename to agent/Modules/MTConnect.NET-AgentModule-MqttAdapter/MqttAdapterModuleConfiguration.cs
index 95ef3f76..61f633c3 100644
--- a/agent/Modules/MTConnect.NET-AgentModule-MqttAdapter/ModuleConfiguration.cs
+++ b/agent/Modules/MTConnect.NET-AgentModule-MqttAdapter/MqttAdapterModuleConfiguration.cs
@@ -1,9 +1,9 @@
-// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
+// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.
namespace MTConnect.Configurations
{
- public class ModuleConfiguration
+ public class MqttAdapterModuleConfiguration
{
///
/// The MQTT broker hostname
@@ -94,7 +94,7 @@ public class ModuleConfiguration
public string DocumentFormat { get; set; }
- public ModuleConfiguration()
+ public MqttAdapterModuleConfiguration()
{
Server = "localhost";
Port = 1883;
diff --git a/agent/Modules/MTConnect.NET-AgentModule-MqttBroker/Module.cs b/agent/Modules/MTConnect.NET-AgentModule-MqttBroker/Module.cs
index a4f22b2b..2b9cce0e 100644
--- a/agent/Modules/MTConnect.NET-AgentModule-MqttBroker/Module.cs
+++ b/agent/Modules/MTConnect.NET-AgentModule-MqttBroker/Module.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
+// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.
using MQTTnet;
@@ -26,7 +26,7 @@ public class Module : MTConnectAgentModule
public const string ConfigurationTypeId = "mqtt-broker";
private const string ModuleId = "MQTT Broker";
- private readonly ModuleConfiguration _configuration;
+ private readonly MqttBrokerModuleConfiguration _configuration;
private readonly MTConnectMqttDocumentServer _server;
private MqttServer _mqttServer;
private CancellationTokenSource _stop;
@@ -36,7 +36,7 @@ public Module(IMTConnectAgentBroker mtconnectAgent, object configuration) : base
{
Id = ModuleId;
- _configuration = AgentApplicationConfiguration.GetConfiguration(configuration);
+ _configuration = AgentApplicationConfiguration.GetConfiguration(configuration);
_server = new MTConnectMqttDocumentServer(mtconnectAgent, _configuration);
_server.ProbeReceived += ProbeReceived;
@@ -162,11 +162,18 @@ private async void ProbeReceived(IDevice device, IDevicesResponseDocument respon
{
var topic = $"{_configuration.TopicPrefix}/{MTConnectMqttDocumentServer.ProbeTopic}/{device.Uuid}";
- var message = new MqttApplicationMessage();
- message.Retain = true;
- message.Topic = topic;
- message.QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtLeastOnce;
- message.Payload = formatResult.Content;
+ //var message = new MqttApplicationMessage();
+ //message.Retain = true;
+ //message.Topic = topic;
+ //message.QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtLeastOnce;
+ //message.Payload = formatResult.Content;
+
+ var messageBuilder = new MqttApplicationMessageBuilder();
+ messageBuilder.WithRetainFlag(true);
+ messageBuilder.WithTopic(topic);
+ messageBuilder.WithQualityOfServiceLevel(MQTTnet.Protocol.MqttQualityOfServiceLevel.AtLeastOnce);
+ messageBuilder.WithPayload(formatResult.Content);
+ var message = messageBuilder.Build();
var injectMessage = new InjectedMqttApplicationMessage(message);
@@ -184,11 +191,18 @@ private async void CurrentReceived(IDevice device, IStreamsResponseOutputDocumen
{
var topic = $"{_configuration.TopicPrefix}/{MTConnectMqttDocumentServer.CurrentTopic}/{device.Uuid}";
- var message = new MqttApplicationMessage();
- message.Retain = true;
- message.Topic = topic;
- message.QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtLeastOnce;
- message.Payload = formatResult.Content;
+ //var message = new MqttApplicationMessage();
+ //message.Retain = true;
+ //message.Topic = topic;
+ //message.QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtLeastOnce;
+ //message.Payload = formatResult.Content;
+
+ var messageBuilder = new MqttApplicationMessageBuilder();
+ messageBuilder.WithRetainFlag(true);
+ messageBuilder.WithTopic(topic);
+ messageBuilder.WithQualityOfServiceLevel(MQTTnet.Protocol.MqttQualityOfServiceLevel.AtLeastOnce);
+ messageBuilder.WithPayload(formatResult.Content);
+ var message = messageBuilder.Build();
var injectMessage = new InjectedMqttApplicationMessage(message);
@@ -206,11 +220,18 @@ private async void SampleReceived(IDevice device, IStreamsResponseOutputDocument
{
var topic = $"{_configuration.TopicPrefix}/{MTConnectMqttDocumentServer.SampleTopic}/{device.Uuid}";
- var message = new MqttApplicationMessage();
- //message.Retain = true;
- message.Topic = topic;
- message.QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtLeastOnce;
- message.Payload = formatResult.Content;
+ //var message = new MqttApplicationMessage();
+ ////message.Retain = true;
+ //message.Topic = topic;
+ //message.QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtLeastOnce;
+ //message.Payload = formatResult.Content;
+
+ var messageBuilder = new MqttApplicationMessageBuilder();
+ messageBuilder.WithRetainFlag(true);
+ messageBuilder.WithTopic(topic);
+ messageBuilder.WithQualityOfServiceLevel(MQTTnet.Protocol.MqttQualityOfServiceLevel.AtLeastOnce);
+ messageBuilder.WithPayload(formatResult.Content);
+ var message = messageBuilder.Build();
var injectMessage = new InjectedMqttApplicationMessage(message);
@@ -233,11 +254,18 @@ private async void AssetReceived(IDevice device, IAssetsResponseDocument respons
{
var topic = $"{_configuration.TopicPrefix}/{MTConnectMqttDocumentServer.AssetTopic}/{device.Uuid}/{asset.AssetId}";
- var message = new MqttApplicationMessage();
- message.Retain = true;
- message.Topic = topic;
- message.QualityOfServiceLevel = (MQTTnet.Protocol.MqttQualityOfServiceLevel)_configuration.QoS;
- message.Payload = formatResult.Content;
+ //var message = new MqttApplicationMessage();
+ //message.Retain = true;
+ //message.Topic = topic;
+ //message.QualityOfServiceLevel = (MQTTnet.Protocol.MqttQualityOfServiceLevel)_configuration.QoS;
+ //message.Payload = formatResult.Content;
+
+ var messageBuilder = new MqttApplicationMessageBuilder();
+ messageBuilder.WithRetainFlag(true);
+ messageBuilder.WithTopic(topic);
+ messageBuilder.WithQualityOfServiceLevel(MQTTnet.Protocol.MqttQualityOfServiceLevel.AtLeastOnce);
+ messageBuilder.WithPayload(formatResult.Content);
+ var message = messageBuilder.Build();
var injectMessage = new InjectedMqttApplicationMessage(message);
diff --git a/agent/Modules/MTConnect.NET-AgentModule-MqttBroker/ModuleConfiguration.cs b/agent/Modules/MTConnect.NET-AgentModule-MqttBroker/MqttBrokerModuleConfiguration.cs
similarity index 93%
rename from agent/Modules/MTConnect.NET-AgentModule-MqttBroker/ModuleConfiguration.cs
rename to agent/Modules/MTConnect.NET-AgentModule-MqttBroker/MqttBrokerModuleConfiguration.cs
index 5a567f79..62e258d7 100644
--- a/agent/Modules/MTConnect.NET-AgentModule-MqttBroker/ModuleConfiguration.cs
+++ b/agent/Modules/MTConnect.NET-AgentModule-MqttBroker/MqttBrokerModuleConfiguration.cs
@@ -1,9 +1,9 @@
-// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
+// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.
namespace MTConnect.Configurations
{
- public class ModuleConfiguration : IMTConnectMqttServerConfiguration
+ public class MqttBrokerModuleConfiguration : IMTConnectMqttServerConfiguration
{
///
/// The MQTT broker hostname to bind to
@@ -86,7 +86,7 @@ public class ModuleConfiguration : IMTConnectMqttServerConfiguration
public int SampleInterval { get; set; }
- public ModuleConfiguration()
+ public MqttBrokerModuleConfiguration()
{
Port = 1883;
InitialDelay = 500;
diff --git a/agent/Modules/MTConnect.NET-AgentModule-MqttRelay/Module.cs b/agent/Modules/MTConnect.NET-AgentModule-MqttRelay/Module.cs
index e467f3bd..cc31b5c4 100644
--- a/agent/Modules/MTConnect.NET-AgentModule-MqttRelay/Module.cs
+++ b/agent/Modules/MTConnect.NET-AgentModule-MqttRelay/Module.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
+// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.
using MQTTnet;
@@ -24,7 +24,7 @@ public class Module : MTConnectAgentModule
public const string ConfigurationTypeId = "mqtt-relay";
private const string ModuleId = "MQTT Relay";
- private readonly ModuleConfiguration _configuration;
+ private readonly MqttRelayModuleConfiguration _configuration;
private readonly MTConnectMqttDocumentServer _server;
private readonly MqttFactory _mqttFactory;
private readonly IMqttClient _mqttClient;
@@ -35,7 +35,7 @@ public Module(IMTConnectAgentBroker mtconnectAgent, object configuration) : base
{
Id = ModuleId;
- _configuration = AgentApplicationConfiguration.GetConfiguration(configuration);
+ _configuration = AgentApplicationConfiguration.GetConfiguration(configuration);
_server = new MTConnectMqttDocumentServer(mtconnectAgent, _configuration);
_server.ProbeReceived += ProbeReceived;
@@ -181,11 +181,18 @@ private async void ProbeReceived(IDevice device, IDevicesResponseDocument respon
{
var topic = $"{_configuration.TopicPrefix}/{MTConnectMqttDocumentServer.ProbeTopic}/{device.Uuid}";
- var message = new MqttApplicationMessage();
- message.Retain = true;
- message.Topic = topic;
- message.QualityOfServiceLevel = (MQTTnet.Protocol.MqttQualityOfServiceLevel)_configuration.QoS;
- message.Payload = formatResult.Content;
+ //var message = new MqttApplicationMessage();
+ //message.Retain = true;
+ //message.Topic = topic;
+ //message.QualityOfServiceLevel = (MQTTnet.Protocol.MqttQualityOfServiceLevel)_configuration.QoS;
+ //message.Payload = formatResult.Content;
+
+ var messageBuilder = new MqttApplicationMessageBuilder();
+ messageBuilder.WithRetainFlag(true);
+ messageBuilder.WithTopic(topic);
+ messageBuilder.WithQualityOfServiceLevel(MQTTnet.Protocol.MqttQualityOfServiceLevel.AtLeastOnce);
+ messageBuilder.WithPayload(formatResult.Content);
+ var message = messageBuilder.Build();
try
{
@@ -219,11 +226,18 @@ private async void CurrentReceived(IDevice device, IStreamsResponseOutputDocumen
{
var topic = $"{_configuration.TopicPrefix}/{MTConnectMqttDocumentServer.CurrentTopic}/{device.Uuid}";
- var message = new MqttApplicationMessage();
- //message.Retain = true;
- message.Topic = topic;
- message.QualityOfServiceLevel = (MQTTnet.Protocol.MqttQualityOfServiceLevel)_configuration.QoS;
- message.Payload = formatResult.Content;
+ //var message = new MqttApplicationMessage();
+ ////message.Retain = true;
+ //message.Topic = topic;
+ //message.QualityOfServiceLevel = (MQTTnet.Protocol.MqttQualityOfServiceLevel)_configuration.QoS;
+ //message.Payload = formatResult.Content;
+
+ var messageBuilder = new MqttApplicationMessageBuilder();
+ //messageBuilder.WithRetainFlag(true);
+ messageBuilder.WithTopic(topic);
+ messageBuilder.WithQualityOfServiceLevel(MQTTnet.Protocol.MqttQualityOfServiceLevel.AtLeastOnce);
+ messageBuilder.WithPayload(formatResult.Content);
+ var message = messageBuilder.Build();
try
{
@@ -257,11 +271,18 @@ private async void SampleReceived(IDevice device, IStreamsResponseOutputDocument
{
var topic = $"{_configuration.TopicPrefix}/{MTConnectMqttDocumentServer.SampleTopic}/{device.Uuid}";
- var message = new MqttApplicationMessage();
- //message.Retain = true;
- message.Topic = topic;
- message.QualityOfServiceLevel = (MQTTnet.Protocol.MqttQualityOfServiceLevel)_configuration.QoS;
- message.Payload = formatResult.Content;
+ //var message = new MqttApplicationMessage();
+ ////message.Retain = true;
+ //message.Topic = topic;
+ //message.QualityOfServiceLevel = (MQTTnet.Protocol.MqttQualityOfServiceLevel)_configuration.QoS;
+ //message.Payload = formatResult.Content;
+
+ var messageBuilder = new MqttApplicationMessageBuilder();
+ //messageBuilder.WithRetainFlag(true);
+ messageBuilder.WithTopic(topic);
+ messageBuilder.WithQualityOfServiceLevel(MQTTnet.Protocol.MqttQualityOfServiceLevel.AtLeastOnce);
+ messageBuilder.WithPayload(formatResult.Content);
+ var message = messageBuilder.Build();
try
{
@@ -297,11 +318,18 @@ private async void AssetReceived(IDevice device, IAssetsResponseDocument respons
{
var topic = $"{_configuration.TopicPrefix}/{MTConnectMqttDocumentServer.AssetTopic}/{device.Uuid}/{asset.AssetId}";
- var message = new MqttApplicationMessage();
- message.Retain = true;
- message.Topic = topic;
- message.QualityOfServiceLevel = (MQTTnet.Protocol.MqttQualityOfServiceLevel)_configuration.QoS;
- message.Payload = formatResult.Content;
+ //var message = new MqttApplicationMessage();
+ //message.Retain = true;
+ //message.Topic = topic;
+ //message.QualityOfServiceLevel = (MQTTnet.Protocol.MqttQualityOfServiceLevel)_configuration.QoS;
+ //message.Payload = formatResult.Content;
+
+ var messageBuilder = new MqttApplicationMessageBuilder();
+ messageBuilder.WithRetainFlag(true);
+ messageBuilder.WithTopic(topic);
+ messageBuilder.WithQualityOfServiceLevel(MQTTnet.Protocol.MqttQualityOfServiceLevel.AtLeastOnce);
+ messageBuilder.WithPayload(formatResult.Content);
+ var message = messageBuilder.Build();
try
{
diff --git a/agent/Modules/MTConnect.NET-AgentModule-MqttRelay/ModuleConfiguration.cs b/agent/Modules/MTConnect.NET-AgentModule-MqttRelay/MqttRelayModuleConfiguration.cs
similarity index 94%
rename from agent/Modules/MTConnect.NET-AgentModule-MqttRelay/ModuleConfiguration.cs
rename to agent/Modules/MTConnect.NET-AgentModule-MqttRelay/MqttRelayModuleConfiguration.cs
index f92475bb..882eec96 100644
--- a/agent/Modules/MTConnect.NET-AgentModule-MqttRelay/ModuleConfiguration.cs
+++ b/agent/Modules/MTConnect.NET-AgentModule-MqttRelay/MqttRelayModuleConfiguration.cs
@@ -1,9 +1,9 @@
-// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
+// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.
namespace MTConnect.Configurations
{
- public class ModuleConfiguration : IMTConnectMqttServerConfiguration
+ public class MqttRelayModuleConfiguration : IMTConnectMqttServerConfiguration
{
///
/// The MQTT broker hostname
@@ -105,7 +105,7 @@ public class ModuleConfiguration : IMTConnectMqttServerConfiguration
public int SampleInterval { get; set; }
- public ModuleConfiguration()
+ public MqttRelayModuleConfiguration()
{
Server = "localhost";
Port = 7878;
diff --git a/agent/Modules/MTConnect.NET-AgentModule-ShdrAdapter/Module.cs b/agent/Modules/MTConnect.NET-AgentModule-ShdrAdapter/Module.cs
index 5d93b7d3..5b1c025c 100644
--- a/agent/Modules/MTConnect.NET-AgentModule-ShdrAdapter/Module.cs
+++ b/agent/Modules/MTConnect.NET-AgentModule-ShdrAdapter/Module.cs
@@ -20,7 +20,7 @@ public class Module : MTConnectAgentModule
public const string ConfigurationTypeId = "shdr-adapter";
private const string ModuleId = "SHDR Adapter";
- private readonly ModuleConfiguration _configuration;
+ private readonly ShdrAdapterModuleConfiguration _configuration;
private readonly IMTConnectAgentBroker _mtconnectAgent;
private readonly List _adapters = new List();
@@ -30,7 +30,7 @@ public Module(IMTConnectAgentBroker mtconnectAgent, object configuration) : base
Id = ModuleId;
_mtconnectAgent = mtconnectAgent;
- _configuration = AgentApplicationConfiguration.GetConfiguration(configuration);
+ _configuration = AgentApplicationConfiguration.GetConfiguration(configuration);
}
diff --git a/agent/Modules/MTConnect.NET-AgentModule-ShdrAdapter/ModuleConfiguration.cs b/agent/Modules/MTConnect.NET-AgentModule-ShdrAdapter/ShdrAdapterModuleConfiguration.cs
similarity index 65%
rename from agent/Modules/MTConnect.NET-AgentModule-ShdrAdapter/ModuleConfiguration.cs
rename to agent/Modules/MTConnect.NET-AgentModule-ShdrAdapter/ShdrAdapterModuleConfiguration.cs
index 8122e5be..5b1fd627 100644
--- a/agent/Modules/MTConnect.NET-AgentModule-ShdrAdapter/ModuleConfiguration.cs
+++ b/agent/Modules/MTConnect.NET-AgentModule-ShdrAdapter/ShdrAdapterModuleConfiguration.cs
@@ -1,9 +1,9 @@
-// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
+// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.
namespace MTConnect.Configurations
{
- public class ModuleConfiguration : ShdrAdapterClientConfiguration
+ public class ShdrAdapterModuleConfiguration : ShdrAdapterClientConfiguration
{
///
/// Gets or Sets whether a Device Model can be sent from an SHDR Adapter
@@ -11,7 +11,7 @@ public class ModuleConfiguration : ShdrAdapterClientConfiguration
public bool AllowShdrDevice { get; set; }
- public ModuleConfiguration()
+ public ShdrAdapterModuleConfiguration()
{
AllowShdrDevice = false;
}
diff --git a/build/AssemblyInfo.cs b/build/AssemblyInfo.cs
index e1e68fb9..23e2506e 100644
--- a/build/AssemblyInfo.cs
+++ b/build/AssemblyInfo.cs
@@ -1,6 +1,6 @@
using System.Reflection;
-[assembly: AssemblyVersion("6.0.12")]
-[assembly: AssemblyFileVersion("6.0.12")]
+[assembly: AssemblyVersion("6.0.14")]
+[assembly: AssemblyFileVersion("6.0.14")]
[assembly: AssemblyCompany("TrakHound Inc.")]
[assembly: AssemblyCopyright("Copyright (c) 2024 TrakHound Inc., All Rights Reserved.")]
diff --git a/libraries/MTConnect.NET-Common/Agents/MTConnectAgentModules.cs b/libraries/MTConnect.NET-Common/Agents/MTConnectAgentModules.cs
index 58e5be32..816fdfdd 100644
--- a/libraries/MTConnect.NET-Common/Agents/MTConnectAgentModules.cs
+++ b/libraries/MTConnect.NET-Common/Agents/MTConnectAgentModules.cs
@@ -66,19 +66,26 @@ public void Load()
{
if (_configuration.IsModuleConfigured(configurationTypeId))
{
- try
- {
- // Create new Instance of the Controller and add to cached dictionary
- var module = (IMTConnectAgentModule)Activator.CreateInstance(moduleType, new object[] { _mtconnectAgent, null });
- module.LogReceived += HandleModuleLogReceived;
-
- var moduleId = Guid.NewGuid().ToString();
-
- if (ModuleLoaded != null) ModuleLoaded.Invoke(this, module);
-
- lock (_lock) _modules.Add(moduleId, module);
- }
- catch { }
+ var moduleCount = _configuration.GetModuleCount(configurationTypeId);
+ if (moduleCount > 0)
+ {
+ for (int i = 0; i < moduleCount; i++)
+ {
+ try
+ {
+ // Create new Instance of the Controller and add to cached dictionary
+ var module = (IMTConnectAgentModule)Activator.CreateInstance(moduleType, new object[] { _mtconnectAgent, null });
+ module.LogReceived += HandleModuleLogReceived;
+
+ var moduleId = Guid.NewGuid().ToString();
+
+ if (ModuleLoaded != null) ModuleLoaded.Invoke(this, module);
+
+ lock (_lock) _modules.Add(moduleId, module);
+ }
+ catch { }
+ }
+ }
}
}
}
diff --git a/libraries/MTConnect.NET-Common/Agents/MTConnectInputAgentModule.cs b/libraries/MTConnect.NET-Common/Agents/MTConnectInputAgentModule.cs
index a96454c0..7e512322 100644
--- a/libraries/MTConnect.NET-Common/Agents/MTConnectInputAgentModule.cs
+++ b/libraries/MTConnect.NET-Common/Agents/MTConnectInputAgentModule.cs
@@ -461,7 +461,7 @@ public void AddTimeSeriesObservation(
public void AddObservation(IObservationInput observation)
{
- Agent.AddObservation(observation);
+ Agent.AddObservation(_device.Uuid, observation);
}
diff --git a/libraries/MTConnect.NET-Common/Configurations/AdapterApplicationConfiguration.cs b/libraries/MTConnect.NET-Common/Configurations/AdapterApplicationConfiguration.cs
index 4b57549e..e10737d1 100644
--- a/libraries/MTConnect.NET-Common/Configurations/AdapterApplicationConfiguration.cs
+++ b/libraries/MTConnect.NET-Common/Configurations/AdapterApplicationConfiguration.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
+// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.
using System;
diff --git a/libraries/MTConnect.NET-Common/Configurations/AgentApplicationConfiguration.cs b/libraries/MTConnect.NET-Common/Configurations/AgentApplicationConfiguration.cs
index 3f554039..24a940ef 100644
--- a/libraries/MTConnect.NET-Common/Configurations/AgentApplicationConfiguration.cs
+++ b/libraries/MTConnect.NET-Common/Configurations/AgentApplicationConfiguration.cs
@@ -1,8 +1,9 @@
-// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
+// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.
-using MTConnect.Devices.Configurations;
+using System;
using System.Collections.Generic;
+using System.Linq;
using System.Text.Json.Serialization;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
@@ -132,6 +133,31 @@ public IEnumerable