Skip to content

Commit

Permalink
* after refactor of predefined concepts
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHoffmeisterFesto committed Mar 3, 2024
1 parent b5322bd commit dcef9a2
Show file tree
Hide file tree
Showing 33 changed files with 68 additions and 45 deletions.
2 changes: 1 addition & 1 deletion src/AasxPluginExportTable/Table/ExportTableProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This source code may use other Open Source software components (see LICENSE.txt)
using System.Text.RegularExpressions;
using System.Windows.Media;
using Aas = AasCore.Aas3_0;
using AasxPredefinedConcepts;
using AasxPredefinedConcepts.Qualifiers;

// ReSharper disable PossiblyMistakenUseOfParamsMethod .. issue, even if according to samples of Word API

Expand Down
2 changes: 1 addition & 1 deletion src/AasxPluginExportTable/Uml/BaseWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This source code may use other Open Source software components (see LICENSE.txt)
using Aas = AasCore.Aas3_0;
using AdminShellNS;
using Extensions;
using AasxPredefinedConcepts;
using AasxPredefinedConcepts.Qualifiers;

namespace AasxPluginExportTable.Uml
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This source code may use other Open Source software components (see LICENSE.txt)
// reSharper disable UnusedType.Global
// reSharper disable ClassNeverInstantiated.Global

namespace AasxPredefinedConcepts
namespace AasxPredefinedConcepts.Qualifiers
{
/// <summary>
/// This class provides handles specific qualifiers, extensions
Expand Down Expand Up @@ -64,105 +64,105 @@ public enum AccessMode
ReadOnly
};

public static Aas.IQualifier CreateQualifierSmtCardinality(SmtCardinality card)
public static IQualifier CreateQualifierSmtCardinality(SmtCardinality card)
{
return new Aas.Qualifier(
return new Qualifier(
type: "SMT/Cardinality",
valueType: DataTypeDefXsd.String,
kind: QualifierKind.TemplateQualifier,
semanticId: new Aas.Reference(ReferenceTypes.ExternalReference,
(new Aas.IKey[] {
new Aas.Key(KeyTypes.GlobalReference,
semanticId: new Reference(ReferenceTypes.ExternalReference,
(new IKey[] {
new Key(KeyTypes.GlobalReference,
"https://admin-shell.io/SubmodelTemplates/Cardinality/1/0")
}).ToList()),
value: "" + card);
}

public static Aas.IQualifier CreateQualifierSmtAllowedValue(string regex)
public static IQualifier CreateQualifierSmtAllowedValue(string regex)
{
return new Aas.Qualifier(
return new Qualifier(
type: "SMT/AllowedValue",
valueType: DataTypeDefXsd.String,
kind: QualifierKind.TemplateQualifier,
semanticId: new Aas.Reference(ReferenceTypes.ExternalReference,
(new Aas.IKey[] {
new Aas.Key(KeyTypes.GlobalReference,
semanticId: new Reference(ReferenceTypes.ExternalReference,
(new IKey[] {
new Key(KeyTypes.GlobalReference,
"https://admin-shell.io/SubmodelTemplates/AllowedValue/1/0")
}).ToList()),
value: "" + regex);
}

public static Aas.IQualifier CreateQualifierSmtExampleValue(string exampleValue)
public static IQualifier CreateQualifierSmtExampleValue(string exampleValue)
{
return new Aas.Qualifier(
return new Qualifier(
type: "SMT/ExampleValue",
valueType: DataTypeDefXsd.String,
kind: QualifierKind.TemplateQualifier,
semanticId: new Aas.Reference(ReferenceTypes.ExternalReference,
(new Aas.IKey[] {
new Aas.Key(KeyTypes.GlobalReference,
semanticId: new Reference(ReferenceTypes.ExternalReference,
(new IKey[] {
new Key(KeyTypes.GlobalReference,
"https://admin-shell.io/SubmodelTemplates/ExampleValue/1/0")
}).ToList()),
value: "" + exampleValue);
}

public static Aas.IQualifier CreateQualifierSmtDefaultValue(string defaultValue)
public static IQualifier CreateQualifierSmtDefaultValue(string defaultValue)
{
return new Aas.Qualifier(
return new Qualifier(
type: "SMT/DefaultValue",
valueType: DataTypeDefXsd.String,
kind: QualifierKind.TemplateQualifier,
semanticId: new Aas.Reference(ReferenceTypes.ExternalReference,
(new Aas.IKey[] {
new Aas.Key(KeyTypes.GlobalReference,
semanticId: new Reference(ReferenceTypes.ExternalReference,
(new IKey[] {
new Key(KeyTypes.GlobalReference,
"https://admin-shell.io/SubmodelTemplates/DefaultValue/1/0")
}).ToList()),
value: "" + defaultValue);
}

public static Aas.IQualifier CreateQualifierSmtEitherOr(string equivalencyClass)
public static IQualifier CreateQualifierSmtEitherOr(string equivalencyClass)
{
return new Aas.Qualifier(
return new Qualifier(
type: "SMT/EitherOr",
valueType: DataTypeDefXsd.String,
kind: QualifierKind.TemplateQualifier,
semanticId: new Aas.Reference(ReferenceTypes.ExternalReference,
(new Aas.IKey[] {
new Aas.Key(KeyTypes.GlobalReference,
semanticId: new Reference(ReferenceTypes.ExternalReference,
(new IKey[] {
new Key(KeyTypes.GlobalReference,
"https://admin-shell.io/SubmodelTemplates/Cardinality/1/0")
}).ToList()),
value: "" + equivalencyClass);
}

public static Aas.IQualifier CreateQualifierSmtRequiredLang(string reqLang)
public static IQualifier CreateQualifierSmtRequiredLang(string reqLang)
{
return new Aas.Qualifier(
return new Qualifier(
type: "SMT/RequiredLang",
valueType: DataTypeDefXsd.String,
kind: QualifierKind.TemplateQualifier,
semanticId: new Aas.Reference(ReferenceTypes.ExternalReference,
(new Aas.IKey[] {
new Aas.Key(KeyTypes.GlobalReference,
semanticId: new Reference(ReferenceTypes.ExternalReference,
(new IKey[] {
new Key(KeyTypes.GlobalReference,
"https://admin-shell.io/SubmodelTemplates/RequiredLang/1/0")
}).ToList()),
value: "" + reqLang);
}

public static Aas.IQualifier CreateQualifierSmtAccessMode(AccessMode mode)
public static IQualifier CreateQualifierSmtAccessMode(AccessMode mode)
{
return new Aas.Qualifier(
return new Qualifier(
type: "SMT/AccessMode",
valueType: DataTypeDefXsd.String,
kind: QualifierKind.TemplateQualifier,
semanticId: new Aas.Reference(ReferenceTypes.ExternalReference,
(new Aas.IKey[] {
new Aas.Key(KeyTypes.GlobalReference,
semanticId: new Reference(ReferenceTypes.ExternalReference,
(new IKey[] {
new Key(KeyTypes.GlobalReference,
"https://admin-shell.io/SubmodelTemplates/AccessMode/1/0")
}).ToList()),
value: "" + mode);
}

public static Aas.IQualifier[] AllSmtQualifiers =
public static IQualifier[] AllSmtQualifiers =
{
CreateQualifierSmtCardinality(SmtCardinality.One),
CreateQualifierSmtAllowedValue(""),
Expand All @@ -177,11 +177,11 @@ public static Aas.IQualifier CreateQualifierSmtAccessMode(AccessMode mode)
/// Find either <c>type</c> or <c>semanticId</c> and returns the link
/// to a STATIC IQualifier (not to be changed!).
/// </summary>
public static Aas.IQualifier FindQualifierTypeInst(
string type, Aas.IReference semanticId, bool relaxed = true)
public static IQualifier FindQualifierTypeInst(
string type, IReference semanticId, bool relaxed = true)
{
// at best: tries to find semanticId
Aas.IQualifier res = null;
IQualifier res = null;
foreach (var qti in AllSmtQualifiers)
if (semanticId?.IsValid() == true && semanticId.Matches(qti.SemanticId, MatchMode.Relaxed))
res = qti;
Expand Down Expand Up @@ -210,7 +210,7 @@ public static Aas.IQualifier FindQualifierTypeInst(
/// <summary>
/// Ask for different Qualifier names for cardinality and give a match back.
/// </summary>
public static Aas.IQualifier FindSmtCardinalityQualfier(IEnumerable<IQualifier> qualifiers)
public static IQualifier FindSmtCardinalityQualfier(IEnumerable<IQualifier> qualifiers)
{
// TODO (MIHO, 2024-02-20): In future, check semanticIds as well?

Expand All @@ -234,7 +234,7 @@ public static string CardinalityToString(SmtCardinality card, int format = 0,
if (p >= 0)
multiStr = multiStr.Substring(p).Trim('[', ']');
#else
switch (card)
switch (card)
{
case SmtCardinality.ZeroToOne:
switch (format)
Expand Down
25 changes: 24 additions & 1 deletion src/AasxPredefinedConcepts/README/Overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,18 @@ semanticIds and class structures. These concepts could be used on
*source code level* to avoid having semanticIds as sttring constants.

Nearly everything here was produced by the export function:
AASPE / File / Export / Export predefined concepts
AASPE / File / Export / Export predefined concepts.

Multiple low level SDK function are designed for using these symbols, e.g.

```
foreach (var srcLst in this.theSubmodel.SubmodelElements
.FindAllSemanticIdAs<Aas.SubmodelElementCollection>(
this.defsMtp.CD_SourceList?.GetReference(), MatchMode.Relaxed))
{
...
}
```

## Programmers note

Expand All @@ -19,6 +30,18 @@ However, when using "Add predefined .." button in References dialogue, the user
has to wait some 8sec for the first results, as *ALL* classes are firstly
instantiated for this scan.

## Namespaces

Currently, the folder names do not influence the namespaces of the classes, because
handling would even get longer.

## BaseTopUtil

These classes are either base classes, utility functions or the root definitions,
where all others are linked to.

Note: New definition classes shall be linked within `DefinitionsPool.cs`.

## Concept model

(Deprecated) approach to provide a switcher between different sets of concepts,
Expand Down

0 comments on commit dcef9a2

Please sign in to comment.