Skip to content

Commit

Permalink
Update SysML Import
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickRitchie committed Nov 1, 2023
1 parent 44cf3b0 commit c41cbbf
Show file tree
Hide file tree
Showing 7 changed files with 207 additions and 75 deletions.
Original file line number Diff line number Diff line change
@@ -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<JsonParameterSet> 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<JsonParameterSet>();
}
}
}


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<IParameterSet>();
foreach (var parameterSet in ParameterSets)
{
parameterSets.Add(parameterSet.ToParameterSet());
}
asset.ParameterSets = parameterSets;
}

return asset;
}
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
Original file line number Diff line number Diff line change
@@ -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<JsonParameter> Parameters { get; set; }


public JsonParameterSet() { }

public JsonParameterSet(IParameterSet parameterSet)
{
if (parameterSet != null)
{
Name = parameterSet.Name;

if (!parameterSet.Parameters.IsNullOrEmpty())
{
var jsonParameters = new List<JsonParameter>();
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<IParameter>();
foreach (var parameter in Parameters)
{
parameters.Add(parameter.ToParameter());
}
parameterSet.Parameters = parameters;
}

return parameterSet;
}
}
}

This file was deleted.

2 changes: 1 addition & 1 deletion src/MTConnect.NET-JSON/Assets/JsonAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace MTConnect.Assets.Json
{
public class JsonAsset
public abstract class JsonAsset
{
[JsonPropertyName("assetId")]
public string AssetId { get; set; }
Expand Down
11 changes: 3 additions & 8 deletions src/MTConnect.NET-JSON/Assets/JsonAssetsDocument.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
// 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;

namespace MTConnect.Assets.Json
{
public class JsonAssetsDocument
{
/// <summary>
/// Contains the Header information in an MTConnect Assets XML document
/// </summary>
[JsonPropertyName("header")]
public JsonAssetsHeader Header { get; set; }

/// <summary>
/// An XML container that consists of one or more types of Asset XML elements.
/// </summary>
[JsonPropertyName("assets")]
public List<object> Assets { get; set; }

Expand All @@ -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;
Expand Down
5 changes: 0 additions & 5 deletions src/MTConnect.NET-JSON/MTConnect.NET-JSON.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Assets\CuttingTools\JsonCuttingItemCollection - Copy.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PrivateAssets>all</PrivateAssets>
Expand Down Expand Up @@ -110,7 +106,6 @@
</ItemGroup>

<ItemGroup>
<None Include="Assets\CuttingTools\JsonCuttingItemCollection - Copy.cs" />
<None Include="README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
Expand Down

0 comments on commit c41cbbf

Please sign in to comment.