From fab202b844b918b3a882b97d6e2112b81d63236c Mon Sep 17 00:00:00 2001 From: David Kollinger Date: Wed, 28 Jun 2023 18:46:51 +0900 Subject: [PATCH] Add screen count and indicator, how many screenitems and scripts are processed with dots and semicolons Add finding HMIs also in groups (only relevant for TestAddin) Fix export only the scripts to the files where they belong and not extend the script with every screen Fixed Casing Bug fixed: More than one custom event on faceplate containers Add screen groups to the addin Fix underline in front of every function to avoid JavaScript errors and parent HMI name --- ShowScripts/AddScriptsToList.cs | 26 +++++++++++++++++--------- TestAddin/TestAddin.csproj | 1 + 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/ShowScripts/AddScriptsToList.cs b/ShowScripts/AddScriptsToList.cs index 06fc1db..d693fd2 100644 --- a/ShowScripts/AddScriptsToList.cs +++ b/ShowScripts/AddScriptsToList.cs @@ -349,15 +349,19 @@ public static void ExportScripts(IEnumerable screens, string fileDire csvStringP[0] += "," + entry.Key; } - faceplateTypes = new Dictionary(); - - foreach (var screen in screens.Where(s => Regex.Matches(s.Name, _screenName, RegexOptions.IgnoreCase).Count > 0)) + faceplateTypes = new Dictionary(); + + var screensToExport = screens.Where(s => Regex.Matches(s.Name, _screenName, RegexOptions.IgnoreCase).Count > 0).ToList(); + var screenCount = screensToExport.Count; + for (var i = 0; i < screenCount; i++) { + var screen = screensToExport[i]; var dynamizationList = new List(); var eveList = new List(); var screenDynEventList = new List(); // inits - Console.WriteLine(screen.Name); + Console.WriteLine(); + Console.Write("[" + (i + 1) + "/" + screenCount + "]" + screen.Name); tagNames = new List(); List _dynamizationList = new List(); List _eveList = new List(); @@ -399,6 +403,7 @@ public static void ExportScripts(IEnumerable screens, string fileDire foreach (var screenitem in screen.ScreenItems) { + Console.Write('.'); // the user wants to see that something happens, so a dot will be printed for every screenitem var screenitemDynsPropEves = GetAllMyAttributesDynPropEves(screenitem, deepSearch, whereCondition.Split(',').ToList(), sets.Split(',').ToList()); var screenitemDyns = screenitemDynsPropEves[0]; var screenitemPropEves = screenitemDynsPropEves[1]; @@ -430,7 +435,6 @@ public static void ExportScripts(IEnumerable screens, string fileDire { Console.WriteLine("Screenitem Type: " + screenitem.GetType().Name + " is unknown."); } - } var dynList = screenDyns.Concat(screenItemDynamisations).ToList(); @@ -562,19 +566,21 @@ static public List> GetAllMyAttributesDynPropEves(IEngineeringObjec { if (itemsDyn.Value.Count == 2 && (obj is HmiScreen || obj is HmiScreenItemBase)) { - Console.WriteLine("4"); + Console.Write(';'); // the user wants to see that something happens, so a semicolon will be printed for every script tempListDyn.Insert(0, itemsDyn.Value[0]); tempListDyn.Insert(1, "function _" + objectName + "_" + itemsDyn.Key + "_Trigger() {" + itemsDyn.Value[1] + Environment.NewLine + "}"); } if (itemsDyn.Value.Count == 1 && (obj is HmiScreen || obj is HmiScreenItemBase)) { + Console.Write(';'); // the user wants to see that something happens, so a semicolon will be printed for every script tempListDyn.Add(Environment.NewLine + "//eslint-disable-next-line camelcase"); tempListDyn.Add("function _" + objectName + "_" + itemsDyn.Key + "_Trigger() {" + itemsDyn.Value[0] + Environment.NewLine + "}"); } if (itemsDyn.Value.Count == 1 && !(obj is HmiScreen || obj is HmiScreenItemBase)) { + Console.Write(';'); // the user wants to see that something happens, so a semicolon will be printed for every script tempListDyn.Add(Environment.NewLine + "//eslint-disable-next-line camelcase"); tempListDyn.Add("_" + itemsDyn.Key + "_Trigger() {" + Environment.NewLine + itemsDyn.Value[0] + Environment.NewLine + "}"); } @@ -582,9 +588,9 @@ static public List> GetAllMyAttributesDynPropEves(IEngineeringObjec foreach (var itemsPropEve in propertyEvents) { + Console.Write(';'); // the user wants to see that something happens, so a semicolon will be printed for every script if (itemsPropEve.Value.Count == 2 && (obj is HmiScreen || obj is HmiScreenItemBase)) { - Console.WriteLine("3"); tempListPropEve.Insert(0, itemsPropEve.Value[0]); tempListPropEve.Insert(1, Environment.NewLine + "export function _" + objectName + "_" + itemsPropEve.Key + "_OnPropertyChanged() {" + itemsPropEve.Value[1] + Environment.NewLine + "}"); } @@ -597,7 +603,6 @@ static public List> GetAllMyAttributesDynPropEves(IEngineeringObjec if (itemsPropEve.Value.Count == 2 && !(obj is HmiScreen || obj is HmiScreenItemBase)) { - Console.WriteLine("2"); tempListPropEve.Insert(0, itemsPropEve.Value[0]); tempListPropEve.Insert(1, "_" + itemsPropEve.Key + "_OnPropertyChanged() {" + itemsPropEve.Value[1] + Environment.NewLine + "}"); } @@ -624,6 +629,7 @@ static public List> GetAllMyAttributesDynPropEves(IEngineeringObjec var nodeDynPropEve = GetAllMyAttributesDynPropEves(item, deepSearch, whereConditions, sets); foreach (var dyn in nodeDynPropEve[0]) { + Console.Write(';'); // the user wants to see that something happens, so a semicolon will be printed for every script tempListDyn.Add("function _" + objectName + dyn); } int index = 0; @@ -631,6 +637,7 @@ static public List> GetAllMyAttributesDynPropEves(IEngineeringObjec { if (index != 0) { + Console.Write(';'); // the user wants to see that something happens, so a semicolon will be printed for every script tempListPropEve.Add(Environment.NewLine + "export function _" + obj.GetAttribute("Name") + propEve); } else @@ -655,7 +662,7 @@ static public List GetAllMyAttributesEve(IEngineeringObject obj, List GetAllMyAttributesEve(IEngineeringObject obj, ListTRACE prompt 4 + true