From ee556c1d6d9c9f5a98a6d30392295a56e4f2f1b8 Mon Sep 17 00:00:00 2001
From: Toshiro 444 <55591295+caprican@users.noreply.github.com>
Date: Thu, 25 Apr 2024 06:24:29 +0200
Subject: [PATCH] Search TIA Crach source
---
Extract.Core/Properties/Resources.Designer.cs | 20 +--------
Extract.Core/Properties/Resources.resx | 8 +---
Extract_V18/AlarmsTextsAddIn.cs | 34 +++++++++++----
Extract_V18/Config.xml | 2 +-
TIA_Extract/AlarmsTextsAddIn.cs | 42 ++++++++++++++-----
TIA_Extract/Config.xml | 30 ++++++-------
TIA_Extract/Extract_V19.csproj | 3 ++
TIA_Extract/Properties/launchSettings.json | 5 +++
8 files changed, 83 insertions(+), 61 deletions(-)
diff --git a/Extract.Core/Properties/Resources.Designer.cs b/Extract.Core/Properties/Resources.Designer.cs
index 395490c..d8a9abf 100644
--- a/Extract.Core/Properties/Resources.Designer.cs
+++ b/Extract.Core/Properties/Resources.Designer.cs
@@ -79,7 +79,7 @@ public static string CancelByUser {
}
///
- /// Recherche une chaîne localisée semblable à Build Alarms.
+ /// Recherche une chaîne localisée semblable à Build.
///
public static string ContextMenu_GlobalDb {
get {
@@ -87,24 +87,6 @@ public static string ContextMenu_GlobalDb {
}
}
- ///
- /// Recherche une chaîne localisée semblable à Update Table.
- ///
- public static string ContextMenu_HmiTag {
- get {
- return ResourceManager.GetString("ContextMenu_HmiTag", resourceCulture);
- }
- }
-
- ///
- /// Recherche une chaîne localisée semblable à Généré depuis le dossier.
- ///
- public static string ContextMenu_UserGroup {
- get {
- return ResourceManager.GetString("ContextMenu_UserGroup", resourceCulture);
- }
- }
-
///
/// Recherche une chaîne localisée semblable à Aucun DB d'alarmes trouvé dans le dossier.
///
diff --git a/Extract.Core/Properties/Resources.resx b/Extract.Core/Properties/Resources.resx
index deddd41..cbf1464 100644
--- a/Extract.Core/Properties/Resources.resx
+++ b/Extract.Core/Properties/Resources.resx
@@ -124,13 +124,7 @@
La génération à été annulé par l'utilisateur
- Build Alarms
-
-
- Update Table
-
-
- Généré depuis le dossier
+ Build
Aucun DB d'alarmes trouvé dans le dossier
diff --git a/Extract_V18/AlarmsTextsAddIn.cs b/Extract_V18/AlarmsTextsAddIn.cs
index 0982a0f..c5c693c 100644
--- a/Extract_V18/AlarmsTextsAddIn.cs
+++ b/Extract_V18/AlarmsTextsAddIn.cs
@@ -77,17 +77,35 @@ public AlarmsTextsAddIn(TiaPortal tiaPortal) : base(s_DisplayNameOfAddIn)
///
protected override void BuildContextMenuItems(ContextMenuAddInRoot addInRootSubmenu)
{
- addInRootSubmenu.Items.AddActionItem(Extract.Core.Properties.Resources.ContextMenu_GlobalDb, OnGenerateClick,
- (menuSelectionProvider) => menuSelectionProvider.GetSelection().Any(engineeringObject => engineeringObject is SimaticSW.GlobalDB) ? MenuStatus.Enabled : MenuStatus.Hidden);
-
- addInRootSubmenu.Items.AddActionItem(Extract.Core.Properties.Resources.ContextMenu_GlobalDb, OnGenerateClick,
- (menuSelectionProvider) => menuSelectionProvider.GetSelection().Any(engineeringObject => engineeringObject is SimaticSW.PlcBlockUserGroup) ? MenuStatus.Enabled : MenuStatus.Hidden);
+ addInRootSubmenu.Items.AddActionItem(Extract.Core.Properties.Resources.ContextMenu_GlobalDb, OnGenerate, OnCanGenerate);
+ }
- addInRootSubmenu.Items.AddActionItem(Extract.Core.Properties.Resources.ContextMenu_HmiTag, OnGenerateClick,
- (menuSelectionProvider) => menuSelectionProvider.GetSelection().Any(engineeringObject => engineeringObject is TagTable) ? MenuStatus.Enabled : MenuStatus.Disabled);
+ ///
+ /// Called when mouse is over the context menu item 'Action 1'.
+ /// The returned value will be used to enable or disable it.
+ ///
+ ///
+ /// Here, the same generic type as was used in addInRootSubmenu.Items.AddActionItem must be used
+ /// (here it has to be IEngineeringObject)
+ ///
+ private MenuStatus OnCanGenerate(MenuSelectionProvider menuSelectionProvider)
+ {
+ // MenuStatus
+ // Enabled = Visible
+ // Disabled = Visible but not executable
+ // Hidden = Item will not be shown
+
+ var select1 = menuSelectionProvider.GetSelection();
+ var select2 = menuSelectionProvider.GetSelection();
+ var select3 = menuSelectionProvider.GetSelection();
+
+ if (select1.Any() || select2.Any() || select3.Any())
+ return MenuStatus.Enabled;
+ else
+ return MenuStatus.Hidden;
}
- private void OnGenerateClick(MenuSelectionProvider menuSelectionProvider)
+ private void OnGenerate(MenuSelectionProvider menuSelectionProvider)
{
GetFeedbackContext();
diff --git a/Extract_V18/Config.xml b/Extract_V18/Config.xml
index b625bcf..34459fe 100644
--- a/Extract_V18/Config.xml
+++ b/Extract_V18/Config.xml
@@ -6,7 +6,7 @@
V1.1
Alarms builder
- SKF_AlarmsBuilder
+ 906ABF3F-C4CA-45F7-98F0-2E78F9F3D48B
18.0.1.1
diff --git a/TIA_Extract/AlarmsTextsAddIn.cs b/TIA_Extract/AlarmsTextsAddIn.cs
index b266da5..f082aea 100644
--- a/TIA_Extract/AlarmsTextsAddIn.cs
+++ b/TIA_Extract/AlarmsTextsAddIn.cs
@@ -24,6 +24,8 @@
using System.Text.RegularExpressions;
using SimaticML;
+using Siemens.Engineering.Settings;
+using System.Globalization;
namespace TIA_Extract
{
@@ -62,9 +64,9 @@ public AlarmsTextsAddIn(TiaPortal tiaPortal) : base(s_DisplayNameOfAddIn)
//#if DEBUG
// Core.Properties.Resources.Culture = new CultureInfo("en-US");
//#else
- // TiaPortalSettingsFolder generalSettingsFolder = _tiaPortal.SettingsFolders.Find("General");
- // TiaPortalSetting UILanguageSetting = generalSettingsFolder.Settings.Find("UserInterfaceLanguage");
- // Core.Properties.Resources.Culture = UILanguageSetting.Value as CultureInfo;
+ // TiaPortalSettingsFolder generalSettingsFolder = _tiaPortal.SettingsFolders.Find("General");
+ // TiaPortalSetting UILanguageSetting = generalSettingsFolder.Settings.Find("UserInterfaceLanguage");
+ // Extract.Core.Properties.Resources.Culture = UILanguageSetting.Value as CultureInfo;
//#endif
}
@@ -77,17 +79,35 @@ public AlarmsTextsAddIn(TiaPortal tiaPortal) : base(s_DisplayNameOfAddIn)
///
protected override void BuildContextMenuItems(ContextMenuAddInRoot addInRootSubmenu)
{
- addInRootSubmenu.Items.AddActionItem(Extract.Core.Properties.Resources.ContextMenu_GlobalDb, OnGenerateClick,
- (menuSelectionProvider) => menuSelectionProvider.GetSelection().Any(engineeringObject => engineeringObject is SimaticSW.GlobalDB) ? MenuStatus.Enabled : MenuStatus.Hidden);
-
- addInRootSubmenu.Items.AddActionItem(Extract.Core.Properties.Resources.ContextMenu_GlobalDb, OnGenerateClick,
- (menuSelectionProvider) => menuSelectionProvider.GetSelection().Any(engineeringObject => engineeringObject is SimaticSW.PlcBlockUserGroup) ? MenuStatus.Enabled : MenuStatus.Hidden);
+ addInRootSubmenu.Items.AddActionItem(Extract.Core.Properties.Resources.ContextMenu_GlobalDb, OnGenerate, OnCanGenerate);
+ }
- addInRootSubmenu.Items.AddActionItem(Extract.Core.Properties.Resources.ContextMenu_HmiTag, OnGenerateClick,
- (menuSelectionProvider) => menuSelectionProvider.GetSelection().Any(engineeringObject => engineeringObject is TagTable) ? MenuStatus.Enabled : MenuStatus.Disabled);
+ ///
+ /// Called when mouse is over the context menu item 'Action 1'.
+ /// The returned value will be used to enable or disable it.
+ ///
+ ///
+ /// Here, the same generic type as was used in addInRootSubmenu.Items.AddActionItem must be used
+ /// (here it has to be IEngineeringObject)
+ ///
+ private MenuStatus OnCanGenerate(MenuSelectionProvider menuSelectionProvider)
+ {
+ // MenuStatus
+ // Enabled = Visible
+ // Disabled = Visible but not executable
+ // Hidden = Item will not be shown
+
+ var select1 = menuSelectionProvider.GetSelection();
+ var select2 = menuSelectionProvider.GetSelection();
+ var select3 = menuSelectionProvider.GetSelection();
+
+ if(select1.Any() || select2.Any() || select3.Any())
+ return MenuStatus.Enabled;
+ else
+ return MenuStatus.Hidden;
}
- private void OnGenerateClick(MenuSelectionProvider menuSelectionProvider)
+ private void OnGenerate(MenuSelectionProvider menuSelectionProvider)
{
GetFeedbackContext();
diff --git a/TIA_Extract/Config.xml b/TIA_Extract/Config.xml
index 4f0acb4..87b3953 100644
--- a/TIA_Extract/Config.xml
+++ b/TIA_Extract/Config.xml
@@ -3,11 +3,11 @@
A. MORELLET
Convert comment from global db to hmi alarms
- V1.1
+ V1.2
Alarms builder
- SKF_AlarmsBuilder
- 19.0.1.1
+ 906ABF3F-C4CA-45F7-98F0-2E78F9F3D48B
+ 19.0.1.2
@@ -34,27 +34,27 @@
-
+
-
-
-
-
-
+
+
+
+
+
-
-
+
+
-
+
-
-
-
+
+
+
diff --git a/TIA_Extract/Extract_V19.csproj b/TIA_Extract/Extract_V19.csproj
index b67b35f..27b1bb4 100644
--- a/TIA_Extract/Extract_V19.csproj
+++ b/TIA_Extract/Extract_V19.csproj
@@ -42,6 +42,9 @@
$([MSBuild]::GetRegistryValueFromView(`HKEY_LOCAL_MACHINE\SOFTWARE\Siemens\Automation\_InstalledSW\TIAP19\EditionMain`, `Path`, `AutoDetect`, RegistryView.Registry64, RegistryView.Registry32))
$([System.IO.Path]::GetFullPath('$(SiemensEngineeringPath)'))
+
+ False
+
$(TiaPortalLocation)\PublicAPI\V19.AddIn\Siemens.Engineering.AddIn.dll
diff --git a/TIA_Extract/Properties/launchSettings.json b/TIA_Extract/Properties/launchSettings.json
index feb0218..b0a43f4 100644
--- a/TIA_Extract/Properties/launchSettings.json
+++ b/TIA_Extract/Properties/launchSettings.json
@@ -4,6 +4,11 @@
"commandName": "Executable",
"executablePath": "$(TiaPortalLocation)\\PublicAPI\\V19.AddIn\\Siemens.Engineering.AddIn.DebugStarter.exe",
"commandLineArgs": "$(ProjectDir)$(OutDir)Extract_V19.addin"
+ },
+ "Publish Add-in": {
+ "commandName": "Executable",
+ "executablePath": "$(TiaPortalLocation)\\PublicAPI\\V19.AddIn\\Siemens.Engineering.AddIn.Publisher.exe",
+ "commandLineArgs": "-f $(SolutionDir)$(ProjectName)\\Config.xml -v -c"
}
}
}
\ No newline at end of file