Skip to content

Commit

Permalink
Fix for GitHub Issues 28, 37, 38
Browse files Browse the repository at this point in the history
  • Loading branch information
juileetikekar committed Feb 27, 2024
1 parent d490dbd commit 7570363
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 31 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ sample-aasx/
/src/WpfMtpControl/Properties/AssemblyInfo.cs
/src/MsaglWpfControl/Properties/AssemblyInfo.cs
/.vs/AASPE_Code/v17/.wsuo
/.vs
7 changes: 5 additions & 2 deletions src/AasxCsharpLibrary/AdminShellPackageEnv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1086,8 +1086,11 @@ public void TemporarilySaveCloseAndReOpenPackage(
finally
{
// even after failing of the lambda, the package shall be re-opened
_openPackage = Package.Open(Filename, FileMode.OpenOrCreate);
}
if (Filename.ToLower().EndsWith(".aasx"))
{
_openPackage = Package.Open(Filename, FileMode.OpenOrCreate);

} }
}

private int BackupIndex = 0;
Expand Down
50 changes: 28 additions & 22 deletions src/AasxCsharpLibrary/Extensions/ExtendAssetAdministrationShell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,21 +135,24 @@ public static AssetAdministrationShell ConvertFromV10(this AssetAdministrationSh
{
foreach (var submodelRef in sourceAas.submodelRefs)
{
var keyList = new List<IKey>();
foreach (var refKey in submodelRef.Keys)
if (!submodelRef.IsEmpty)
{
var keyType = Stringification.KeyTypesFromString(refKey.type);
if (keyType != null)
var keyList = new List<IKey>();
foreach (var refKey in submodelRef.Keys)
{
keyList.Add(new Key((KeyTypes)keyType, refKey.value));
}
else
{
Console.WriteLine($"KeyType value {refKey.type} not found.");
var keyType = Stringification.KeyTypesFromString(refKey.type);
if (keyType != null)
{
keyList.Add(new Key((KeyTypes)keyType, refKey.value));
}
else
{
Console.WriteLine($"KeyType value {refKey.type} not found.");
}
}
assetAdministrationShell.Submodels ??= new List<IReference>();
assetAdministrationShell.Submodels.Add(new Reference(ReferenceTypes.ModelReference, keyList));
}
assetAdministrationShell.Submodels ??= new List<IReference>();
assetAdministrationShell.Submodels.Add(new Reference(ReferenceTypes.ModelReference, keyList));
}
}

Expand Down Expand Up @@ -220,21 +223,24 @@ public static AssetAdministrationShell ConvertFromV20(this AssetAdministrationSh
{
foreach (var submodelRef in sourceAas.submodelRefs)
{
var keyList = new List<IKey>();
foreach (var refKey in submodelRef.Keys)
if (!submodelRef.IsEmpty)
{
var keyType = Stringification.KeyTypesFromString(refKey.type);
if (keyType != null)
{
keyList.Add(new Key((KeyTypes)keyType, refKey.value));
}
else
var keyList = new List<IKey>();
foreach (var refKey in submodelRef.Keys)
{
Console.WriteLine($"KeyType value {refKey.type} not found.");
var keyType = Stringification.KeyTypesFromString(refKey.type);
if (keyType != null)
{
keyList.Add(new Key((KeyTypes)keyType, refKey.value));
}
else
{
Console.WriteLine($"KeyType value {refKey.type} not found.");
}
}
assetAdministrationShell.Submodels ??= new List<IReference>();
assetAdministrationShell.Submodels.Add(new Reference(ReferenceTypes.ModelReference, keyList));
}
assetAdministrationShell.Submodels ??= new List<IReference>();
assetAdministrationShell.Submodels.Add(new Reference(ReferenceTypes.ModelReference, keyList));
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/AasxCsharpLibrary/Extensions/ExtendEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ public static Entity ConvertFromV20(this Entity entity, AasxCompatibilityModels.
{
//TODO (jtikekar, 0000-00-00): whether to convert to Global or specific asset id
var assetRef = ExtensionsUtil.ConvertReferenceFromV20(sourceEntity.assetRef, ReferenceTypes.ExternalReference);
entity.GlobalAssetId = assetRef.GetAsIdentifier();
if (assetRef != null)
{
entity.GlobalAssetId = assetRef.GetAsIdentifier();
}
}

return entity;
Expand Down
19 changes: 14 additions & 5 deletions src/AasxCsharpLibrary/Extensions/ExtendISubmodelElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,7 @@ public static ISubmodelElement ConvertFromV10(this ISubmodelElement submodelElem
var newSecond = ExtensionsUtil.ConvertReferenceFromV10(sourceRelationshipElement.second, ReferenceTypes.ModelReference);
outputSubmodelElement = new RelationshipElement(newFirst, newSecond);
}

if (sourceSubmodelElement is AdminShellV10.Operation sourceOperation)
else if (sourceSubmodelElement is AdminShellV10.Operation sourceOperation)
{
var newInputVariables = new List<IOperationVariable>();
var newOutputVariables = new List<IOperationVariable>();
Expand All @@ -280,6 +279,7 @@ public static ISubmodelElement ConvertFromV10(this ISubmodelElement submodelElem
}
}
}

if (!sourceOperation.valueOut.IsNullOrEmpty())
{
foreach (var outputVariable in sourceOperation.valueOut)
Expand All @@ -297,8 +297,10 @@ public static ISubmodelElement ConvertFromV10(this ISubmodelElement submodelElem
outputSubmodelElement = new Operation(inputVariables: newInputVariables, outputVariables: newOutputVariables);
}


outputSubmodelElement.BasicConversionFromV10(sourceSubmodelElement);
if (outputSubmodelElement != null)
{
outputSubmodelElement.BasicConversionFromV10(sourceSubmodelElement);
}
}

return outputSubmodelElement;
Expand Down Expand Up @@ -491,8 +493,15 @@ public static ISubmodelElement ConvertFromV20(this ISubmodelElement submodelElem

outputSubmodelElement = new Operation(inputVariables: newInputVariables, outputVariables: newOutputVariables, inoutputVariables: newInOutVariables);
}
else if(sourceSubmodelElement is AdminShellV20.Capability)
{
outputSubmodelElement = new Capability();
}

outputSubmodelElement.BasicConversionFromV20(sourceSubmodelElement);
if (outputSubmodelElement != null)
{
outputSubmodelElement.BasicConversionFromV20(sourceSubmodelElement);
}
}

return outputSubmodelElement;
Expand Down
3 changes: 2 additions & 1 deletion src/AasxPackageLogic/DispEditHelperEntities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,8 @@ public void DisplayOrEditAasEntityAas(
if (ks != null)
{
// create ref
var smr = new Aas.Reference(Aas.ReferenceTypes.ExternalReference, new List<Aas.IKey>(ks));
//var smr = new Aas.Reference(Aas.ReferenceTypes.ExternalReference, new List<Aas.IKey>(ks));
var smr = new Aas.Reference(Aas.ReferenceTypes.ModelReference, new List<Aas.IKey>(ks));
aas.Submodels.Add(smr);
// event for AAS
Expand Down

0 comments on commit 7570363

Please sign in to comment.