Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jtikekar/GitHub issues 29 #173

Merged
merged 7 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ sample-aasx/
/src/WpfMtpVisuViewer/Properties/AssemblyInfo.cs
/src/WpfMtpControl/Properties/AssemblyInfo.cs
/src/MsaglWpfControl/Properties/AssemblyInfo.cs
/.vs/AASPE_Code/v17/.wsuo
/.vs
9 changes: 6 additions & 3 deletions src/AasxCsharpLibrary/AdminShellPackageEnv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ public bool SaveAs(string fn, bool writeFreshly = false, SerializationFormat pre
System.Net.Mime.MediaTypeNames.Text.Plain, CompressionOption.Maximum);
using (var s = originPart.GetStream(FileMode.Create))
{
var bytes = System.Text.Encoding.ASCII.GetBytes("Intentionally empty.");
var bytes = System.Text.Encoding.ASCII.GetBytes("Intentionally empty");
s.Write(bytes, 0, bytes.Length);
}
package.CreateRelationship(
Expand Down 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
15 changes: 10 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 @@ -496,7 +498,10 @@ public static ISubmodelElement ConvertFromV20(this ISubmodelElement submodelElem
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
2 changes: 1 addition & 1 deletion src/AasxPluginDigitalNameplate/NameplateAnyUiControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ public AnyUiFrameworkElement RenderAnyUiNameplateData(
statement: ((plate.DateOfManufacture?.HasContent() == true)
? new IndexStatement(Quality.Good, statement: "Is given.")
: new IndexStatement(Quality.Warn, statement: "Should be given."))
.Set(description: "SerialNumber:\n" +
.Set(description: "DateOfManufacture:\n" +
"Date from which the production and / or development process is completed or " +
"from which a service is provided completely."));

Expand Down
Loading