Skip to content

Commit 008cd44

Browse files
authored
Release 1.0.0-rc1 (#1)
Initial release candidate of the SDK targeting v3.1 of the AAS specification. The code is generated with: * [aas-core-meta 5a498be] and * [aas-core-codegen 754e167]. [aas-core-meta 5a498be]: aas-core-works/aas-core-meta@5a498be [aas-core-codegen 754e167]: aas-core-works/aas-core-codegen@754e167
1 parent e4c2df7 commit 008cd44

File tree

17,016 files changed

+548639
-76
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

17,016 files changed

+548639
-76
lines changed

dev_scripts/codegen/meta_model.py

Lines changed: 18 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Downloaded from: https://raw.githubusercontent.com/aas-core-works/aas-core-meta/899add10ff71eca9dac421c3a171bb909c68cb2c/aas_core_meta/v3_1.py
1+
# Downloaded from: https://raw.githubusercontent.com/aas-core-works/aas-core-meta/5a498be3a3b56f34af9a90b368cae10ca04e7ae4/aas_core_meta/v3_1.py
22
"""
33
--- WORK IN PROGRESS ---
44
Provide an implementation of the Asset Administration Shell (AAS) V3.1.
@@ -280,52 +280,6 @@ def matches_RFC_2396(text: str) -> bool:
280280
return match(uri_reference, text) is not None
281281

282282

283-
# noinspection SpellCheckingInspection
284-
@verification
285-
def matches_RFC_8089_path(text: str) -> bool:
286-
"""
287-
Check that :paramref:`text` is a path conforming to the pattern of RFC 8089.
288-
289-
The definition has been taken from:
290-
https://datatracker.ietf.org/doc/html/rfc8089
291-
292-
:param text: Text to be checked
293-
:returns: True if the :paramref:`text` conforms to the pattern
294-
295-
"""
296-
h16 = "[0-9A-Fa-f]{1,4}"
297-
dec_octet = "([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])"
298-
ipv4address = f"{dec_octet}\\.{dec_octet}\\.{dec_octet}\\.{dec_octet}"
299-
ls32 = f"({h16}:{h16}|{ipv4address})"
300-
ipv6address = (
301-
f"(({h16}:){{6}}{ls32}|::({h16}:){{5}}{ls32}|({h16})?::({h16}:){{4}}"
302-
f"{ls32}|(({h16}:)?{h16})?::({h16}:){{3}}{ls32}|(({h16}:){{,2}}{h16})?::"
303-
f"({h16}:){{2}}{ls32}|(({h16}:){{,3}}{h16})?::{h16}:{ls32}|(({h16}:){{,4}}"
304-
f"{h16})?::{ls32}|(({h16}:){{,5}}{h16})?::{h16}|(({h16}:){{,6}}{h16})?"
305-
"::)"
306-
)
307-
unreserved = "[a-zA-Z0-9\\-._~]"
308-
sub_delims = "[!$&'()*+,;=]"
309-
ipvfuture = f"[vV][0-9A-Fa-f]+\\.({unreserved}|{sub_delims}|:)+"
310-
ip_literal = f"\\[({ipv6address}|{ipvfuture})\\]"
311-
pct_encoded = "%[0-9A-Fa-f][0-9A-Fa-f]"
312-
reg_name = f"({unreserved}|{pct_encoded}|{sub_delims})*"
313-
host = f"({ip_literal}|{ipv4address}|{reg_name})"
314-
file_auth = f"(localhost|{host})"
315-
pchar = f"({unreserved}|{pct_encoded}|{sub_delims}|[:@])"
316-
segment_nz = f"({pchar})+"
317-
segment = f"({pchar})*"
318-
path_absolute = f"/({segment_nz}(/{segment})*)?"
319-
auth_path = f"({file_auth})?{path_absolute}"
320-
local_path = f"{path_absolute}"
321-
file_hier_part = f"(//{auth_path}|{local_path})"
322-
file_scheme = "file"
323-
file_uri = f"{file_scheme}:{file_hier_part}"
324-
325-
pattern = f"^{file_uri}$"
326-
return match(pattern, text) is not None
327-
328-
329283
# noinspection SpellCheckingInspection
330284
@verification
331285
def matches_BCP_47(text: str) -> bool:
@@ -2279,8 +2233,9 @@ class Asset_information(DBC):
22792233

22802234
asset_kind: "Asset_kind"
22812235
"""
2282-
Denotes whether the Asset is of kind :attr:`Asset_kind.Type` or
2283-
:attr:`Asset_kind.Instance`.
2236+
Denotes whether the Asset is of kind :attr:`Asset_kind.Type`,
2237+
:attr:`Asset_kind.Instance`, :attr:`Asset_kind.Role`, or
2238+
:attr:`Asset_kind.Not_applicable`.
22842239
"""
22852240

22862241
global_asset_ID: Optional["Identifier"]
@@ -2305,13 +2260,13 @@ class Asset_information(DBC):
23052260

23062261
asset_type: Optional["Identifier"]
23072262
"""
2308-
In case :attr:`asset_kind` is applicable the :attr:`asset_type` is the asset ID
2309-
of the type asset of the asset under consideration
2310-
as identified by :attr:`global_asset_ID`.
2263+
In case :attr:`asset_kind` is :attr:`Asset_kind.Not_applicable` the
2264+
:attr:`asset_type` is the asset ID of the type asset of the asset under
2265+
consideration as identified by :attr:`global_asset_ID`.
23112266
23122267
.. note::
23132268
2314-
In case :attr:`asset_kind` is "Instance" than the :attr:`asset_type` denotes
2269+
In case :attr:`asset_kind` is "Instance" then the :attr:`asset_type` denotes
23152270
which "Type" the asset is of. But it is also possible
23162271
to have an :attr:`asset_type` of an asset of kind "Type".
23172272
@@ -2370,7 +2325,8 @@ def __init__(
23702325

23712326
class Asset_kind(Enum):
23722327
"""
2373-
Enumeration for denoting whether an asset is a type asset or an instance asset.
2328+
Enumeration for denoting whether an asset is a type asset or an instance
2329+
asset or is a role or whether this kind of classification is not applicable.
23742330
"""
23752331

23762332
Type = "Type"
@@ -2694,6 +2650,12 @@ class AAS_submodel_elements(Enum):
26942650

26952651

26962652
# fmt: off
2653+
@invariant(
2654+
lambda self:
2655+
not (self.value is not None)
2656+
or ID_shorts_are_unique(self.value),
2657+
"ID-shorts of the value must be unique."
2658+
)
26972659
@invariant(
26982660
lambda self:
26992661
not (
@@ -3920,7 +3882,7 @@ def __init__(
39203882
self.inoutput_variables
39213883
),
39223884
"Constraint AASd-134: For an Operation the ID-short of all values of "
3923-
"input, output and in/output variables."
3885+
"input, output and in/output variables shall be unique."
39243886
)
39253887
# fmt: on
39263888
class Operation(Submodel_element):
@@ -5714,4 +5676,4 @@ def __init__(
57145676
self.value = value
57155677
self.level_type = level_type
57165678

5717-
# Downloaded from: https://raw.githubusercontent.com/aas-core-works/aas-core-meta/899add10ff71eca9dac421c3a171bb909c68cb2c/aas_core_meta/v3_1.py
5679+
# Downloaded from: https://raw.githubusercontent.com/aas-core-works/aas-core-meta/5a498be3a3b56f34af9a90b368cae10ca04e7ae4/aas_core_meta/v3_1.py

dev_scripts/codegen/snippets/Types/Data_element/category_or_default.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/AasCore.Aas3_1.Tests/Common.cs

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
using Aas = AasCore.Aas3_1; // renamed
2+
3+
using System.Collections.Generic; // can't alias
4+
using System.Linq; // can't alias
5+
using NUnit.Framework; // can't alias
6+
7+
namespace AasCore.Aas3_1.Tests
8+
{
9+
/// <summary>
10+
/// Provide common functionality to be re-used across different tests
11+
/// such as reading of environment variables.
12+
/// </summary>
13+
public static class Common
14+
{
15+
public static readonly string RecordModeEnvironmentVariableName = (
16+
"AAS_CORE_AAS3_1_TESTS_RECORD_MODE"
17+
);
18+
19+
// NOTE (mristin, 2023-03-16):
20+
// It is tedious to record manually all the expected error messages. Therefore we include this variable
21+
// to steer the automatic recording. We intentionally inter-twine the recording code with the test code
22+
// to keep them close to each other so that they are easier to maintain.
23+
public static readonly bool RecordMode = (
24+
System.Environment.GetEnvironmentVariable(RecordModeEnvironmentVariableName)?.ToLower()
25+
== "true"
26+
|| System
27+
.Environment.GetEnvironmentVariable(RecordModeEnvironmentVariableName)
28+
?.ToLower() == "on"
29+
|| System
30+
.Environment.GetEnvironmentVariable(RecordModeEnvironmentVariableName)
31+
?.ToLower() == "1"
32+
|| System
33+
.Environment.GetEnvironmentVariable(RecordModeEnvironmentVariableName)
34+
?.ToLower() == "yes"
35+
);
36+
37+
public static readonly string TestDataDir = (
38+
System.Environment.GetEnvironmentVariable("AAS_CORE_AAS3_1_TESTS_TEST_DATA_DIR")
39+
?? throw new System.InvalidOperationException(
40+
"The path to the test data directory is missing in the environment: "
41+
+ "AAS_CORE_AAS3_1_TESTS_TEST_DATA_DIR"
42+
)
43+
);
44+
45+
/// <summary>
46+
/// Find the first instance of <typeparamref name="T"/> in the <paramref name="container" />,
47+
/// including the <paramref name="container" /> itself.
48+
/// </summary>
49+
public static T MustFind<T>(Aas.IClass container)
50+
where T : Aas.IClass
51+
{
52+
var instance = (
53+
(container is T)
54+
? container
55+
: container.Descend().First(something => something is T)
56+
?? throw new System.InvalidOperationException(
57+
$"No instance of {nameof(T)} could be found"
58+
)
59+
);
60+
61+
return (T)instance;
62+
}
63+
64+
public static void AssertNoVerificationErrors(List<Aas.Reporting.Error> errors, string path)
65+
{
66+
if (errors.Count > 0)
67+
{
68+
var builder = new System.Text.StringBuilder();
69+
builder.Append(
70+
$"Expected no errors when verifying the instance de-serialized from {path}, "
71+
+ $"but got {errors.Count} error(s):\n"
72+
);
73+
for (var i = 0; i < errors.Count; i++)
74+
{
75+
builder.Append(
76+
$"Error {i + 1}:\n"
77+
+ $"{Reporting.GenerateJsonPath(errors[i].PathSegments)}: {errors[i].Cause}\n"
78+
);
79+
}
80+
81+
Assert.Fail(builder.ToString());
82+
}
83+
}
84+
85+
public static void AssertEqualsExpectedOrRerecordVerificationErrors(
86+
List<Aas.Reporting.Error> errors,
87+
string path
88+
)
89+
{
90+
if (errors.Count == 0)
91+
{
92+
Assert.Fail(
93+
$"Expected at least one verification error when verifying {path}, but got none"
94+
);
95+
}
96+
97+
string got = string.Join(
98+
";\n",
99+
errors.Select(error =>
100+
$"{Reporting.GenerateJsonPath(error.PathSegments)}: {error.Cause}"
101+
)
102+
);
103+
104+
string errorsPath = path + ".errors";
105+
if (RecordMode)
106+
{
107+
System.IO.File.WriteAllText(errorsPath, got);
108+
}
109+
else
110+
{
111+
if (!System.IO.File.Exists(errorsPath))
112+
{
113+
throw new System.IO.FileNotFoundException(
114+
"The file with the recorded errors does not "
115+
+ $"exist: {errorsPath}; maybe you want to set the environment "
116+
+ $"variable {Aas.Tests.Common.RecordModeEnvironmentVariableName}?"
117+
);
118+
}
119+
120+
string expected = System.IO.File.ReadAllText(errorsPath);
121+
Assert.AreEqual(
122+
expected.Replace("\r\n", "\n"),
123+
got.Replace("\r\n", "\n"),
124+
$"The expected verification errors do not match the actual ones for the file {path}"
125+
);
126+
}
127+
}
128+
}
129+
}

0 commit comments

Comments
 (0)