.NET MTConnect Agent v6 that supports HTTP, MQTT, and SHDR. Built from the MTConnect.NET project.
5.2K

| Name | Link | |
|---|---|---|
| Installer | https://github.com/TrakHound/MTConnect.NET/releases/latest | |
| Docker | https://hub.docker.com/repository/docker/trakhound/mtconnect.net-agent |
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.7 of the MTConnect Standard.

| Description | Supported | Description | Supported |
|---|---|---|---|
| MTConnect Probe | :white_check_mark: | HTTP Server | :white_check_mark: |
| MTConnect Current | :white_check_mark: | MQTT Server (Internal Broker) | :white_check_mark: |
| MTConnect Sample | :white_check_mark: | MQTT Server (External Broker) | :white_check_mark: |
| MTConnect Assets | :white_check_mark: | SHDR Adapters (Input Data) | :white_check_mark: |
| MTConnect Interfaces | :white_check_mark: | HTTP Adapters (Input Data) | :white_check_mark: |
| Configuration File Monitoring | :white_check_mark: | MQTT Adapters (Input Data) | :white_check_mark: |
| Unit Conversion | :white_check_mark: | XML Stylesheets | :white_check_mark: |
| Script Transformation (Python) | :white_check_mark: | XML Static Files | :white_check_mark: |
| Windows Service | :white_check_mark: | XML Schemas | :white_check_mark: |
| Linux Supported | :white_check_mark: | XML Validation | :white_check_mark: |
| Durable File Buffer | :white_check_mark: | JSON (MTConnect.NET v5) | :white_check_mark: |
| Debug Logging | :white_check_mark: | JSON (cppagent) | :white_check_mark: |
| MTConnect Entity Validation | :white_check_mark: | TLS (HTTP & MQTT) | :white_check_mark: |
Follow the steps below to install the MTConnect Agent application.
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

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.

Select the .NET version and Architecture (x64 or x86) to install the application for Then click "Next" to proceed to the next page.

Review the list of components that will be installed and if correct then click "Install" to begin the installation.

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.

View the Probe and Current requests in a Web Browser


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|trace|run|run-service|reset] [configuration_file]
--------------------
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)
trace | Runs the Agent in the terminal (with trace level logging)
run | Runs the Agent in the terminal
run-service | Runs the Agent as a Service
reset | Clears the durable Observation and Asset buffers and their indexes
Arguments :
--------------------
configuration_file | Specifies the Agent Configuration file to load
Default : agent.config.yaml
If no command is given, run is used. A relative configuration_file path is resolved against the executable's directory. If no configuration_file is given and a legacy agent.config.json file exists in the executable's directory, it is read and converted to agent.config.yaml on startup.
Install the Agent as a Windows Service (Note: requires Administrator Privileges)
agent install
Install the Agent as a Windows Service using the configuration file "agent-config.yaml" and Starts the service (Note: requires Administrator Privileges)
agent install-start agent-config.yaml
Starts the Windows Service (Note: requires Administrator Privileges)
agent start
More information about Configurations. The default configuration file is shown below :
# - Device Configuration -
devices: devices
# - Processors -
processors:
- python: # - Add Python Processor
directory: processors
# - Modules -
modules:
- web-ui: # - Add Web UI module (browse data and edit this configuration at http://localhost:5080)
port: 5080
- http-server: # - Add HTTP Server module
port: 5000
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
# - 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
# currentInterval: 10000
# sampleInterval: 500
# documentFormat: JSON-CPPAGENT
# topicPrefix: MTConnect/Document
# topicStructure: Document
# - mqtt-broker: # - Add MQTT Broker module (Entity Structure)
# port: 1883
# currentInterval: 10000
# sampleInterval: 500
# documentFormat: JSON
# topicPrefix: MTConnect/Entity
# topicStructure: Entity
# - mqtt-broker: # - Add MQTT Broker module (TLS)
# port: 8883
# currentInterval: 10000
# sampleInterval: 500
# tls:
# pem:
# certificateAuthority: c:\test-cert\rootCA.crt
# certificatePath: c:\test-cert\trakhound.crt
# privateKeyPath: c:\test-cert\trakhound.key
# privateKeyPassword: trakhound
- mqtt-relay: # - Add MQTT Relay module (Document Structure)
server: localhost
port: 1883
durableRelay: false
currentInterval: 10000
sampleInterval: 500
documentFormat: JSON-CPPAGENT-MQTT
topicPrefix: MTConnect/Document
topicStructure: Document
# - mqtt-relay: # - Add MQTT Relay module (Entity Structure)
# server: localhost
# port: 1883
# durableRelay: true
# currentInterval: 10000
# sampleInterval: 500
# documentFormat: JSON
# topicPrefix: MTConnect/Entity
# topicStructure: Entity
# - mqtt-relay: # - Add MQTT Relay module (TLS)
# server: localhost
# port: 8883
# durableRelay: true
# currentInterval: 10000
# sampleInterval: 500
# tls:
# pem:
# certificateAuthority: c:\test-cert\rootCA.crt
# certificatePath: c:\test-cert\trakhound.crt
# privateKeyPath: c:\test-cert\trakhound.key
# privateKeyPassword: trakhound
- shdr-adapter: # - Add SHDR Adapter module for Device = Okuma and Port = 7878
deviceKey: Okuma
# hostname: localhost
port: 7878
heartbeat: 1000
reconnectInterval: 1000
connectionTimeout: 1000
- shdr-adapter: # - Add SHDR Adapter module for Device = Mazak and Port = 7879
deviceKey: Mazak
# hostname: localhost
port: 7879
heartbeat: 1000
reconnectInterval: 1000
connectionTimeout: 1000
# 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: true
# durableBufferPath: C:\mtconnect\agent\buffer
# Disables the Agent Device
# enableAgentDevice: false
# Sets the default MTConnect version to output response documents for.
# defaultVersion: 2.3
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. There is no default: if devices is not set, no Device files are loaded.processors - Contains configurations for Agent Processors (ex. python). These configurations are specific to the individual processors.modules - Contains configurations for Agent Modules. These configurations are specific to the individual modules and may be customized for custom modules.observationBufferSize - The maximum number of Observations the agent can hold in its buffer. Default is 131072.
assetBufferSize - The maximum number of assets the agent can hold in its buffer. Default is 1024.
durable - Sets whether the Agent buffers are durable and retain state after restart. Default is false.
durableBufferPath - The base path to the directory to write the buffer files to when durable is true
useBufferCompression - Sets whether the durable Agent buffers use Compression. Default is false.
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. Default is false.
defaultVersion - Sets the default MTConnect version to output response documents for. Default is the latest version supported (2.7).
sender - Sets the sender attribute in the Header of response documents. Default is the host name of the machine the Agent is running on.
timeZoneOutput - Sets the TimeZone to use when timestamps are output from the Agent
convertUnits - Sets the default for Converting Units when adding Observations. Default is true.
ignoreObservationCase - Sets the default for Ignoring the case of Observation values. Applicable values will be converted to uppercase. Default is false.
enableValidation - Sets whether Observations are validated against their DataItem when they are added, and marked as valid or invalid in the output. Default is false.
inputValidationLevel - Sets the default per-DataItem validation level applied when new Observations and Assets are added to the Agent. Governs InvalidObservationAdded and InvalidAssetAdded. 0 = Ignore, 1 = Warning, 2 = Remove, 3 = Strict. Default is Warning.
deviceValidationLevel - Sets the default device-shape validation level applied while a Device is being added or normalised (Component, Composition, DataItem). Independent from inputValidationLevel — a common integrator profile is inputValidationLevel: Strict alongside deviceValidationLevel: Warning. Governs InvalidComponentAdded, InvalidCompositionAdded, InvalidDataItemAdded, and InvalidDeviceAdded. 0 = Ignore, 1 = Warning, 2 = Remove, 3 = Strict. Default is Warning.
allowEmptyResultForEnumEvents - When true, preserves an empty Result verbatim on VALUE-representation EVENT DataItems whose Type has a controlled vocabulary (EXECUTION, CONTROLLER_MODE, AVAILABILITY, etc.). Default false coerces the empty Result to UNAVAILABLE. Free-form String and Numeric-typed Events are unaffected.
enableAgentDevice - Sets whether the Agent Device is output. Default is true.
agentUuid - Sets a static UUID to assign to the Agent Device. If not set, a UUID is resolved automatically.
monitorConfigurationFiles - Sets whether Configuration files are monitored. If enabled and a configuration file is changed, the Agent will restart. Default is true.
configurationFileRestartInterval - Sets the minimum time (in seconds) between Agent restarts when MonitorConfigurationFiles is enabled. Default is 2.
enableMetrics - Sets whether Agent Metrics are captured (ex. ObservationUpdateRate, AssetUpdateRate). Default is true.
serviceName - Changes the service name when installing or removing the service. This allows multiple agents to run as services on the same machine.
serviceDisplayName - Changes the display name of the service. This helps with identification when multiple agents run as services on the same machine.
serviceDescription - Changes the description of the service.
serviceAutoStart - Sets the Service Start Type. True = Auto | False = Manual. Default is true.
Logging is done using 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:
modules.http-server)processors.python-scripts)The default NLog Configuration File is shown below:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!-- the targets to write to -->
<targets>
<!--Console-->
<target name="logconsole" xsi:type="Console" />
<!--Application Log File-->
<target xsi:type="File" name="application-file" fileName="logs\application-${shortdate}.log" maxArchiveFiles="90" archiveEvery="Day"
layout="${longdate}|${event-properties:item=EventId_Id:whenEmpty=0}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}" />
<!--Agent Log File-->
<target xsi:type="File" name="agent-file" fileName="logs\agent-${shortdate}.log" maxArchiveFiles="90" archiveEvery="Day"
layout="${longdate}|${event-properties:item=EventId_Id:whenEmpty=0}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}" />
<!--Agent Validation Log File-->
<target xsi:type="File" name="agent-validation-file" fileName="logs\agent-validation-${shortdate}.log" maxArchiveFiles="90" archiveEvery="Day"
layout="${longdate}|${event-properties:item=EventId_Id:whenEmpty=0}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}" />
<!--Module Log File-->
<target xsi:type="File" name="module-file" fileName="logs\${logger}-${shortdate}.log" maxArchiveFiles="90" archiveEvery="Day"
layout="${longdate}|${event-properties:item=EventId_Id:whenEmpty=0}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}" />
<!--Processor Log File-->
<target xsi:type="File" name="processor-file" fileName="logs\${logger}-${shortdate}.log" maxArchiveFiles="90" archiveEvery="Day"
layout="${longdate}|${event-properties:item=EventId_Id:whenEmpty=0}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}" />
</targets>
<!-- rules to map from logger name to target -->
<rules>
<!--Write to Console-->
<logger name="*" minlevel="Info" writeTo="logconsole" />
<!--Application Logger-->
<logger name="application-logger" minlevel="Warning" writeTo="application-file" final="true" />
<!--Agent Logger-->
<logger name="agent-logger" minlevel="Warning" writeTo="agent-file" final="true" />
<!--Agent Validation Logger (Used to log Data Validation Errors)-->
<logger name="agent-validation" minlevel="Warning" writeTo="agent-validation-file" final="true" />
<!--Module Logger-->
<logger name="modules.*" minlevel="Warning" writeTo="module-file" final="true" />
<!--Processor Logger-->
<logger name="processors.*" minlevel="Warning" writeTo="processor-file" final="true" />
<!--Skip non-critical Microsoft logs and so log only own logs (BlackHole) -->
<logger name="Microsoft.*" maxlevel="Warning" final="true" />
<logger name="System.Net.Http.*" maxlevel="Warning" final="true" />
</rules>
</nlog>
This project can be built using a variety of options using the DotNet CLI publish command such as below:
dotnet publish -c:Release -f:net8.0 -r:win-x64 -p:PublishSingleFile=true -p:IncludeAllContentForSelfExtract=true --self-contained false
This project uses the MTConnect.NET-Applications-Agents library (available on Nuget) to create an MTConnect Agent application. More information about this library can be found Here. 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 functional MTConnect Application can be created in just a few lines of code.
This application and its source code is licensed under the MIT License and is free to use and distribute.
Content type
Image
Digest
sha256:4a810f47d…
Size
42.5 MB
Last updated
5 days ago
docker pull trakhound/mtconnect.net-agent