MTConnect.NET-HTTP 3.4.2

.NET 5.0 .NET Core 3.1 .NET Standard 2.0 .NET Framework 4.6.1
Install-Package MTConnect.NET-HTTP -Version 3.4.2
dotnet add package MTConnect.NET-HTTP --version 3.4.2
<PackageReference Include="MTConnect.NET-HTTP" Version="3.4.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MTConnect.NET-HTTP --version 3.4.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MTConnect.NET-HTTP, 3.4.2"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install MTConnect.NET-HTTP as a Cake Addin
#addin nuget:?package=MTConnect.NET-HTTP&version=3.4.2

// Install MTConnect.NET-HTTP as a Cake Tool
#tool nuget:?package=MTConnect.NET-HTTP&version=3.4.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

MTConnect Http REST Clients

These client classes use the Http REST Api that is described in Part 1 : Section 5.4 & Section 8 of the MTConnect Standard.

MTConnectClient

The MTConnectClient class is the primary class to use when wanting to implement the full MTConnect protocol. This class handles an initial Probe request to gather capabilities of the Agent, a Current request to read the initial values, and a Sample request (at the specified Interval) to read successive values.

Class Initialization

Class initialization is straightforward in that specifiying the BaseUrl (the URL of the Agent) is all that is required. Then call the Start() method to start the request sequence.

No Device Name (Get All Devices)
using MTConnect.Clients.Rest;

var baseUrl = "localhost:5006";

var client = new MTConnectClient(baseUrl);
client.Interval = 500;
client.Start();
Get Specific Device by Name
using MTConnect.Clients.Rest;

var deviceName = "OKUMA.Lathe";
var baseUrl = "localhost:5000";

var client = new MTConnectClient(baseUrl, deviceName);
client.Interval = 500;
client.Start();

Handle Probe Received Event

(MTConnectDevices Response Document received from a Probe Request)
var client = new MTConnectClient(baseUrl, deviceName);
client.OnProbeReceived += (sender, document) =>
{
    foreach (var device in document.Devices)
    {
        // Device
        Console.WriteLine(device.Id);

        // DataItems
        foreach (var dataItem in device.DataItems)
        {
            Console.WriteLine(dataItem.Id);
        }

        // Components
        foreach (var component in device.Components)
        {
            Console.WriteLine(component.Id);
        }
    }
};
client.Start();

Handle Current Received Event

(MTConnectStreams Response Document received from a Current Request)
var client = new MTConnectClient(baseUrl, deviceName);
client.OnCurrentReceived += (sender, document) =>
{
    foreach (var deviceStream in document.Streams)
    {
        // DeviceStream
        Console.WriteLine(deviceStream.Name);

        // Component Streams
        foreach (var componentStream in deviceStream.ComponentStreams)
        {
            Console.WriteLine(componentStream.Name);

            // DataItems (Samples, Events, and Conditions)
            foreach (var dataItem in componentStream.DataItems)
            {
                Console.WriteLine(dataItem.DataItemId);
            }
        }
    }
};
client.Start();

Handle Samples Received Event

(MTConnectStreams Response Document received from a Sample Stream)
var client = new MTConnectClient(baseUrl, deviceName);
client.Interval = 500;
client.OnSampleReceived += (sender, document) =>
{
    foreach (var deviceStream in document.Streams)
    {
        // Device
        Console.WriteLine(deviceStream.Name);

        // Component Streams
        foreach (var componentStream in deviceStream.ComponentStreams)
        {
            Console.WriteLine(componentStream.Name);

            // DataItems
            foreach (var dataItem in componentStream.DataItems)
            {
                Console.WriteLine(dataItem.DataItemId);
            }
        }
    }
};
client.Start();

MTConnectProbeClient

The MTConnectProbeClient class is used to send a Probe request and return an MTConenctDevices Response Document.

using MTConnect.Clients.Rest;

var deviceName = "OKUMA.Lathe";
var baseUrl = "localhost:5000";

var client = new MTConnectProbeClient(baseUrl, deviceName);
var document = client.Get();
foreach (var device in document.Devices)
{
    // Device
    Console.WriteLine(device.Id);

    // DataItems
    foreach (var dataItem in device.DataItems)
    {
        Console.WriteLine(dataItem.Id);
    }

    // Components
    foreach (var component in device.Components)
    {
        Console.WriteLine(component.Id);
    }
}

MTConnectCurrentClient

The MTConnectCurrentClient class is used to send a Current request and return an MTConenctStreams Response Document.

using MTConnect.Clients.Rest;

var deviceName = "OKUMA.Lathe";
var baseUrl = "localhost:5006";

var client = new MTConnectCurrentClient(baseUrl, deviceName);
var document = client.Get();
foreach (var deviceStream in document.Streams)
{
    // Device
    Console.WriteLine(deviceStream.Name);

    // Component Streams
    foreach (var componentStream in deviceStream.ComponentStreams)
    {
        Console.WriteLine(componentStream.Name);

        // DataItems
        foreach (var dataItem in componentStream.DataItems)
        {
            Console.WriteLine(dataItem.DataItemId);
        }
    }
}

MTConnectSampleClient

The MTConnectSampleClient class is used to send a Sample request and return an MTConenctStreams Response Document.

using MTConnect.Clients.Rest;

var deviceName = "OKUMA.Lathe";
var baseUrl = "localhost:5006";
var fromSequence = 150;
var toSequence = 250;

var client = new MTConnectSampleClient(baseUrl, deviceName, fromSequence, toSequence);
var document = client.Get();
foreach (var deviceStream in document.Streams)
{
    // Device
    Console.WriteLine(deviceStream.Name);

    // Component Streams
    foreach (var componentStream in deviceStream.ComponentStreams)
    {
        Console.WriteLine(componentStream.Name);

        // DataItems
        foreach (var dataItem in componentStream.DataItems)
        {
            Console.WriteLine(dataItem.DataItemId);
        }
    }
}
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on MTConnect.NET-HTTP:

Package Downloads
MTConnect.NET

MTConnect.NET is a fully featured .NET library for MTConnect® Agents, Adapters, and Clients. Supports MTConnect Versions up to 2.0. Supports .NET Framework 4.6.1 up to .NET 6

MTConnect.NET-SHDR

MTConnect.NET-SHDR implements the SHDR Adapter Protocol for use with the MTConnect.NET library. Supports MTConnect Versions up to 2.0. Supports .NET Framework 4.6.1 up to .NET 6

MTConnect.NET-HTTP-AspNetCore

MTConnect.NET-HTTP-AspNetCore is an extension library to MTConnect.NET that uses ApiControllers and the built-in features for Asp.NET Core

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.4.2 96 6/20/2022
3.4.1 125 6/17/2022
3.4.0 70 6/16/2022
3.3.1 327 4/27/2022
3.3.0 171 4/13/2022
3.2.0 180 3/29/2022