Skip to content

Commit

Permalink
Search TIA Crach source
Browse files Browse the repository at this point in the history
  • Loading branch information
caprican committed Apr 25, 2024
1 parent c457dfa commit ee556c1
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 61 deletions.
20 changes: 1 addition & 19 deletions Extract.Core/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions Extract.Core/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,7 @@
<value>La génération à été annulé par l'utilisateur</value>
</data>
<data name="ContextMenu_GlobalDb" xml:space="preserve">
<value>Build Alarms</value>
</data>
<data name="ContextMenu_HmiTag" xml:space="preserve">
<value>Update Table</value>
</data>
<data name="ContextMenu_UserGroup" xml:space="preserve">
<value>Généré depuis le dossier</value>
<value>Build</value>
</data>
<data name="EmptyGlobalDb" xml:space="preserve">
<value>Aucun DB d'alarmes trouvé dans le dossier</value>
Expand Down
34 changes: 26 additions & 8 deletions Extract_V18/AlarmsTextsAddIn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,35 @@ public AlarmsTextsAddIn(TiaPortal tiaPortal) : base(s_DisplayNameOfAddIn)
/// </param>
protected override void BuildContextMenuItems(ContextMenuAddInRoot addInRootSubmenu)
{
addInRootSubmenu.Items.AddActionItem<IEngineeringObject>(Extract.Core.Properties.Resources.ContextMenu_GlobalDb, OnGenerateClick,
(menuSelectionProvider) => menuSelectionProvider.GetSelection().Any(engineeringObject => engineeringObject is SimaticSW.GlobalDB) ? MenuStatus.Enabled : MenuStatus.Hidden);

addInRootSubmenu.Items.AddActionItem<IEngineeringObject>(Extract.Core.Properties.Resources.ContextMenu_GlobalDb, OnGenerateClick,
(menuSelectionProvider) => menuSelectionProvider.GetSelection().Any(engineeringObject => engineeringObject is SimaticSW.PlcBlockUserGroup) ? MenuStatus.Enabled : MenuStatus.Hidden);
addInRootSubmenu.Items.AddActionItem<IEngineeringObject>(Extract.Core.Properties.Resources.ContextMenu_GlobalDb, OnGenerate, OnCanGenerate);
}

addInRootSubmenu.Items.AddActionItem<IEngineeringObject>(Extract.Core.Properties.Resources.ContextMenu_HmiTag, OnGenerateClick,
(menuSelectionProvider) => menuSelectionProvider.GetSelection().Any(engineeringObject => engineeringObject is TagTable) ? MenuStatus.Enabled : MenuStatus.Disabled);
/// <summary>
/// Called when mouse is over the context menu item 'Action 1'.
/// The returned value will be used to enable or disable it.
/// </summary>
/// <param name="menuSelectionProvider">
/// Here, the same generic type as was used in addInRootSubmenu.Items.AddActionItem must be used
/// (here it has to be IEngineeringObject)
/// </param>
private MenuStatus OnCanGenerate(MenuSelectionProvider<IEngineeringObject> menuSelectionProvider)
{
// MenuStatus
// Enabled = Visible
// Disabled = Visible but not executable
// Hidden = Item will not be shown

var select1 = menuSelectionProvider.GetSelection<SimaticSW.GlobalDB>();
var select2 = menuSelectionProvider.GetSelection<SimaticSW.PlcBlockUserGroup>();
var select3 = menuSelectionProvider.GetSelection<TagTable>();

if (select1.Any() || select2.Any() || select3.Any())
return MenuStatus.Enabled;
else
return MenuStatus.Hidden;
}

private void OnGenerateClick(MenuSelectionProvider<IEngineeringObject> menuSelectionProvider)
private void OnGenerate(MenuSelectionProvider<IEngineeringObject> menuSelectionProvider)
{
GetFeedbackContext();

Expand Down
2 changes: 1 addition & 1 deletion Extract_V18/Config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<AddInVersion>V1.1</AddInVersion>
<Product>
<Name>Alarms builder</Name>
<Id>SKF_AlarmsBuilder</Id>
<Id>906ABF3F-C4CA-45F7-98F0-2E78F9F3D48B</Id>
<Version>18.0.1.1</Version>
</Product>
<FeatureAssembly>
Expand Down
42 changes: 31 additions & 11 deletions TIA_Extract/AlarmsTextsAddIn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

using System.Text.RegularExpressions;
using SimaticML;
using Siemens.Engineering.Settings;
using System.Globalization;

namespace TIA_Extract
{
Expand Down Expand Up @@ -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
}

Expand All @@ -77,17 +79,35 @@ public AlarmsTextsAddIn(TiaPortal tiaPortal) : base(s_DisplayNameOfAddIn)
/// </param>
protected override void BuildContextMenuItems(ContextMenuAddInRoot addInRootSubmenu)
{
addInRootSubmenu.Items.AddActionItem<IEngineeringObject>(Extract.Core.Properties.Resources.ContextMenu_GlobalDb, OnGenerateClick,
(menuSelectionProvider) => menuSelectionProvider.GetSelection().Any(engineeringObject => engineeringObject is SimaticSW.GlobalDB) ? MenuStatus.Enabled : MenuStatus.Hidden);

addInRootSubmenu.Items.AddActionItem<IEngineeringObject>(Extract.Core.Properties.Resources.ContextMenu_GlobalDb, OnGenerateClick,
(menuSelectionProvider) => menuSelectionProvider.GetSelection().Any(engineeringObject => engineeringObject is SimaticSW.PlcBlockUserGroup) ? MenuStatus.Enabled : MenuStatus.Hidden);
addInRootSubmenu.Items.AddActionItem<IEngineeringObject>(Extract.Core.Properties.Resources.ContextMenu_GlobalDb, OnGenerate, OnCanGenerate);
}

addInRootSubmenu.Items.AddActionItem<IEngineeringObject>(Extract.Core.Properties.Resources.ContextMenu_HmiTag, OnGenerateClick,
(menuSelectionProvider) => menuSelectionProvider.GetSelection().Any(engineeringObject => engineeringObject is TagTable) ? MenuStatus.Enabled : MenuStatus.Disabled);
/// <summary>
/// Called when mouse is over the context menu item 'Action 1'.
/// The returned value will be used to enable or disable it.
/// </summary>
/// <param name="menuSelectionProvider">
/// Here, the same generic type as was used in addInRootSubmenu.Items.AddActionItem must be used
/// (here it has to be IEngineeringObject)
/// </param>
private MenuStatus OnCanGenerate(MenuSelectionProvider<IEngineeringObject> menuSelectionProvider)
{
// MenuStatus
// Enabled = Visible
// Disabled = Visible but not executable
// Hidden = Item will not be shown

var select1 = menuSelectionProvider.GetSelection<SimaticSW.GlobalDB>();
var select2 = menuSelectionProvider.GetSelection<SimaticSW.PlcBlockUserGroup>();
var select3 = menuSelectionProvider.GetSelection<TagTable>();

if(select1.Any() || select2.Any() || select3.Any())
return MenuStatus.Enabled;
else
return MenuStatus.Hidden;
}

private void OnGenerateClick(MenuSelectionProvider<IEngineeringObject> menuSelectionProvider)
private void OnGenerate(MenuSelectionProvider<IEngineeringObject> menuSelectionProvider)
{
GetFeedbackContext();

Expand Down
30 changes: 15 additions & 15 deletions TIA_Extract/Config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<!--Enter values for Author, Description, AddInVersion, Name, ...-->
<Author>A. MORELLET</Author>
<Description>Convert comment from global db to hmi alarms</Description>
<AddInVersion>V1.1</AddInVersion>
<AddInVersion>V1.2</AddInVersion>
<Product>
<Name>Alarms builder</Name>
<Id>SKF_AlarmsBuilder</Id>
<Version>19.0.1.1</Version>
<Id>906ABF3F-C4CA-45F7-98F0-2E78F9F3D48B</Id>
<Version>19.0.1.2</Version>
</Product>
<FeatureAssembly>
<AssemblyInfo>
Expand All @@ -34,27 +34,27 @@
</TIAPermissions>

<SecurityPermissions>
<System.Security.Permissions.SecurityPermission.UnmanagedCode/>
<!--<System.Security.Permissions.SecurityPermission.UnmanagedCode/>-->
<System.Security.Permissions.FileDialogPermission/>
<System.Security.Permissions.UIPermission/>
<System.Security.Permissions.MediaPermission/>
<Siemens.Engineering.AddIn.Permissions.ProcessStartPermission/>
<System.Net.WebPermission/>
<System.Security.Permissions.KeyContainerPermission/>
<System.Net.SocketPermission/>
<!--<System.Security.Permissions.MediaPermission/>-->
<!--<Siemens.Engineering.AddIn.Permissions.ProcessStartPermission/>-->
<!--<System.Net.WebPermission/>-->
<!--<System.Security.Permissions.KeyContainerPermission/>-->
<!--<System.Net.SocketPermission/>-->
<!--<System.Data.Odbc.OdbcPermission/>-->
<System.Security.Permissions.WebBrowserPermission/>
<System.Net.NetworkInformation.NetworkInformationPermission/>
<!--<System.Security.Permissions.WebBrowserPermission/>-->
<!--<System.Net.NetworkInformation.NetworkInformationPermission/>-->
<System.Security.Permissions.StorePermission/>
<System.Configuration.ConfigurationPermission/>
<!--<System.Configuration.ConfigurationPermission/>-->
<System.Security.Permissions.FileIOPermission/>
<System.Diagnostics.EventLogPermission/>
<!--<System.Drawing.Printing.PrintingPermission/>-->
<System.Security.Permissions.IsolatedStorageFilePermission/>
<System.Data.OleDb.OleDbPermission/>
<System.Security.Permissions.RegistryPermission/>
<System.Data.SqlClient.SqlClientPermission/>
<System.Security.Permissions.EnvironmentPermission/>
<!--<System.Security.Permissions.RegistryPermission/>-->
<!--<System.Data.SqlClient.SqlClientPermission/>-->
<!--<System.Security.Permissions.EnvironmentPermission/>-->
<!--<System.Net.Mail.SmtpPermission/>-->
</SecurityPermissions>
</RequiredPermissions>
Expand Down
3 changes: 3 additions & 0 deletions TIA_Extract/Extract_V19.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
<SiemensEngineeringPath Condition="'$(SiemensEngineeringPath)' == ''">$([MSBuild]::GetRegistryValueFromView(`HKEY_LOCAL_MACHINE\SOFTWARE\Siemens\Automation\_InstalledSW\TIAP19\EditionMain`, `Path`, `AutoDetect`, RegistryView.Registry64, RegistryView.Registry32))</SiemensEngineeringPath>
<TiaPortalLocation Condition="'$(TiaPortalLocation)' == '' AND '$(SiemensEngineeringPath)' != 'AutoDetect'">$([System.IO.Path]::GetFullPath('$(SiemensEngineeringPath)'))</TiaPortalLocation>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<Optimize>False</Optimize>
</PropertyGroup>
<ItemGroup>
<Reference Condition="'$(TiaPortalLocation)' != ''" Include="Siemens.Engineering.AddIn">
<HintPath>$(TiaPortalLocation)\PublicAPI\V19.AddIn\Siemens.Engineering.AddIn.dll</HintPath>
Expand Down
5 changes: 5 additions & 0 deletions TIA_Extract/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}

0 comments on commit ee556c1

Please sign in to comment.