-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added MQTT Protocol support that includes Agent information, a connection heartbeat, and multiple Observation Intervals - Added QoS configuration parameter for MQTT Client and Relay Agent configurations - Started adding documentation
- Loading branch information
1 parent
0738d59
commit 0b5239f
Showing
31 changed files
with
1,196 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# MQTT Protocol for MTConnect | ||
|
||
## Overview | ||
This is a protocol for accessing MTConnect data using MQTT that mimics the functionality of the MTConnect HTTP REST protocol. | ||
The main difference between the HTTP and MQTT protocols is that the MQTT protocol deals with the individual MTConnect entities directly (ex. Device, Observation, Asset). | ||
|
||
#### All Devices | ||
![All_Devices](../img/mtconnect-mqtt-protocol-all-01.png) | ||
|
||
|
||
#### By Device | ||
![All_Devices](../img/mtconnect-mqtt-protocol-by-device-01.png) | ||
|
||
|
||
### Multiple Configurable Observation Intervals | ||
This protocol enables multiple intervals that Observations can be received. | ||
This interval essentially implements a window that a maximum of one Observation per DataItem will be published. | ||
This can be used by client applications such as Dashboards. An interval of "0" will indicate that all observation changes are published. | ||
|
||
#### Observation Topics | ||
The interval (in milliseconds) is specified in the brackets suffix for an Observations topic following the pattern below: | ||
|
||
##### Observation Interval 1000ms | ||
``` | ||
MTConnect/Devices/ff8fc5c5-206f-4d94-96a8-a03c70b682b8/Observations[1000]/# | ||
``` | ||
|
||
##### Observation Interval 100ms | ||
``` | ||
MTConnect/Devices/ff8fc5c5-206f-4d94-96a8-a03c70b682b8/Observations[100]/# | ||
``` | ||
|
||
##### Observation Interval 0 ("Realtime") | ||
``` | ||
MTConnect/Devices/ff8fc5c5-206f-4d94-96a8-a03c70b682b8/Observations/# | ||
``` | ||
|
||
|
||
### Agent Connection Heartbeat | ||
A connection heartbeat that represents the connection between the MTConnect Agent and the MQTT Broker can be read from the topic below: | ||
``` | ||
MTConnect/Agents/[AGENT_UUID]/HeartbeatTimestamp | ||
``` | ||
|
||
The payload is a simple 64 bit Integer representing the last timestamp (in Unix milliseconds) that the Agent sent a heartbeat. | ||
|
||
Using this timestamp in combination with the HeartbeatInterval property found in the **MTConnect/Agents/[AGENT_UUID]/Information** topic, | ||
the connection status of the MTConnect Agent can be determined. | ||
Typically waiting for 3 failed heartbeats allows for temporary connection interruptions and follows a similar pattern of other MTConnect related heartbeat protocols. | ||
|
||
|
||
### Entity level Agent InstanceId support | ||
Each MTConnect entity contains an InstanceId property which can be compared to the **InstanceId** property found in the **MTConnect/Agents/[AGENT_UUID]/Information**. | ||
If the entity's InstanceId property differs, then it can be assumed that the Agent was restarted, reconfigured, etc. and the protocol should be restarted. | ||
This is similar to the MTConnect HTTP protocol. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
using System.Reflection; | ||
|
||
[assembly: AssemblyVersion("5.3.0")] | ||
[assembly: AssemblyFileVersion("5.3.0")] | ||
[assembly: AssemblyVersion("5.4.0")] | ||
[assembly: AssemblyFileVersion("5.4.0")] | ||
[assembly: AssemblyCompany("TrakHound Inc.")] | ||
[assembly: AssemblyCopyright("Copyright (c) 2023 TrakHound Inc., All Rights Reserved.")] |
26 changes: 25 additions & 1 deletion
26
...Connect.NET-Applications-Agents-MQTT/Configurations/IMqttAgentApplicationConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,36 @@ | ||
// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. | ||
// TrakHound Inc. licenses this file to you under the MIT license. | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace MTConnect.Configurations | ||
{ | ||
public interface IMqttAgentApplicationConfiguration : IAgentApplicationConfiguration, IMTConnectMqttClientConfiguration | ||
public interface IMqttAgentApplicationConfiguration : IAgentApplicationConfiguration | ||
{ | ||
string Server { get; set; } | ||
|
||
int Port { get; set; } | ||
|
||
string Username { get; set; } | ||
|
||
string Password { get; set; } | ||
|
||
string CertificateAuthority { get; set; } | ||
|
||
string PemCertificate { get; set; } | ||
|
||
string PemPrivateKey { get; set; } | ||
|
||
bool UseTls { get; set; } | ||
|
||
bool AllowUntrustedCertificates { get; set; } | ||
|
||
string TopicPrefix { get; set; } | ||
|
||
bool RetainMessages { get; set; } | ||
|
||
MTConnectMqttFormat MqttFormat { get; set; } | ||
|
||
IEnumerable<int> ObservationIntervals { get; set; } | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...ct.NET-Applications-Agents-MQTT/Configurations/IMqttRelayAgentApplicationConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. | ||
// TrakHound Inc. licenses this file to you under the MIT license. | ||
|
||
namespace MTConnect.Configurations | ||
{ | ||
public interface IMqttRelayAgentApplicationConfiguration : IMqttAgentApplicationConfiguration | ||
{ | ||
string ClientId { get; set; } | ||
|
||
int QoS { get; set; } | ||
|
||
int RetryInterval { get; set; } | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...ET-Applications-Agents-MQTT/Configurations/IShdrMqttRelayAgentApplicationConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. | ||
// TrakHound Inc. licenses this file to you under the MIT license. | ||
|
||
namespace MTConnect.Configurations | ||
{ | ||
/// <summary> | ||
/// Configuration for an MTConnect SHDR > MQTT Agent | ||
/// </summary> | ||
public interface IShdrMqttRelayAgentApplicationConfiguration : IShdrAgentApplicationConfiguration, IMqttRelayAgentApplicationConfiguration | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...ect.NET-Applications-Agents-MQTT/Configurations/MqttRelayAgentApplicationConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. | ||
// TrakHound Inc. licenses this file to you under the MIT license. | ||
|
||
using System.Text.Json.Serialization; | ||
|
||
namespace MTConnect.Configurations | ||
{ | ||
public class MqttRelayAgentApplicationConfiguration : MqttAgentApplicationConfiguration, IMqttRelayAgentApplicationConfiguration | ||
{ | ||
[JsonPropertyName("clientId")] | ||
public string ClientId { get; set; } | ||
|
||
[JsonPropertyName("qos")] | ||
public int QoS { get; set; } | ||
|
||
[JsonPropertyName("retryInterval")] | ||
public int RetryInterval { get; set; } | ||
|
||
|
||
public MqttRelayAgentApplicationConfiguration() | ||
{ | ||
Server = "localhost"; | ||
Port = 1883; | ||
QoS = 1; | ||
RetryInterval = 5000; | ||
RetainMessages = true; | ||
MqttFormat = MTConnectMqttFormat.Hierarchy; | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...-Applications-Agents-MQTT/Configurations/MqttRelayAgentGatewayApplicationConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. | ||
// TrakHound Inc. licenses this file to you under the MIT license. | ||
|
||
using System.Collections.Generic; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace MTConnect.Configurations | ||
{ | ||
/// <summary> | ||
/// Configuration for an MTConnect Mqtt Gateway Agent Application | ||
/// </summary> | ||
public class MqttRelayAgentGatewayApplicationConfiguration : MqttRelayAgentApplicationConfiguration | ||
{ | ||
/// <summary> | ||
/// List of MTConnect Http Clients to read from | ||
/// </summary> | ||
[JsonPropertyName("clients")] | ||
public List<HttpClientConfiguration> Clients { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.