Skip to content

Commit a96f124

Browse files
Updated to add the Validation header flag and EnableValidation Agent configuration parameter
1 parent 61a40a0 commit a96f124

12 files changed

Lines changed: 69 additions & 6 deletions

libraries/MTConnect.NET-Common/Agents/MTConnectAgentBroker.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
1+
// Copyright (c) 2025 TrakHound Inc., All Rights Reserved.
22
// TrakHound Inc. licenses this file to you under the MIT license.
33

44
using MTConnect.Assets;
@@ -467,9 +467,11 @@ private MTConnectDevicesHeader GetDevicesHeader(Version mtconnectVersion = null)
467467
InstanceId = InstanceId,
468468
Sender = Sender,
469469
Version = Version.ToString(),
470-
TestIndicator = false
470+
TestIndicator = false,
471+
Validation = Configuration.EnableValidation
471472
};
472473

474+
if (version < MTConnectVersions.Version25) header.Validation = false;
473475
if (version < MTConnectVersions.Version17) header.DeviceModelChangeTime = null;
474476
if (version < MTConnectVersions.Version12) header.AssetBufferSize = 0;
475477
if (version < MTConnectVersions.Version12) header.AssetCount = 0;
@@ -492,9 +494,11 @@ private MTConnectStreamsHeader GetStreamsHeader(IObservationBufferResults result
492494
FirstSequence = results.FirstSequence,
493495
LastSequence = results.LastSequence,
494496
NextSequence = results.NextSequence,
495-
TestIndicator = false
497+
TestIndicator = false,
498+
Validation = Configuration.EnableValidation
496499
};
497500

501+
if (version < MTConnectVersions.Version25) header.Validation = false;
498502
if (version < MTConnectVersions.Version17) header.DeviceModelChangeTime = null;
499503

500504
return header;
@@ -513,9 +517,11 @@ private MTConnectAssetsHeader GetAssetsHeader(Version mtconnectVersion = null)
513517
InstanceId = InstanceId,
514518
Sender = Sender,
515519
Version = Version.ToString(),
516-
TestIndicator = false
520+
TestIndicator = false,
521+
Validation = Configuration.EnableValidation
517522
};
518523

524+
if (version < MTConnectVersions.Version25) header.Validation = false;
519525
if (version < MTConnectVersions.Version17) header.DeviceModelChangeTime = null;
520526

521527
return header;

libraries/MTConnect.NET-Common/Configurations/AgentConfiguration.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
1+
// Copyright (c) 2025 TrakHound Inc., All Rights Reserved.
22
// TrakHound Inc. licenses this file to you under the MIT license.
33

44
using MTConnect.Agents;
@@ -94,6 +94,12 @@ public string DefaultVersionValue
9494
[JsonPropertyName("ignoreObservationCase")]
9595
public bool IgnoreObservationCase { get; set; }
9696

97+
/// <summary>
98+
/// Gets or Sets whether validation information is output
99+
/// </summary>
100+
[JsonPropertyName("enableValidation")]
101+
public bool EnableValidation { get; set; }
102+
97103
/// <summary>
98104
/// Gets or Sets the default Input (Observation or Asset) validation level. 0 = Ignore, 1 = Warning, 2 = Remove, 3 = Strict
99105
/// </summary>

libraries/MTConnect.NET-Common/Configurations/IAgentConfiguration.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
1+
// Copyright (c) 2025 TrakHound Inc., All Rights Reserved.
22
// TrakHound Inc. licenses this file to you under the MIT license.
33

44
using MTConnect.Agents;
@@ -49,6 +49,11 @@ public interface IAgentConfiguration
4949
/// </summary>
5050
bool IgnoreObservationCase { get; }
5151

52+
/// <summary>
53+
/// Gets or Sets whether validation information is output
54+
/// </summary>
55+
bool EnableValidation { get; }
56+
5257
/// <summary>
5358
/// Gets the default Input (Observation or Asset) validation level. 0 = Ignore, 1 = Warning, 2 = Remove, 3 = Strict
5459
/// </summary>

libraries/MTConnect.NET-Common/Headers/IMTConnectAssestsHeader.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ public interface IMTConnectAssetsHeader
4848
/// </summary>
4949
bool TestIndicator { get; }
5050

51+
/// <summary>
52+
/// Indicates if the MTConnect Agent is validating against the normative model.
53+
/// </summary>
54+
bool Validation { get; }
55+
5156
/// <summary>
5257
/// CreationTime represents the time that an Agent published the Response Document.
5358
/// </summary>

libraries/MTConnect.NET-Common/Headers/IMTConnectDevicesHeader.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ public interface IMTConnectDevicesHeader
5353
/// </summary>
5454
bool TestIndicator { get; }
5555

56+
/// <summary>
57+
/// Indicates if the MTConnect Agent is validating against the normative model.
58+
/// </summary>
59+
bool Validation { get; }
60+
5661
/// <summary>
5762
/// CreationTime represents the time that an Agent published the Response Document.
5863
/// </summary>

libraries/MTConnect.NET-Common/Headers/IMTConnectStreamsHeader.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ public interface IMTConnectStreamsHeader
6161
/// </summary>
6262
bool TestIndicator { get; }
6363

64+
/// <summary>
65+
/// Indicates if the MTConnect Agent is validating against the normative model.
66+
/// </summary>
67+
bool Validation { get; }
68+
6469
/// <summary>
6570
/// CreationTime represents the time that an Agent published the Response Document.
6671
/// </summary>

libraries/MTConnect.NET-Common/Headers/MTConnectAssestsHeader.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ public class MTConnectAssetsHeader : IMTConnectAssetsHeader
4848
/// </summary>
4949
public bool TestIndicator { get; set; }
5050

51+
/// <summary>
52+
/// Indicates if the MTConnect Agent is validating against the normative model.
53+
/// </summary>
54+
public bool Validation { get; set; }
55+
5156
/// <summary>
5257
/// CreationTime represents the time that an Agent published the Response Document.
5358
/// </summary>

libraries/MTConnect.NET-Common/Headers/MTConnectDevicesHeader.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ public class MTConnectDevicesHeader : IMTConnectDevicesHeader
5353
/// </summary>
5454
public bool TestIndicator { get; set; }
5555

56+
/// <summary>
57+
/// Indicates if the MTConnect Agent is validating against the normative model.
58+
/// </summary>
59+
public bool Validation { get; set; }
60+
5661
/// <summary>
5762
/// CreationTime represents the time that an Agent published the Response Document.
5863
/// </summary>

libraries/MTConnect.NET-Common/Headers/MTConnectStreamsHeader.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ public class MTConnectStreamsHeader : IMTConnectStreamsHeader
6161
/// </summary>
6262
public bool TestIndicator { get; set; }
6363

64+
/// <summary>
65+
/// Indicates if the MTConnect Agent is validating against the normative model.
66+
/// </summary>
67+
public bool Validation { get; set; }
68+
6469
/// <summary>
6570
/// CreationTime represents the time that an Agent published the Response Document.
6671
/// </summary>

libraries/MTConnect.NET-XML/Assets/XmlAssetsHeader.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ public class XmlAssetsHeader
3131
[XmlAttribute("testIndicator")]
3232
public bool TestIndicator { get; set; }
3333

34+
[XmlAttribute("validation")]
35+
public bool Validation { get; set; }
36+
3437
[XmlAttribute("creationTime")]
3538
public DateTime CreationTime { get; set; }
3639

@@ -45,6 +48,7 @@ public virtual IMTConnectAssetsHeader ToErrorHeader()
4548
header.AssetCount = AssetCount;
4649
header.DeviceModelChangeTime = DeviceModelChangeTime;
4750
header.TestIndicator = TestIndicator;
51+
header.Validation = Validation;
4852
header.CreationTime = CreationTime;
4953
return header;
5054
}
@@ -61,6 +65,7 @@ public static void WriteXml(XmlWriter writer, IMTConnectAssetsHeader header)
6165
writer.WriteAttributeString("assetCount", header.AssetCount.ToString());
6266
writer.WriteAttributeString("deviceModelChangeTime", header.DeviceModelChangeTime);
6367
if (header.TestIndicator) writer.WriteAttributeString("testIndicator", header.TestIndicator.ToString());
68+
if (header.Validation) writer.WriteAttributeString("validation", header.Validation.ToString());
6469
writer.WriteAttributeString("creationTime", header.CreationTime.ToString("o"));
6570
writer.WriteEndElement();
6671
}

0 commit comments

Comments
 (0)