MTConnect.NET-SHDR 3.4.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package MTConnect.NET-SHDR --version 3.4.2
NuGet\Install-Package MTConnect.NET-SHDR -Version 3.4.2
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-SHDR" 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-SHDR --version 3.4.2
#r "nuget: MTConnect.NET-SHDR, 3.4.2"
#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-SHDR as a Cake Addin
#addin nuget:?package=MTConnect.NET-SHDR&version=3.4.2

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

SHDR Adapters

Adapter classes to handle the SHDR Agent Adapter Protocol associated with the MTConnect Standard.

Overview

The ShdrAdapter class handles the TCP connection to the Agent. SHDR conversion is handled in each individual class:

  • ShdrDataItem : Handles converting Events and/or Samples with a Representation of VALUE to the appropriate SHDR format.
  • ShdrCondition : Handles converting Conditions to the appropriate SHDR format
  • ShdrTimeSeries : Handles converting Samples with a Representation of TIME_SERIES to the appropriate SHDR format
  • ShdrDataSet : Handles converting Events and/or Samples with a Representation of DATA_SET to the appropriate SHDR format
  • ShdrTable : Handles converting Events and/or Samples with a Representation of TABLE to the appropriate SHDR format

The ShdrAdapterClient class handles the TCP connection to read from the Adapter and add data to an IMTConnectAgent class.

Usage

There are several different ways to setup and add data to the ShdrAdapter

Initialization

using MTConnect.Adapters.Shdr;

string deviceName = "OKUMA.Lathe";
ShdrAdpater adapter = new ShdrAdapter(deviceName);
adapter.Start();

Add DataItems Individually

// DataItemId and CDATA
adapter.AddDataItem(new ShdrDataItem("L2estop", "ARMED"));

// DataItemId, CDATA, and Timestamp
adapter.AddDataItem(new ShdrDataItem("L2estop", "ARMED", DateTime.UtcNow));

If no timestamp is given then the timestamp will be set when the DataItem is sent to the Agent. To insure that all dataitems have the same timestamp, it can be set explicitly.

Add List of DataItems

var dataItems = new List<ShdrDataItem>();

dataItems.Add(new ShdrDataItem("L2p1execution", "READY"));
dataItems.Add(new ShdrDataItem("L2p1Fovr", 100));
dataItems.Add(new ShdrDataItem("L2p1partcount", 15));
dataItems.Add(new ShdrDataItem("L2p1Fact", 250));

adapter.AddDataItems(dataItems);

Store DataItems in Variables

ShdrDataItem executionDataItem = new ShdrDataItem("L2p1execution");
ShdrDataItem feedrateOverrideDataItem = new ShdrDataItem("L2p1Fovr");
ShdrDataItem partCountDataItem = new ShdrDataItem("L2p1partcount");
ShdrDataItem feedrateActualDataItem = new ShdrDataItem("L2p1Fact");

executionDataItem.Value = "READY";
feedrateOverrideDataItem.Value = 100;
partCountDataItem.Value = 15;
feedrateActualDataItem.Value = 250;

adapter.AddDataItem(executionDataItem);
adapter.AddDataItem(feedrateOverrideDataItem);
adapter.AddDataItem(partCountDataItem);
adapter.AddDataItem(feedrateActualDataItem);

Use Models

The DeviceModel class can be used to add data to an ShdrAdapter by setting the properties of the DeviceModel and adding those Observations to the Adapter as shown below:

using MTConnect.Models;
using MTConnect.Observations.Events.Values;

DeviceModel deviceModel = new DeviceModel("OKUMA.Lathe");
deviceModel.Controller.EmergencyStop = EmergencyStop.ARMED;

adapter.AddDataItems(deviceModel.GetObservations());

Conditions

ShdrCondition condition = new ShdrCondition("L2p1system", ConditionLevel.FAULT);
condition.NativeCode = "404";
condition.NativeSeverity = "100";
condition.Qualifier = "LOW";
condition.Message = "Testing from new adapter";

adapter.AddCondition(condition);

TimeSeries

List<double> samples = new List<double>();
samples.Add(12);
samples.Add(15);
samples.Add(14);
samples.Add(18);
samples.Add(25);
samples.Add(30);

ShdrTimeSeries timeSeries = new ShdrTimeSeries("L2p1Sensor", samples, 100);

adapter.AddTimeSeries(timeSeries);

DataSets

List<DataSetEntry> dataSetEntries = new List<DataSetEntry>();
dataSetEntries.Add(new DataSetEntry("V1", 5));
dataSetEntries.Add(new DataSetEntry("V2", 205));

ShdrDataSet dataSet = new ShdrDataSet("L2p1Variables", dataSetEntries);

adapter.AddDataSet(dataSet);

Tables

List<TableEntry> tableEntries = new List<TableEntry>();

// Tool 1
List<TableCell> t1Cells = new List<TableCell>();
t1Cells.Add(new TableCell("LENGTH", 7.123));
t1Cells.Add(new TableCell("DIAMETER", 0.494));
t1Cells.Add(new TableCell("TOOL_LIFE", 0.35));
tableEntries.Add(new TableEntry("T1", t1Cells));

// Tool 2
List<TableCell> t2Cells = new List<TableCell>();
t2Cells.Add(new TableCell("LENGTH", 10.456));
t2Cells.Add(new TableCell("DIAMETER", 0.125));
t2Cells.Add(new TableCell("TOOL_LIFE", 1));
tableEntries.Add(new TableEntry("T2", t2Cells));

// Tool 3
List<TableCell> t3Cells = new List<TableCell>();
t3Cells.Add(new TableCell("LENGTH", 6.251));
t3Cells.Add(new TableCell("DIAMETER", 1.249));
t3Cells.Add(new TableCell("TOOL_LIFE", 0.93));
tableEntries.Add(new TableEntry("T3", t3Cells));

ShdrTable table = new ShdrTable("L2p1ToolTable", tableEntries);

adapter.AddTable(table);

SHDR Conversion

Conversion to and from an SHDR message is done through methods in the ShdrDataItem, ShdrCondition, ShdrTimeSeries, ShdrDataSet, and ShdrTable classes. Each class overrides the base "ToString()" method and also contains a "FromString()" method. The "ToString()" method creates an SHDR compatible string from the object and the "FromString()" creates an object from an SHDR string.

ShdrDataItem.ToString()

ShdrDataItem availableDataItem = new ShdrDataItem("L2avail", Availability.AVAILABLE, DateTime.UtcNow);
Console.WriteLine(availableDataItem);

2022-02-01T13:53:03.6940000Z|L2avail|AVAILABLE

ShdrCondition.ToString()

ShdrCondition condition = new ShdrCondition("L2p1system", ConditionLevel.FAULT, DateTime.UtcNow);
condition.NativeCode = "404";
condition.NativeSeverity = "100";
condition.Qualifier = "LOW";
condition.Message = "Testing from new adapter";
Console.WriteLine(condition);

2022-02-01T13:55:11.8460000Z|L2p1system|FAULT|404|100|LOW|Testing from new adapter

ShdrTimeSeries.ToString()

List<double> samples = new List<double>();
samples.Add(12);
samples.Add(15);
samples.Add(14);
samples.Add(18);
samples.Add(25);
samples.Add(30);

ShdrTimeSeries timeSeries = new ShdrTimeSeries("L2p1Sensor", samples, 100, DateTime.UtcNow);
Console.WriteLine(timeSeries);

2022-02-01T13:56:58.7700000Z|L2p1Sensor|6|100|12 15 14 18 25 30

ShdrDataSet.ToString()

List<DataSetEntry> dataSetEntries = new List<DataSetEntry>();
dataSetEntries.Add(new DataSetEntry("V1", 5));
dataSetEntries.Add(new DataSetEntry("V2", 205));

ShdrDataSet dataSet = new ShdrDataSet("L2p1Variables", dataSetEntries, DateTime.UtcNow);
Console.WriteLine(dataSet);

2022-02-01T13:58:31.8150000Z|L2p1Variables|V1=5 V2=205

ShdrTable.ToString()

List<TableEntry> tableEntries = new List<TableEntry>();

// Tool 1
List<TableCell> t1Cells = new List<TableCell>();
t1Cells.Add(new TableCell("LENGTH", 7.123));
t1Cells.Add(new TableCell("DIAMETER", 0.494));
t1Cells.Add(new TableCell("TOOL_LIFE", 0.35));
tableEntries.Add(new TableEntry("T1", t1Cells));

// Tool 2
List<TableCell> t2Cells = new List<TableCell>();
t2Cells.Add(new TableCell("LENGTH", 10.456));
t2Cells.Add(new TableCell("DIAMETER", 0.125));
t2Cells.Add(new TableCell("TOOL_LIFE", 1));
tableEntries.Add(new TableEntry("T2", t2Cells));

// Tool 3
List<TableCell> t3Cells = new List<TableCell>();
t3Cells.Add(new TableCell("LENGTH", 6.251));
t3Cells.Add(new TableCell("DIAMETER", 1.249));
t3Cells.Add(new TableCell("TOOL_LIFE", 0.93));
tableEntries.Add(new TableEntry("T3", t3Cells));

ShdrTable table = new ShdrTable("L2p1ToolTable", tableEntries, DateTime.UtcNow);
Console.WriteLine(table);

2022-02-01T13:59:47.5980000Z|L2p1ToolTable|T1={LENGTH=7.123 DIAMETER=0.494 TOOL_LIFE=0.35} T2={LENGTH=10.456 DIAMETER=0.125 TOOL_LIFE=1} T3={LENGTH=6.251 DIAMETER=1.249 TOOL_LIFE=0.93}

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 was computed.  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-SHDR:

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-Applications-Adapters-SHDR

MTConnect.NET-Applications-Adapters-SHDR contains classes to fully implement an MTConnect SHDR Adapter application. Supports MTConnect Versions up to 2.1. Supports .NET Framework 4.6.1 up to .NET 7

MTConnect.NET-Applications-Agents-MQTT

MTConnect.NET-Applications-Agents-MQTT contains classes to implement the MQTT Protocol in an MTConnect Agent application. Supports MTConnect Versions up to 2.1. Supports .NET Framework 4.6.1 up to .NET 7

MTConnect.NET-AgentModule-ShdrAdapter

MTConnect.NET-AgentModule-ShdrAdapter implements the SHDR protocol for use with the MTConnectAgentApplication class in the MTConnect.NET-Applications-Agents library. Supports MTConnect Versions up to 2.2. 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 80 4/17/2024
6.2.2-beta 94 4/5/2024
6.2.1-beta 105 4/3/2024
6.2.0-beta 102 3/27/2024
6.1.3-beta 136 3/15/2024
6.1.2-beta 117 3/15/2024
6.0.11-beta 302 2/2/2024
6.0.10-beta 277 1/26/2024
6.0.9-beta 370 12/28/2023
6.0.8-beta 341 12/27/2023
6.0.7-beta 381 12/19/2023
6.0.5-beta 414 12/14/2023
6.0.3-beta 388 12/12/2023
6.0.1-beta 445 12/7/2023
5.4.4 3,372 6/6/2023
5.4.3 1,993 5/20/2023
5.4.1 1,583 3/28/2023
5.4.0 1,673 3/20/2023
5.3.0 1,402 3/14/2023
5.2.0 1,511 3/5/2023
5.1.0 1,566 3/3/2023
5.0.0 3,120 2/3/2023
4.6.0 1,453 11/28/2022
4.5.0 1,598 10/18/2022
4.4.0 1,528 10/5/2022
4.3.0 1,552 9/20/2022
4.2.0 1,455 9/13/2022
4.1.0 1,452 8/30/2022
4.0.0 1,437 8/26/2022
3.4.2 1,822 6/20/2022
3.4.1 1,380 6/17/2022
3.4.0 1,219 6/16/2022
3.3.1 1,656 4/27/2022
3.3.0 1,255 4/13/2022
3.2.0 1,358 3/29/2022