MTConnect.NET-HTTP 5.4.4

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package MTConnect.NET-HTTP --version 5.4.4
NuGet\Install-Package MTConnect.NET-HTTP -Version 5.4.4
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MTConnect.NET-HTTP" Version="5.4.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MTConnect.NET-HTTP --version 5.4.4
#r "nuget: MTConnect.NET-HTTP, 5.4.4"
#r directive can be used in F# Interactive and Polyglot Notebooks. 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=5.4.4

// Install MTConnect.NET-HTTP as a Cake Tool
#tool nuget:?package=MTConnect.NET-HTTP&version=5.4.4

MTConnect Http REST Clients

These client classes use the Http REST Api that is described in MTConnect Standard.

MTConnectHttpClient

The MTConnectHttpClient class is the primary class to use when wanting to implement the full MTConnect REST 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;

var baseUrl = "localhost:5000";

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

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

var client = new MTConnectHttpClient(baseUrl, deviceName);
client.Interval = 500;
client.Start();
Specfiy Hostname and Port
using MTConnect.Clients;

var hostname = "localhost";
var port = 5000;

var client = new MTConnectHttpClient(hostname, port);
client.Interval = 500;
client.Start();
Specfiy Hostname, Port, and Device
using MTConnect.Clients;

var hostname = "localhost";
var port = 5000;
var deviceName = "OKUMA.Lathe";

var client = new MTConnectHttpClient(hostname, port, deviceName);
client.Interval = 500;
client.Start();

Properties

  • Id - A unique Identifier used to indentify this instance of the MTConnectClient class

  • Authority - The authority portion consists of the DNS name or IP address associated with an Agent

  • Device - If present, specifies that only the Equipment Metadata for the piece of equipment represented by the name or uuid will be published

  • DocumentFormat - Gets or Sets the Document Format to use (ex. XML, JSON, etc.)

  • Interval - Gets or Sets the Interval in Milliseconds for the Sample Stream

  • Timeout - Gets or Sets the connection timeout for the request

  • Heartbeat - Gets or Sets the MTConnect Agent Heartbeat for the request

  • RetryInterval - Gets or Sets the Interval in Milliseconds that the Client will attempt to reconnect if the connection fails

  • MaximumSampleCount - Gets or Sets the Maximum Number of Samples returned per interval from the Sample Stream

  • ContentEncodings - Gets or Sets the List of Encodings (ex. gzip, br, deflate) to pass to the Accept-Encoding HTTP Header

  • ContentType - Gets or Sets the Content-type (or MIME-type) to pass to the Accept HTTP Header

  • LastInstanceId - Gets the Last Instance ID read from the MTConnect Agent

  • LastSequence - Gets the Last Sequence read from the MTConnect Agent

  • LastResponse - Gets the Unix Timestamp (in Milliseconds) since the last response from the MTConnect Agent

  • CurrentOnly - Gets or Sets whether the stream requests a Current (true) or a Sample (false)

Handle Probe Received Event

(MTConnectDevices Response Document received from a Probe Request)
var baseUrl = "localhost:5000";
var deviceName = "OKUMA-Lathe";

var client = new MTConnectHttpClient(baseUrl, deviceName);
client.OnProbeReceived += (sender, document) =>
{
    foreach (var device in document.Devices)
    {
        // Device
        Console.WriteLine(device.Id);

        // All DataItems (traverse the entire Device model)
        foreach (var dataItem in device.GetDataItems())
        {
            Console.WriteLine(dataItem.IdPath);
        }

        // All Components (traverse the entire Device model)
        foreach (var component in device.GetComponents())
        {
            Console.WriteLine(component.IdPath);
        }

        // All Compositions (traverse the entire Device model)
        foreach (var composition in device.GetCompositions())
        {
            Console.WriteLine(composition.IdPath);
        }
    }
};
client.Start();

Handle Current Received Event

(MTConnectStreams Response Document received from a Current Request)
var baseUrl = "localhost:5000";
var deviceName = "OKUMA-Lathe";

var client = new MTConnectHttpClient(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 observation in componentStream.Observations)
            {
                Console.WriteLine(observation.DataItemId);
            }
        }
    }
};
client.Start();

Handle Samples Received Event

(MTConnectStreams Response Document received from a Sample Stream)
var baseUrl = "localhost:5000";
var deviceName = "OKUMA-Lathe";

var client = new MTConnectHttpClient(baseUrl, deviceName);
client.Interval = 500;
client.OnSampleReceived += (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 observation in componentStream.Observations)
            {
                Console.WriteLine(observation.DataItemId);
            }
        }
    }
};
client.Start();

Handle Assets Received Event

(MTConnectAssets Response Document received from an Asset Request)
var baseUrl = "localhost:5000";
var deviceName = "OKUMA-Lathe";

var client = new MTConnectHttpClient(baseUrl, deviceName);
client.Interval = 500;
client.OnAssetsReceived += (sender, document) =>
{
    foreach (var asset in document.Assets)
    {
        // Print AssetId to the Console
        Console.WriteLine(asset.AssetId);
    }
};
client.Start();

MTConnectHttpProbeClient

The MTConnectHttpProbeClient class is used to send a Probe request and return an MTConnectDevices Response Document.

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

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

    // All DataItems (traverse the entire Device model)
    foreach (var dataItem in device.GetDataItems())
    {
        Console.WriteLine(dataItem.IdPath);
    }

    // All Components (traverse the entire Device model)
    foreach (var component in device.GetComponents())
    {
        Console.WriteLine(component.IdPath);
    }

    // All Compositions (traverse the entire Device model)
    foreach (var composition in device.GetCompositions())
    {
        Console.WriteLine(composition.IdPath);
    }
}

MTConnectHttpCurrentClient

The MTConnectHttpCurrentClient class is used to send a Current request and return an MTConnectStreams Response Document.

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

var client = new MTConnectHttpCurrentClient(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 (Samples, Events, and Conditions)
        foreach (var observation in componentStream.Observations)
        {
            Console.WriteLine(observation.DataItemId);
        }
    }
}

MTConnectHttpSampleClient

The MTConnectHttpSampleClient class is used to send a Sample request and return an MTConnectStreams Response Document.

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

var client = new MTConnectHttpSampleClient(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 (Samples, Events, and Conditions)
        foreach (var observation in componentStream.Observations)
        {
            Console.WriteLine(observation.DataItemId);
        }
    }
}

MTConnectHttpAssetClient

The MTConnectHttpAssetClient class is used to send an Assets request and return an MTConnectAssets Response Document.

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

var client = new MTConnectHttpAssetClient(baseUrl, deviceName, count);
var document = client.Get();
foreach (var asset in document.Assets)
{
    // Print AssetId to the Console
    Console.WriteLine(asset.AssetId);
}
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 is compatible. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 is compatible.  net462 is compatible.  net463 was computed.  net47 is compatible.  net471 is compatible.  net472 is compatible.  net48 is compatible.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (6)

Showing the top 5 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.3. Supports .NET Framework 4.6.1 up to .NET 8

MTConnect.NET-SHDR

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

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 up to .NET 7

MTConnect.NET-DeviceFinder

MTConnect.NET-DeviceFinder contains classes to find MTConnect Devices on a network. Supports MTConnect Versions up to 2.3. Supports .NET Framework 4.6.1 up to .NET 8

MTConnect.NET-AgentModule-HttpServer

MTConnect.NET-AgentModule-HttpServer implements a server for the MTConnect HTTP REST Protocol for use with the MTConnectAgentApplication class in the MTConnect.NET-Applications-Agents library. Supports MTConnect Versions up to 2.3. Supports .NET Framework 4.6.1 up to .NET 8

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
6.3.0-beta 40 4/17/2024
6.2.2-beta 34 4/5/2024
6.2.1-beta 68 4/3/2024
6.2.0-beta 93 3/27/2024
6.1.3-beta 134 3/15/2024
6.1.2-beta 115 3/15/2024
6.0.11-beta 316 2/2/2024
6.0.10-beta 264 1/26/2024
6.0.9-beta 393 12/28/2023
6.0.8-beta 359 12/27/2023
6.0.7-beta 403 12/19/2023
6.0.5-beta 459 12/14/2023
6.0.3-beta 424 12/12/2023
6.0.1-beta 460 12/7/2023
5.4.4 3,320 6/6/2023
5.4.3 2,061 5/20/2023
5.4.1 1,674 3/28/2023
5.4.0 1,800 3/20/2023
5.3.0 1,530 3/14/2023
5.2.0 1,665 3/5/2023
5.1.0 1,742 3/3/2023
5.0.0 4,084 2/3/2023
4.6.0 2,666 11/28/2022
4.5.0 2,909 10/18/2022
4.4.0 2,831 10/5/2022
4.3.0 2,958 9/20/2022
4.2.0 2,627 9/13/2022
4.1.0 2,621 8/30/2022
4.0.0 2,565 8/26/2022
3.4.2 3,010 6/20/2022
3.4.1 2,548 6/17/2022
3.4.0 2,395 6/16/2022
3.3.1 2,851 4/27/2022
3.3.0 2,452 4/13/2022
3.2.0 2,368 3/29/2022