mirror of
https://github.com/OPCFoundation/UA-.NETStandard.git
synced 2026-10-26 04:19:53 +08:00
# Description Implements the **Asset Administration Shell** companion specifications on top of `marcschier/wot-type-binding`, in two halves that a Server chooses between: * **AAS V3** — the [draft](https://github.com/marcschier/opcua-drafts/tree/main/companion-specs/AAS) (`http://opcfoundation.org/UA/I4AAS/v3/`), all sixteen conformance units: the metamodel, the registry built on the abstract xRegistry base, generational materialization, federation, packages with digest-bound integrity, the Digital Product Passport vocabulary, and the Annex F bridge to WoT Thing Descriptions. * **AAS V2** — the published [OPC 30270](https://reference.opcfoundation.org/specs/OPC-30270/full) (`http://opcfoundation.org/UA/I4AAS/`), which maps the AAS V2.0.1 metamodel: object model, ingestion of XML, JSON and AASX, materialization, server and client. The two are different metamodel generations rather than two revisions of one model — V2 keeps `Asset` as a first-class Identifiable, `identification.idType`, Views and ordered collections, none of which survive into V3 — so they are **alternatives**. A Server hosts one or the other; this is documented rather than enforced at startup. Each is named for the generation it maps (`Opc.Ua.Aas.V2`, `Opc.Ua.Aas.V3`, `AddAasV2Server`, `AddAasV3Server`), and what genuinely serves both carries no marker and sits at the root of `Opc.Ua.Aas`: the deterministic NodeId encoding and idShortPath conventions, `AasOptional<T>`, the digest rule, the materialization diagnostics, the AASX container walk, and the value and operation providers, which are keyed on `NodeId` and `Variant` and so carry no version at all. ## What is in here **New libraries**: `Opc.Ua.Aas`, `Opc.Ua.Aas.Server`, `Opc.Ua.Aas.Client`, `Opc.Ua.Aas.WoT`, plus `samples/Aas` and `docs/Aas.md`. **Enabling changes to existing code**, each needed by the above: * The OPC UA `Decimal` DataType added to `Opc.Ua.Types`, with its Part 6 §5.1.10 wire encoding. `BinaryDecoder` gained one internal member, `TryReadRemainingBodyBytes`, because a trailing field with no self-describing length cannot otherwise be read; `Decimal.Decode` is its only caller. Part 6 Table 3 types the unscaled `Value` as an **OctetString whose byte count is `Length` − 2**, not a length-prefixed `ByteString`, so it carries no length of its own — `DecimalEncodingTests` pins the body byte-for-byte against that mistake, and against the `Length ≤ 2` values the same table calls invalid. * The xRegistry projection engine extracted into `Opc.Ua.XRegistry.Server` and `Opc.Ua.WotCon.Server` migrated onto it (−848/+387 lines), with the WoT Connectivity tests passing **unedited**. * Two source-generator fixes, both of which made a model impossible to build (see below). ## Defects found and fixed along the way Running the stack end to end, rather than trusting per-area test suites, surfaced defects that no unit test caught. The ones worth a maintainer's attention: * **The generator emitted non-terminating constructors.** A structure field with no declared default was initialized with `new T()`, so a self-referential DataType (`AASReferenceDataType.referredSemanticId`) recursed until the stack overflowed and `AddOpcUaAas` could not load the model at all. The test host *died* rather than failing. Only the field that closes a cycle is now left null. * **The generator omitted `new` on a redeclared placeholder.** `AASOrderedSubmodelElementCollectionType` redeclares the `SubmodelElement` slot of its base type, and the generated `Add` method hid the base one without saying so, so the V2 model would not compile. No existing model could have hit either defect — both are build failures, so anything that builds today is unaffected. * **The metamodel half had never worked outside its unit tests**: the emitted NodeSet declared no reference-type aliases and was rejected by the loader; the Mandatory `Invoke` Method was never emitted, because a NodeSet is imported as written rather than instantiated from its type; the runtime bound at the authored namespace index instead of the one the Server assigns; and `MethodDeclarationId` was addressed in the wrong namespace. Every materializer test inspected the in-memory object graph, which cannot see whether the graph is loadable — two tests now import it exactly as `RuntimeNodeSetNodeManager` does. * **The client could not see any Property member.** It browsed `HasComponent` with subtypes, but `HasProperty` is a sibling under `Aggregates`, so reading a value failed and invoking failed argument validation. * **Every repeated registry write forked a duplicate group and resource** instead of adding a version, because the identifier was re-derived against a sibling set that already contained the entity itself. This also made the persistence bounds unreachable. * `.gitignore`'s `**/packages/*` silently swallowed the whole package-integrity implementation and its tests, which would have vanished on a fresh clone. ## Specification findings Nine findings against the V3 draft are fixed in [marcschier/opcua-drafts#75](https://github.com/marcschier/opcua-drafts/pull/75). The substantive one: clause 6.1.5's absent-versus-empty rule was **unsatisfiable** for five container fields that materialize as parent components with no node of their own, which made `AAS-LosslessRoundTrip` unachievable. OPC 30270 contradicts itself twice. Both are recorded in `AasV2ConformanceUnits.cs` and the documentation rather than smoothed over: Table 83 spells the unit `I4AAS MultiLangaugeProperty` where Table 85 spells it correctly, and Table 85 lists an `I4AAS Security` unit that Table 83 never defines. Table 84, which would assign profile URIs, is empty, so `ServerProfileArray` gains no I4AAS entry. ## Known limitation Calling an `Operation` **with arguments** answers `BadTooManyArguments`. Method resolution works from both the instance NodeId and the `MethodDeclarationId`, and the argument definitions are published, but `NodeState.AddChild` does not route through `MethodState.FindChild`, so a Method imported from a NodeSet leaves its typed `InputArguments` null. Closing this means changing how the shared NodeSet import claims typed children, which affects every consumer of runtime NodeSets and is out of scope here. It is documented in `docs/Aas.md` §11, the conformance matrix marks `AAS-OperationInvoke` partial rather than claiming it, and `samples/Aas` exercises the path and reports the status rather than working around it. V2 is unaffected — its `Operation` is an OptionalPlaceholder with no declared arguments. ## Related Issues - No tracking issue yet. Opening as a **draft** for design discussion first, per the ADR guidance below; happy to open one and link it once the shape is agreed. ## Checklist - [x] I have signed the [CLA](https://opcfoundation.org/license/cla/ContributorLicenseAgreementv1.0.pdf) and read the [CONTRIBUTING](https://github.com/OPCFoundation/UA-.NETStandard/blob/master/CONTRIBUTING.md) doc. - [x] I have added tests that prove my fix is effective or that my feature works and increased code coverage. - [x] I have added all necessary documentation. - [x] I have verified that my changes do not introduce (new) build or analyzer warnings. - [x] I ran **all** tests locally using the **UA.slnx** solution against at least .net **framework** and .net **10**, and all passed. - [ ] I fixed **all** failing and flaky tests in the CI pipelines and **all** CodeQL warnings. - [ ] I have addressed **all** PR feedback received. ### Verification | Check | Result | |---|---| | AAS tests | **670 passed, 0 failed** on net472, net48, net8.0, net9.0, net10.0 | | Coverage | Client 80.8 %, Server 81.2 %, `Opc.Ua.Aas` 82.0 %, WoT 82.4 % — all above the 80 % gate | | Libraries | `Opc.Ua.Aas`, `.Server`, `.Client`, `.WoT` build clean on every target framework, zero warnings | | Regression | `Opc.Ua.Types` 8677, `Opc.Ua.WotCon` 1094, `Opc.Ua.XRegistry` 198, `Opc.Ua.Server` 4050 — all green | | Sample | `samples/Aas` builds warning-free and runs end to end | | Merge validation | Solution builds clean on net10.0 and net48; WoT Types 504, WotCon 1111, AAS 670, XRegistry 198 tests passed | | CI | All 99 checks green on `ff9298e44`; only the CLA signature status is outstanding | ### Review pass A full review against both specifications, and for API consistency and correctness, produced twelve fixes. Each one has a test that fails without it. | Defect | Where | Why it mattered | |---|---|---| | V2 projection aborted on **every** `File` read from a document | `AasV2EnvironmentRuntime` | The runtime bound `File/Value` unconditionally, the materializer emitted it only with content, and the builder throws `BadNotFound` for an unknown NodeId — aborting the whole registration. No reader ever populates `AasFile.File`, so no AAS V2 document could be hosted at all. | | `aas-suppl` anchored on the wrong part | `AasxPackageReaderCore`, `AasxPackageWriter` | IDTA and the Package Explorer anchor it on the environment part; we used the origin part. Every real `.aasx` returned zero supplementary files, silently. Affects both halves. | | Federation failed closed on pooled connections | `AasFederation` | `ConnectCallback` fires only for new connections, so the second fetch to an origin — and all of net472/net48/netstandard2.1 — failed with a security-flavoured error. The peer is now validated *inside* the callback, which makes reuse safe by construction. | | Malformed `Decimal` escaped as `ArgumentOutOfRangeException` | `BinaryDecoder` | A declared body shorter than `Scale` produced a negative read length. Two of the three test cases had been passing for the wrong reason. | | V2 and V3 cross-wired their value providers | `OpcUaAasServerBuilderExtensions` | Both registered `IAasValueProvider`; whichever was added first served both AddressSpaces. V2 now has its own contract, so co-hosting is harmless rather than silently wrong. `EnvironmentFolder` was also bound and ignored on the V2 path. | | Export filter skipped three nesting kinds | `AasEnvironmentExporter` | Content under `Entity`, `AnnotatedRelationshipElement` and `Operation` was exported unevaluated *and* stamped with a Digest presenting it as complete (clause 6.5.10). List authorization paths also shifted after a denial. | | Concealment held at the Method but not in the projection | `AasRegistryModel` | `GetSubmodel` answered `BadNotFound` while an anonymous Browse revealed the node, its identifier, semanticId and digest (clause 6.5.7). | | File handles were unsynchronized and unowned | `AasElementFileManager` | The async node manager holds no lock, so concurrent Calls raced a bare `Dictionary`; sequential handles let any Session read, seek or commit another's. Writes were also unbounded. | | Projection host was unimplementable outside the stack | `AasEnvironmentProjection` | The handle demanded a type with an internal constructor — our own tests used `FormatterServices.GetUninitializedObject` to get round it. Now mirrors WotCon's interface-typed registration. | | Embedded `FileType` omitted 7 of 10 Mandatory members | `AasEnvironmentMaterializer` (V2) | OPC 10000-3 6.4.4 requires them all; without `Size` and `OpenCount` a Client cannot size a read or detect an abandoned handle. | | Round-trip oracle ignored most of the model | `AasRoundTripComparer` | `Blob`, `File`, `ReferenceElement` and `BasicEventElement` had no case arm, so their fields compared equal by falling off the switch; `valueType`, `semanticId`, `entityType` and `Key.type` were never read. The clause 6.4 losslessness claim rested on it. | Known, unchanged: calling an `Operation` with arguments answers `BadTooManyArguments`, because `NodeState.AddChild` does not route through `MethodState.FindChild`. Documented in `docs/Aas.md` §11. Not addressed in this pass, and worth a maintainer decision: OPC 30270 §9.2 says all NodeIds of Nodes not defined in the companion specification **shall not** use the standard namespaces, and Table 87 marks a vendor-specific instance namespace Mandatory. Both halves currently mint instances in the companion namespace. Separating them touches NodeId minting, the runtime and the client together, so it is better done deliberately than folded into a review pass. This is a large change and touches shared code (`Opc.Ua.Types`, the source generator, the xRegistry projection). It is deliberately a draft: the enabling changes are separable if maintainers would prefer them split into their own PRs. The latest `master` is merged into this branch in `0dd0ff0e1`. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9e6a5abf-3299-4cd1-9855-010fedbf0ad8 Copilot-Session: c3d88950-4a65-4ff6-87d2-1f545a875c9b Copilot-Session: b8ab3763-b9bd-46ae-b0ef-045db26e5782
422 lines
17 KiB
C#
422 lines
17 KiB
C#
/* ========================================================================
|
|
* Copyright (c) 2005-2026 The OPC Foundation, Inc. All rights reserved.
|
|
*
|
|
* OPC Foundation MIT License 1.00
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person
|
|
* obtaining a copy of this software and associated documentation
|
|
* files (the "Software"), to deal in the Software without
|
|
* restriction, including without limitation the rights to use,
|
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following
|
|
* conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be
|
|
* included in all copies or substantial portions of the Software.
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
*
|
|
* The complete license agreement can be found here:
|
|
* http://opcfoundation.org/License/MIT/1.00/
|
|
* ======================================================================*/
|
|
|
|
using Opc.Ua.Aas.V3;
|
|
using System;
|
|
using System.IO;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Opc.Ua;
|
|
using Opc.Ua.Aas;
|
|
using Opc.Ua.Aas.Server.Materialization;
|
|
using Opc.Ua.Aas.Server.Packaging;
|
|
using Opc.Ua.Aas.Server.Registry;
|
|
|
|
namespace AasSample
|
|
{
|
|
/// <summary>
|
|
/// Creates the small AAS environment, registry documents, and DPP metadata used by the sample.
|
|
/// </summary>
|
|
public static class AasSampleData
|
|
{
|
|
/// <summary>
|
|
/// The materialized AAS instance namespace exposed by the sample server.
|
|
/// </summary>
|
|
public const string InstanceNamespaceUri = "urn:opcfoundation.org:UA:AasSample:BatteryPassport";
|
|
|
|
/// <summary>
|
|
/// The sample Asset Administration Shell identifier.
|
|
/// </summary>
|
|
public const string ShellId = "urn:opcfoundation:sample:aas:battery-pack:0001";
|
|
|
|
/// <summary>
|
|
/// The nameplate submodel identifier.
|
|
/// </summary>
|
|
public const string NameplateSubmodelId = "urn:opcfoundation:sample:submodel:nameplate:0001";
|
|
|
|
/// <summary>
|
|
/// The battery passport submodel identifier.
|
|
/// </summary>
|
|
public const string PassportSubmodelId = "urn:opcfoundation:sample:submodel:battery-passport:0001";
|
|
|
|
/// <summary>
|
|
/// The published package identifier.
|
|
/// </summary>
|
|
public const string PackageId = "urn:opcfoundation:sample:aasx:battery-passport:0001";
|
|
|
|
/// <summary>
|
|
/// Creates the complete sample data set.
|
|
/// </summary>
|
|
public static async ValueTask<AasSampleDataset> CreateAsync(CancellationToken cancellationToken)
|
|
{
|
|
AasDppIdentifierResult carbonFootprint = AasDppIdentifier.Construct("0173-1#02-AAO677#002");
|
|
AasDisclosureDecision passportDisclosure = AasDppDisclosurePolicy.Map(
|
|
AasDppRegulatoryClass.AvailableToPublic);
|
|
AasDisclosureDecision controlledDisclosure = AasDppDisclosurePolicy.Map(
|
|
AasDppRegulatoryClass.LegitimateInterestAndCommission);
|
|
AasSubmodel nameplate = CreateNameplateSubmodel();
|
|
AasSubmodel passport = CreatePassportSubmodel(carbonFootprint.Iri);
|
|
AasConceptDescription concept = new()
|
|
{
|
|
Id = carbonFootprint.Iri,
|
|
IdShort = Present("CarbonFootprintConcept")
|
|
};
|
|
AasEnvironment environment = new()
|
|
{
|
|
AssetAdministrationShells = Present(new ArrayOf<AasShell>(new[]
|
|
{
|
|
new AasShell
|
|
{
|
|
Id = ShellId,
|
|
IdShort = Present("BatteryPack0001"),
|
|
AssetInformation = new AasAssetInformation
|
|
{
|
|
AssetKind = AASAssetKindDataType.Instance,
|
|
GlobalAssetId = Present("urn:epc:id:sgtin:0614141.107346.0001"),
|
|
SpecificAssetIds = Present(new ArrayOf<AASSpecificAssetIdDataType>(new[]
|
|
{
|
|
SpecificAssetId("serialNumber", "BP-2026-0001"),
|
|
SpecificAssetId("manufacturerPartId", "BATT-MODULE-42")
|
|
}))
|
|
}
|
|
}
|
|
})),
|
|
Submodels = Present(new ArrayOf<AasSubmodel>(new[] { nameplate, passport })),
|
|
ConceptDescriptions = Present(new ArrayOf<AasConceptDescription>(new[] { concept }))
|
|
};
|
|
|
|
ByteString environmentDocument = await WriteEnvironmentAsync(environment, cancellationToken)
|
|
.ConfigureAwait(false);
|
|
ByteString nameplateDocument = await WriteEnvironmentAsync(
|
|
new AasEnvironment { Submodels = Present(new ArrayOf<AasSubmodel>(new[] { nameplate })) },
|
|
cancellationToken).ConfigureAwait(false);
|
|
ByteString passportDocument = await WriteEnvironmentAsync(
|
|
new AasEnvironment { Submodels = Present(new ArrayOf<AasSubmodel>(new[] { passport })) },
|
|
cancellationToken).ConfigureAwait(false);
|
|
ByteString conceptDocument = await WriteEnvironmentAsync(
|
|
new AasEnvironment
|
|
{
|
|
ConceptDescriptions = Present(new ArrayOf<AasConceptDescription>(new[] { concept }))
|
|
},
|
|
cancellationToken).ConfigureAwait(false);
|
|
ByteString package = ByteString.From(Encoding.UTF8.GetBytes(
|
|
"AASX placeholder package for the AAS V3 battery passport sample."));
|
|
string packageDigest = AasPackageIntegrity.ComputeDigest(package, AasPackageIntegrity.Sha256);
|
|
|
|
return new AasSampleDataset(
|
|
environment,
|
|
environmentDocument,
|
|
RegistryRequests(
|
|
nameplateDocument,
|
|
passportDocument,
|
|
conceptDocument,
|
|
package,
|
|
passportDisclosure,
|
|
controlledDisclosure,
|
|
packageDigest),
|
|
MaterializationDocuments(environmentDocument),
|
|
carbonFootprint,
|
|
passportDisclosure,
|
|
controlledDisclosure,
|
|
package,
|
|
packageDigest);
|
|
}
|
|
|
|
private static ArrayOf<AasUpsertResourceRequest> RegistryRequests(
|
|
ByteString nameplateDocument,
|
|
ByteString passportDocument,
|
|
ByteString conceptDocument,
|
|
ByteString package,
|
|
AasDisclosureDecision passportDisclosure,
|
|
AasDisclosureDecision controlledDisclosure,
|
|
string packageDigest)
|
|
{
|
|
return new AasUpsertResourceRequest[]
|
|
{
|
|
SubmodelRequest(
|
|
NameplateSubmodelId,
|
|
"Battery nameplate",
|
|
nameplateDocument,
|
|
AASDisclosureTierDataType.Public,
|
|
string.Empty),
|
|
SubmodelRequest(
|
|
PassportSubmodelId,
|
|
"EU battery passport",
|
|
passportDocument,
|
|
passportDisclosure.Tier,
|
|
passportDisclosure.Authorization),
|
|
new()
|
|
{
|
|
GroupSourceIdentity = "urn:opcfoundation:sample:concept-dictionary:battery-passport",
|
|
ResourceSourceIdentity = "https://rdf.eclass.eu/resource/0173-1_02-AAO677_002",
|
|
GroupKind = AasRegistryEntityKind.ConceptDictionary,
|
|
ResourceKind = AasRegistryEntityKind.ConceptDescription,
|
|
Name = "Carbon footprint concept",
|
|
Content = conceptDocument
|
|
},
|
|
new()
|
|
{
|
|
GroupSourceIdentity = "urn:opcfoundation:sample:package-store:battery-passports",
|
|
ResourceSourceIdentity = PackageId,
|
|
GroupKind = AasRegistryEntityKind.PackageStore,
|
|
ResourceKind = AasRegistryEntityKind.Package,
|
|
Name = "Battery passport AASX package",
|
|
Content = package,
|
|
Format = "aasx/3.0",
|
|
ContentType = "application/asset-administration-shell-package+xml",
|
|
Description = "Digest " + packageDigest,
|
|
DisclosureTier = controlledDisclosure.Tier,
|
|
Authorization = Authorization(controlledDisclosure.Authorization)
|
|
}
|
|
}.ToArrayOf();
|
|
}
|
|
|
|
private static AasUpsertResourceRequest SubmodelRequest(
|
|
string submodelId,
|
|
string name,
|
|
ByteString content,
|
|
AASDisclosureTierDataType tier,
|
|
string authorization)
|
|
{
|
|
return new AasUpsertResourceRequest
|
|
{
|
|
GroupSourceIdentity = ShellId,
|
|
ResourceSourceIdentity = submodelId,
|
|
GroupKind = AasRegistryEntityKind.Shell,
|
|
ResourceKind = AasRegistryEntityKind.Submodel,
|
|
Name = name,
|
|
Content = content,
|
|
DisclosureTier = tier,
|
|
Authorization = Authorization(authorization),
|
|
SpecificAssetIds = new AasRegistryAssetLink[]
|
|
{
|
|
new() { Name = "serialNumber", Value = "BP-2026-0001" },
|
|
new() { Name = "manufacturerPartId", Value = "BATT-MODULE-42" }
|
|
}.ToArrayOf()
|
|
};
|
|
}
|
|
|
|
private static ArrayOf<AasMaterializationDocument> MaterializationDocuments(ByteString environmentDocument)
|
|
{
|
|
return new AasMaterializationDocument[]
|
|
{
|
|
new()
|
|
{
|
|
Xid = "battery-passport-environment",
|
|
VersionId = "v1",
|
|
SourceIdentity = ShellId,
|
|
Kind = AasMaterializationDocumentKind.Environment,
|
|
Content = environmentDocument,
|
|
Format = "aas/3.0+json"
|
|
}
|
|
}.ToArrayOf();
|
|
}
|
|
|
|
private static AasSubmodel CreateNameplateSubmodel()
|
|
{
|
|
return new AasSubmodel
|
|
{
|
|
Id = NameplateSubmodelId,
|
|
IdShort = Present("Nameplate"),
|
|
SubmodelElements = Present(new AasSubmodelElement[]
|
|
{
|
|
Property("ManufacturerName", AASDataTypeDefXsdDataType.String, "Contoso Battery Systems"),
|
|
Property("SerialNumber", AASDataTypeDefXsdDataType.String, "BP-2026-0001")
|
|
}.ToArrayOf())
|
|
};
|
|
}
|
|
|
|
private static AasSubmodel CreatePassportSubmodel(string carbonFootprintSemanticId)
|
|
{
|
|
return new AasSubmodel
|
|
{
|
|
Id = PassportSubmodelId,
|
|
IdShort = Present("BatteryPassport"),
|
|
SubmodelElements = Present(new AasSubmodelElement[]
|
|
{
|
|
Property("PassportIdentifier", AASDataTypeDefXsdDataType.String, "DPP-BP-2026-0001"),
|
|
Property(
|
|
"CarbonFootprint",
|
|
AASDataTypeDefXsdDataType.String,
|
|
"87.4",
|
|
Reference(carbonFootprintSemanticId)),
|
|
Property("StateOfHealth", AASDataTypeDefXsdDataType.Double, 98.2d),
|
|
Property("DisclosureClass", AASDataTypeDefXsdDataType.String, "available to the public"),
|
|
new AasOperation
|
|
{
|
|
IdShort = Present("RecalculatePassport"),
|
|
InputVariables = Present(new AasSubmodelElement[]
|
|
{
|
|
Property("Reason", AASDataTypeDefXsdDataType.String, "operator-request")
|
|
}.ToArrayOf()),
|
|
OutputVariables = Present(new AasSubmodelElement[]
|
|
{
|
|
Property("Result", AASDataTypeDefXsdDataType.String, "pending")
|
|
}.ToArrayOf())
|
|
}
|
|
}.ToArrayOf())
|
|
};
|
|
}
|
|
|
|
private static AasProperty Property(
|
|
string idShort,
|
|
AASDataTypeDefXsdDataType valueType,
|
|
Variant value,
|
|
AASReferenceDataType? semanticId = null)
|
|
{
|
|
return new AasProperty
|
|
{
|
|
IdShort = Present(idShort),
|
|
ValueType = valueType,
|
|
Value = Present(value),
|
|
SemanticId = semanticId is null ? default : Present(semanticId)
|
|
};
|
|
}
|
|
|
|
private static AASSpecificAssetIdDataType SpecificAssetId(string name, string value)
|
|
{
|
|
return new AASSpecificAssetIdDataType { Name = name, Value = value };
|
|
}
|
|
|
|
private static AASReferenceDataType Reference(string value)
|
|
{
|
|
return new AASReferenceDataType
|
|
{
|
|
Type = AASReferenceTypesDataType.ExternalReference,
|
|
Keys = new AASKeyDataType[]
|
|
{
|
|
new() { Type = AASKeyTypesDataType.GlobalReference, Value = value }
|
|
}.ToArrayOf()
|
|
};
|
|
}
|
|
|
|
private static ArrayOf<AASAuthorizationOptionDataType> Authorization(string authorization)
|
|
{
|
|
return string.IsNullOrEmpty(authorization)
|
|
? ArrayOf<AASAuthorizationOptionDataType>.Empty
|
|
: new AASAuthorizationOptionDataType[]
|
|
{
|
|
new() { Type = "DPP", ResourceUri = authorization }
|
|
}.ToArrayOf();
|
|
}
|
|
|
|
private static AasOptional<T> Present<T>(T value) where T : notnull
|
|
{
|
|
return AasOptional<T>.Present(value);
|
|
}
|
|
|
|
private static async ValueTask<ByteString> WriteEnvironmentAsync(
|
|
AasEnvironment environment,
|
|
CancellationToken cancellationToken)
|
|
{
|
|
using var stream = new MemoryStream();
|
|
await new AasJsonWriter().WriteAsync(stream, environment, cancellationToken).ConfigureAwait(false);
|
|
return ByteString.From(stream.ToArray());
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Complete sample data produced before the server starts.
|
|
/// </summary>
|
|
public sealed class AasSampleDataset
|
|
{
|
|
/// <summary>
|
|
/// Initializes the sample data set.
|
|
/// </summary>
|
|
public AasSampleDataset(
|
|
AasEnvironment environment,
|
|
ByteString environmentDocument,
|
|
ArrayOf<AasUpsertResourceRequest> registryRequests,
|
|
ArrayOf<AasMaterializationDocument> materializationDocuments,
|
|
AasDppIdentifierResult carbonFootprintIdentifier,
|
|
AasDisclosureDecision passportDisclosure,
|
|
AasDisclosureDecision controlledDisclosure,
|
|
ByteString package,
|
|
string packageDigest)
|
|
{
|
|
Environment = environment;
|
|
EnvironmentDocument = environmentDocument;
|
|
RegistryRequests = registryRequests;
|
|
MaterializationDocuments = materializationDocuments;
|
|
CarbonFootprintIdentifier = carbonFootprintIdentifier;
|
|
PassportDisclosure = passportDisclosure;
|
|
ControlledDisclosure = controlledDisclosure;
|
|
Package = package;
|
|
PackageDigest = packageDigest;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the AAS environment used for metamodel materialization.
|
|
/// </summary>
|
|
public AasEnvironment Environment { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the serialized complete AAS environment.
|
|
/// </summary>
|
|
public ByteString EnvironmentDocument { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the registry seed requests.
|
|
/// </summary>
|
|
public ArrayOf<AasUpsertResourceRequest> RegistryRequests { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the coordinator document set.
|
|
/// </summary>
|
|
public ArrayOf<AasMaterializationDocument> MaterializationDocuments { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the DPP semantic identifier construction result.
|
|
/// </summary>
|
|
public AasDppIdentifierResult CarbonFootprintIdentifier { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the passport disclosure mapping.
|
|
/// </summary>
|
|
public AasDisclosureDecision PassportDisclosure { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the controlled disclosure mapping.
|
|
/// </summary>
|
|
public AasDisclosureDecision ControlledDisclosure { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the sample package bytes.
|
|
/// </summary>
|
|
public ByteString Package { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the sample package digest.
|
|
/// </summary>
|
|
public string PackageDigest { get; }
|
|
}
|
|
|
|
}
|