Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setpoint node if not existing (necessary because TIA sets setpoin… #120

Merged
merged 1 commit into from
Jun 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions TiaGitHandler/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,35 @@ private static void ParseFolder(ProjectFolder folder, string dir, List<string> s
}
}

// add setpoint node if not existing (necessary because TIA sets setpoint true if no node exists during import)
try
{
var nodes = xmlDoc2.SelectNodes("//smns2:Member/*[local-name()= \"AttributeList\"]", ns2);
foreach (var node in nodes.Cast<XmlNode>())
{
var setPointAttributeExists = false;
foreach (var node2 in node.ChildNodes.Cast<XmlNode>())
{
if (node2.Attributes["Name"].Value == "SetPoint")
{
setPointAttributeExists = true;
}
}

if (!setPointAttributeExists)
{
XmlElement booleanAttribute = xmlDoc2.CreateElement("BooleanAttribute", node.NamespaceURI);
booleanAttribute.SetAttribute("Name", "SetPoint");
booleanAttribute.SetAttribute("SystemDefined", "true");
booleanAttribute.InnerXml = "false";
node.AppendChild(booleanAttribute);
}
}
}
catch
{
}

if (resetSetpoints)
{
try
Expand Down