Skip to content

Commit

Permalink
Updated MQTT input models
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickRitchie committed Dec 10, 2023
1 parent 71ff0ad commit a6795b8
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
37 changes: 37 additions & 0 deletions libraries/MTConnect.NET-MQTT/Input/MTConnectMqttInputDevices.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using MTConnect.Devices;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace MTConnect.Mqtt
{
public class MTConnectMqttInputDevices
{
[JsonPropertyName("devices")]
public Dictionary<string, string> Devices { get; set; }


public MTConnectMqttInputDevices() { }

public MTConnectMqttInputDevices(IDevice device)
{
if (device != null && !string.IsNullOrEmpty(device.Uuid))
{

}
}

public MTConnectMqttInputDevices(IEnumerable<IDevice> devices)
{
if (!devices.IsNullOrEmpty())
{
foreach (var device in devices)
{
if (device != null && !string.IsNullOrEmpty(device.Uuid))
{

}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ namespace MTConnect.Mqtt
{
public class MTConnectMqttInputObservation
{
[JsonPropertyName("dataItemKey")]
public string DataItemKey { get; set; }
[JsonPropertyName("dataItem")]
public string DataItem { get; set; }

[JsonPropertyName("values")]
public Dictionary<string, string> Values { get; set; }
Expand All @@ -16,7 +16,7 @@ public MTConnectMqttInputObservation() { }

public MTConnectMqttInputObservation(string dataItemKey, Dictionary<string, string> values)
{
DataItemKey = dataItemKey;
DataItem = dataItemKey;
Values = values;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace MTConnect.Mqtt
{
public class MTConnectMqttInputModel
public class MTConnectMqttInputObservations
{
[JsonPropertyName("timestamp")]
public DateTime Timestamp { get; set; }
Expand All @@ -34,10 +34,10 @@ private static IEnumerable<IObservationInput> ToObservationInputs(DateTime times

foreach (var mqttObservation in mqttObservations)
{
if (!string.IsNullOrEmpty(mqttObservation.DataItemKey) && !mqttObservation.Values.IsNullOrEmpty())
if (!string.IsNullOrEmpty(mqttObservation.DataItem) && !mqttObservation.Values.IsNullOrEmpty())
{
var observation = new ObservationInput();
observation.DataItemKey = mqttObservation.DataItemKey;
observation.DataItemKey = mqttObservation.DataItem;
observation.Timestamp = ts;

foreach (var value in mqttObservation.Values)
Expand Down

0 comments on commit a6795b8

Please sign in to comment.