# MTConnect.NET

> Open source .NET applications and libraries for MTConnect: an Agent that supports MTConnect 2.7 and reads Fanuc, Haas, and Tormach machines directly, an Adapter Framework, and client libraries, as installers, Docker images, and NuGet packages. MIT licensed.

URL: https://www.trakhound.com/mtconnect-net

*An Open Source MTConnect Agent, Adapter Framework, and Client Libraries for .NET*

- MTConnect Agent for Windows, Linux, and Docker
- Reads Fanuc, Haas, and Tormach CNC machines directly, with no separate adapter
- Supports MTConnect versions up to 2.7
- Serves data over HTTP and MQTT, in XML or JSON
- Adapter Framework for sending PLC data to an Agent
- NuGet libraries for .NET Framework 4.6.1 through .NET 10

[Download Agent](https://github.com/TrakHound/MTConnect.NET/releases/download/v7.0.0-prerelease/mtconnect.net-agent-7.0.0-prerelease-install.exe) [Documentation](https://www.trakhound.com/docs/mtconnect-net) [View on GitHub](https://github.com/TrakHound/MTConnect.NET)

- Windows Installer
- Linux
- Docker
- NuGet



| Name |  | Downloads | Link |
| --- | --- | --- | --- |
| Agent | Installer |  | [https://github.com/TrakHound/MTConnect.NET/releasesView](https://github.com/TrakHound/MTConnect.NET/releases) |
| Agent | Docker |  | [https://hub.docker.com/r/trakhound/mtconnect.net-agentView](https://hub.docker.com/r/trakhound/mtconnect.net-agent) |
| Libraries | NuGet |  | [https://www.nuget.org/packages/MTConnect.NETView](https://www.nuget.org/packages/MTConnect.NET) |

*Run an Agent, or Build MTConnect into Your Own Application*

## Get Started

Install the Agent to connect machines and serve their data, or use the NuGet packages to build Agents, Adapters, and Clients of your own. Everything is free and open source under the MIT License.

Install on Windows

Run the installer, then add your Devices and Modules to the Agent's configuration. The Agent runs as a Windows Service and serves data on port 5000.

[Download Agent](https://github.com/TrakHound/MTConnect.NET/releases/download/v7.0.0-prerelease/mtconnect.net-agent-7.0.0-prerelease-install.exe)

Run in Docker

Run the Agent on Linux or Windows with Docker, including ARM devices. Mount your own configuration and Devices with -v.

```
docker run -p 5000:5000 trakhound/mtconnect.net-agent
```

[Docker Hub](https://hub.docker.com/r/trakhound/mtconnect.net-agent)

Embed an Agent

Create an Agent application of your own, with your code reading the machine and the Agent in the same process.

```
dotnet new install MTConnect.NET-Agent-Template
dotnet new mtconnect.net-agent
```

[Getting Started](https://www.trakhound.com/docs/mtconnect-net/getting-started)

Read from an Agent

Add the client libraries to a .NET application to read Devices and data from any MTConnect Agent.

```
dotnet add package MTConnect.NET
```

[Client Libraries](https://www.trakhound.com/mtconnect-net#client)

*A .NET Native MTConnect Agent*

## MTConnect Agent

A complete MTConnect Agent that reads data from machines, adapters, and other Agents, and serves it to any MTConnect client. Install it on Windows, run it on Linux, or start it in Docker, then choose what it does by adding Modules to its configuration file.

- Supports MTConnect versions up to 2.7, and answers each client in the version it asks for
- Input Modules read from SHDR Adapters, MQTT brokers, other Agents, and [Fanuc, Haas, and Tormach controls](https://www.trakhound.com/mtconnect-net#machines)
- Output Modules serve Probe, Current, Sample, and Assets over HTTP, and publish to MQTT, in XML or JSON, with HTTPS and TLS
- A Web UI for browsing Devices, current values, and Assets, and for editing the configuration
- A durable buffer that keeps the Agent's data through restarts
- Python Processors that transform data as it arrives
- Validates Devices and data against the MTConnect Standard
- Devices in a single `devices.xml` file, or a folder with a file for each Device
- Restarts itself when its configuration changes
- Runs as a Windows Service or a console application, with logging through NLog

Diagram: Input Modules read data from SHDR Adapters, MQTT brokers, other Agents, and Fanuc, Haas, and Tormach controls into the Agent. The Agent keeps the data in an in-memory or durable file buffer and can transform it with Python Processors. Output Modules serve the data over HTTP and MQTT, and the Web UI shows it in a browser.

[Download Agent](https://github.com/TrakHound/MTConnect.NET/releases/download/v7.0.0-prerelease/mtconnect.net-agent-7.0.0-prerelease-install.exe) [Agent Modules](https://www.trakhound.com/docs/mtconnect-net/modules)

*Connect Fanuc, Haas, and Tormach Machines Without a Separate Adapter*

## Built-In Machine Support

The Agent includes Modules that read data directly from Fanuc, Haas, and Tormach CNC controls. Add a Module to the Agent's configuration with the machine's address, and the Agent creates the Device and starts reporting MTConnect data, with no separate adapter to install or maintain.

Fanuc

FOCAS over Ethernet

Reads Fanuc Series 0i, 16i, 18i, 21i, 30i, 31i, 32i, and 35i controls. Paths, axes, and spindles are read from the CNC when it connects, and the Device is built to match.

Data Read from the Control

- Availability
- Emergency Stop
- Mode & Execution
- Program & Line
- Part Count
- Tool Number
- Feedrate & Overrides
- Alarms
- Spindle Speed & Load
- Axis Positions & Loads
- Timers
- Work Offset

Configuration

```
modules:
  - fanuc-adapter:
      deviceKey: M1
      server: 192.168.1.70
      port: 8193
```

Requires the Fanuc FOCAS2 libraries (available from Fanuc) and FOCAS enabled on the CNC's Ethernet port.

[Setup Guide](https://www.trakhound.com/docs/mtconnect-net/modules/fanuc-adapter)

Haas

Ethernet or RS-232

Reads Haas controls, including the Next Generation Control, using Haas Machine Data Collection. Supports up to five axes, with machine and work positions.

Data Read from the Control

- Availability
- Mode & Execution
- Program
- Part Counts
- Tool Number
- Alarms
- Spindle Speed & Load
- Axis Positions
- Timers & Cycle Times
- Work Offset
- Coolant Level
- Software Version

Configuration

```
modules:
  - haas-adapter:
      deviceKey: VF2
      server: 192.168.1.60
      port: 5051
```

Enable Machine Data Collection on the control by setting Setting 143 to the TCP port to use.

[Setup Guide](https://www.trakhound.com/docs/mtconnect-net/modules/haas-adapter)

Tormach

PathPilot over Ethernet

Reads Tormach machines running PathPilot. A small status server included with the Agent runs on the controller and sends the machine's status to the Agent. It only reads status, and never sends commands to the machine.

Data Read from the Control

- Availability
- Emergency Stop
- Mode & Execution
- Program & Line
- Tool Number
- Work Offset
- Optional Stop
- Feedrate & Overrides
- Spindle Speed & Override
- Axis Positions

Configuration

```
modules:
  - tormach-adapter:
      deviceKey: PCNC1100
      server: 192.168.1.80
      port: 7890
```

Copy the PathPilot status server to the controller and start it. PathPilot doesn't report alarms or part counts.

[Setup Guide](https://www.trakhound.com/docs/mtconnect-net/modules/tormach-adapter)

*Send Data from PLCs and Other Equipment to an Agent*

## MTConnect Adapter Framework

For equipment without built-in support, write a Data Source that reads the PLC or controller, and the Adapter Framework sends its data to any MTConnect Agent. You write the code that reads the machine, and the framework does the rest.

- Data Source Modules read the equipment, and Output Modules send the data
- The SHDR Module sends data to an MTConnect Agent over TCP
- The MQTT Module publishes data to an MQTT broker for an Agent to read
- Runs as a Windows Service, and restarts when its configuration file changes
- Updated through NuGet, so new versions don't mean copying source code
- Or skip the Adapter and embed an Agent in your application with the `mtconnect.net-agent` template

Diagram: A Data Source Module reads values from a PLC or machine. The Adapter keeps changes in a Send Queue, and the SHDR and MQTT Modules send them to an MTConnect Agent.

[Write an Adapter](https://www.trakhound.com/docs/mtconnect-net/cookbook/write-an-adapter) [View on GitHub](https://github.com/TrakHound/MTConnect.NET/tree/master/adapter)

*Read MTConnect Data in Your .NET Applications*

## MTConnect Client Libraries

NuGet libraries for reading data from any MTConnect Agent, from a single Current request to a long-running stream, in applications that target .NET Framework 4.6.1 through .NET 10.

- Probe, Current, Sample, and Assets requests
- HTTP and MQTT clients, reading XML or JSON
- Streams Sample data, with compression, and reconnects when the connection drops
- HTTPS and TLS
- Typed Response Documents and entities, the same whatever the protocol or format
- IntelliSense documentation from the MTConnect Standard, generated from the MTConnect SysML model
- Converts units automatically

Diagram: A .NET application uses the Client libraries to send Probe, Current, Sample, and Assets requests to an MTConnect Agent over HTTP or MQTT, in XML or JSON. Sample requests can stream.

```
var client = new MTConnectHttpClient("localhost", 5000);
client.ObservationReceived += (s, observation) =>
{
    var value = observation.GetValue(ValueKeys.Result);
    Console.WriteLine($"{observation.DataItemId} = {value}");
};
client.Start();
```

[Getting Started](https://www.trakhound.com/docs/mtconnect-net/getting-started) [Examples](https://github.com/TrakHound/MTConnect.NET/tree/master/examples)

*Install Only What Your Application Uses*

## NuGet Packages

MTConnect.NET is split into packages by protocol and format. Install **MTConnect.NET** to get everything, or only the packages your application needs. Each one supports MTConnect versions up to 2.7.

[MTConnect.NET Everything in one package: Agents, Adapters, and Clients](https://www.nuget.org/packages/MTConnect.NET)[MTConnect.NET-Common Devices, Observations, Assets, and the Agent](https://www.nuget.org/packages/MTConnect.NET-Common)[MTConnect.NET-HTTP HTTP Client and Server](https://www.nuget.org/packages/MTConnect.NET-HTTP)[MTConnect.NET-MQTT MQTT Client, Broker, and Relay](https://www.nuget.org/packages/MTConnect.NET-MQTT)[MTConnect.NET-SHDR SHDR Adapters and Client](https://www.nuget.org/packages/MTConnect.NET-SHDR)[MTConnect.NET-XML XML Documents](https://www.nuget.org/packages/MTConnect.NET-XML)[MTConnect.NET-JSON JSON Documents](https://www.nuget.org/packages/MTConnect.NET-JSON)[MTConnect.NET-JSON-cppagent JSON Documents in the format of the MTConnect Reference Agent](https://www.nuget.org/packages/MTConnect.NET-JSON-cppagent)[MTConnect.NET-TLS HTTPS and TLS](https://www.nuget.org/packages/MTConnect.NET-TLS)[MTConnect.NET-Services Run as a Windows Service](https://www.nuget.org/packages/MTConnect.NET-Services)[MTConnect.NET-DeviceFinder Find MTConnect Agents and Devices on a network](https://www.nuget.org/packages/MTConnect.NET-DeviceFinder)[MTConnect.NET-Applications-Agents Build an Agent application](https://www.nuget.org/packages/MTConnect.NET-Applications-Agents)[MTConnect.NET-Applications-Adapter Build an Adapter application](https://www.nuget.org/packages/MTConnect.NET-Applications-Adapter)



*Support TrakHound Open Source Projects*

## Sponsor

If you have found our open source projects helpful, please consider donating to our open source efforts using GitHub.



[Sponsor](https://github.com/sponsors/TrakHound?o=esb)
