Skip to content

Commit

Permalink
* pending fixes from merge
Browse files Browse the repository at this point in the history
  • Loading branch information
festo-i40 committed Aug 27, 2024
1 parent 4e198f4 commit fe7561a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 80 deletions.
45 changes: 10 additions & 35 deletions src/AasxCsharpLibrary/Extensions/ExtendAssetAdministrationShell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ public static bool HasSubmodelReference(this IAssetAdministrationShell aas, Refe
return aas.FindSubmodelReference(smRef) != null;
}

public static void AddSubmodelReference(this IAssetAdministrationShell assetAdministrationShell, IReference newSubmodelReference)
{
if (assetAdministrationShell.Submodels == null)
{
assetAdministrationShell.Submodels = new List<IReference>();
}

assetAdministrationShell.Submodels.Add(newSubmodelReference);
}

/// <summary>
/// Enumerates any references to Submodels in the AAS. Will not return <c>null</c>.
/// Is tolerant, if the list is <c>null</c>.
Expand Down Expand Up @@ -109,41 +119,6 @@ public static void Add(this IAssetAdministrationShell aas, IReference newSmRef)
aas.Submodels.Add(newSmRef);
}

/// <summary>
/// Returns the <c>index</c>-th Submodel, if exists. Returns <c>null</c> in any other case.
/// </summary>
public static IReference SubmodelByIndex(this IAssetAdministrationShell aas, int index)
{
if (aas?.Submodels == null || index < 0 || index >= aas.Submodels.Count)
return null;
return aas.Submodels[index];
/// <summary>
/// Removes the reference, if contained in list. Might set the list to <c>null</c> !!
/// Note: <c>smRef</c> must be the exact object, not only match it!
/// </summary>
public static void Remove(this IAssetAdministrationShell aas, IReference smRef)
{
if (aas?.Submodels == null)
return;
if (aas.Submodels.Contains(smRef))
aas.Submodels.Remove(smRef);
if (aas.Submodels.Count < 1)
aas.Submodels = null;
}

/// <summary>
/// Adds. Might create the list.
/// </summary>
public static void Add(this IAssetAdministrationShell aas, IReference newSmRef)
{
if (aas == null)
return;
if (aas.Submodels == null)
aas.Submodels = new List<IReference>();

aas.Submodels.Add(newSmRef);
}

/// <summary>
/// Removes the reference, if contained in list. Might set the list to <c>null</c> !!
/// Note: <c>smRef</c> must be the exact object, not only match it!
Expand Down
23 changes: 0 additions & 23 deletions src/AasxCsharpLibrary/Extensions/ExtendEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -496,29 +496,6 @@ public static IConceptDescription AddConceptDescriptionOrReturnExisting(
return cd;
}

public static IConceptDescription AddConceptDescriptionOrReturnExisting(
this AasCore.Aas3_0.IEnvironment env, IConceptDescription cd)
{
if (cd == null)
{
return null;
}
if (env.ConceptDescriptions != null)
{
var existingCd = env.ConceptDescriptions.Where(c => c.Id == cd.Id).FirstOrDefault();
if (existingCd != null)
{
return existingCd;
}
else
{
env.ConceptDescriptions.Add(cd);
}
}

return cd;
}

/// <summary>
/// Adds the Submodel. If env.Submodels are <c>null</c>, then
/// the list will be created.
Expand Down
22 changes: 0 additions & 22 deletions src/AasxPackageLogic/VisualAasxElements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1297,28 +1297,6 @@ public override void RefreshFromMainData()
this.Info += " = " + vl;
}

// SAMM?
var sammType = DispEditHelperSammModules.CheckReferableForSammExtensionType(theCD);
var sammName = DispEditHelperSammModules.CheckReferableForSammExtensionTypeName(sammType);
if (sammName?.HasContent() == true)
{
// completely reformat the Caption
this.Caption = $"\"{"" + theCD.IdShort}\" \uff5f{sammName}\uff60 {"" + theCD.Id}";

// do model element colors?
var ri = Samm.Constants.GetRenderInfo(sammType);
if (ri != null)
{
this.TagString = "" + ri.Abbreviation;
this.Border = new AnyUiColor(ri.Background);
this.Background = new AnyUiColor(Samm.Constants.RenderBackground);
this.TagBg = new AnyUiColor(ri.Background);
this.TagFg = new AnyUiColor(ri.Foreground);

this.HasSpecialColors = true;
}
}

// SAMM?
var sammType = DispEditHelperSammModules.CheckReferableForSammExtensionType(theCD);
var sammName = DispEditHelperSammModules.CheckReferableForSammExtensionTypeName(sammType);
Expand Down

0 comments on commit fe7561a

Please sign in to comment.