Skip to content

Fixes #228: Var tab import #229

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

Merged
merged 1 commit into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion DotNetSiemensPLCToolBoxLibrary.TIAV19/Step7ProjectV19Tia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security;
using System.Xml.Linq;
using DotNetSiemensPLCToolBoxLibrary.DataTypes;
using DotNetSiemensPLCToolBoxLibrary.DataTypes.Blocks;
Expand Down Expand Up @@ -459,6 +458,11 @@ public List<ITIAVarTab> TagTables
return retVal;
}
}

public override void ImportFile(FileInfo file, bool overwrite, bool importFromSource)
{
this.group.TagTables.Import(file, overwrite ? ImportOptions.Override : ImportOptions.None);
}
}

public class TIAOpennessWatchTable : ITIAWatchTable
Expand Down
4 changes: 4 additions & 0 deletions DotNetSiemensPLCToolBoxLibrary.TIAV20/Step7ProjectV20Tia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,10 @@ public List<ITIAVarTab> TagTables
}
return retVal;
}
}
public override void ImportFile(FileInfo file, bool overwrite, bool importFromSource)
{
this.group.TagTables.Import(file, overwrite ? ImportOptions.Override : ImportOptions.None);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using DotNetSiemensPLCToolBoxLibrary.DataTypes.Projectfolders;
using DotNetSiemensPLCToolBoxLibrary.Projectfiles.TIA.Openness;
using System.Collections.Generic;

namespace DotNetSiemensPLCToolBoxLibrary.DataTypes.Blocks.Step7V11
{
public interface ITIAVarTabFolder: IProjectFolder
public interface ITIAVarTabFolder: ITIAOpennessProjectFolder
{
List<ITIAVarTab> TagTables { get; }
}
Expand Down
33 changes: 8 additions & 25 deletions TiaImporter/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using DotNetSiemensPLCToolBoxLibrary.DataTypes.Projectfolders;
using DotNetSiemensPLCToolBoxLibrary.DataTypes.Blocks.Step7V11;
using DotNetSiemensPLCToolBoxLibrary.Projectfiles;
using DotNetSiemensPLCToolBoxLibrary.Projectfiles.TIA.Openness;

Expand Down Expand Up @@ -116,37 +116,20 @@ void ImportFiles()
{
var dtFolder = importFolder as ITIAOpennessPlcDatatypeFolder;
var pgFolder = importFolder as ITIAOpennessProgramFolder;
var tagFolder = importFolder as ITIAVarTabFolder;

if (dtFolder != null)
{
dtFolder.ImportFile(new FileInfo(importFile), true, false);
}
else if (pgFolder != null)
{
//if (importFile.ToLower().EndsWith("scl"))
//{
// string srcBeforeScl = null;
// var blkInfo = pgFolder.BlockInfos.FirstOrDefault(x => x.Name.ToLower() == Path.GetFileNameWithoutExtension(importFile).ToLower());
// if (blkInfo != null)
// {
// Console.WriteLine("SCL File with XML File: " + relativePath);
// Console.WriteLine("Export current XML...");
// srcBeforeScl = blkInfo.Export(ExportFormat.Xml);
// Console.WriteLine("Import SCL...");
// }
// pgFolder.ImportFile(new FileInfo(importFile), true, !importFile.ToLower().EndsWith("xml"));
// if (blkInfo != null)
// {
// Console.WriteLine("Export new XML...");
// var blkAfter = pgFolder.BlockInfos.FirstOrDefault(x => x.Name.ToLower() == Path.GetFileNameWithoutExtension(importFile).ToLower());
// var srcAfter = blkAfter.Export(ExportFormat.Xml);
// Console.WriteLine("Import combined XML...");
// }
//}
//else
{
pgFolder.ImportFile(new FileInfo(importFile), true, !importFile.ToLower().EndsWith("xml"));
}

pgFolder.ImportFile(new FileInfo(importFile), true, !importFile.ToLower().EndsWith("xml"));
}
else if (tagFolder != null)
{
tagFolder.ImportFile(new FileInfo(importFile), true, false);
}

Console.ForegroundColor = ConsoleColor.Green;
Expand Down
Loading