Skip to content

Commit

Permalink
Update 6.0.11
Browse files Browse the repository at this point in the history
- Fixed issue with Conditions with same Native Code
- Added methods to Device, Component, Composition to set IDs and Add DataItems
- Added MTConnectInputAgentModule class to use for embedded adapters
- Fixed issues with SHDR Adapter in Agent Device
- Fixed various minor issues
  • Loading branch information
PatrickRitchie committed Feb 2, 2024
1 parent eab82b0 commit 280e0d8
Show file tree
Hide file tree
Showing 805 changed files with 5,204 additions and 1,465 deletions.
10 changes: 10 additions & 0 deletions MTConnect.NET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MTConnect.NET-AgentModule-M
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MTConnect.NET-Client-MQTT", "clients\MTConnect.NET-Client-MQTT\MTConnect.NET-Client-MQTT.csproj", "{2844E2F1-8CC0-437B-A730-9045A25971F6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp41", "C:\temp\ConsoleApp41\ConsoleApp41.csproj", "{05289E74-4CBE-4B3C-BCCC-5B2BAD2D4825}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -388,6 +390,14 @@ Global
{2844E2F1-8CC0-437B-A730-9045A25971F6}.Package|Any CPU.Build.0 = Debug|Any CPU
{2844E2F1-8CC0-437B-A730-9045A25971F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2844E2F1-8CC0-437B-A730-9045A25971F6}.Release|Any CPU.Build.0 = Release|Any CPU
{05289E74-4CBE-4B3C-BCCC-5B2BAD2D4825}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{05289E74-4CBE-4B3C-BCCC-5B2BAD2D4825}.Debug|Any CPU.Build.0 = Debug|Any CPU
{05289E74-4CBE-4B3C-BCCC-5B2BAD2D4825}.Docker|Any CPU.ActiveCfg = Debug|Any CPU
{05289E74-4CBE-4B3C-BCCC-5B2BAD2D4825}.Docker|Any CPU.Build.0 = Debug|Any CPU
{05289E74-4CBE-4B3C-BCCC-5B2BAD2D4825}.Package|Any CPU.ActiveCfg = Debug|Any CPU
{05289E74-4CBE-4B3C-BCCC-5B2BAD2D4825}.Package|Any CPU.Build.0 = Debug|Any CPU
{05289E74-4CBE-4B3C-BCCC-5B2BAD2D4825}.Release|Any CPU.ActiveCfg = Release|Any CPU
{05289E74-4CBE-4B3C-BCCC-5B2BAD2D4825}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
4 changes: 2 additions & 2 deletions adapter/MTConnect.NET-Adapter/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.

using System;
Expand All @@ -14,7 +14,7 @@ public class Program

// Copyright statement for the application. If you are implementing this into your own application, you can change this to your own copyright, or set it to 'null'.
// This is just what is shown in the console header.
private const string ApplicationCopyright = "Copyright 2023 TrakHound Inc., All Rights Reserved";
private const string ApplicationCopyright = "Copyright 2024 TrakHound Inc., All Rights Reserved";


public static void Main(string[] args)
Expand Down
4 changes: 2 additions & 2 deletions agent/MTConnect.NET-Agent/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.

using System;
Expand All @@ -14,7 +14,7 @@ public class Program

// Copyright statement for the application. If you are implementing this into your own application, you can change this to your own copyright.
// This is just what is shown in the console header. If you want to show support for the MTConnect.NET project, you can reference it using the links in the default header
private const string ApplicationCopyright = "Copyright 2023 TrakHound Inc., All Rights Reserved";
private const string ApplicationCopyright = "Copyright 2024 TrakHound Inc., All Rights Reserved";

public static void Main(string[] args)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.

using MTConnect.Agents;
Expand All @@ -21,10 +21,10 @@

namespace MTConnect.Applications
{
/// <summary>
/// An MTConnect Agent Application base class supporting Command line arguments, Device management, Buffer management, Logging, Windows Service, and Configuration File management
/// </summary>
public class MTConnectAgentApplication : IMTConnectAgentApplication
/// <summary>
/// An MTConnect Agent Application base class supporting Command line arguments, Device management, Buffer management, Logging, Windows Service, and Configuration File management
/// </summary>
public class MTConnectAgentApplication : IMTConnectAgentApplication
{
private const string DefaultServiceName = "MTConnect.NET-Agent";
private const string DefaultServiceDisplayName = "MTConnect.NET Agent";
Expand Down Expand Up @@ -392,7 +392,7 @@ public void StartAgent(IAgentApplicationConfiguration configuration, bool verbos
}

OnStartAgentBeforeLoad(null, initializeDataItems);
_modules.StartBeforeLoad();
_modules.StartBeforeLoad(initializeDataItems);

// Read Device Configuration Files
var devicesPath = configuration.Devices;
Expand Down Expand Up @@ -449,7 +449,7 @@ public void StartAgent(IAgentApplicationConfiguration configuration, bool verbos
_mtconnectAgent.InitializeCurrentObservations(_observationBuffer.CurrentConditions.SelectMany(o => o.Value));
}

_modules.StartAfterLoad();
_modules.StartAfterLoad(initializeDataItems);
OnStartAgentAfterLoad(devices, initializeDataItems);

// Save Indexes for Buffer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public Module(IMTConnectAgentBroker mtconnectAgent, object configuration) : base
}


protected override void OnStartAfterLoad()
protected override void OnStartAfterLoad(bool initializeDataItems)
{
if (_configuration != null && !string.IsNullOrEmpty(_configuration.Address))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public Module(IMTConnectAgentBroker mtconnectAgent, object controllerConfigurati
}


protected override void OnStartAfterLoad()
protected override void OnStartAfterLoad(bool initializeDataItems)
{
// Intialize the Http Server
_httpServer = new MTConnectShdrHttpAgentServer(_configuration, _mtconnectAgent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public Module(IMTConnectAgentBroker mtconnectAgent, object configuration) : base
}


protected override void OnStartAfterLoad()
protected override void OnStartAfterLoad(bool initializeDataItems)
{
if (_configuration != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public Module(IMTConnectAgentBroker mtconnectAgent, object configuration) : base
}


protected override void OnStartBeforeLoad()
protected override void OnStartBeforeLoad(bool initializeDataItems)
{
_stop = new CancellationTokenSource();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public Module(IMTConnectAgentBroker mtconnectAgent, object configuration) : base
}


protected override void OnStartAfterLoad()
protected override void OnStartAfterLoad(bool initializeDataItems)
{
_stop = new CancellationTokenSource();

Expand Down
72 changes: 46 additions & 26 deletions agent/Modules/MTConnect.NET-AgentModule-ShdrAdapter/Module.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.

using MTConnect.Adapters;
Expand All @@ -8,13 +8,14 @@
using MTConnect.Devices.Components;
using MTConnect.Devices.DataItems;
using MTConnect.Logging;
using MTConnect.Observations.Events;
using System;
using System.Collections.Generic;
using System.Linq;

namespace MTConnect.Modules
{
public class Module : MTConnectAgentModule
public class Module : MTConnectAgentModule
{
public const string ConfigurationTypeId = "shdr-adapter";
private const string ModuleId = "SHDR Adapter";
Expand All @@ -33,7 +34,7 @@ public Module(IMTConnectAgentBroker mtconnectAgent, object configuration) : base
}


protected override void OnStartAfterLoad()
protected override void OnStartAfterLoad(bool initializeDataItems)
{
if (_configuration != null)
{
Expand All @@ -44,14 +45,12 @@ protected override void OnStartAfterLoad()
{
// Find Device matching DeviceKey
var device = devices.FirstOrDefault(o => o.Uuid == _configuration.DeviceKey || o.Name == _configuration.DeviceKey);
if (device != null) AddAdapter(_configuration, device);
//if (device != null) AddAdapter(_configuration, device, initializeDataItems);
if (device != null) AddAdapter(_configuration, device, initializeDataItems);
}
else
{
// Add Adapter for each Device (every device reads from the same adapter)
foreach (var device in devices) AddAdapter(_configuration, device, true, device.Id);
//foreach (var device in devices) AddAdapter(adapter, device, initializeDataItems, device.Id);
foreach (var device in devices) AddAdapter(_configuration, device, initializeDataItems, device.Id);
}
}
else if (_configuration.AllowShdrDevice) // Prevent accidental generic Adapter creation
Expand Down Expand Up @@ -90,20 +89,20 @@ private void AddAdapter(IShdrAdapterClientConfiguration configuration, IDevice d
{
if (configuration != null)
{
var adapterComponent = new ShdrAdapterComponent(configuration, idSuffix, device, device);
var adapterComponent = new ShdrAdapterComponent(configuration, idSuffix, _mtconnectAgent.Agent, _mtconnectAgent.Agent);

// Add Adapter Component to Agent Device
_mtconnectAgent.Agent.AddAdapterComponent(adapterComponent);

if (!adapterComponent.DataItems.IsNullOrEmpty())
if (configuration.OutputConnectionInformation)
{
// Initialize Adapter URI Observation
var adapterUriDataItem = adapterComponent.DataItems.FirstOrDefault(o => o.Type == AdapterUriDataItem.TypeId);
if (adapterUriDataItem != null && initializeDataItems)
{
_mtconnectAgent.AddObservation(_mtconnectAgent.Uuid, adapterUriDataItem.Id, adapterComponent.Uri);
}
}
// Initialize Adapter URI Observation
var adapterUriDataItem = adapterComponent.GetDataItemByType(AdapterUriDataItem.TypeId);
if (adapterUriDataItem != null && initializeDataItems)
{
_mtconnectAgent.AddObservation(adapterUriDataItem, adapterComponent.Uri);
}
}

// Create new SHDR Adapter Client to read from SHDR stream
var adapterClient = new ShdrAdapterClient(configuration, _mtconnectAgent, device, idSuffix);
Expand All @@ -117,18 +116,30 @@ private void AddAdapter(IShdrAdapterClientConfiguration configuration, IDevice d
adapterClient.PongReceived += AdapterPongReceived;
adapterClient.ProtocolReceived += AdapterProtocolReceived;

// Start the Adapter Client
adapterClient.Start();
}
// Set ConnectionStatus DataItem
var connectionStatusDataItem = _mtconnectAgent.Agent.GetDataItemByKey(DataItem.CreateId(adapterClient.Id, ConnectionStatusDataItem.NameId));
_mtconnectAgent.AddObservation(connectionStatusDataItem, ConnectionStatus.LISTEN);

// Start the Adapter Client
adapterClient.Start();
}
}


private void AdapterConnected(object sender, string message)
{
var adapterClient = (ShdrAdapterClient)sender;

var dataItemId = DataItem.CreateId(adapterClient.Id, ConnectionStatusDataItem.NameId);
_mtconnectAgent.AddObservation(_mtconnectAgent.Uuid, dataItemId, Observations.Events.ConnectionStatus.ESTABLISHED);
// Set ConnectionStatus DataItem
var connectionStatusDataItem = _mtconnectAgent.Agent.GetDataItemByKey(DataItem.CreateId(adapterClient.Id, ConnectionStatusDataItem.NameId));
_mtconnectAgent.AddObservation(connectionStatusDataItem, ConnectionStatus.ESTABLISHED);

// Set Availability (if AvailableOnConnection = TRUE)
if (_configuration.AvailableOnConnection)
{
var availabilityDataItem = adapterClient.Device.GetDataItemByType(AvailabilityDataItem.TypeId);
_mtconnectAgent.AddObservation(availabilityDataItem, Availability.AVAILABLE);
}

Log(MTConnectLogLevel.Information, $"ID = " + adapterClient.Id + " : " + message);
}
Expand All @@ -137,10 +148,18 @@ private void AdapterDisconnected(object sender, string message)
{
var adapterClient = (ShdrAdapterClient)sender;

var dataItemId = DataItem.CreateId(adapterClient.Id, ConnectionStatusDataItem.NameId);
_mtconnectAgent.AddObservation(_mtconnectAgent.Uuid, dataItemId, Observations.Events.ConnectionStatus.CLOSED);
// Set ConnectionStatus DataItem
var connectionStatusDataItem = _mtconnectAgent.Agent.GetDataItemByKey(DataItem.CreateId(adapterClient.Id, ConnectionStatusDataItem.NameId));
_mtconnectAgent.AddObservation(connectionStatusDataItem, ConnectionStatus.CLOSED);

Log(MTConnectLogLevel.Information, $"ID = " + adapterClient.Id + " : " + message);
// Set Availability (if AvailableOnConnection = TRUE)
if (_configuration.AvailableOnConnection)
{
var availabilityDataItem = adapterClient.Device.GetDataItemByType(AvailabilityDataItem.TypeId);
_mtconnectAgent.AddObservation(availabilityDataItem, Availability.UNAVAILABLE);
}

Log(MTConnectLogLevel.Information, $"ID = " + adapterClient.Id + " : " + message);
}

private void AdapterConnectionError(object sender, Exception exception)
Expand All @@ -153,8 +172,9 @@ private void AdapterListening(object sender, string message)
{
var adapterClient = (ShdrAdapterClient)sender;

var dataItemId = DataItem.CreateId(adapterClient.Id, ConnectionStatusDataItem.NameId);
_mtconnectAgent.AddObservation(_mtconnectAgent.Uuid, dataItemId, Observations.Events.ConnectionStatus.LISTEN);
// Set ConnectionStatus DataItem
var connectionStatusDataItem = _mtconnectAgent.Agent.GetDataItemByKey(DataItem.CreateId(adapterClient.Id, ConnectionStatusDataItem.NameId));
_mtconnectAgent.AddObservation(connectionStatusDataItem, ConnectionStatus.LISTEN);

Log(MTConnectLogLevel.Debug, $"ID = " + adapterClient.Id + " : " + message);
}
Expand Down
6 changes: 3 additions & 3 deletions build/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Reflection;

[assembly: AssemblyVersion("6.0.10")]
[assembly: AssemblyFileVersion("6.0.10")]
[assembly: AssemblyVersion("6.0.11")]
[assembly: AssemblyFileVersion("6.0.11")]
[assembly: AssemblyCompany("TrakHound Inc.")]
[assembly: AssemblyCopyright("Copyright (c) 2023 TrakHound Inc., All Rights Reserved.")]
[assembly: AssemblyCopyright("Copyright (c) 2024 TrakHound Inc., All Rights Reserved.")]
20 changes: 18 additions & 2 deletions build/MTConnect.NET-SysML-Import/CSharp/DataItemType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class DataItemType : MTConnectDataItemType, ITemplateModel
{
public string Namespace => NamespaceHelper.GetNamespace(Id);

public string DefaultName => Type.ToCamelCase();
public string DefaultName => GetName(Type);

public string UnitsEnum => Units != null ? $"Devices.{Units}" : null;

Expand Down Expand Up @@ -98,5 +98,21 @@ public virtual string RenderModel()
public string RenderInterface() => null;

public string RenderDescriptions() => null;
}


private static string GetName(string type)
{
switch (type)
{
case "EMERGENCY_STOP": return "estop";
case "CONTROLLER_MODE": return "mode";
case "EXECUTION": return "exec";
case "LOAD": return "load";
case "POSITION": return "pos";
case "TEMPERATURE": return "temp";
}

return type.ToCamelCase();
}
}
}
9 changes: 8 additions & 1 deletion build/MTConnect.NET-SysML-Import/CSharp/TemplateRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ public static void Render(MTConnectModel mtconnectModel, string outputPath)
if (typeof(MTConnectInterfaceDataItemType).IsAssignableFrom(type)) template = InterfaceDataItemType.Create((MTConnectInterfaceDataItemType)exportModel);
else if (typeof(MTConnectDataItemType).IsAssignableFrom(type)) template = DataItemType.Create((MTConnectDataItemType)exportModel);
else if (typeof(MTConnectCompositionType).IsAssignableFrom(type)) template = CompositionType.Create((MTConnectCompositionType)exportModel);
else if (typeof(MTConnectComponentType).IsAssignableFrom(type)) template = ComponentType.Create((MTConnectComponentType)exportModel);
else if (typeof(MTConnectComponentType).IsAssignableFrom(type))
{
if (((MTConnectComponentType)exportModel).Type == "Controllers") ((MTConnectComponentType)exportModel).MinimumVersion = new Version(1, 0);
template = ComponentType.Create((MTConnectComponentType)exportModel);
}
else if (typeof(MTConnectCuttingToolMeasurementModel).IsAssignableFrom(type)) template = CuttingToolMeasurementModel.Create((MTConnectCuttingToolMeasurementModel)exportModel);
else if (typeof(MTConnectClassModel).IsAssignableFrom(type)) template = ClassModel.Create((MTConnectClassModel)exportModel);
else if (typeof(MTConnectObservationModel).IsAssignableFrom(type)) template = ObservationModel.Create((MTConnectObservationModel)exportModel);
Expand Down Expand Up @@ -108,6 +112,9 @@ public static void Render(MTConnectModel mtconnectModel, string outputPath)
case "Devices.References.DataItemReference": ((ClassModel)template).HasDescriptions = false; break;
case "Devices.Units": ((EnumStringModel)template).IsPartial = true; break;

case "Devices.DataItems.ToolOffsetsDataItem": ((DataItemType)template).Representation = "TABLE"; break;
case "Devices.DataItems.WorkOffsetsDataItem": ((DataItemType)template).Representation = "TABLE"; break;

//case "Devices.DataItemResetTrigger": ((EnumModel)template).Values.Add(new MTConnectEnumValueModel { Name = "NONE" }); break;
//case "Devices.DataItemStatistic": ((EnumModel)template).Values.Add(new MTConnectEnumValueModel { Name = "NONE" }); break;
//case "Devices.Configurations.CriticalityType": ((EnumModel)template).Values.Add(new MTConnectEnumValueModel { Name = "NOT_SPECIFIED" }); break;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.

namespace MTConnect.Assets.CuttingTools.Measurements
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.

// MTConnect SysML v2.2 : UML ID = {{uml_id}}
Expand All @@ -19,6 +19,10 @@ namespace MTConnect.Devices.Components
{{ if (minimum_version_enum) }}public override System.Version MinimumVersion => {{minimum_version_enum}};{{ end }}


public {{name}}() { Type = TypeId; }
public {{name}}()
{
Type = TypeId;
Name = NameId;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
// TrakHound Inc. licenses this file to you under the MIT license.

namespace MTConnect.Devices.Compositions
Expand Down
Loading

0 comments on commit 280e0d8

Please sign in to comment.