diff --git a/LibNoDaveConnectionLibrary/DataTypes/Projectfolders/Step5/Step5BlocksFolder.cs b/LibNoDaveConnectionLibrary/DataTypes/Projectfolders/Step5/Step5BlocksFolder.cs index b817d0fd..bd469c0e 100644 --- a/LibNoDaveConnectionLibrary/DataTypes/Projectfolders/Step5/Step5BlocksFolder.cs +++ b/LibNoDaveConnectionLibrary/DataTypes/Projectfolders/Step5/Step5BlocksFolder.cs @@ -36,7 +36,8 @@ public Block GetBlock(string BlockName) internal S5ProjectBlockInfo GetBlockInfo(string BlockName) { - var nm = BlockName.Replace(" ", ""); + //Callers pass both "FB1" and "S5_FB1"; the comparison below is without the "S5_" prefix + var nm = BlockName.Replace(" ", "").Replace("S5_", ""); lock (step5BlocksinfoList) { diff --git a/LibNoDaveConnectionLibrary/PLCs/S5/MC5/MC5LIB_SYMTAB.cs b/LibNoDaveConnectionLibrary/PLCs/S5/MC5/MC5LIB_SYMTAB.cs index be6cc9d5..7a5f5643 100644 --- a/LibNoDaveConnectionLibrary/PLCs/S5/MC5/MC5LIB_SYMTAB.cs +++ b/LibNoDaveConnectionLibrary/PLCs/S5/MC5/MC5LIB_SYMTAB.cs @@ -132,7 +132,7 @@ static class MC5LIB_SYMTAB new object[] {0x5B80, 0x0000, 9, 7, 0xff80, 0x007f, "T", "AD", "PrintNummer",ReferenceDataAccessMode.Write}, new object[] {0x5C00, 0x0000, 8, 8, 0xff00, 0x00ff, "S", "Z", "PrintNummer",ReferenceDataAccessMode.Write}, new object[] {0x5D00, 0x0000, 8, 8, 0xff00, 0x00ff, "SPB", "SB", "PrintNummer",ReferenceDataAccessMode.Call}, - new object[] {0x5F00, 0x0000, 8, 6, 0xff00, 0x00ff, "L", "QB", "PrintNummer",ReferenceDataAccessMode.Read}, + new object[] {0x5F00, 0x0000, 8, 8, 0xff00, 0x00ff, "L", "QB", "PrintNummer",ReferenceDataAccessMode.Read}, new object[] {0x6000, 0x0000, 16, 0, 0xffff, 0x0000, ":F", null, null,ReferenceDataAccessMode.None}, new object[] {0x6003, 0x0000, 16, 0, 0xffff, 0x0000, ":G", null, null,ReferenceDataAccessMode.None}, new object[] {0x6004, 0x0000, 16, 0, 0xffff, 0x0000, "xF", null, null,ReferenceDataAccessMode.None}, diff --git a/LibNoDaveConnectionLibrary/PLCs/S5/MC5/MC5toDB.cs b/LibNoDaveConnectionLibrary/PLCs/S5/MC5/MC5toDB.cs index 2ee51c4c..ea0c3a54 100644 --- a/LibNoDaveConnectionLibrary/PLCs/S5/MC5/MC5toDB.cs +++ b/LibNoDaveConnectionLibrary/PLCs/S5/MC5/MC5toDB.cs @@ -88,6 +88,8 @@ public static S5DataBlock GetDB(ProjectPlcBlockInfo blkInfo, byte[] block, byte[ { s7DataRow = new S7DataRow(string.Empty, S7DataRowType.S5_KH, retVal); main.Add(s7DataRow); + //Rows not described by a pre-header are still referenced by line number in the comment block + zeilenListe.Add(s7DataRow); } switch (s7DataRow.DataType) diff --git a/LibNoDaveConnectionLibrary/Projectfiles/Step5Project.cs b/LibNoDaveConnectionLibrary/Projectfiles/Step5Project.cs index 4b9d8724..90b7df61 100644 --- a/LibNoDaveConnectionLibrary/Projectfiles/Step5Project.cs +++ b/LibNoDaveConnectionLibrary/Projectfiles/Step5Project.cs @@ -176,8 +176,16 @@ protected override void LoadProject() int len = 0; ByteAddressOFExistingBlocks.Add(n); + int blockStart = n; var tmp = AddBlockInfo(s5ProjectByteArray, ref n, blkFld, bstHeaders[akanz - 1]); + + //Comment blocks (PK, FK, DK, ...) can carry the type byte of their parent block (PB, FB, DB, ...), + //so they would be read as a second PB, FB, DB. The type of the section they are stored in is the real one. + int blockTypeByte = s5ProjectByteArray[blockStart] == 0x70 ? s5ProjectByteArray[blockStart + 2] : s5ProjectByteArray[blockStart]; + if (tmp != null && blockTypeByte != section_header_type) + tmp.BlockType = (PLCBlockType)(section_header_type | 0xf00); + if (tmp != null) blkFld.step5BlocksinfoList.Add(tmp);