private static List<FunctionBlockRow> GetMC5Rows(byte[] code, int codestart, List<S5Parameter> parameters, Step5BlocksFolder blkFld, S5FunctionBlock block) { List<FunctionBlockRow> retVal=new List<FunctionBlockRow>(); int codepos = codestart; retVal.Add(new S5FunctionBlockRow() {Command = "BLD", Parameter = "255", Parent = block}); //Command for first Network does not exist! //This needs to be removen when written back to S5D! while (codepos < code.Length) { byte mc = code[codepos]; // finde Befehle in der Symbol Tabelle int index = find_mc5_code(code, codepos); S5FunctionBlockRow newRow = new S5FunctionBlockRow(){Parent = block}; if (index >= 0) { newRow.MC5LIB_SYMTAB_Row = (object[])sym[index]; bool fb = false; newRow.Command = (string) ((object[]) sym[index])[operation]; string oper = (string) ((object[]) sym[index])[operand]; if (oper == "PAR") { int paridx = find_mc5_param(code, codepos, index); if (parameters != null && parameters.Count > paridx - 1) { newRow.Parameter = "=" + parameters[paridx - 1].Name; } else { newRow.Parameter = "$$error$$ -> invalid Parameter, idx:"+ (paridx - 1); } } else { if (oper != null) newRow.Parameter = oper; fb = IsCall(newRow); //false; /*if ((newRow.Command=="SPA" && newRow.Parameter=="FB") || (newRow.Command=="SPB" && newRow.Parameter=="FB") || (newRow.Command=="BA" && newRow.Parameter=="FX") || (newRow.Command=="BAB" && newRow.Parameter=="FX")) { fb = true; }*/ int par = find_mc5_param(code, codepos, index); switch ((string)((object[])sym[index])[printpar]) { case null: break; case "PrintNummer": if (!string.IsNullOrEmpty(newRow.Parameter)) newRow.Parameter += " "; Int16 wrt =(Int16)par; if (wrt >= 0 && newRow.Parameter == "KF ") newRow.Parameter += " +"; newRow.Parameter += wrt.ToString(); break; case "PrintKY": newRow.Parameter += BitConverter.GetBytes(par)[1].ToString() + "," + BitConverter.GetBytes(par)[0].ToString(); break; case "PrintChar": if (!string.IsNullOrEmpty(newRow.Parameter)) newRow.Parameter += " "; newRow.Parameter += ((char)(BitConverter.GetBytes((Int16)par)[0])).ToString() + ((char)(BitConverter.GetBytes((Int16)par)[1])); break; case "PrintHEX4": if (!string.IsNullOrEmpty(newRow.Parameter)) newRow.Parameter += " "; newRow.Parameter += par.ToString("X").PadLeft(4, '0'); break; case "PrintGleitpunkt": if (!string.IsNullOrEmpty(newRow.Parameter)) newRow.Parameter += " "; newRow.Parameter += "gleit"; break; case "PrintHEX8": if (!string.IsNullOrEmpty(newRow.Parameter)) newRow.Parameter += " "; newRow.Parameter += par.ToString("X").PadLeft(4, '0'); break; case "PrintMerkerBit": if (!string.IsNullOrEmpty(newRow.Parameter)) newRow.Parameter += " "; newRow.Parameter += (par & 0x00FF).ToString() + "." + (par >> 8).ToString(); break; case "PrintSMerkerBit": if (!string.IsNullOrEmpty(newRow.Parameter)) newRow.Parameter += " "; newRow.Parameter += (par & 0x0FFF).ToString() + "." + (par >> 12).ToString(); break; } } int _parlen = (int)((object[])sym[index])[parlen]; int _codelen = (int)((object[])sym[index])[codelen]; int btSize = (_codelen + _parlen) / 8; codepos += btSize; // Schleifenzähler if (fb) { //FB-Call index = find_mc5_code(code, codepos); if (index < 0 || (string)((object[])sym[index])[operation] != "SPA=") newRow.Command = "Error reading Jump after FB/FX Call!"; int spa = find_mc5_param(code, codepos, index); newRow.ExtParameter=new List<S5Parameter>(); //newRow.ExtParameter = new List<string>(); byte[] calledfb = blkFld.GetBlockInByte("S5_" + newRow.Parameter.Replace(" ", "")); if (calledfb!=null) { S5Parameter newPar = new S5Parameter(); newRow.ExtParameter.Add(newPar); string fbNM = System.Text.Encoding.GetEncoding("ISO-8859-1").GetString(calledfb, 12, 8); //newRow.ExtParameter.Add("Name :" + fbNM); newPar.Name = "Name :"; newPar.Value = fbNM; List<S5Parameter> par = GetParameters(calledfb); int j = 0; foreach (var s5Parameter in par) { newPar = new S5Parameter(); newRow.ExtParameter.Add(newPar); j++; string akOper = ""; int pos = codepos + j*2; switch (s5Parameter.S5ParameterType) { case S5ParameterType.A: case S5ParameterType.E: int ber = code[pos]; switch (s5Parameter.S5ParameterFormat) { case S5ParameterFormat.BI: switch (ber & 0xf0) { case 0x80: akOper += "M"; break; } akOper += code[pos + 1].ToString(); akOper += "." + (code[pos] & 0x0f).ToString(); break; case S5ParameterFormat.BY: switch (ber) { case 0x0a: akOper += "MB"; break; case 0x2a: akOper += "DR"; break; case 0x22: akOper += "DL"; break; default: akOper += ""; break; } akOper += code[pos + 1].ToString(); break; case S5ParameterFormat.W: switch (ber) { case 0x12: akOper += "MW"; break; case 0x32: akOper += "DW"; break; } akOper += code[pos + 1].ToString(); break; case S5ParameterFormat.D: break; } break; case S5ParameterType.D: int wrt = code[pos]*0x100 + code[pos + 1]; akOper += s5Parameter.S5ParameterFormat.ToString() + " "; switch (s5Parameter.S5ParameterFormat) { case S5ParameterFormat.KF: if (((Int16)wrt)>0) akOper += "+"; akOper += ((Int16)wrt).ToString(); break; case S5ParameterFormat.KT: //code[pos + 1] // Bit 4-7 0-3 4-7 0-3 //Format: Zeitbasis, 100er, 10er, 1er akOper += wrt.ToString().PadLeft(3, '0') + ".0"; break; case S5ParameterFormat.KC: akOper += (char)code[pos] + (char)code[pos + 1]; break; case S5ParameterFormat.KM: akOper += libnodave.dec2bin(code[pos]) + " "; akOper += libnodave.dec2bin(code[pos + 1]); break; case S5ParameterFormat.KY: akOper += code[pos].ToString() + "," + code[pos + 1].ToString(); break; default: akOper += ((Int16)wrt).ToString("X").PadLeft(4, '0'); break; } break; case S5ParameterType.B: int bst = code[pos]; switch (bst) { case 0x20: akOper += "DB"; break; } akOper += code[pos + 1].ToString(); break; case S5ParameterType.T: //int abst = code[pos]; akOper += "T " + code[pos + 1].ToString(); break; case S5ParameterType.Z: akOper += "Z " + code[pos + 1].ToString(); break; } newPar.Name = s5Parameter.Name; newPar.Value = akOper; //newRow.ExtParameter.Add(s5Parameter.Name.PadRight(5, ' ') + ": " + akOper); } } else for (int j = 1; j < spa; j++) { int myPar = (code[codepos + j*2] << 8) | code[codepos + j*2 + 1]; //newRow.ExtParameter.Add(myPar.ToString()); S5Parameter newPar = new S5Parameter(); newRow.ExtParameter.Add(newPar); newPar.Name = myPar.ToString(); } btSize += spa * 2; codepos += spa * 2; fb = false; } byte[] MC5 = new byte[btSize]; Array.Copy(code,codepos - btSize, MC5, 0, btSize); newRow.MC5 = MC5; } else { newRow.Command = "Error converting command!"; codepos += 2; //throw new Exception("Code nicht in Symtab!"); } retVal.Add(newRow); } #region Build the Jumpsmarks.... int JumpCount = 1; int akBytePos = 0; Dictionary<int, S5FunctionBlockRow> ByteAdressNumerPLCFunctionBlocks = new Dictionary<int, S5FunctionBlockRow>(); foreach (S5FunctionBlockRow tmp in retVal) { if (tmp.ByteSize > 0) { ByteAdressNumerPLCFunctionBlocks.Add(akBytePos, tmp); akBytePos += tmp.ByteSize; } } akBytePos = 0; foreach (S5FunctionBlockRow tmp in retVal) { if (tmp.Command == "SPA=" || tmp.Command == "SPB=" || tmp.Command == "SPZ=" || tmp.Command == "SPN=" || tmp.Command == "SPP=" || tmp.Command == "SPM=" || tmp.Command == "SPO=") { int jmpBytePos = 0; byte[] backup = tmp.MC5; tmp.Command = tmp.Command.Substring(0, tmp.Command.Length - 1); tmp.JumpWidth = (SByte)Convert.ToInt32(tmp.Parameter); jmpBytePos = akBytePos + (tmp.JumpWidth * 2); if (ByteAdressNumerPLCFunctionBlocks.ContainsKey(jmpBytePos)) { var target = ByteAdressNumerPLCFunctionBlocks[jmpBytePos]; if (target.Label.Trim() == "") { target.Label = "M" + JumpCount.ToString().PadLeft(3, '0'); JumpCount++; } //Backup the MC7 Code, because the MC7 Code is always deleted when the command or parameter changes! tmp.Parameter = "=" + target.Label; tmp.MC5 = backup; } else { tmp.Parameter = "Error! JumpWidth :" + tmp.JumpWidth; tmp.MC5 = backup; } } akBytePos += tmp.ByteSize; } #endregion return retVal; }
private S5ProjectBlockInfo AddBlockInfo(byte[] s5ProjectByteArray, ref int pos, Step5BlocksFolder blkFld, byte[] header) { int len = 0; S5ProjectBlockInfo tmpBlk = new S5ProjectBlockInfo(); tmpBlk._blkHeaderByte = header; if (s5ProjectByteArray[pos] == 0x70 && s5ProjectByteArray[pos + 1] == 0x70) //Step5 Block // && s5ProjectByteArray[n - 1] == 0x00) { len = (s5ProjectByteArray[pos + 8] * 0x100 + s5ProjectByteArray[pos + 9]) * 2; tmpBlk.BlockType = (PLCBlockType)(s5ProjectByteArray[pos + 2] | 0xf00); tmpBlk.BlockNumber = s5ProjectByteArray[pos + 3]; //byte n+4 -> kennungen für das programiergerät //byte n+5,6,7 -> bib nummer byte[] code = new byte[len]; Array.Copy(s5ProjectByteArray, pos, code, 0, len); tmpBlk._blkByte = code; tmpBlk.ParentFolder = blkFld; //blkFld.step5BlocksinfoList.Add(tmpBlk); //string aa = System.Text.Encoding.GetEncoding("ISO-8859-1").GetString(code); } else if (s5ProjectByteArray[pos] == 0x06) //DB - Vorkopf { len = (s5ProjectByteArray[pos + 4] * 0x100 + s5ProjectByteArray[pos + 5]) * 2; tmpBlk.BlockType = PLCBlockType.S5_DV; tmpBlk.BlockNumber = s5ProjectByteArray[pos + 1]; byte[] code = new byte[len]; Array.Copy(s5ProjectByteArray, pos, code, 0, len); tmpBlk._blkByte = code; tmpBlk.ParentFolder = blkFld; //blkFld.step5BlocksinfoList.Add(tmpBlk); } else if (s5ProjectByteArray[pos] == 0x11) //DX - Vorkopf { len = (s5ProjectByteArray[pos + 4] * 0x100 + s5ProjectByteArray[pos + 5]) * 2; tmpBlk.BlockType = PLCBlockType.S5_DVX; tmpBlk.BlockNumber = s5ProjectByteArray[pos + 1]; byte[] code = new byte[len]; Array.Copy(s5ProjectByteArray, pos, code, 0, len); tmpBlk._blkByte = code; tmpBlk.ParentFolder = blkFld; //blkFld.step5BlocksinfoList.Add(tmpBlk); } else if (s5ProjectByteArray[pos] == 0x0D) //FB - Vorkopf { len = (s5ProjectByteArray[pos + 4] * 0x100 + s5ProjectByteArray[pos + 5]) * 2; tmpBlk.BlockType = PLCBlockType.S5_FV; tmpBlk.BlockNumber = s5ProjectByteArray[pos + 1]; byte[] code = new byte[len]; Array.Copy(s5ProjectByteArray, pos, code, 0, len); tmpBlk._blkByte = code; tmpBlk.ParentFolder = blkFld; //blkFld.step5BlocksinfoList.Add(tmpBlk); } else if (s5ProjectByteArray[pos] == 0x0A) //FX - Vorkopf { len = (s5ProjectByteArray[pos + 4] * 0x100 + s5ProjectByteArray[pos + 5]) * 2; tmpBlk.BlockType = PLCBlockType.S5_FVX; tmpBlk.BlockNumber = s5ProjectByteArray[pos + 1]; byte[] code = new byte[len]; Array.Copy(s5ProjectByteArray, pos, code, 0, len); tmpBlk._blkByte = code; tmpBlk.ParentFolder = blkFld; //blkFld.step5BlocksinfoList.Add(tmpBlk); } else { //Here are the $ Blocks woch are not yet implemented! //akanz--; len = 0x80; tmpBlk = null; } if (len == 0) len = 0x80; pos += (len / 0x80) * 0x80; if (len % 0x80 != 0) pos += 0x80; return tmpBlk; }
internal override void LoadProject() { _projectLoaded = true; //Read Step5 Project into a Byte-Array Stream fsProject = _ziphelper.GetReadStream(_projectfilename); s5ProjectByteArray = new byte[_ziphelper.GetStreamLength(_projectfilename, fsProject)]; fsProject.Read(s5ProjectByteArray, 0, s5ProjectByteArray.Length); fsProject.Close(); //Read the Project Name ProjectName = System.Text.Encoding.UTF7.GetString(s5ProjectByteArray, 0x08, 8); //Read the Project Size Size = s5ProjectByteArray[0x14] + s5ProjectByteArray[0x15]*0x100; //Create the main Project Folder ProjectStructure = new Step5ProgrammFolder() {Project = this, Name = this.ToString()}; //int startpos = s5ProjectByteArray[0x12] * 0x80; int anz_sections = s5ProjectByteArray[0x16]; List<int> sections_lst = new List<int>(); for (int j = 0; j < anz_sections; j++) { int pos = 0x44 + j*19; sections_lst.Add(s5ProjectByteArray[pos + 15] + s5ProjectByteArray[pos + 16]*0x100); } Step5BlocksFolder blkFld = new Step5BlocksFolder() {Name = "Blocks", Project = this, Parent = ProjectStructure}; BlocksFolder = blkFld; ProjectStructure.SubItems.Add(blkFld); //int section_start = startpos; int n = 0; List<int> ByteAddressOFExistingBlocks = new List<int>(); foreach (int secpos in sections_lst) { int section_start = secpos*0x80; /* The len for a Section is not always calculated right, so if the Section does not begin with the filename add 0x80 until it works */ /* But I don't know why it's wrong */ /* while (System.Text.Encoding.UTF7.GetString(s5ProjectByteArray, section_start, 8) != ProjectName) { section_start += 0x80; if (section_start>=s5ProjectByteArray.Length) break; } */ if (section_start >= s5ProjectByteArray.Length) break; //if (section_start == 0x1580) //only for debbuging // section_start = section_start; //Don't know what this Byte means, maybe it describes wich Blocks are in the Section? int section_header_type = s5ProjectByteArray[section_start + 8]; int akanz = 0; int anzbst = s5ProjectByteArray[section_start + 22]; List<byte[]> bstHeaders = new List<byte[]>(); for (int j = 0; j < anzbst; j++) { byte[] tmp = new byte[15]; Array.Copy(s5ProjectByteArray, section_start + 68 + j*15, tmp, 0, 15); bstHeaders.Add(tmp); } //int section_size = ((s5ProjectByteArray[section_start + 21] * 0x100) + s5ProjectByteArray[section_start + 20]) * 0x80; //if (section_size == 0) //only for debbuging // section_size = section_size; /* int section_header_size = anzbst * 15 + 68; section_header_size = (section_header_size / 0x80) * 0x80; if ((anzbst * 15 + 68) % 0x80 != 0) section_header_size += 0x80; */ //Don't know wich Information is in the Section Header! int section_header_size = s5ProjectByteArray[section_start + 18]*0x80; //Read the Block normaly (using the Section-Headers) { //for (int n = blkstart + blkheadersize; n < blkstart + blksize /* s5ProjectByteArray.Length - 2 */; n++) n = section_start + section_header_size; //while (s5ProjectByteArray[n] == 0x00 && s5ProjectByteArray[n + 1] == 0x00) // n += 0x80; while (akanz < anzbst && n + 1 < s5ProjectByteArray.Length) //n < section_start + section_size) { akanz++; int len = 0; ByteAddressOFExistingBlocks.Add(n); var tmp = AddBlockInfo(s5ProjectByteArray, ref n, blkFld, bstHeaders[akanz - 1]); if (tmp != null) blkFld.step5BlocksinfoList.Add(tmp); /* if (s5ProjectByteArray[n] == 0x70 && s5ProjectByteArray[n + 1] == 0x70) //Step5 Block // && s5ProjectByteArray[n - 1] == 0x00) { len = (s5ProjectByteArray[n + 8] * 0x100 + s5ProjectByteArray[n + 9]) * 2; Step5ProjectBlockInfo tmpBlk = new Step5ProjectBlockInfo(); //S5Block tmpBlk = new S5Block(); //if (((IList<int>)Enum.GetValues(typeof(PLCBlockType))).Contains((s5ProjectByteArray[n + 2] | 0xf00))) //only for debbuging tmpBlk.BlockType = (PLCBlockType)(s5ProjectByteArray[n + 2] | 0xf00); //else // tt_nr = tt_nr; tmpBlk.BlockNumber = s5ProjectByteArray[n + 3]; tmpBlk._blkHeaderByte = bstHeaders[akanz - 1]; //byte n+4 -> kennungen für das programiergerät //byte n+5,6,7 -> bib nummer byte[] code = new byte[len]; Array.Copy(s5ProjectByteArray, n, code, 0, len); tmpBlk._blkByte = code; tmpBlk.ParentFolder = blkFld; blkFld.step5BlocksinfoList.Add(tmpBlk); //string aa = System.Text.Encoding.GetEncoding("ISO-8859-1").GetString(code); } else if (s5ProjectByteArray[n] == 0x06) //DB - Vorkopf { len = (s5ProjectByteArray[n + 4] * 0x100 + s5ProjectByteArray[n + 5]) * 2; Step5ProjectBlockInfo tmpBlk = new Step5ProjectBlockInfo(); //S5Block tmpBlk = new S5Block(); tmpBlk.BlockType = PLCBlockType.S5_DV; tmpBlk.BlockNumber = s5ProjectByteArray[n + 1]; byte[] code = new byte[len]; Array.Copy(s5ProjectByteArray, n, code, 0, len); tmpBlk._blkByte = code; tmpBlk.ParentFolder = blkFld; blkFld.step5BlocksinfoList.Add(tmpBlk); } else if (s5ProjectByteArray[n] == 0x11) //DX - Vorkopf { len = (s5ProjectByteArray[n + 4] * 0x100 + s5ProjectByteArray[n + 5]) * 2; Step5ProjectBlockInfo tmpBlk = new Step5ProjectBlockInfo(); //S5Block tmpBlk = new S5Block(); tmpBlk.BlockType = PLCBlockType.S5_DVX; tmpBlk.BlockNumber = s5ProjectByteArray[n + 1]; byte[] code = new byte[len]; Array.Copy(s5ProjectByteArray, n, code, 0, len); tmpBlk._blkByte = code; tmpBlk.ParentFolder = blkFld; blkFld.step5BlocksinfoList.Add(tmpBlk); } else if (s5ProjectByteArray[n] == 0x0D) //FB - Vorkopf { len = (s5ProjectByteArray[n + 4] * 0x100 + s5ProjectByteArray[n + 5]) * 2; Step5ProjectBlockInfo tmpBlk = new Step5ProjectBlockInfo(); //S5Block tmpBlk = new S5Block(); tmpBlk.BlockType = PLCBlockType.S5_FV; tmpBlk.BlockNumber = s5ProjectByteArray[n + 1]; byte[] code = new byte[len]; Array.Copy(s5ProjectByteArray, n, code, 0, len); tmpBlk._blkByte = code; tmpBlk.ParentFolder = blkFld; blkFld.step5BlocksinfoList.Add(tmpBlk); } else if (s5ProjectByteArray[n] == 0x0A) //FX - Vorkopf { len = (s5ProjectByteArray[n + 4] * 0x100 + s5ProjectByteArray[n + 5]) * 2; Step5ProjectBlockInfo tmpBlk = new Step5ProjectBlockInfo(); //S5Block tmpBlk = new S5Block(); tmpBlk.BlockType = PLCBlockType.S5_FVX; tmpBlk.BlockNumber = s5ProjectByteArray[n + 1]; byte[] code = new byte[len]; Array.Copy(s5ProjectByteArray, n, code, 0, len); tmpBlk._blkByte = code; tmpBlk.ParentFolder = blkFld; blkFld.step5BlocksinfoList.Add(tmpBlk); } else { //Here are the $ Blocks woch are not yet implemented! //akanz--; len = 0x80; } n += (len / 0x80) * 0x80; if (len % 0x80 != 0) n += 0x80; */ } } section_start = n; //section_start += section_size; } if (_showDeleted) { //Read also the deleted Blocks, that means, don't use the Section Headers ... int akpos = s5ProjectByteArray[0x12]*0x80; while (akpos <= s5ProjectByteArray.Length - 0x80) { while (!IsCurrentPosABlockStart(s5ProjectByteArray, akpos) && akpos <= s5ProjectByteArray.Length - 0x80) akpos += 0x80; if (akpos <= s5ProjectByteArray.Length - 0x80) { bool blkExists = ByteAddressOFExistingBlocks.Contains(akpos); var tmp=AddBlockInfo(s5ProjectByteArray, ref akpos, blkFld, null); if (!blkExists) { tmp.Deleted = true; blkFld.step5BlocksinfoList.Add(tmp); } } } } if (_ziphelper.FileExists(_projectfilename.ToLower().Replace("st.s5d", "z0.seq"))) { Stream symTabStream = _ziphelper.GetReadStream(_projectfilename.ToLower().Replace("st.s5d", "z0.seq")); SymbolTable symtab=new SymbolTable(); symtab.LoadSymboltable(symTabStream); symTabStream.Close(); symtab.Parent = ProjectStructure; symtab.Project = this; ProjectStructure.SubItems.Add(symtab); } ProjectStructure.SubItems.Add(new ReferenceData((Step5ProgrammFolder)ProjectStructure, this)); // { Parent = ProjectStructure, Project = this }); }
private void LoadReferenceData() { ReferenceDataLoaded = false; Step5ProgrammFolder prgFld = (Step5ProgrammFolder)this.Parent; Step5BlocksFolder blkFld = (Step5BlocksFolder)prgFld.BlocksFolder; SymbolTable smyTab = (SymbolTable)prgFld.SymbolTable; //try { foreach (ProjectBlockInfo projectBlockInfo in blkFld.readPlcBlocksList()) { if (projectBlockInfo.BlockType == PLCBlockType.S5_PB || projectBlockInfo.BlockType == PLCBlockType.S5_FB || projectBlockInfo.BlockType == PLCBlockType.S5_FX || projectBlockInfo.BlockType == PLCBlockType.S5_OB || projectBlockInfo.BlockType == PLCBlockType.S5_SB) { S5FunctionBlock blk = (S5FunctionBlock)projectBlockInfo.GetBlock(); int networkNR = 0; foreach (Blocks.Network network in blk.Networks) { int rowNR = 0; networkNR++; string akdb = ""; foreach (S5FunctionBlockRow functionBlockRow in network.AWLCode) { if (!string.IsNullOrEmpty(functionBlockRow.Label)) { akdb = ""; } if (functionBlockRow.Command == "A" || functionBlockRow.Command == "AX") { if (functionBlockRow.Parameter == "DB 0" || functionBlockRow.Parameter == "DX 0") { akdb = ""; } else { akdb = functionBlockRow.Parameter; } } rowNR++; if (functionBlockRow.MC5LIB_SYMTAB_Row != null && ((ReferenceDataAccessMode)functionBlockRow.MC5LIB_SYMTAB_Row[9]) != ReferenceDataAccessMode.None) { //Normal reference... string operand = functionBlockRow.Parameter; if (operand == "DB 0") { operand = "DB ??"; } ReferenceDataEntry entr; operandIndexList.TryGetValue(operand, out entr); if (entr == null) { SymbolTableEntry symb = null; if (smyTab != null) { symb = smyTab.GetEntryFromOperand(operand); } entr = new ReferenceDataEntry() { Operand = operand, SymbolTableEntry = symb }; operandIndexList.Add(operand, entr); _ReferenceDataEntrys.Add(entr); } entr.ReferencePoints.Add(new ReferencePoint() { Block = blk, Network = network, NetworkNumber = networkNR, LineNumber = rowNR, BlockRow = functionBlockRow, AccessMode = (ReferenceDataAccessMode)functionBlockRow.MC5LIB_SYMTAB_Row[9] }); //Reference to DB if (akdb != "") { if (functionBlockRow.Parameter.StartsWith("D ") || functionBlockRow.Parameter.StartsWith("DW") || functionBlockRow.Parameter.StartsWith("DL") || functionBlockRow.Parameter.StartsWith("DR") || functionBlockRow.Parameter.StartsWith("DX")) { //Normal reference... operand = akdb + "." + functionBlockRow.Parameter; entr = null; operandIndexList.TryGetValue(operand, out entr); if (entr == null) { SymbolTableEntry symb = null; if (smyTab != null) { symb = smyTab.GetEntryFromOperand(operand); } entr = new ReferenceDataEntry() { Operand = operand, SymbolTableEntry = symb }; operandIndexList.Add(operand, entr); _ReferenceDataEntrys.Add(entr); } entr.ReferencePoints.Add(new ReferencePoint() { Block = blk, Network = network, NetworkNumber = networkNR, LineNumber = rowNR, BlockRow = functionBlockRow, AccessMode = (ReferenceDataAccessMode)functionBlockRow.MC5LIB_SYMTAB_Row[9] }); } } } } } } } } /*catch (Exception ex) * { * MessageBox.Show("There was an error generating the Reference Data! Maybe the Step5 project is broken? \n" + ex.Message); * }*/ ReferenceDataLoaded = true; }