Skip to content

Commit

Permalink
Deserialize globalDb
Browse files Browse the repository at this point in the history
  • Loading branch information
caprican committed Jan 26, 2025
1 parent 1577b5d commit 4621388
Show file tree
Hide file tree
Showing 16 changed files with 578 additions and 156 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Documentation
You can find further documentation and help in the following links:
- [TIA Portal Openness V16: System manual](https://support.industry.siemens.com/cs/document/109773802/simatic-tia-portal-openness-automating-creation-of-projects?dti=0&lc=en-WW)
- [TIA Portal Openness V17: System manual](https://support.industry.siemens.com/cs/document/109798533/simatic-tia-portal-openness-api-for-automation-of-engineering-workflows?dti=0&lc=en-WW)
- [TIA Portal Openness V18: System manual](https://support.industry.siemens.com/cs/document/109815199/simatic-tia-portal-openness-api-for-automation-of-engineering-workflows?dti=0&lc=en-WW)
- [TIA Portal Openness V19: System manual](https://support.industry.siemens.com/cs/document/109826886/simatic-tia-portal-openness-api-for-automation-of-engineering-workflows?dti=0&lc=en-WW)
42 changes: 42 additions & 0 deletions SimaticML.Demo/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// See https://aka.ms/new-console-template for more information
using System.Xml.Serialization;
using System.Xml;

Console.WriteLine("Hello, World!");

var fileName = @"C:\Users\capri\OneDrive\Documents\Automation\TIA069\UserFiles\Export\N100_Defauts.xml";
//var fileName = @"C:\Users\capri\OneDrive\Documents\Automation\TIA069\UserFiles\Export\LSKF_Motor.xml";

var settings = new XmlReaderSettings
{
//ValidationType = ValidationType.Schema
};
//settings.Schemas.Add("", @"Schemas\Commons\SW.Common_v3.xsd");
//settings.Schemas.Add("http://www.siemens.com/automation/Openness/SW/Interface/v5", @"Schemas\InterfaceSections\SW.InterfaceSections_v5.xsd");


var serializer = new XmlSerializer(typeof(SimaticML.Document)/*, attrOverrides*/);
serializer.UnknownAttribute += OnUnknownAttribute;
serializer.UnknownElement += OnUnknownElement;

var reader = XmlReader.Create(fileName, settings);

if (serializer.Deserialize(reader) is SimaticML.Document document)
{
switch (document[0])
{
case SimaticML.SW.Blocks.GlobalDB globalDB:
//var item = globalDB.AttributeList.Interface.Sections[0];//.Member[0];

break;
}
}


void OnUnknownElement(object? sender, XmlElementEventArgs e)
{
}

void OnUnknownAttribute(object? sender, XmlAttributeEventArgs e)
{
}
14 changes: 14 additions & 0 deletions SimaticML.Demo/SimaticML.Demo.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\SimaticML\SimaticML.csproj" />
</ItemGroup>

</Project>
17 changes: 17 additions & 0 deletions SimaticML.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ VisualStudioVersion = 17.8.34330.188
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimaticML", "SimaticML\SimaticML.csproj", "{4B873907-F27F-4561-8363-D38C074D4D53}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Éléments de solution", "Éléments de solution", "{5C17E06B-DC3C-4F74-831D-2838670D6252}"
ProjectSection(SolutionItems) = preProject
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimaticML.Demo", "SimaticML.Demo\SimaticML.Demo.csproj", "{8F5ED2F2-548D-434B-8CA0-6E41D2895CBA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimaticML.test", "SimaticML.test\SimaticML.test.csproj", "{C2929704-9889-4CFD-8E0F-6DFE94A3974B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +24,14 @@ Global
{4B873907-F27F-4561-8363-D38C074D4D53}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4B873907-F27F-4561-8363-D38C074D4D53}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4B873907-F27F-4561-8363-D38C074D4D53}.Release|Any CPU.Build.0 = Release|Any CPU
{8F5ED2F2-548D-434B-8CA0-6E41D2895CBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8F5ED2F2-548D-434B-8CA0-6E41D2895CBA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8F5ED2F2-548D-434B-8CA0-6E41D2895CBA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8F5ED2F2-548D-434B-8CA0-6E41D2895CBA}.Release|Any CPU.Build.0 = Release|Any CPU
{C2929704-9889-4CFD-8E0F-6DFE94A3974B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C2929704-9889-4CFD-8E0F-6DFE94A3974B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C2929704-9889-4CFD-8E0F-6DFE94A3974B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C2929704-9889-4CFD-8E0F-6DFE94A3974B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
1 change: 1 addition & 0 deletions SimaticML.test/MSTestSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)]
19 changes: 19 additions & 0 deletions SimaticML.test/SimaticML.test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="MSTest" Version="3.6.4" />
</ItemGroup>

<ItemGroup>
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
</ItemGroup>

</Project>
11 changes: 11 additions & 0 deletions SimaticML.test/Test1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace SimaticML.test
{
[TestClass]
public sealed class Test1
{
[TestMethod]
public void TestMethod1()
{
}
}
}
61 changes: 24 additions & 37 deletions SimaticML/AttributeList_G.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.ComponentModel;
using System.Xml;
using System.Xml.Serialization;

namespace SimaticML
Expand All @@ -10,109 +11,95 @@ namespace SimaticML
[Serializable]
public class AttributeList_G
{
public AttributeList_G()
{
AutoNumber = true;
HeaderAuthor = "";
HeaderFamily = "";
HeaderName = "";
HeaderVersion = "0.1";

IsKnowHowProtected = false;
IsWriteProtected = false;

PLCSimAdvancedSupport = false;
}

[DefaultValue(true)]
public bool AutoNumber { get; set; }
public bool AutoNumber { get; set; } = true;
[XmlIgnore]
public bool AutoNumberSpecified { get; set; }

public DateTime CodeModifiedDate { get; set; }
public DateTime? CodeModifiedDate { get; set; } = null;
[XmlIgnore]
public bool CodeModifiedDateSpecified { get; set; }

public DateTime CompileDate { get; set; }
public DateTime? CompileDate { get; set; } = null;
[XmlIgnore]
public bool CompileDateSpecified { get; set; }

public DateTime CreationDate { get; set; }
public DateTime? CreationDate { get; set; } = null;
[XmlIgnore]
public bool CreationDateSpecified { get; set; }

[DefaultValue("")]
public string HeaderAuthor { get; set; }
public string HeaderAuthor { get; set; } = "";
[XmlIgnore]
public bool HeaderAuthorSpecified { get; set; }

[DefaultValue("")]
public string HeaderFamily { get; set; }
public string HeaderFamily { get; set; } = "";
[XmlIgnore]
public bool HeaderFamilySpecified { get; set; }

[DefaultValue("")]
public string HeaderName { get; set; }
public string HeaderName { get; set; } = "";
[XmlIgnore]
public bool HeaderNameSpecified { get; set; }

[DefaultValue("0.1")]
public string HeaderVersion { get; set; }
public string HeaderVersion { get; set; } = "0.1";
[XmlIgnore]
public bool HeaderVersionSpecified { get; set; }

//public SW.Interface_T Interface { get; set; }
//[XmlIgnore]
//public bool InterfaceSpecified { get; set; }
public SW.Interface_T Interface { get; set; } = null;
[XmlIgnore]
public bool InterfaceSpecified { get; set; }

public DateTime InterfaceModifiedDate { get; set; }
public DateTime? InterfaceModifiedDate { get; set; } = null;
[XmlIgnore]
public bool InterfaceModifiedDateSpecified { get; set; }

public bool IsConsistent { get; set; }
public bool? IsConsistent { get; set; } = null;
[XmlIgnore]
public bool IsConsistentSpecified { get; set; }

[DefaultValue(false)]
public bool IsKnowHowProtected { get; set; }
public bool IsKnowHowProtected { get; set; } = false;
[XmlIgnore]
public bool IsKnowHowProtectedPrecified { get; set; }

[DefaultValue(false)]
public bool IsWriteProtected { get; set; }
public bool IsWriteProtected { get; set; } = false;
[XmlIgnore]
public bool IsWriteProtectedSpecified { get; set; }

public MemoryLayout_TE MemoryLayout { get; set; }
public MemoryLayout_TE? MemoryLayout { get; set; } = null;
[XmlIgnore]
public bool MemoryLayoutSpecified { get; set; }

public DateTime ModifiedDate { get; set; }
public DateTime? ModifiedDate { get; set; } = null;
[XmlIgnore]
public bool ModifiedDateSpecified { get; set; }

public string Name { get; set; }
public string Name { get; set; } = null;
[XmlIgnore]
public bool NameSpecified { get; set; }

public int Number { get; set; }
public int? Number { get; set; } = null;
[XmlIgnore]
public bool NumberSpecified { get; set; }

public DateTime ParameterModified { get; set; }
public DateTime? ParameterModified { get; set; } = null;
[XmlIgnore]
public bool ParameterModifiedSpecified { get; set; }

[DefaultValue(false)]
public bool PLCSimAdvancedSupport { get; set; }
public bool PLCSimAdvancedSupport { get; set; } = false;
[XmlIgnore]
public bool PLCSimAdvancedSupportSpecified { get; set; }

public ProgrammingLanguage_TE ProgrammingLanguage { get; set; }
public ProgrammingLanguage_TE? ProgrammingLanguage { get; set; } = null;
[XmlIgnore]
public bool ProgrammingLanguageSpecified { get; set; }

public DateTime StructureModified { get; set; }
public DateTime? StructureModified { get; set; } = null;
[XmlIgnore]
public bool StructureModifiedSpecified { get; set; }
}
Expand Down
Loading

0 comments on commit 4621388

Please sign in to comment.