Skip to content

Commit

Permalink
Tbm0115/memory fix namespace refactor (#26)
Browse files Browse the repository at this point in the history
* Added null check

* Added implicit null operators and fixed null reference exception

* Added null check

* Support for component collections in device configuration

* Fixed naming issues

* Refactored Adapter code into Interface class/project

* Update AdapterSdk.csproj

* UPnP abstraction

* Abstracted methods and Assets

* Extensions abstraction

* Fix generic AgentCommand

* Fixed subcomponent naming

* Improved implicit operators

* EnableDynamicLoading

* Refactor

* Removed migrated code

* Migrated enums and generated code to Core

* Release versions
  • Loading branch information
tbm0115 authored Nov 2, 2023
1 parent cfb87fa commit 05c4ea5
Show file tree
Hide file tree
Showing 571 changed files with 31,944 additions and 29,077 deletions.
57 changes: 57 additions & 0 deletions AdapterSdk.Core/AdapterSdk.Core.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;netstandard2.0;net461;</TargetFrameworks>
<BaseOutputPath>bin\</BaseOutputPath>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<NeutralLanguage>en-US</NeutralLanguage>
<RootNamespace>Mtconnect.AdapterSdk</RootNamespace>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageId>Mtconnect.AdapterSdk.Core</PackageId>
<Title>MTConnect Adapter SDK Core</Title>
<Authors>tbm0115</Authors>
<Company>True Analytics Manufacturing Solutions</Company>
<Product>MTConnect</Product>
<Description>An interface library for connecting other libraries into the Mtconnect.AdapterSdk.</Description>
<Copyright>True Analytics Manufacturing Solutions, LLC 2023</Copyright>
<PackageIcon>icon.jpg</PackageIcon>
<RepositoryType>git</RepositoryType>
<PackageTags>MTConnect;Adapter;Interface</PackageTags>
<PackageReleaseNotes>Added support for device model configuration with a MTConnect Agent.</PackageReleaseNotes>
<ApplicationIcon>icon.ico</ApplicationIcon>
<PackageProjectUrl>https://github.com/TrueAnalyticsSolutions/Mtconnect.Adapter</PackageProjectUrl>
<RepositoryUrl>$(ProjectUrl)</RepositoryUrl>
<Version>1.0.1.0</Version>
<IncludeSymbols>True</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<DebugSymbols>true</DebugSymbols>
<EmbedAllSources>true</EmbedAllSources>
<DebugType>portable</DebugType>
<DocumentationFile>$(AssemblyName).xml</DocumentationFile>
</PropertyGroup>

<ItemGroup>
<None Remove="icon.jpg" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\Constants.cs" Link="Constants.cs" />
</ItemGroup>

<ItemGroup>
<Content Include="icon.ico" />
<Content Include="icon.jpg">
<PackagePath>\</PackagePath>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Pack>True</Pack>
</Content>
</ItemGroup>

<ItemGroup>
<Folder Include="Contracts\Enums\Values\" />
<Folder Include="Contracts\Enums\Types\" />
<Folder Include="Contracts\Components\" />
<Folder Include="Contracts\Values\" />
</ItemGroup>

</Project>
27,364 changes: 27,364 additions & 0 deletions AdapterSdk.Core/AdapterSdk.Core.xml

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions AdapterSdk.Core/Assets/IAsset.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Xml;

namespace Mtconnect.AdapterSdk.Assets
{
/// <summary>
/// Abstract Asset class.
/// </summary>
public interface IAsset
{
/// <summary>
/// Unique identifier of an MTConnect Asset.
/// </summary>
string AssetId { set; get; }

/// <summary>
/// Writes XML to the provided <paramref name="writer"/>.
/// </summary>
/// <param name="writer">Method uses this to write XML.</param>
/// <returns>Pass-thru reference to <paramref name="writer"/>.</returns>
XmlWriter ToXml(XmlWriter writer);

/// <summary>
/// Generic method for getting the type of Asset.
/// </summary>
/// <returns>Reference to the type of MTConnect Asset type.</returns>
string GetMTCType();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace Mtconnect.AdapterSdk.Contracts.Attributes
namespace Mtconnect.AdapterSdk.Attributes
{
/// <summary>
/// A decorative attribute for indicating a property intended to go thru an Adapter stream as an Condition.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Mtconnect.AdapterSdk.DataItems;
using System;

namespace Mtconnect.AdapterSdk.Contracts.Attributes
namespace Mtconnect.AdapterSdk.Attributes
{
/// <summary>
/// A decorative attribute for indicating a property intended to go thru an Adapter stream.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Mtconnect.AdapterSdk.Contracts.Attributes
namespace Mtconnect.AdapterSdk.Attributes
{
/// <summary>
/// A decorative attribute for indicating a complex object with properties that are decorated as DataItems.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Mtconnect.AdapterSdk.DataItems;
using System;

namespace Mtconnect.AdapterSdk.Contracts.Attributes
namespace Mtconnect.AdapterSdk.Attributes
{
/// <summary>
/// A decorative attribute for indicating a class intended to set the <see cref="DataItem.DevicePrefix"/> of each <see cref="DataItem"/> in a <see cref="IAdapterDataModel"/>.
Expand All @@ -12,6 +12,10 @@ public class DeviceIdAttribute : Attribute
/// <inheritdoc cref="DataItem.DevicePrefix"/>
public string Id { get; }

/// <summary>
/// Constructs a new instance of a <see cref="DeviceIdAttribute"/>
/// </summary>
/// <param name="id"><inheritdoc cref="Id" path="/summary"/></param>
public DeviceIdAttribute(string id)
{
Id = id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Mtconnect.AdapterSdk.DataItemTypes;
using System;

namespace Mtconnect.AdapterSdk.Contracts.Attributes
namespace Mtconnect.AdapterSdk.Attributes
{
/// <summary>
/// A decorative attribute for indicating a property intended to go thru an Adapter stream as an Event.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Mtconnect.AdapterSdk.DataItemTypes;
using System;

namespace Mtconnect.AdapterSdk.Contracts.Attributes
namespace Mtconnect.AdapterSdk.Attributes
{
/// <summary>
/// A decorative attribute for indicating a property intended to go thru an Adapter stream as an Message.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace Mtconnect.AdapterSdk.Contracts.Attributes
namespace Mtconnect.AdapterSdk.Attributes
{
/// <summary>
/// An attribute used to flag the applicability of an object based on the version of the standard the MTConnect Response Document should be compared against.
Expand All @@ -13,6 +13,9 @@ public class MtconnectVersionAttribute : Attribute
/// </summary>
public MtconnectVersions MinimumVersion { get; set; }

/// <summary>
/// Reference to the version of the MTConnect Standard that this object applies to.
/// </summary>
public MtconnectVersions? MaximumVersion { get; set; }

/// <summary>
Expand Down Expand Up @@ -45,7 +48,7 @@ public MtconnectVersionAttribute(MtconnectVersions version, string standardRefer
/// Compares the Response Document version against the version specified in the attribute based on the comparison method provided.
/// </summary>
/// <param name="documentVersion">Reference to the version of MTConnect implemented in the Response Document.</param>
/// <returns>Flag for whether the MTConnect Response Document version matches with the specified <see cref="MinimumVersion"/> according to the <see cref="ComparisonType"/>.</returns>
/// <returns>Flag for whether the MTConnect Response Document version matches with the specified <see cref="MinimumVersion"/> according to the ComparisonType.</returns>
public bool Compare(MtconnectVersions documentVersion)
{
return documentVersion >= MinimumVersion && (MaximumVersion.HasValue ? documentVersion <= MaximumVersion.Value : true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace Mtconnect.AdapterSdk.Contracts.Attributes
namespace Mtconnect.AdapterSdk.Attributes
{
/// <summary>
/// An attribute used to indicate that an enum value that represents an observational type also has relevant sub-type(s).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace Mtconnect.AdapterSdk.Contracts.Attributes
namespace Mtconnect.AdapterSdk.Attributes
{
/// <summary>
/// An attribute used to indicate that an enum value that represents an observational type also has relevant type(s).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;

namespace Mtconnect.AdapterSdk.Attributes
{
/// <summary>
/// Attribute indicating the <see cref="Enum"/> listing the possible Values for the attached Field
/// </summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
public class ObservationalValueAttribute : Attribute
{
/// <summary>
/// Reference to the remote <see cref="Enum"/>
/// </summary>
public Type ValueEnum { get; set; }

/// <summary>
/// Constructs a new instance of this attribute.
/// </summary>
/// <param name="valueEnum"><inheritdoc cref="ValueEnum" path="/summary"/></param>
public ObservationalValueAttribute(Type valueEnum)
{
ValueEnum = valueEnum;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Mtconnect.AdapterSdk.DataItemTypes;
using System;

namespace Mtconnect.AdapterSdk.Contracts.Attributes
namespace Mtconnect.AdapterSdk.Attributes
{
/// <summary>
/// A decorative attribute for indicating a property intended to go thru an Adapter stream as an Sample.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Mtconnect.AdapterSdk.DataItemTypes;
using System;

namespace Mtconnect.AdapterSdk.Contracts.Attributes
namespace Mtconnect.AdapterSdk.Attributes
{
/// <summary>
/// A decorative attribute for indicating a property intended to go thru an Adapter stream as an Time Series.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Mtconnect.AdapterSdk.DataItems;
using System;

namespace Mtconnect.AdapterSdk.Contracts.Attributes
namespace Mtconnect.AdapterSdk.Attributes
{
/// <summary>
/// Indicates that a <see cref="DateTime"/> property can be the source for <see cref="DataItem.LastChanged"/>.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using Mtconnect.AdapterSdk.Contracts;
#pragma warning disable CS0618
#pragma warning disable CS1574
#pragma warning disable CS1570
#pragma warning disable CS1584
using Mtconnect.AdapterSdk;
using Mtconnect.AdapterSdk.DataItemValues;
using System;
using System.CodeDom.Compiler;
Expand All @@ -10,7 +14,7 @@ namespace Mtconnect.AdapterSdk.DataItemTypes {
/// <see cref="Component">Component</see> composed of a physical apparatus that moves or controls a mechanism or system. /// Description
/// </summary>
/// <remarks>Introduced in <see href="https://model.mtconnect.org/#_Version_1.1">v1.1</see>.</remarks>
[GeneratedCode("MtconnectTranspiler.Sinks.CSharp.Adapter", "1.0.12.0")]
[GeneratedCode("MtconnectTranspiler.Sinks.CSharp.Adapter; Adapter.ComponentInterface.scriban", "1.0.12.0")]
public class Actuator : IAdapterDataModel, IComponentModel {
/// <summary>
/// Sets all data items to <c>UNAVAILABLE</c> by setting the properties to <c>default</c>.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using Mtconnect.AdapterSdk.Contracts;
#pragma warning disable CS0618
#pragma warning disable CS1574
#pragma warning disable CS1570
#pragma warning disable CS1584
using Mtconnect.AdapterSdk;
using Mtconnect.AdapterSdk.DataItemValues;
using System;
using System.CodeDom.Compiler;
Expand All @@ -10,7 +14,7 @@ namespace Mtconnect.AdapterSdk.DataItemTypes {
/// <see cref="Component">Component</see> that provides information about the data source for an <i>MTConnect Agent</i>./// Description
/// </summary>
/// <remarks>Introduced in <see href="https://model.mtconnect.org/#_Version_1.7">v1.7</see>.</remarks>
[GeneratedCode("MtconnectTranspiler.Sinks.CSharp.Adapter", "1.0.12.0")]
[GeneratedCode("MtconnectTranspiler.Sinks.CSharp.Adapter; Adapter.ComponentInterface.scriban", "1.0.12.0")]
public class Adapter : IAdapterDataModel, IComponentModel {
/// <summary>
/// Sets all data items to <c>UNAVAILABLE</c> by setting the properties to <c>default</c>.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using Mtconnect.AdapterSdk.Contracts;
#pragma warning disable CS0618
#pragma warning disable CS1574
#pragma warning disable CS1570
#pragma warning disable CS1584
using Mtconnect.AdapterSdk;
using Mtconnect.AdapterSdk.DataItemValues;
using System;
using System.CodeDom.Compiler;
Expand All @@ -10,7 +14,7 @@ namespace Mtconnect.AdapterSdk.DataItemTypes {
/// <see cref="Component">Component</see> that <i>organize</i>s <see cref="Adapter">Adapter</see> types.
/// </summary>
/// <remarks>Introduced in <see href="https://model.mtconnect.org/#_Version_1.7">v1.7</see>.</remarks>
[GeneratedCode("MtconnectTranspiler.Sinks.CSharp.Adapter", "1.0.12.0")]
[GeneratedCode("MtconnectTranspiler.Sinks.CSharp.Adapter; Adapter.ComponentInterface.scriban", "1.0.12.0")]
public class Adapters : IAdapterDataModel, IComponentModel {

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using Mtconnect.AdapterSdk.Contracts;
#pragma warning disable CS0618
#pragma warning disable CS1574
#pragma warning disable CS1570
#pragma warning disable CS1584
using Mtconnect.AdapterSdk;
using Mtconnect.AdapterSdk.DataItemValues;
using System;
using System.CodeDom.Compiler;
Expand All @@ -10,7 +14,7 @@ namespace Mtconnect.AdapterSdk.DataItemTypes {
/// leaf <see cref="Component">Component</see> composed of an electronic component or circuit that amplifies power, electric current, or voltage.
/// </summary>
/// <remarks>Introduced in <see href="https://model.mtconnect.org/#_Version_1.4">v1.4</see>.</remarks>
[GeneratedCode("MtconnectTranspiler.Sinks.CSharp.Adapter", "1.0.12.0")]
[GeneratedCode("MtconnectTranspiler.Sinks.CSharp.Adapter; Adapter.ComponentInterface.scriban", "1.0.12.0")]
public class Amplifier : IAdapterDataModel, IComponentModel {
/// <summary>
/// Sets all data items to <c>UNAVAILABLE</c> by setting the properties to <c>default</c>.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using Mtconnect.AdapterSdk.Contracts;
#pragma warning disable CS0618
#pragma warning disable CS1574
#pragma warning disable CS1570
#pragma warning disable CS1584
using Mtconnect.AdapterSdk;
using Mtconnect.AdapterSdk.DataItemValues;
using System;
using System.CodeDom.Compiler;
Expand All @@ -10,7 +14,7 @@ namespace Mtconnect.AdapterSdk.DataItemTypes {
/// <see cref="ToolingDelivery">ToolingDelivery</see> composed of a tool delivery mechanism that moves tools between a <see cref="ToolMagazine">ToolMagazine</see> and a <i>spindle</i> a <see cref="Turret">Turret</see>./// Description
/// </summary>
/// <remarks>Introduced in <see href="https://model.mtconnect.org/#_Version_1.7">v1.7</see>.</remarks>
[GeneratedCode("MtconnectTranspiler.Sinks.CSharp.Adapter", "1.0.12.0")]
[GeneratedCode("MtconnectTranspiler.Sinks.CSharp.Adapter; Adapter.ComponentInterface.scriban", "1.0.12.0")]
public class AutomaticToolChanger : ToolingDelivery, IAdapterDataModel, IComponentModel {
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using Mtconnect.AdapterSdk.Contracts;
#pragma warning disable CS0618
#pragma warning disable CS1574
#pragma warning disable CS1570
#pragma warning disable CS1584
using Mtconnect.AdapterSdk;
using Mtconnect.AdapterSdk.DataItemValues;
using System;
using System.CodeDom.Compiler;
Expand All @@ -10,7 +14,7 @@ namespace Mtconnect.AdapterSdk.DataItemTypes {
/// <see cref="Component">Component</see> that <i>organize</i>s <see cref="Auxiliary">Auxiliary</see> types.
/// </summary>
/// <remarks>Introduced in <see href="https://model.mtconnect.org/#_Version_1.4">v1.4</see>.</remarks>
[GeneratedCode("MtconnectTranspiler.Sinks.CSharp.Adapter", "1.0.12.0")]
[GeneratedCode("MtconnectTranspiler.Sinks.CSharp.Adapter; Adapter.ComponentInterface.scriban", "1.0.12.0")]
public class Auxiliaries : IAdapterDataModel, IComponentModel {

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using Mtconnect.AdapterSdk.Contracts;
#pragma warning disable CS0618
#pragma warning disable CS1574
#pragma warning disable CS1570
#pragma warning disable CS1584
using Mtconnect.AdapterSdk;
using Mtconnect.AdapterSdk.DataItemValues;
using System;
using System.CodeDom.Compiler;
Expand All @@ -10,7 +14,7 @@ namespace Mtconnect.AdapterSdk.DataItemTypes {
/// abstract <see cref="Component">Component</see> composed of removable part(s) of a piece of equipment that provides supplementary or extended functionality.
/// </summary>
/// <remarks>Introduced in <see href="https://model.mtconnect.org/#_Version_1.4">v1.4</see>.</remarks>
[GeneratedCode("MtconnectTranspiler.Sinks.CSharp.Adapter", "1.0.12.0")]
[GeneratedCode("MtconnectTranspiler.Sinks.CSharp.Adapter; Adapter.ComponentInterface.scriban", "1.0.12.0")]
public class Auxiliary : IAdapterDataModel, IComponentModel {

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using Mtconnect.AdapterSdk.Contracts;
#pragma warning disable CS0618
#pragma warning disable CS1574
#pragma warning disable CS1570
#pragma warning disable CS1584
using Mtconnect.AdapterSdk;
using Mtconnect.AdapterSdk.DataItemValues;
using System;
using System.CodeDom.Compiler;
Expand All @@ -10,7 +14,7 @@ namespace Mtconnect.AdapterSdk.DataItemTypes {
/// <see cref="Component">Component</see> that <i>organize</i>s <see cref="Component Types::Axis">Component Types::Axis</see> types.
/// </summary>
/// <remarks>Introduced in <see href="https://model.mtconnect.org/#_Version_1.0">v1.0</see>.</remarks>
[GeneratedCode("MtconnectTranspiler.Sinks.CSharp.Adapter", "1.0.12.0")]
[GeneratedCode("MtconnectTranspiler.Sinks.CSharp.Adapter; Adapter.ComponentInterface.scriban", "1.0.12.0")]
public class Axes : IAdapterDataModel, IComponentModel {

/// <summary>
Expand Down
Loading

0 comments on commit 05c4ea5

Please sign in to comment.