Skip to content

Commit 8ece460

Browse files
committed
* updates for product change
notifications * use more preferred name than short names from CDs * refactor use of Aas.IEnvironment instead Aas.Environment
1 parent 4737a35 commit 8ece460

File tree

61 files changed

+539
-328
lines changed

Some content is hidden

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

61 files changed

+539
-328
lines changed

src/AasxAmlImExport/AmlExport.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ private static void SetQualifiers(
314314
}
315315

316316
private static void ExportReferenceWithSme(
317-
AasCore.Aas3_0.Environment env,
317+
Aas.IEnvironment env,
318318
List<AmlInternalLinkEntity> internalLinksToCreate,
319319
InternalElementType ie,
320320
IReferable referable,
@@ -377,7 +377,7 @@ private static void ExportReferenceWithSme(
377377

378378
private static void ExportListOfSme(
379379
AasAmlMatcher matcher, List<AmlInternalLinkEntity> internalLinksToCreate,
380-
SystemUnitClassType parent, AasCore.Aas3_0.Environment env,
380+
SystemUnitClassType parent, Aas.IEnvironment env,
381381
List<ISubmodelElement> wrappers, bool tryUseCompactProperties = false,
382382
bool aasStyleAttributes = false, bool amlStyleAttributes = true)
383383
{
@@ -648,7 +648,7 @@ private static void ExportListOfSme(
648648
private static void ExportSubmodelIntoElement(
649649
AasAmlMatcher matcher, List<AmlInternalLinkEntity> internalLinksToCreate,
650650
SystemUnitClassType parent,
651-
AasCore.Aas3_0.Environment env,
651+
IEnvironment env,
652652
ISubmodel sm,
653653
bool tryUseCompactProperties = false,
654654
bool exportShallow = false)
@@ -679,7 +679,7 @@ private static void ExportSubmodelIntoElement(
679679
private static InternalElementType ExportSubmodel(
680680
AasAmlMatcher matcher,
681681
List<AmlInternalLinkEntity> internalLinksToCreate, InternalElementSequence ieseq,
682-
AasCore.Aas3_0.Environment env,
682+
Aas.IEnvironment env,
683683
ISubmodel sm,
684684
bool tryUseCompactProperties = false,
685685
bool exportShallow = false)
@@ -699,7 +699,7 @@ private static InternalElementType ExportSubmodel(
699699
}
700700

701701
private static void ExportAsset(
702-
InternalElementSequence ieseq, AasCore.Aas3_0.Environment env, IAssetInformation asset)
702+
InternalElementSequence ieseq, Aas.IEnvironment env, Aas.IAssetInformation asset)
703703
{
704704
if (ieseq == null || env == null || asset == null)
705705
return;
@@ -777,7 +777,7 @@ private static void ExportAsset(
777777
// dead-csharp on
778778
private static void ExportAAS(
779779
AasAmlMatcher matcher, InstanceHierarchyType insthier, SystemUnitClassLibType suchier,
780-
AasCore.Aas3_0.Environment env, IAssetAdministrationShell aas,
780+
IEnvironment env, IAssetAdministrationShell aas,
781781
bool tryUseCompactProperties = false)
782782
{
783783
// access
@@ -1027,7 +1027,7 @@ private static void SetAttributesForConceptDescription(
10271027

10281028

10291029
private static void ExportConceptDescriptionsWithExtraContentToIHT(
1030-
InstanceHierarchyType lib, Aas.Environment env)
1030+
InstanceHierarchyType lib, Aas.IEnvironment env)
10311031
{
10321032
// acceess
10331033
if (lib == null || env == null)

src/AasxBammRdfImExport/RDFimport.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static class BAMMRDFimport
2727
public static AdminShellNS.AdminShellPackageEnv thePackageEnv;
2828

2929
public static void ImportInto(
30-
string rdffn, Aas.Environment env, Aas.ISubmodel sm,
30+
string rdffn, Aas.IEnvironment env, Aas.ISubmodel sm,
3131
Aas.Reference smref)
3232
{
3333
thePackageEnv = new AdminShellNS.AdminShellPackageEnv();

src/AasxCsharpLibrary/AdminShellPackageEnv.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public class AdminShellPackageEnv : IDisposable
276276

277277
private string _tempFn = null;
278278

279-
private AasCore.Aas3_0.Environment _aasEnv = new AasCore.Aas3_0.Environment();
279+
private IEnvironment _aasEnv = new AasCore.Aas3_0.Environment();
280280
private Package _openPackage = null;
281281
private readonly ListOfAasSupplementaryFile _pendingFilesToAdd = new ListOfAasSupplementaryFile();
282282
private readonly ListOfAasSupplementaryFile _pendingFilesToDelete = new ListOfAasSupplementaryFile();
@@ -315,15 +315,15 @@ public string Filename
315315
}
316316
}
317317

318-
public AasCore.Aas3_0.Environment AasEnv
318+
public IEnvironment AasEnv
319319
{
320320
get
321321
{
322322
return _aasEnv;
323323
}
324324
}
325325

326-
public void SetEnvironment(AasCore.Aas3_0.Environment environment)
326+
public void SetEnvironment(IEnvironment environment)
327327
{
328328
_aasEnv = environment;
329329
}

src/AasxCsharpLibrary/AdminShellUtil.cs

+10
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,16 @@ public static string TakeFirstContent(params string[] choices)
451451
return "";
452452
}
453453

454+
/// <summary>
455+
/// Takes the character at index 0 and converts it to upper case.
456+
/// </summary>
457+
public static string CapitalizeFirstLetter(string str)
458+
{
459+
if (str.HasContent() && char.IsLower(str[0]))
460+
str = char.ToUpperInvariant(str[0]) + str.Substring(1);
461+
return str;
462+
}
463+
454464
/// <summary>
455465
/// If len of <paramref name="str"/> exceeds <paramref name="maxLen"/> then
456466
/// string is shortened and returned with an ellipsis(…) at the end.

src/AasxCsharpLibrary/Extensions/ExtendConceptDescription.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ public static Tuple<string, string> ToCaptionInfo(this IConceptDescription conce
8181
if (conceptDescription.Id != null)
8282
caption = (caption + " " + conceptDescription.Id).Trim();
8383

84-
var info = "" + conceptDescription.GetDefaultShortName();
84+
// NEW (2024-07-03): use preferred name instead of default name
85+
var info = "" + conceptDescription.GetDefaultPreferredName();
8586

8687
return Tuple.Create(caption, info);
8788
}

src/AasxCsharpLibrary/Extensions/ExtendIReferable.cs

+9-75
Original file line numberDiff line numberDiff line change
@@ -428,86 +428,20 @@ public static IEnumerable<ISubmodelElement> EnumerateChildren(this IReferable rf
428428
foreach (var desc in rf.DescendOnce())
429429
if (desc is ISubmodelElement sme)
430430
yield return sme;
431+
}
431432

432-
#if __old
433-
if (referable is Submodel submodel && submodel.SubmodelElements != null)
434-
{
435-
if (submodel.SubmodelElements != null)
436-
{
437-
foreach (var submodelElement in submodel.SubmodelElements)
438-
{
439-
yield return submodelElement;
440-
}
441-
}
442-
}
443-
else if (referable is SubmodelElementCollection submodelElementCollection)
444-
{
445-
if (submodelElementCollection.Value != null)
446-
{
447-
foreach (var submodelElement in submodelElementCollection.Value)
448-
{
449-
yield return submodelElement;
450-
}
451-
}
452-
}
453-
else if (referable is SubmodelElementList submodelElementList)
454-
{
455-
if (submodelElementList.Value != null)
456-
{
457-
foreach (var submodelElement in submodelElementList.Value)
458-
{
459-
yield return submodelElement;
460-
}
461-
}
462-
}
463-
else if (referable is AnnotatedRelationshipElement annotatedRelationshipElement)
464-
{
465-
if (annotatedRelationshipElement.Annotations != null)
466-
{
467-
foreach (var submodelElement in annotatedRelationshipElement.Annotations)
468-
{
469-
yield return submodelElement;
470-
}
471-
}
472-
}
473-
else if (referable is Entity entity)
474-
{
475-
if (entity.Statements != null)
476-
{
477-
foreach (var submodelElement in entity.Statements)
478-
{
479-
yield return submodelElement;
480-
}
481-
}
482-
}
483-
else if (referable is Operation operation)
484-
{
485-
if (operation.InputVariables != null)
486-
foreach (var inputVariable in operation.InputVariables)
487-
{
488-
yield return inputVariable.Value;
489-
}
490-
491-
if (operation.OutputVariables != null)
492-
foreach (var outputVariable in operation.OutputVariables)
493-
{
494-
yield return outputVariable.Value;
495-
}
496-
497-
if (operation.InoutputVariables != null)
498-
foreach (var inOutVariable in operation.InoutputVariables)
499-
{
500-
yield return inOutVariable.Value;
501-
}
502-
}
503-
else
433+
public static IEnumerable<ISubmodelElement> EnumerateChildrenFor(this IReferable rf,
434+
bool SMC = false,
435+
bool SML = false)
436+
{
437+
if (rf is ISubmodelElementCollection && SMC
438+
|| rf is ISubmodelElementList && SML)
504439
{
505-
yield break;
440+
foreach (var x in rf.EnumerateChildren())
441+
yield return x;
506442
}
507-
#endif
508443
}
509444

510-
511445
public static void SetAllParentsAndTimestamps(this IReferable referable, IReferable parent, DateTime timeStamp, DateTime timeStampCreate)
512446
{
513447
if (parent == null)

src/AasxCsharpLibrary/IAasxOnlineConnection.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ This source code may use other Open Source software components (see LICENSE.txt)
88
*/
99

1010
using System.IO;
11+
using Aas = AasCore.Aas3_0;
1112

1213
namespace AasxIntegrationBase
1314
{
@@ -21,6 +22,6 @@ public interface IAasxOnlineConnection
2122
string GetInfo();
2223
Stream GetThumbnailStream();
2324
string UpdatePropertyValue(
24-
AasCore.Aas3_0.Environment env, Submodel submodel, ISubmodelElement sme);
25+
Aas.IEnvironment env, Submodel submodel, ISubmodelElement sme);
2526
}
2627
}

src/AasxDictionaryImport/Cdd/Importer.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace AasxDictionaryImport.Cdd
3131
/// </summary>
3232
internal class Importer
3333
{
34-
private readonly Aas.Environment _env;
34+
private readonly Aas.IEnvironment _env;
3535
private readonly Context _context;
3636
private readonly bool _all;
3737

@@ -40,7 +40,7 @@ internal class Importer
4040
/// </summary>
4141
/// <param name="env">The environment to import the data into</param>
4242
/// <param name="context">The data context of the IEC CDD data</param>
43-
public Importer(Aas.Environment env, Context context)
43+
public Importer(Aas.IEnvironment env, Context context)
4444
{
4545
_env = env;
4646
_context = context;

src/AasxDictionaryImport/Cdd/Model.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -263,14 +263,14 @@ public ClassWrapper(Context context, Class cls, Model.IElement? parent = null)
263263
}
264264

265265
/// <inheritdoc/>
266-
public override bool ImportSubmodelInto(Aas.Environment env,
266+
public override bool ImportSubmodelInto(Aas.IEnvironment env,
267267
Aas.IAssetAdministrationShell adminShell)
268268
{
269269
return new Importer(env, Context).ImportSubmodel(this, adminShell);
270270
}
271271

272272
/// <inheritdoc/>
273-
public override bool ImportSubmodelElementsInto(Aas.Environment env,
273+
public override bool ImportSubmodelElementsInto(Aas.IEnvironment env,
274274
Aas.IReferable parent)
275275
{
276276
// If we wanted to import the class, we would typically use the submodel import
@@ -350,7 +350,7 @@ public override Dictionary<string, string> GetDetails()
350350
}
351351

352352
/// <inheritdoc/>
353-
public override bool ImportSubmodelElementsInto(Aas.Environment env,
353+
public override bool ImportSubmodelElementsInto(Aas.IEnvironment env,
354354
Aas.IReferable parent)
355355
{
356356
return new Importer(env, Context).ImportSubmodelElements(this, parent);

src/AasxDictionaryImport/Eclass/Model.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ private bool IsAspect()
657657
}
658658

659659
/// <inheritdoc/>
660-
public override bool ImportSubmodelInto(Aas.Environment env,
660+
public override bool ImportSubmodelInto(Aas.IEnvironment env,
661661
Aas.IAssetAdministrationShell adminShell)
662662
{
663663
if (!IsSelected)
@@ -686,7 +686,7 @@ public override bool ImportSubmodelInto(Aas.Environment env,
686686
}
687687

688688
/// <inheritdoc/>
689-
public override bool ImportSubmodelElementsInto(Aas.Environment env,
689+
public override bool ImportSubmodelElementsInto(Aas.IEnvironment env,
690690
Aas.IReferable parent)
691691
{
692692
if (!IsSelected)
@@ -784,7 +784,7 @@ public Property(Property property, Model.IElement? parent)
784784
}
785785

786786
/// <inheritdoc/>
787-
public override bool ImportSubmodelElementsInto(Aas.Environment env,
787+
public override bool ImportSubmodelElementsInto(Aas.IEnvironment env,
788788
Aas.IReferable parent)
789789
{
790790
if (!IsSelected)

src/AasxDictionaryImport/Iec61360Utils.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static string CreateIdShort(string s)
4545
/// <param name="data">The IEC 61360 data to create the submodel from</param>
4646
/// <returns>A new submodel with the given data</returns>
4747
public static Aas.Submodel CreateSubmodel(
48-
Aas.Environment env,
48+
Aas.IEnvironment env,
4949
Aas.IAssetAdministrationShell adminShell, Iec61360Data data)
5050
{
5151
// We need this to ensure that we don't use the same AAS ID twice when importing multiple submodels (as
@@ -73,7 +73,7 @@ public static Aas.Submodel CreateSubmodel(
7373
/// <param name="data">The IEC 61360 data to create the collection from</param>
7474
/// <returns>A new submodel element collection with the given data</returns>
7575
public static Aas.SubmodelElementCollection CreateCollection(
76-
Aas.Environment env, Iec61360Data data)
76+
Aas.IEnvironment env, Iec61360Data data)
7777
{
7878
var collection = new Aas.SubmodelElementCollection(
7979
idShort: data.IdShort
@@ -90,7 +90,7 @@ public static Aas.SubmodelElementCollection CreateCollection(
9090
/// <param name="valueType">The value type of the property</param>
9191
/// <returns>A new property with the given data</returns>
9292
public static Aas.Property CreateProperty(
93-
Aas.Environment env, Iec61360Data data, string valueType)
93+
Aas.IEnvironment env, Iec61360Data data, string valueType)
9494
{
9595
var property = new Aas.Property(
9696
idShort: data.IdShort,
@@ -100,7 +100,7 @@ public static Aas.Property CreateProperty(
100100
return property;
101101
}
102102

103-
private static void InitSubmodelElement(Aas.Environment env,
103+
private static void InitSubmodelElement(Aas.IEnvironment env,
104104
Aas.ISubmodelElement submodelElement, Iec61360Data data)
105105
{
106106
AddDescriptions(submodelElement, data);
@@ -113,7 +113,7 @@ private static void AddDescriptions(Aas.IReferable r, Iec61360Data data)
113113
r.AddDescription(lang, data.PreferredName.Get(lang));
114114
}
115115

116-
private static void AddDataSpecification(Aas.Environment env,
116+
private static void AddDataSpecification(Aas.IEnvironment env,
117117
Aas.Submodel submodel, Iec61360Data data)
118118
{
119119
var cd = CreateConceptDescription(env, data);
@@ -130,7 +130,7 @@ private static void AddDataSpecification(Aas.Environment env,
130130
submodel.SemanticId = cd.GetReference().Copy();
131131
}
132132

133-
private static void AddDataSpecification(Aas.Environment env,
133+
private static void AddDataSpecification(Aas.IEnvironment env,
134134
Aas.ISubmodelElement submodelElement, Iec61360Data data)
135135
{
136136
var cd = CreateConceptDescription(env, data);
@@ -148,7 +148,7 @@ private static void AddDataSpecification(Aas.Environment env,
148148
}
149149

150150
private static Aas.ConceptDescription CreateConceptDescription(
151-
Aas.Environment env, Iec61360Data data)
151+
Aas.IEnvironment env, Iec61360Data data)
152152
{
153153
var cd = new Aas.ConceptDescription(
154154
idShort: data.IdShort, id: data.Irdi);

src/AasxDictionaryImport/Import.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public static class Import
7070
/// <param name="adminShell">The admin shell to import into, or null if a new admin shell should be
7171
/// created</param>
7272
/// <returns>true if at least one submodel was imported</returns>
73-
public static bool ImportSubmodel(Window window, Aas.Environment env,
73+
public static bool ImportSubmodel(Window window, Aas.IEnvironment env,
7474
string defaultSourceDir, Aas.IAssetAdministrationShell? adminShell = null)
7575
{
7676
adminShell ??= CreateAdminShell(env);
@@ -89,7 +89,7 @@ public static bool ImportSubmodel(Window window, Aas.Environment env,
8989
/// directory</param>
9090
/// <param name="parent">The parent element to import into</param>
9191
/// <returns>true if at least one submodel element was imported</returns>
92-
public static bool ImportSubmodelElements(Window window, Aas.Environment env,
92+
public static bool ImportSubmodelElements(Window window, Aas.IEnvironment env,
9393
string defaultSourceDir, Aas.IReferable parent)
9494
{
9595
return PerformImport(window, ImportMode.ForSubmodelElements, defaultSourceDir,
@@ -119,7 +119,7 @@ private static bool PerformImport(Window window, ImportMode importMode, string d
119119
return imported > 0;
120120
}
121121

122-
private static Aas.AssetAdministrationShell CreateAdminShell(Aas.Environment env)
122+
private static Aas.AssetAdministrationShell CreateAdminShell(Aas.IEnvironment env)
123123
{
124124
var adminShell = new Aas.AssetAdministrationShell("", new Aas.AssetInformation(Aas.AssetKind.Instance))
125125
{

0 commit comments

Comments
 (0)