Skip to content

Commit

Permalink
Correction génération par dossiers
Browse files Browse the repository at this point in the history
  • Loading branch information
caprican committed Apr 23, 2024
1 parent 107f9b3 commit c457dfa
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
15 changes: 7 additions & 8 deletions Extract_V18/AlarmsTextsAddIn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ public AlarmsTextsAddIn(TiaPortal tiaPortal) : base(s_DisplayNameOfAddIn)
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 || engineeringObject is SimaticSW.PlcBlockUserGroup) ? MenuStatus.Enabled : MenuStatus.Hidden);
(menuSelectionProvider) => menuSelectionProvider.GetSelection().Any(engineeringObject => engineeringObject is SimaticSW.GlobalDB) ? MenuStatus.Enabled : MenuStatus.Hidden);

//addInRootSubmenu.Items.AddActionItem<IEngineeringObject>(Extract.Core.Properties.Resources.ContextMenu_UserGroup, OnGenerateClick,
// (menuSelectionProvider) => menuSelectionProvider.GetSelection().Any(engineeringObject => engineeringObject is SimaticSW.PlcBlockUserGroup) ? MenuStatus.Enabled : MenuStatus.Disabled);
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_HmiTag, OnGenerateClick,
(menuSelectionProvider) => menuSelectionProvider.GetSelection().Any(engineeringObject => engineeringObject is TagTable) ? MenuStatus.Enabled : MenuStatus.Disabled);
Expand Down Expand Up @@ -128,21 +128,20 @@ private void OnGenerateClick(MenuSelectionProvider<IEngineeringObject> menuSelec
var asUpdateAlarms = false;
do
{
if (tempGroupList[0].Blocks.Any(block => block is SimaticSW.GlobalDB))
if (tempGroupList[0].Blocks.Where(bloc => bloc is SimaticSW.GlobalDB).Cast<SimaticSW.GlobalDB>() is IEnumerable<SimaticSW.GlobalDB> globalDBs)
{
foreach (var plcDataBlock in blockGroup.Blocks.Where(bloc => bloc is SimaticSW.GlobalDB).Cast<SimaticSW.GlobalDB>())
foreach (var plcDataBlock in globalDBs)
{
asUpdateAlarms = true;
BuildAlarms(exclusiveAccess, plcDataBlock, projectPath.Directory.FullName);
_feedbackContext.Log(NotificationIcon.Success, Extract.Core.Properties.Resources.Feedback_AlarmsUpdated_Text);
}
}
if (tempGroupList[0].Groups.Count > 0)
{
tempGroupList.AddRange(tempGroupList[0].Groups);
}

tempGroupList.RemoveAt(0);

} while (tempGroupList.Count > 0);

if(!asUpdateAlarms)
Expand Down Expand Up @@ -371,8 +370,8 @@ public void BuildAlarms(ExclusiveAccess exclusiveAccess, SimaticSW.GlobalDB glob
{
tagTables.AddRange(tagTablesGroup[0].TagTables);
tagTablesGroup.AddRange(tagTablesGroup[0].Groups);
tagTablesGroup.RemoveAt(0);
}
tagTablesGroup.RemoveAt(0);
} while (tagTablesGroup.Count > 0);

if (!tagTables.Any(a => a.Name == folderName))
Expand Down
4 changes: 2 additions & 2 deletions Extract_V18/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.0</AddInVersion>
<AddInVersion>V1.1</AddInVersion>
<Product>
<Name>Alarms builder</Name>
<Id>SKF_AlarmsBuilder</Id>
<Version>18.0.1.0</Version>
<Version>18.0.1.1</Version>
</Product>
<FeatureAssembly>
<AssemblyInfo>
Expand Down
22 changes: 12 additions & 10 deletions TIA_Extract/AlarmsTextsAddIn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
using Siemens.Engineering.HW;
using Siemens.Engineering.HW.Features;
using Siemens.Engineering.SW;

using SimaticSW = Siemens.Engineering.SW.Blocks;
using Siemens.Engineering.SW.Blocks.Interface;
using Siemens.Engineering.SW.Units;

using System.Text.RegularExpressions;
using SimaticML;

Expand Down Expand Up @@ -76,10 +78,10 @@ public AlarmsTextsAddIn(TiaPortal tiaPortal) : base(s_DisplayNameOfAddIn)
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 || engineeringObject is SimaticSW.PlcBlockUserGroup) ? MenuStatus.Enabled : MenuStatus.Hidden);
(menuSelectionProvider) => menuSelectionProvider.GetSelection().Any(engineeringObject => engineeringObject is SimaticSW.GlobalDB) ? MenuStatus.Enabled : MenuStatus.Hidden);

//addInRootSubmenu.Items.AddActionItem<IEngineeringObject>(Extract.Core.Properties.Resources.ContextMenu_UserGroup, OnGenerateClick,
// (menuSelectionProvider) => menuSelectionProvider.GetSelection().Any(engineeringObject => engineeringObject is SimaticSW.PlcBlockUserGroup) ? MenuStatus.Enabled : MenuStatus.Disabled);
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_HmiTag, OnGenerateClick,
(menuSelectionProvider) => menuSelectionProvider.GetSelection().Any(engineeringObject => engineeringObject is TagTable) ? MenuStatus.Enabled : MenuStatus.Disabled);
Expand Down Expand Up @@ -126,21 +128,20 @@ private void OnGenerateClick(MenuSelectionProvider<IEngineeringObject> menuSelec
var asUpdateAlarms = false;
do
{
if (tempGroupList[0].Blocks.Any(block => block is SimaticSW.GlobalDB))
if (tempGroupList[0].Blocks.Where(bloc => bloc is SimaticSW.GlobalDB).Cast<SimaticSW.GlobalDB>() is IEnumerable<SimaticSW.GlobalDB> globalDBs)
{
foreach (var plcDataBlock in blockGroup.Blocks.Where(bloc => bloc is SimaticSW.GlobalDB).Cast<SimaticSW.GlobalDB>())
foreach (var plcDataBlock in globalDBs)
{
asUpdateAlarms = true;
BuildAlarms(exclusiveAccess, plcDataBlock, projectPath.Directory.FullName);
_feedbackContext.Log(NotificationIcon.Success, Extract.Core.Properties.Resources.Feedback_AlarmsUpdated_Text);
}
}
if (tempGroupList[0].Groups.Count > 0)
{
tempGroupList.AddRange(tempGroupList[0].Groups);
}


tempGroupList.RemoveAt(0);

} while (tempGroupList.Count > 0);

if(!asUpdateAlarms)
Expand All @@ -167,8 +168,9 @@ private void OnGenerateClick(MenuSelectionProvider<IEngineeringObject> menuSelec
{
devices.AddRange(deviceGroup[0].Devices);
deviceGroup.AddRange(deviceGroup[0].Groups);
deviceGroup.RemoveAt(0);
}
deviceGroup.RemoveAt(0);

} while (deviceGroup.Count > 0);

foreach (var device in devices)
Expand Down Expand Up @@ -367,8 +369,8 @@ public void BuildAlarms(ExclusiveAccess exclusiveAccess, SimaticSW.GlobalDB glob
{
tagTables.AddRange(tagTablesGroup[0].TagTables);
tagTablesGroup.AddRange(tagTablesGroup[0].Groups);
tagTablesGroup.RemoveAt(0);
}
tagTablesGroup.RemoveAt(0);
} while (tagTablesGroup.Count > 0);

if (!tagTables.Any(a => a.Name == folderName))
Expand Down
4 changes: 2 additions & 2 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.0</AddInVersion>
<AddInVersion>V1.1</AddInVersion>
<Product>
<Name>Alarms builder</Name>
<Id>SKF_AlarmsBuilder</Id>
<Version>19.0.1.0</Version>
<Version>19.0.1.1</Version>
</Product>
<FeatureAssembly>
<AssemblyInfo>
Expand Down

0 comments on commit c457dfa

Please sign in to comment.