Skip to content

Commit fa269b0

Browse files
committed
* merge
2 parents 9f4a903 + 5cfce2c commit fa269b0

10 files changed

+1370
-139
lines changed

src/AasxCsharpLibrary/Extensions/ExtendEnvironment.cs

+8-3
Original file line numberDiff line numberDiff line change
@@ -756,10 +756,12 @@ public bool IsValid
756756
}
757757

758758
//TODO (jtikekar, 0000-00-00): Need to test
759+
//Micha added check for sourceOfSubElems to check if index is in SML
759760
public static IReferable FindReferableByReference(
760761
this AasCore.Aas3_0.IEnvironment environment,
761762
IReference reference,
762763
int keyIndex = 0,
764+
IReferable sourceOfSubElems = null,
763765
IEnumerable<ISubmodelElement> submodelElems = null,
764766
ReferableRootInfo rootInfo = null)
765767
{
@@ -872,7 +874,8 @@ public static IReferable FindReferableByReference(
872874
if (keyIndex >= keyList.Count - 1)
873875
return submodel;
874876

875-
return environment.FindReferableByReference(reference, ++keyIndex, submodel.SubmodelElements);
877+
return environment.FindReferableByReference(reference, ++keyIndex,
878+
submodel, submodel.SubmodelElements);
876879
}
877880
}
878881

@@ -882,7 +885,8 @@ public static IReferable FindReferableByReference(
882885
{
883886
ISubmodelElement submodelElement;
884887
//check if key.value is index
885-
bool isIndex = int.TryParse(firstKeyId, out int index);
888+
var index = 0;
889+
bool isIndex = (sourceOfSubElems is ISubmodelElementList) && int.TryParse(firstKeyId, out index);
886890
if (isIndex)
887891
{
888892
var smeList = submodelElems.ToList();
@@ -905,7 +909,8 @@ public static IReferable FindReferableByReference(
905909

906910
//Recurse again
907911
if (submodelElement?.EnumeratesChildren() == true)
908-
return environment.FindReferableByReference(reference, ++keyIndex, submodelElement.EnumerateChildren());
912+
return environment.FindReferableByReference(reference, ++keyIndex,
913+
submodelElement, submodelElement.EnumerateChildren());
909914
}
910915
}
911916

src/AasxCsharpLibrary/Extensions/ExtendReference.cs

+39
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This source code is licensed under the Apache License 2.0 (see LICENSE.txt).
77
This source code may use other Open Source software components (see LICENSE.txt).
88
*/
99
using AdminShellNS.Exceptions;
10+
using System;
1011
using System.Collections.Generic;
1112
using System.Linq;
1213

@@ -198,6 +199,44 @@ public static bool Matches(this IReference reference, IReference otherReference,
198199
return match;
199200
}
200201

202+
/// <summary>
203+
/// Checks, if there is a partial match from <c>reference</c> to <c>findReference</c>
204+
/// (starting from key[0]) and replaces those sequence
205+
/// </summary>
206+
/// <returns><c>True</c>, if a replacement was done</returns>
207+
public static bool ReplacePartialHead(
208+
this IReference reference,
209+
IReference findReference,
210+
IReference replaceReference,
211+
MatchMode matchMode = MatchMode.Strict)
212+
{
213+
// access
214+
if (reference.Keys == null || reference.Keys.Count == 0
215+
|| findReference?.Keys == null || findReference.Keys.Count == 0
216+
|| replaceReference?.Keys == null)
217+
{
218+
return false;
219+
}
220+
221+
// match?
222+
bool match = true;
223+
var matchLen = Math.Min(reference.Keys.Count, findReference.Keys.Count);
224+
for (int i = 0; i < matchLen; i++)
225+
{
226+
match = match && reference.Keys[i].Matches(findReference.Keys[i], matchMode);
227+
}
228+
if (!match)
229+
return false;
230+
231+
// execute replacement
232+
for (int i = 0; i < matchLen; i++)
233+
reference.Keys.RemoveAt(0);
234+
for (int i = Math.Min(matchLen - 1, replaceReference.Count() - 1); i >= 0; i--)
235+
reference.Keys.Insert(0, replaceReference.Keys[i].Copy());
236+
237+
return true;
238+
}
239+
201240
/// <summary>
202241
/// Useful, if the searched reference will have only one key (e.g. ECLASS properties)
203242
/// </summary>

src/AasxCsharpLibrary/Extensions/ExtendSubmodel.cs

+75
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,81 @@ public static void RecurseOnSubmodelElements(this ISubmodel submodel, object sta
384384
});
385385
}
386386

387+
public static IReferable FindContainingReferable(this ISubmodel submodel, ISubmodelElement findSme)
388+
{
389+
IReferable res = null;
390+
submodel.SubmodelElements?.RecurseOnReferables(null, null, (o, par, rf) =>
391+
{
392+
if (rf == findSme)
393+
{
394+
if (par.Count < 1)
395+
res = submodel;
396+
else
397+
res = par.LastOrDefault();
398+
return false;
399+
}
400+
else
401+
return true;
402+
});
403+
return res;
404+
}
405+
406+
/// <summary>
407+
/// Builds up a key list for an IReference. Relies on integrity of the <code>Parent</code>
408+
/// attributes!!
409+
/// </summary>
410+
public static List<IKey> BuildKeysToTop(this ISubmodel submodel, ISubmodelElement findSme)
411+
{
412+
// make a "inner function"
413+
var res = new List<IKey>();
414+
var resHasIdf = false;
415+
Action<IReferable> lambdaInsertTop = (rf) =>
416+
{
417+
if (rf is IIdentifiable iddata)
418+
{
419+
// a Identifiable will terminate the list of keys
420+
resHasIdf = true;
421+
res.Insert(
422+
0,
423+
new Key((KeyTypes)Stringification.KeyTypesFromString(iddata.GetSelfDescription().AasElementName), iddata.Id));
424+
}
425+
else
426+
{
427+
// add a key and go up ..
428+
IKey key;
429+
if (rf is ISubmodelElementList smeList)
430+
{
431+
var index = smeList.Value.IndexOf((ISubmodelElement)rf);
432+
key = new Key((KeyTypes)Stringification.KeyTypesFromString(rf.GetSelfDescription().AasElementName), index.ToString());
433+
}
434+
else
435+
{
436+
key = new Key((KeyTypes)Stringification.KeyTypesFromString(rf.GetSelfDescription().AasElementName), rf.IdShort);
437+
}
438+
res.Insert(0, key);
439+
}
440+
};
441+
442+
// insert self ..
443+
if (findSme != null)
444+
{
445+
lambdaInsertTop(findSme);
446+
var curr = findSme.Parent as IReferable;
447+
while (curr != null)
448+
{
449+
lambdaInsertTop(curr);
450+
curr = curr.Parent as IReferable;
451+
}
452+
}
453+
454+
// in case that Identifiable hasnt been added
455+
if (!resHasIdf)
456+
lambdaInsertTop(submodel);
457+
458+
// ok
459+
return res;
460+
}
461+
387462
public static ISubmodelElement FindSubmodelElementByIdShort(this ISubmodel submodel, string smeIdShort)
388463
{
389464
if (submodel.SubmodelElements == null || submodel.SubmodelElements.Count == 0)

src/AasxPackageExplorer/options-debug.MIHO.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_ProductChangeNotification\\IDTA_02036-1-0_SMT_ProductChangeNotification_Draft_v22.aasx",
4141
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_ProductChangeNotification\\IDTA_02036-1-0_SMT_ProductChangeNotification_Examples_v08.aasx",
4242
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_ProductChangeNotification\\SMT_ProductChangeNotification_Draft_v20_spiel.aasx",
43+
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_ProductChangeNotification\\IDTA_02036-1-0_SMT_ProductChangeNotification_Examples_v08.aasx",
4344
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\tmp\\Syn2tecMachine_P2518_AAS__V3_DL2.aasx",
45+
"AasxToLoad": "C:\\MIHO\\Develop\\Aasx\\repo\\Syn2tecMachine_P2518_AAS__V3_DL2.aasx",
4446
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\tmp\\00_FestoDemoBox-Module-2-Kopie.aasx",
4547
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\tmp\\8001203_SPAU-P10R-T-R18M-L-PNLK-PNVBA-M8D_060ff64f-9fd2-422d-81ce-b17e49f007c5_work_spiel.aasx",
4648
// "AasxToLoad": "C:\\MIHO\\Develop\\Aasx\\repo\\SMT_and_SAMM_Showcase_v02.aasx",
@@ -219,7 +221,7 @@
219221
{
220222
"Path": "..\\..\\..\\..\\..\\..\\..\\..\\AasxFesto\\AasxFesto\\AasxPluginFluiddrawBom\\bin\\Debug\\net6.0-windows\\AasxPluginFluiddrawBom.dll",
221223
"Args": []
222-
}
224+
}
223225
],
224226
"SecureConnectPresets": [
225227
{

src/AasxPluginBomStructure/AasxPluginBomStructure.Options.json

+79-2
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
"Background": "#7F99FF",
163163
"Stroke": "#0128CB",
164164
"LineWidth": 2.0,
165-
"Radius": 0.0,
165+
"Radius": 2.0,
166166
"FontSize": 8.0,
167167
"Dashed": true,
168168
"FontBold": false,
@@ -178,7 +178,7 @@
178178
"Background": "#DBE2FF",
179179
"Stroke": "#0128CB",
180180
"LineWidth": 1.0,
181-
"Radius": 0.0,
181+
"Radius": 2.0,
182182
"FontSize": 8.0,
183183
"Dashed": true,
184184
"FontBold": false,
@@ -217,6 +217,83 @@
217217
"FontBold": false,
218218
"Dotted": false
219219
}
220+
],
221+
"NodeSupplSemIds": [
222+
"http://admin-shell.io/sandbox/CompositeComponent/General/EntityOfBOM/1/0",
223+
"http://admin-shell.io/sandbox/CompositeComponent/General/FeatureOfEntity/1/0",
224+
"http://admin-shell.io/sandbox/CompositeComponent/Mechanical/EntityOfPhysicalBreakdown/1/0",
225+
"http://admin-shell.io/sandbox/CompositeComponent/Mechanical/EntityOfFunctionalBreakdown/1/0",
226+
"http://admin-shell.io/sandbox/CompositeComponent/Electrical/EntityOfElectricalEngineering/1/0",
227+
"http://admin-shell.io/sandbox/CompositeComponent/Electrical/Potential/1/0",
228+
"http://admin-shell.io/sandbox/CompositeComponent/Electrical/JunctionPoint/1/0",
229+
"http://admin-shell.io/sandbox/CompositeComponent/Electrical/PhysicalCable/1/0",
230+
"http://admin-shell.io/sandbox/CompositeComponent/Electrical/PhysicalWire/1/0",
231+
"http://admin-shell.io/sandbox/CompositeComponent/Fluidic/EntityOfFluidicEngineering/1/0",
232+
"http://admin-shell.io/sandbox/CompositeComponent/Fluidic/Potential/1/0",
233+
"http://admin-shell.io/sandbox/CompositeComponent/Fluidic/JunctionPoint/1/0",
234+
"http://admin-shell.io/sandbox/CompositeComponent/Fluidic/Tube/1/0",
235+
"http://admin-shell.io/sandbox/CompositeComponent/Fluidic/ConnectorTubePipe/1/0",
236+
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/EquipmentEntity/1/0",
237+
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/Valve/1/0",
238+
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/Sensor/1/0",
239+
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/Drive/1/0",
240+
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/PIDCtrl/1/0",
241+
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/TerminationSource/1/0",
242+
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/TerminationSink/1/0",
243+
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/EquipmentEntity/1/0",
244+
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/InstrumentationEntity/1/0",
245+
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/TerminationSource/1/0",
246+
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/TerminationSink/1/0",
247+
"http://admin-shell.io/sandbox/CompositeComponent/ProgrammableLogicControl/PouEntity/1/0",
248+
"http://admin-shell.io/sandbox/CompositeComponent/ProgrammableLogicControl/InstanceOfPou/1/0",
249+
"http://admin-shell.io/sandbox/CompositeComponent/ProgrammableLogicControl/PinOfInstance/1/0",
250+
"http://admin-shell.io/sandbox/CompositeComponent/ProgrammableLogicControl/InformationInput/1/0",
251+
"http://admin-shell.io/sandbox/CompositeComponent/ProgrammableLogicControl/InformationOutput/1/0"
252+
],
253+
"EdgeSupplSemIds": [
254+
"http://admin-shell.io/sandbox/CompositeComponent/General/FileToNavigateElement/1/0",
255+
"http://admin-shell.io/sandbox/CompositeComponent/General/FileToEntity/1/0",
256+
"http://admin-shell.io/sandbox/CompositeComponent/General/IsPartOfForBOM/1/0",
257+
"http://admin-shell.io/sandbox/CompositeComponent/General/IsIdenticalForBOM/1/0",
258+
"http://admin-shell.io/sandbox/CompositeComponent/Mechanical/IsPartOfPhysicalBreakdown/1/0",
259+
"http://admin-shell.io/sandbox/CompositeComponent/Mechanical/IsPartOfFunctionalBreakdown/1/0",
260+
"http://admin-shell.io/sandbox/CompositeComponent/Mechanical/FunctionalDirectlyConnected/1/0",
261+
"http://admin-shell.io/sandbox/CompositeComponent/Mechanical/PermanentJoint/1/0",
262+
"http://admin-shell.io/sandbox/CompositeComponent/Mechanical/DetachableJoint/1/0",
263+
"http://admin-shell.io/sandbox/CompositeComponent/Mechanical/PrismaticJoint/1/0",
264+
"http://admin-shell.io/sandbox/CompositeComponent/Mechanical/RevoluteJoint/1/0",
265+
"http://admin-shell.io/sandbox/CompositeComponent/Mechanical/CylindricalJoint/1/0",
266+
"http://admin-shell.io/sandbox/CompositeComponent/Mechanical/ShericalJoint/1/0",
267+
"http://admin-shell.io/sandbox/CompositeComponent/Electrical/IsPartOfCable/1/0",
268+
"http://admin-shell.io/sandbox/CompositeComponent/Electrical/SinglePoleConnection/1/0",
269+
"http://admin-shell.io/sandbox/CompositeComponent/Electrical/MultiPoleConnection/1/0",
270+
"http://admin-shell.io/sandbox/CompositeComponent/Electrical/BusConnection/1/0",
271+
"http://admin-shell.io/sandbox/CompositeComponent/Electrical/ConnectionOfPotential/1/0",
272+
"http://admin-shell.io/sandbox/CompositeComponent/Electrical/TerminalConnection/1/0",
273+
"http://admin-shell.io/sandbox/CompositeComponent/Fluidic/TubePipeConnection/1/0",
274+
"http://admin-shell.io/sandbox/CompositeComponent/Fluidic/TubePipeConnectionPneumatic/1/0",
275+
"http://admin-shell.io/sandbox/CompositeComponent/Fluidic/TubePipeConnectionHydraulic/1/0",
276+
"http://admin-shell.io/sandbox/CompositeComponent/Fluidic/FittingConnection/1/0",
277+
"http://admin-shell.io/sandbox/CompositeComponent/Fluidic/ManifoldConnection/1/0",
278+
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/PipeConnection/1/0",
279+
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/MeasurementLine/1/0",
280+
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/FunctionalLine/1/0",
281+
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/PipeConnection/1/0",
282+
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/ProcessConnectionLine/1/0",
283+
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/SignalLine/1/0",
284+
"http://admin-shell.io/sandbox/CompositeComponent/ProgrammableLogicControl/ParameterConnection/1/0",
285+
"http://admin-shell.io/sandbox/CompositeComponent/ProgrammableLogicControl/DataConnection/1/0",
286+
"http://admin-shell.io/sandbox/CompositeComponent/ProgrammableLogicControl/EventConnection/1/0",
287+
"http://admin-shell.io/sandbox/CompositeComponent/SoftwareEngineering/ClassEntity/1/0",
288+
"http://admin-shell.io/sandbox/CompositeComponent/SoftwareEngineering/ObjectEntity/1/0",
289+
"http://admin-shell.io/sandbox/CompositeComponent/SoftwareEngineering/ComponentEntity/1/0",
290+
"http://admin-shell.io/sandbox/CompositeComponent/SoftwareEngineering/ExecutionEnvironmentEntity/1/0",
291+
"http://admin-shell.io/sandbox/CompositeComponent/SoftwareEngineering/InheritanceRelationship/1/0",
292+
"http://admin-shell.io/sandbox/CompositeComponent/SoftwareEngineering/AggregateRelationship/1/0",
293+
"http://admin-shell.io/sandbox/CompositeComponent/SoftwareEngineering/ComposeRelationship/1/0",
294+
"http://admin-shell.io/sandbox/CompositeComponent/SoftwareEngineering/IsInstanceOfRelationship/1/0",
295+
"http://admin-shell.io/sandbox/CompositeComponent/SoftwareEngineering/IsInstanceOfRelationship/1/0",
296+
"http://admin-shell.io/sandbox/CompositeComponent/SoftwareEngineering/IsExecutedInRelationship/1/0"
220297
]
221298
}
222299
]

src/AasxPluginBomStructure/AasxPluginBomStructure.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</ItemGroup>
2525
<ItemGroup>
2626
<ProjectReference Include="..\AasxIntegrationBase\AasxIntegrationBase.csproj" />
27-
<ProjectReference Include="..\MsaglWpfControl\MsaglWpfControl.csproj" />
27+
<ProjectReference Include="..\AasxPredefinedConcepts\AasxPredefinedConcepts.csproj" />
2828
</ItemGroup>
2929
<ItemGroup>
3030
<Resource Include="LICENSE.TXT">
@@ -39,6 +39,7 @@
3939
<ItemGroup>
4040
<PackageReference Include="AutomaticGraphLayout" Version="1.1.12" />
4141
<PackageReference Include="AutomaticGraphLayout.Drawing" Version="1.1.12" />
42+
<PackageReference Include="AutomaticGraphLayout.WpfGraphControl" Version="1.1.12" />
4243
<PackageReference Include="JetBrains.Annotations" Version="2022.1.0" />
4344
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
4445
</ItemGroup>

src/AasxPluginBomStructure/BomStructureOptions.cs

+3
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ public class BomStructureOptionsRecord : AasxPluginOptionsLookupRecordBase
8686
public ListOfBomArguments LinkStyles = new ListOfBomArguments();
8787
public ListOfBomArguments NodeStyles = new ListOfBomArguments();
8888

89+
public List<string> NodeSupplSemIds = new List<string>();
90+
public List<string> EdgeSupplSemIds = new List<string>();
91+
8992
public void Index()
9093
{
9194
LinkStyles.Index();

0 commit comments

Comments
 (0)