Skip to content

Commit

Permalink
Merge branch 'main' into mf/headers
Browse files Browse the repository at this point in the history
  • Loading branch information
juileetikekar authored Feb 26, 2025
2 parents e03aafd + 65a4d0b commit b3f116b
Show file tree
Hide file tree
Showing 56 changed files with 9,447 additions and 171 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,28 @@ jobs:

- name: Upload latest
continue-on-error: true
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: aasx-package-explorer.LATEST.alpha.${{ steps.setTimestamp.outputs.timestamp }}
path: artefacts/release/LATEST.alpha/aasx-package-explorer.zip

- name: Upload latest small
continue-on-error: true
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: aasx-package-explorer-small.LATEST.alpha.${{ steps.setTimestamp.outputs.timestamp }}
path: artefacts/release/LATEST.alpha/aasx-package-explorer-small.zip

- name: Upload latest BlazorExplorer small
continue-on-error: true
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: aasx-package-explorer-blazorexplorer-small.LATEST.alpha.${{ steps.setTimestamp.outputs.timestamp }}
path: artefacts/release/LATEST.alpha/aasx-package-explorer-blazorexplorer-small.zip

- name: Upload latest BlazorUI
continue-on-error: true
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: aasx-package-explorer-blazorexplorer.LATEST.alpha.${{ steps.setTimestamp.outputs.timestamp }}
path: artefacts/release/LATEST.alpha/aasx-package-explorer-blazorexplorer.zip
4,074 changes: 4,074 additions & 0 deletions SBOM.md

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion src/AasxCore.Samm2_2_0/AasxCore.Samm2_2_0.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
Expand All @@ -14,4 +14,10 @@
<ProjectReference Include="..\AasxCsharpLibrary\AasxCsharpLibrary.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="LICENSE.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
1,475 changes: 1,475 additions & 0 deletions src/AasxCore.Samm2_2_0/LICENSE.txt

Large diffs are not rendered by default.

44 changes: 41 additions & 3 deletions src/AasxCsharpLibrary/AdminShellUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,8 @@ public static ISubmodelElement CreateSubmodelElementFromEnum(
}
case AasSubmodelElements.BasicEventElement:
{
return new BasicEventElement(crDefRef(),
var observed = new Reference(ReferenceTypes.ModelReference, new List<IKey>() { new Key(KeyTypes.Referable, "") });
return new BasicEventElement(observed,
Direction.Input, StateOfEvent.Off).UpdateFrom(sourceSme);
}
case AasSubmodelElements.Entity:
Expand Down Expand Up @@ -1103,11 +1104,12 @@ public static string GetTemporaryDirectory()

// see: https://stackoverflow.com/questions/6386113/using-system-io-packaging-to-generate-a-zip-file
public static void AddFileToZip(
string zipFilename, string fileToAdd,
string zipFilename,
string fileToAdd,
CompressionOption compression = CompressionOption.Normal,
FileMode fileMode = FileMode.OpenOrCreate)
{
using (Package zip = System.IO.Packaging.Package.Open(zipFilename, FileMode.OpenOrCreate))
using (Package zip = System.IO.Packaging.Package.Open(zipFilename, fileMode))
{
string destFilename = ".\\" + Path.GetFileName(fileToAdd);
Uri uri = PackUriHelper.CreatePartUri(new Uri(destFilename, UriKind.Relative));
Expand All @@ -1126,6 +1128,42 @@ public static void AddFileToZip(
}
}

public static void RecursiveAddDirToZip(
Package zip,
string localPath,
string zipPath = "",
CompressionOption compression = CompressionOption.Normal)
{
// enumerate only on this level
foreach (var infn in Directory.EnumerateDirectories(localPath, "*"))
{
// recurse
RecursiveAddDirToZip(
zip,
localPath: infn,
zipPath: Path.Combine(zipPath, Path.GetFileName(infn)),
compression: compression);
}

foreach (var infn in Directory.EnumerateFiles(localPath, "*"))
{
string destFilename = ".\\" + Path.Combine(zipPath, Path.GetFileName(infn));
Uri uri = PackUriHelper.CreatePartUri(new Uri(destFilename, UriKind.Relative));
if (zip.PartExists(uri))
{
zip.DeletePart(uri);
}
PackagePart part = zip.CreatePart(uri, "", compression);
using (FileStream fileStream = new FileStream(infn, FileMode.Open, FileAccess.Read))
{
using (Stream dest = part.GetStream())
{
fileStream.CopyTo(dest);
}
}
}
}

//
// some URL enabled path handling
//
Expand Down
10 changes: 10 additions & 0 deletions src/AasxCsharpLibrary/Extensions/ExtendReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ public static Reference CreateFromKey(KeyTypes type,
return res;
}

//This method has ben added to make Event.Observed as model reference
public static Reference CreateFromKey(ReferenceTypes referenceType, KeyTypes type,
string value)
{
var res = new Reference(referenceType,
new List<IKey> { new Key(type, value) });
res.Type = res.GuessType();
return res;
}

/// <summary>
/// Formaly a static constructor.
/// Creates a Reference from a list of keys, guessing Reference.Type.
Expand Down
4 changes: 2 additions & 2 deletions src/AasxIntegrationBase/AasForms/FormInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ public static AnyUiGrid RenderAnyUiRefAttribs(
uitk.AddSmallComboBoxTo(g, row, 2, margin: new AnyUiThickness(1.0),
horizontalAlignment: AnyUiHorizontalAlignment.Stretch,
text: "" + ls.Language,
items: AasxLanguageHelper.GetLangCodes().ToArray()),
items: AasxLanguageHelper.Languages.GetAllLanguages().ToArray()),
(o) =>
{
if (o is string os)
Expand Down Expand Up @@ -1711,7 +1711,7 @@ public override void RenderAnyUi(AnyUiStackPanel view, AnyUiSmallWidgetToolkit u
uitk.AddSmallComboBoxTo(g, row, 1, margin: new AnyUiThickness(1.0),
horizontalAlignment: AnyUiHorizontalAlignment.Stretch,
text: "" + ls.Language,
items: AasxLanguageHelper.GetLangCodes().ToArray()),
items: AasxLanguageHelper.Languages.GetAllLanguages().ToArray()),
(o) =>
{
if (o is string os)
Expand Down
169 changes: 169 additions & 0 deletions src/AasxIntegrationBase/AasxLanguageHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,184 @@ 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;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace AasxIntegrationBase
{
/// <summary>
/// This class lists valid combinations of ISO 639 (2 digit language codes)
/// and ISO 3166 (2 digit country codes). Only 1:1 relations are modelled.
/// </summary>
public class AasxLanguageTuple
{
/// <summary>
/// According ISO 639-2, 2 digit language code
/// </summary>
public string LangCode;

/// <summary>
/// According ISO 3166, 2 digit country code
/// </summary>
public string CountryCode;

/// <summary>
/// Marks the wildcard element
/// </summary>
public bool IsAny()
{
return LangCode == "" && CountryCode == ""
|| LangCode == "All" && CountryCode == "All";
}

public static AasxLanguageTuple GetAny()
{
return new AasxLanguageTuple() { LangCode = "All", CountryCode = "All" };
}
}

/// <summary>
/// Maintains a list of language tuples.
/// Note: Is always defaulted with a list of language tuples.
/// Could be cleard/ added.
/// </summary>
public class AasxLanguageTupleSet : MultiValueDictionary<string, AasxLanguageTuple>
{
public void Add(string lang, string country, bool correctInput = true)
{
if (correctInput)
{
lang = lang?.ToLower().Trim();
country = country?.ToUpper().Trim();
}

if (lang != null && lang != ""
&& country != null && country != "")
{
this.Add(lang, new AasxLanguageTuple() { LangCode = lang, CountryCode = country });
}
}

public AasxLanguageTupleSet()
{
Init();
}

/// <summary>
/// Rationale for default languages/ countries: member in IDTA or IEC TC65 WG24
/// </summary>
public void Init()
{
this.Clear();
Add("All", "All", correctInput: false);
Add("en", "GB");
Add("en", "US");
Add("de", "DE");
Add("de", "CH");
Add("de", "AT");
Add("es", "ES");
Add("fi", "FI");
Add("fr", "FR");
Add("it", "IT");
Add("ja", "JP");
Add("ko", "KR");
Add("nl", "NL");
Add("no", "NO");
Add("pt", "PT");
Add("sv", "SE");
Add("zh", "CN");
}

public IEnumerable<AasxLanguageTuple> FindByLang(string lang)
{
lang = lang?.ToLower().Trim();
if (lang == null || lang == "" || this.ContainsKey(lang) == false)
yield break;
foreach (var x in this[lang])
yield return x;
}

public IEnumerable<AasxLanguageTuple> FindByCountry(string country)
{
country = country?.ToUpper().Trim();
if (country == null || country == "")
yield break;
foreach (var tp in this.Values)
if (country == tp.CountryCode.ToUpper())
yield return tp;
}

public IEnumerable<string> GetAllLanguages(bool nullForAny = false)
{
var temp = new List<string>();
foreach (var tp in this.Values)
if (!tp.IsAny())
temp.Add(tp.LangCode);
else
{
if (nullForAny)
temp.Add(null);
else
temp.Add(tp.LangCode);
}

if (temp.Count < 1)
yield break;

temp = temp.Distinct().ToList();
var first = temp[0];
temp.RemoveAt(0);
temp.Sort();
temp.Insert(0, first);

foreach (var t in temp)
yield return t;
}

public IEnumerable<string> GetAllCountries()
{
var temp = new List<string>();
foreach (var tp in this.Values)
temp.Add(tp.CountryCode);

if (temp.Count < 1)
yield break;

temp = temp.Distinct().ToList();
var first = temp[0];
temp.RemoveAt(0);
temp.Sort();
temp.Insert(0, first);

foreach (var t in temp)
yield return t;
}

public void InitByCustomString(string input)
{
this.Clear();
Add("All", "All", correctInput: false);
var pairs = input.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
foreach (var pair in pairs)
{
var m = Regex.Match(pair, @"(\w+)\s*-\s*(\w+)");
if (m.Success)
Add(m.Groups[1].ToString(), m.Groups[2].ToString());
}
}
}

public static class AasxLanguageHelper
{
public static AasxLanguageTupleSet Languages = new AasxLanguageTupleSet();

#if __old
public enum LangEnum { Any = 0, EN, DE, ZH, JA, KO, FR, ES };

public static string[] LangEnumToISO639String = {
Expand Down Expand Up @@ -77,6 +245,7 @@ public static IEnumerable<string> GetLangCodes()
for (int i = 1; i < LangEnumToISO639String.Length; i++)
yield return LangEnumToISO639String[i];
}
#endif

public static string GetFirstLangCode(string codes)
{
Expand Down
6 changes: 6 additions & 0 deletions src/AasxIntegrationBaseWpf/AasxIntegrationBaseWpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@
<UseWPF>true</UseWPF>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>
<ItemGroup>
<None Remove="Resources\country_flags.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AasxIntegrationBase\AasxIntegrationBase.csproj" />
<ProjectReference Include="..\AnyUi\AnyUi.csproj" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\country_flags.png">
<Pack>True</Pack>
</Resource>
<Resource Include="Resources\msg_error.png" />
<Resource Include="Resources\msg_hand.png" />
<Resource Include="Resources\msg_info.png" />
Expand Down
Loading

0 comments on commit b3f116b

Please sign in to comment.