Skip to content

Commit

Permalink
Update SysML Import
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickRitchie committed Oct 30, 2023
1 parent 80c8380 commit 6fdc255
Show file tree
Hide file tree
Showing 18 changed files with 176 additions and 104 deletions.

This file was deleted.

16 changes: 16 additions & 0 deletions src/MTConnect.NET-Common/Assets/Files/AbstractFileAsset.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.

namespace MTConnect.Assets.Files
{
public partial class AbstractFileAsset
{
public const string TypeId = "File";


public AbstractFileAsset()
{
Type = TypeId;
}
}
}
90 changes: 90 additions & 0 deletions src/MTConnect.NET-Common/Assets/Files/FileAsset.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;

namespace MTConnect.Assets.Files
{
public partial class FileAsset
{
public const string TypeId = "File";

Check warning on line 11 in src/MTConnect.NET-Common/Assets/Files/FileAsset.cs

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu-latest-MTConnect-NET-HTTP

'FileAsset.TypeId' hides inherited member 'AbstractFileAsset.TypeId'. Use the new keyword if hiding was intended.

Check warning on line 11 in src/MTConnect.NET-Common/Assets/Files/FileAsset.cs

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu-latest-MTConnect-NET-HTTP

'FileAsset.TypeId' hides inherited member 'AbstractFileAsset.TypeId'. Use the new keyword if hiding was intended.

Check warning on line 11 in src/MTConnect.NET-Common/Assets/Files/FileAsset.cs

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu-latest-MTConnect-NET-MQTT

'FileAsset.TypeId' hides inherited member 'AbstractFileAsset.TypeId'. Use the new keyword if hiding was intended.

Check warning on line 11 in src/MTConnect.NET-Common/Assets/Files/FileAsset.cs

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu-latest-MTConnect-NET-MQTT

'FileAsset.TypeId' hides inherited member 'AbstractFileAsset.TypeId'. Use the new keyword if hiding was intended.

Check warning on line 11 in src/MTConnect.NET-Common/Assets/Files/FileAsset.cs

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu-latest-MTConnect-NET-Common

'FileAsset.TypeId' hides inherited member 'AbstractFileAsset.TypeId'. Use the new keyword if hiding was intended.

Check warning on line 11 in src/MTConnect.NET-Common/Assets/Files/FileAsset.cs

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu-latest-MTConnect-NET-Common

'FileAsset.TypeId' hides inherited member 'AbstractFileAsset.TypeId'. Use the new keyword if hiding was intended.

Check warning on line 11 in src/MTConnect.NET-Common/Assets/Files/FileAsset.cs

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu-latest-MTConnect-NET-XML

'FileAsset.TypeId' hides inherited member 'AbstractFileAsset.TypeId'. Use the new keyword if hiding was intended.

Check warning on line 11 in src/MTConnect.NET-Common/Assets/Files/FileAsset.cs

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu-latest-MTConnect-NET-XML

'FileAsset.TypeId' hides inherited member 'AbstractFileAsset.TypeId'. Use the new keyword if hiding was intended.

Check warning on line 11 in src/MTConnect.NET-Common/Assets/Files/FileAsset.cs

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu-latest-MTConnect-NET-SHDR

'FileAsset.TypeId' hides inherited member 'AbstractFileAsset.TypeId'. Use the new keyword if hiding was intended.

Check warning on line 11 in src/MTConnect.NET-Common/Assets/Files/FileAsset.cs

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu-latest-MTConnect-NET-HTTP-AspNetCore

'FileAsset.TypeId' hides inherited member 'AbstractFileAsset.TypeId'. Use the new keyword if hiding was intended.


public FileAsset()
{
Type = TypeId;
}


protected override IAsset OnProcess(Version mtconnectVersion)
{
if (Size <= 0) return null;
if (string.IsNullOrEmpty(VersionId)) return null;

return base.OnProcess(mtconnectVersion);
}

public override AssetValidationResult IsValid(Version mtconnectVersion)
{
var baseResult = base.IsValid(mtconnectVersion);
var message = baseResult.Message;
var result = baseResult.IsValid;

if (baseResult.IsValid)
{
if (Size <= 0)
{
message = "Size property is Required and must be greater than 0";
result = false;
}
else if (string.IsNullOrEmpty(VersionId))
{
message = "VersionId property is Required";
result = false;
}
else if (CreationTime <= DateTime.MinValue)
{
message = "CreationTime property is Required";
result = false;
}
else if (Location == null)
{
message = "FileLocation is Required";
result = false;
}
else
{
if (string.IsNullOrEmpty(Location.Href))
{
message = "FileLocation Href property is Required";
result = false;
}
}
}

return new AssetValidationResult(result, message);
}

public override string GenerateHash()
{
return GenerateHash(this);
}

public static string GenerateHash(FileAsset asset)
{
if (asset != null)
{
var ids = new List<string>();

ids.Add(ObjectExtensions.GetHashPropertyString(asset).ToSHA1Hash());

// Need to include CuttingItems

return StringFunctions.ToSHA1Hash(ids.ToArray());
}

return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class JsonCuttingToolArchetype

public JsonCuttingToolArchetype() { }

public JsonCuttingToolArchetype(CuttingToolArchetype cuttingToolArchetype)
public JsonCuttingToolArchetype(ICuttingToolArchetypeAsset cuttingToolArchetype)
{
if (cuttingToolArchetype != null)
{
Expand All @@ -23,9 +23,9 @@ public JsonCuttingToolArchetype(CuttingToolArchetype cuttingToolArchetype)
}


public CuttingToolArchetype ToCuttingToolArchetype()
public ICuttingToolArchetypeAsset ToCuttingToolArchetype()
{
var cuttingToolArchetype = new CuttingToolArchetype();
var cuttingToolArchetype = new CuttingToolArchetypeAsset();
if (CuttingToolDefinition != null) cuttingToolArchetype.CuttingToolDefinition = CuttingToolDefinition.ToCuttingToolDefinition();
return cuttingToolArchetype;
}
Expand Down
8 changes: 4 additions & 4 deletions src/MTConnect.NET-JSON-cppagent/Assets/Files/JsonFileAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ public class JsonFileAsset
public DateTime CreationTime { get; set; }

[JsonPropertyName("modificationTime")]
public DateTime ModificationTime { get; set; }
public DateTime? ModificationTime { get; set; }


public JsonFileAsset() { }

public JsonFileAsset(IFile asset)
public JsonFileAsset(IFileAsset asset)
{
if (asset != null)
{
Expand Down Expand Up @@ -134,9 +134,9 @@ public JsonFileAsset(IFile asset)
}


public IFile ToFileAsset()
public IFileAsset ToFileAsset()
{
var asset = new File();
var asset = new FileAsset();

asset.AssetId = AssetId;
asset.Type = Type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public JsonAssetsDocument(IAssetsResponseDocument assetsDocument)
switch (asset.Type)
{
case "CuttingTool": jsonAsset = new JsonCuttingToolAsset(asset as CuttingToolAsset); break;
case "File": jsonAsset = new JsonFileAsset(asset as File); break;
case "File": jsonAsset = new JsonFileAsset(asset as FileAsset); break;
case "QIFDocumentWrapper": jsonAsset = new JsonQIFDocumentWrapperAsset(asset as QIFDocumentWrapperAsset); break;
case "RawMaterial": jsonAsset = new JsonRawMaterialAsset(asset as RawMaterialAsset); break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ public class JsonQIFDocumentWrapperAsset


[JsonPropertyName("qifDocumentType")]
public string QifDocumentType { get; set; }
public string QIFDocumentType { get; set; }

[JsonPropertyName("qifDocument")]
public string QifDocument { get; set; }
public string QIFDocument { get; set; }


public JsonQIFDocumentWrapperAsset() { }
Expand All @@ -54,8 +54,8 @@ public JsonQIFDocumentWrapperAsset(QIFDocumentWrapperAsset asset)

if (asset.Description != null) Description = new JsonDescription(asset.Description);

QifDocumentType = asset.QifDocumentType;
QifDocument = asset.QifDocument;
QIFDocumentType = asset.QifDocumentType.ToString();
//QifDocument = asset.QifDocument;
}
}

Expand All @@ -72,8 +72,8 @@ public QIFDocumentWrapperAsset ToQIFDocumentWrapperAsset()

if (Description != null) asset.Description = Description.ToDescription();

asset.QifDocumentType = QifDocumentType;
asset.QifDocument = QifDocument;
asset.QifDocumentType = QIFDocumentType.ConvertEnum<QIFDocumentType>();
//asset.QifDocument = QifDocument;
return asset;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class JsonMaterial

public JsonMaterial() { }

public JsonMaterial(Material material)
public JsonMaterial(IMaterial material)
{
if (material != null)
{
Expand All @@ -52,7 +52,7 @@ public JsonMaterial(Material material)
}


public Material ToMaterial()
public IMaterial ToMaterial()
{
var material = new Material();
material.Id = Id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class JsonRawMaterialAsset

public JsonRawMaterialAsset() { }

public JsonRawMaterialAsset(RawMaterialAsset asset)
public JsonRawMaterialAsset(IRawMaterialAsset asset)
{
if (asset != null)
{
Expand All @@ -100,24 +100,24 @@ public JsonRawMaterialAsset(RawMaterialAsset asset)
ContainerType = asset.ContainerType;
ProcessKind = asset.ProcessKind;
SerialNumber = asset.SerialNumber;
Form = asset.Form;
//Form = asset.Form;
HasMaterial = asset.HasMaterial;
ManufacturingDate = asset.ManufacturingDate;
FirstUseDate = asset.FirstUseDate;
LastUseDate = asset.LastUseDate;
InitialVolume = asset.InitialVolume;
InitialDimension = asset.InitialDimension;
InitialQuantity = asset.InitialQuantity;
CurrentVolume = asset.CurrentVolume;
CurrentDimension = asset.CurrentDimension;
//InitialVolume = asset.InitialVolume;
//InitialDimension = asset.InitialDimension;
//InitialQuantity = asset.InitialQuantity;
//CurrentVolume = asset.CurrentVolume;
//CurrentDimension = asset.CurrentDimension;
CurrentQuantity = asset.CurrentQuantity;

if (asset != null) Material = new JsonMaterial(asset.Material);
}
}


public RawMaterialAsset ToRawMaterialAsset()
public IRawMaterialAsset ToRawMaterialAsset()
{
var asset = new RawMaterialAsset();

Expand All @@ -133,16 +133,16 @@ public RawMaterialAsset ToRawMaterialAsset()
asset.ContainerType = ContainerType;
asset.ProcessKind = ProcessKind;
asset.SerialNumber = SerialNumber;
asset.Form = Form;
//asset.Form = Form;
asset.HasMaterial = HasMaterial;
asset.ManufacturingDate = ManufacturingDate;
asset.FirstUseDate = FirstUseDate;
asset.LastUseDate = LastUseDate;
asset.InitialVolume = InitialVolume;
asset.InitialDimension = InitialDimension;
asset.InitialQuantity = InitialQuantity;
asset.CurrentVolume = CurrentVolume;
asset.CurrentDimension = CurrentDimension;
//asset.InitialVolume = InitialVolume;
//asset.InitialDimension = InitialDimension;
//asset.InitialQuantity = InitialQuantity;
//asset.CurrentVolume = CurrentVolume;
//asset.CurrentDimension = CurrentDimension;
asset.CurrentQuantity = CurrentQuantity;

if (Material != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class JsonCuttingToolArchetype

public JsonCuttingToolArchetype() { }

public JsonCuttingToolArchetype(CuttingToolArchetype cuttingToolArchetype)
public JsonCuttingToolArchetype(ICuttingToolArchetypeAsset cuttingToolArchetype)
{
if (cuttingToolArchetype != null)
{
Expand All @@ -23,9 +23,9 @@ public JsonCuttingToolArchetype(CuttingToolArchetype cuttingToolArchetype)
}


public CuttingToolArchetype ToCuttingToolArchetype()
public ICuttingToolArchetypeAsset ToCuttingToolArchetype()
{
var cuttingToolArchetype = new CuttingToolArchetype();
var cuttingToolArchetype = new CuttingToolArchetypeAsset();
if (CuttingToolDefinition != null) cuttingToolArchetype.CuttingToolDefinition = CuttingToolDefinition.ToCuttingToolDefinition();
return cuttingToolArchetype;
}
Expand Down
8 changes: 4 additions & 4 deletions src/MTConnect.NET-JSON/Assets/Files/JsonFileAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ public class JsonFileAsset
public DateTime CreationTime { get; set; }

[JsonPropertyName("modificationTime")]
public DateTime ModificationTime { get; set; }
public DateTime? ModificationTime { get; set; }


public JsonFileAsset() { }

public JsonFileAsset(IFile asset)
public JsonFileAsset(IFileAsset asset)
{
if (asset != null)
{
Expand Down Expand Up @@ -134,9 +134,9 @@ public JsonFileAsset(IFile asset)
}


public IFile ToFileAsset()
public IFileAsset ToFileAsset()
{
var asset = new File();
var asset = new FileAsset();

asset.AssetId = AssetId;
asset.Type = Type;
Expand Down
2 changes: 1 addition & 1 deletion src/MTConnect.NET-JSON/Assets/JsonAssetsDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public JsonAssetsDocument(IAssetsResponseDocument assetsDocument)
switch (asset.Type)
{
case "CuttingTool": jsonAsset = new JsonCuttingToolAsset(asset as CuttingToolAsset); break;
case "File": jsonAsset = new JsonFileAsset(asset as File); break;
case "File": jsonAsset = new JsonFileAsset(asset as FileAsset); break;
case "QIFDocumentWrapper": jsonAsset = new JsonQIFDocumentWrapperAsset(asset as QIFDocumentWrapperAsset); break;
case "RawMaterial": jsonAsset = new JsonRawMaterialAsset(asset as RawMaterialAsset); break;
}
Expand Down
Loading

0 comments on commit 6fdc255

Please sign in to comment.