From c41cbbfdfb46ab3579f22dec26a6c47107c62ea2 Mon Sep 17 00:00:00 2001 From: Patrick Ritchie Date: Tue, 31 Oct 2023 22:59:25 -0400 Subject: [PATCH] Update SysML Import --- ...onComponentConfigurationParametersAsset.cs | 82 +++++++++++++++++++ .../JsonParameter.cs | 63 ++++++++++++++ .../JsonParameterSet.cs | 58 +++++++++++++ .../JsonCuttingItemCollection - Copy.cs | 61 -------------- src/MTConnect.NET-JSON/Assets/JsonAsset.cs | 2 +- .../Assets/JsonAssetsDocument.cs | 11 +-- .../MTConnect.NET-JSON.csproj | 5 -- 7 files changed, 207 insertions(+), 75 deletions(-) create mode 100644 src/MTConnect.NET-JSON/Assets/ComponentConfigurationParameters/JsonComponentConfigurationParametersAsset.cs create mode 100644 src/MTConnect.NET-JSON/Assets/ComponentConfigurationParameters/JsonParameter.cs create mode 100644 src/MTConnect.NET-JSON/Assets/ComponentConfigurationParameters/JsonParameterSet.cs delete mode 100644 src/MTConnect.NET-JSON/Assets/CuttingTools/JsonCuttingItemCollection - Copy.cs diff --git a/src/MTConnect.NET-JSON/Assets/ComponentConfigurationParameters/JsonComponentConfigurationParametersAsset.cs b/src/MTConnect.NET-JSON/Assets/ComponentConfigurationParameters/JsonComponentConfigurationParametersAsset.cs new file mode 100644 index 00000000..10d3122a --- /dev/null +++ b/src/MTConnect.NET-JSON/Assets/ComponentConfigurationParameters/JsonComponentConfigurationParametersAsset.cs @@ -0,0 +1,82 @@ +// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. +// TrakHound Inc. licenses this file to you under the MIT license. + +using MTConnect.Assets.ComponentConfigurationParameters; +using System; +using System.Collections.Generic; +using System.Text.Json.Serialization; + +namespace MTConnect.Assets.Json.ComponentConfigurationParameters +{ + public class JsonComponentConfigurationParametersAsset + { + [JsonPropertyName("assetId")] + public string AssetId { get; set; } + + [JsonPropertyName("type")] + public string Type { get; set; } + + [JsonPropertyName("timestamp")] + public DateTime Timestamp { get; set; } + + [JsonPropertyName("deviceUuid")] + public string DeviceUuid { get; set; } + + [JsonPropertyName("removed")] + public bool Removed { get; set; } + + [JsonPropertyName("description")] + public string Description { get; set; } + + [JsonPropertyName("parameterSets")] + public IEnumerable ParameterSets { get; set; } + + + public JsonComponentConfigurationParametersAsset() { } + + public JsonComponentConfigurationParametersAsset(IComponentConfigurationParametersAsset asset) + { + if (asset != null) + { + AssetId = asset.AssetId; + Type = asset.Type; + Timestamp = asset.Timestamp; + DeviceUuid = asset.DeviceUuid; + Removed = asset.Removed; + + //if (asset.Description != null) Description = new JsonDescription(asset.Description); + + if (!asset.ParameterSets.IsNullOrEmpty()) + { + var jsonParameterSets = new List(); + } + } + } + + + public IComponentConfigurationParametersAsset ToComponentConfigurationParametersAsset() + { + var asset = new ComponentConfigurationParametersAsset(); + + asset.AssetId = AssetId; + asset.Type = Type; + asset.Timestamp = Timestamp; + asset.DeviceUuid = DeviceUuid; + asset.Removed = Removed; + + //if (Description != null) asset.Description = Description.ToDescription(); + + if (!ParameterSets.IsNullOrEmpty()) + { + var parameterSets = new List(); + foreach (var parameterSet in ParameterSets) + { + parameterSets.Add(parameterSet.ToParameterSet()); + } + asset.ParameterSets = parameterSets; + } + + return asset; + } + } +} \ No newline at end of file diff --git a/src/MTConnect.NET-JSON/Assets/ComponentConfigurationParameters/JsonParameter.cs b/src/MTConnect.NET-JSON/Assets/ComponentConfigurationParameters/JsonParameter.cs new file mode 100644 index 00000000..9e046a05 --- /dev/null +++ b/src/MTConnect.NET-JSON/Assets/ComponentConfigurationParameters/JsonParameter.cs @@ -0,0 +1,63 @@ +// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. +// TrakHound Inc. licenses this file to you under the MIT license. + +using MTConnect.Assets.ComponentConfigurationParameters; +using System.Text.Json.Serialization; + +namespace MTConnect.Assets.Json.ComponentConfigurationParameters +{ + public class JsonParameter + { + [JsonPropertyName("identifier")] + public string Identifier { get; set; } + + [JsonPropertyName("name")] + public string Name { get; set; } + + [JsonPropertyName("maximum")] + public double? Maximum { get; set; } + + [JsonPropertyName("minimum")] + public double? Minimum { get; set; } + + [JsonPropertyName("nominal")] + public double? Nominal { get; set; } + + [JsonPropertyName("units")] + public string Units { get; set; } + + [JsonPropertyName("value")] + public string Value { get; set; } + + + public JsonParameter() { } + + public JsonParameter(IParameter parameter) + { + if (parameter != null) + { + Identifier = parameter.Identifier; + Name = parameter.Name; + Maximum = parameter.Maximum; + Minimum = parameter.Minimum; + Nominal = parameter.Nominal; + Units = parameter.Units; + Value = parameter.Value; + } + } + + + public IParameter ToParameter() + { + var parameter = new Parameter(); + parameter.Identifier = Identifier; + parameter.Name = Name; + parameter.Maximum = Maximum; + parameter.Minimum = Minimum; + parameter.Nominal = Nominal; + parameter.Units = Units; + parameter.Value = Value; + return parameter; + } + } +} \ No newline at end of file diff --git a/src/MTConnect.NET-JSON/Assets/ComponentConfigurationParameters/JsonParameterSet.cs b/src/MTConnect.NET-JSON/Assets/ComponentConfigurationParameters/JsonParameterSet.cs new file mode 100644 index 00000000..1f694e72 --- /dev/null +++ b/src/MTConnect.NET-JSON/Assets/ComponentConfigurationParameters/JsonParameterSet.cs @@ -0,0 +1,58 @@ +// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. +// TrakHound Inc. licenses this file to you under the MIT license. + +using MTConnect.Assets.ComponentConfigurationParameters; +using System.Collections.Generic; +using System.Text.Json.Serialization; + +namespace MTConnect.Assets.Json.ComponentConfigurationParameters +{ + public class JsonParameterSet + { + [JsonPropertyName("name")] + public string Name { get; set; } + + [JsonPropertyName("parameters")] + public IEnumerable Parameters { get; set; } + + + public JsonParameterSet() { } + + public JsonParameterSet(IParameterSet parameterSet) + { + if (parameterSet != null) + { + Name = parameterSet.Name; + + if (!parameterSet.Parameters.IsNullOrEmpty()) + { + var jsonParameters = new List(); + foreach (var parameter in parameterSet.Parameters) + { + jsonParameters.Add(new JsonParameter(parameter)); + } + Parameters = jsonParameters; + } + } + } + + + public IParameterSet ToParameterSet() + { + var parameterSet = new ParameterSet(); + parameterSet.Name = Name; + + if (!Parameters.IsNullOrEmpty()) + { + var parameters = new List(); + foreach (var parameter in Parameters) + { + parameters.Add(parameter.ToParameter()); + } + parameterSet.Parameters = parameters; + } + + return parameterSet; + } + } +} \ No newline at end of file diff --git a/src/MTConnect.NET-JSON/Assets/CuttingTools/JsonCuttingItemCollection - Copy.cs b/src/MTConnect.NET-JSON/Assets/CuttingTools/JsonCuttingItemCollection - Copy.cs deleted file mode 100644 index 777d4f42..00000000 --- a/src/MTConnect.NET-JSON/Assets/CuttingTools/JsonCuttingItemCollection - Copy.cs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. -// TrakHound Inc. licenses this file to you under the MIT license. - -using MTConnect.Assets.CuttingTools; -using System.Collections.Generic; -using System.Text.Json.Serialization; - -namespace MTConnect.Assets.Json.CuttingTools -{ - public class JsonCuttingItemCollection - { - [JsonPropertyName("count")] - public int Count { get; set; } - - - [JsonPropertyName("cuttingItem")] - public IEnumerable CuttingItems { get; set; } - - - public JsonCuttingItemCollection() { } - - public JsonCuttingItemCollection(CuttingItemCollection cuttingItemCollection) - { - if (cuttingItemCollection != null) - { - Count = cuttingItemCollection.Count; - - // CuttingItems - if (!cuttingItemCollection.CuttingItems.IsNullOrEmpty()) - { - var cuttingItems = new List(); - foreach (var cuttingItem in cuttingItemCollection.CuttingItems) - { - cuttingItems.Add(new JsonCuttingItem(cuttingItem)); - } - CuttingItems = cuttingItems; - } - } - } - - - public CuttingItemCollection ToCuttingItemCollection() - { - var cuttingItemCollection = new CuttingItemCollection(); - cuttingItemCollection.Count = Count; - - // CuttingItems - if (!CuttingItems.IsNullOrEmpty()) - { - var cuttingItems = new List(); - foreach (var cuttingItem in CuttingItems) - { - cuttingItems.Add(cuttingItem.ToCuttingItem()); - } - cuttingItemCollection.CuttingItems = cuttingItems; - } - - return cuttingItemCollection; - } - } -} \ No newline at end of file diff --git a/src/MTConnect.NET-JSON/Assets/JsonAsset.cs b/src/MTConnect.NET-JSON/Assets/JsonAsset.cs index ada92d28..886b5668 100644 --- a/src/MTConnect.NET-JSON/Assets/JsonAsset.cs +++ b/src/MTConnect.NET-JSON/Assets/JsonAsset.cs @@ -6,7 +6,7 @@ namespace MTConnect.Assets.Json { - public class JsonAsset + public abstract class JsonAsset { [JsonPropertyName("assetId")] public string AssetId { get; set; } diff --git a/src/MTConnect.NET-JSON/Assets/JsonAssetsDocument.cs b/src/MTConnect.NET-JSON/Assets/JsonAssetsDocument.cs index 0362b6bf..02a5a167 100644 --- a/src/MTConnect.NET-JSON/Assets/JsonAssetsDocument.cs +++ b/src/MTConnect.NET-JSON/Assets/JsonAssetsDocument.cs @@ -1,16 +1,16 @@ // Copyright (c) 2023 TrakHound Inc., All Rights Reserved. // TrakHound Inc. licenses this file to you under the MIT license. +using MTConnect.Assets.ComponentConfigurationParameters; using MTConnect.Assets.CuttingTools; using MTConnect.Assets.Files; +using MTConnect.Assets.Json.ComponentConfigurationParameters; using MTConnect.Assets.Json.CuttingTools; using MTConnect.Assets.Json.Files; using MTConnect.Assets.Json.QIF; using MTConnect.Assets.Json.RawMaterials; using MTConnect.Assets.QIF; using MTConnect.Assets.RawMaterials; -using MTConnect.Headers; -using MTConnect.Streams.Json; using System.Collections.Generic; using System.Text.Json.Serialization; @@ -18,15 +18,9 @@ namespace MTConnect.Assets.Json { public class JsonAssetsDocument { - /// - /// Contains the Header information in an MTConnect Assets XML document - /// [JsonPropertyName("header")] public JsonAssetsHeader Header { get; set; } - /// - /// An XML container that consists of one or more types of Asset XML elements. - /// [JsonPropertyName("assets")] public List Assets { get; set; } @@ -47,6 +41,7 @@ public JsonAssetsDocument(IAssetsResponseDocument assetsDocument) switch (asset.Type) { + case "ComponentConfigurationParameters": jsonAsset = new JsonComponentConfigurationParametersAsset(asset as ComponentConfigurationParametersAsset); break; case "CuttingTool": jsonAsset = new JsonCuttingToolAsset(asset as CuttingToolAsset); break; case "File": jsonAsset = new JsonFileAsset(asset as FileAsset); break; case "QIFDocumentWrapper": jsonAsset = new JsonQIFDocumentWrapperAsset(asset as QIFDocumentWrapperAsset); break; diff --git a/src/MTConnect.NET-JSON/MTConnect.NET-JSON.csproj b/src/MTConnect.NET-JSON/MTConnect.NET-JSON.csproj index c5f1d3f5..2fa6e711 100644 --- a/src/MTConnect.NET-JSON/MTConnect.NET-JSON.csproj +++ b/src/MTConnect.NET-JSON/MTConnect.NET-JSON.csproj @@ -53,10 +53,6 @@ true - - - - all @@ -110,7 +106,6 @@ - True \