Skip to content

Commit 063ab3b

Browse files
committed
support block download
1 parent faef08b commit 063ab3b

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

src/S7CommPlusDriver/S7CommPlusConnectionHighLevel.cs

+27-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using System;
1717
using System.Collections.Generic;
1818
using System.Linq;
19+
using System.Text;
1920

2021
namespace S7CommPlusDriver
2122
{
@@ -88,6 +89,23 @@ public enum ProgrammingLanguage : int
8889
CEM = 600,
8990
}
9091

92+
public enum BinaryArtifacts : uint
93+
{
94+
Undefined = 0u,
95+
PlcFamily = 2147483649u,
96+
PlcMc7plusData = 2147483650u,
97+
PlcOptimizationInfoData = 2147483651u,
98+
PlcClosedImmediateData = 2147483652u,
99+
SimulatorFamily = 2147483665u,
100+
SimulatorMc7plusData = 2147483666u,
101+
SimulatorOptimizationInfoData = 2147483667u,
102+
SimulatorClosedImmediateData = 2147483668u,
103+
VirtualPlcFamilyKey = 2147483681u,
104+
VirtualPlcMc7plusDataKey = 2147483682u,
105+
VirtualPlcOptimizationInfoDataKey = 2147483683u,
106+
VirtualPlcClosedImmediateDataKey = 2147483684u
107+
}
108+
91109
public class BlockInfo
92110
{
93111
public string name; // Name of the datablock
@@ -296,10 +314,17 @@ public int GetBlockXml(uint relid, out string xml_linecomment, out Dictionary<ui
296314
var xx = (ValueBlobSparseArray)att.Value;
297315
BlobDecompressor bd3 = new BlobDecompressor();
298316
var blob_sp3 = xx.GetValue();
299-
blockBody = new string[blob_sp3.Count];
317+
blockBody = new string[blob_sp3.Where(x => x.Key < (uint)BinaryArtifacts.PlcFamily).Count()];
300318
var i = 0;
301-
foreach (var key in blob_sp3.Keys)
319+
foreach (var key in blob_sp3.Keys.Order())
302320
{
321+
if (!(key < (uint)BinaryArtifacts.PlcFamily))
322+
{
323+
//TODO: what to do with binary artifacts?
324+
var binaryArtifactType = (BinaryArtifacts)key;
325+
continue;
326+
}
327+
303328
if (blob_sp3[key].value != null)
304329
{
305330
var code = bd3.decompress(blob_sp3[key].value, 4);

0 commit comments

Comments
 (0)