Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Commit

Permalink
* issue with compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
festo-i40 committed Jan 6, 2024
1 parent 9af8f96 commit 49d18d3
Show file tree
Hide file tree
Showing 21 changed files with 2,810 additions and 223 deletions.
144 changes: 143 additions & 1 deletion src/AasxCsharpLibrary/AdminShellUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ public static ISubmodelElement CreateSubmodelElementFromEnum(AasSubmodelElements
}

#endregion

public static string EvalToNonNullString(string fmt, object o, string elseString = "")
{
if (o == null)
Expand All @@ -427,6 +428,17 @@ public static string EvalToNonEmptyString(string fmt, string o, string elseStrin
return string.Format(fmt, o);
}

/// <summary>
/// Some syntactic sugar to easily take the first string which has content.
/// </summary>
public static string TakeFirstContent(params string[] choices)
{
foreach (var c in choices)
if (c != null && c.Trim().Length > 0)
return c;
return "";
}

/// <summary>
/// If len of <paramref name="str"/> exceeds <paramref name="maxLen"/> then
/// string is shortened and returned with an ellipsis(…) at the end.
Expand Down Expand Up @@ -789,18 +801,40 @@ public static string WrapLinesAtColumn(string text, int columnLimit)
// Reflection
//

/// <summary>
/// Returns type or the underlying type, if is a Nullable
/// </summary>
public static Type GetTypeOrUnderlyingType(Type type)
{
var nut = Nullable.GetUnderlyingType(type);
if (nut != null)
type = nut;
return type;
}

/// <summary>
/// Tries parsing the <c>value</c>, supposedly a string, to a field value
/// for reflection of type specific data.
/// Works for most scalars, dateTime, string.
/// </summary>
public static void SetFieldLazyValue(FieldInfo f, object obj, object value)
{
// access
if (f == null || obj == null)
return;

switch (Type.GetTypeCode(f.FieldType))
// 2024-01-04: make function more suitable for <DateTime?>
switch (Type.GetTypeCode(GetTypeOrUnderlyingType(f.FieldType)))
{
case TypeCode.String:
f.SetValue(obj, "" + value);
break;

case TypeCode.DateTime:
if (DateTime.TryParse("" + value, out var dt))
f.SetValue(obj, dt);
break;

case TypeCode.Byte:
if (Byte.TryParse("" + value, out var ui8))
f.SetValue(obj, ui8);
Expand Down Expand Up @@ -842,12 +876,24 @@ public static void SetFieldLazyValue(FieldInfo f, object obj, object value)
break;

case TypeCode.Single:
if (value is double vd)
f.SetValue(obj, vd);
else
if (value is float vf)
f.SetValue(obj, vf);
else
if (Single.TryParse("" + value, NumberStyles.Float,
CultureInfo.InvariantCulture, out var sgl))
f.SetValue(obj, sgl);
break;

case TypeCode.Double:
if (value is double vd2)
f.SetValue(obj, vd2);
else
if (value is float vf2)
f.SetValue(obj, vf2);
else
if (Double.TryParse("" + value, NumberStyles.Float,
CultureInfo.InvariantCulture, out var dbl))
f.SetValue(obj, dbl);
Expand All @@ -863,6 +909,102 @@ public static void SetFieldLazyValue(FieldInfo f, object obj, object value)
}
}

/// <summary>
/// Rathhe sepcialised: adding a type-specific value to a list
/// of type-specific values.
/// Works for most scalars, dateTime, string.
/// </summary>
public static void AddToListLazyValue(object obj, object value)
{
// access
if (obj == null)
return;

switch (obj)
{
case List<string> lstr:
lstr.Add("" + value);
break;

case List<DateTime> ldt:
if (DateTime.TryParse("" + value, out var dt))
ldt.Add(dt);
break;

case List<byte> lbyte:
if (Byte.TryParse("" + value, out var ui8))
lbyte.Add(ui8);
break;

case List<sbyte> lsbyte:
if (SByte.TryParse("" + value, out var i8))
lsbyte.Add(i8);
break;

case List<Int16> li16:
if (Int16.TryParse("" + value, out var i16))
li16.Add(i16);
break;

case List<Int32> li32:
if (Int32.TryParse("" + value, out var i32))
li32.Add(i32);
break;

case List<Int64> li64:
if (Int64.TryParse("" + value, out var i64))
li64.Add(i64);
break;

case List<UInt16> lui16:
if (UInt16.TryParse("" + value, out var ui16))
lui16.Add(ui16);
break;

case List<UInt32> lui32:
if (UInt32.TryParse("" + value, out var ui32))
lui32.Add(ui32);
break;

case List<UInt64> lui64:
if (UInt64.TryParse("" + value, out var ui64))
lui64.Add(ui64);
break;

case List<float> lfloat:
if (value is double vd)
lfloat.Add((float) vd);
else
if (value is float vf)
lfloat.Add(vf);
else
if (Single.TryParse("" + value, NumberStyles.Float,
CultureInfo.InvariantCulture, out var sgl))
lfloat.Add(sgl);
break;

case List<double> ldouble:
if (value is double vd2)
ldouble.Add(vd2);
else
if (value is float vf2)
ldouble.Add(vf2);
else
if (Double.TryParse("" + value, NumberStyles.Float,
CultureInfo.InvariantCulture, out var dbl))
ldouble.Add(dbl);
break;

case List<bool> lbool:
var isFalse = value == null
|| (value is int vi && vi == 0)
|| (value is string vs && (vs == "" || vs == "false"))
|| (value is bool vb && !vb);
lbool.Add(!isFalse);
break;
}
}

//
// temp file utilities
//
Expand Down
3 changes: 3 additions & 0 deletions src/AasxCsharpLibrary/Extensions/ExtendReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ public static bool Matches(this IReference reference, IReference otherReference,
return match;
}

/// <summary>
/// Useful, if the searched reference will have only on key (e.g. ECLASS properties)
/// </summary>
public static bool MatchesExactlyOneKey(this IReference reference, IKey key, MatchMode matchMode = MatchMode.Strict)
{
if (key == null || reference.Keys == null || reference.Keys.Count != 1)
Expand Down
35 changes: 35 additions & 0 deletions src/AasxCsharpLibrary/Extensions/ExtendReferenceList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
Copyright (c) 2018-2023 Festo SE & Co. KG <https://www.festo.com/net/de_de/Forms/web/contact_international>
Author: Michael Hoffmeister
This source code is licensed under the Apache License 2.0 (see LICENSE.txt).
This source code may use other Open Source software components (see LICENSE.txt).
*/
using AdminShellNS.Exceptions;
using System.Collections.Generic;
using System.Linq;

namespace Extensions
{
public static class ExtendReferenceList
{
/// <summary>
/// Useful, if the searched reference will have only on key (e.g. ECLASS properties)
/// </summary>
public static bool MatchesAnyWithExactlyOneKey(this List<IReference> reflist, IKey key, MatchMode matchMode = MatchMode.Strict)
{
if (key == null || reflist == null || reflist.Count < 1)
{
return false;
}

var found = false;
foreach (var r in reflist)
found = found || r.MatchesExactlyOneKey(key, matchMode);

return found;
}
}

}
37 changes: 35 additions & 2 deletions src/AasxPackageExplorer.sln
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AasxPluginContactInformatio
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AasxCore.Samm2_2_0", "AasxCore.Samm2_2_0\AasxCore.Samm2_2_0.csproj", "{DCFD6C2F-A7C5-4AA2-82F3-0D3856E7EA99}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AasxPluginAssetInterfaceDesc", "AasxPluginAssetInterfaceDesc\AasxPluginAssetInterfaceDesc.csproj", "{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -419,8 +421,8 @@ Global
{6D1A03B2-EBA7-4CE2-9237-DF9AD7128947}.ReleaseWithoutCEF|x64.Build.0 = Release|Any CPU
{6D1A03B2-EBA7-4CE2-9237-DF9AD7128947}.ReleaseWithoutCEF|x86.ActiveCfg = Release|Any CPU
{6D1A03B2-EBA7-4CE2-9237-DF9AD7128947}.ReleaseWithoutCEF|x86.Build.0 = Release|Any CPU
{042305D7-DB68-4D02-B08F-ED47BBCD705E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{042305D7-DB68-4D02-B08F-ED47BBCD705E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{042305D7-DB68-4D02-B08F-ED47BBCD705E}.Debug|Any CPU.ActiveCfg = Debug|x64
{042305D7-DB68-4D02-B08F-ED47BBCD705E}.Debug|Any CPU.Build.0 = Debug|x64
{042305D7-DB68-4D02-B08F-ED47BBCD705E}.Debug|x64.ActiveCfg = Debug|Any CPU
{042305D7-DB68-4D02-B08F-ED47BBCD705E}.Debug|x64.Build.0 = Debug|Any CPU
{042305D7-DB68-4D02-B08F-ED47BBCD705E}.Debug|x86.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -1971,6 +1973,36 @@ Global
{DCFD6C2F-A7C5-4AA2-82F3-0D3856E7EA99}.ReleaseWithoutCEF|x64.Build.0 = Release|Any CPU
{DCFD6C2F-A7C5-4AA2-82F3-0D3856E7EA99}.ReleaseWithoutCEF|x86.ActiveCfg = Release|Any CPU
{DCFD6C2F-A7C5-4AA2-82F3-0D3856E7EA99}.ReleaseWithoutCEF|x86.Build.0 = Release|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.Debug|x64.ActiveCfg = Debug|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.Debug|x64.Build.0 = Debug|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.Debug|x86.ActiveCfg = Debug|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.Debug|x86.Build.0 = Debug|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.DebugSlow|Any CPU.ActiveCfg = Debug|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.DebugSlow|Any CPU.Build.0 = Debug|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.DebugSlow|x64.ActiveCfg = Debug|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.DebugSlow|x64.Build.0 = Debug|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.DebugSlow|x86.ActiveCfg = Debug|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.DebugSlow|x86.Build.0 = Debug|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.DebugWithoutCEF|Any CPU.ActiveCfg = Debug|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.DebugWithoutCEF|Any CPU.Build.0 = Debug|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.DebugWithoutCEF|x64.ActiveCfg = Debug|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.DebugWithoutCEF|x64.Build.0 = Debug|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.DebugWithoutCEF|x86.ActiveCfg = Debug|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.DebugWithoutCEF|x86.Build.0 = Debug|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.Release|Any CPU.Build.0 = Release|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.Release|x64.ActiveCfg = Release|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.Release|x64.Build.0 = Release|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.Release|x86.ActiveCfg = Release|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.Release|x86.Build.0 = Release|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.ReleaseWithoutCEF|Any CPU.ActiveCfg = Release|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.ReleaseWithoutCEF|Any CPU.Build.0 = Release|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.ReleaseWithoutCEF|x64.ActiveCfg = Release|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.ReleaseWithoutCEF|x64.Build.0 = Release|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.ReleaseWithoutCEF|x86.ActiveCfg = Release|Any CPU
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8}.ReleaseWithoutCEF|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -2035,6 +2067,7 @@ Global
{DA75828B-E5AC-4E9D-AE1F-398F8FF5AE25} = {66D730EB-B9D7-4C3A-8954-0F86240AD612}
{938BB137-DC45-4A84-B0C9-AC46DA321FDB} = {66D730EB-B9D7-4C3A-8954-0F86240AD612}
{DCFD6C2F-A7C5-4AA2-82F3-0D3856E7EA99} = {DDA9C372-F8ED-4099-A53C-01B9333FD985}
{92AC5ECF-6DB4-4ABD-8DD4-6EFA0BE65BA8} = {66D730EB-B9D7-4C3A-8954-0F86240AD612}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1AE21162-9541-4B98-A49C-A63B6AD03998}
Expand Down
2 changes: 1 addition & 1 deletion src/AasxPackageExplorer/debug.MIHO.script
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Tool("editkey");
Select("Submodel", "First");
// Tool("sammaspectimport", "File", "C:\\HOMI\\Develop\\Aasx\\repo\\samm-test\\Aspect_Example_SML_MLP.ttl");
Tool("exportpredefineconcepts", "File", "C:\HOMI\Develop\Aasx\repo\aid\new.txt");
// Tool("exportpredefineconcepts", "File", "C:\HOMI\Develop\Aasx\repo\aid\new.txt");
// Tool("submodelinstancefromsmtconcepts");
// Select("ConceptDescription", "First");
// Select("ConceptDescription", "Next");
Expand Down
7 changes: 6 additions & 1 deletion src/AasxPackageExplorer/options-debug.MIHO.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\samm-test\\SMT_and_SAMM_Showcase_v02.aasx",
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\samm-test\\Aspect_Example_SML_MLP.ttl",
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\8001203_SPAU-P10R-T-R18M-L-PNLK-PNVBA-M8D_060ff64f-9fd2-422d-81ce-b17e49f007c5_work.aasx",
"AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\aid\\2023_AID1.0_Template_Rework_MIHO.aasx",
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\aid\\2023_AID1.0_Template_Rework_MIHO.aasx",
"AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\aid\\aid-test-2.aasx",
// "AasxRepositoryFn": "C:\\HOMI\\Develop\\Aasx\\repo_Festo_demo_case_V3\\Festo-DemoCase-repo-V3-local.json",
"WindowLeft": 200,
"WindowTop": -1,
Expand Down Expand Up @@ -120,6 +121,10 @@
"Args": []
},
*/
{
"Path": "..\\..\\..\\..\\..\\..\\AasxPluginAssetInterfaceDesc\\bin\\Debug\\net6.0-windows\\AasxPluginAssetInterfaceDesc.dll",
"Args": []
},
{
"Path": "..\\..\\..\\..\\..\\..\\AasxPluginKnownSubmodels\\bin\\Debug\\net6.0-windows\\AasxPluginKnownSubmodels.dll",
"Args": []
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<OutputType>library</OutputType>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWPF>true</UseWPF>

<!-- force NuGet / Build to put required.dll and more to bin folder -->
<!-- Drawback: puts all other *.dll as well :-( -->
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>
<ItemGroup>
<None Remove="Resources\logo-http.png" />
<None Remove="Resources\logo-modbus.png" />
<None Remove="Resources\logo-mqtt.png" />
</ItemGroup>
<ItemGroup>
<None Update="AasxPluginMtpViewer.options.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="AasxPluginMtpViewer.plugin">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Resource Include="LICENSE.TXT" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\LICENSE.TXT" />
<EmbeddedResource Include="Resources\logo-http.png" />
<EmbeddedResource Include="Resources\logo-modbus.png" />
<EmbeddedResource Include="Resources\logo-mqtt.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AasxIntegrationBaseGdi\AasxIntegrationBaseGdi.csproj" />
<ProjectReference Include="..\AasxIntegrationBaseWpf\AasxIntegrationBaseWpf.csproj" />
<ProjectReference Include="..\AasxIntegrationBase\AasxIntegrationBase.csproj" />
<ProjectReference Include="..\AasxPredefinedConcepts\AasxPredefinedConcepts.csproj" />
<ProjectReference Include="..\WpfMtpControl\WpfMtpControl.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="Opc.Ua.SampleClient.Config.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="FluentModbus" Version="5.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
</Project>
Loading

0 comments on commit 49d18d3

Please sign in to comment.