-
-
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.
- Loading branch information
1 parent
595b061
commit 3273eb3
Showing
31 changed files
with
10,752 additions
and
374 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
9 changes: 9 additions & 0 deletions
9
build/MTConnect.NET-SysML-Import/Json-cppagent/DataItemsModel.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,9 @@ | ||
using MTConnect.SysML.Models.Devices; | ||
|
||
namespace MTConnect.SysML.Json_cppagent | ||
{ | ||
public class DataItemsModel | ||
{ | ||
public List<MTConnectDataItemType> Types { get; set; } = new(); | ||
} | ||
} |
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
97 changes: 97 additions & 0 deletions
97
build/MTConnect.NET-SysML-Import/Json-cppagent/Templates/Events.scriban
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,97 @@ | ||
// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. | ||
// TrakHound Inc. licenses this file to you under the MIT license. | ||
|
||
using MTConnect.Devices; | ||
using MTConnect.Devices.DataItems; | ||
using MTConnect.Observations; | ||
using MTConnect.Observations.Output; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace MTConnect.Streams.Json | ||
{ | ||
public class JsonEvents | ||
{ | ||
[JsonIgnore] | ||
public List<IObservation> Observations | ||
{ | ||
get | ||
{ | ||
var l = new List<IObservation>(); | ||
|
||
{{- for type in types }} | ||
if (!{{type.name}}.IsNullOrEmpty()) foreach (var x in {{type.name}}) l.Add(x.ToObservation({{type.name}}DataItem.TypeId)); | ||
if (!{{type.name}}DataSet.IsNullOrEmpty()) foreach (var x in {{type.name}}DataSet) l.Add(x.ToObservation({{type.name}}DataItem.TypeId)); | ||
if (!{{type.name}}Table.IsNullOrEmpty()) foreach (var x in {{type.name}}Table) l.Add(x.ToObservation({{type.name}}DataItem.TypeId)); | ||
{{ end }} | ||
|
||
return l; | ||
} | ||
} | ||
|
||
{{- for type in types }} | ||
[JsonPropertyName("{{type.name}}")] | ||
public IEnumerable<JsonEventValue> {{type.name}} { get; set; } | ||
|
||
[JsonPropertyName("{{type.name}}DataSet")] | ||
public IEnumerable<JsonEventDataSet> {{type.name}}DataSet { get; set; } | ||
|
||
[JsonPropertyName("{{type.name}}Table")] | ||
public IEnumerable<JsonEventTable> {{type.name}}Table { get; set; } | ||
|
||
{{ end }} | ||
|
||
public JsonEvents() { } | ||
|
||
public JsonEvents(IEnumerable<IObservationOutput> observations) | ||
{ | ||
if (observations != null) | ||
{ | ||
if (!observations.IsNullOrEmpty()) | ||
{ | ||
IEnumerable<IObservationOutput> typeObservations; | ||
|
||
{{- for type in types }} | ||
// Add {{type.name}} | ||
typeObservations = observations.Where(o => o.Type == {{type.name}}DataItem.TypeId && o.Representation == DataItemRepresentation.VALUE); | ||
if (!typeObservations.IsNullOrEmpty()) | ||
{ | ||
var jsonObservations = new List<JsonEventValue>(); | ||
foreach (var observation in typeObservations) | ||
{ | ||
jsonObservations.Add(new JsonEventValue(observation)); | ||
} | ||
{{type.name}} = jsonObservations; | ||
} | ||
|
||
// Add {{type.name}}DataSet | ||
typeObservations = observations.Where(o => o.Type == {{type.name}}DataItem.TypeId && o.Representation == DataItemRepresentation.DATA_SET); | ||
if (!typeObservations.IsNullOrEmpty()) | ||
{ | ||
var jsonObservations = new List<JsonEventDataSet>(); | ||
foreach (var observation in typeObservations) | ||
{ | ||
jsonObservations.Add(new JsonEventDataSet(observation)); | ||
} | ||
{{type.name}}DataSet = jsonObservations; | ||
} | ||
|
||
// Add {{type.name}}Table | ||
typeObservations = observations.Where(o => o.Type == {{type.name}}DataItem.TypeId && o.Representation == DataItemRepresentation.TABLE); | ||
if (!typeObservations.IsNullOrEmpty()) | ||
{ | ||
var jsonObservations = new List<JsonEventTable>(); | ||
foreach (var observation in typeObservations) | ||
{ | ||
jsonObservations.Add(new JsonEventTable(observation)); | ||
} | ||
{{type.name}}Table = jsonObservations; | ||
} | ||
|
||
{{ end }} | ||
} | ||
} | ||
} | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
build/MTConnect.NET-SysML-Import/Json-cppagent/Templates/Samples.scriban
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,81 @@ | ||
// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. | ||
// TrakHound Inc. licenses this file to you under the MIT license. | ||
|
||
using MTConnect.Devices; | ||
using MTConnect.Devices.DataItems; | ||
using MTConnect.Observations; | ||
using MTConnect.Observations.Output; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace MTConnect.Streams.Json | ||
{ | ||
public class JsonSamples | ||
{ | ||
[JsonIgnore] | ||
public List<IObservation> Observations | ||
{ | ||
get | ||
{ | ||
var l = new List<IObservation>(); | ||
|
||
{{- for type in types }} | ||
if (!{{type.name}}.IsNullOrEmpty()) foreach (var x in {{type.name}}) l.Add(x.ToObservation({{type.name}}DataItem.TypeId)); | ||
if (!{{type.name}}DataSet.IsNullOrEmpty()) foreach (var x in {{type.name}}DataSet) l.Add(x.ToObservation({{type.name}}DataItem.TypeId)); | ||
{{ end }} | ||
|
||
return l; | ||
} | ||
} | ||
|
||
{{- for type in types }} | ||
[JsonPropertyName("{{type.name}}")] | ||
public IEnumerable<JsonSampleValue> {{type.name}} { get; set; } | ||
|
||
[JsonPropertyName("{{type.name}}DataSet")] | ||
public IEnumerable<JsonSampleDataSet> {{type.name}}DataSet { get; set; } | ||
|
||
{{ end }} | ||
|
||
public JsonSamples() { } | ||
|
||
public JsonSamples(IEnumerable<IObservationOutput> observations) | ||
{ | ||
if (observations != null) | ||
{ | ||
if (!observations.IsNullOrEmpty()) | ||
{ | ||
IEnumerable<IObservationOutput> typeObservations; | ||
|
||
{{- for type in types }} | ||
// Add {{type.name}} | ||
typeObservations = observations.Where(o => o.Type == {{type.name}}DataItem.TypeId); | ||
if (!typeObservations.IsNullOrEmpty()) | ||
{ | ||
var jsonObservations = new List<JsonSampleValue>(); | ||
foreach (var observation in typeObservations) | ||
{ | ||
jsonObservations.Add(new JsonSampleValue(observation)); | ||
} | ||
{{type.name}} = jsonObservations; | ||
} | ||
|
||
// Add {{type.name}}DataSet | ||
typeObservations = observations.Where(o => o.Type == {{type.name}}DataItem.TypeId && o.Representation == DataItemRepresentation.DATA_SET); | ||
if (!typeObservations.IsNullOrEmpty()) | ||
{ | ||
var jsonObservations = new List<JsonSampleDataSet>(); | ||
foreach (var observation in typeObservations) | ||
{ | ||
jsonObservations.Add(new JsonSampleDataSet(observation)); | ||
} | ||
{{type.name}}DataSet = jsonObservations; | ||
} | ||
|
||
{{ end }} | ||
} | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.