Skip to content

Commit

Permalink
Add screen count and indicator, how many screenitems and scripts are …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
David-Kollinger committed Jun 28, 2023
1 parent 8725e1e commit fab202b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
26 changes: 17 additions & 9 deletions ShowScripts/AddScriptsToList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,15 +349,19 @@ public static void ExportScripts(IEnumerable<HmiScreen> screens, string fileDire
csvStringP[0] += "," + entry.Key;
}

faceplateTypes = new Dictionary<string, int>();

foreach (var screen in screens.Where(s => Regex.Matches(s.Name, _screenName, RegexOptions.IgnoreCase).Count > 0))
faceplateTypes = new Dictionary<string, int>();

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<string>();
var eveList = new List<string>();
var screenDynEventList = new List<ScreenDynEvents>();
// inits
Console.WriteLine(screen.Name);
Console.WriteLine();
Console.Write("[" + (i + 1) + "/" + screenCount + "]" + screen.Name);
tagNames = new List<string>();
List<string> _dynamizationList = new List<string>();
List<string> _eveList = new List<string>();
Expand Down Expand Up @@ -399,6 +403,7 @@ public static void ExportScripts(IEnumerable<HmiScreen> 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];
Expand Down Expand Up @@ -430,7 +435,6 @@ public static void ExportScripts(IEnumerable<HmiScreen> screens, string fileDire
{
Console.WriteLine("Screenitem Type: " + screenitem.GetType().Name + " is unknown.");
}

}

var dynList = screenDyns.Concat(screenItemDynamisations).ToList();
Expand Down Expand Up @@ -562,29 +566,31 @@ static public List<List<string>> 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 + "}");
}
}

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 + "}");
}
Expand All @@ -597,7 +603,6 @@ static public List<List<string>> 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 + "}");
}
Expand All @@ -624,13 +629,15 @@ static public List<List<string>> 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;
foreach (var propEve in nodeDynPropEve[1])
{
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
Expand All @@ -655,14 +662,15 @@ static public List<string> GetAllMyAttributesEve(IEngineeringObject obj, List<st
{
if (itemsEve.Value.Count == 2)
{
Console.WriteLine("1");
Console.Write(';'); // the user wants to see that something happens, so a semicolon will be printed for every script
//tempListEve.Add(Environment.NewLine + "//eslint-disable-next-line camelcase");
tempListEve.Insert(0, itemsEve.Value[0]);
tempListEve.Insert(1, Environment.NewLine + "export async function _" + objectName + "_" + itemsEve.Key + "() {" + itemsEve.Value[1] + Environment.NewLine + "}");
}

if (itemsEve.Value.Count == 1)
{
Console.Write(';'); // the user wants to see that something happens, so a semicolon will be printed for every script
tempListEve.Add(Environment.NewLine + "//eslint-disable-next-line camelcase");
tempListEve.Add("export async function _" + objectName + "_" + itemsEve.Key + "() {" + itemsEve.Value[0] + Environment.NewLine + "}");
}
Expand Down
1 change: 1 addition & 0 deletions TestAddin/TestAddin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>true</UseVSHostingProcess>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualBasic" />
Expand Down

0 comments on commit fab202b

Please sign in to comment.