Skip to content

Getting started

Trais McAllister edited this page Jan 18, 2023 · 5 revisions

Understanding Adapter structures

There are two components to using Mtconnect.Adapter:

  1. Consuming a source of data (see Mtconnect.AdapterInterface)
  2. Publishing the data to clients (MTConnect Agent(s)) (see Mtconnect.TcpAdapter)
sequenceDiagram
  participant IAdapterSource
  participant IAdapterDataModel
  participant Adapter
  participant Client
  loop poll
    IAdapterSource->>IAdapterSource: data source
    IAdapterSource-->>IAdapterDataModel: deserialize
    IAdapterDataModel-->>IAdapterSource: entity
    IAdapterSource--)Adapter: OnDataReceieved(IAdapterDataModel, DataReceivedEventArgs)
  end
  loop heartbeat
    Adapter->>Client: Publish
  end
Loading

Consuming data

There are generics within Mtconnect.Adapter that can be utilized to manage basic data sources. Implementing the IAdapterSource interface provides the easiest transmission of source data.

However, you can manage your own data items and gain additional control over how your data is published.

Publishing data

The Mtconnect.Adapter library understands that there are many protocols for publishing data across networks. Currently, TCP is the prevailing and recommended form of publishing data from an Adapter to a MTConnect Agent. For this, we've created the Mtconnect.TcpAdapter package. However, if you wanted to publish via gRPC, you could do that after implementing the Adapter class.

Okay, what do I need to start?

At a minimum, you will need to reference the Mtconnect.AdapterInterface package. Additionally, you may reference a publish protocol package like the Mtconnect.TcpAdapter.

Installing from NuGET

The core package is Mtconnect.AdapterInterface. The supported platforms are .NET/.NET Core, .NET Framework 4.6+.

$ dotnet add package Mtconnect.AdapterInterface

If you are not implementing your own publishing protocol, then you will need to reference a library that will publish the data through the Adapter class.

For example, if you want to publish through TCP connections, you can add the Mtconnect.TcpAdapter package:

$ dotnet add package Mtconnect.TcpAdapter

Setup

There are two methods for setting up an Adapter:

  • Manual: You manually add each DataItem and manage the values by keys in the Adapter. See the example
  • Data Model: You implement a data model and allow a service to update the entity. See the example