Skip to content

Commit

Permalink
* start refactor predefined concepts
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHoffmeisterFesto committed Mar 3, 2024
1 parent 5566a45 commit b5322bd
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 0 deletions.
79 changes: 79 additions & 0 deletions src/AasxPluginProductChangeNotifications/PcnAnyUiControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ This source code may use other Open Source software components (see LICENSE.txt)
using System.Globalization;
using System.Windows.Controls;
using AasxIntegrationBaseGdi;
using System.Windows;

namespace AasxPluginProductChangeNotifications
{
Expand Down Expand Up @@ -374,6 +375,51 @@ protected void InnerDocAddText(
wrap: (wrapText != AnyUiTextWrapping.Wrap) ? null : (new[] { 1 }));
}

protected void InnerDocAddGridCells(
AnyUiSmallWidgetToolkit uitk,
AnyUiGrid grid,
string[] cell,
int[] bold = null,
int[] wrap = null,
int[] centered = null)
{
// access and add row
if (grid == null || cell == null)
return;
int row = InnerDocGetNewRow(grid);

// text(s)
for (int i = 0; i < cell.Length; i++)
{
// make the border
var brd = uitk.AddSmallBorderTo(grid, row, i,
margin: (i == 0) ? new AnyUiThickness(0, -1, 0, 0)
: new AnyUiThickness(-1, -1, 0, 0),
borderThickness: new AnyUiThickness(1.0),
borderBrush: AnyUiBrushes.Black);

var stb = new AnyUiSelectableTextBlock()
{
Text = "" + cell[i],
Padding = new AnyUiThickness(1),
FontWeight = (bold != null && bold.Contains(i))
? AnyUiFontWeight.Bold : null,
TextWrapping = (wrap != null && wrap.Contains(i))
? AnyUiTextWrapping.Wrap : null,
VerticalAlignment = AnyUiVerticalAlignment.Center,
VerticalContentAlignment = AnyUiVerticalAlignment.Center
};

brd.Child = stb;

if (centered != null && centered.Contains(i))
{
stb.HorizontalAlignment = AnyUiHorizontalAlignment.Center;
stb.HorizontalContentAlignment = AnyUiHorizontalAlignment.Center;
}
}
}

protected void InnerDocAddLifeCycleMilestones(
AnyUiSmallWidgetToolkit uitk,
AnyUiGrid grid, int col,
Expand Down Expand Up @@ -656,6 +702,30 @@ protected void InnerDocAddAdditionalInfo(
}
}

protected void InnerDocAddTechnicalDataChanges(
AnyUiSmallWidgetToolkit uitk,
AnyUiGrid grid, int col,
AasClassMapperInfo info)
{
// access and add row
if (grid == null
|| !(info?.Referable is Aas.ISubmodelElementCollection smc))
return;
int row = InnerDocGetNewRow(grid);

// make inner grid
var inner = uitk.Set(
uitk.AddSmallGridTo(grid, row, col,
rows: 0, cols: 3,
colWidths: new[] { "#", "*", "#" }),
colSpan: _innerDocumentCols - col);

// add head line
InnerDocAddGridCells(uitk, inner,
cell: new[] { "IdShort", "SemanticId", "New value" },
bold: new[] { 0, 1, 2 });
}

protected void RenderPanelInner(
AnyUiStackPanel view, AnyUiSmallWidgetToolkit uitk,
PcnOptionsRecord rec,
Expand Down Expand Up @@ -871,6 +941,15 @@ protected void RenderPanelInner(
}

}

// technical data - changes
if (data.ItemOfChange?.TechnicalData_Changes != null)
{
InnerDocAddHeadline(uitk, grid, 0, "Given changes of technical data for the item of change", 2);

InnerDocAddTechnicalDataChanges(uitk, grid, 0,
data.ItemOfChange.TechnicalData_Changes.__Info__);
}
}

#endregion
Expand Down
65 changes: 65 additions & 0 deletions src/AasxPredefinedConcepts/README/Overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Overview on organization of AASPE predefined concepts

## General

This projects hold a wealth of classes defining concepts, in particular
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

## Programmers note

As many (!) classes and attributes are declared, these classes seem contribute
significantly to the loading time of AASPE in general. Basically, these classes
seem to be loaded on demand by the class loader.

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.

## Concept model

(Deprecated) approach to provide a switcher between different sets of concepts,
here for some ZVEI models.

## Convert

Classes used to allow (automatic) converting between different versions of
Submodels. Useful to define, when a large user basis is known to use an old
version of a Submodel.

## Definitions and Resources

Classes providing `CD_xxx` references having constant semanticId in it.

In newer versions of these files, a reflection approach stores the full
ConceptDescriptions (CDs) in the Resource JSON files and the source code
links against it.

This is the *preferred approach* to realize predefined data for the AASPE,
as many functions ("Add predefined ..", "New Submodel ..") can use these
data automatically.

In order the be properly linked, the classes need to be listed in
`DefinitionsPool.cs`.

Note: It is recommended, to *NOT* include all symbols by
`using AasxPredefinedConcepts`, but to refer to specific classes.

Note: For the sake of shorter source code symbols, the classes in the
`DefinitionsXXX` are cut to `XXX` because preferable preceded by
`AasxPredefinedConcepts.`.

## Mapping

These classes support an automatic mapping of Submodel structures
to C# class hierarchies. These classes are 1:1 mapping of the
SMT structure and contain C# attributes with explicit semanticIds
to allow functionality of `PredefinedConceptsClassMapper.cs`.

## Qualifers

These classes pre-define names, semanticIds and functions for
handling `Qualifiers`.

0 comments on commit b5322bd

Please sign in to comment.