From 14ed54a4ecd508f887f6ca1a2bd689212a2db09b Mon Sep 17 00:00:00 2001 From: Michael Hoffmeister Date: Thu, 29 Aug 2024 22:53:37 +0200 Subject: [PATCH] * select first plugin in SM for scripting --- src/AasxPackageExplorer/debug.MIHO.script | 3 ++- src/AasxPackageExplorer/options-debug.MIHO.json | 3 ++- src/AasxPackageLogic/MainWindowScripting.cs | 17 +++++++++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/AasxPackageExplorer/debug.MIHO.script b/src/AasxPackageExplorer/debug.MIHO.script index 4ad15d8d..45dfb185 100644 --- a/src/AasxPackageExplorer/debug.MIHO.script +++ b/src/AasxPackageExplorer/debug.MIHO.script @@ -10,7 +10,8 @@ // Tool("sammaspectimport", "File", "C:\\HOMI\\Develop\\Aasx\\repo\\samm-test\\Batch-MM-2_0_0.ttl"); Tool("editkey"); Select("Submodel", "First"); -Select("Submodel", "Next"); +Select("Plugin", "First"); +// Select("Submodel", "Next"); // Select("SME", "First"); // Tool("aas-elem-copy"); // Tool("aas-elem-paste-below"); diff --git a/src/AasxPackageExplorer/options-debug.MIHO.json b/src/AasxPackageExplorer/options-debug.MIHO.json index f7ef6296..5dbf588d 100644 --- a/src/AasxPackageExplorer/options-debug.MIHO.json +++ b/src/AasxPackageExplorer/options-debug.MIHO.json @@ -40,7 +40,8 @@ // "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_ProductChangeNotification\\IDTA_02036-1-0_SMT_ProductChangeNotification_Draft_v22.aasx", // "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_ProductChangeNotification\\IDTA_02036-1-0_SMT_ProductChangeNotification_Examples_v08.aasx", // "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_ProductChangeNotification\\SMT_ProductChangeNotification_Draft_v20_spiel.aasx", - "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\aaspe-testing\\210_Copy_Paste\\Sample_AAS.aasx", + // "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\aaspe-testing\\210_Copy_Paste\\Sample_AAS.aasx", + "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\aaspe-testing\\310_Plugin_DNP\\Sample_AAS.aasx", // "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\aaspe-testing\\200_Find_Replace\\Sample_SMT.aasx", // "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_ProductChangeNotification\\IDTA_02036-1-0_SMT_ProductChangeNotification_Examples_v08.aasx", // "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\tmp\\Syn2tecMachine_P2518_AAS__V3_DL2.aasx", diff --git a/src/AasxPackageLogic/MainWindowScripting.cs b/src/AasxPackageLogic/MainWindowScripting.cs index ed719f50..d540f881 100644 --- a/src/AasxPackageLogic/MainWindowScripting.cs +++ b/src/AasxPackageLogic/MainWindowScripting.cs @@ -29,7 +29,7 @@ namespace AasxPackageLogic /// public class MainWindowScripting : MainWindowAnyUiDialogs, IAasxScriptRemoteInterface { - public enum ScriptSelectRefType { None = 0, This, AAS, SM, SME, CD }; + public enum ScriptSelectRefType { None = 0, This, AAS, SM, SME, CD, Plugin }; public enum ScriptSelectAdressMode { None = 0, First, Next, Prev, idShort, semanticId }; protected static string[] _allowedSelectAdressMode = { @@ -153,6 +153,16 @@ public enum ScriptSelectAdressMode { None = 0, First, Next, Prev, idShort, seman } } + if (refType == ScriptSelectRefType.Plugin) + { + // search the first plugin + var siPE = siSM?.Members?.FirstOrDefault((si) => si is VisualElementPluginExtension); + if (siPE != null && siPE is VisualElementPluginExtension siPEPE) + { + return new Tuple(siPEPE.theReferable, siPEPE.GetMainDataObject()); + } + } + if (refType == ScriptSelectRefType.CD) { if (firstCd == null) @@ -325,6 +335,9 @@ protected ScriptSelectRefType GetScriptRefType(string refTypeName) case "conceptdescription": res = ScriptSelectRefType.CD; break; + case "plugin": + res = ScriptSelectRefType.Plugin; + break; } return res; @@ -357,7 +370,7 @@ Aas.IReferable IAasxScriptRemoteInterface.Select(object[] args) if (args.Length < 2 || !(args[1] is string adrModeName)) { - Log.Singleton.Error("Script: Select: Adfress mode missing!"); + Log.Singleton.Error("Script: Select: Address mode missing!"); return null; }