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

Commit

Permalink
* update sources
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaHofft committed Nov 19, 2023
1 parent 3c2758c commit df8f058
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 140 deletions.
10 changes: 7 additions & 3 deletions src/AasxPackageLogic/DispEditHelperMiniModules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1874,7 +1874,7 @@ public void DispSmeListAddNewHelper<T>(
});
}

public static Aas.ISubmodel DispEditHelperCreateSubmodelFromSmtSamm(
public static Tuple<Aas.ISubmodel, Aas.IReference> DispEditHelperCreateSubmodelFromSmtSamm(
PackageCentral.PackageCentral packages,
Aas.IEnvironment env,
Aas.IConceptDescription rootCd,
Expand All @@ -1893,8 +1893,12 @@ public static Aas.ISubmodel DispEditHelperCreateSubmodelFromSmtSamm(
env.Submodels.Add(submodel);

var aas1 = env?.AssetAdministrationShells?.FirstOrDefault();
Aas.IReference smres = null;
if (aas1 != null)
aas1.Submodels.Add(submodel.GetReference());
{
smres = submodel.GetReference();
aas1.Submodels.Add(smres);
}

// lambda to recurse
int numAdded = 0;
Expand Down Expand Up @@ -1956,7 +1960,7 @@ public static Aas.ISubmodel DispEditHelperCreateSubmodelFromSmtSamm(
Log.Singleton.Info($"Added {numAdded}. {numErrors} errors.");

// ok
return submodel;
return new Tuple<ISubmodel, IReference>(submodel, smres);
}

}
Expand Down
32 changes: 29 additions & 3 deletions src/AasxPackageLogic/DispEditHelperSammModules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2590,6 +2590,21 @@ public static IEnumerable<DispEditHelperMiniModules.ConceptOrganizedChildItem>

// possible childs?
var childs = new List<Samm.SammReference>();

// lambda for going deeper (Property) -> Characteristics -> Entity -> Property
Func<Samm.Property, Samm.Entity> lambdaTryProp2Entity = (propTest) =>
{
var propCharCd = packages.QuickLookupFirstIdent<Aas.IConceptDescription>(propTest.Characteristic?.Value);
var propCharMe = DispEditHelperSammModules.CheckReferableForSammElements(propCharCd)?.FirstOrDefault();
if (propCharMe is Samm.Characteristic propChar)
{
var propEntCd = packages.QuickLookupFirstIdent<Aas.IConceptDescription>(propChar.DataType?.Value);
var propEntMe = DispEditHelperSammModules.CheckReferableForSammElements(propEntCd)?.FirstOrDefault();
if (propEntMe is Samm.Entity ent)
return ent;
}
return null;
};

// Aspect
if (me is Samm.Aspect asp)
Expand All @@ -2602,9 +2617,10 @@ public static IEnumerable<DispEditHelperMiniModules.ConceptOrganizedChildItem>
childs.AddRange(asp.Events);
}

// Property -> Charasteristics -> Enitity -> Property
// Property
if (me is Samm.Property prop)
{
#if old
var propCharCd = packages.QuickLookupFirstIdent<Aas.IConceptDescription>(prop.Characteristic?.Value);
var propCharMe = DispEditHelperSammModules.CheckReferableForSammElements(propCharCd)?.FirstOrDefault();
if (propCharMe is Samm.Characteristic propChar)
Expand All @@ -2615,7 +2631,13 @@ public static IEnumerable<DispEditHelperMiniModules.ConceptOrganizedChildItem>
foreach (var p in ent.Properties)
childs.Add(p);
}
}
#endif

var propEnt = lambdaTryProp2Entity(prop);
if (propEnt?.Properties != null)
foreach (var p in propEnt.Properties)
childs.Add(p);
}

// try lookup childs
foreach (var child in childs)
Expand All @@ -2638,7 +2660,11 @@ public static IEnumerable<DispEditHelperMiniModules.ConceptOrganizedChildItem>
smtRec.ExampleValue = childProp.ExampleValue;

// poor mens SME type
smtRec.SubmodelElements = new List<AasSubmodelElements>() { AasSubmodelElements.Property };
var childSmeType = AasSubmodelElements.Property;
var childEntTest = lambdaTryProp2Entity(childProp);
if (childEntTest != null)
childSmeType = AasSubmodelElements.SubmodelElementCollection;
smtRec.SubmodelElements = new List<AasSubmodelElements>() { childSmeType };

// put into item
yield return new DispEditHelperMiniModules.ConceptOrganizedChildItem()
Expand Down
24 changes: 21 additions & 3 deletions src/AasxPackageLogic/MainWindowAnyUiDialogs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1532,10 +1532,28 @@ await DisplayContextPlus.CheckIfDownloadAndStart(
MainWindow.RedrawAllElementsAndFocus();
}

if (cmd == "submodelinstancefromsammaspect"
if (cmd == "submodelinstancefromsmtconcepts")
{
// simply pass on
try
{
// delegate futher
await CommandBinding_GeneralDispatchHeadless(cmd, menuItem, ticket);
}
catch (Exception ex)
{
LogErrorToTicket(ticket, ex,
$"When executing command {cmd}, an error occurred");
}

// redisplay
if (ticket.Success)
MainWindow.RedrawAllElementsAndFocus(nextFocus: ticket?.SetNextFocus);
}

if (cmd == "submodelinstancefromsammaspect"
|| cmd == "smtextensionfromqualifiers"
|| cmd == "smtorganizesfromSubmodel"
|| cmd == "submodelinstancefromsmtconcepts")
|| cmd == "smtorganizesfromSubmodel")
{
// simply pass on
try
Expand Down
6 changes: 3 additions & 3 deletions src/AasxPackageLogic/MainWindowHeadless.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,7 @@ record = rec;
}

// perfom dialogue
if (!DisplayContext.StartFlyoverModal(uc)
if (!(await DisplayContext.StartFlyoverModalAsync(uc))
|| !uc.Result || uc.ResultItem == null)
return;

Expand All @@ -1465,8 +1465,8 @@ record = rec;
Log.Singleton.Error("Error creating new Submodel from accessible ConceptDescriptions.");
else
{
Log.Singleton.Info($"Submodel {sm.IdShort} created");
ticket.SetNextFocus = sm;
Log.Singleton.Info($"Submodel {sm.Item1.IdShort} created");
ticket.SetNextFocus = sm.Item2;
}
}
catch (Exception ex)
Expand Down
3 changes: 3 additions & 0 deletions src/BlazorExplorer/Data/BlazorSession.CommandBindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ public async Task CommandBinding_GeneralDispatch(
MainMenu?.SetChecked("HintsMenu", hintsMode);
}

// trigger re-indexing
TriggerPendingReIndexElements();

// try to remember current selected data object
object currMdo = null;
if (DisplayElements.SelectedItem != null)
Expand Down
20 changes: 20 additions & 0 deletions src/BlazorExplorer/Data/BlazorSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -634,14 +634,34 @@ public bool PrepareDisplayDataAndElementPanel(
return true;
}

private bool _mainTimer_PendingReIndexElements = true;
private DateTime _mainTimer_LastCheckForReIndexElements = DateTime.Now;

/// <summary>
/// This is the main session timer callback. It is either activated by the session itself
/// or by the index page (proper initialized / disposed cycle).
/// </summary>
public void MainTimerTick()
{
// do re-index?
var deltaSecs2 = (DateTime.Now - _mainTimer_LastCheckForReIndexElements).TotalSeconds;
if (deltaSecs2 >= 1.0 && _mainTimer_PendingReIndexElements)
{
// dis-engage
_mainTimer_PendingReIndexElements = false;

// be modest for the time being
PackageCentral?.MainItem?.Container?.ReIndexIdentifiables();

// Info
Log.Singleton.Info("Re-indexing Identifiables for faster access.");
}
}

public void TriggerPendingReIndexElements()
{
_mainTimer_LastCheckForReIndexElements = DateTime.Now;
_mainTimer_PendingReIndexElements = true;
}

/// <summary>
Expand Down
Loading

0 comments on commit df8f058

Please sign in to comment.