Skip to content

Commit f69b2d1

Browse files
authored
Merge pull request #261 from TomMuehlegger/master
fix: S5 project conversion
2 parents 9424de5 + 941c386 commit f69b2d1

4 files changed

Lines changed: 13 additions & 2 deletions

File tree

‎LibNoDaveConnectionLibrary/DataTypes/Projectfolders/Step5/Step5BlocksFolder.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ public Block GetBlock(string BlockName)
3636

3737
internal S5ProjectBlockInfo GetBlockInfo(string BlockName)
3838
{
39-
var nm = BlockName.Replace(" ", "");
39+
//Callers pass both "FB1" and "S5_FB1"; the comparison below is without the "S5_" prefix
40+
var nm = BlockName.Replace(" ", "").Replace("S5_", "");
4041

4142
lock (step5BlocksinfoList)
4243
{

‎LibNoDaveConnectionLibrary/PLCs/S5/MC5/MC5LIB_SYMTAB.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static class MC5LIB_SYMTAB
132132
new object[] {0x5B80, 0x0000, 9, 7, 0xff80, 0x007f, "T", "AD", "PrintNummer",ReferenceDataAccessMode.Write},
133133
new object[] {0x5C00, 0x0000, 8, 8, 0xff00, 0x00ff, "S", "Z", "PrintNummer",ReferenceDataAccessMode.Write},
134134
new object[] {0x5D00, 0x0000, 8, 8, 0xff00, 0x00ff, "SPB", "SB", "PrintNummer",ReferenceDataAccessMode.Call},
135-
new object[] {0x5F00, 0x0000, 8, 6, 0xff00, 0x00ff, "L", "QB", "PrintNummer",ReferenceDataAccessMode.Read},
135+
new object[] {0x5F00, 0x0000, 8, 8, 0xff00, 0x00ff, "L", "QB", "PrintNummer",ReferenceDataAccessMode.Read},
136136
new object[] {0x6000, 0x0000, 16, 0, 0xffff, 0x0000, ":F", null, null,ReferenceDataAccessMode.None},
137137
new object[] {0x6003, 0x0000, 16, 0, 0xffff, 0x0000, ":G", null, null,ReferenceDataAccessMode.None},
138138
new object[] {0x6004, 0x0000, 16, 0, 0xffff, 0x0000, "xF", null, null,ReferenceDataAccessMode.None},

‎LibNoDaveConnectionLibrary/PLCs/S5/MC5/MC5toDB.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ public static S5DataBlock GetDB(ProjectPlcBlockInfo blkInfo, byte[] block, byte[
8888
{
8989
s7DataRow = new S7DataRow(string.Empty, S7DataRowType.S5_KH, retVal);
9090
main.Add(s7DataRow);
91+
//Rows not described by a pre-header are still referenced by line number in the comment block
92+
zeilenListe.Add(s7DataRow);
9193
}
9294

9395
switch (s7DataRow.DataType)

‎LibNoDaveConnectionLibrary/Projectfiles/Step5Project.cs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,16 @@ protected override void LoadProject()
176176
int len = 0;
177177

178178
ByteAddressOFExistingBlocks.Add(n);
179+
int blockStart = n;
179180
var tmp = AddBlockInfo(s5ProjectByteArray, ref n, blkFld,
180181
bstHeaders[akanz - 1]);
182+
183+
//Comment blocks (PK, FK, DK, ...) can carry the type byte of their parent block (PB, FB, DB, ...),
184+
//so they would be read as a second PB, FB, DB. The type of the section they are stored in is the real one.
185+
int blockTypeByte = s5ProjectByteArray[blockStart] == 0x70 ? s5ProjectByteArray[blockStart + 2] : s5ProjectByteArray[blockStart];
186+
if (tmp != null && blockTypeByte != section_header_type)
187+
tmp.BlockType = (PLCBlockType)(section_header_type | 0xf00);
188+
181189
if (tmp != null)
182190
blkFld.step5BlocksinfoList.Add(tmp);
183191

0 commit comments

Comments
 (0)