-
Notifications
You must be signed in to change notification settings - Fork 0
Add TechnicalDataBuilder with ECLASS/IEC-61360 validation and Template Integration #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Freezor
merged 5 commits into
main
from
codex/implement-technicaldatabuilder-for-aas-project
Mar 28, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a7c7dd0
Add TechnicalDataBuilder with ECLASS-aware validation and tests
Freezor a99d976
Fix TechnicalData example to build environment from AasBuilder
Freezor 8bff9fa
Add descriptive XML docs for TechnicalData public API
Freezor 94e4c27
Move TechnicalData example to README and integration tests
Freezor fa95a87
Move TechnicalData composition example into integration tests
Freezor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
117 changes: 117 additions & 0 deletions
117
FluentAAS/FluentAAS.Templates.Tests/TechnicalData/TechnicalDataBuilderTests.cs
This file contains hidden or 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,117 @@ | ||
| using AasCore.Aas3_0; | ||
| using FluentAAS.Builder; | ||
| using FluentAAS.Templates.TechnicalData; | ||
| using Shouldly; | ||
|
|
||
| namespace FluentAAS.Templates.Tests.TechnicalData; | ||
|
|
||
| public class TechnicalDataBuilderTests | ||
| { | ||
| [Fact] | ||
| public void BuildTechnicalData_ShouldFail_WhenMandatoryParametersAreMissing() | ||
| { | ||
| var envBuilder = AasBuilder.Create(); | ||
| var shellBuilder = envBuilder.AddShell("urn:aas:example:shell:technical-data", "DriveShell"); | ||
|
|
||
| var sut = shellBuilder.AddTechnicalData("urn:aas:example:submodel:technical-data") | ||
| .WithMotorPerformance(motor => motor | ||
| .WithRatedVoltage(400m) | ||
| .WithRatedCurrent(82.5m)); | ||
|
|
||
| var ex = Record.Exception(() => sut.BuildTechnicalData()); | ||
|
|
||
| ex.ShouldBeOfType<InvalidOperationException>(); | ||
| ex.Message.ShouldContain("MotorPerformance.RatedPower"); | ||
| ex.Message.ShouldContain("MotorPerformance.RatedSpeed"); | ||
| ex.Message.ShouldContain("BearingCharacteristics.InnerDiameter"); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void BuildTechnicalData_ShouldFail_WhenUnitIsInvalid() | ||
| { | ||
| var envBuilder = AasBuilder.Create(); | ||
| var shellBuilder = envBuilder.AddShell("urn:aas:example:shell:technical-data", "DriveShell"); | ||
|
|
||
| var ex = Record.Exception(() => shellBuilder.AddTechnicalData("urn:aas:example:submodel:technical-data") | ||
| .WithMotorPerformance(motor => motor.WithRatedVoltage(400m, "mm"))); | ||
|
|
||
| ex.ShouldBeOfType<InvalidOperationException>(); | ||
| ex.Message.ShouldContain("Unit 'mm' is invalid for 'RatedVoltage'"); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void BuildTechnicalData_ShouldFail_WhenSemanticIdDoesNotMatchEclassCatalogEntry() | ||
| { | ||
| var envBuilder = AasBuilder.Create(); | ||
| var shellBuilder = envBuilder.AddShell("urn:aas:example:shell:technical-data", "DriveShell"); | ||
|
|
||
| var ex = Record.Exception(() => shellBuilder.AddTechnicalData("urn:aas:example:submodel:technical-data") | ||
| .WithMotorPerformance(motor => motor.WithRatedVoltage(400m, "V", TechnicalDataSemantics.RatedCurrent))); | ||
|
|
||
| ex.ShouldBeOfType<InvalidOperationException>(); | ||
| ex.Message.ShouldContain("Semantic ID mismatch for 'RatedVoltage'"); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void BuildTechnicalData_ShouldCreateStructuredGroups_WithEclassSemanticIds() | ||
| { | ||
| var envBuilder = AasBuilder.Create(); | ||
| var shellBuilder = envBuilder.AddShell("urn:aas:example:shell:technical-data", "DriveShell"); | ||
|
|
||
| shellBuilder.AddTechnicalData("urn:aas:example:submodel:technical-data") | ||
| .WithMotorPerformance(motor => motor | ||
| .WithRatedVoltage(400m, "V", TechnicalDataSemantics.RatedVoltage) | ||
| .WithRatedCurrent(82.5m, "A", TechnicalDataSemantics.RatedCurrent) | ||
| .WithRatedPower(45m, "kW", TechnicalDataSemantics.RatedPower) | ||
| .WithRatedSpeed(1470m, "1/min", TechnicalDataSemantics.RatedSpeed)) | ||
| .WithBearingCharacteristics(bearing => bearing | ||
| .WithInnerDiameter(50m, "mm", TechnicalDataSemantics.InnerDiameter) | ||
| .WithOuterDiameter(90m, "mm", TechnicalDataSemantics.OuterDiameter) | ||
| .WithWidth(20m, "mm", TechnicalDataSemantics.Width) | ||
| .WithLimitingSpeed(6500m, "1/min", TechnicalDataSemantics.LimitingSpeed)) | ||
| .BuildTechnicalData(); | ||
|
|
||
| var env = envBuilder.Build(); | ||
|
|
||
| var submodel = env.Submodels!.Single(sm => sm.Id == "urn:aas:example:submodel:technical-data"); | ||
| submodel.SemanticId!.Keys.Single().Value.ShouldBe(TechnicalDataSemantics.SubmodelTechnicalData); | ||
|
|
||
| var motorGroup = submodel.SubmodelElements! | ||
| .OfType<SubmodelElementCollection>() | ||
| .Single(x => x.IdShort == TechnicalDataIdentifiers.MotorPerformance); | ||
|
|
||
| var ratedVoltage = motorGroup.Value! | ||
| .OfType<Property>() | ||
| .Single(x => x.IdShort == TechnicalDataIdentifiers.RatedVoltage); | ||
|
|
||
| ratedVoltage.Value.ShouldBe("400"); | ||
| ratedVoltage.Category.ShouldBe("V"); | ||
| ratedVoltage.SemanticId!.Keys.Single().Value.ShouldBe(TechnicalDataSemantics.RatedVoltage); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void InlineComposition_ShouldBuildEnvironment() | ||
| { | ||
| var envBuilder = AasBuilder.Create(); | ||
| envBuilder.AddShell("urn:aas:example:drivetrain:1000", "DriveTrainAAS") | ||
| .AddTechnicalData("urn:aas:submodel:technical-data:drivetrain:1000") | ||
| .WithMotorPerformance(motor => motor | ||
| .WithRatedVoltage(400m, "V", TechnicalDataSemantics.RatedVoltage) | ||
| .WithRatedCurrent(82.5m, "A", TechnicalDataSemantics.RatedCurrent) | ||
| .WithRatedPower(45m, "kW", TechnicalDataSemantics.RatedPower) | ||
| .WithRatedSpeed(1470m, "1/min", TechnicalDataSemantics.RatedSpeed)) | ||
| .WithBearingCharacteristics(bearing => bearing | ||
| .WithInnerDiameter(50m, "mm", TechnicalDataSemantics.InnerDiameter) | ||
| .WithOuterDiameter(90m, "mm", TechnicalDataSemantics.OuterDiameter) | ||
| .WithWidth(20m, "mm", TechnicalDataSemantics.Width) | ||
| .WithLimitingSpeed(6500m, "1/min", TechnicalDataSemantics.LimitingSpeed)) | ||
| .BuildTechnicalData(); | ||
|
|
||
| var env = envBuilder.Build(); | ||
|
|
||
| env.AssetAdministrationShells.ShouldNotBeNull(); | ||
| env.AssetAdministrationShells!.Count.ShouldBe(1); | ||
| env.Submodels.ShouldNotBeNull(); | ||
| env.Submodels!.Count.ShouldBe(1); | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: Freezor/FluentAAS
Length of output: 3003
🌐 Web query:
AAS 3.0 Property Category field usage and IEC 61360 unit storage💡 Result:
In AAS 3.0, the 'category' field is defined in the Referable abstract class, inherited by elements like Property. It provides meta-information about the element's class, affecting expected attributes and constraints (e.g., distinguishing measurement values). It is optional (string type, default null) and deprecated since V3.0, though still present for backward compatibility. Legacy values include PARAMETER, CONSTANT, VALUE for data elements like Properties, influencing validation (e.g., in ConceptDescription constraints referencing category, marked deprecated). IEC 61360 units for quantitative properties (e.g., dataType INTEGER_MEASURE, REAL_MEASURE) are stored in ConceptDescriptions via the DataSpecificationIec61360 template, using 'unit' (string, primary unit text) or 'unitId' (Reference to global unit identifier, e.g., IRDI). These are embedded in the semanticId-referenced ConceptDescription of the Property, not directly in the Property.value. Constraint AASc-3a-009 requires unit/unitId for measure types. The Property.valueType maps IEC data types to XSD (e.g., xs:integer for INTEGER_MEASURE).
Citations:
Remove Category field usage for unit storage; use ConceptDescription's DataSpecificationIec61360 instead.
The test asserts
ratedVoltage.Category.ShouldBe("V"), but in AAS 3.0, theCategoryfield is deprecated and meant for element classification (e.g., PARAMETER, CONSTANT, VALUE). Units should be stored in the ConceptDescription'sDataSpecificationIec61360template via theunitfield, not in the Property'sCategoryfield. This applies to the builder implementation as well (TechnicalDataBuilder.cs:95).🤖 Prompt for AI Agents