Skip to content

Commit d718c44

Browse files
Improve from first Retrieval demo (#299)
* * small fixes which were inspired by first Retrieval demo * * improve queries to standardized API * * query working * more query options * show last blue message * SMT AsciiDoc to use podman * * update * * update * * fix recursive copy of AAS with supplemental files --------- Co-authored-by: Michael Hoffmeister <michael.hoffmeister@festo.com>
1 parent 4a4200f commit d718c44

31 files changed

Lines changed: 1153 additions & 255 deletions

src/AasxCsharpLibrary/AdminShellUtil.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,18 @@ public static void SetFieldLazyValue(
10991099
return;
11001100
}
11011101

1102+
// list of strings is vary common, therefore a special case is justified
1103+
if (tut?.IsGenericType == true
1104+
&& tut.GetGenericTypeDefinition() == typeof(List<>)
1105+
&& tut.GetGenericArguments().Count() == 1
1106+
&& tut.GetGenericArguments()[0] == typeof(string)
1107+
&& value is IEnumerable<string> vstr2)
1108+
{
1109+
var lststr = vstr2.ToList();
1110+
f.SetValue(obj, lststr);
1111+
return;
1112+
}
1113+
11021114
// 2024-01-04: make function more suitable for <DateTime?>
11031115
switch (Type.GetTypeCode(tut))
11041116
{

src/AasxCsharpLibrary/Extensions/ExtendEnvironment.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,20 @@ public static IEnumerable<IConceptDescription> AllConceptDescriptions(this AasCo
417417
yield return cd;
418418
}
419419

420+
/// <summary>
421+
/// Enumerates any Identifiables in the Environment. Will not return <c>null</c>.
422+
/// Is tolerant, if the list is <c>null</c>.
423+
/// </summary>
424+
public static IEnumerable<IIdentifiable> AllIdentifiables(this AasCore.Aas3_0.IEnvironment env)
425+
{
426+
foreach (var aas in env.AllAssetAdministrationShells())
427+
yield return aas;
428+
foreach (var sm in env.AllSubmodels())
429+
yield return sm;
430+
foreach (var cd in env.AllConceptDescriptions())
431+
yield return cd;
432+
}
433+
420434
/// <summary>
421435
/// Returns the number of AssetAdministrationShells.
422436
/// Is tolerant, if the list is <c>null</c>.

src/AasxIntegrationBase/AnyUI/AnyUiContextPlusDialogs.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,8 @@ public async virtual Task<AnyUiDialogueDataLogMessage> MenuExecuteSystemCommand(
445445
string caption,
446446
string workDir,
447447
string cmd,
448-
string args)
448+
string args,
449+
string[] ignoreError = null)
449450
{
450451
await Task.Yield();
451452
throw new NotImplementedException("MenuExecuteSystemCommand");

src/AasxIntegrationBase/LogInstance.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,18 @@ public void Append(StoredPrint sp)
250250
/// </summary>
251251
public int NumberErrors = 0;
252252

253+
/// <summary>
254+
/// Incremented for each blue (important) message
255+
/// </summary>
256+
public int NumberBlues = 0;
257+
253258
/// <summary>
254259
/// Clears errors
255260
/// </summary>
256261
public void ClearNumberErrors()
257262
{
258263
NumberErrors = 0;
264+
NumberBlues = 0;
259265
}
260266

261267
#region //////// Append to Log
@@ -282,6 +288,10 @@ public void Info(string msg, params object[] args)
282288
/// </summary>
283289
public void Info(StoredPrint.Color color, string msg, params object[] args)
284290
{
291+
if (color == StoredPrint.Color.Red)
292+
NumberErrors++;
293+
if (color == StoredPrint.Color.Blue)
294+
NumberBlues++;
285295
var p = new StoredPrint(color, String.Format(msg, args));
286296
Append(p);
287297
}

src/AasxPackageExplorer/AasxPackageExplorer.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@
8181

8282
<ItemGroup>
8383
<Folder Include="FlyoutsForPlugins\" />
84+
<None Update="query-presets.json">
85+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
86+
</None>
8487
<None Update="data-spec-presets.json">
8588
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
8689
</None>

src/AasxPackageExplorer/MainWindow.CommandBindings.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public async Task CommandExecution_RedrawAllAsync()
9797
/// </summary>
9898
public bool ScriptModeShutdown = false;
9999

100-
public async Task<int> ExecuteMainMenuCommand(string menuItemName, params object[] args)
100+
public async Task<int> ExecuteMainMenuCommand(string menuItemName, bool scriptMode, params object[] args)
101101
{
102102
if (menuItemName?.HasContent() != true)
103103
{
@@ -123,7 +123,7 @@ public async Task<int> ExecuteMainMenuCommand(string menuItemName, params object
123123
var ticket = new AasxMenuActionTicket()
124124
{
125125
MenuItem = mi,
126-
ScriptMode = true,
126+
ScriptMode = scriptMode,
127127
ArgValue = new AasxMenuArgDictionary()
128128
};
129129

src/AasxPackageExplorer/MainWindow.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,8 @@
382382
<Label x:Name="LabelNumberErrors"
383383
DockPanel.Dock="Right" MinWidth="60" Margin="2,3,2,2" Padding="2,0,2,0"
384384
VerticalContentAlignment="Center" BorderBrush="LightGray" BorderThickness="1"
385-
Content="No errors"/>
385+
Content="No errors"
386+
MouseDown="LabelNumberErrors_MouseDown"/>
386387

387388
<Grid DockPanel.Dock="Right">
388389
<Grid.RowDefinitions>

src/AasxPackageExplorer/MainWindow.xaml.cs

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,7 @@ private async void Window_Loaded(object sender, RoutedEventArgs e)
10681068

10691069
// Package Central starting ..
10701070
PackageCentral.CentralRuntimeOptions = UiBuildRuntimeOptionsForMainAppLoad();
1071+
PackageCentral.ExecuteMainCommand = this;
10711072

10721073
// start with empty repository and load, if given by options
10731074
RepoListControl.PackageCentral = PackageCentral;
@@ -1285,12 +1286,16 @@ private async void Window_Loaded(object sender, RoutedEventArgs e)
12851286
};
12861287

12871288
// what happens on a file drop -> dispatch
1288-
RepoListControl.FileDrop += (senderList, fr, files) =>
1289+
RepoListControl.FileDrop += async (senderList, fr, files) =>
12891290
{
12901291
// access
12911292
if (files == null || files.Length < 1)
12921293
return;
12931294

1295+
// hand over the full list for potential bulk adding
1296+
if (fr != null)
1297+
await fr.AddByListOfAasxFn(PackageCentral, files);
1298+
12941299
// more than one?
12951300
foreach (var fn in files)
12961301
{
@@ -1387,6 +1392,11 @@ private async void Window_Loaded(object sender, RoutedEventArgs e)
13871392

13881393
if (container == null)
13891394
Log.Singleton.Error($"Failed to auto-load AASX from {location}");
1395+
else if (container.Env?.AasEnv != null && container.Env.AasEnv.AllIdentifiables().Count() < 1)
1396+
{
1397+
Log.Singleton.Info(StoredPrint.Color.Blue,
1398+
$"Auto-load request seem to result in empty data! Auto-load location: {location}");
1399+
}
13901400
else
13911401
UiLoadPackageWithNew(PackageCentral.MainItem,
13921402
takeOverContainer: container, onlyAuxiliary: false, indexItems: true,
@@ -1525,6 +1535,9 @@ private void ToolFindReplace_ResultSelected(AasxSearchUtil.SearchResultItem resu
15251535
onlyReFocus: true));
15261536
}
15271537

1538+
private string _lastMessageBlue = "";
1539+
private string _lastMessageError = "";
1540+
15281541
private void MainTimer_HandleLogMessages()
15291542
{
15301543
// pop log messages from the plug-ins into the Stored Prints in Log
@@ -1551,20 +1564,23 @@ private void MainTimer_HandleLogMessages()
15511564
}
15521565
case StoredPrint.Color.Blue:
15531566
{
1567+
_lastMessageBlue = "" + sp.msg;
15541568
Message.Background = Brushes.LightBlue;
15551569
Message.Foreground = Brushes.Black;
15561570
Message.FontWeight = FontWeights.Normal;
15571571
break;
15581572
}
15591573
case StoredPrint.Color.Yellow:
15601574
{
1575+
_lastMessageBlue = "" + sp.msg;
15611576
Message.Background = Brushes.Yellow;
15621577
Message.Foreground = Brushes.Black;
15631578
Message.FontWeight = FontWeights.Bold;
15641579
break;
15651580
}
15661581
case StoredPrint.Color.Red:
15671582
{
1583+
_lastMessageError = "" + sp.msg;
15681584
Message.Background = new SolidColorBrush(Color.FromRgb(0xd4, 0x20, 0x44)); // #D42044
15691585
Message.Foreground = Brushes.White;
15701586
Message.FontWeight = FontWeights.Bold;
@@ -1590,14 +1606,21 @@ private void MainTimer_HandleLogMessages()
15901606

15911607
// always tell the errors
15921608
var ne = Log.Singleton.NumberErrors;
1609+
var nb = Log.Singleton.NumberBlues;
15931610
if (ne > 0)
15941611
{
15951612
LabelNumberErrors.Content = "Errors: " + ne;
15961613
LabelNumberErrors.Background = new SolidColorBrush(Color.FromRgb(0xd4, 0x20, 0x44)); // #D42044
15971614
}
15981615
else
1616+
if (nb > 0)
1617+
{
1618+
LabelNumberErrors.Content = "Major: " + nb;
1619+
LabelNumberErrors.Background = Brushes.LightBlue;
1620+
}
1621+
else
15991622
{
1600-
LabelNumberErrors.Content = "No errors";
1623+
LabelNumberErrors.Content = "No attention";
16011624
LabelNumberErrors.Background = Brushes.White;
16021625
}
16031626
}
@@ -3224,6 +3247,8 @@ private async Task ButtonHistory_ObjectRequested(object sender, VisualElementHis
32243247
/// </summary>
32253248
public void StatusLineClear()
32263249
{
3250+
_lastMessageBlue = "";
3251+
_lastMessageError = "";
32273252
Log.Singleton.ClearNumberErrors();
32283253
Message.Content = "";
32293254
Message.Background = Brushes.White;
@@ -3232,6 +3257,29 @@ public void StatusLineClear()
32323257
SetProgressDownload();
32333258
}
32343259

3260+
public void ShowLastMessage(StoredPrint.Color showColor)
3261+
{
3262+
switch (showColor)
3263+
{
3264+
case StoredPrint.Color.Blue:
3265+
{
3266+
Message.Content = "" + _lastMessageBlue;
3267+
Message.Background = Brushes.LightBlue;
3268+
Message.Foreground = Brushes.Black;
3269+
Message.FontWeight = FontWeights.Normal;
3270+
break;
3271+
}
3272+
case StoredPrint.Color.Red:
3273+
{
3274+
Message.Content = "" + _lastMessageError;
3275+
Message.Background = new SolidColorBrush(Color.FromRgb(0xd4, 0x20, 0x44)); // #D42044
3276+
Message.Foreground = Brushes.White;
3277+
Message.FontWeight = FontWeights.Bold;
3278+
break;
3279+
}
3280+
}
3281+
}
3282+
32353283
/// <summary>
32363284
/// Show log in a window / list perceivable for the user.
32373285
/// </summary>
@@ -3290,6 +3338,16 @@ private void ButtonReport_Click(object sender, RoutedEventArgs e)
32903338
}
32913339
}
32923340

3341+
private void LabelNumberErrors_MouseDown(object sender, MouseButtonEventArgs e)
3342+
{
3343+
// something important
3344+
if (Log.Singleton.NumberErrors > 0 && _lastMessageError?.HasContent() == true)
3345+
ShowLastMessage(StoredPrint.Color.Red);
3346+
else
3347+
if (Log.Singleton.NumberBlues > 0 && _lastMessageBlue?.HasContent() == true)
3348+
ShowLastMessage(StoredPrint.Color.Blue);
3349+
}
3350+
32933351
/// <summary>
32943352
/// Take a screenshot and save to file
32953353
/// </summary>
@@ -4519,6 +4577,5 @@ private async void Button_Click(object sender, RoutedEventArgs e)
45194577
}
45204578
}
45214579

4522-
45234580
}
45244581
}

src/AasxPackageExplorer/options-debug.MIHO.json

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
/* If set, start in editor mode instead of browse mode. */
33
"EditMode": true
44
/* If set, do not start in hinting mode. */,
5-
"NoHints": true
6-
/* This file shall be loaded as main package at start of application | Arg: <path> */,
7-
"AasxToLoad": "http://localhost:8081/shells/aHR0cHM6Ly9hZG1pbi1zaGVsbC1pby9pZHRhL2Fhcy9Qcm9kdWN0Q2hhbmdlTm90aWZpY2F0aW9ucy8xLzA"
5+
"NoHints": true,
6+
/* This file shall be loaded as main package at start of application | Arg: <path> */
7+
// "AasxToLoad": "http://localhost:8081/shells/aHR0cHM6Ly9hZG1pbi1zaGVsbC1pby9pZHRhL2Fhcy9Qcm9kdWN0Q2hhbmdlTm90aWZpY2F0aW9ucy8xLzA"
8+
// "AasxToLoad": "http://localhost:8081/shells/aHR1cHM6Ly9hZG1pbi1zaGVsbC1pby9pZHRhL2Fhcy9Qcm9kdWN0Q2hhbmdlTm90aWZpY2F0aW9ucy8xLzA"
89
// "AasxToLoad": "C:\\Users\\Micha\\Desktop\\test-smt-on-basyx\\IDTA_02036-1-0_SMT_ProductChangeNotification_Draft_v35_manual_fixes.aasx"
10+
"AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\SMT\\IDTA 02036-1-0_Submodel_ProductChangeNotification\\IDTA_02036-1-0_SMT_ProductChangeNotification_Draft_v40_add_podman.aasx"
911
/* This file shall be loaded as aux package at start of application | Arg: <path> */,
1012
"AuxToLoad": null
1113
/* List of pathes to a JSON, defining a set of AasxPackage-Files, which serve as repository. | Arg: <path> */,
@@ -31,18 +33,18 @@
3133
"Method": "Ask", // None, Ask, Basic, CertificateStore, File, InteractiveEntry, Secret
3234
"Username": "Admin",
3335
"Password": "",
34-
// "Password": "SuperSafePasswd",
36+
// "Password": "superSafePasswd",
3537
// "AuthServer": "",
3638
"AuthServer": "https://www.admin-shell-io.com/50001/.well-known/openid-configuration", // for rest of authentication
3739
// "AuthServer": "https://credential.aas-voyager.com/token", // for secret based OpenID Connect
3840
"CertFile": "",
3941
"CertPassword": "",
40-
"CertPick": "GEANT",
41-
// "CertPick" : "",
42-
// "SecretId": "",
43-
"SecretId": "aorzelski@phoenixcontact.com",
44-
// "SecretValue": "",
45-
"SecretValue": "aorzelski@phoenixcontact.com-secret"
42+
// "CertPick": "GEANT",
43+
"CertPick": "",
44+
"SecretId": "",
45+
// "SecretId": "aorzelski@phoenixcontact.com",
46+
"SecretValue": ""
47+
// "SecretValue": "aorzelski@phoenixcontact.com-secret"
4648
}
4749
},
4850
{
@@ -75,15 +77,15 @@
7577
/* Maximum parallel write operations, such as HTTP uploads. */,
7678
"MaxParallelWriteOps": 1
7779
/* For connecting to repositories/ registry, default pagination limit. */,
78-
"DefaultConnectPageLimit" : 20
80+
"DefaultConnectPageLimit": 20
7981
/* If not -1, the left of window | Arg: <pixel> */,
8082
"WindowLeft": -1
8183
/* If not -1, the top of window | Arg: <pixel> */,
8284
"WindowTop": -1
8385
/* If not -1, the width of window | Arg: <pixel> */,
84-
"WindowWidth": 900
86+
"WindowWidth": 1440
8587
/* If not -1, the height of window | Arg: <pixel> */,
86-
"WindowHeight": 600
88+
"WindowHeight": 584
8789
/* If set, then maximize window on application startup */,
8890
"WindowMaximized": false
8991
/* Template string for the id of an AAS. Could contain up to 16 placeholders of: D = decimal digit, X = hex digit, A = alphanumerical digit | Arg: <string> */,
@@ -112,14 +114,16 @@
112114
"ExtensionsPresetFile": "extension-presets.json"
113115
/* Path to JSON file defining data specification presets. | Arg: <path> */,
114116
"DataSpecPresetFile": "data-spec-presets.json"
117+
/* Path to JSON file defining query presets. */,
118+
"QueryPresetFile": "query-presets.json"
115119
/* Home address of the content browser on startup, on change of AASX | Arg: <URL> */,
116120
"ContentHome": "https://github.com/eclipse-aaspe/package-explorer/blob/main/README.md"
117121
/* If unset, use transparent flyover dialogs, where possible */,
118122
"UseFlyovers": true
119123
/* If other then -1, then time in ms for the splash window to stay on the screen. | Arg: <milli-secs> */,
120124
"SplashTime": 0
121125
/* Fraction of main window with dedicated to left column of screen when resizing window. | Arg: Percent 0-100.0 */,
122-
"PercentageLeftColumn": 12.0
126+
"PercentageLeftColumn": 15.0
123127
/* Fraction of main window with dedicated to right column of screen (content section) when resizing window. | Arg: Percent 0-100.0 */,
124128
"PercentageRightColumn": 60.0
125129
/* If true, use always internal browser */,

src/AasxPackageExplorer/options-debug.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"ExtensionsPresetFile": "extension-presets.json",
2222
"IdentifierKeyValuePairsFile": "local-identifier-presets.json",
2323
"DataSpecPresetFile": "data-spec-presets.json",
24+
"QueryPresetFile": "query-presets.json",
2425
"ContentHome": "https://github.com/admin-shell/io/blob/master/README.md",
2526
"UseFlyovers": true,
2627
"SplashTime": 0,

0 commit comments

Comments
 (0)