Skip to content

Commit d8cc8ca

Browse files
committed
* improve BOM plugin
functionality
1 parent 951b3df commit d8cc8ca

File tree

7 files changed

+139
-12
lines changed

7 files changed

+139
-12
lines changed

src/AasxCsharpLibrary/Extensions/ExtendIReferable.cs

+21
Original file line numberDiff line numberDiff line change
@@ -607,5 +607,26 @@ public static void MigrateV20QualifiersToExtensions(this IReferable rf)
607607
}
608608
}
609609

610+
public static void FixReferences(IReferable rf, IEnumerable<ISubmodel> smToCheck)
611+
{
612+
if (rf == null || smToCheck == null)
613+
return;
614+
foreach (var x in rf.DescendOnce())
615+
if (x is IReference xrf
616+
&& xrf.Count() > 0
617+
&& xrf.Keys.First()?.Type == KeyTypes.Submodel
618+
&& xrf.Keys.First().Value?.HasContent() == true)
619+
{
620+
foreach (var smtc in smToCheck)
621+
if (smtc.IdShort?.HasContent() == true
622+
&& smtc.Id?.HasContent() == true
623+
&& xrf.Keys.First().Value.Trim() == smtc.IdShort.Trim())
624+
{
625+
// found place to fix
626+
xrf.Keys.First().Value = smtc.Id;
627+
}
628+
}
629+
}
630+
610631
}
611632
}

src/AasxPackageExplorer/debug.MIHO.script

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ Select("Submodel", "First");
2323
// Tool("submodelinstancefromsammaspect");
2424
// Tool("importtable", "Format", "Excel", "Preset", "Submodel templ. spec. import", "File", "C:\\HOMI\\Develop\\Aasx\\repo\\bugfix\\test-import.xlsx");
2525
// Tool("WinMaximize");
26-
Tool("ExportTable", "File", "C:\\HOMI\\Develop\\Aasx\\repo\\new.adoc", "Preset", "AsciiDoc");
26+
// Tool("ExportTable", "File", "C:\\HOMI\\Develop\\Aasx\\repo\\new.adoc", "Preset", "AsciiDoc");

src/AasxPackageExplorer/options-debug.MIHO.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_TechData_Work\\IDTA 02003-1-2_SubmodelTemplate_TechnicalData_v1.2__with_Draft_1_3_and_AsciiDoc_v01.aasx",
4040
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_ProductChangeNotification\\IDTA_02036-1-0_SMT_ProductChangeNotification_Draft_v21.aasx",
4141
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_ProductChangeNotification\\SMT_ProductChangeNotification_Draft_v20_spiel.aasx",
42-
"AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_ProductChangeNotification\\IDTA_02036-1-0_SMT_ProductChangeNotification_Examples_v08.aasx",
42+
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_ProductChangeNotification\\IDTA_02036-1-0_SMT_ProductChangeNotification_Examples_v08.aasx",
43+
"AasxToLoad": "C:\\Users\\homi0002\\Desktop\\tmp\\Syn2tecMachine_P2518_AAS__V3_DL2.aasx",
4344
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\tmp\\00_FestoDemoBox-Module-2-Kopie.aasx",
4445
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\tmp\\8001203_SPAU-P10R-T-R18M-L-PNLK-PNVBA-M8D_060ff64f-9fd2-422d-81ce-b17e49f007c5_work_spiel.aasx",
4546
// "AasxToLoad": "C:\\MIHO\\Develop\\Aasx\\repo\\SMT_and_SAMM_Showcase_v02.aasx",
@@ -207,10 +208,9 @@
207208
{
208209
"Path": "..\\..\\..\\..\\..\\..\\AasxPluginWebBrowser\\bin\\x64\\Debug\\AasxPluginWebBrowser.dll",
209210
"Args": []
210-
}
211+
},
211212

212213
// Festo specific from here on
213-
/*
214214
{
215215
"Path": "..\\..\\..\\..\\..\\..\\..\\..\\AasxFesto\\AasxFesto\\AasxPluginFluiddrawViewer\\bin\\Debug\\net6.0-windows\\AasxPluginFluiddrawViewer.dll",
216216
"Args": []
@@ -219,7 +219,6 @@
219219
"Path": "..\\..\\..\\..\\..\\..\\..\\..\\AasxFesto\\AasxFesto\\AasxPluginFluiddrawBom\\bin\\Debug\\net6.0-windows\\AasxPluginFluiddrawBom.dll",
220220
"Args": []
221221
}
222-
*/
223222
],
224223
"SecureConnectPresets": [
225224
{

src/AasxPackageLogic/DispEditHelperEntities.cs

+39-7
Original file line numberDiff line numberDiff line change
@@ -1940,16 +1940,12 @@ public void DisplayOrEditAasEntitySubmodelOrRef(
19401940
ticketMenu: new AasxMenu()
19411941
.AddAction("upgrade-qualifiers", "Upgrade qualifiers",
19421942
"Upgrades particular qualifiers from V2.0 to V3.0 for selected element.")
1943-
#if __moved_to_menu
1944-
.AddAction("SMT-qualifiers-convert", "Convert SMT qualifiers",
1945-
"Converts particular SMT qualifiers to SMT extension for selected element.")
1946-
.AddAction("SMT-set-organize", "Set SMT organize",
1947-
"Take over Submodel's element relationships to associated concepts.")
1948-
#endif
19491943
.AddAction("remove-qualifiers", "Remove qualifiers",
19501944
"Removes all qualifiers for selected element.")
19511945
.AddAction("remove-extensions", "Remove extensions",
1952-
"Removes all extensions for selected element."),
1946+
"Removes all extensions for selected element.")
1947+
.AddAction("fix-references", "Fix References",
1948+
"Fix, if References first key to Identifiables use idShort instead of id."),
19531949
ticketAction: (buttonNdx, ticket) =>
19541950
{
19551951
if (buttonNdx == 0)
@@ -2151,6 +2147,42 @@ public void DisplayOrEditAasEntitySubmodelOrRef(
21512147
return new AnyUiLambdaActionRedrawAllElements(nextFocus: smref, isExpanded: true);
21522148
}
21532149

2150+
if (buttonNdx == 3)
2151+
{
2152+
// confirm
2153+
if (ticket?.ScriptMode != true
2154+
&& AnyUiMessageBoxResult.Yes != this.context.MessageBoxFlyoutShow(
2155+
"This operation will affect all References within " +
2156+
"the Submodel and all of its SubmodelElements. Do you want to proceed?",
2157+
"Fix References",
2158+
AnyUiMessageBoxButton.YesNo, AnyUiMessageBoxImage.Warning))
2159+
return new AnyUiLambdaActionNone();
2160+
2161+
// action
2162+
try
2163+
{
2164+
ExtendIReferable.FixReferences(submodel, env?.AllSubmodels());
2165+
submodel.RecurseOnSubmodelElements(null, (o, parents, sme) =>
2166+
{
2167+
// upgrade
2168+
ExtendIReferable.FixReferences(sme, env?.AllSubmodels());
2169+
2170+
// recurse
2171+
return true;
2172+
});
2173+
2174+
}
2175+
catch (Exception ex)
2176+
{
2177+
Log.Singleton.Error(
2178+
ex, $"While fixing References.");
2179+
}
2180+
2181+
// emit event for Submodel and children
2182+
this.AddDiaryEntry(submodel, new DiaryEntryStructChange(), allChildrenAffected: true);
2183+
2184+
return new AnyUiLambdaActionRedrawAllElements(nextFocus: smref, isExpanded: true);
2185+
}
21542186
return new AnyUiLambdaActionNone();
21552187
});
21562188

src/AasxPluginBomStructure/AasxPluginBomStructure.Options.json

+69
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"Width": 1.0,
8282
"Title": "isPartOf"
8383
},
84+
// VWS4LS used "ConceptDescription"
8485
{
8586
"Match": {
8687
"type": "ConceptDescription",
@@ -113,9 +114,77 @@
113114
"Stroke": "Black",
114115
"Width": 1.0,
115116
"Title": "isPartOf"
117+
},
118+
// according IDTA 0211-1-1
119+
{
120+
"Match": {
121+
"type": "GlobalReference",
122+
"value": "https://admin-shell.io/idta/HierarchicalStructures/SameAs/1/0"
123+
},
124+
"Start": "Normal",
125+
"End": "Normal",
126+
"Stroke": "Black",
127+
"Width": 1.0,
128+
"Title": "sameAs"
129+
},
130+
{
131+
"Match": {
132+
"type": "GlobalReference",
133+
"value": "https://admin-shell.io/idta/HierarchicalStructures/HasPart/1/0"
134+
},
135+
"Start": "None",
136+
"End": "Normal",
137+
"Stroke": "Black",
138+
"Width": 1.0,
139+
"Title": "hasPart"
140+
},
141+
{
142+
"Match": {
143+
"type": "GlobalReference",
144+
"value": "https://admin-shell.io/idta/HierarchicalStructures/IsPartOf/1/0"
145+
},
146+
"Start": "None",
147+
"End": "Normal",
148+
"Stroke": "Black",
149+
"Width": 1.0,
150+
"Title": "isPartOf"
116151
}
117152
],
118153
"NodeStyles": [
154+
// according IDTA 0211-1-1
155+
{
156+
"Match": {
157+
"type": "GlobalReference",
158+
"value": "https://admin-shell.io/idta/HierarchicalStructures/EntryNode/1/0"
159+
},
160+
"Skip": false,
161+
"Shape": "Circle",
162+
"Background": "#7F99FF",
163+
"Stroke": "#0128CB",
164+
"LineWidth": 2.0,
165+
"Radius": 0.0,
166+
"FontSize": 8.0,
167+
"Dashed": true,
168+
"FontBold": false,
169+
"Dotted": false
170+
},
171+
{
172+
"Match": {
173+
"type": "GlobalReference",
174+
"value": "https://admin-shell.io/idta/HierarchicalStructures/Node/1/0"
175+
},
176+
"Skip": false,
177+
"Shape": "Box",
178+
"Background": "#DBE2FF",
179+
"Stroke": "#0128CB",
180+
"LineWidth": 1.0,
181+
"Radius": 0.0,
182+
"FontSize": 8.0,
183+
"Dashed": true,
184+
"FontBold": false,
185+
"Dotted": false
186+
},
187+
// VWS4LS used "ConceptDescription"
119188
{
120189
"Match": {
121190
"type": "ConceptDescription",

src/AasxPluginBomStructure/GenericBomControl.cs

+3
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ private Microsoft.Msagl.Drawing.Graph CreateGraph(
406406
}
407407
}
408408

409+
409410
// make default or (already) preferred settings
410411
var settings = GivePresetSettings(options, graph.NodeCount);
411412
if (this.preferredPreset != null && sm != null
@@ -414,6 +415,8 @@ private Microsoft.Msagl.Drawing.Graph CreateGraph(
414415
if (settings != null)
415416
graph.LayoutAlgorithmSettings = settings;
416417

418+
graph.Attr.LayerDirection = Microsoft.Msagl.Drawing.LayerDirection.LR;
419+
417420
#endif
418421
return graph;
419422
}

src/AasxPluginBomStructure/GenericBomCreator.cs

+3
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,9 @@ public void RecurseOnLayout(
607607
// includes AnnotatedRelationshipElement
608608
x1 = this.FindReferableByReference(rel.First);
609609
x2 = this.FindReferableByReference(rel.Second);
610+
611+
if (x1 == null || x2 == null)
612+
;
610613
}
611614

612615
if (sme is Aas.IReferenceElement rfe)

0 commit comments

Comments
 (0)