Skip to content

Commit

Permalink
Updated Devices files from SysML Import
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickRitchie committed Oct 25, 2023
1 parent e0aeba4 commit ef7fe74
Show file tree
Hide file tree
Showing 1,345 changed files with 31,282 additions and 23,552 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"profiles": {
"WSL": {
"commandName": "WSL2",
"distributionName": ""
}
}
}
19 changes: 10 additions & 9 deletions build/MTConnect.NET-SysML-Import/Program.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
using MTConnect.SysML.CSharp;
using MTConnect.SysML;
using MTConnect.SysML;
using MTConnect.SysML.CSharp;
using System.Text.Json;

var xmlPath = @"D:\TrakHound\MTConnect\MTConnectSysMLModel.xml";
var outputPath = @"C:\temp\mtconnect-model-results";
var outputPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../../../src/MTConnect.NET-Common");

var mtconnectModel = MTConnectModel.Parse(xmlPath);

var jsonOptions = new JsonSerializerOptions();
jsonOptions.WriteIndented = true;
jsonOptions.DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault;
jsonOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
//var jsonOptions = new JsonSerializerOptions();
//jsonOptions.WriteIndented = true;
//jsonOptions.DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault;
//jsonOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;

//var json = JsonSerializer.Serialize(mtconnectModel, options: jsonOptions);
//await File.WriteAllTextAsync(@"C:\temp\mtconnect-model.json", json);

var json = JsonSerializer.Serialize(mtconnectModel, options: jsonOptions);
await File.WriteAllTextAsync(@"C:\temp\mtconnect-model.json", json);

CSharpTemplateRenderer.Render(mtconnectModel, outputPath);
14 changes: 6 additions & 8 deletions src/MTConnect.NET-Common/Agents/MTConnectAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
using MTConnect.Configurations;
using MTConnect.Devices;
using MTConnect.Devices.DataItems;
using MTConnect.Devices.DataItems.Events;
using MTConnect.Devices.DataItems.Samples;
using MTConnect.Observations;
using MTConnect.Observations.Input;
using MTConnect.Observations.Output;
Expand Down Expand Up @@ -107,7 +105,7 @@ public Version MTConnectVersion
if (version == null) version = MTConnectVersions.Max;

_mtconnectVersion = version;
if (_agent != null) _agent.MTConnectVersion = _mtconnectVersion;
if (_agent != null) _agent.MTConnectVersion = _mtconnectVersion.ToString();
}
}

Expand Down Expand Up @@ -1715,20 +1713,20 @@ public bool AddAsset(string deviceKey, IAsset asset, bool? ignoreTimestamp = nul
if (device != null)
{
// Set Device UUID Property
asset.DeviceUuid = device.Uuid;
((Asset)asset).DeviceUuid = device.Uuid;

// Set InstanceId
asset.InstanceId = _instanceId;

// Set Timestamp
if ((!ignoreTimestamp.HasValue && _configuration.IgnoreTimestamps) || (ignoreTimestamp.HasValue && ignoreTimestamp.Value))
{
asset.Timestamp = UnixDateTime.Now;
((Asset)asset).Timestamp = DateTime.Now;
}
else asset.Timestamp = asset.Timestamp > 0 ? asset.Timestamp : UnixDateTime.Now;
else ((Asset)asset).Timestamp = asset.Timestamp > DateTime.Now ? asset.Timestamp : DateTime.Now;

// Set Asset Hash
asset.Hash = asset.GenerateHash();
((Asset)asset).Hash = asset.GenerateHash();

// Validate Asset based on Device's MTConnectVersion
var validationResults = asset.IsValid(device.MTConnectVersion);
Expand All @@ -1750,7 +1748,7 @@ public bool AddAsset(string deviceKey, IAsset asset, bool? ignoreTimestamp = nul
assetChangedObservation.DataItemKey = assetChanged.Id;
assetChangedObservation.AddValue(ValueKeys.Result, asset.AssetId);
assetChangedObservation.AddValue(ValueKeys.AssetType, asset.Type);
assetChangedObservation.Timestamp = asset.Timestamp;
assetChangedObservation.Timestamp = asset.Timestamp.ToUnixTime();
AddObservation(deviceUuid, assetChangedObservation);
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/MTConnect.NET-Common/Agents/MTConnectAgentBroker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
using MTConnect.Configurations;
using MTConnect.Devices;
using MTConnect.Devices.DataItems;
using MTConnect.Devices.DataItems.Events;
using MTConnect.Devices.DataItems.Samples;
using MTConnect.Errors;
using MTConnect.Headers;
using MTConnect.Observations;
Expand Down
89 changes: 1 addition & 88 deletions src/MTConnect.NET-Common/Assets/Asset.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.

using MTConnect.Devices;
using MTConnect.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.Serialization;

namespace MTConnect.Assets
{
/// <summary>
/// It is used in the manufacturing process, but is not permanently associated with a single piece of equipment.
/// It can be removed from the piece of equipment without compromising its function, and can be associated with other pieces of equipment during its lifecycle.
/// </summary>
public class Asset : IAsset
public partial class Asset : IAsset
{
private static Dictionary<string, Type> _types;

private long _timestamp;
private DateTime _dateTime;


internal string _uuid;
/// <summary>
Expand All @@ -41,93 +30,17 @@ public string Uuid

public MTConnectEntityType EntityType => MTConnectEntityType.Asset;

/// <summary>
/// The unique identifier for the MTConnect Asset.
/// </summary>
[XmlAttribute("assetId")]
[JsonPropertyName("assetId")]
public string AssetId { get; set; }

/// <summary>
/// The type for the MTConnect Asset
/// </summary>
[XmlAttribute("type")]
[JsonPropertyName("type")]
public string Type { get; set; }

[XmlIgnore]
[JsonIgnore]
public bool TypeSpecified => false;

/// <summary>
/// The time this MTConnect Asset was last modified.
/// </summary>
[XmlIgnore]
[JsonIgnore]
public long Timestamp
{
get => _timestamp;
set
{
_timestamp = value;
if (_dateTime.ToUnixTime() != _timestamp) _dateTime = _timestamp.ToDateTime();
}
}

/// <summary>
/// The time this MTConnect Asset was last modified.
/// </summary>
[XmlAttribute("timestamp")]
[JsonPropertyName("timestamp")]
public DateTime DateTime
{
get => _dateTime;
set
{
_dateTime = value;
if (_timestamp.ToDateTime() != _dateTime) _timestamp = _dateTime.ToUnixTime();
}
}

/// <summary>
/// The Agent InstanceId that produced this Asset
/// </summary>
[XmlIgnore]
[JsonPropertyName("instanceId")]
public long InstanceId { get; set; }

/// <summary>
/// The piece of equipments UUID that supplied this data.
/// </summary>
[XmlAttribute("deviceUuid")]
[JsonPropertyName("deviceUuid")]
public string DeviceUuid { get; set; }

/// <summary>
/// This is an optional attribute that is an indicator that the MTConnect
/// Asset has been removed from the piece of equipment.
/// </summary>
[XmlAttribute("removed")]
[JsonPropertyName("removed")]
public bool Removed { get; set; }

[XmlIgnore]
[JsonIgnore]
public bool RemovedSpecified => Removed;

/// <summary>
/// An optional element that can contain any descriptive content.
/// </summary>
[XmlAttribute("description")]
[JsonPropertyName("description")]
public string Description { get; set; }

/// <summary>
/// Condensed message digest from a secure one-way hash function. FIPS PUB 180-4
/// </summary>
[XmlAttribute("hash")]
[JsonPropertyName("hash")]
public string Hash { get; set; }

public static IAsset Create(string type)
{
Expand Down
51 changes: 51 additions & 0 deletions src/MTConnect.NET-Common/Assets/Asset.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.

// MTConnect SysML v2.2 : UML ID = EAID_C7D39183_23CB_416b_A62D_F60815E08B1A

namespace MTConnect.Assets
{
/// <summary>
/// Abstract Asset.
/// </summary>
public partial class Asset : IAsset
{
public const string DescriptionText = "Abstract Asset.";


/// <summary>
/// Unique identifier for an Asset.
/// </summary>
public string AssetId { get; set; }

/// <summary>
/// Technical information about an entity describing its physical layout, functional characteristics, and relationships with other entities.
/// </summary>
public MTConnect.Devices.Configurations.IConfiguration Configuration { get; set; }

/// <summary>
/// Description can contain any descriptive content about the Asset.
/// </summary>
public MTConnect.Devices.IDescription Description { get; set; }

/// <summary>
/// Associated piece of equipment's UUID that supplied the Asset's data.It references to the uuid property of the Device defined in Device Information Model.
/// </summary>
public string DeviceUuid { get; set; }

/// <summary>
/// Condensed message digest from a secure one-way hash function. FIPS PUB 180-4
/// </summary>
public string Hash { get; set; }

/// <summary>
/// Indicator that the Asset has been removed from the piece of equipment.
/// </summary>
public bool Removed { get; set; }

/// <summary>
/// Time the Asset data was last modified.
/// </summary>
public System.DateTime Timestamp { get; set; }
}
}
43 changes: 43 additions & 0 deletions src/MTConnect.NET-Common/Assets/AssetDescriptions.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.

namespace MTConnect.Assets
{
public static class AssetDescriptions
{
/// <summary>
/// Unique identifier for an Asset.
/// </summary>
public const string AssetId = "Unique identifier for an Asset.";

/// <summary>
/// Technical information about an entity describing its physical layout, functional characteristics, and relationships with other entities.
/// </summary>
public const string Configuration = "Technical information about an entity describing its physical layout, functional characteristics, and relationships with other entities.";

/// <summary>
/// Description can contain any descriptive content about the Asset.
/// </summary>
public const string Description = "Description can contain any descriptive content about the Asset.";

/// <summary>
/// Associated piece of equipment's UUID that supplied the Asset's data.It references to the uuid property of the Device defined in Device Information Model.
/// </summary>
public const string DeviceUuid = "Associated piece of equipment's UUID that supplied the Asset's data.It references to the uuid property of the Device defined in Device Information Model.";

/// <summary>
/// Condensed message digest from a secure one-way hash function. FIPS PUB 180-4
/// </summary>
public const string Hash = "Condensed message digest from a secure one-way hash function. FIPS PUB 180-4";

/// <summary>
/// Indicator that the Asset has been removed from the piece of equipment.
/// </summary>
public const string Removed = "Indicator that the Asset has been removed from the piece of equipment.";

/// <summary>
/// Time the Asset data was last modified.
/// </summary>
public const string Timestamp = "Time the Asset data was last modified.";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.

// MTConnect SysML v2.2 : UML ID = _19_0_3_68e0225_1678197202508_829668_17803

namespace MTConnect.Assets.ComponentConfigurationParameters
{
/// <summary>
/// Set of parameters that govern the functionality of the related Component.
/// </summary>
public class ComponentConfigurationParameters : Asset, IComponentConfigurationParameters
{
public new const string DescriptionText = "Set of parameters that govern the functionality of the related Component.";


/// <summary>
/// Set of parameters defining the configuration of a Component.
/// </summary>
public System.Collections.Generic.IEnumerable<MTConnect.Assets.ComponentConfigurationParameters.IParameterSet> ParameterSets { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.

namespace MTConnect.Assets.ComponentConfigurationParameters
{
public static class ComponentConfigurationParametersDescriptions
{
/// <summary>
/// Set of parameters defining the configuration of a Component.
/// </summary>
public const string ParameterSets = "Set of parameters defining the configuration of a Component.";
}
}
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.ComponentConfigurationParameters
{
/// <summary>
/// Set of parameters that govern the functionality of the related Component.
/// </summary>
public interface IComponentConfigurationParameters : IAsset
{
/// <summary>
/// Set of parameters defining the configuration of a Component.
/// </summary>
System.Collections.Generic.IEnumerable<MTConnect.Assets.ComponentConfigurationParameters.IParameterSet> ParameterSets { get; }
}
}
Loading

0 comments on commit ef7fe74

Please sign in to comment.