Skip to content

Commit 7e2bdb5

Browse files
authored
Merge pull request #57 from siemens/18-can-i-define-the-hardware-plcs-and-drives-in-excel-and-later-generate-the-elements
feat: add hardware generation excel based example (#18)
2 parents f6444f8 + 35b4ca1 commit 7e2bdb5

18 files changed

+961
-450
lines changed

.editorconfig

Lines changed: 224 additions & 171 deletions
Large diffs are not rendered by default.
Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,57 @@
11
using System.Reflection;
2-
3-
using NUnit.Framework;
4-
52
using MAC_use_cases.Model;
63
using MAC_use_cases.TiaImports;
7-
4+
using NUnit.Framework;
85
using Siemens.ModularApplicationCreator.Testenvironment;
96
using Siemens.ModularApplicationCreator.Testenvironment.UnitTestBaseClasses.Enums;
107

11-
12-
138
namespace MAC_use_cases.Tests.TestEnvironment
149
{
1510
public class MacFunctionTestBaseMAC_use_cases : MacFunctionTestBase<MAC_use_casesEM>
1611
{
17-
[TearDown]
18-
public override void Teardown()
12+
protected ResourceManagement ResourceManagement
1913
{
14+
get => Get(() => new ResourceManagement(), NunitTestContext.TestCase);
2015
}
2116

22-
protected ResourceManagement ResourceManagement => this.Get( () => new ResourceManagement(), NunitTestContext.TestCase);
2317

24-
protected override void InitializeModuleClassesForTesting()
18+
protected override string DirectoryNameOfViewTestResources
2519
{
20+
get => Get(() => "MAC_use_cases.Tests.Resources");
2621
}
2722

23+
protected override string NameOfTiaZapFileFromResources
24+
{
25+
get => Get(() => "MacTestenvironmentBaseProject.zap19");
26+
}
2827

29-
protected override string DirectoryNameOfViewTestResources =>
30-
this.Get(() => "MAC_use_cases.Tests.Resources");
28+
protected override Assembly Assembly
29+
{
30+
get => Get(() => typeof(MacFunctionTestBaseMAC_use_cases).Assembly);
31+
}
3132

32-
protected override string NameOfTiaZapFileFromResources => this.Get(() => "MacTestenvironmentBaseProject.zap19");
33-
protected override Assembly Assembly => this.Get(() => typeof(MacFunctionTestBaseMAC_use_cases).Assembly);
33+
protected override string PlcName
34+
{
35+
get => Get(() => "S7-1500/ET200MP station_1");
36+
}
3437

35-
protected override string PlcName => this.Get(() => "S7-1500/ET200MP station_1");
36-
protected override string PlcCPUName => this.Get(() => "TestenvironmentPLC");
37-
protected override string OrderNumberPLC => this.Get(() => "");
38-
}
38+
protected override string PlcCPUName
39+
{
40+
get => Get(() => "TestenvironmentPLC");
41+
}
42+
43+
protected override string OrderNumberPLC
44+
{
45+
get => Get(() => "");
46+
}
3947

48+
[TearDown]
49+
public override void Teardown()
50+
{
51+
}
52+
53+
protected override void InitializeModuleClassesForTesting()
54+
{
55+
}
56+
}
4057
}

MAC_use_cases.Tests/TestEnvironment/MacGenerationTestBaseMAC_use_cases.cs

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,52 @@
11
using System.IO;
22
using System.Reflection;
3-
4-
using NUnit.Framework;
5-
63
using MAC_use_cases.Model;
7-
4+
using NUnit.Framework;
85
using Siemens.Engineering;
96
using Siemens.ModularApplicationCreator.Testenvironment;
107

118
namespace MAC_use_cases.Tests.TestEnvironment
129
{
1310
public class MacGenerationTestBaseMAC_use_cases : MacGenerationTestBase<MAC_use_casesEM>
1411
{
15-
[TearDown]
16-
public override void Teardown()
12+
protected override string DirectoryNameOfViewTestResources
1713
{
14+
get => Get(() => "MAC_use_cases.Tests.Resources");
1815
}
19-
protected override void InitializeModuleClassesForTesting()
16+
17+
protected override string NameOfTiaZapFileFromResources
2018
{
19+
get => Get(() => "MacTestenvironmentBaseProject.zap19");
2120
}
2221

23-
protected override string DirectoryNameOfViewTestResources =>
24-
this.Get(() => "MAC_use_cases.Tests.Resources");
22+
protected override Assembly Assembly
23+
{
24+
get => Get(() => typeof(MacGenerationTestBaseMAC_use_cases).Assembly);
25+
}
2526

26-
protected override string NameOfTiaZapFileFromResources => this.Get(() => "MacTestenvironmentBaseProject.zap19");
27-
protected override Assembly Assembly => this.Get(() => typeof(MacGenerationTestBaseMAC_use_cases).Assembly);
27+
protected override string PlcName
28+
{
29+
get => Get(() => "S7-1500/ET200MP station_1");
30+
}
2831

29-
protected override string PlcName => this.Get(() => "S7-1500/ET200MP station_1");
30-
protected override string PlcCPUName => this.Get(() => "TestenvironmentPLC");
31-
protected override string OrderNumberPLC => this.Get(() => "");
32+
protected override string PlcCPUName
33+
{
34+
get => Get(() => "TestenvironmentPLC");
35+
}
36+
37+
protected override string OrderNumberPLC
38+
{
39+
get => Get(() => "");
40+
}
41+
42+
[TearDown]
43+
public override void Teardown()
44+
{
45+
}
46+
47+
protected override void InitializeModuleClassesForTesting()
48+
{
49+
}
3250

3351

3452
protected void OpenProjectInNewTiaPortalWithUi()
Binary file not shown.

MAC_use_cases/MAC_use_cases.csproj

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ where to where -->
5252
<TiaPortalLocation Condition="'$(TiaPortalLocation)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Siemens\Automation\_InstalledSW\TIAP19\Global@Path)</TiaPortalLocation>
5353
</PropertyGroup>
5454
<ItemGroup>
55+
<Reference Include="Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
56+
<SpecificVersion>False</SpecificVersion>
57+
<EmbedInteropTypes>True</EmbedInteropTypes>
58+
<HintPath>C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.Excel\15.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Excel.dll</HintPath>
59+
</Reference>
5560
<Reference Include="Microsoft.VisualBasic" />
5661
<Reference Include="PresentationCore" />
5762
<Reference Include="PresentationFramework" />
@@ -84,6 +89,7 @@ where to where -->
8489
in MPFProj12\ProjectNode.cs, ProcessFiles.
8590
-->
8691
<ItemGroup>
92+
<Compile Include="Model\UseCases\HardwareGenerationExcelBased.cs" />
8793
<Compile Include="TiaImports\CustomLibraryClasses\Lib_Screen_1.cs" />
8894
<Compile Include="TiaImports\CustomLibraryClasses\Lib_MAC_use_cases_custom.cs" />
8995
<Compile Include="Model\UseCases\CreateVariables.cs" />
@@ -113,6 +119,7 @@ where to where -->
113119
<Compile Include="UI\SecondPage.xaml.cs">
114120
<DependentUpon>SecondPage.xaml</DependentUpon>
115121
</Compile>
122+
<Compile Include="ViewModel\HardwareGenerationExcelBasedViewModel.cs" />
116123
</ItemGroup>
117124
<ItemGroup>
118125
<None Include="MAC_use_cases.nuspec">
@@ -130,6 +137,7 @@ where to where -->
130137
<None Include="Helpfiles\OnlineHelpTopics.xml">
131138
<SubType>Content</SubType>
132139
</None>
140+
<Content Include="AdditionalContent\HardwareGenerationExcelBased.xlsx" />
133141
</ItemGroup>
134142
<ItemGroup>
135143
<Page Include="Resources\Lang_en.xaml">
@@ -211,4 +219,4 @@ where to where -->
211219
<Target Name="AfterBuild">
212220
</Target>
213221
-->
214-
</Project>
222+
</Project>

MAC_use_cases/MAC_use_cases.nuspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package>
33
<metadata>
44
<id>MAC_use_cases</id>
5-
<version>1.0.9237-pre20250416105728</version>
5+
<version>1.0.9238-pre20250417091804</version>
66
<title>MAC_use_cases</title>
77
<authors>SIEMENS AG</authors>
88
<projectUrl>http://equipmentmodule.info/</projectUrl>
@@ -40,6 +40,7 @@
4040
<frameworkAssembly assemblyName="WindowsBase" targetFramework=".NETFramework4.8" />
4141
</frameworkAssemblies>
4242
<contentFiles>
43+
<files include="any/net48/AdditionalContent/HardwareGenerationExcelBased.xlsx" buildAction="Content" copyToOutput="false" />
4344
<files include="any/net48/Images/AddLibrary.png" buildAction="Content" copyToOutput="false" />
4445
<files include="any/net48/Images/ClassExplanation.PNG" buildAction="Content" copyToOutput="false" />
4546
<files include="any/net48/Images/CodeExplanation.PNG" buildAction="Content" copyToOutput="false" />

0 commit comments

Comments
 (0)