Skip to content

Commit

Permalink
Small code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
barnstee committed Jan 16, 2025
1 parent cd9577b commit 41e7165
Showing 1 changed file with 0 additions and 83 deletions.
83 changes: 0 additions & 83 deletions I4AASNodeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,89 +202,6 @@ private void AddNodesFromNodesetXml(string nodesetFile)
}
}

public static Referable? FindReferableByReference(AssetAdministrationShellEnvironment environment, Reference? reference, int keyIndex = 0)
{
if (environment == null || reference == null)
{
return null;
}

var keyList = reference?.Keys;
if (keyList == null || keyList.Count == 0 || keyIndex >= keyList.Count)
{
return null;
}

var firstKeyType = keyList[keyIndex].Type;
var firstKeyId = keyList[keyIndex].Value;

switch (firstKeyType)
{
case KeyElements.AssetAdministrationShell:
{
var aas = environment.AssetAdministrationShells.Where(
shell => shell.IdShort.Equals(firstKeyId,
StringComparison.OrdinalIgnoreCase)).First();

if (aas == null || keyIndex >= keyList.Count - 1)
{
return aas;
}

return FindReferableByReference(environment, reference, ++keyIndex);
}

case KeyElements.GlobalReference:
{
var keyedAas = environment.AssetAdministrationShells.Where(
globalRef => globalRef.AssetInformation.GlobalAssetId.Equals(firstKeyId,
StringComparison.OrdinalIgnoreCase)).First();

if (keyedAas != null)
{
return keyedAas;
}

return null;
}

case KeyElements.ConceptDescription:
{
var keyedAas = environment.ConceptDescriptions.Where(
description => description.IdShort.Equals(firstKeyId,
StringComparison.OrdinalIgnoreCase)).First();

if (keyedAas != null)
{
return keyedAas;
}

return null;
}

case KeyElements.Submodel:
{
var submodel = environment.Submodels.Where(
description => description.IdShort.Equals(firstKeyId,
StringComparison.OrdinalIgnoreCase)).First();

if (submodel == null)
{
return null;
}

if (keyIndex >= keyList.Count - 1)
{
return submodel;
}

return FindReferableByReference(environment, reference, ++keyIndex);
}
}

return null;
}

public void CreateObjects(AssetAdministrationShellEnvironment env)
{
string typeNodeId = "ns=" + Server.NamespaceUris.GetIndex("http://opcfoundation.org/UA/I4AAS/").ToString() + ";i=";
Expand Down

0 comments on commit 41e7165

Please sign in to comment.