-
-
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
3273eb3
commit b827cae
Showing
42 changed files
with
1,773 additions
and
88 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
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/Xml/CuttingToolMeasurementsModel.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.Assets; | ||
|
||
namespace MTConnect.SysML.Xml | ||
{ | ||
public class CuttingToolMeasurementsModel | ||
{ | ||
public List<MTConnectCuttingToolMeasurementModel> 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
using MTConnect.SysML.Models.Assets; | ||
using Scriban; | ||
|
||
namespace MTConnect.SysML.Xml | ||
{ | ||
public static class XmlTemplateRenderer | ||
{ | ||
public static void Render(MTConnectModel mtconnectModel, string outputPath) | ||
{ | ||
if (mtconnectModel != null && !string.IsNullOrEmpty(outputPath)) | ||
{ | ||
WriteCuttingToolMeasurements(mtconnectModel, outputPath); | ||
WriteCuttingToolLifeCycle(mtconnectModel, outputPath); | ||
} | ||
} | ||
|
||
|
||
private static void WriteCuttingToolMeasurements(MTConnectModel mtconnectModel, string outputPath) | ||
{ | ||
var measurementsModel = new CuttingToolMeasurementsModel(); | ||
|
||
var measurements = mtconnectModel.AssetInformationModel.CuttingTools.Classes.Where(o => typeof(MTConnectCuttingToolMeasurementModel).IsAssignableFrom(o.GetType())); | ||
foreach (var measurement in measurements.OrderBy(o => o.Name)) measurementsModel.Types.Add((MTConnectCuttingToolMeasurementModel)measurement); | ||
|
||
var templateFilename = $"XmlMeasurements.scriban"; | ||
var templatePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "xml", "templates", templateFilename); | ||
if (File.Exists(templatePath)) | ||
{ | ||
try | ||
{ | ||
var templateContents = File.ReadAllText(templatePath); | ||
if (templateContents != null) | ||
{ | ||
var template = Template.Parse(templateContents); | ||
var result = template.Render(measurementsModel); | ||
if (result != null) | ||
{ | ||
var resultPath = $"Assets/CuttingTools/XmlMeasurements"; | ||
resultPath = Path.Combine(outputPath, resultPath); | ||
resultPath = $"{resultPath}.g.cs"; | ||
|
||
var resultDirectory = Path.GetDirectoryName(resultPath); | ||
if (!Directory.Exists(resultDirectory)) Directory.CreateDirectory(resultDirectory); | ||
|
||
File.WriteAllText(resultPath, result); | ||
} | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine(ex.Message); | ||
} | ||
} | ||
} | ||
|
||
private static void WriteCuttingToolLifeCycle(MTConnectModel mtconnectModel, string outputPath) | ||
{ | ||
var measurementsModel = new CuttingToolMeasurementsModel(); | ||
|
||
var measurements = mtconnectModel.AssetInformationModel.CuttingTools.Classes.Where(o => typeof(MTConnectCuttingToolMeasurementModel).IsAssignableFrom(o.GetType())); | ||
foreach (var measurement in measurements.OrderBy(o => o.Name)) measurementsModel.Types.Add((MTConnectCuttingToolMeasurementModel)measurement); | ||
|
||
var templateFilename = $"XmlCuttingToolLifeCycle.scriban"; | ||
var templatePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "xml", "templates", templateFilename); | ||
if (File.Exists(templatePath)) | ||
{ | ||
try | ||
{ | ||
var templateContents = File.ReadAllText(templatePath); | ||
if (templateContents != null) | ||
{ | ||
var template = Template.Parse(templateContents); | ||
var result = template.Render(measurementsModel); | ||
if (result != null) | ||
{ | ||
var resultPath = $"Assets/CuttingTools/XmlCuttingToolLifeCycle"; | ||
resultPath = Path.Combine(outputPath, resultPath); | ||
resultPath = $"{resultPath}.g.cs"; | ||
|
||
var resultDirectory = Path.GetDirectoryName(resultPath); | ||
if (!Directory.Exists(resultDirectory)) Directory.CreateDirectory(resultDirectory); | ||
|
||
File.WriteAllText(resultPath, result); | ||
} | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine(ex.Message); | ||
} | ||
} | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
build/MTConnect.NET-SysML-Import/Xml/Templates/XmlCuttingToolLifeCycle.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,19 @@ | ||
// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. | ||
// TrakHound Inc. licenses this file to you under the MIT license. | ||
|
||
using MTConnect.Assets.CuttingTools.Measurements; | ||
using MTConnect.Assets.Xml.CuttingTools; | ||
using System.Collections.Generic; | ||
using System.Xml.Serialization; | ||
|
||
namespace MTConnect.Assets.Json.CuttingTools | ||
{ | ||
public partial class XmlCuttingToolLifeCycle | ||
{ | ||
[XmlArray("Measurements")] | ||
{{- for type in types }} | ||
[XmlArrayItem({{type.name}}.TypeId, typeof(Xml{{type.name}}))] | ||
{{- end }} | ||
public List<XmlMeasurement> Measurements { get; set; } | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
build/MTConnect.NET-SysML-Import/Xml/Templates/XmlMeasurements.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,11 @@ | ||
// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. | ||
// TrakHound Inc. licenses this file to you under the MIT license. | ||
|
||
using MTConnect.Assets.CuttingTools.Measurements; | ||
|
||
namespace MTConnect.Assets.Xml.CuttingTools | ||
{ | ||
{{- for type in types }} | ||
public class Xml{{type.name}} : XmlMeasurement { public Xml{{type.name}}() { Type = {{type.name}}.TypeId; } } | ||
{{ 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
38 changes: 38 additions & 0 deletions
38
src/MTConnect.NET-Common/Assets/CuttingTools/CuttingToolAssetDescriptions.g.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,38 @@ | ||
// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. | ||
// TrakHound Inc. licenses this file to you under the MIT license. | ||
|
||
namespace MTConnect.Assets.CuttingTools | ||
{ | ||
public static class CuttingToolAssetDescriptions | ||
{ | ||
/// <summary> | ||
/// Reference information about the assetId and/or the URL of the data source of CuttingToolArchetype. | ||
/// </summary> | ||
public const string CuttingToolArchetypeReference = "Reference information about the assetId and/or the URL of the data source of CuttingToolArchetype."; | ||
|
||
/// <summary> | ||
/// Detailed structure of the cutting tool which is static during its lifecycle. ISO 13399. | ||
/// </summary> | ||
public const string CuttingToolDefinition = "Detailed structure of the cutting tool which is static during its lifecycle. ISO 13399."; | ||
|
||
/// <summary> | ||
/// Data regarding the application or use of the tool.This data is provided by various pieces of equipment (i.e. machine tool, presetter) and statistical process control applications. Life cycle data will not remain static, but will change periodically when a tool is used or measured. | ||
/// </summary> | ||
public const string CuttingToolLifeCycle = "Data regarding the application or use of the tool.This data is provided by various pieces of equipment (i.e. machine tool, presetter) and statistical process control applications. Life cycle data will not remain static, but will change periodically when a tool is used or measured."; | ||
|
||
/// <summary> | ||
/// Manufacturers of the cutting tool.This will reference the tool item and adaptive items specifically. The cutting itemsmanufacturers’ will be a property of CuttingItem.> Note: In XML, the representation **MUST** be a comma(,) delimited list of manufacturer names. See CuttingTool Schema Diagrams. | ||
/// </summary> | ||
public const string Manufacturers = "Manufacturers of the cutting tool.This will reference the tool item and adaptive items specifically. The cutting itemsmanufacturers’ will be a property of CuttingItem.> Note: In XML, the representation **MUST** be a comma(,) delimited list of manufacturer names. See CuttingTool Schema Diagrams."; | ||
|
||
/// <summary> | ||
/// Unique identifier for this assembly. | ||
/// </summary> | ||
public const string SerialNumber = "Unique identifier for this assembly."; | ||
|
||
/// <summary> | ||
/// Identifier for a class of cutting tools. | ||
/// </summary> | ||
public const string ToolId = "Identifier for a class of cutting tools."; | ||
} | ||
} |
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
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.