-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
58 lines (36 loc) · 1.71 KB
/
Program.cs
File metadata and controls
58 lines (36 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System.Collections.Generic;
using System.IO;
using DotNetSiemensPLCToolBoxLibrary;
namespace Stp7Toolbox
{
class Program
{
static void Main(string[] args)
{
// ----- Example usage of PlcParser -----
//string projectPath = @"D:\Prosjekter\Program\Xxxxx.s7p";
//string outputDir = @"D:\Prosjekter\ProgramOutput";
string projectPath = args[0];
string outputDir = args[1];
PlcParser plcParser = new PlcParser(projectPath);
List<PlcParser.Item> Blocks = plcParser.getAllBlocks();
// Get all blocks in MC7 and zipped
plcParser.writeBlocksToZipfile(Blocks, outputDir);
// Get all blocks in MC7
plcParser.writeBlocksToFiles(Blocks, Path.Combine(outputDir,"MC7"));
// Get info on all blocks written to a file
plcParser.writeItemsInfoToFile(Blocks, outputDir + @"\BlocksInfo.txt");
// Get program blocks as a symbolic single awl.
string awl = plcParser.getSourceAwl();
// Get the symbol table formated as SDF.
string symboltable = plcParser.GetSymbolTable();
System.IO.File.WriteAllText(outputDir + @"\Program.awl", awl);
System.IO.File.WriteAllText(outputDir + @"\Program.sdf", symboltable);
// ---- Uncomment only if it is safe to edit the given PLC program. ----
//// Remove NonRetain attribute
//PlcParser.DbItemsCollection dbItemsCollection = plcParser.clearNonRetainAttr();
//// Unde remove NonRetain attribute
//plcParser.undoClearingNonRetainAttr(dbItemsCollection);
}
}
}