private SymbolTable _GetSymTabForProject(S7ProgrammFolder myBlockFolder, bool showDeleted)
        {
            string tmpId1 = "";

            var retVal = new SymbolTable() { Project = this };

            int tmpId2 = 0;

            //Look in Sym-LinkList for ID
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "YDBs" + _DirSeperator + "YLNKLIST.DBF", _ziphelper, _DirSeperator);
                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool) row["DELETED_FLAG"])
                    {
                        if ((int) row["TOI"] == myBlockFolder.ID)
                        {
                            tmpId2 = (int) row["SOI"];
                            break;
                        }
                    }
                }

                if (tmpId2 == 0 && showDeleted)
                    foreach (DataRow row in dbfTbl.Rows)
                    {
                        if ((int) row["TOI"] == myBlockFolder.ID)
                        {
                            tmpId2 = (int) row["SOI"];
                            retVal.Folder = ProjectFolder + "YDBs" + _DirSeperator + tmpId2.ToString() + _DirSeperator;
                            break;
                        }
                    }
            }

            //Look fro Symlist Name
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "YDBs" + _DirSeperator + "SYMLISTS.DBF", _ziphelper, _DirSeperator);
                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"] || showDeleted)
                    {
                        if ((int)row["_ID"] == tmpId2)
                        {
                            retVal.Name = (string)row["_UName"];
                            if ((bool)row["DELETED_FLAG"]) retVal.Name = "$$_" + retVal.Name;
                            break;
                        }
                    }
                }
            }

            if (string.IsNullOrEmpty(retVal.Name) && !File.Exists(ProjectFolder + "YDBs" + _DirSeperator + tmpId2.ToString() + _DirSeperator + "SYMLIST.DBF"))
                return null;

            retVal.showDeleted = showDeleted;
            if (tmpId2 != 0)
                retVal.Folder = ProjectFolder + "YDBs" + _DirSeperator + tmpId2.ToString() + _DirSeperator;

            return retVal;
        }
        /// <summary>
        /// Reads an Block from the Project and returns the block data that is stored in the S7 Project
        /// </summary>
        /// <param name="blkInfo">The Block info object that identifies the block to read from Disk</param>
        /// <param name="myConvOpt">Defines options that determine how the Block will be converted</param>
        /// <returns></returns>
        public Block GetBlock(ProjectBlockInfo blkInfo, S7ConvertingOptions myConvOpt)
        {
            if (blkInfo._Block != null && ((blkInfo._Block) as S7Block).usedS7ConvertingOptions.Equals(myConvOpt))
            {
                return(blkInfo._Block);
            }


            ProjectPlcBlockInfo plcblkifo = (ProjectPlcBlockInfo)blkInfo;
            tmpBlock            myTmpBlk  = GetBlockBytes(blkInfo);

            List <Step7Attribute> step7Attributes = null;

            if (myTmpBlk != null)
            {
                if (myTmpBlk.uda != null)
                {
                    int uPos = 2;
                    if (myTmpBlk.uda != null && myTmpBlk.uda.Length > 0 && myTmpBlk.uda[0] > 0)
                    {
                        step7Attributes = new List <Step7Attribute>();
                        for (int j = 0; j < myTmpBlk.uda[0]; j++)
                        {
                            string t1 = Project.ProjectEncoding.GetString(myTmpBlk.uda, uPos + 1, myTmpBlk.uda[uPos]);
                            uPos += myTmpBlk.uda[uPos] + 1;
                            string t2 = Project.ProjectEncoding.GetString(myTmpBlk.uda, uPos + 1, myTmpBlk.uda[uPos]);
                            uPos += myTmpBlk.uda[uPos] + 1;
                            step7Attributes.Add(new Step7Attribute(t1, t2));
                        }
                    }
                }

                //Begin with the Block Reading...
                if (blkInfo.BlockType == PLCBlockType.VAT)
                {
                    S7VATBlock retValBlock = new S7VATBlock(myTmpBlk.mc7code, myTmpBlk.comments, plcblkifo.BlockNumber, Project.ProjectEncoding);
                    retValBlock.Attributes = step7Attributes;

                    retValBlock.LastCodeChange      = myTmpBlk.LastCodeChange;
                    retValBlock.LastInterfaceChange = myTmpBlk.LastInterfaceChange;

                    retValBlock.ParentFolder            = this;
                    retValBlock.usedS7ConvertingOptions = myConvOpt;
                    blkInfo._Block = retValBlock;

                    return(retValBlock);
                }
                else if (blkInfo.BlockType == PLCBlockType.DB || blkInfo.BlockType == PLCBlockType.UDT)
                {
                    List <string> tmpList = new List <string>();
                    S7DataBlock   retVal  = new S7DataBlock();
                    retVal.IsInstanceDB = myTmpBlk.IsInstanceDB;
                    retVal.FBNumber     = myTmpBlk.FBNumber;

                    //if this is an interface DB, then rather take the Interface declaration from the instance FB,
                    //instead of the data sotred in the project.
                    //The reason is that if you change the comment in an FB, the DB data is not actualized and my contain outdated
                    //Declarations. When you change the interface, Step7 tells you to "regenerate" the instance DB which only then would
                    //Actualize the comments. Simple Commentary changes do not change the Datablocks row.
                    if (retVal.IsInstanceDB && myConvOpt.UseFBDeclarationForInstanceDB)
                    {
                        //load the FB data from the Project
                        tmpBlock InstFB = GetBlockBytes((myTmpBlk.IsSFB ? "SFB" : "FB") + myTmpBlk.FBNumber);

                        //Resolve both interfaces
                        List <string> tmpPar = new List <string>();
                        if (InstFB != null)
                        {
                            S7DataRow InterfaceFB =
                                Parameter.GetInterfaceOrDBFromStep7ProjectString(InstFB.blkinterface, ref tmpPar,
                                                                                 PLCBlockType.FB, false, this, null);
                            S7DataRow InterfaceDB =
                                Parameter.GetInterfaceOrDBFromStep7ProjectString(myTmpBlk.blkinterface, ref tmpPar,
                                                                                 PLCBlockType.DB, false, this, null);

                            //Only use the FB interface Declaration if they are compatible
                            if (Parameter.IsInterfaceCompatible(InterfaceFB, InterfaceDB))
                            {
                                myTmpBlk.blkinterface = InstFB.blkinterface;
                            }
                        }
                    }

                    if (myTmpBlk.mc7code != null)
                    {
                        retVal.CodeSize = myTmpBlk.mc7code.Length;
                    }

                    retVal.StructureFromString = Parameter.GetInterfaceOrDBFromStep7ProjectString(myTmpBlk.blkinterface, ref tmpList, blkInfo.BlockType, false, this, retVal, myTmpBlk.mc7code);
                    if (myTmpBlk.blkinterfaceInMC5 != null)
                    {
                        //List<string> tmp = new List<string>();
                        //retVal.StructureFromMC7 = Parameter.GetInterface(myTmpBlk.blkinterfaceInMC5, myTmpBlk.mc7code, ref tmp, blkInfo.BlockType, myTmpBlk.IsInstanceDB, retVal);
                    }
                    retVal.BlockNumber = plcblkifo.BlockNumber;
                    retVal.BlockType   = blkInfo.BlockType;
                    retVal.Attributes  = step7Attributes;

                    retVal.LastCodeChange      = myTmpBlk.LastCodeChange;
                    retVal.LastInterfaceChange = myTmpBlk.LastInterfaceChange;

                    retVal.ParentFolder            = this;
                    retVal.usedS7ConvertingOptions = myConvOpt;
                    retVal.CheckSum = myTmpBlk.CheckSum;
                    blkInfo._Block  = retVal;

                    return(retVal);
                }
                else if (blkInfo.BlockType == PLCBlockType.FC || blkInfo.BlockType == PLCBlockType.FB || blkInfo.BlockType == PLCBlockType.OB || blkInfo.BlockType == PLCBlockType.SFB || blkInfo.BlockType == PLCBlockType.SFC)
                {
                    List <string> ParaList = new List <string>();

                    S7FunctionBlock retVal = new S7FunctionBlock();

                    retVal.LastCodeChange      = myTmpBlk.LastCodeChange;
                    retVal.LastInterfaceChange = myTmpBlk.LastInterfaceChange;

                    retVal.BlockNumber       = plcblkifo.BlockNumber;
                    retVal.BlockType         = blkInfo.BlockType;
                    retVal.Attributes        = step7Attributes;
                    retVal.KnowHowProtection = myTmpBlk.knowHowProtection;
                    retVal.MnemonicLanguage  = Project.ProjectLanguage;

                    retVal.Author  = myTmpBlk.username;
                    retVal.Version = myTmpBlk.version;

                    retVal.Parameter = Parameter.GetInterfaceOrDBFromStep7ProjectString(myTmpBlk.blkinterface, ref ParaList, blkInfo.BlockType, false, this, retVal);

                    if (myTmpBlk.blockdescription != null)
                    {
                        retVal.Title       = Project.ProjectEncoding.GetString(myTmpBlk.blockdescription, 3, myTmpBlk.blockdescription[1] - 4);
                        retVal.Description = Project.ProjectEncoding.GetString(myTmpBlk.blockdescription, myTmpBlk.blockdescription[1], myTmpBlk.blockdescription.Length - myTmpBlk.blockdescription[1] - 1).Replace("\n", Environment.NewLine);
                    }

                    if (blkInfo.BlockType == PLCBlockType.FC || blkInfo.BlockType == PLCBlockType.FB || blkInfo.BlockType == PLCBlockType.OB)
                    {
                        retVal.CodeSize = myTmpBlk.mc7code.Length;

                        int[] Networks;
                        Networks = NetWork.GetNetworks(0, myTmpBlk.nwinfo);

                        S7ProgrammFolder prgFld = null;
                        if (this.Parent is S7ProgrammFolder)
                        {
                            prgFld = (S7ProgrammFolder)this.Parent;
                        }

                        retVal.AWLCode = MC7toAWL.GetAWL(0, myTmpBlk.mc7code.Length - 2, (int)myConvOpt.Mnemonic, myTmpBlk.mc7code, Networks, ParaList, prgFld, retVal, retVal.Parameter);

                        retVal.AWLCode = JumpMarks.AddJumpmarks(retVal.AWLCode, myTmpBlk.jumpmarks, myTmpBlk.nwinfo, myConvOpt);

                        LocalDataConverter.ConvertLocaldataToSymbols(retVal, myConvOpt);

                        CallConverter.ConvertUCToCall(retVal, prgFld, this, myConvOpt, null);

                        FBStaticAccessConverter.ReplaceStaticAccess(retVal, prgFld, myConvOpt);

                        #region UseComments from Block
                        if (myConvOpt.UseComments)
                        {
                            List <FunctionBlockRow> newAwlCode = new List <FunctionBlockRow>();

                            int n = 0;
                            int akRowInAwlCode   = 0;
                            int lineNumberInCall = 0; //Counter wich line in Command (for Calls and UCs)

                            if (myTmpBlk.comments != null)
                            {
                                byte[] cmt = myTmpBlk.comments;

                                //string aa = System.Text.Encoding.GetEncoding("Windows-1251").GetString(cmt);
                                //string testaa = "";

                                while (n < myTmpBlk.comments.Length)
                                {
                                    int kommLen            = cmt[n + 0];
                                    int startNWKomm        = cmt[n + 1];
                                    int anzUebsprungZeilen = cmt[n + 2] + cmt[n + 3] * 0x100;
                                    int lenNWKommZeile     = cmt[n + 3] + cmt[n + 4] * 0x100;
                                    //Console.WriteLine(cmt[n + 5].ToString("X"));
                                    if (cmt[n + 5] == 0x06)
                                    {
                                        //NWKomentar:
                                        string tx1 = Project.ProjectEncoding.GetString(cmt, n + 6, startNWKomm - 7);
                                        string tx2 = Project.ProjectEncoding.GetString(cmt, n + startNWKomm, lenNWKommZeile - startNWKomm - 1).Replace("\n", Environment.NewLine);
                                        n += lenNWKommZeile;

                                        if (retVal.AWLCode.Count > akRowInAwlCode)
                                        {
                                            while (retVal.AWLCode.Count - 1 > akRowInAwlCode && retVal.AWLCode[akRowInAwlCode].Command != "NETWORK")
                                            {
                                                if (!newAwlCode.Contains(retVal.AWLCode[akRowInAwlCode]))
                                                {
                                                    //newAwlCode.Add(retVal.AWLCode[akRowInAwlCode]);
                                                    S7FunctionBlockRow akRw = (S7FunctionBlockRow)retVal.AWLCode[akRowInAwlCode];

                                                    if (akRw.CombineDBAccess)
                                                    {
                                                        S7FunctionBlockRow nRw = (S7FunctionBlockRow)retVal.AWLCode[akRowInAwlCode + 1];
                                                        if (!nRw.Parameter.Contains("["))
                                                        {
                                                            nRw.Parameter = akRw.Parameter + "." + nRw.Parameter;
                                                            nRw.MC7       = Helper.CombineByteArray(akRw.MC7, nRw.MC7);
                                                            nRw.Label     = akRw.Label ?? nRw.Label;
                                                            akRw          = nRw;
                                                            retVal.AWLCode.RemoveAt(akRowInAwlCode + 1);
                                                        }
                                                    }

                                                    if (!newAwlCode.Contains(akRw))
                                                    {
                                                        newAwlCode.Add(akRw);
                                                    }
                                                }
                                                akRowInAwlCode++;
                                            }
                                            ((S7FunctionBlockRow)retVal.AWLCode[akRowInAwlCode]).NetworkName = tx1;
                                            ((S7FunctionBlockRow)retVal.AWLCode[akRowInAwlCode]).Comment     = tx2;
                                            newAwlCode.Add(retVal.AWLCode[akRowInAwlCode]);
                                        }
                                        akRowInAwlCode++;

                                        lineNumberInCall = 0;
                                    }
                                    else
                                    {
                                        S7FunctionBlockRow lastRow = null;

                                        //Anzahl der Anweisungen vor diesem Kommentar (inklusive aktueller Zeile!)
                                        for (int q = 0; q < (anzUebsprungZeilen); q++)
                                        {
                                            if (retVal.AWLCode.Count > akRowInAwlCode)
                                            {
                                                S7FunctionBlockRow akRw = (S7FunctionBlockRow)retVal.AWLCode[akRowInAwlCode];

                                                if (cmt[n + 4] == 0xc0 && q == anzUebsprungZeilen - 1)
                                                {
                                                    akRw.CombineDBAccess = false;
                                                }

                                                //Db Zugriff zusammenfügen...
                                                if (akRw.CombineDBAccess)
                                                {
                                                    S7FunctionBlockRow nRw = (S7FunctionBlockRow)retVal.AWLCode[akRowInAwlCode + 1];
                                                    nRw.Parameter = akRw.Parameter + "." + nRw.Parameter;
                                                    nRw.MC7       = Helper.CombineByteArray(akRw.MC7, nRw.MC7);
                                                    nRw.Label     = akRw.Label ?? nRw.Label;
                                                    akRw          = nRw;
                                                    retVal.AWLCode.RemoveAt(akRowInAwlCode + 1);
                                                }

                                                if (!newAwlCode.Contains(akRw))
                                                {
                                                    newAwlCode.Add(akRw);
                                                }


                                                if (akRw.GetNumberOfLines() == 1)
                                                {
                                                    lineNumberInCall = 0;

                                                    lastRow = akRw;

                                                    //if (!newAwlCode.Contains(akRw))
                                                    //    newAwlCode.Add(akRw);

                                                    akRowInAwlCode++;
                                                }
                                                else
                                                {
                                                    lastRow = akRw;
                                                    if (lineNumberInCall == 0 && !(cmt[n + 4] != 0x80 && cmt[n + 4] != 0xc0))
                                                    {
                                                        //if (!newAwlCode.Contains(akRw))
                                                        //    newAwlCode.Add(akRw);
                                                    }

                                                    if (akRw.GetNumberOfLines() - 1 == lineNumberInCall)
                                                    {
                                                        akRowInAwlCode++;
                                                        lineNumberInCall = 0;
                                                        //subCnt++;    //The set to zero was wrong here, but maybe now comments on calls do not work, need to check!
                                                    }
                                                    else
                                                    {
                                                        lineNumberInCall++;
                                                    }
                                                }
                                            }
                                        }


                                        //if (lastRow == null || cmt[n + 4] != 0x80)
                                        if (lastRow == null || (cmt[n + 4] != 0x80 && cmt[n + 4] != 0xc0))
                                        {
                                            lastRow = new S7FunctionBlockRow()
                                            {
                                                Parent = retVal
                                            };
                                            newAwlCode.Add(lastRow);
                                            lineNumberInCall = 0;
                                        }

                                        string tx1 = Project.ProjectEncoding.GetString(cmt, n + 6, kommLen);
                                        if (lineNumberInCall == 0)
                                        {
                                            lastRow.Comment = tx1;
                                        }
                                        else
                                        if (lastRow.Command == "CALL")
                                        {
                                            if (lineNumberInCall == 1)
                                            {
                                                lastRow.Comment = tx1;
                                            }
                                            else
                                            {
                                                if (lastRow.CallParameter.Count >= lineNumberInCall - 2)
                                                {
                                                    lastRow.CallParameter[lineNumberInCall - 2].Comment = tx1;
                                                }
                                            }
                                        }
                                        n += kommLen + 6;

                                        //subCnt = 0;
                                    }
                                }
                            }
                            while (akRowInAwlCode < retVal.AWLCode.Count)
                            {
                                newAwlCode.Add(retVal.AWLCode[akRowInAwlCode]);
                                akRowInAwlCode++;
                            }
                            retVal.AWLCode = newAwlCode;
                        }
                        #endregion
                    }

                    retVal.Networks = NetWork.GetNetworksList(retVal);

                    retVal.ParentFolder            = this;
                    retVal.usedS7ConvertingOptions = myConvOpt;
                    retVal.CheckSum = myTmpBlk.CheckSum;
                    blkInfo._Block  = retVal;

                    return(retVal);
                }
            }
            return(null);
        }
 private void Button_Click_2(object sender, RoutedEventArgs e)
 {
     myblkFld = SelectProjectPart.SelectS7ProgrammFolder();
 }
        internal override void LoadProject()
        {
            _projectLoaded = true;

            ProjectStructure = new Step7ProjectFolder() {Project = this};
            CPUFolders = new List<CPUFolder>();
            CPFolders=new List<CPFolder>();
            S7ProgrammFolders = new List<S7ProgrammFolder>();
            BlocksOfflineFolders = new List<BlocksOfflineFolder>();

            ProjectStructure.Name = this.ToString();

            //Get The Project Stations...
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hstatx" + _DirSeperator + "HOBJECT1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hstatx" + _DirSeperator + "HOBJECT1.DBF", _ziphelper, _DirSeperator);
                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                    {
                        if ((int)row["OBJTYP"] == 1314969 || (int)row["OBJTYP"] == 1314970 || (int)row["OBJTYP"] == 1315650)
                        {
                            var x = new StationConfigurationFolder() { Project = this, Parent = ProjectStructure};
                            x.Name = ((string)row["Name"]).Replace("\0", "");
                            if ((bool) row["DELETED_FLAG"]) x.Name = "$$_" + x.Name;
                            x.ID = (int) row["ID"];
                            x.UnitID = (int)row["UNITID"];
                            switch ((int)row["OBJTYP"])
                            {
                                case 1314969:
                                    x.StationType = PLCType.Simatic300;
                                    break;
                                case 1314970:
                                    x.StationType = PLCType.Simatic400;
                                    break;
                                case 1315650:
                                    x.StationType = PLCType.Simatic400H;
                                    break;
                            }
                            x.Parent = ProjectStructure;
                            ProjectStructure.SubItems.Add(x);
                        }
                    }
                }
            }

            //Get The CP Folders
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7wb53ax" + _DirSeperator + "HRELATI1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7wb53ax" + _DirSeperator + "HRELATI1.DBF", _ziphelper, _DirSeperator);
                foreach (var y in ProjectStructure.SubItems)
                {
                    if (y.GetType() == typeof(StationConfigurationFolder))
                    {
                        var z = (StationConfigurationFolder)y;
                        foreach (DataRow row in dbfTbl.Rows)
                        {
                            if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                            {
                                if ((int)row["TUNITID"] == z.ID &&
                                    ((int)row["TUNITTYP"] == 1314969 || (int)row["TUNITTYP"] == 1314970 || (int)row["TUNITTYP"] == 1315650))//as in "Get The Project Stations"
                                {
                                    var x = new CPFolder() {Project = this};
                                    x.UnitID = Convert.ToInt32(row["TUNITID"]);
                                    x.TobjTyp = Convert.ToInt32(row["TOBJTYP"]);
                                    x.ID = Convert.ToInt32(row["SOBJID"]);
                                    x.Parent = z;
                                    z.SubItems.Add(x);
                                    CPFolders.Add(x);

                                }
                            }
                        }
                    }
                }
            }

            //Get The CPU 300 Folders
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk31ax" + _DirSeperator + "HRELATI1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk31ax" + _DirSeperator + "HRELATI1.DBF", _ziphelper, _DirSeperator);
                foreach (var y in ProjectStructure.SubItems)
                {
                    if (y.GetType() == typeof(StationConfigurationFolder))
                    {
                        var z = (StationConfigurationFolder)y;
                        foreach (DataRow row in dbfTbl.Rows)
                        {
                            if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                            {
                                if ((int)row["TUNITID"] == z.ID && (int)row["TOBJTYP"] == 1314972)
                                   //((int)row["TUNITTYP"] == 1314969 || (int)row["TUNITTYP"] == 1314969 || (int)row["TUNITTYP"] == 1314969))
                                {
                                    var x = new CPUFolder() {Project = this};
                                    x.UnitID = Convert.ToInt32(row["TUNITID"]);
                                    x.TobjTyp = Convert.ToInt32(row["TOBJTYP"]);
                                    x.CpuType = z.StationType;
                                    x.ID = Convert.ToInt32(row["SOBJID"]);
                                    x.Parent = z;
                                    z.SubItems.Add(x);
                                    CPUFolders.Add(x);
                                }
                            }
                        }
                    }
                }
            }

            //Get The CPU 300 ET200s Folders
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hkcomx" + _DirSeperator + "HRELATI1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hkcomx" + _DirSeperator + "HRELATI1.DBF", _ziphelper, _DirSeperator);
                foreach (var y in ProjectStructure.SubItems)
                {
                    if (y.GetType() == typeof(StationConfigurationFolder))
                    {
                        var z = (StationConfigurationFolder)y;
                        foreach (DataRow row in dbfTbl.Rows)
                        {
                            if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                            {
                                if ((int)row["TUNITID"] == z.ID && (int)row["TOBJTYP"] == 1314972)
                                //((int)row["TUNITTYP"] == 1314969 || (int)row["TUNITTYP"] == 1314969 || (int)row["TUNITTYP"] == 1314969))
                                {
                                    var x = new CPUFolder() { Project = this };
                                    x.UnitID = Convert.ToInt32(row["TUNITID"]);
                                    x.TobjTyp = Convert.ToInt32(row["TOBJTYP"]);
                                    x.CpuType = z.StationType;
                                    x.ID = Convert.ToInt32(row["SOBJID"]);
                                    x.CpuType = PLCType.SimaticET200;
                                    x.Parent = z;
                                    z.SubItems.Add(x);
                                    CPUFolders.Add(x);
                                }
                            }
                        }
                    }
                }
            }
            //Get The CPU 400 Folders
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk41ax" + _DirSeperator + "HRELATI1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk41ax" + _DirSeperator + "HRELATI1.DBF", _ziphelper, _DirSeperator);

                foreach (var y in ProjectStructure.SubItems)
                {
                    if (y.GetType() == typeof(StationConfigurationFolder))
                    {
                        var z = (StationConfigurationFolder)y;
                        foreach (DataRow row in dbfTbl.Rows)
                        {
                            if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                            {
                                if ((int)row["TUNITID"] == z.ID && ((int)row["TOBJTYP"] == 1314972 || (int)row["TOBJTYP"] == 1315656 /* BackupCPU bei H Sys */))
                                   //((int)row["TUNITTYP"] == 1314969 || (int)row["TUNITTYP"] == 1314969 || (int)row["TUNITTYP"] == 1314969))
                                {
                                    var x = new CPUFolder() { Project = this };
                                    x.UnitID = Convert.ToInt32(row["TUNITID"]);
                                    x.TobjTyp = Convert.ToInt32(row["TOBJTYP"]);
                                    x.CpuType = z.StationType;
                                    x.ID = Convert.ToInt32(row["SOBJID"]);
                                    x.Parent = z;
                                    z.SubItems.Add(x);
                                    CPUFolders.Add(x);
                                }
                            }
                        }
                    }
                }
            }

            /*
            //Get The HW Folder for the Station...
            if (ZipHelper.FileExists(_zipfile,ProjectFolder + "hOmSave7" + _DirSeperator + "s7hstatx" + _DirSeperator + "HRELATI1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hstatx" + _DirSeperator + "HRELATI1.DBF", _zipfile, _DirSeperator);
                foreach (var y in Step7ProjectStructure.SubItems)
                {
                    if (y.GetType() == typeof (StationConfigurationFolder))
                    {
                        var z = (StationConfigurationFolder) y;
                        foreach (DataRow row in dbfTbl.Rows)
                        {
                            if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                            {
                                if ((int)row["SOBJID"] == z.ID && (int)row["RELID"] == 1315838)
                                {
                                    var x = new CPUFolder() {Project = this};
                                    x.UnitID = Convert.ToInt32(row["TUNITID"]);
                                    x.TobjTyp = Convert.ToInt32(row["TOBJTYP"]);
                                    x.CpuType = z.StationType;
                                    bool add = true;
                                    foreach (Step7ProjectFolder tmp in z.SubItems)
                                    {
                                        if (tmp.GetType() == typeof (CPUFolder) && ((CPUFolder) tmp).UnitID == x.UnitID)
                                            add = false;
                                    }
                                    if (add)
                                    {
                                        x.Parent = z;
                                        z.SubItems.Add(x);
                                        CPUFolders.Add(x);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            */

            //Get The CPU(ET200S)...
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hkcomx" + _DirSeperator + "HOBJECT1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hkcomx" + _DirSeperator + "HOBJECT1.DBF", _ziphelper, _DirSeperator);

                foreach (var y in CPUFolders)
                {
                    foreach (DataRow row in dbfTbl.Rows)
                    {
                        if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                        {
                            if ((int)row["ID"] == y.ID && y.CpuType == PLCType.SimaticET200)
                            //if ((int)row["UNITID"] == y.UnitID && y.CpuType == PLCType.SimaticET200)
                            {
                                y.Name = ((string)row["Name"]).Replace("\0", "");
                                if ((bool)row["DELETED_FLAG"]) y.Name = "$$_" + y.Name;
                                y.ID = (int)row["ID"];
                            }
                        }
                    }
                }
            }

            //Get The CPU(300)...
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk31ax" + _DirSeperator + "HOBJECT1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk31ax" + _DirSeperator + "HOBJECT1.DBF", _ziphelper, _DirSeperator);

                foreach (var y in CPUFolders)
                {
                    foreach (DataRow row in dbfTbl.Rows)
                    {
                        if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                        {
                            if ((int)row["ID"] == y.ID && y.CpuType == PLCType.Simatic300)
                            //if ((int)row["UNITID"] == y.UnitID && y.CpuType == PLCType.Simatic300)
                            {
                                y.Name = ((string)row["Name"]).Replace("\0", "");
                                if ((bool)row["DELETED_FLAG"]) y.Name = "$$_" + y.Name;
                                y.ID = (int)row["ID"];
                            }
                        }
                    }
                }
            }

            //Get The CPU(300) password
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk31ax" + _DirSeperator + "HATTRME1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk31ax" + _DirSeperator + "HATTRME1.DBF", _ziphelper, _DirSeperator);
                byte[] memoarray = null;

                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"])
                    {
                        if ((int)row["ATTRIIDM"] == 111142)
                        {
                            if (row["MEMOARRAYM"] != DBNull.Value)
                                memoarray = (byte[])row["MEMOARRAYM"];

                            if (memoarray.Length >= 12)
                            {
                                // memoarray[3] : level password (1-3)
                                byte[] mempass = new byte[8];
                                for (int i = 0; i < 8; i++)
                                {
                                    if (i < 2) mempass[i] = (byte) (memoarray[i + 4] ^ 0xAA);
                                    else mempass[i] = (byte) (memoarray[i + 2] ^ memoarray[i + 4] ^ 0xAA);
                                }
                                string res = ProjectEncoding.GetString(mempass);
                                foreach (var y in CPUFolders)
                                {
                                    if ((int) row["IDM"] == y.ID)
                                    {
                                        y.PasswdHard = res.Trim();
                                    }
                                }
                            }
                        }
                    }
                }
            }

            //Get The CPU(400)...
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk41ax" + _DirSeperator + "HOBJECT1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk41ax" + _DirSeperator + "HOBJECT1.DBF", _ziphelper, _DirSeperator);

                foreach (var y in CPUFolders)
                {
                    foreach (DataRow row in dbfTbl.Rows)
                    {
                        if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                        {
                            if ((int)row["ID"] == y.ID && (y.CpuType == PLCType.Simatic400 || y.CpuType == PLCType.Simatic400H))
                            //if ((int)row["UNITID"] == y.UnitID && (y.CpuType == PLCType.Simatic400 || y.CpuType == PLCType.Simatic400H) )
                            {
                                y.Name = ((string)row["Name"]).Replace("\0", "");
                                if ((bool)row["DELETED_FLAG"]) y.Name = "$$_" + y.Name;
                                y.ID = (int)row["ID"];
                            }
                        }
                    }
                }
            }

            //Get The CPU(400) password
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk41ax" + _DirSeperator + "HATTRME1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk41ax" + _DirSeperator + "HATTRME1.DBF", _ziphelper, _DirSeperator);
                byte[] memoarray = null;

                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"])
                    {
                        if ((int)row["ATTRIIDM"] == 111142)
                        {
                            if (row["MEMOARRAYM"] != DBNull.Value)
                                memoarray = (byte[])row["MEMOARRAYM"];
                            if (memoarray.Length >= 12)
                            {
                                // memoarray[3] : level password (1-3)
                                byte[] mempass = new byte[8];
                                for (int i = 0; i < 8; i++)
                                {
                                    if (i < 2) mempass[i] = (byte)(memoarray[i + 4] ^ 0xAA);
                                    else mempass[i] = (byte)(memoarray[i + 2] ^ memoarray[i + 4] ^ 0xAA);
                                }
                                string res = ProjectEncoding.GetString(mempass);
                                foreach (var y in CPUFolders)
                                {
                                    if ((int)row["IDM"] == y.ID)
                                    {
                                        y.PasswdHard = res.Trim();
                                    }
                                }
                            }
                        }
                    }
                }
            }

            //Get The CPs...
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7wb53ax" + _DirSeperator + "HOBJECT1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7wb53ax" + _DirSeperator + "HOBJECT1.DBF", _ziphelper, _DirSeperator);

                foreach (var y in CPFolders)
                {
                    foreach (DataRow row in dbfTbl.Rows)
                    {
                        if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                        {
                            if ((int)row["ID"] == y.ID)
                            {
                                y.Name = ((string)row["Name"]).Replace("\0", "");
                                if ((bool)row["DELETED_FLAG"]) y.Name = "$$_" + y.Name;
                            }
                        }
                    }
                }
            }

            var tmpS7ProgrammFolders = new List<S7ProgrammFolder>();
            //Get all Program Folders
            if (_ziphelper.FileExists(ProjectFolder + "hrs" + _DirSeperator + "S7RESOFF.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hrs" + _DirSeperator + "S7RESOFF.DBF", _ziphelper, _DirSeperator);

                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                    {
                        var x = new S7ProgrammFolder() { Project = this };
                        x.Name = ((string)row["Name"]).Replace("\0","");
                        if ((bool) row["DELETED_FLAG"]) x.Name = "$$_" + x.Name;
                        x.ID = (int) row["ID"];
                        x._linkfileoffset = (int) row["RSRVD4_L"];
                        S7ProgrammFolders.Add(x);
                        tmpS7ProgrammFolders.Add(x);
                    }
                }
            }

            //Combine Folder and CPU (300)
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk31ax" + _DirSeperator + "HRELATI1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk31ax" + _DirSeperator + "HRELATI1.DBF", _ziphelper, _DirSeperator);

                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                    {

                        if ((int)row["RELID"] == 16)
                        {
                            int cpuid = (int)row["SOBJID"];
                            int fldid = (int)row["TOBJID"];
                            foreach (var y in CPUFolders)
                            {
                                if (y.ID == cpuid && y.CpuType == PLCType.Simatic300)
                                {
                                    foreach (var z in S7ProgrammFolders)
                                    {
                                        if (z.ID == fldid)
                                        {
                                            z.Parent = y;
                                            y.SubItems.Add(z);
                                            tmpS7ProgrammFolders.Remove(z);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            //Combine Folder and CPU (300 ET200s)
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hkcomx" + _DirSeperator + "HRELATI1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hkcomx" + _DirSeperator + "HRELATI1.DBF", _ziphelper, _DirSeperator);

                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                    {

                        if ((int)row["RELID"] == 16)
                        {
                            int cpuid = (int)row["SOBJID"];
                            int fldid = (int)row["TOBJID"];
                            foreach (var y in CPUFolders)
                            {
                                if (y.ID == cpuid && y.CpuType == PLCType.SimaticET200)
                                {
                                    foreach (var z in S7ProgrammFolders)
                                    {
                                        if (z.ID == fldid)
                                        {
                                            z.Parent = y;
                                            y.SubItems.Add(z);
                                            tmpS7ProgrammFolders.Remove(z);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            //Combine Folder and CPU (400)
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk41ax" + _DirSeperator + "HRELATI1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk41ax" + _DirSeperator + "HRELATI1.DBF", _ziphelper, _DirSeperator);

                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                    {

                        if ((int)row["RELID"] == 16)
                        {
                            int cpuid = (int)row["SOBJID"];
                            int fldid = (int)row["TOBJID"];
                            foreach (var y in CPUFolders)
                            {
                                if (y.ID == cpuid && (y.CpuType == PLCType.Simatic400 || y.CpuType == PLCType.Simatic400H))
                                {
                                    foreach (var z in S7ProgrammFolders)
                                    {
                                        if (z.ID == fldid)
                                        {
                                            z.Parent = y;
                                            y.SubItems.Add(z);
                                            tmpS7ProgrammFolders.Remove(z);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            //Add the BlockFolders without CPU to the Ground project
            foreach (var z in tmpS7ProgrammFolders)
            {
                z.Parent = ProjectStructure;
                ProjectStructure.SubItems.Add(z);
            }

            //Get Symbol Tables
            foreach (var z in S7ProgrammFolders)
            {
                var symtab = _GetSymTabForProject(z, this._showDeleted);
                if (symtab != null)
                {
                    symtab.Parent = z;
                    z.SymbolTable = symtab;
                    z.SubItems.Add(symtab);
                }
            }

            var tmpBlocksOfflineFolders = new List<BlocksOfflineFolder>();
            //Create the Programm Block folders...
            if (_ziphelper.FileExists(ProjectFolder + "ombstx" + _DirSeperator + "offline" + _DirSeperator + "BSTCNTOF.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "ombstx" + _DirSeperator + "offline" + _DirSeperator + "BSTCNTOF.DBF", _ziphelper, _DirSeperator);

                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                    {
                        var x = new BlocksOfflineFolder() { Project = this };
                        x.Name = ((string)row["Name"]).Replace("\0", "");
                        if ((bool)row["DELETED_FLAG"]) x.Name = "$$_" + x.Name;
                        x.ID = (int) row["ID"];
                        x.Folder = ProjectFolder + "ombstx" + _DirSeperator + "offline" + _DirSeperator + x.ID.ToString("X").PadLeft(8, '0') + _DirSeperator;
                        tmpBlocksOfflineFolders.Add(x);
                        _blocksOfflineFolders.Add(x);
                    }
                }
            }

            var Step7ProjectTypeStep7Sources = new List<SourceFolder>();
            //Create the Source Block folders...
            if (_ziphelper.FileExists(ProjectFolder + "s7asrcom" + _DirSeperator + "S7CNTREF.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "s7asrcom" + _DirSeperator + "S7CNTREF.DBF", _ziphelper, _DirSeperator);

                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                    {
                        var x = new SourceFolder() { Project = this };
                        x.Name = ((string)row["Name"]).Replace("\0","");
                        if ((bool)row["DELETED_FLAG"]) x.Name = "$$_" + x.Name;
                        x.ID = (int)row["ID"];
                        x.Folder = ProjectFolder + "s7asrcom" + _DirSeperator + x.ID.ToString("X").PadLeft(8, '0') + _DirSeperator;
                        Step7ProjectTypeStep7Sources.Add(x);
                    }
                }
            }

            //Infos about Link file hrs\linkhrs.lnk
            //Size of a Structure in the Link File: 512 bytes
            //Offset of Linkfile is in hrs\S7RESOFF.DBF, Filed 12 (RSRVD3_L)
            //after 0x04, 0x20, 0x11 follows the Step7ProjectBlockFolder ID (2 Bytes) or maybe the source folder id
            //after 0x01, 0x60, 0x11 follows the Step7Programm ID (2 Bytes)

            //Create the Link BlocksOfflineFolder Folder with S7ProgrammFolders...
            if (_ziphelper.FileExists(ProjectFolder + "hrs" + _DirSeperator + "linkhrs.lnk"))
            {

                //FileStream hrsLink = new FileStream(ProjectFolder + "hrs" + _DirSeperator + "linkhrs.lnk", FileMode.Open, FileAccess.Read, System.IO.FileShare.ReadWrite);
                Stream hrsLink = _ziphelper.GetReadStream(ProjectFolder + "hrs" + _DirSeperator + "linkhrs.lnk");
                BinaryReader rd = new BinaryReader(hrsLink);
                byte[] completeBuffer = rd.ReadBytes((int)_ziphelper.GetStreamLength(ProjectFolder + "hrs" + _DirSeperator + "linkhrs.lnk", hrsLink));
                rd.Close();
                hrsLink.Close();
                hrsLink = new MemoryStream(completeBuffer);

                foreach (var x in S7ProgrammFolders)
                {
                    byte[] tmpLink = new byte[0x200];
                    hrsLink.Position = x._linkfileoffset;
                    hrsLink.Read(tmpLink, 0, 0x200);

                    int pos1 = ASCIIEncoding.ASCII.GetString(tmpLink).IndexOf(ASCIIEncoding.ASCII.GetString(new byte[] { 0x01, 0x60, 0x11 }));
                    int wrt1 = tmpLink[pos1 + 3] * 0x100 + tmpLink[pos1 + 4];

                    int pos2 = ASCIIEncoding.ASCII.GetString(tmpLink).IndexOf(ASCIIEncoding.ASCII.GetString(new byte[] { 0x04, 0x20, 0x11 }));
                    int wrt2 = tmpLink[pos2 + 3] * 0x100 + tmpLink[pos2 + 4];

                    foreach (var y in tmpBlocksOfflineFolders)
                    {
                        if (y.ID == wrt1)
                        {
                            y.Parent = x;
                            x.SubItems.Add(y);
                            x.BlocksOfflineFolder = y;
                        }
                    }

                    foreach (var y in Step7ProjectTypeStep7Sources)
                    {
                        if (y.ID == wrt2)
                        {
                            y.Parent = x;
                            x.SubItems.Add(y);
                            x.SourceFolder = y;
                        }
                    }

                }
                hrsLink.Close();
            }
            else
            {
                foreach (var y in tmpBlocksOfflineFolders)
                {
                    y.Parent = ProjectStructure;
                    ProjectStructure.SubItems.Add(y);
                }

                foreach (var y in Step7ProjectTypeStep7Sources)
                {
                    y.Parent = ProjectStructure;
                    ProjectStructure.SubItems.Add(y);
                }
            }
        }
        public static void ReplaceStaticAccess(S7FunctionBlock myFct, S7ProgrammFolder myFld, S7ConvertingOptions myOpt)
        {
            if (myOpt.ReplaceDIAccessesWithSymbolNames && myFct.BlockType==PLCBlockType.FB)
            {
                List<FunctionBlockRow> retVal = new List<FunctionBlockRow>();
                List<FunctionBlockRow> tempList = new List<FunctionBlockRow>();

                bool LargeAccess = false;
                int add_adresse = 0;

                foreach (var functionBlockRow in myFct.AWLCode)
                {
                    if (functionBlockRow.Command == "TAR2")
                    {
                        tempList.Add(functionBlockRow);
                        LargeAccess = true;
                    }
                    else if (functionBlockRow.Command == "+AR2" && LargeAccess)
                    {
                        tempList.Add(functionBlockRow);
                        add_adresse += Convert.ToInt32(Convert.ToDouble(((S7FunctionBlockRow) functionBlockRow).Parameter.Substring(2), new NumberFormatInfo() {NumberDecimalSeparator = "."}));
                    }
                    else if (((S7FunctionBlockRow)functionBlockRow).Parameter.Contains("[AR2,P#") && ((S7FunctionBlockRow)functionBlockRow).Parameter.Substring(0, 2) == "DI" && !LargeAccess)
                    {
                        string para = ((S7FunctionBlockRow) functionBlockRow).Parameter;
                        ByteBitAddress adr = new ByteBitAddress(para.Substring(10, para.Length - 11));
                        var parRow = S7DataRow.GetDataRowWithAddress(myFct.Parameter, adr);
                        if (parRow!=null)
                        {
                            byte[] tmp = ((S7FunctionBlockRow) functionBlockRow).MC7;
                            ((S7FunctionBlockRow) functionBlockRow).Parameter = "#" + parRow.StructuredName.Substring(parRow.StructuredName.IndexOf('.') + 1);
                            ((S7FunctionBlockRow) functionBlockRow).MC7 = tmp;
                        }
                        retVal.Add(functionBlockRow);
                    }
                    else if (((S7FunctionBlockRow)functionBlockRow).Parameter.Contains("[AR2,P#") && ((S7FunctionBlockRow)functionBlockRow).Parameter.Substring(0, 2) == "DI" && LargeAccess)
                    {
                        /*
                        string para = ((S7FunctionBlockRow)functionBlockRow).Parameter;
                        ByteBitAddress adr = new ByteBitAddress(para.Substring(10, para.Length - 11));
                        adr.ByteAddress += add_adresse;
                        var parRow = S7DataRow.GetDataRowWithAddress(myFct.Parameter, adr);
                        if (parRow != null)
                        {
                            byte[] tmp = ((S7FunctionBlockRow)functionBlockRow).MC7;
                            ((S7FunctionBlockRow)functionBlockRow).Parameter = "#" + parRow.StructuredName;
                            ((S7FunctionBlockRow)functionBlockRow).MC7 = tmp;
                        }
                        retVal.Add(functionBlockRow);
                         * */
                    }
                    else if (functionBlockRow.Command=="LAR2")
                    {

                    }
                    else
                    {
                        LargeAccess = false;
                        retVal.AddRange(tempList);
                        tempList.Clear();
                        retVal.Add(functionBlockRow);
                    }
                }

                myFct.AWLCode = retVal;
            }
        }
        internal override void LoadProject()
        {
            _projectLoaded = true;

            ProjectStructure = new Step7ProjectFolder() { Project = this };
            CPUFolders = new List<CPUFolder>();
            CPFolders = new List<CPFolder>();
            S7ProgrammFolders = new List<S7ProgrammFolder>();
            BlocksOfflineFolders = new List<BlocksOfflineFolder>();

            ProjectStructure.Name = this.ToString();

            var stations = new List<StationConfigurationFolder>();

            List<CPFolder> DPFolders = new List<CPFolder>();//ProfiBusDP and MPI
            //Get The Project Stations...
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hstatx" + _DirSeperator + "HOBJECT1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hstatx" + _DirSeperator + "HOBJECT1.DBF", _ziphelper, _DirSeperator);
                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                    {
                        if ((int)row["OBJTYP"] == objectType_Simatic300 || (int)row["OBJTYP"] == objectType_Simatic400 || (int)row["OBJTYP"] == objectType_Simatic400H)
                        {
                            var x = new StationConfigurationFolder() { Project = this, Parent = ProjectStructure };
                            x.Name = ((string)row["Name"]).Replace("\0", "");
                            if ((bool)row["DELETED_FLAG"]) x.Name = "$$_" + x.Name;
                            x.ID = (int)row["ID"];
                            x.UnitID = (int)row["UNITID"];
                            x.ObjTyp = (int)row["OBJTYP"];
                            switch ((int)row["OBJTYP"])
                            {
                                case objectType_Simatic300:
                                    x.StationType = PLCType.Simatic300;
                                    break;
                                case objectType_Simatic400:
                                    x.StationType = PLCType.Simatic400;
                                    break;
                                case objectType_Simatic400H:
                                    x.StationType = PLCType.Simatic400H;
                                    break;
                            }
                            x.Parent = ProjectStructure;
                            ProjectStructure.SubItems.Add(x);
                            stations.Add(x);
                            _allFolders.Add(x);
                        }
                        else if ( Convert.ToInt32(row["OBJTYP"])==objectType_MpiDPinCPU)
                        {
                            var dp = new CPFolder();
                            dp.UnitID = Convert.ToInt32(row["UNITID"]);//is UNITID in CPUFolder
                            dp.ID = Convert.ToInt32(row["ID"]);
                            DPFolders.Add(dp);
                            _allFolders.Add(dp);
                        }
                    }
                }
            }

            //Get The HW Folder for the Station...
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hstatx" + _DirSeperator + "HRELATI1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hstatx" + _DirSeperator + "HRELATI1.DBF", _ziphelper, _DirSeperator);
                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                    {
                        if (Convert.ToInt32(row["RELID"]) == 1315820)
                        {
                            int TobjType = Convert.ToInt32(row["TOBJTYP"]);

                            if (TobjType == objectType_MpiDP400 || TobjType == objectType_MpiDP300)
                            {
                                var dp = DPFolders.FirstOrDefault(x => x.ID == Convert.ToInt32(row["SOBJID"]));
                                if (dp != null)
                                {
                                    if (dp.IdTobjId == null) dp.IdTobjId = new List<int>();
                                    dp.IdTobjId.Add(Convert.ToInt32(row["TOBJID"]));
                                }
                            }
                        }
                    }
                }
            }

            /*
            //Get The HW Folder for the Station...
            if (ZipHelper.FileExists(_zipfile,ProjectFolder + "hOmSave7" + _DirSeperator + "s7hstatx" + _DirSeperator + "HRELATI1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hstatx" + _DirSeperator + "HRELATI1.DBF", _zipfile, _DirSeperator);
                foreach (var y in Step7ProjectStructure.SubItems)
                {
                    if (y.GetType() == typeof (StationConfigurationFolder))
                    {
                        var z = (StationConfigurationFolder) y;
                        foreach (DataRow row in dbfTbl.Rows)
                        {
                            if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                            {
                                if ((int)row["SOBJID"] == z.ID && (int)row["RELID"] == 1315838)
                                {
                                    var x = new CPUFolder() {Project = this};
                                    x.UnitID = Convert.ToInt32(row["TUNITID"]);
                                    x.TobjTyp = Convert.ToInt32(row["TOBJTYP"]);
                                    x.CpuType = z.StationType;
                                    bool add = true;
                                    foreach (Step7ProjectFolder tmp in z.SubItems)
                                    {
                                        if (tmp.GetType() == typeof (CPUFolder) && ((CPUFolder) tmp).UnitID == x.UnitID)
                                            add = false;
                                    }
                                    if (add)
                                    {
                                        x.Parent = z;
                                        z.SubItems.Add(x);
                                        CPUFolders.Add(x);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            */

            //Get The CPs...
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7wb53ax" + _DirSeperator + "HOBJECT1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7wb53ax" + _DirSeperator + "HOBJECT1.DBF", _ziphelper, _DirSeperator);

                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                    {
                        var cp = new CPFolder() { Project = this };
                        cp.ID = Convert.ToInt32(row["ID"]);
                        cp.UnitID = Convert.ToInt32(row["UNITID"]);
                        cp.TobjTyp = Convert.ToInt32(row["OBJTYP"]);
                        cp.Name = ((string)row["Name"]).Replace("\0", "");
                        if (Convert.ToBoolean(row["DELETED_FLAG"])) cp.Name = "$$_" + cp.Name;
                        cp.Rack = Convert.ToInt32(row["SUBSTATN"]);
                        cp.Slot = Convert.ToInt32(row["MODULN"]);
                        cp.SubModulNumber = Convert.ToInt32(row["SUBMODN"]);
                        CPFolders.Add(cp);
                        _allFolders.Add(cp);
                    }
                }
            }
            //add subitem to parent
            foreach(var cp in CPFolders.Where(x=>x.SubModulNumber > 0))
            {
                var parent = CPFolders.FirstOrDefault(x => x.ID == cp.UnitID);
                if (parent != null) parent.SubModul = cp;
            }

            //Get The CP Folders
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7wb53ax" + _DirSeperator + "HRELATI1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7wb53ax" + _DirSeperator + "HRELATI1.DBF", _ziphelper, _DirSeperator);
                foreach(DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                    {
                        int relID = Convert.ToInt32(row["RELID"]);
                        if (relID == 1315827)
                        {
                            var cpu = (StationConfigurationFolder)ProjectStructure.SubItems.FirstOrDefault(x => x.ID == Convert.ToInt32(row["TUNITID"]));
                            var cp = CPFolders.FirstOrDefault(x => x.ID == Convert.ToInt32(row["SOBJID"]));
                            if (cpu != null && cp != null) cpu.SubItems.Add(cp);
                        }
                        else if (relID == 64)
                        {
                            var cp = CPFolders.FirstOrDefault(x => x.ID == Convert.ToInt32(row["SOBJID"]));
                            if (cp != null)
                            {
                                if (cp.TobjId == null) cp.TobjId = new List<int>();
                                cp.TobjId.Add(Convert.ToInt32(row["TOBJID"]));
                            }
                        }
                    }
                }
            }

            //Get The CPU 300 Folders
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk31ax" + _DirSeperator + "HRELATI1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk31ax" + _DirSeperator + "HRELATI1.DBF", _ziphelper, _DirSeperator);
                foreach (var y in ProjectStructure.SubItems)
                {
                    if (y.GetType() == typeof(StationConfigurationFolder))
                    {
                        var z = (StationConfigurationFolder)y;
                        foreach (DataRow row in dbfTbl.Rows)
                        {
                            if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                            {
                                if ((int)row["TUNITID"] == z.ID && (int)row["TOBJTYP"] == 1314972)
                                //((int)row["TUNITTYP"] == 1314969 || (int)row["TUNITTYP"] == 1314969 || (int)row["TUNITTYP"] == 1314969))
                                {
                                    var x = new CPUFolder() { Project = this };
                                    x.UnitID = Convert.ToInt32(row["TUNITID"]);
                                    x.TobjTyp = Convert.ToInt32(row["TOBJTYP"]);
                                    x.CpuType = z.StationType;
                                    x.ID = Convert.ToInt32(row["SOBJID"]);
                                    x.Parent = z;
                                    z.SubItems.Add(x);
                                    CPUFolders.Add(x);
                                    _allFolders.Add(x);
                                }
                            }
                        }
                    }
                }
            }

            //Get The CPU 300 ET200s Folders
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hkcomx" + _DirSeperator + "HRELATI1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hkcomx" + _DirSeperator + "HRELATI1.DBF", _ziphelper, _DirSeperator);
                foreach (var y in ProjectStructure.SubItems)
                {
                    if (y.GetType() == typeof(StationConfigurationFolder))
                    {
                        var z = (StationConfigurationFolder)y;
                        foreach (DataRow row in dbfTbl.Rows)
                        {
                            if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                            {
                                if ((int)row["TUNITID"] == z.ID && (int)row["TOBJTYP"] == 1314972)
                                //((int)row["TUNITTYP"] == 1314969 || (int)row["TUNITTYP"] == 1314969 || (int)row["TUNITTYP"] == 1314969))
                                {
                                    var x = new CPUFolder() { Project = this };
                                    x.UnitID = Convert.ToInt32(row["TUNITID"]);
                                    x.TobjTyp = Convert.ToInt32(row["TOBJTYP"]);
                                    x.CpuType = z.StationType;
                                    x.ID = Convert.ToInt32(row["SOBJID"]);
                                    x.CpuType = PLCType.SimaticET200;
                                    x.Parent = z;
                                    z.SubItems.Add(x);
                                    CPUFolders.Add(x);
                                    _allFolders.Add(x);
                                }
                            }
                        }
                    }
                }
            }
            //Get The CPU 400 Folders
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk41ax" + _DirSeperator + "HRELATI1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk41ax" + _DirSeperator + "HRELATI1.DBF", _ziphelper, _DirSeperator);

                foreach (var y in ProjectStructure.SubItems)
                {
                    if (y.GetType() == typeof(StationConfigurationFolder))
                    {
                        var z = (StationConfigurationFolder)y;
                        foreach (DataRow row in dbfTbl.Rows)
                        {
                            if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                            {
                                if ((int)row["TUNITID"] == z.ID && ((int)row["TOBJTYP"] == 1314972 || (int)row["TOBJTYP"] == 1315656 /* BackupCPU bei H Sys */))
                                //((int)row["TUNITTYP"] == 1314969 || (int)row["TUNITTYP"] == 1314969 || (int)row["TUNITTYP"] == 1314969))
                                {
                                    var x = new CPUFolder() { Project = this };
                                    x.UnitID = Convert.ToInt32(row["TUNITID"]);
                                    x.TobjTyp = Convert.ToInt32(row["TOBJTYP"]);
                                    x.CpuType = z.StationType;
                                    x.ID = Convert.ToInt32(row["SOBJID"]);
                                    x.Parent = z;
                                    z.SubItems.Add(x);
                                    CPUFolders.Add(x);
                                    _allFolders.Add(x);
                                }
                            }
                        }
                    }
                }
            }

            //Get The CPU(ET200S)...
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hkcomx" + _DirSeperator + "HOBJECT1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hkcomx" + _DirSeperator + "HOBJECT1.DBF", _ziphelper, _DirSeperator);

                foreach (var y in CPUFolders)
                {
                    foreach (DataRow row in dbfTbl.Rows)
                    {
                        if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                        {
                            if ((int)row["ID"] == y.ID && y.CpuType == PLCType.SimaticET200)
                            //if ((int)row["UNITID"] == y.UnitID && y.CpuType == PLCType.SimaticET200)
                            {
                                y.Name = ((string)row["Name"]).Replace("\0", "");
                                if ((bool)row["DELETED_FLAG"]) y.Name = "$$_" + y.Name;
                                y.ID = (int)row["ID"];

                                y.Rack = (int)row["SUBSTATN"];
                                y.Slot = (int)row["MODULN"];
                            }
                        }
                    }
                }
            }

            //Get The CPU(300)...
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk31ax" + _DirSeperator + "HOBJECT1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk31ax" + _DirSeperator + "HOBJECT1.DBF", _ziphelper, _DirSeperator);

                foreach (var y in CPUFolders)
                {
                    foreach (DataRow row in dbfTbl.Rows)
                    {
                        if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                        {
                            if ((int)row["ID"] == y.ID && y.CpuType == PLCType.Simatic300)
                            //if ((int)row["UNITID"] == y.UnitID && y.CpuType == PLCType.Simatic300)
                            {
                                y.Name = ((string)row["Name"]).Replace("\0", "");
                                if ((bool)row["DELETED_FLAG"]) y.Name = "$$_" + y.Name;
                                y.ID = (int)row["ID"];

                                y.Rack = (int)row["SUBSTATN"];
                                y.Slot = (int)row["MODULN"];
                            }
                        }
                    }
                }
            }

            //Get The CPU(300) password
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk31ax" + _DirSeperator + "HATTRME1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk31ax" + _DirSeperator + "HATTRME1.DBF", _ziphelper, _DirSeperator);
                byte[] memoarray = null;

                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"])
                    {
                        if ((int)row["ATTRIIDM"] == 111142)
                        {
                            if (row["MEMOARRAYM"] != DBNull.Value)
                                memoarray = (byte[])row["MEMOARRAYM"];

                            if (memoarray.Length >= 12)
                            {
                                // memoarray[3] : level password (1-3)
                                byte[] mempass = new byte[8];
                                for (int i = 0; i < 8; i++)
                                {
                                    if (i < 2) mempass[i] = (byte)(memoarray[i + 4] ^ 0xAA);
                                    else mempass[i] = (byte)(memoarray[i + 2] ^ memoarray[i + 4] ^ 0xAA);
                                }
                                string res = ProjectEncoding.GetString(mempass);
                                foreach (var y in CPUFolders)
                                {
                                    if ((int)row["IDM"] == y.ID)
                                    {
                                        y.PasswdHard = res.Trim();
                                    }
                                }
                            }
                        }
                    }
                }
            }

            //Get The CPU(400)...
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk41ax" + _DirSeperator + "HOBJECT1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk41ax" + _DirSeperator + "HOBJECT1.DBF", _ziphelper, _DirSeperator);

                foreach (var y in CPUFolders)
                {
                    foreach (DataRow row in dbfTbl.Rows)
                    {
                        if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                        {
                            if ((int)row["ID"] == y.ID && (y.CpuType == PLCType.Simatic400 || y.CpuType == PLCType.Simatic400H))
                            //if ((int)row["UNITID"] == y.UnitID && (y.CpuType == PLCType.Simatic400 || y.CpuType == PLCType.Simatic400H) )
                            {
                                y.Name = ((string)row["Name"]).Replace("\0", "");
                                if ((bool)row["DELETED_FLAG"]) y.Name = "$$_" + y.Name;
                                y.ID = (int)row["ID"];

                                y.Rack = (int)row["SUBSTATN"];
                                y.Slot = (int)row["MODULN"];
                            }
                        }
                    }
                }
            }

            //Get The CPU(400) password
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk41ax" + _DirSeperator + "HATTRME1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk41ax" + _DirSeperator + "HATTRME1.DBF", _ziphelper, _DirSeperator);
                byte[] memoarray = null;

                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"])
                    {
                        if ((int)row["ATTRIIDM"] == 111142)
                        {
                            if (row["MEMOARRAYM"] != DBNull.Value)
                                memoarray = (byte[])row["MEMOARRAYM"];
                            if (memoarray.Length >= 12)
                            {
                                // memoarray[3] : level password (1-3)
                                byte[] mempass = new byte[8];
                                for (int i = 0; i < 8; i++)
                                {
                                    if (i < 2) mempass[i] = (byte)(memoarray[i + 4] ^ 0xAA);
                                    else mempass[i] = (byte)(memoarray[i + 2] ^ memoarray[i + 4] ^ 0xAA);
                                }
                                string res = ProjectEncoding.GetString(mempass);
                                foreach (var y in CPUFolders)
                                {
                                    if ((int)row["IDM"] == y.ID)
                                    {
                                        y.PasswdHard = res.Trim();
                                    }
                                }
                            }
                        }
                    }
                }
            }

            var tmpS7ProgrammFolders = new List<S7ProgrammFolder>();
            //Get all Program Folders
            if (_ziphelper.FileExists(ProjectFolder + "hrs" + _DirSeperator + "S7RESOFF.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hrs" + _DirSeperator + "S7RESOFF.DBF", _ziphelper, _DirSeperator);

                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                    {
                        var x = new S7ProgrammFolder() { Project = this };
                        x.Name = ((string)row["Name"]).Replace("\0", "");
                        if ((bool)row["DELETED_FLAG"]) x.Name = "$$_" + x.Name;
                        x.ID = (int)row["ID"];
                        x._linkfileoffset = (int)row["RSRVD4_L"];
                        S7ProgrammFolders.Add(x);
                        tmpS7ProgrammFolders.Add(x);
                        _allFolders.Add(x);
                    }
                }
            }

            //Combine Folder and CPU (300)
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk31ax" + _DirSeperator + "HRELATI1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk31ax" + _DirSeperator + "HRELATI1.DBF", _ziphelper, _DirSeperator);

                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                    {

                        if ((int)row["RELID"] == 16)
                        {
                            int cpuid = (int)row["SOBJID"];
                            int fldid = (int)row["TOBJID"];
                            foreach (var y in CPUFolders)
                            {
                                if (y.ID == cpuid && y.CpuType == PLCType.Simatic300)
                                {
                                    foreach (var z in S7ProgrammFolders)
                                    {
                                        if (z.ID == fldid)
                                        {
                                            z.Parent = y;
                                            y.SubItems.Add(z);
                                            tmpS7ProgrammFolders.Remove(z);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            //Combine Folder and CPU (300 ET200s)
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hkcomx" + _DirSeperator + "HRELATI1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hkcomx" + _DirSeperator + "HRELATI1.DBF", _ziphelper, _DirSeperator);

                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                    {

                        if ((int)row["RELID"] == 16)
                        {
                            int cpuid = (int)row["SOBJID"];
                            int fldid = (int)row["TOBJID"];
                            foreach (var y in CPUFolders)
                            {
                                if (y.ID == cpuid && y.CpuType == PLCType.SimaticET200)
                                {
                                    foreach (var z in S7ProgrammFolders)
                                    {
                                        if (z.ID == fldid)
                                        {
                                            z.Parent = y;
                                            y.SubItems.Add(z);
                                            tmpS7ProgrammFolders.Remove(z);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            //Combine Folder and CPU (400)
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk41ax" + _DirSeperator + "HRELATI1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hk41ax" + _DirSeperator + "HRELATI1.DBF", _ziphelper, _DirSeperator);

                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                    {

                        if ((int)row["RELID"] == 16)
                        {
                            int cpuid = (int)row["SOBJID"];
                            int fldid = (int)row["TOBJID"];
                            foreach (var y in CPUFolders)
                            {
                                if (y.ID == cpuid && (y.CpuType == PLCType.Simatic400 || y.CpuType == PLCType.Simatic400H))
                                {
                                    foreach (var z in S7ProgrammFolders)
                                    {
                                        if (z.ID == fldid)
                                        {
                                            z.Parent = y;
                                            y.SubItems.Add(z);
                                            tmpS7ProgrammFolders.Remove(z);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            //Add the BlockFolders without CPU to the Ground project
            foreach (var z in tmpS7ProgrammFolders)
            {
                z.Parent = ProjectStructure;
                ProjectStructure.SubItems.Add(z);
            }

            //Get Symbol Tables
            foreach (var z in S7ProgrammFolders)
            {
                var symtab = _GetSymTabForProject(z, this._showDeleted);
                if (symtab != null)
                {
                    symtab.Parent = z;
                    z.SymbolTable = symtab;
                    z.SubItems.Add(symtab);
                    _allFolders.Add(symtab);
                }
            }

            var tmpBlocksOfflineFolders = new List<BlocksOfflineFolder>();
            //Create the Programm Block folders...
            if (_ziphelper.FileExists(ProjectFolder + "ombstx" + _DirSeperator + "offline" + _DirSeperator + "BSTCNTOF.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "ombstx" + _DirSeperator + "offline" + _DirSeperator + "BSTCNTOF.DBF", _ziphelper, _DirSeperator);

                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                    {
                        var x = new BlocksOfflineFolder() { Project = this };
                        x.Name = ((string)row["Name"]).Replace("\0", "");
                        if ((bool)row["DELETED_FLAG"]) x.Name = "$$_" + x.Name;
                        x.ID = (int)row["ID"];
                        x.Folder = ProjectFolder + "ombstx" + _DirSeperator + "offline" + _DirSeperator + x.ID.ToString("X").PadLeft(8, '0') + _DirSeperator;
                        tmpBlocksOfflineFolders.Add(x);
                        _blocksOfflineFolders.Add(x);
                        _allFolders.Add(x);
                    }
                }
            }

            var Step7ProjectTypeStep7Sources = new List<SourceFolder>();
            //Create the Source Block folders...
            if (_ziphelper.FileExists(ProjectFolder + "s7asrcom" + _DirSeperator + "S7CNTREF.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "s7asrcom" + _DirSeperator + "S7CNTREF.DBF", _ziphelper, _DirSeperator);

                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                    {
                        var x = new SourceFolder() { Project = this };
                        x.Name = ((string)row["Name"]).Replace("\0", "");
                        if ((bool)row["DELETED_FLAG"]) x.Name = "$$_" + x.Name;
                        x.ID = (int)row["ID"];
                        x.Folder = ProjectFolder + "s7asrcom" + _DirSeperator + x.ID.ToString("X").PadLeft(8, '0') + _DirSeperator;
                        Step7ProjectTypeStep7Sources.Add(x);
                        _allFolders.Add(x);
                    }
                }
            }

            var pbMasterSystems = new List<ProfibusMasterSystem>();

            //Get all Profibus Master Systems
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "S7HDPSSX" + _DirSeperator + "HOBJECT1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "S7HDPSSX" + _DirSeperator + "HOBJECT1.DBF", _ziphelper, _DirSeperator);

                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                    {
                        if ((int)row["OBJTYP"] == 1314971)
                        {
                            var x = new ProfibusMasterSystem() { Project = this, Name = row["NAME"].ToString().Replace("\0", ""), Id = (int)row["ID"] };
                            pbMasterSystems.Add(x);
                            _allFolders.Add(x);
                        }
                    }
                }
            }

            //Link all PbMasterSystems to the Stations
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "S7HDPSSX" + _DirSeperator + "HRELATI1.DBF"))
            {
                var lnkLst = new List<LinkHelp>();

                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "S7HDPSSX" + _DirSeperator + "HRELATI1.DBF", _ziphelper, _DirSeperator);

                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                    {
                        lnkLst.Add(new LinkHelp() { SOBJID = (int)row["SOBJID"], SOBJTYP = (int)row["SOBJTYP"], RELID = (int)row["RELID"], TOBJID = (int)row["TOBJID"], TOBJTYP = (int)row["TOBJTYP"], TUNITID = (int)row["TUNITID"], TUNITTYP = (int)row["TUNITTYP"] });
                    }
                }

                foreach (StationConfigurationFolder station in stations)
                {
                    var lnks = lnkLst.Where(x => x.TOBJTYP == station.ObjTyp && x.TOBJID == station.ID);
                    foreach (LinkHelp linkHelp in lnks)
                    {
                        var ms = pbMasterSystems.FirstOrDefault(x => x.Id == linkHelp.SOBJID);
                        if (ms != null)
                        {
                            station.MasterSystems.Add(ms);
                            station.SubItems.Add(ms);
                        }
                    }
                }
            }

            //Get all Profibus Parts
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hslntx" + _DirSeperator + "HOBJECT1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hslntx" + _DirSeperator + "HOBJECT1.DBF", _ziphelper, _DirSeperator);

                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                    {
                        if ((int)row["OBJTYP"] == 1314988)
                        {
                            var node = new ProfibusNode() { Name = row["NAME"].ToString().Replace("\0", ""), NodeId = (int)row["SUBSTATN"], GsdFile = row["CEXTTYPE"].ToString() };

                            var ma = pbMasterSystems.FirstOrDefault(x => x.Id == (int)row["UNITID"]);
                            if (ma != null)
                                ma.Children.Add(node);
                        }
                    }
                }
            }

            var pnMasterSystems = new List<ProfinetMasterSystem>();

            //Get all Profibus Master Systems
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hssiox" + _DirSeperator + "HOBJECT1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hssiox" + _DirSeperator + "HOBJECT1.DBF", _ziphelper, _DirSeperator);

                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                    {
                        int objType = Convert.ToInt32(row["OBJTYP"]);
                        if (objType == 1316787)
                        {
                            var x = new ProfinetMasterSystem() { Project = this, Name = row["NAME"].ToString().Replace("\0", ""), Id = (int)row["ID"] };
                            pnMasterSystems.Add(x);
                            _allFolders.Add(x);
                        }
                        else if (objType == objectType_EternetInCPU3xx || objType == objectType_EternetInCPU4xx)
                        {
                            var cpu = CPUFolders.FirstOrDefault(x => x.ID == Convert.ToInt32(row["UNITID"]));
                            if (cpu != null) cpu.IdTobjId = Convert.ToInt32(row["ID"]);
                        }
                        else if ( objType == 2364971 || objType == 2367589 )
                        {
                            var cp = CPFolders.FirstOrDefault(x => x.ID == (int)row["UNITID"]);
                            if (cp != null)
                            {
                                if (cp.IdTobjId == null) cp.IdTobjId = new List<int>();
                                cp.IdTobjId.Add((int)row["ID"]);
                            }
                        }
                    }
                }
            }

            //Link all PnMasterSystems to the Stations
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hssiox" + _DirSeperator + "HRELATI1.DBF"))
            {
                var lnkLst = new List<LinkHelp>();

                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hssiox" + _DirSeperator + "HRELATI1.DBF", _ziphelper, _DirSeperator);

                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                    {
                        if ( Convert.ToInt32(row["RELID"]) == 64)
                        {
                            var cpu = CPUFolders.FirstOrDefault(x => x.IdTobjId == Convert.ToInt32(row["SOBJID"]));
                            if (cpu != null) cpu.TobjId = Convert.ToInt32(row["TOBJID"]);

                            var cp = CPFolders.FirstOrDefault(x => x.IdTobjId != null && x.IdTobjId.Any(c => c == (int)row["SOBJID"]));
                            if (cp != null)
                            {
                                if (cp.TobjId == null) cp.TobjId = new List<int>();
                                cp.TobjId.Add((int)row["TOBJID"]);
                            }
                        }

                        lnkLst.Add(new LinkHelp() { SOBJID = (int)row["SOBJID"], SOBJTYP = (int)row["SOBJTYP"], RELID = (int)row["RELID"], TOBJID = (int)row["TOBJID"], TOBJTYP = (int)row["TOBJTYP"], TUNITID = (int)row["TUNITID"], TUNITTYP = (int)row["TUNITTYP"] });
                    }
                }
                foreach (StationConfigurationFolder station in stations)
                {
                    var lnks = lnkLst.Where(x => x.TOBJTYP == station.ObjTyp && x.TOBJID == station.ID);
                    foreach (LinkHelp linkHelp in lnks)
                    {
                        var ms = pnMasterSystems.FirstOrDefault(x => x.Id == linkHelp.SOBJID);
                        if (ms != null)
                        {
                            station.MasterSystems.Add(ms);
                            station.SubItems.Add(ms);
                        }
                    }
                }
            }

            //Get all Profinet Parts ...
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hdevnx" + _DirSeperator + "HOBJECT1.DBF"))
            {
                var attLst = new List<AttrMeHelp>();

                //Read real name from hattrme.dbf
                if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hdevnx" + _DirSeperator + "HATTRME1.DBF"))
                {
                    var dbfTbl2 = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hdevnx" + _DirSeperator + "HATTRME1.DBF", _ziphelper, _DirSeperator);

                    foreach (DataRow row in dbfTbl2.Rows)
                    {
                        if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                        {
                            attLst.Add(new AttrMeHelp() { IDM = (int)row["IDM"], ATTRIIDM = (int)row["ATTRIIDM"], ATTFORMATM = (int)row["ATTFORMATM"], MEMOARRAYM = (byte[])row["MEMOARRAYM"] });
                        }
                    }
                }

                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hdevnx" + _DirSeperator + "HOBJECT1.DBF", _ziphelper, _DirSeperator);

                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                    {
                        if ((int)row["OBJTYP"] == 1316803)
                        {
                            var node = new ProfibusNode() { Name = row["NAME"].ToString().Replace("\0", ""), NodeId = (int)row["SUBSTATN"], GsdFile = row["CEXTTYPE"].ToString() };

                            var inf = attLst.FirstOrDefault(x => x.IDM == (int)row["ID"] && x.ATTRIIDM == 111386);

                            if (inf != null)
                                node.Name = ProjectEncoding.GetString(inf.MEMOARRAYM).Replace("\0", "");

                            var ma = pnMasterSystems.FirstOrDefault(x => x.Id == (int)row["UNITID"]);
                            if (ma != null)
                                ma.Children.Add(node);
                        }
                    }
                }
            }

            //Infos about Link file hrs\linkhrs.lnk
            //Size of a Structure in the Link File: 512 bytes
            //Offset of Linkfile is in hrs\S7RESOFF.DBF, Filed 12 (RSRVD3_L)
            //after 0x04, 0x20, 0x11 follows the Step7ProjectBlockFolder ID (2 Bytes) or maybe the source folder id
            //after 0x01, 0x60, 0x11 follows the Step7Programm ID (2 Bytes)

            //Create the Link BlocksOfflineFolder Folder with S7ProgrammFolders...
            if (_ziphelper.FileExists(ProjectFolder + "hrs" + _DirSeperator + "linkhrs.lnk"))
            {

                //FileStream hrsLink = new FileStream(ProjectFolder + "hrs" + _DirSeperator + "linkhrs.lnk", FileMode.Open, FileAccess.Read, System.IO.FileShare.ReadWrite);
                Stream hrsLink = _ziphelper.GetReadStream(ProjectFolder + "hrs" + _DirSeperator + "linkhrs.lnk");
                BinaryReader rd = new BinaryReader(hrsLink);
                byte[] completeBuffer = rd.ReadBytes((int)_ziphelper.GetStreamLength(ProjectFolder + "hrs" + _DirSeperator + "linkhrs.lnk", hrsLink));
                rd.Close();
                hrsLink.Close();
                hrsLink = new MemoryStream(completeBuffer);

                foreach (var x in S7ProgrammFolders)
                {
                    byte[] tmpLink = new byte[0x200];
                    hrsLink.Position = x._linkfileoffset;
                    hrsLink.Read(tmpLink, 0, 0x200);

                    int pos1 = ASCIIEncoding.ASCII.GetString(tmpLink).IndexOf(ASCIIEncoding.ASCII.GetString(new byte[] { 0x01, 0x60, 0x11 }));
                    int wrt1 = tmpLink[pos1 + 3] * 0x100 + tmpLink[pos1 + 4];

                    int pos2 = ASCIIEncoding.ASCII.GetString(tmpLink).IndexOf(ASCIIEncoding.ASCII.GetString(new byte[] { 0x04, 0x20, 0x11 }));
                    int wrt2 = tmpLink[pos2 + 3] * 0x100 + tmpLink[pos2 + 4];

                    BlocksOfflineFolder fld = null;
                    foreach (var y in tmpBlocksOfflineFolders)
                    {
                        if (y.ID == wrt1)
                        {
                            y.Parent = x;
                            x.SubItems.Add(y);
                            x.BlocksOfflineFolder = y;
                            fld = y;
                            break;
                        }
                    }

                    if (fld != null)
                        tmpBlocksOfflineFolders.Remove(fld);

                    foreach (var y in Step7ProjectTypeStep7Sources)
                    {
                        if (y.ID == wrt2)
                        {
                            y.Parent = x;
                            x.SubItems.Add(y);
                            x.SourceFolder = y;
                        }
                    }

                }
                hrsLink.Close();
            }
            else
            {
                foreach (var y in tmpBlocksOfflineFolders)
                {
                    y.Parent = ProjectStructure;
                    ProjectStructure.SubItems.Add(y);
                }

                foreach (var y in Step7ProjectTypeStep7Sources)
                {
                    y.Parent = ProjectStructure;
                    ProjectStructure.SubItems.Add(y);
                }
            }

            if (_showDeleted)
            {
                foreach (var y in tmpBlocksOfflineFolders)
                {
                    var x = new S7ProgrammFolder() { Name = "$$tmpProgram_for_deleted" };
                    x.Project = this;
                    x.Parent = ProjectStructure;
                    y.Parent = x;
                    x.SubItems.Add(y);
                    x.BlocksOfflineFolder = y;
                    ProjectStructure.SubItems.Add(x);
                }
            }
            //Get The ProfiBus and MPI
            List<DpHelp> DPlist = new List<DpHelp>();
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hkdmax" + _DirSeperator + "HOBJECT1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hkdmax" + _DirSeperator + "HOBJECT1.DBF", _ziphelper, _DirSeperator);

                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                    {
                        var dp = new DpHelp();
                        dp.id = Convert.ToInt32(row["ID"]);
                        DPlist.Add(dp);
                    }
                }
            }
            if (_ziphelper.FileExists(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hkdmax" + _DirSeperator + "HRELATI1.DBF"))
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "hOmSave7" + _DirSeperator + "s7hkdmax" + _DirSeperator + "HRELATI1.DBF", _ziphelper, _DirSeperator);

                var rrr = DPFolders;
                foreach (DataRow row in dbfTbl.Rows)
                {
                    int relID = Convert.ToInt32(row["RELID"]);
                    if ( relID == 1315837)
                    {
                        var dp = DPlist.FirstOrDefault(x => x.id == Convert.ToInt32(row["SOBJID"]));
                        if ( dp != null)
                        {
                            dp.TobjID = Convert.ToInt32(row["TOBJID"]);
                        }
                    }
                    else if (relID == 64)
                    {
                        var dp = DPlist.FirstOrDefault(x => x.id == Convert.ToInt32(row["SOBJID"]));
                        if (dp != null)
                        {
                            dp.addr = Convert.ToInt32(row["TOBJID"]);
                        }
                    }
                }
            }
            //remove DP from DPlist to DPFolder
            foreach(var dp in DPlist)
            {
                var dpf = DPFolders.FirstOrDefault(x => x.IdTobjId.Any(y => y == dp.TobjID));
                if ( dpf != null)
                {
                    if (dpf.TobjId == null) dpf.TobjId = new List<int>();
                    dpf.TobjId.Add(dp.addr);
                }
            }
            //add subitem to parent
            //foreach (var cp in CPFolders.Where(x => x.SubModulNumber > 0))
            //{
            //    var parent = CPFolders.FirstOrDefault(x => x.ID == cp.UnitID);
            //    if (parent != null) parent.SubModul = cp;
            //}

            try {
                //read IP address from S7Netze\S7NONFGX.tab
                if (_ziphelper.FileExists(ProjectFolder + "S7Netze" + _DirSeperator + "S7NONFGX.tab"))
                {
                    Stream hrsLink = _ziphelper.GetReadStream(ProjectFolder + "S7Netze" + _DirSeperator + "S7NONFGX.tab");
                    BinaryReader rd = new BinaryReader(hrsLink);
                    int lengthFile = (int)_ziphelper.GetStreamLength(ProjectFolder + "S7Netze" + _DirSeperator + "S7NONFGX.tab", hrsLink);
                    byte[] completeBuffer = rd.ReadBytes(lengthFile);
                    rd.Close();
                    hrsLink.Close();

                    char[] searchValid = { 'A', 'd', 'd', 'r', 'e', 's', 's', 'I', 's', 'V', 'a', 'l', 'i', 'd' };
                    byte[] searchName = { (byte)'B', (byte)'a', (byte)'u', (byte)'g', (byte)'r', (byte)'u', (byte)'p', (byte)'p', (byte)'e', (byte)'n', (byte)'n', (byte)'a', (byte)'m', (byte)'e' };

                    byte[] startStructure = { 0x03, 0x52, 0x14, 0x00 };
                    byte[] startIP = { 0xE0, 0x0F, 0x00, 0x00, 0xE0, 0x0F, 0x00, 0x00 };
                    byte[] startMAC = { 0xA2, 0x0F, 0x00, 0x00, 0xA2, 0x0F, 0x00, 0x00 };
                    byte[] startMask = { 0xE5, 0x0F, 0x00, 0x00, 0xE5, 0x0F, 0x00, 0x00 };
                    byte[] startRouter = { 0xE3, 0x0F, 0x00, 0x00, 0xE3, 0x0F, 0x00, 0x00 };
                    byte[] startUseRouter = { 0xE8, 0x0F, 0x00, 0x00, 0xE8, 0x0F, 0x00, 0x00 };
                    byte[] startUseIP = { 0xEA, 0x0F, 0x00, 0x00, 0xEA, 0x0F, 0x00, 0x00 };
                    byte[] startUseMac = { 0xED, 0x0F, 0x00, 0x00, 0xED, 0x0F, 0x00, 0x00 };
                    int position = 0;
                    int lenStructure = 1705;// 1960;  //I don't think this len is correct... (look)
                    while ((position = indexOfByteArray(completeBuffer, startStructure, position + 1, lengthFile)) >= 0)
                    {
                        int number = BitConverter.ToInt32(completeBuffer, position + 4);//or ToInt16
                        //Debug.Print(number.ToString());
                        var cp = CPFolders.FirstOrDefault(x => x.TobjId != null && x.TobjId.Any(y => y == number));
                        var cpu = CPUFolders.FirstOrDefault(x => x.TobjId == number);
                        EthernetNetworkInterface ethernet = new EthernetNetworkInterface();
                        if (cp != null)
                        {
                            if (cp.NetworkInterfaces == null) cp.NetworkInterfaces = new List<NetworkInterface>();
                            cp.NetworkInterfaces.Add(ethernet);
                        }
                        else if (cpu != null)
                        {
                            if (cpu.NetworkInterfaces == null) cpu.NetworkInterfaces = new List<NetworkInterface>();
                            cpu.NetworkInterfaces.Add(ethernet);
                        }
                        else continue;

                        int pos = indexOfByteArray(completeBuffer, searchName, position, lenStructure);
                        if (pos > 0)
                        {
                            try
                            {
                                string strName = System.Text.Encoding.Default.GetString(completeBuffer, pos + 25, (int)completeBuffer[pos + 24]);

                                ethernet.Name = strName;
                            }
                            catch
                            { }
                        }

                        pos = indexOfByteArray(completeBuffer, startIP, position, lenStructure);
                        if (pos > 0)
                        {
                            try
                            {
                                string strIP = System.Text.Encoding.Default.GetString(completeBuffer, pos + 20, (int)completeBuffer[pos + 19]);
                                byte[] bIP = new byte[4];
                                bIP[0] = byte.Parse(strIP.Substring(0, 2), System.Globalization.NumberStyles.AllowHexSpecifier);
                                bIP[1] = byte.Parse(strIP.Substring(2, 2), System.Globalization.NumberStyles.AllowHexSpecifier);
                                bIP[2] = byte.Parse(strIP.Substring(4, 2), System.Globalization.NumberStyles.AllowHexSpecifier);
                                bIP[3] = byte.Parse(strIP.Substring(6, 2), System.Globalization.NumberStyles.AllowHexSpecifier);

                                ethernet.IpAddress = new System.Net.IPAddress(bIP);
                            }
                            catch
                            { }
                        }
                        pos = indexOfByteArray(completeBuffer, startMAC, position, lenStructure);
                        if (pos > 0)
                        {
                            try
                            {
                                string strMAC = System.Text.Encoding.Default.GetString(completeBuffer, pos + 20, (int)completeBuffer[pos + 19]);

                                ethernet.Mac = System.Net.NetworkInformation.PhysicalAddress.Parse(strMAC);
                            }
                            catch
                            { }
                        }
                        pos = indexOfByteArray(completeBuffer, startMask, position, lenStructure);
                        if (pos > 0)
                        {
                            try
                            {
                                string strMask = System.Text.Encoding.Default.GetString(completeBuffer, pos + 20, (int)completeBuffer[pos + 19]);
                                byte[] bIP = new byte[4];
                                bIP[0] = byte.Parse(strMask.Substring(0, 2), System.Globalization.NumberStyles.AllowHexSpecifier);
                                bIP[1] = byte.Parse(strMask.Substring(2, 2), System.Globalization.NumberStyles.AllowHexSpecifier);
                                bIP[2] = byte.Parse(strMask.Substring(4, 2), System.Globalization.NumberStyles.AllowHexSpecifier);
                                bIP[3] = byte.Parse(strMask.Substring(6, 2), System.Globalization.NumberStyles.AllowHexSpecifier);

                                ethernet.SubnetMask = new System.Net.IPAddress(bIP);
                            }
                            catch
                            { }
                        }
                        pos = indexOfByteArray(completeBuffer, startRouter, position, lenStructure);
                        if (pos > 0)
                        {
                            try
                            {
                                string strRouter = System.Text.Encoding.Default.GetString(completeBuffer, pos + 20, (int)completeBuffer[pos + 19]);
                                byte[] bIP = new byte[4];
                                bIP[0] = byte.Parse(strRouter.Substring(0, 2), System.Globalization.NumberStyles.AllowHexSpecifier);
                                bIP[1] = byte.Parse(strRouter.Substring(2, 2), System.Globalization.NumberStyles.AllowHexSpecifier);
                                bIP[2] = byte.Parse(strRouter.Substring(4, 2), System.Globalization.NumberStyles.AllowHexSpecifier);
                                bIP[3] = byte.Parse(strRouter.Substring(6, 2), System.Globalization.NumberStyles.AllowHexSpecifier);
                                ethernet.Router = new System.Net.IPAddress(bIP);
                            }
                            catch
                            { }
                        }
                        pos = indexOfByteArray(completeBuffer, startUseRouter, position, lenStructure);
                        if (pos > 0)
                        {
                            try
                            {
                                ethernet.UseRouter = Convert.ToBoolean(completeBuffer[pos + 19]);
                            }
                            catch
                            { }
                        }
                        pos = indexOfByteArray(completeBuffer, startUseIP, position, lenStructure);
                        if (pos > 0)
                        {
                            try
                            {
                                ethernet.UseIp = Convert.ToBoolean(completeBuffer[pos + 19]);
                            }
                            catch
                            { }
                        }
                        pos = indexOfByteArray(completeBuffer, startUseMac, position, lenStructure);
                        if (pos > 0)
                        {
                            try
                            {
                                ethernet.UseIso = Convert.ToBoolean(completeBuffer[pos + 19]);
                            }
                            catch
                            { }
                        }
                    }
                    //read ProfiBus Parametrs
                    startStructure[0] = 0x02;
                    byte[] startAddress = { 0x36, 0x08, 0x00, 0x00, 0x36, 0x08, 0x00, 0x00 };
                    lenStructure = 2000;
                    position = 0;
                    while ((position = indexOfByteArray(completeBuffer, startStructure, position + 1, lengthFile)) >= 0)
                    {
                        int number = BitConverter.ToInt32(completeBuffer, position + 4);//or ToInt16
                        var dp = DPFolders.FirstOrDefault(x => x.TobjId != null && x.TobjId.Any(y => y == number));
                        CPUFolder cpu = null;
                        if ( dp != null)
                            cpu = CPUFolders.FirstOrDefault(x => x.UnitID == dp.UnitID);
                        MpiProfiBusNetworkInterface MpiDP = new MpiProfiBusNetworkInterface() { NetworkInterfaceType = NetworkType.Profibus};
                        if (cpu != null)
                        {
                            if (cpu.NetworkInterfaces == null) cpu.NetworkInterfaces = new List<NetworkInterface>();
                            cpu.NetworkInterfaces.Add(MpiDP);
                        }
                        else continue;

                        int pos = indexOfByteArray(completeBuffer, startAddress, position, lenStructure);
                        if (pos > 0)
                        {
                            try
                            {
                                MpiDP.Address = (int)Convert.ToByte(completeBuffer[pos + 19 + (int)Convert.ToByte(completeBuffer[pos + 8])]);
                            }
                            catch
                            { }
                        }
                        pos = indexOfByteArray(completeBuffer, searchName, position, lenStructure);
                        if (pos > 0)
                        {
                            try
                            {
                                string strName = System.Text.Encoding.Default.GetString(completeBuffer, pos + 25, (int)completeBuffer[pos + 24]);

                                MpiDP.Name = strName;
                            }
                            catch
                            { }
                        }

                    }
                    //read MPI Parametrs
                    startStructure[0] = 0x01;
                    byte[] startMPIAddress = { 0x9A, 0x08, 0x00, 0x00, 0x9A, 0x08, 0x00, 0x00 };
                    lenStructure = 2000;
                    position = 0;
                    while ((position = indexOfByteArray(completeBuffer, startStructure, position + 1, lengthFile)) >= 0)
                    {
                        int number = BitConverter.ToInt32(completeBuffer, position + 4);//or ToInt16
                        var dp = DPFolders.FirstOrDefault(x => x.TobjId != null && x.TobjId.Any(y => y == number));
                        CPUFolder cpu = null;
                        if (dp != null)
                            cpu = CPUFolders.FirstOrDefault(x => x.UnitID == dp.UnitID);

                        MpiProfiBusNetworkInterface MpiDP = new MpiProfiBusNetworkInterface() { NetworkInterfaceType = NetworkType.Mpi };
                        if (cpu != null)
                        {
                            if (cpu.NetworkInterfaces == null) cpu.NetworkInterfaces = new List<NetworkInterface>();
                            cpu.NetworkInterfaces.Add(MpiDP);
                        }
                        else continue;

                        int pos = indexOfByteArray(completeBuffer, startMPIAddress, position, lenStructure);
                        if (pos > 0)
                        {
                            try
                            {
                                MpiDP.Address = (int)Convert.ToByte(completeBuffer[pos + 19 + (int)Convert.ToByte(completeBuffer[pos + 8])]);
                            }
                            catch
                            { }
                        }
                        pos = indexOfByteArray(completeBuffer, searchName, position, lenStructure);
                        if (pos > 0)
                        {
                            try
                            {
                                string strName = System.Text.Encoding.Default.GetString(completeBuffer, pos + 25, (int)completeBuffer[pos + 24]);

                                MpiDP.Name = strName;
                            }
                            catch
                            { }
                        }
                    }
                }
            }
            catch { }
            //union SubModul Cp
            bool repeat;
            do
            {
                repeat = false;
                foreach (var cp in CPFolders.Where(x => x.SubModul != null))
                {
                    if (cp.NetworkInterfaces == null) cp.NetworkInterfaces = new List<NetworkInterface>();
                    cp.NetworkInterfaces.AddRange(cp.SubModul.NetworkInterfaces);
                    CPFolders.Remove(cp.SubModul);
                    cp.SubModul = null;
                    repeat = true;
                    break;
                }
            } while (repeat);
        }
示例#7
0
        //In this Class a UC is converted to a Call and also backwards...
        public static void ConvertUCToCall(S7FunctionBlock myFct, S7ProgrammFolder myFld, BlocksOfflineFolder myblkFld, S7ConvertingOptions myOpt, byte[] addInfoFromBlock)
        {
            if (myOpt.GenerateCallsfromUCs)
            {
                int inBld = 0; //1=nach BLD 1
                S7FunctionBlockRow newRow = null;

                Dictionary<string, string> Parameters = new Dictionary<string, string>();
                List<FunctionBlockRow> retVal = new List<FunctionBlockRow>();
                List<FunctionBlockRow> tempList = new List<FunctionBlockRow>();

                string akPar = "";
                string db = "";
                string label = "";
                bool afterCall = false;
                S7FunctionBlockRow callRow = null;

                for (int n = 0; n < myFct.AWLCode.Count; n++)
                {
                    S7FunctionBlockRow row = (S7FunctionBlockRow)myFct.AWLCode[n];
                    if (row.Command == Mnemonic.opBLD[(int)myOpt.Mnemonic] && ( row.Parameter == "1" ||  row.Parameter == "7") && inBld==0)
                    {
                        retVal.AddRange(tempList);
                        tempList.Clear();

                        Parameters.Clear();
                        db = "";

                        label = row.Label;

                        inBld = Convert.ToInt32(row.Parameter);
                        newRow = null;
                        afterCall = false;
                        callRow = null;
                        tempList.Add(row);
                    }
                    else if (inBld > 0)
                    {
                        tempList.Add(row);
                        if (row.Command == "=" && n > 0 && myFct.AWLCode[n - 1].Command == Mnemonic.opBLD[(int)myOpt.Mnemonic])
                        {
                            //Do nothing, but this line needs to be there!
                        }
                        else if (row.Command == Mnemonic.opU[(int)myOpt.Mnemonic] || row.Command == Mnemonic.opUN[(int)myOpt.Mnemonic] ||
                                 row.Command == Mnemonic.opO[(int)myOpt.Mnemonic] || row.Command == Mnemonic.opON[(int)myOpt.Mnemonic] ||
                                 row.Command == Mnemonic.opO[(int)myOpt.Mnemonic] || row.Command == Mnemonic.opON[(int)myOpt.Mnemonic] ||
                                 row.Command == Mnemonic.opX[(int)myOpt.Mnemonic] || row.Command == Mnemonic.opXN[(int)myOpt.Mnemonic] ||
                                 row.Command == Mnemonic.opL[(int)myOpt.Mnemonic])
                        {
                            akPar = row.Parameter;
                        }
                        else if (row.Command == "AUF")
                        {
                            db = row.Parameter + ".";
                        }
                        else if (row.Command == "CLR")
                        {
                            akPar = "FALSE";
                        }
                        else if (row.Command == "SET")
                        {
                            akPar = "TRUE";
                        }
                        else if ((row.Command == "=") && akPar != "")
                        {
                            if (afterCall == false)
                            {
                                string key = row.Parameter.Replace("L", "").Replace("W", "").Replace("B", "").Replace("D", "");
                                if (!Parameters.ContainsKey(key))
                                    Parameters.Add("P#V " + key, db + akPar);
                            }
                            else
                            {
                                string key = akPar.Replace("L", "").Replace("W", "").Replace("B", "").Replace("D", "");
                                if (!Parameters.ContainsKey(key))
                                    Parameters.Add("P#V " + key, db + row.Parameter);
                            }
                            akPar = "";
                            db = "";
                        }
                        else if (row.Command == Mnemonic.opT[(int)myOpt.Mnemonic] && akPar != "")
                        {
                            if (afterCall == false)
                            {
                                string key = row.Parameter.Replace("L", "").Replace("W", "").Replace("B", "").Replace("D", "");
                                if (!Parameters.ContainsKey(key))
                                    Parameters.Add("P#V " + key + ".0", db + akPar);
                            }
                            else
                            {
                                string key = akPar.Replace("L", "").Replace("W", "").Replace("B", "").Replace("D", "");
                                if (!Parameters.ContainsKey(key))
                                    Parameters.Add("P#V " + key, db + row.Parameter);
                            }
                            akPar = "";
                            db = "";
                        }
                        else if (row.Command == Mnemonic.opUC[(int)myOpt.Mnemonic])
                        {
                            //Commands after a Call --> Out-Para
                            callRow = row;
                            afterCall = true;
                        }
                        else if (row.Command == Mnemonic.opBLD[(int)myOpt.Mnemonic] && (row.Parameter == "2" || row.Parameter == "8"))
                        {
                            //Block Interface auslesen (von FC oder vom Programm)
                            //myFld.BlocksOfflineFolder.GetBlock()
                            S7DataRow para = myblkFld.GetInterface(callRow.Parameter);

                            newRow = new S7FunctionBlockRow();
                            newRow.Command = Mnemonic.opCALL[(int)myOpt.Mnemonic];
                            newRow.Parameter = callRow.Parameter;
                            //newRow.ExtParameter = new List<string>();
                            newRow.CallParameter=new List<S7FunctionBlockParameter>();

                            for (int i = 0; i < callRow.ExtParameter.Count; i++)
                            {
                                string s = callRow.ExtParameter[i];

                                string parnm = "";
                                S7DataRow akRow = Parameter.GetFunctionParameterFromNumber(para, i);
                                if (akRow != null)
                                    parnm = akRow.Name + "";
                                else
                                    parnm = "$$undef";

                                S7FunctionBlockParameter newPar = new S7FunctionBlockParameter();
                                newPar.Name = parnm;
                                if (akRow != null)
                                {
                                    newPar.ParameterDataType = akRow.DataType;
                                    if (akRow.Parent.Name == "OUT")
                                        newPar.ParameterType = S7FunctionBlockParameterDirection.OUT;
                                    else if (akRow.Parent.Name == "IN_OUT")
                                        newPar.ParameterType = S7FunctionBlockParameterDirection.IN_OUT;
                                    else
                                        newPar.ParameterType = S7FunctionBlockParameterDirection.IN;
                                    //newPar.ParameterType
                                }

                                if (akRow != null)
                                {
                                    int posL = s.IndexOf(' ');
                                    int ak_address = 0;
                                    if (posL >= 0)
                                        ak_address = Convert.ToInt32(s.Substring(posL + 1).Split('.')[0]);
                                    else
                                    {
                                        ak_address = Convert.ToInt32(s.Substring(2).Split('.')[0])*8 +
                                                     Convert.ToInt32(s.Substring(2).Split('.')[1]);
                                    }

                                    int lokaldata_address = -1;
                                    if (s.Substring(0, 3) == "P#V")
                                        lokaldata_address = Convert.ToInt32(s.Substring(4).Split('.')[0]);

                                    if (akRow.DataType == S7DataRowType.STRING || akRow.DataType == S7DataRowType.DATE_AND_TIME ||
                                        akRow.DataType == S7DataRowType.STRUCT || akRow.DataType == S7DataRowType.UDT ||
                                        akRow.DataType == S7DataRowType.POINTER || akRow.IsArray)
                                    {
                                        string p1 = Parameters["P#V " + (lokaldata_address + 0).ToString() + ".0"];
                                        string p2 = Parameters["P#V " + (lokaldata_address + 2).ToString() + ".0"];

                                        string tmp = "";
                                        if (p1 != "" && p1 != "0")
                                            tmp += "P#DB" + p1 + "." + p2.Substring(2);
                                        else
                                            tmp += p2;
                                        newPar.Value = tmp;
                                        newRow.CallParameter.Add(newPar);
                                        //newRow.ExtParameter.Add(parnm + tmp);
                                    }
                                    else if (akRow.DataType == S7DataRowType.ANY)
                                    {
                                        string tmp = s;
                                        if (Parameters.ContainsKey("P#V " + (lokaldata_address + 0).ToString() + ".0") &&
                                            Parameters.ContainsKey("P#V " + (lokaldata_address + 2).ToString() + ".0") &&
                                            Parameters.ContainsKey("P#V " + (lokaldata_address + 4).ToString() + ".0") &&
                                            Parameters.ContainsKey("P#V " + (lokaldata_address + 6).ToString() + ".0"))
                                        {
                                            string p1 = Parameters["P#V " + (lokaldata_address + 0).ToString() + ".0"];
                                            string p2 = Parameters["P#V " + (lokaldata_address + 2).ToString() + ".0"];
                                            string p3 = Parameters["P#V " + (lokaldata_address + 4).ToString() + ".0"];
                                            string p4 = Parameters["P#V " + (lokaldata_address + 6).ToString() + ".0"];

                                            tmp = "P#";
                                            if (p3 != "0")
                                                tmp += "DB" + p3 + ".";
                                            tmp += p4.Substring(2);
                                            tmp += " BYTE "; //Todo Parse Byte 1 if the Type is Byte!
                                            tmp += p2;
                                        }
                                        newPar.Value = tmp;
                                        newRow.CallParameter.Add(newPar);
                                        //newRow.ExtParameter.Add(parnm + tmp);
                                    }
                                    else
                                    {
                                        if (Parameters.ContainsKey(s))
                                        {
                                            string par = Parameters[s];
                                            if (akRow.DataType == S7DataRowType.S5TIME && par[0] >= '0' && par[0] <= '9')
                                            {
                                                newPar.Value = Helper.GetS5Time(
                                                                            BitConverter.GetBytes(Convert.ToInt32(par))[1],
                                                                            BitConverter.GetBytes(Convert.ToInt32(par))[0]);
                                                newRow.CallParameter.Add(newPar);
                                                //newRow.ExtParameter.Add(parnm +
                                                //                        Helper.GetS5Time(
                                                //                            BitConverter.GetBytes(Convert.ToInt32(par))[1],
                                                //                            BitConverter.GetBytes(Convert.ToInt32(par))[0]));
                                            }
                                            else if (akRow.DataType == S7DataRowType.TIME && par[0] >= '0' && par[0] <= '9')
                                            {
                                                newPar.Value = Helper.GetDTime(BitConverter.GetBytes(Convert.ToInt32(par)),0);
                                                newRow.CallParameter.Add(newPar);
                                                //newRow.ExtParameter.Add(parnm +
                                                //                        Helper.GetDTime(BitConverter.GetBytes(Convert.ToInt32(par)),0));
                                            }
                                            else if (akRow.DataType == S7DataRowType.CHAR && par[0] == 'B')
                                            {
                                                newPar.Value =
                                                    (char)
                                                    Int32.Parse(par.Substring(5),
                                                                System.Globalization.NumberStyles.AllowHexSpecifier) +
                                                    "'";
                                                newRow.CallParameter.Add(newPar);
                                                //newRow.ExtParameter.Add(parnm + "'" +
                                                //                        (char)Int32.Parse(par.Substring(5), System.Globalization.NumberStyles.AllowHexSpecifier) + "'");
                                            }
                                            else
                                            {
                                                newPar.Value = Parameters[s];
                                                newRow.CallParameter.Add(newPar);
                                                //newRow.ExtParameter.Add(parnm + Parameters[s]);
                                            }
                                        }
                                        else
                                        {
                                            if (akRow.DataType == S7DataRowType.BOOL)
                                            {
                                                newPar.Value = s.Substring(2).Replace('V', 'L');
                                                newRow.CallParameter.Add(newPar);
                                                //newRow.ExtParameter.Add(parnm + s.Substring(2).Replace('V', 'L'));
                                            }
                                            else if (akRow.DataType == S7DataRowType.BLOCK_DB)
                                            {
                                                newPar.Value = "DB" + ak_address.ToString();
                                                newRow.CallParameter.Add(newPar);
                                                //newRow.ExtParameter.Add(parnm + "DB" + ak_address.ToString());
                                            }
                                            else if (akRow.DataType == S7DataRowType.BLOCK_FB)
                                            {
                                                newPar.Value = "FB" + ak_address.ToString();
                                                newRow.CallParameter.Add(newPar);
                                                //newRow.ExtParameter.Add(parnm + "FB" + ak_address.ToString());
                                            }
                                            else if (akRow.DataType == S7DataRowType.BLOCK_FC)
                                            {
                                                newPar.Value = "FC" + ak_address.ToString();
                                                newRow.CallParameter.Add(newPar);
                                            }
                                            else if (akRow.DataType == S7DataRowType.BLOCK_SDB)
                                            {
                                                newPar.Value = "SDB" + ak_address.ToString();
                                                newRow.CallParameter.Add(newPar);
                                            }
                                            else if (akRow.DataType == S7DataRowType.TIMER)
                                            {
                                                newPar.Value = Mnemonic.adT[(int)myOpt.Mnemonic] + ak_address.ToString();
                                                newRow.CallParameter.Add(newPar);
                                            }
                                            else if (akRow.DataType == S7DataRowType.COUNTER)
                                            {
                                                newPar.Value = Mnemonic.adZ[(int)myOpt.Mnemonic] + ak_address.ToString();
                                                newRow.CallParameter.Add(newPar);
                                            }
                                            else
                                            {
                                                string ber = "";
                                                if (s.Substring(0, 5) == "P#DBX")
                                                    ber = "DB";
                                                else if (s.Substring(0, 5) == "P#DIX")
                                                    ber = "DI";
                                                else
                                                    ber = s.Substring(2, 1);

                                                if (akRow.ByteLength == 1)
                                                    ber += "B";
                                                else if (akRow.ByteLength == 2)
                                                    ber += "W";
                                                else if (akRow.ByteLength == 4)
                                                    ber += "D";

                                                newPar.Value = ber.Replace('V', 'L') + ak_address.ToString();
                                                newRow.CallParameter.Add(newPar);
                                                //newRow.ExtParameter.Add(parnm +
                                                //                        ber.Replace('V', 'L') +
                                                //                        ak_address.ToString());

                                            }

                                        }
                                    }
                                }
                            }

                            newRow.CombinedCommands = tempList;
                            newRow.Label = label;

                            int sz = 0;
                            foreach (var functionBlockRow in newRow.CombinedCommands)
                            {
                                sz += ((S7FunctionBlockRow) functionBlockRow).ByteSize;
                            }
                            byte[] mcges=new byte[sz];
                            sz = 0;
                            foreach (var functionBlockRow in newRow.CombinedCommands)
                            {
                                Array.Copy(((S7FunctionBlockRow) functionBlockRow).MC7, 0, mcges, sz, ((S7FunctionBlockRow) functionBlockRow).ByteSize);
                                sz += ((S7FunctionBlockRow)functionBlockRow).ByteSize;
                            }
                            newRow.MC7 = mcges;

                            retVal.Add(newRow);
                            Parameters.Clear();
                            tempList = new List<FunctionBlockRow>();
                            inBld = 0;
                        }
                        else
                        {
                            retVal.AddRange(tempList);
                            tempList.Clear();

                            inBld = 0;
                        }
                    }
                    else
                    {
                        retVal.Add(row);
                    }

                }
                myFct.AWLCode = retVal;
            }
        }
        //In this Class a UC is converted to a Call and also backwards...
        public static void ConvertUCToCall(S7FunctionBlock myFct, S7ProgrammFolder myFld, BlocksOfflineFolder myblkFld, S7ConvertingOptions myOpt, byte[] addInfoFromBlock)
        {
            if (myOpt.GenerateCallsfromUCs)
            {
                int inBld = 0; //1=nach BLD 1
                S7FunctionBlockRow newRow = null;

                Dictionary<string, string> Parameters = new Dictionary<string, string>();
                List<FunctionBlockRow> retVal = new List<FunctionBlockRow>();
                List<FunctionBlockRow> tempList = new List<FunctionBlockRow>();

                string registerDi = "DI";
                string registerDb = "";
                string registerAkku1 = "";
                string registerAkku2 = "";
                string registerAR1 = "";
                string registerAR2 = "";

                string diName = "";
                string akPar = "";
                string db = "";
                string label = "";
                string akku = "";
                bool afterCall = false;
                bool multiInstance = false;
                int multiInstanceOffset = 0;
                Pointer ar2Addr = new Pointer(0,0);

                S7FunctionBlockRow callRow = null;

                for (int n = 0; n < myFct.AWLCode.Count; n++)
                {
                    S7FunctionBlockRow row = (S7FunctionBlockRow)myFct.AWLCode[n];
                    if (row.Command == Mnemonic.opBLD[(int)myOpt.Mnemonic] && (row.Parameter == "1" || row.Parameter == "7" || row.Parameter == "3" || row.Parameter == "16" || row.Parameter == "14") && inBld == 0)
                    {
                        retVal.AddRange(tempList);
                        tempList.Clear();

                        Parameters.Clear();
                        db = "";

                        label = row.Label;

                        inBld = Convert.ToInt32(row.Parameter);
                        newRow = null;
                        afterCall = false;
                        callRow = null;
                        diName = "";

                        multiInstance = false;
                        multiInstanceOffset = 0;
                        ar2Addr = new Pointer(0, 0);

                        tempList.Add(row);
                    }
                    else if (inBld == 1 || inBld == 7)
                    {
                        #region FC Aufruf
                        tempList.Add(row);
                        if (row.Command == "=" && n > 0 && myFct.AWLCode[n - 1].Command == Mnemonic.opBLD[(int)myOpt.Mnemonic])
                        {
                            //Do nothing, but this line needs to be there!
                        }
                        else if (row.Command == Mnemonic.opU[(int)myOpt.Mnemonic] || row.Command == Mnemonic.opUN[(int)myOpt.Mnemonic] ||
                                 row.Command == Mnemonic.opO[(int)myOpt.Mnemonic] || row.Command == Mnemonic.opON[(int)myOpt.Mnemonic] ||
                                 row.Command == Mnemonic.opO[(int)myOpt.Mnemonic] || row.Command == Mnemonic.opON[(int)myOpt.Mnemonic] ||
                                 row.Command == Mnemonic.opX[(int)myOpt.Mnemonic] || row.Command == Mnemonic.opXN[(int)myOpt.Mnemonic] ||
                                 row.Command == Mnemonic.opL[(int)myOpt.Mnemonic])
                        {
                            akPar = row.Parameter;
                        }
                        else if (row.Command == Mnemonic.opAUF[(int)myOpt.Mnemonic])
                        {
                            db = row.Parameter + ".";
                        }
                        else if (row.Command == Mnemonic.opCLR[(int)myOpt.Mnemonic])
                        {
                            akPar = "FALSE";
                        }
                        else if (row.Command == Mnemonic.opSET[(int)myOpt.Mnemonic] )
                        {
                            akPar = "TRUE";
                        }
                        else if (row.Command == Mnemonic.opTAR2[(int)myOpt.Mnemonic])
                        {
                            //look what we need to do here!!!
                        }
                        else if (row.Command == Mnemonic.opPAR2[(int)myOpt.Mnemonic])
                        {
                            //look what we need to do here!!!
                        }
                        else if (row.Command == Mnemonic.opLAR2[(int)myOpt.Mnemonic])
                        {
                            //look what we need to do here!!!
                        }
                        else if (row.Command == Mnemonic.opLAR1[(int)myOpt.Mnemonic])
                        {
                            //look what we need to do here!!!
                        }
                        else if ((row.Command == "=") && akPar != "")
                        {
                            if (afterCall == false)
                            {
                                string key = row.Parameter.Replace("L", "").Replace("W", "").Replace("B", "").Replace("D", "");
                                if (!Parameters.ContainsKey(key))
                                    Parameters.Add("P#V " + key, db + akPar);
                            }
                            else
                            {
                                string key = akPar.Replace("L", "").Replace("W", "").Replace("B", "").Replace("D", "");
                                if (!Parameters.ContainsKey(key))
                                    Parameters.Add("P#V " + key, db + row.Parameter);
                            }
                            akPar = "";
                            db = "";
                        }
                        else if (row.Command == Mnemonic.opT[(int)myOpt.Mnemonic] && akPar != "")
                        {
                            if (afterCall == false)
                            {
                                string key = row.Parameter.Replace("L", "").Replace("W", "").Replace("B", "").Replace("D", "");
                                if (!Parameters.ContainsKey(key))
                                    Parameters.Add("P#V " + key + ".0", db + akPar);
                            }
                            else
                            {
                                string key = akPar.Replace("L", "").Replace("W", "").Replace("B", "").Replace("D", "");
                                if (!Parameters.ContainsKey("P#V " + key))
                                    Parameters.Add("P#V " + key, db + row.Parameter);
                            }
                            akPar = "";
                            db = "";
                        }
                        else if (row.Command == Mnemonic.opT[(int)myOpt.Mnemonic] && akPar == "")
                        {
                            //look what we need to do here!!!
                        }
                        else if (row.Command == Mnemonic.opUC[(int)myOpt.Mnemonic])
                        {
                            //Commands after a Call --> Out-Para
                            callRow = row;
                            afterCall = true;
                        }
                        else if (row.Command == Mnemonic.opBLD[(int)myOpt.Mnemonic] && (row.Parameter == "2" || row.Parameter == "8"))
                        {
                            //Block Interface auslesen (von FC oder vom Programm)
                            S7DataRow para = myblkFld.GetInterface(callRow.Parameter);

                            newRow = new S7FunctionBlockRow();
                            newRow.Command = Mnemonic.opCALL[(int)myOpt.Mnemonic];
                            newRow.Parent = callRow.Parent;
                            newRow.Parameter = callRow.Parameter;
                            newRow.CallParameter = new List<S7FunctionBlockParameter>();

                            for (int i = 0; i < callRow.ExtParameter.Count; i++)
                            {
                                string s = callRow.ExtParameter[i];

                                string parnm = "";
                                S7DataRow akRow = Parameter.GetFunctionParameterFromNumber(para, i);
                                if (akRow != null)
                                    parnm = akRow.Name + "";
                                else
                                    parnm = "$$undef";

                                S7FunctionBlockParameter newPar = new S7FunctionBlockParameter(newRow);
                                newPar.Name = parnm;
                                if (akRow != null)
                                {
                                    newPar.ParameterDataType = akRow.DataType;
                                    if (akRow.Parent.Name == "OUT")
                                        newPar.ParameterType = S7FunctionBlockParameterDirection.OUT;
                                    else if (akRow.Parent.Name == "IN_OUT")
                                        newPar.ParameterType = S7FunctionBlockParameterDirection.IN_OUT;
                                    else
                                        newPar.ParameterType = S7FunctionBlockParameterDirection.IN;
                                }

                                if (akRow != null)
                                {
                                    int posL = s.IndexOf(' ');
                                    int ak_address = 0;
                                    if (posL >= 0)
                                        ak_address = Convert.ToInt32(s.Substring(posL + 1).Split('.')[0]);
                                    else
                                    {
                                        ak_address = Convert.ToInt32(s.Substring(2).Split('.')[0])*8 +
                                                     Convert.ToInt32(s.Substring(2).Split('.')[1]);
                                    }

                                    int lokaldata_address = -1;
                                    if (s.Substring(0, 3) == "P#V")
                                        lokaldata_address = Convert.ToInt32(s.Substring(4).Split('.')[0]);

                                    if (akRow.DataType == S7DataRowType.STRING || akRow.DataType == S7DataRowType.DATE_AND_TIME ||
                                        akRow.DataType == S7DataRowType.STRUCT || akRow.DataType == S7DataRowType.UDT ||
                                        akRow.DataType == S7DataRowType.POINTER || akRow.IsArray)
                                    {
                                        string p1 = "";
                                        string p2 = "";
                                        Parameters.TryGetValue("P#V " + (lokaldata_address + 0).ToString() + ".0", out p1);
                                        Parameters.TryGetValue("P#V " + (lokaldata_address + 2).ToString() + ".0", out p2);

                                        string tmp = "";
                                        if (p1 != "" && p1 != "0")
                                            tmp += "P#DB" + p1 + "." + (p2 == null ? "0" : p2.Substring(2));
                                        else
                                            tmp += p2;
                                        newPar.Value = tmp;
                                        newRow.CallParameter.Add(newPar);
                                    }
                                    else if (akRow.DataType == S7DataRowType.ANY)
                                    {
                                        string tmp = s;
                                        if (Parameters.ContainsKey("P#V " + (lokaldata_address + 0).ToString() + ".0") &&
                                            Parameters.ContainsKey("P#V " + (lokaldata_address + 2).ToString() + ".0") &&
                                            Parameters.ContainsKey("P#V " + (lokaldata_address + 4).ToString() + ".0") &&
                                            Parameters.ContainsKey("P#V " + (lokaldata_address + 6).ToString() + ".0"))
                                        {
                                            string p1 = Parameters["P#V " + (lokaldata_address + 0).ToString() + ".0"];
                                            string p2 = Parameters["P#V " + (lokaldata_address + 2).ToString() + ".0"];
                                            string p3 = Parameters["P#V " + (lokaldata_address + 4).ToString() + ".0"];
                                            string p4 = Parameters["P#V " + (lokaldata_address + 6).ToString() + ".0"];

                                            tmp = "P#";
                                            if (p3 != "0")
                                                tmp += "DB" + p3 + ".";
                                            tmp += p4.Substring(2);
                                            tmp += " BYTE "; //Todo Parse Byte 1 if the Type is Byte!
                                            tmp += p2;
                                        }
                                        newPar.Value = tmp;
                                        newRow.CallParameter.Add(newPar);
                                    }
                                    else
                                    {
                                        if (Parameters.ContainsKey(s))
                                        {
                                            string par = Parameters[s];
                                            if (akRow.DataType == S7DataRowType.S5TIME && par[0] >= '0' && par[0] <= '9')
                                            {
                                                newPar.Value = Helper.GetS5Time(
                                                                            BitConverter.GetBytes(Convert.ToInt32(par))[1],
                                                                            BitConverter.GetBytes(Convert.ToInt32(par))[0]);
                                            }
                                            else if (akRow.DataType == S7DataRowType.TIME && par[0] >= '0' && par[0] <= '9')
                                            {
                                                newPar.Value = Helper.GetDTime(BitConverter.GetBytes(Convert.ToInt32(par)),0);
                                            }
                                            else if (akRow.DataType == S7DataRowType.CHAR && par[0] == 'B')
                                            {
                                                newPar.Value = (char) Int32.Parse(par.Substring(5), System.Globalization.NumberStyles.AllowHexSpecifier) + "'";
                                            }
                                            else
                                            {
                                                newPar.Value = Parameters[s];
                                            }
                                        }
                                        else
                                        {
                                            if (akRow.DataType == S7DataRowType.BOOL)
                                            {
                                                newPar.Value = s.Substring(2).Replace('V', 'L');
                                            }
                                            else if (akRow.DataType == S7DataRowType.BLOCK_DB)
                                            {
                                                newPar.Value = "DB" + ak_address.ToString();
                                            }
                                            else if (akRow.DataType == S7DataRowType.BLOCK_FB)
                                            {
                                                newPar.Value = "FB" + ak_address.ToString();
                                            }
                                            else if (akRow.DataType == S7DataRowType.BLOCK_FC)
                                            {
                                                newPar.Value = "FC" + ak_address.ToString();
                                            }
                                            else if (akRow.DataType == S7DataRowType.BLOCK_SDB)
                                            {
                                                newPar.Value = "SDB" + ak_address.ToString();
                                            }
                                            else if (akRow.DataType == S7DataRowType.TIMER)
                                            {
                                                newPar.Value = Mnemonic.adT[(int)myOpt.Mnemonic] + ak_address.ToString();
                                            }
                                            else if (akRow.DataType == S7DataRowType.COUNTER)
                                            {
                                                newPar.Value = Mnemonic.adZ[(int)myOpt.Mnemonic] + ak_address.ToString();
                                            }
                                            else
                                            {
                                                string ber = "";
                                                if (s.Substring(0, 5) == "P#DBX")
                                                    ber = "DB";
                                                else if (s.Substring(0, 5) == "P#DIX")
                                                    ber = "DI";
                                                else
                                                    ber = s.Substring(2, 1);

                                                if (akRow.ByteLength == 1)
                                                    ber += "B";
                                                else if (akRow.ByteLength == 2)
                                                    ber += "W";
                                                else if (akRow.ByteLength == 4)
                                                    ber += "D";

                                                newPar.Value = ber.Replace('V', 'L') + ak_address.ToString();

                                            }
                                        }

                                        newRow.CallParameter.Add(newPar);
                                    }
                                }
                            }

                            newRow.CombinedCommands = tempList;
                            newRow.Label = label;

                            int sz = 0;
                            foreach (var functionBlockRow in newRow.CombinedCommands)
                            {
                                sz += ((S7FunctionBlockRow) functionBlockRow).ByteSize;
                            }
                            byte[] mcges=new byte[sz];
                            sz = 0;
                            foreach (var functionBlockRow in newRow.CombinedCommands)
                            {
                                Array.Copy(((S7FunctionBlockRow) functionBlockRow).MC7, 0, mcges, sz, ((S7FunctionBlockRow) functionBlockRow).ByteSize);
                                sz += ((S7FunctionBlockRow)functionBlockRow).ByteSize;
                            }
                            newRow.MC7 = mcges;

                            retVal.Add(newRow);
                            Parameters.Clear();
                            tempList = new List<FunctionBlockRow>();
                            inBld = 0;

                            newRow = null;
                        }
                        else
                        {
                            retVal.AddRange(tempList);
                            tempList.Clear();

                            inBld = 0;
                        }
                        #endregion
                    }
                    else if (inBld == 3 || inBld == 16 || inBld == 14)
                    {
                        #region FB Aufruf
                        tempList.Add(row);
                        if (row.Command == "=" && n > 0 && myFct.AWLCode[n - 1].Command == Mnemonic.opBLD[(int)myOpt.Mnemonic])
                        {
                            //Do nothing, but this line needs to be there!
                        }
                        else if (row.Command == Mnemonic.opTDB[(int)myOpt.Mnemonic])
                        {
                            //Do nothing, but this line needs to be there!
                        }
                        else if (row.Command == Mnemonic.opBLD[(int)myOpt.Mnemonic] && row.Parameter=="11")
                        {
                            //whatever this BLD 11 in the FB Calls means...
                        }
                        else if (row.Command == Mnemonic.opTAR2[(int)myOpt.Mnemonic])
                        {
                            if (ar2Addr.MemoryArea==MemoryArea.None)
                                akPar = "P#DIX " + ar2Addr.ToString();
                            else
                                akPar = ar2Addr.ToString(myOpt.Mnemonic);
                        }
                        else if (row.Command == Mnemonic.opLAR2[(int)myOpt.Mnemonic])
                        {
                            if (row.Parameter.StartsWith("P#"))
                            {
                                ar2Addr = new Pointer(row.Parameter.Substring(2));
                            }
                            else
                            {
                                ar2Addr.ByteAddress = 0;
                                ar2Addr.BitAddress = 0;
                            }
                        }
                        else if (row.Command == Mnemonic.opPAR2[(int)myOpt.Mnemonic])
                        {
                            ar2Addr += new Pointer(row.Parameter);
                        }
                        else if (row.Command == Mnemonic.opAUF[(int)myOpt.Mnemonic] && (tempList.Count == 4))
                        {
                            diName = row.Parameter;
                        }
                        else if (row.Command == Mnemonic.opAUF[(int)myOpt.Mnemonic] && row.Parameter.Contains("[") && (tempList.Count == 6))
                        {
                            multiInstance = true;

                            diName = "";
                        }
                        else if (row.Command == Mnemonic.opU[(int)myOpt.Mnemonic] || row.Command == Mnemonic.opUN[(int)myOpt.Mnemonic] ||
                                 row.Command == Mnemonic.opO[(int)myOpt.Mnemonic] || row.Command == Mnemonic.opON[(int)myOpt.Mnemonic] ||
                                 row.Command == Mnemonic.opO[(int)myOpt.Mnemonic] || row.Command == Mnemonic.opON[(int)myOpt.Mnemonic] ||
                                 row.Command == Mnemonic.opX[(int)myOpt.Mnemonic] || row.Command == Mnemonic.opXN[(int)myOpt.Mnemonic] ||
                                 row.Command == Mnemonic.opL[(int)myOpt.Mnemonic])
                        {
                            akPar = db + row.Parameter;
                            db = "";
                        }
                        else if (row.Command == Mnemonic.opAUF[(int)myOpt.Mnemonic])
                        {
                            db = row.Parameter + ".";
                        }
                        else if (row.Command == "CLR")
                        {
                            akPar = "FALSE";
                        }
                        else if (row.Command == "SET")
                        {
                            akPar = "TRUE";
                        }
                        else if ((row.Command == "=") && akPar != "")
                        {
                            if (afterCall == false)
                            {
                                if (!Parameters.ContainsKey(row.Parameter))
                                    Parameters.Add(row.Parameter, akPar);
                            }
                            else
                            {
                                if (!Parameters.ContainsKey(akPar))
                                    Parameters.Add(akPar, row.Parameter);
                            }
                            akPar = "";
                            db = "";
                        }
                        else if (row.Command == Mnemonic.opT[(int)myOpt.Mnemonic] && akPar != "")
                        {
                            if (afterCall == false)
                            {
                                if (!Parameters.ContainsKey(row.Parameter))
                                    Parameters.Add(row.Parameter, akPar);
                            }
                            else
                            {
                                if (!Parameters.ContainsKey(akPar))
                                    Parameters.Add(akPar, row.Parameter);
                            }
                            akPar = "";
                            db = "";
                        }
                        else if (row.Command == Mnemonic.opT[(int)myOpt.Mnemonic])
                        {
                            if (afterCall == false)
                            {
                                if (!Parameters.ContainsKey(row.Parameter))
                                    Parameters.Add(row.Parameter, "");
                            }
                            akPar = "";
                            db = "";
                        }
                        else if (row.Command == Mnemonic.opUC[(int)myOpt.Mnemonic])
                        {
                            multiInstanceOffset = 0;
                            for (int j = tempList.Count - 2; j > -1; j--)
                            {
                                if (tempList[j].Command == Mnemonic.opPAR2[(int)myOpt.Mnemonic])
                                    multiInstanceOffset += (int)double.Parse((((S7FunctionBlockRow)tempList[j]).Parameter.Substring(2)), CultureInfo.InvariantCulture);
                                break;
                            }

                            //Commands after a Call --> Out-Para
                            callRow = row;
                            afterCall = true;
                        }
                        else if (row.Command == Mnemonic.opBLD[(int)myOpt.Mnemonic] && (row.Parameter == "4" || row.Parameter == "17" || row.Parameter == "15"))
                        {
                            //Block Interface auslesen (von FC oder vom Programm)
                            S7DataRow para = myblkFld.GetInterface(callRow.Parameter);

                            newRow = new S7FunctionBlockRow();
                            newRow.Parent = callRow.Parent;
                            newRow.Command = Mnemonic.opCALL[(int)myOpt.Mnemonic];
                            newRow.Parameter = callRow.Parameter;
                            if (diName.Length > 2 && !diName.StartsWith("#"))
                                newRow.DiName = "DI" + int.Parse(diName.Substring(2));
                            else if (diName.StartsWith("#"))
                                newRow.DiName = diName;
                            newRow.CallParameter = new List<S7FunctionBlockParameter>();

                            if (para != null)
                            {
                            var allPar = para.Children.Where(itm => itm.Name == "IN" || itm.Name == "IN_OUT" || itm.Name == "OUT");
                                foreach (var s7DataRowMain in allPar)
                                {
                                    foreach (var s7DataRow in s7DataRowMain.Children)
                                    {
                                        S7FunctionBlockParameter newPar = new S7FunctionBlockParameter(newRow);
                                        newPar.Name = s7DataRow.Name;

                                        string par = null;
                                        if (!multiInstance) Parameters.TryGetValue(((S7DataRow)s7DataRow).BlockAddressInDbFormat.Replace("DB", "DI"), out par);
                                        else if (((S7DataRow)s7DataRow).DataType == S7DataRowType.ANY)
                                        {
                                            var anySizeAddr = ((S7DataRow)s7DataRow).BlockAddress.ByteAddress + multiInstanceOffset + 2;
                                            var anyPosAddr = ((S7DataRow)s7DataRow).BlockAddress.ByteAddress + multiInstanceOffset + 6;

                                            string anySize = "";
                                            string anyPos = "";
                                            Parameters.TryGetValue("DIW[AR2,P#" + anySizeAddr + ".0]", out anySize);
                                            Parameters.TryGetValue("DID[AR2,P#" + anyPosAddr + ".0]", out anyPos);
                                            par = anyPos + " BYTE " + anySize;
                                        }
                                        else
                                        {
                                            var addr = ((S7DataRow)s7DataRow).BlockAddressInDbFormat;
                                            if (!string.IsNullOrEmpty(addr))
                                            {
                                                var addrTp = addr.Substring(0, 3).Replace("DB", "DI");
                                                double bytepos = double.Parse(addr.Substring(3), CultureInfo.InvariantCulture) + multiInstanceOffset;
                                                Parameters.TryGetValue(addrTp + "[AR2,P#" + bytepos.ToString("0.0", CultureInfo.InvariantCulture) + "]", out par);
                                            }
                                        }

                                        if (par != null && par.Contains("[AR2"))
                                        {
                                            newPar.Value = par;
                                            var addr = par.Substring(10);
                                            addr = addr.Substring(0, addr.Length - 1);
                                            var pRow = S7DataRow.GetDataRowWithAddress(myFct.Parameter.Children.Where(itm => itm.Name != "TEMP").Cast<S7DataRow>(), new ByteBitAddress(addr));
                                            if (pRow != null) newPar.Value = ((S7DataRow)pRow).StructuredName.Substring(((S7DataRow)pRow).StructuredName.IndexOf('.') + 1);

                                        }
                                        else
                                        {
                                            switch (((S7DataRow)s7DataRow).DataType)
                                            {
                                                case S7DataRowType.BLOCK_DB:
                                                    newPar.Value = "DB" + par;
                                                    break;
                                                case S7DataRowType.BLOCK_FC:
                                                    newPar.Value = "FC" + par;
                                                    break;
                                                case S7DataRowType.BLOCK_FB:
                                                    newPar.Value = "FB" + par;
                                                    break;
                                                case S7DataRowType.TIMER:
                                                    newPar.Value = Mnemonic.adT[(int)myOpt.Mnemonic] + par.ToString();
                                                    break;
                                                case S7DataRowType.COUNTER:
                                                    newPar.Value = Mnemonic.adZ[(int)myOpt.Mnemonic] + par.ToString();
                                                    break;
                                                case S7DataRowType.TIME:
                                                    if (par != null && par.StartsWith("L#"))
                                                    {
                                                        var arr = BitConverter.GetBytes(Convert.ToInt32(par.Substring(2)));
                                                        Array.Reverse(arr);
                                                        newPar.Value = Helper.GetDTime(arr, 0);
                                                    }
                                                    else
                                                    {
                                                        newPar.Value = par;
                                                    }
                                                    break;
                                                default:
                                                    newPar.Value = par;
                                                    break;
                                            }
                                        }

                                        newRow.CallParameter.Add(newPar);
                                    }
                                }
                            }

                            newRow.CombinedCommands = tempList;
                            newRow.Label = label;

                            int sz = 0;
                            foreach (var functionBlockRow in newRow.CombinedCommands)
                            {
                                sz += ((S7FunctionBlockRow)functionBlockRow).ByteSize;
                            }
                            byte[] mcges = new byte[sz];
                            sz = 0;
                            foreach (var functionBlockRow in newRow.CombinedCommands)
                            {
                                Array.Copy(((S7FunctionBlockRow)functionBlockRow).MC7, 0, mcges, sz, ((S7FunctionBlockRow)functionBlockRow).ByteSize);
                                sz += ((S7FunctionBlockRow)functionBlockRow).ByteSize;
                            }
                            newRow.MC7 = mcges;

                            retVal.Add(newRow);
                            Parameters.Clear();
                            tempList = new List<FunctionBlockRow>();
                            inBld = 0;

                            newRow = null;
                        }
                        else
                        {
                            retVal.AddRange(tempList);
                            tempList.Clear();

                            inBld = 0;
                        }
                        #endregion
                    }
                    else
                    {
                        retVal.Add(row);
                    }

                }
                myFct.AWLCode = retVal;
            }
        }
示例#9
0
        public Block GetBlock(ProjectBlockInfo blkInfo, S7ConvertingOptions myConvOpt)
        {
            //Todo: Enable this, but then myConvOpt is only used the first time!
            //if (blkInfo._Block != null)
            //    return blkInfo._Block;


            ProjectPlcBlockInfo plcblkifo = (ProjectPlcBlockInfo)blkInfo;
            tmpBlock            myTmpBlk  = GetBlockBytes(blkInfo);

            List <Step7Attribute> step7Attributes = null;

            if (myTmpBlk != null)
            {
                if (myTmpBlk.uda != null)
                {
                    int uPos = 2;
                    if (myTmpBlk.uda != null && myTmpBlk.uda.Length > 0 && myTmpBlk.uda[0] > 0)
                    {
                        step7Attributes = new List <Step7Attribute>();
                        for (int j = 0; j < myTmpBlk.uda[0]; j++)
                        {
                            string t1 = Project.ProjectEncoding.GetString(myTmpBlk.uda, uPos + 1, myTmpBlk.uda[uPos]);
                            uPos += myTmpBlk.uda[uPos] + 1;
                            string t2 = Project.ProjectEncoding.GetString(myTmpBlk.uda, uPos + 1, myTmpBlk.uda[uPos]);
                            uPos += myTmpBlk.uda[uPos] + 1;
                            step7Attributes.Add(new Step7Attribute(t1, t2));
                        }
                    }
                }


                //Begin with the Block Reading...
                if (blkInfo.BlockType == PLCBlockType.VAT)
                {
                    S7VATBlock retValBlock = new S7VATBlock(myTmpBlk.mc7code, myTmpBlk.comments, plcblkifo.BlockNumber, Project.ProjectEncoding);
                    retValBlock.Attributes = step7Attributes;

                    retValBlock.LastCodeChange      = myTmpBlk.LastCodeChange;
                    retValBlock.LastInterfaceChange = myTmpBlk.LastInterfaceChange;

                    retValBlock.BlockLanguage = (PLCLanguage)myTmpBlk.Language;

                    return(retValBlock);
                }
                else if (blkInfo.BlockType == PLCBlockType.DB || blkInfo.BlockType == PLCBlockType.UDT)
                {
                    List <string> tmpList = new List <string>();
                    S7DataBlock   retVal  = new S7DataBlock();
                    retVal.IsInstanceDB        = myTmpBlk.IsInstanceDB;
                    retVal.FBNumber            = myTmpBlk.FBNumber;
                    retVal.StructureFromString = Parameter.GetInterfaceOrDBFromStep7ProjectString(myTmpBlk.blkinterface, ref tmpList, blkInfo.BlockType, false, this, retVal, myTmpBlk.mc7code);
                    if (myTmpBlk.blkinterfaceInMC5 != null)
                    {
                        //List<string> tmp = new List<string>();
                        //retVal.StructureFromMC7 = Parameter.GetInterface(myTmpBlk.blkinterfaceInMC5, myTmpBlk.mc7code, ref tmp, blkInfo.BlockType, myTmpBlk.IsInstanceDB, retVal);
                    }
                    retVal.BlockNumber = plcblkifo.BlockNumber;
                    retVal.BlockType   = blkInfo.BlockType;
                    retVal.Attributes  = step7Attributes;

                    retVal.LastCodeChange      = myTmpBlk.LastCodeChange;
                    retVal.LastInterfaceChange = myTmpBlk.LastInterfaceChange;
                    if (blkInfo.BlockType != PLCBlockType.UDT)
                    {
                        retVal.CodeSize = myTmpBlk.mc7code.Length + 36;
                    }

                    retVal.BlockLanguage = (PLCLanguage)myTmpBlk.Language;

                    return(retVal);
                }
                else if (blkInfo.BlockType == PLCBlockType.FC || blkInfo.BlockType == PLCBlockType.FB || blkInfo.BlockType == PLCBlockType.OB || blkInfo.BlockType == PLCBlockType.SFB || blkInfo.BlockType == PLCBlockType.SFC)
                {
                    List <string> ParaList = new List <string>();

                    S7FunctionBlock retVal = new S7FunctionBlock();
                    blkInfo._Block = retVal;

                    retVal.LastCodeChange      = myTmpBlk.LastCodeChange;
                    retVal.LastInterfaceChange = myTmpBlk.LastInterfaceChange;

                    retVal.BlockNumber       = plcblkifo.BlockNumber;
                    retVal.BlockType         = blkInfo.BlockType;
                    retVal.Attributes        = step7Attributes;
                    retVal.KnowHowProtection = myTmpBlk.knowHowProtection;
                    retVal.MnemonicLanguage  = Project.ProjectLanguage;
                    retVal.CodeSize          = myTmpBlk.mc7code.Length + 36;

                    retVal.Author  = myTmpBlk.username;
                    retVal.Version = myTmpBlk.version;

                    //  retVal.Parameter = Parameter.GetInterfaceOrDBFromStep7ProjectString(myTmpBlk.blkinterface, ref ParaList, blkInfo.BlockType, false, this, retVal);

                    if (myTmpBlk.blockdescription != null)
                    {
                        retVal.Title       = Project.ProjectEncoding.GetString(myTmpBlk.blockdescription, 3, myTmpBlk.blockdescription[1] - 4);
                        retVal.Description = Project.ProjectEncoding.GetString(myTmpBlk.blockdescription, myTmpBlk.blockdescription[1], myTmpBlk.blockdescription.Length - myTmpBlk.blockdescription[1] - 1).Replace("\n", Environment.NewLine);
                    }

                    retVal.BlockLanguage = (PLCLanguage)myTmpBlk.Language;

                    return(retVal);

                    if (blkInfo.BlockType == PLCBlockType.FC || blkInfo.BlockType == PLCBlockType.FB || blkInfo.BlockType == PLCBlockType.OB)
                    {
                        int[] Networks;
                        Networks = NetWork.GetNetworks(0, myTmpBlk.nwinfo);

                        S7ProgrammFolder prgFld = null;
                        if (this.Parent is S7ProgrammFolder)
                        {
                            prgFld = (S7ProgrammFolder)this.Parent;
                        }

                        retVal.AWLCode = MC7toAWL.GetAWL(0, myTmpBlk.mc7code.Length - 2, (int)myConvOpt.Mnemonic, myTmpBlk.mc7code, Networks, ParaList, prgFld);

                        retVal.AWLCode = JumpMarks.AddJumpmarks(retVal.AWLCode, myTmpBlk.jumpmarks, myTmpBlk.nwinfo);

                        LocalDataConverter.ConvertLocaldataToSymbols(retVal, myConvOpt);

                        FBStaticAccessConverter.ReplaceStaticAccess(retVal, prgFld, myConvOpt);

                        CallConverter.ConvertUCToCall(retVal, prgFld, this, myConvOpt, null);

                        #region UseComments from Block
                        if (myConvOpt.UseComments)
                        {
                            List <FunctionBlockRow> newAwlCode = new List <FunctionBlockRow>();

                            int n      = 0;
                            int j      = 0;
                            int subCnt = 0; //Counter wich line in Command (for Calls and UCs)

                            if (myTmpBlk.comments != null)
                            {
                                byte[] cmt = myTmpBlk.comments;

                                //string aa = System.Text.Encoding.GetEncoding("Windows-1251").GetString(cmt);
                                //string testaa = "";

                                while (n < myTmpBlk.comments.Length)
                                {
                                    int kommLen            = cmt[n + 0];
                                    int startNWKomm        = cmt[n + 1];
                                    int anzUebsprungZeilen = cmt[n + 2] + cmt[n + 3] * 0x100;
                                    int lenNWKommZeile     = cmt[n + 3] + cmt[n + 4] * 0x100;
                                    //Console.WriteLine(cmt[n + 5].ToString("X"));
                                    if (cmt[n + 5] == 0x06)
                                    {
                                        //NWKomentar:
                                        string tx1 = Project.ProjectEncoding.GetString(cmt, n + 6, startNWKomm - 7);
                                        string tx2 = Project.ProjectEncoding.GetString(cmt, n + startNWKomm, lenNWKommZeile - startNWKomm - 1).Replace("\n", Environment.NewLine);
                                        n += lenNWKommZeile;

                                        if (retVal.AWLCode.Count > j)
                                        {
                                            while (retVal.AWLCode.Count - 1 > j && retVal.AWLCode[j].Command != "NETWORK")
                                            {
                                                newAwlCode.Add(retVal.AWLCode[j]);
                                                j++;
                                            }
                                            ((S7FunctionBlockRow)retVal.AWLCode[j]).NetworkName = tx1;
                                            ((S7FunctionBlockRow)retVal.AWLCode[j]).Comment     = tx2;
                                            newAwlCode.Add(retVal.AWLCode[j]);
                                        }
                                        j++;

                                        subCnt = 0;
                                    }
                                    else
                                    {
                                        S7FunctionBlockRow lastRow = null;

                                        //Anzahl der Anweisungen vor diesem Kommentar (inklusive aktueller Zeile!)
                                        for (int q = 0; q < (anzUebsprungZeilen); q++)
                                        {
                                            if (retVal.AWLCode.Count > j)
                                            {
                                                S7FunctionBlockRow akRw = (S7FunctionBlockRow)retVal.AWLCode[j];

                                                if (cmt[n + 4] == 0xc0 && q == anzUebsprungZeilen - 1)
                                                {
                                                    akRw.CombineDBAccess = false;
                                                }

                                                //Db Zugriff zusammenfügen...
                                                if (akRw.CombineDBAccess)
                                                {
                                                    S7FunctionBlockRow nRw = (S7FunctionBlockRow)retVal.AWLCode[j + 1];
                                                    nRw.Parameter = akRw.Parameter + "." + nRw.Parameter;
                                                    nRw.MC7       = Helper.CombineByteArray(akRw.MC7, nRw.MC7);

                                                    akRw = nRw;
                                                    retVal.AWLCode.RemoveAt(j + 1);
                                                }


                                                if (akRw.GetNumberOfLines() == 1)
                                                {
                                                    subCnt = 0;

                                                    lastRow = akRw;

                                                    newAwlCode.Add(akRw);
                                                    j++;
                                                }
                                                else
                                                {
                                                    lastRow = akRw;
                                                    if (subCnt == 0)
                                                    {
                                                        newAwlCode.Add(akRw);
                                                    }

                                                    if (akRw.GetNumberOfLines() - 1 == subCnt)
                                                    {
                                                        j++;
                                                        //subCnt = 0;
                                                        subCnt++;
                                                    }
                                                    else
                                                    {
                                                        subCnt++;
                                                    }
                                                }
                                            }
                                        }


                                        //if (lastRow == null || cmt[n + 4] != 0x80)
                                        if (lastRow == null || (cmt[n + 4] != 0x80 && cmt[n + 4] != 0xc0))
                                        {
                                            lastRow = new S7FunctionBlockRow();
                                            newAwlCode.Add(lastRow);
                                            subCnt = 0;
                                        }

                                        string tx1 = Project.ProjectEncoding.GetString(cmt, n + 6, kommLen);
                                        if (subCnt == 0)
                                        {
                                            lastRow.Comment = tx1;
                                        }
                                        else
                                        if (lastRow.Command == "CALL")
                                        {
                                            if (subCnt == 1)
                                            {
                                                lastRow.Comment = tx1;
                                            }
                                            else
                                            {
                                                lastRow.CallParameter[subCnt - 2].Comment = tx1;
                                            }
                                        }
                                        n += kommLen + 6;

                                        //subCnt = 0;
                                    }
                                }
                            }
                            while (j < retVal.AWLCode.Count)
                            {
                                newAwlCode.Add(retVal.AWLCode[j]);
                                j++;
                            }
                            retVal.AWLCode = newAwlCode;
                        }
                        #endregion
                    }

                    retVal.Networks = NetWork.GetNetworksList(retVal);

                    retVal.ParentFolder = this;

                    return(retVal);
                }
            }
            return(null);
        }
示例#10
0
        public static S7Block GetAWLBlock(byte[] MC7Code, int MnemoricLanguage, S7ProgrammFolder prjBlkFld)
        {
            /*
            string ttmp = "";
            for (int i = 0; i < MC7Code.Length; i++)
            {
                ttmp += MC7Code[i].ToString("X").PadLeft(2, '0');
            }
            MessageBox.Show(ttmp);
            Clipboard.SetText(ttmp);
            */

            S7Block retBlock = null;
            if (MC7Code != null)
            {
                if ((MC7Code[5] == 0x0a) || (MC7Code[5] == 0x0b))
                    retBlock = (S7Block) new S7DataBlock();
                else
                    retBlock = (S7Block)new S7FunctionBlock();

                const int MC7Start_or_DBBodyStart = 36;

                /*
                 * Description of a MC7 Block (Common)
                 *
                 * 0,1     = Signature ('pp')
                 * 2       = Block Version
                 * 3       = Block Attribute (.0 not unlinked, .1 standart block + know how protect, .3 know how protect, .5 not retain
                 * 4       = Block Language
                 * 5       = Block Type (a=DB, b=SDB)
                 * 6,7     = Block Number
                 * 8-11    = Block Length
                 * 12-15   = Block Password
                 * 16-21   = Last Modified
                 * 22-27   = Last Interface Change
                 * 28,29   = Interface length or DB Body (actual Values Part) length
                 * 30,31   = Segment Table Length?  (Normaly 0 on a DB) (Length of networks!)
                 * 32,33   = Local Data Length? (Normaly 0 on a DB)
                 * 34,35   = MC7-Length or DB Body (definitions/initial values)
                 */

                /*
                 * Description of a MC7 Block (Function - Block)
                 * 36-xx     = AWL
                 * xx+1,     = 0x01
                 * xx+2,xx+3 = Again Block number, Zero on OB            (but bytes swapped)
                 * xx+4,xx+5 = Interface Length (from xx+6 to yy)
                 * xx+6,xx+7 = Interface Blocks Count (In,Out,Satic,TMP etc) * 2
                 * xx+8,xx+9 = allways Zero
                 * xx+10-yy  = Interface
                 * yy+1-zz   = Networks
                 *
                 */

                /*
                 * Description of a MC7 Block (Data - Block)
                 * 36-xx   = AWL
                 * xx+1,     = 0x05 (DB) 0x10 (DI)
                 * xx+2,xx+3 = Again Block Number or FB Number on a DI   (but bytes swapped)
                 * xx+4,xx+5 = Interface Length
                 * xx+6-yy   = Interface
                 * yy-zz   = Start-Values
                 * xx      = Nertworks
                 */

                retBlock.BlockVersion = Convert.ToString(MC7Code[2] - 1);
                retBlock.BlockAttribute = Convert.ToString(MC7Code[3] - 1);
                retBlock.BlockLanguage = (DataTypes.PLCLanguage) MC7Code[4]; // Enum.Parse(typeof(DataTypes.PLCLanguage), Helper.GetLang(MC7Code[4]));
                retBlock.MnemonicLanguage = (MnemonicLanguage)MnemoricLanguage;
                retBlock.BlockType = Helper.GetPLCBlockType(MC7Code[5]);
                retBlock.BlockNumber = (MC7Code[6]*0x100) + MC7Code[7];
                retBlock.Length = libnodave.getU32from(MC7Code, 8);
                retBlock.Password = new byte[] {MC7Code[12], MC7Code[13], MC7Code[14], MC7Code[15]};
                retBlock.LastCodeChange = Helper.GetDT(MC7Code[16], MC7Code[17], MC7Code[18], MC7Code[19], MC7Code[20], MC7Code[21]);
                retBlock.LastInterfaceChange = Helper.GetDT(MC7Code[22], MC7Code[23], MC7Code[24], MC7Code[25], MC7Code[26], MC7Code[27]);

                int InterfaceLength_or_DBActualValuesLength = libnodave.getU16from(MC7Code, 28);
                retBlock.SegmentTableSize = libnodave.getU16from(MC7Code, 30); //(Length of networks?)
                int LocalDataLength = libnodave.getU16from(MC7Code, 32);
                int MC7Length_or_DBBodyLength = libnodave.getU16from(MC7Code, 34);
                int IntfStart = MC7Start_or_DBBodyStart + MC7Length_or_DBBodyLength + 3;
                int IntfLength = BitConverter.ToUInt16(MC7Code, IntfStart) + 2;
                int IntfValStart = IntfStart + IntfLength + 2;

                retBlock.InterfaceSize = InterfaceLength_or_DBActualValuesLength;
                retBlock.LocalDataSize = LocalDataLength;
                retBlock.CodeSize = MC7Length_or_DBBodyLength;

                int FooterStart = MC7Start_or_DBBodyStart + MC7Length_or_DBBodyLength + InterfaceLength_or_DBActualValuesLength + retBlock.SegmentTableSize;
                retBlock.Author = Helper.GetString(FooterStart + 0 , 8, MC7Code);
                retBlock.Family = Helper.GetString(FooterStart + 8, 8, MC7Code);
                retBlock.Name = Helper.GetString(FooterStart + 16, 8, MC7Code);
                retBlock.Version = Helper.GetVersion(MC7Code[FooterStart + 24]);

                if ((MC7Code[5] == 0x0a) || (MC7Code[5] == 0x0b))
                {
                    //Instance DB??
                    if (MC7Code[MC7Start_or_DBBodyStart + MC7Length_or_DBBodyLength] == 0x0a)
                    {
                        ((S7DataBlock) retBlock).IsInstanceDB = true;
                        ((S7DataBlock)retBlock).FBNumber = BitConverter.ToUInt16(MC7Code, MC7Start_or_DBBodyStart + MC7Length_or_DBBodyLength + 1);
                    }
                    //((PLCDataBlock) retBlock).Structure = MC7toDB.GetDBInterface(IntfStart, IntfLength, AWLStart, IntfValStart, MC7Code);

                    /*var interf = new byte[IntfLength];
                    Array.Copy(MC7Code, IntfStart, interf, 0, IntfLength);
                    string wr = "";
                    for (int i=0;i<interf.Length-1;i=i+2)
                    {
                        wr += interf[i+1].ToString("X").PadLeft(2, '0');
                        wr += interf[i].ToString("X").PadLeft(2, '0');
                    }
                    wr = wr;*/
                    List<string> tmp = new List<string>();
                    var interfaceBytes = new byte[IntfLength + 3];
                    var actualValues = new byte[MC7Length_or_DBBodyLength];
                    Array.Copy(MC7Code, IntfStart - 3, interfaceBytes, 0, IntfLength + 3); //-3 because of in the project file in the structere ssbpart is also the same structure with this 4 bytes!!
                    Array.Copy(MC7Code, MC7Start_or_DBBodyStart, actualValues, 0, MC7Length_or_DBBodyLength);

                    ((S7DataBlock)retBlock).StructureFromMC7 = Parameter.GetInterface(interfaceBytes, actualValues, ref tmp, retBlock.BlockType, ((S7DataBlock)retBlock).IsInstanceDB, retBlock);

                }
                else
                {
                    var interfaceBytes = new byte[IntfLength + 3];
                    Array.Copy(MC7Code, IntfStart - 3, interfaceBytes, 0, IntfLength + 3); //-3 because of in the project file in the structere ssbpart is also the same structure with this 4 bytes!!

                    List<string> ParaList = new List<string>();
                    ((S7FunctionBlock)retBlock).Parameter = Parameter.GetInterface(interfaceBytes, null, ref ParaList, retBlock.BlockType, false, retBlock);

                    int[] Networks;
                    Networks = NetWork.GetNetworks(MC7Start_or_DBBodyStart + MC7Length_or_DBBodyLength + InterfaceLength_or_DBActualValuesLength, MC7Code);
                    ((S7FunctionBlock) retBlock).AWLCode = MC7toAWL.GetAWL(MC7Start_or_DBBodyStart, MC7Length_or_DBBodyLength - 2, MnemoricLanguage, MC7Code, Networks, ParaList, prjBlkFld);

                    ((S7FunctionBlock) retBlock).Networks = NetWork.GetNetworksList((S7FunctionBlock) retBlock);
                }

            }
            return retBlock;
        }
        public static S7Block GetAWLBlock(byte[] MC7Code, int MnemoricLanguage, S7ProgrammFolder prjBlkFld)
        {
            var retBlock = GetAWLBlockBasicInfo(MC7Code, MnemoricLanguage);


            if (retBlock != null)
            {

                int IntfStart = MC7Start_or_DBBodyStart + retBlock.CodeSize + 3;
                int IntfLength = BitConverter.ToUInt16(MC7Code, IntfStart) + 2;
                int IntfValStart = IntfStart + IntfLength + 2;

                if ((MC7Code[5] == 0x0a) || (MC7Code[5] == 0x0b))
                {
                    //Instance DB??
                    if (MC7Code[MC7Start_or_DBBodyStart + retBlock.CodeSize] == 0x0a)
                    {
                        ((S7DataBlock)retBlock).IsInstanceDB = true;
                        ((S7DataBlock)retBlock).FBNumber = BitConverter.ToUInt16(MC7Code, MC7Start_or_DBBodyStart + retBlock.CodeSize + 1);
                    }
                    //((PLCDataBlock) retBlock).Structure = MC7toDB.GetDBInterface(IntfStart, IntfLength, AWLStart, IntfValStart, MC7Code);

                    /*var interf = new byte[IntfLength];
                    Array.Copy(MC7Code, IntfStart, interf, 0, IntfLength);
                    string wr = "";
                    for (int i=0;i<interf.Length-1;i=i+2)
                    {
                        wr += interf[i+1].ToString("X").PadLeft(2, '0');
                        wr += interf[i].ToString("X").PadLeft(2, '0');
                    }
                    wr = wr;*/
                    List<string> tmp = new List<string>();
                    var interfaceBytes = new byte[IntfLength + 3];
                    var actualValues = new byte[retBlock.CodeSize];
                    Array.Copy(MC7Code, IntfStart - 3, interfaceBytes, 0, IntfLength + 3); //-3 because of in the project file in the structere ssbpart is also the same structure with this 4 bytes!!
                    Array.Copy(MC7Code, MC7Start_or_DBBodyStart, actualValues, 0, retBlock.CodeSize);

                    ((S7DataBlock)retBlock).StructureFromMC7 = Parameter.GetInterface(interfaceBytes, actualValues, ref tmp, retBlock.BlockType, ((S7DataBlock)retBlock).IsInstanceDB, retBlock);

                }
                else
                {
                    var interfaceBytes = new byte[IntfLength + 3];
                    Array.Copy(MC7Code, IntfStart - 3, interfaceBytes, 0, IntfLength + 3); //-3 because of in the project file in the structere ssbpart is also the same structure with this 4 bytes!!

                    List<string> ParaList = new List<string>();
                    ((S7FunctionBlock)retBlock).Parameter = Parameter.GetInterface(interfaceBytes, null, ref ParaList, retBlock.BlockType, false, retBlock);

                    int[] Networks;
                    Networks = NetWork.GetNetworks(MC7Start_or_DBBodyStart + retBlock.CodeSize + retBlock.InterfaceSize, MC7Code);
                    ((S7FunctionBlock)retBlock).AWLCode = MC7toAWL.GetAWL(MC7Start_or_DBBodyStart, retBlock.CodeSize - 2, MnemoricLanguage, MC7Code, Networks, ParaList, prjBlkFld, (S7FunctionBlock)retBlock);

                    ((S7FunctionBlock)retBlock).Networks = NetWork.GetNetworksList((S7FunctionBlock)retBlock);
                }


            }
            return retBlock;
        }
示例#12
0
        internal static List<FunctionBlockRow> GetAWL(int Start, int Count, int MN, byte[] BD, int[] Networks, List<string> ParaList, S7ProgrammFolder prjBlkFld)
        {
            var retVal = new List<FunctionBlockRow>();

            //bool CombineDBOpenAndCommand = false; // true; // false; //If DB Open and Acess should be One AWL Line (like in Step 7). This should be a Parameter.

            int NWNr = 1;

            int pos = Start;

            int counter = 0;
            int oldpos = pos;

            while (pos <= (Start + Count) - 2)
            {
                //if (retVal.Count >103)  //For Bugfixing, The Rownumber in the AWL Editor - 2
                //    pos=pos;

                if (Networks != null)
                    NetWork.NetworkCheck(ref Networks, ref retVal, ref counter, oldpos, pos, ref NWNr);
                oldpos = pos;

                if (BD[pos] == 0x00 && BD[pos + 1] == 0x00)
                {
                    retVal.Add(new S7FunctionBlockRow()
                                   {
                                       Command = Mnemonic.opNOP[MN],
                                       Parameter = "0"
                                   });

                    ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                    pos += 2;
                }
                else if (BD[pos] == 0x01 && BD[pos + 1] == 0x00)
                {
                    retVal.Add(new S7FunctionBlockRow() {Command = Mnemonic.opINVI[MN]});
                    ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] {BD[pos], BD[pos + 1]};
                    pos += 2;
                }
                else if (BD[pos] == 0x05 && BD[pos + 1] == 0x00)
                {
                    retVal.Add(new S7FunctionBlockRow() {Command = Mnemonic.opBEB[MN]});
                    ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] {BD[pos], BD[pos + 1]};
                    pos += 2;
                }
                else if (BD[pos] == 0x09 && BD[pos + 1] == 0x00)
                {
                    retVal.Add(new S7FunctionBlockRow() {Command = Mnemonic.opNEGI[MN]});
                    ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] {BD[pos], BD[pos + 1]};
                    pos += 2;
                }
                else if (BD[pos] == 0x49 && BD[pos + 1] == 0x00)
                {
                    retVal.Add(new S7FunctionBlockRow() {Command = Mnemonic.opOW[MN]});
                    ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] {BD[pos], BD[pos + 1]};
                    pos += 2;
                }
                else if (BD[pos] == 0x00 || BD[pos] == 0x01 || BD[pos] == 0x05 || BD[pos] == 0x09 || BD[pos] == 0x49)
                {
                    string curr_op = "";
                    string curr_ad = "";
                    int HighByte = BD[pos + 1] & 0xF0; //Only Highbyte
                    switch (BD[pos])
                    {
                        case (0x00):
                            curr_op = HighByte < 0x90 ? Mnemonic.opU[MN] : Mnemonic.opUN[MN];
                            break;
                        case (0x01):
                            curr_op = HighByte < 0x90 ? Mnemonic.opO[MN] : Mnemonic.opON[MN];
                            break;
                        case (0x05):
                            curr_op = HighByte < 0x90 ? Mnemonic.opX[MN] : Mnemonic.opXN[MN];
                            break;
                        case (0x09):
                            curr_op = HighByte < 0x90 ? Mnemonic.opS[MN] : Mnemonic.opR[MN];
                            break;
                        case (0x49):
                            curr_op = HighByte < 0x90 ? Mnemonic.opFP[MN] : Mnemonic.opFN[MN];
                            break;
                    }

                    string par = "";
                    byte[] DBByte = null;

                    switch (HighByte)
                    {
                        case (0x10):
                        case (0x90):
                            curr_ad = Mnemonic.adE[MN];
                            break;
                        case (0x20):
                        case (0xA0):
                            curr_ad = Mnemonic.adA[MN];
                            break;
                        case (0x30):
                        case (0xB0):
                            curr_ad = Mnemonic.adM[MN];
                            break;
                        case (0x40):
                        case (0xC0):
                            if (retVal[retVal.Count - 1].Command == Mnemonic.opAUF[MN] && !((S7FunctionBlockRow)retVal[retVal.Count - 1]).Parameter.Contains("["))// && CombineDBOpenAndCommand)
                            {
                                ((S7FunctionBlockRow) retVal[retVal.Count - 1]).CombineDBAccess = true;
                                //DBByte = ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7;
                                //par = ((S7FunctionBlockRow)retVal[retVal.Count - 1]).Parameter + ".";
                                //retVal.RemoveAt(retVal.Count - 1);
                            }
                            curr_ad = Mnemonic.adDBX[MN];
                            break;
                        case (0x50):
                        case (0xD0):
                            curr_ad = Mnemonic.adDIX[MN];
                            break;
                        case (0x60):
                        case (0xE0):
                            curr_ad = Mnemonic.adL[MN];
                            break;
                    }
                    int LowByte = BD[pos + 1] & 0x0F;

                    retVal.Add(new S7FunctionBlockRow()
                                   {
                                       Command = curr_op,
                                       Parameter =
                                           par + curr_ad + " " + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + "." +
                                           Convert.ToString(BD[pos + 1] - HighByte)
                                   });
                    ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                    if (DBByte != null)
                        ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = Helper.CombineByteArray(DBByte, ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7);

                    pos += 4;

                }
                else
                    switch (BD[pos])
                    {
                        case 0x00:
                            {
                                switch (BD[pos + 1])
                                {
                                    case 0x00:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opNOP[MN], Parameter = "0" });
                                        //Result = Result + Memnoic.opNOP[MN] + "0";
                                        ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                        pos += 2;
                                        break;
                                    default:
                                        retVal.Add(new S7FunctionBlockRow() { Command = "errx" });
                                        ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                        pos += 4;
                                        break;
                                }
                            }
                            break;
                        case 0x02:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opL[MN], Parameter = Mnemonic.adT[MN] + Convert.ToString(BD[pos + 1]) });
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x04:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opFR[MN], Parameter = Mnemonic.adT[MN] + Convert.ToString(BD[pos + 1]) });
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x0A:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opL[MN], Parameter = Mnemonic.adMB[MN] + Convert.ToString(BD[pos + 1]) });
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x0B:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opT[MN], Parameter = Mnemonic.adMB[MN] + Convert.ToString(BD[pos + 1]) });
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x0C:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opLC[MN], Parameter = Mnemonic.adT[MN] + Convert.ToString(BD[pos + 1]) });
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x10:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opBLD[MN], Parameter = Convert.ToString(BD[pos + 1]) });
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x11:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opINC[MN], Parameter = Convert.ToString(BD[pos + 1]) });
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x12:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opL[MN], Parameter = Mnemonic.adMW[MN] + Convert.ToString(BD[pos + 1]) });
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x13:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opT[MN], Parameter = Mnemonic.adMW[MN] + Convert.ToString(BD[pos + 1]) });
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x14:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opSA[MN], Parameter = Mnemonic.adT[MN] + Convert.ToString(BD[pos + 1]) });
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x19:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opDEC[MN], Parameter = Convert.ToString(BD[pos + 1]) });
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x1A:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opL[MN], Parameter = Mnemonic.adMD[MN] + Convert.ToString(BD[pos + 1]) });
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x1b:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opT[MN], Parameter = Mnemonic.adMD[MN] + Convert.ToString(BD[pos + 1]) });
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x1C:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opSV[MN], Parameter = Mnemonic.adT[MN] + Convert.ToString(BD[pos + 1]) });
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x1D:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opCC[MN], Parameter = Mnemonic.adFC[MN] + Convert.ToString(BD[pos + 1]) });
                                //Result = Result + Memnoic.opCC[MN] + Memnoic.adFC[MN] + Convert.ToString(BD[pos + 1]);
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3], BD[pos + 4], BD[pos + 5] };
                                pos += 6;
                            }
                            break;
                        case 0x20:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opAUF[MN], Parameter = Mnemonic.adDB[MN] + Convert.ToString(BD[pos + 1]) });
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x21:
                            {
                                switch (BD[pos + 1])
                                {
                                    case 0x20:
                                        retVal.Add(new S7FunctionBlockRow() { Command = ">I" });
                                        break;
                                    case 0x40:
                                        retVal.Add(new S7FunctionBlockRow() { Command = "<I" });
                                        break;
                                    case 0x60:
                                        retVal.Add(new S7FunctionBlockRow() { Command = "<>I" });
                                        break;
                                    case 0x80:
                                        retVal.Add(new S7FunctionBlockRow() { Command = "==I" });
                                        break;
                                    case 0xA0:
                                        retVal.Add(new S7FunctionBlockRow() { Command = ">=I" });
                                        break;
                                    case 0xC0:
                                        retVal.Add(new S7FunctionBlockRow() { Command = "<=I" });
                                        break;
                                }
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x24:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opSE[MN], Parameter = Mnemonic.adT[MN] + Convert.ToString(BD[pos + 1]) });
                                //Result = Result + Memnoic.opSE[MN] + Memnoic.adT[MN] + Convert.ToString(BD[pos + 1]);
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x28:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opL[MN], Parameter = "B#16#" + (BD[pos + 1]).ToString("X") });
                                //Result = Result + Memnoic.opL[MN] + "B#16#" + (BD[pos + 1]).ToString("X");
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x29:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opSLD[MN], Parameter = (BD[pos + 1]).ToString() });
                                //Result = Result + Memnoic.opSLD[MN] + Convert.ToString(BD[pos + 1]);
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x2C:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opSS[MN], Parameter = Mnemonic.adT[MN] + Convert.ToString(BD[pos + 1]) });
                                //Result = Result + Memnoic.opSS[MN] + Memnoic.adT[MN] + Convert.ToString(BD[pos + 1]);
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x30:
                            {
                                //Result = Result + Memnoic.opL[MN];
                                string par = "";
                                switch (BD[pos + 1])
                                {
                                    case 0x02:
                                        //Result = Result + "2#" + Helper.GetWordBool(BD[pos + 2], BD[pos + 3]);
                                        par = "2#" + Helper.GetWordBool(BD[pos + 2], BD[pos + 3]);
                                        break;
                                    case 0x03:
                                        par = Convert.ToString(libnodave.getS16from(BD, pos + 2)); //Helper.GetInt(BD[pos + 2], BD[pos + 3]));
                                        //Result = Result + Convert.ToString(Helper.GetInt(BD[pos + 2], BD[pos + 3]));
                                        break;
                                    case 0x05:
                                        par = Helper.GetS7String(pos + 2, 2, BD);
                                        //Result = Result + Helper.GetS7String(pos + 2, 2, BD);
                                        break;
                                    case 0x06:
                                        par = "B#(" + Convert.ToString(BD[pos + 2]) + ", " +
                                                 Convert.ToString(BD[pos + 3]) + ")";
                                        break;
                                    case 0x00:
                                    case 0x07:
                                        par = "W#16#" + libnodave.getU16from(BD, pos + 2).ToString("X"); // Helper.GetWord(BD[pos + 2], BD[pos + 3]).ToString("X");
                                        //Result = Result + "W#16#" +
                                        //         Helper.GetWord(BD[pos + 2], BD[pos + 3]).ToString("X");
                                        break;
                                    case 0x08:
                                        par = "C#" + libnodave.getU16from(BD, pos + 2).ToString("X"); // Helper.GetWord(BD[pos + 2], BD[pos + 3]).ToString("X");
                                        //Result = Result + "C#" + Helper.GetWord(BD[pos + 2], BD[pos + 3]).ToString("X");
                                        break;
                                    case 0x0A:
                                        par = Helper.GetDate(BD[pos + 2], BD[pos + 3]);
                                        //Result = Result + Helper.GetDate(BD[pos + 2], BD[pos + 3]);
                                        break;
                                    case 0x0C:
                                        par = Helper.GetS5Time(BD[pos + 2], BD[pos + 3]);
                                        //Result = Result + Helper.GetS5Time(BD[pos + 2], BD[pos + 3]);
                                        break;
                                }
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opL[MN], Parameter = par });
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                pos += 4;
                            }
                            break;
                        case 0x31:
                            {
                                switch (BD[pos + 1])
                                {
                                    case 0x20:
                                        //Result = Result + ">R";
                                        retVal.Add(new S7FunctionBlockRow() { Command = ">R" });
                                        break;
                                    case 0x40:
                                        retVal.Add(new S7FunctionBlockRow() { Command = "<R" });
                                        //Result = Result + "<R";
                                        break;
                                    case 0x60:
                                        retVal.Add(new S7FunctionBlockRow() { Command = "<>R" });
                                        //Result = Result + "<>R";
                                        break;
                                    case 0x80:
                                        retVal.Add(new S7FunctionBlockRow() { Command = "==R" });
                                        //Result = Result + "==R";
                                        break;
                                    case 0xA0:
                                        retVal.Add(new S7FunctionBlockRow() { Command = ">=R" });
                                        //Result = Result + ">=R";
                                        break;
                                    case 0xC0:
                                        retVal.Add(new S7FunctionBlockRow() { Command = "<=R" });
                                        //Result = Result + "<=R";
                                        break;
                                }
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x34:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opSI[MN], Parameter = Mnemonic.adT[MN] + Convert.ToString(BD[pos + 1]) });
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x38:
                            {
                                string par = "";
                                switch (BD[pos + 1])
                                {
                                    case 0x01:
                                        par = libnodave.getFloatfrom(BD, pos + 2).ToString("0.000000e+000");
                                        break;
                                    case 0x02:
                                        par = "2#" +
                                                 Helper.GetDWordBool(BD[pos + 2], BD[pos + 3], BD[pos + 4], BD[pos + 5]);
                                        break;
                                    case 0x03:
                                        par = "L#" + Convert.ToString(libnodave.getS32from(BD, pos + 2));
                                        //par = "L#" + Convert.ToString(Helper.GetDInt(BD[pos + 2], BD[pos + 3], BD[pos + 4], BD[pos + 5]));
                                        break;
                                    case 0x04:
                                        par = Helper.GetPointer(BD,pos+2);
                                        break;
                                    case 0x05:
                                        par = Helper.GetS7String(pos + 2, 4, BD);
                                        break;
                                    case 0x06:
                                        par = "B#(" + Convert.ToString(BD[pos + 2]) + ", " +
                                                 Convert.ToString(BD[pos + 3]) + ", " + Convert.ToString(BD[pos + 4]) +
                                                 ", " +
                                                 Convert.ToString(BD[pos + 5]) + ")";
                                        break;
                                    case 0x07:
                                        //par = "DW#16#" + Helper.GetDWord(BD[pos + 2], BD[pos + 3], BD[pos + 4], BD[pos + 5]).ToString("X");
                                        par = "DW#16#" + libnodave.getU32from(BD, pos + 2).ToString("X");
                                        break;
                                    case 0x09:
                                        par = Helper.GetDTime(BD, pos + 2);
                                        //par = Helper.GetDTime(BD[pos + 2], BD[pos + 3], BD[pos + 4], BD[pos + 5]);
                                        break;
                                    case 0x0b:
                                        //par = Helper.GetTOD(BD[pos + 2], BD[pos + 3], BD[pos + 4], BD[pos + 5]);
                                        par = Helper.GetTOD(BD, pos + 2);
                                        break;
                                }
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opL[MN], Parameter = par });
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3], BD[pos + 4], BD[pos + 5] };
                                pos += 6;
                            }
                            break;
                        case 0x39:
                            {
                                switch (BD[pos + 1])
                                {
                                    case 0x20:
                                        retVal.Add(new S7FunctionBlockRow() { Command = ">D" });
                                        //Result = Result + ">D";
                                        break;
                                    case 0x40:
                                        retVal.Add(new S7FunctionBlockRow() { Command = "<D" });
                                        //Result = Result + "<D";
                                        break;
                                    case 0x60:
                                        retVal.Add(new S7FunctionBlockRow() { Command = "<>D" });
                                        //Result = Result + "<>D";
                                        break;
                                    case 0x80:
                                        retVal.Add(new S7FunctionBlockRow() { Command = "==D" });
                                        //Result = Result + "==D";
                                        break;
                                    case 0xA0:
                                        retVal.Add(new S7FunctionBlockRow() { Command = ">=D" });
                                        //Result = Result + ">=D";
                                        break;
                                    case 0xC0:
                                        retVal.Add(new S7FunctionBlockRow() { Command = "<=D" });
                                        //Result = Result + "<=D";
                                        break;
                                }
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x3C:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opR[MN], Parameter = Mnemonic.adT[MN] + Convert.ToString(BD[pos + 1]) });
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x3D:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opUC[MN], Parameter = Mnemonic.adFC[MN] + Convert.ToString(BD[pos + 1]) });

                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3], BD[pos + 4], BD[pos + 5] };

                                //Get Parameter Count
                                int paranz = (BD[pos + 5] / 2) - 1;
                                List<string> tmplst = new List<string>();
                                for (int n = 1; n <= paranz; n++)
                                {
                                    tmplst.Add(Helper.GetFCPointer(BD[pos + 6], BD[pos + 7], BD[pos + 8], BD[pos + 9]));
                                    ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = Helper.CombineByteArray(((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7, new byte[] { BD[pos + 6], BD[pos + 7], BD[pos + 8], BD[pos + 9] });
                                    pos += 4;
                                }
                                byte[] backup = ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7;
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).ExtParameter = tmplst;
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = backup;

                                pos += 6;
                            }
                            break;
                        case 0x41:
                            {
                                switch (BD[pos + 1])
                                {
                                    case 0x00:
                                        {
                                            retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opUW[MN] });
                                            //Result = Result + Memnoic.opUW[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x10:
                                    case 0x11:
                                    case 0x12:
                                    case 0x13:
                                    case 0x14:
                                    case 0x15:
                                    case 0x16:
                                    case 0x17:
                                        retVal.Add(new S7FunctionBlockRow()
                                        {
                                            Command = Mnemonic.opZUW[MN],
                                            Parameter = Mnemonic.adE[MN] +
                                                Convert.ToString(libnodave.getU16from(BD, pos + 2)) + "." +
                                                Convert.ToString(BD[pos + 1] - 0x10)
                                        });
                                        //Result = Result + Memnoic.opZUW[MN] + Memnoic.adE[MN] +
                                        //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3])) + "." +
                                        //         Convert.ToString(BD[pos + 1] - 0x10);
                                        ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                        pos += 4;
                                        break;
                                    case 0x20:
                                    case 0x21:
                                    case 0x22:
                                    case 0x23:
                                    case 0x24:
                                    case 0x25:
                                    case 0x26:
                                    case 0x27:
                                        retVal.Add(new S7FunctionBlockRow()
                                        {
                                            Command = Mnemonic.opZUW[MN],
                                            Parameter = Mnemonic.adA[MN] +
                                                Convert.ToString(libnodave.getU16from(BD, pos + 2)) + "." +
                                                Convert.ToString(BD[pos + 1] - 0x20)
                                        });
                                        //Result = Result + Memnoic.opZUW[MN] + Memnoic.adA[MN] +
                                        //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3])) + "." +
                                        //         Convert.ToString(BD[pos + 1] - 0x20);
                                        ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                        pos += 4;
                                        break;
                                    case 0x30:
                                    case 0x31:
                                    case 0x32:
                                    case 0x33:
                                    case 0x34:
                                    case 0x35:
                                    case 0x36:
                                    case 0x37:
                                        retVal.Add(new S7FunctionBlockRow()
                                        {
                                            Command = Mnemonic.opZUW[MN],
                                            Parameter = Mnemonic.adM[MN] +
                                                Convert.ToString(libnodave.getU16from(BD, pos + 2)) + "." +
                                                Convert.ToString(BD[pos + 1] - 0x30)
                                        });
                                        ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                        pos += 4;
                                        break;
                                    case 0x40:  //Zuweisung with DB
                                    case 0x41:
                                    case 0x42:
                                    case 0x43:
                                    case 0x44:
                                    case 0x45:
                                    case 0x46:
                                    case 0x47:
                                        {
                                            string par = "";
                                            byte[] DBByte = null;
                                            if (retVal[retVal.Count - 1].Command == Mnemonic.opAUF[MN] && !((S7FunctionBlockRow)retVal[retVal.Count - 1]).Parameter.Contains("["))// && CombineDBOpenAndCommand)
                                            {
                                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).CombineDBAccess = true;
                                                //DBByte = ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7;
                                                //par = ((S7FunctionBlockRow)retVal[retVal.Count - 1]).Parameter + ".";
                                                //retVal.RemoveAt(retVal.Count - 1);
                                            }
                                            retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opZUW[MN], Parameter = par + Mnemonic.adDBX[MN] + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + "." + Convert.ToString(BD[pos + 1] - 0x40) });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            if (DBByte != null)
                                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = Helper.CombineByteArray(DBByte, ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7);
                                            pos += 4;
                                            break;
                                        }
                                    case 0x50: //Zuweisung with DI
                                    case 0x51:
                                    case 0x52:
                                    case 0x53:
                                    case 0x54:
                                    case 0x55:
                                    case 0x56:
                                    case 0x57:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                                           {
                                                               Command = Mnemonic.opZUW[MN],
                                                               Parameter = Mnemonic.adDIX[MN] +
                                                                           Convert.ToString(libnodave.getU16from(BD, pos + 2)) +
                                                                           "." +
                                                                           Convert.ToString(BD[pos + 1] - 0x50)
                                                           });
                                            //Result = Result + Memnoic.opZUW[MN] + Memnoic.adDIX[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3])) + "." +
                                            //         Convert.ToString(BD[pos + 1] - 0x50);
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                            break;
                                        }
                                    case 0x60://Zuweisung without DB
                                    case 0x61:
                                    case 0x62:
                                    case 0x63:
                                    case 0x64:
                                    case 0x65:
                                    case 0x66:
                                    case 0x67:
                                        retVal.Add(new S7FunctionBlockRow()
                                        {
                                            Command = Mnemonic.opZUW[MN],
                                            Parameter = Mnemonic.adL[MN] +
                                                Convert.ToString(libnodave.getU16from(BD, pos + 2)) + "." +
                                                Convert.ToString(BD[pos + 1] - 0x60)
                                        });
                                        //Result = Result + Memnoic.opZUW[MN] + Memnoic.adL[MN] +
                                        //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3])) + "." +
                                        //         Convert.ToString(BD[pos + 1] - 0x60);
                                        ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                        pos += 4;
                                        break;
                                    default:
                                        retVal.Add(new S7FunctionBlockRow() { Command = "erra" });
                                        ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                        pos += 4;
                                        break;
                                }
                            }
                            break;
                        case 0x42:
                            {
                                retVal.Add(new S7FunctionBlockRow()
                                {
                                    Command = Mnemonic.opL[MN],
                                    Parameter = Mnemonic.adZ[MN] + Convert.ToString(BD[pos + 1])
                                });
                                //Result = Result + Memnoic.opL[MN] + Memnoic.adZ[MN] + Convert.ToString(BD[pos + 1]);
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x44:
                            {
                                retVal.Add(new S7FunctionBlockRow()
                                {
                                    Command = Mnemonic.opFR[MN],
                                    Parameter = Mnemonic.adZ[MN] + Convert.ToString(BD[pos + 1])
                                });
                                //Result = Result + Memnoic.opFR[MN] + Memnoic.adZ[MN] + Convert.ToString(BD[pos + 1]);
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x4A:
                            {
                                if (BD[pos + 1] < 0x80)
                                    retVal.Add(new S7FunctionBlockRow()
                                                   {
                                                       Command = Mnemonic.opL[MN],
                                                       Parameter = Mnemonic.adEB[MN] + Convert.ToString(BD[pos + 1])
                                                   });
                                //Result = Result + Memnoic.opL[MN] + Memnoic.adEB[MN] + Convert.ToString(BD[pos + 1]);
                                else
                                    retVal.Add(new S7FunctionBlockRow()
                                    {
                                        Command = Mnemonic.opL[MN],
                                        Parameter = Mnemonic.adAB[MN] + Convert.ToString(BD[pos + 1] - 0x80)
                                    });
                                //Result = Result + Memnoic.opL[MN] + Memnoic.adAB[MN] + Convert.ToString(BD[pos + 1] - 0x80);
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x4b:
                            {
                                if (BD[pos + 1] < 0x80)
                                    retVal.Add(new S7FunctionBlockRow()
                                                   {
                                                       Command = Mnemonic.opT[MN],
                                                       Parameter = Mnemonic.adEB[MN] + Convert.ToString(BD[pos + 1])
                                                   });
                                //Result = Result + Memnoic.opT[MN] + Memnoic.adEB[MN] + Convert.ToString(BD[pos + 1]);
                                else
                                    retVal.Add(new S7FunctionBlockRow()
                                                   {
                                                       Command = Mnemonic.opT[MN],
                                                       Parameter = Mnemonic.adAB[MN] + Convert.ToString(BD[pos + 1] - 0x80)
                                                   });
                                //Result = Result + Memnoic.opT[MN] + Memnoic.adAB[MN] + Convert.ToString(BD[pos + 1] - 0x80);
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x4C:
                            {
                                retVal.Add(new S7FunctionBlockRow()
                                {
                                    Command = Mnemonic.opLC[MN],
                                    Parameter = Mnemonic.adZ[MN] + Convert.ToString(BD[pos + 1])
                                });
                                //Result = Result + Memnoic.opLC[MN] + Memnoic.adZ[MN] + Convert.ToString(BD[pos + 1]);
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x51:
                        case 0x58:
                        case 0x59:
                            {

                                string cmd = "", par = "";

                                if (BD[pos + 1] == 0x00)
                                {
                                    switch (BD[pos])
                                    {
                                        case 0x51:
                                            cmd = Mnemonic.opXOW[MN];
                                            retVal.Add(new S7FunctionBlockRow() { Command = cmd});
                                    ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                    pos += 2;
                                            break;
                                        case 0x58:
                                            cmd = Mnemonic.opPLU[MN];
                                            retVal.Add(new S7FunctionBlockRow()
                                                           {
                                                               Command = cmd,
                                                               Parameter = libnodave.getS16from(BD, pos + 2).ToString()
                                                           });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[]
                                                                               {
                                                                                   BD[pos], BD[pos + 1], BD[pos + 2],
                                                                                   BD[pos + 3]
                                                                               };
                                    pos += 4;
                                            break;
                                        case 0x59:
                                            cmd = "-I";
                                            retVal.Add(new S7FunctionBlockRow() { Command = cmd});
                                    ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                    pos += 2;
                                            break;
                                    }

                                }
                                else
                                {
                                    int LowByte = BD[pos + 1] & 0x0F; //Only Highbyte
                                    switch (BD[pos])
                                    {
                                        case 0x51:
                                            if (BD[pos + 1] < 0xb0)
                                                cmd = LowByte < 0x09 ? Mnemonic.opU[MN] : Mnemonic.opO[MN];
                                            else
                                                cmd = LowByte < 0x09 ? Mnemonic.opUN[MN] : Mnemonic.opON[MN];
                                            break;
                                        case 0x58:
                                            if (BD[pos + 1] < 0xb0)
                                                cmd = LowByte < 0x09 ? Mnemonic.opX[MN] : Mnemonic.opS[MN];
                                            else
                                                cmd = LowByte < 0x09 ? Mnemonic.opXN[MN] : Mnemonic.opR[MN];
                                            break;
                                        case 0x59:
                                            if (BD[pos + 1] < 0xb0)
                                                cmd = LowByte < 0x09 ? Mnemonic.opZUW[MN] : Mnemonic.opFP[MN];
                                            else
                                                cmd = LowByte < 0x09 ? "err1" : Mnemonic.opFN[MN];//Don't know the Low Byte command
                                            break;
                                    }
                                    switch (BD[pos + 1] & 0x0F)
                                    {
                                        case 0x01:
                                        case 0x09:
                                            par = Mnemonic.adE[MN];
                                            break;
                                        case 0x02:
                                        case 0x0A:
                                            par = Mnemonic.adA[MN];
                                            break;
                                        case 0x03:
                                        case 0x0B:
                                            par = Mnemonic.adM[MN];
                                            break;
                                        case 0x04:
                                        case 0x0C:
                                            par = Mnemonic.adDBX[MN];
                                            break;
                                        case 0x05:
                                        case 0x0D:
                                            par = Mnemonic.adDIX[MN];
                                            break;
                                        case 0x06:
                                        case 0x0E:
                                            par = Mnemonic.adL[MN];
                                            break;

                                    }

                                    switch (BD[pos + 1] & 0xF0)
                                    {

                                        case 0x30:
                                        case 0xb0:
                                            par += Mnemonic.adMD[MN] + Convert.ToString(libnodave.getU16from(BD, pos + 2)) +
                                                   "]";
                                            break;
                                        case 0x40:
                                        case 0xc0:
                                            par += Mnemonic.adDBD[MN] + Convert.ToString(libnodave.getU16from(BD, pos + 2)) +
                                                   "]";
                                            break;
                                        case 0x50:
                                        case 0xd0:
                                            par += Mnemonic.adDID[MN] + Convert.ToString(libnodave.getU16from(BD, pos + 2)) +
                                                   "]";
                                            break;
                                        case 0x60:
                                        case 0xe0:
                                            par += Mnemonic.adLD[MN] + Convert.ToString(libnodave.getU16from(BD, pos + 2)) +
                                                   "]";
                                            break;
                                        case 0x70:
                                        case 0xf0:
                                            par += Mnemonic.adMD[MN] + Convert.ToString(libnodave.getU16from(BD, pos + 2)) +
                                                   "]";
                                            break;
                                    }
                                    ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                    retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                    pos += 4;
                                }

                            }
                            break;
                        case 0x52:
                            {
                                if (BD[pos + 1] < 0x80)
                                    retVal.Add(new S7FunctionBlockRow()
                                                   {
                                                       Command = Mnemonic.opL[MN],
                                                       Parameter = Mnemonic.adEW[MN] + Convert.ToString(BD[pos + 1])
                                                   });
                                else
                                    retVal.Add(new S7FunctionBlockRow()
                                                   {
                                                       Command = Mnemonic.opL[MN],
                                                       Parameter = Mnemonic.adAW[MN] + Convert.ToString(BD[pos + 1] - 0x80)
                                                   });
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x53:
                            {
                                    if (BD[pos + 1] < 0x80)
                                        retVal.Add(new S7FunctionBlockRow()
                                                       {
                                                           Command = Mnemonic.opT[MN],
                                                           Parameter = Mnemonic.adEW[MN] + Convert.ToString(BD[pos + 1])
                                                       });
                                    //Result = Result + Memnoic.opT[MN] + Memnoic.adEW[MN] + Convert.ToString(BD[pos + 1]);
                                    else
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opT[MN],
                                                Parameter = Mnemonic.adAW[MN] + Convert.ToString(BD[pos + 1] - 0x80)
                                            });
                                //Result = Result + Memnoic.opT[MN] + Memnoic.adAW[MN] + Convert.ToString(BD[pos + 1] - 0x80);
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x54:
                            {
                                if (BD[pos + 1] < 0x80)
                                    retVal.Add(new S7FunctionBlockRow()
                                    {
                                        Command = Mnemonic.opZR[MN],
                                        Parameter = Mnemonic.adZ[MN] + Convert.ToString(BD[pos + 1])
                                    });
                                //Result = Result + Memnoic.opZR[MN] + Memnoic.adZ[MN] + Convert.ToString(BD[pos + 1]);
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x55:
                            {
                                if (BD[pos + 1] < 0x80)
                                    retVal.Add(new S7FunctionBlockRow()
                                    {
                                        Command = Mnemonic.opCC[MN],
                                        Parameter = Mnemonic.adFB[MN] + Convert.ToString(BD[pos + 1])
                                    });
                                //Result = Result + Memnoic.opCC[MN] + Memnoic.adFB[MN] + Convert.ToString(BD[pos + 1]);
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x5A:
                            {
                                if (BD[pos + 1] < 0x80)
                                    retVal.Add(new S7FunctionBlockRow()
                                                   {
                                                       Command = Mnemonic.opL[MN],
                                                       Parameter = Mnemonic.adED[MN] + Convert.ToString(BD[pos + 1])
                                                   });
                                //Result = Result + Memnoic.opL[MN] + Memnoic.adED[MN] + Convert.ToString(BD[pos + 1]);
                                else
                                    retVal.Add(new S7FunctionBlockRow()
                                                   {
                                                       Command = Mnemonic.opL[MN],
                                                       Parameter = Mnemonic.adAD[MN] + Convert.ToString(BD[pos + 1] - 0x80)
                                                   });
                                //Result = Result + Memnoic.opL[MN] + Memnoic.adAD[MN] + Convert.ToString(BD[pos + 1] - 0x80);
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x5b:
                            {
                                if (BD[pos + 1] < 0x80)
                                    retVal.Add(new S7FunctionBlockRow()
                                    {
                                        Command = Mnemonic.opT[MN],
                                        Parameter = Mnemonic.adED[MN] + Convert.ToString(BD[pos + 1])
                                    });
                                else
                                    retVal.Add(new S7FunctionBlockRow()
                                    {
                                        Command = Mnemonic.opT[MN],
                                        Parameter = Mnemonic.adAD[MN] + Convert.ToString(BD[pos + 1])
                                    });
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x5C:
                            {
                                retVal.Add(new S7FunctionBlockRow()
                                {
                                    Command = Mnemonic.opS[MN],
                                    Parameter = Mnemonic.adZ[MN] + Convert.ToString(BD[pos + 1])
                                });
                                //Result = Result + Memnoic.opS[MN] + Memnoic.adZ[MN] + Convert.ToString(BD[pos + 1]);
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x60:
                            {
                                switch (BD[pos + 1])
                                {
                                    case 0x00:
                                        retVal.Add(new S7FunctionBlockRow() { Command = "/I" });
                                        break;
                                    case 0x01:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opMOD[MN] });
                                        break;
                                    case 0x02:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opABS[MN] });
                                        break;
                                    case 0x03:
                                        retVal.Add(new S7FunctionBlockRow() { Command = "/R" });
                                        break;
                                    case 0x04:
                                        retVal.Add(new S7FunctionBlockRow() { Command = "*I" });
                                        break;
                                    case 0x05:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                                           {
                                                               Command = Mnemonic.opPLU[MN],
                                                               Parameter = "L#" + Convert.ToString(libnodave.getS32from(BD, pos + 2))
                                                           });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3], BD[pos + 4], BD[pos + 5] };
                                            pos += 6;
                                            goto brk2;
                                        }
                                        break;
                                    case 0x06:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opNEGR[MN] });
                                        break;
                                    case 0x07:
                                        retVal.Add(new S7FunctionBlockRow() { Command = "*R" });
                                        break;
                                    case 0x08:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opENT[MN] });
                                        break;
                                    case 0x09:
                                        retVal.Add(new S7FunctionBlockRow() { Command = "-D" });
                                        break;
                                    case 0x0A:
                                        retVal.Add(new S7FunctionBlockRow() { Command = "*D" });
                                        break;
                                    case 0x0b:
                                        retVal.Add(new S7FunctionBlockRow() { Command = "-R" });
                                        break;
                                    case 0x0D:
                                        retVal.Add(new S7FunctionBlockRow() { Command = "+D" });
                                        break;
                                    case 0x0E:
                                        retVal.Add(new S7FunctionBlockRow() { Command = "/D" });
                                        break;
                                    case 0x0F:
                                        retVal.Add(new S7FunctionBlockRow() { Command = "+R" });
                                        break;
                                    case 0x10:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opSIN[MN] });
                                        break;
                                    case 0x11:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opCOS[MN] });
                                        break;
                                    case 0x12:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opTAN[MN] });
                                        break;
                                    case 0x13:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opLN[MN] });
                                        break;
                                    case 0x14:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opSQRT[MN] });
                                        break;
                                    case 0x18:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opASIN[MN] });
                                        break;
                                    case 0x19:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opACOS[MN] });
                                        break;
                                    case 0x1A:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opATAN[MN] });
                                        break;
                                    case 0x1b:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opEXP[MN] });
                                        break;
                                    case 0x1C:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opSQR[MN] });
                                        break;
                                }
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                    brk2:
                            break;
                        case 0x61:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opSLW[MN], Parameter = Convert.ToString(BD[pos + 1]) });
                                //Result = Result + Memnoic.opSLW[MN] + Convert.ToString(BD[pos + 1]);
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x64:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opRLD[MN], Parameter = Convert.ToString(BD[pos + 1]) });
                                //Result = Result + Memnoic.opRLD[MN] + Convert.ToString(BD[pos + 1]);
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x65:
                            {
                                switch (BD[pos + 1])
                                {
                                    case 0x00:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opBE[MN] });
                                        //Result = Result + Memnoic.opBE[MN];
                                        break;
                                    case 0x01:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opBEA[MN] });
                                        //Result = Result + Memnoic.opBEA[MN];
                                        break;
                                }
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x68:
                            {
                                switch (BD[pos + 1])
                                {
                                    case 0x06:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opDTR[MN] });
                                        //Result = Result + Memnoic.opDTR[MN];
                                        break;
                                    case 0x07:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opNEGD[MN] });
                                        //Result = Result + Memnoic.opNEGD[MN];
                                        break;
                                    case 0x08:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opITB[MN] });
                                        //Result = Result + Memnoic.opITB[MN];
                                        break;
                                    case 0x0C:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opBTI[MN] });
                                        //Result = Result + Memnoic.opBTI[MN];
                                        break;
                                    case 0x0A:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opDTB[MN] });
                                        //Result = Result + Memnoic.opDTB[MN];
                                        break;
                                    case 0x0D:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opINVD[MN] });
                                        //Result = Result + Memnoic.opINVD[MN];
                                        break;
                                    case 0x0E:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opBTD[MN] });
                                        //Result = Result + Memnoic.opBTD[MN];
                                        break;
                                    case 0x12:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opSLW[MN] });
                                        //Result = Result + Memnoic.opSLW[MN];
                                        break;
                                    case 0x13:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opSLD[MN] });
                                        //Result = Result + Memnoic.opSLD[MN];
                                        break;
                                    case 0x17:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opRLD[MN] });
                                        //Result = Result + Memnoic.opRLD[MN];
                                        break;
                                    case 0x18:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opRLDA[MN] });
                                        //Result = Result + Memnoic.opRLDA[MN];
                                        break;
                                    case 0x1A:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opTAW[MN] });
                                        //Result = Result + Memnoic.opTAW[MN];
                                        break;
                                    case 0x1b:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opTAD[MN] });
                                        //Result = Result + Memnoic.opTAD[MN];
                                        break;
                                    case 0x1C:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opCLR[MN] });
                                        //Result = Result + Memnoic.opCLR[MN];
                                        break;
                                    case 0x1D:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opSET[MN] });
                                        //Result = Result + Memnoic.opSET[MN];
                                        break;
                                    case 0x1E:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opITD[MN] });
                                        //Result = Result + Memnoic.opITD[MN];
                                        break;
                                    case 0x22:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opSRW[MN] });
                                        //Result = Result + Memnoic.opSRW[MN];
                                        break;
                                    case 0x23:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opSRD[MN] });
                                        //Result = Result + Memnoic.opSRD[MN];
                                        break;
                                    case 0x24:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opSSI[MN] });
                                        //Result = Result + Memnoic.opSSI[MN];
                                        break;
                                    case 0x25:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opSSD[MN] });
                                        //Result = Result + Memnoic.opSSD[MN];
                                        break;
                                    case 0x27:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opRRD[MN] });
                                        //Result = Result + Memnoic.opRRD[MN];
                                        break;
                                    case 0x28:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opRRDA[MN] });
                                        //Result = Result + Memnoic.opRRDA[MN];
                                        break;
                                    case 0x2C:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opSAVE[MN] });
                                        //Result = Result + Memnoic.opSAVE[MN];
                                        break;
                                    case 0x2D:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opNOT[MN] });
                                        //Result = Result + Memnoic.opNOT[MN];
                                        break;
                                    case 0x2E:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opPUSH[MN] });
                                        //Result = Result + Memnoic.opPUSH[MN];
                                        break;
                                    case 0x37:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opUD[MN] });
                                        //Result = Result + Memnoic.opUD[MN];
                                        break;
                                    case 0x34:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                                           {
                                                               Command = Mnemonic.opUW[MN],
                                                               Parameter = "W#16#" +
                                                                           (libnodave.getU16from(BD, pos + 2)).ToString("X")
                                                           });
                                            //Result = Result + Memnoic.opUW[MN] + "W#16#" +
                                            //         (Helper.GetWord(BD[pos + 2], BD[pos + 3])).ToString("X");
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                            goto brk1;
                                        }
                                        break;
                                    case 0x36:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opUD[MN],
                                                Parameter = "DW#16#" + (libnodave.getU32from(BD,pos + 2).ToString("X"))
                                            });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3], BD[pos + 4], BD[pos + 5] };
                                            pos += 6;
                                            goto brk1;
                                        }
                                        break;
                                    case 0x3A:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opMCRA[MN] });
                                        //Result = Result + Memnoic.opMCRA[MN];
                                        break;
                                    case 0x3b:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opMCRD[MN] });
                                        //Result = Result + Memnoic.opMCRD[MN];
                                        break;
                                    case 0x3C:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opMCRO[MN] });
                                        //Result = Result + Memnoic.opMCRO[MN];
                                        break;
                                    case 0x3D:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opMCRC[MN] });
                                        //Result = Result + Memnoic.opMCRC[MN];
                                        break;
                                    case 0x3E:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opPOP[MN] });
                                        //Result = Result + Memnoic.opPOP[MN];
                                        break;
                                    case 0x44:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opOW[MN],
                                                Parameter = "W#16#" +
                                                            (libnodave.getU16from(BD, pos + 2)).ToString("X")
                                            });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                            goto brk1;
                                        }
                                        break;
                                    case 0x46:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opOD[MN],
                                                Parameter = "DW#16#" + libnodave.getU32from(BD,pos + 2).ToString("X")
                                            });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3], BD[pos + 4], BD[pos + 5] };
                                            pos += 6;
                                            goto brk1;
                                        }
                                        break;
                                    case 0x47:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opOD[MN] });
                                        break;
                                    case 0x4E:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opLEAVE[MN] });
                                        break;
                                    case 0x54:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opXOW[MN],
                                                Parameter = "W#16#" +
                                                     (libnodave.getU16from(BD, pos + 2)).ToString("X")
                                            });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                            goto brk1;
                                        }
                                        break;
                                    case 0x56:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opXOD[MN],
                                                Parameter = "DW#16#" + libnodave.getU32from(BD, pos + 2).ToString("X")
                                            });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3], BD[pos + 4], BD[pos + 5] };
                                            pos += 6;
                                            goto brk1;
                                        }
                                        break;
                                    case 0x57:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opXOD[MN] });
                                        break;
                                    case 0x5C:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opRND[MN] });
                                        break;
                                    case 0x5D:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opRNDM[MN] });
                                        break;
                                    case 0x5E:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opRNDP[MN] });
                                        break;
                                    case 0x5F:
                                        retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opTRUNC[MN] });
                                        break;
                                    default:
                                        {
                                            if ((BD[pos + 1] & 0x0F) == 0x01)
                                                retVal.Add(new S7FunctionBlockRow()
                                                               {
                                                                   Command = Mnemonic.opSSI[MN],
                                                                   Parameter = Convert.ToString((BD[pos + 1] >> 4) & 0x0F)
                                                               });
                                            else
                                                retVal.Add(new S7FunctionBlockRow() { Command = "err2" });
                                        }
                                        break;
                                }
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                        brk1:
                            break;
                        case 0x69:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opSRW[MN], Parameter = Convert.ToString(BD[pos + 1]) });
                                //Result = Result + Memnoic.opSRW[MN] + Convert.ToString(BD[pos + 1]);
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x6C:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opZV[MN], Parameter = Mnemonic.adZ[MN] + Convert.ToString(BD[pos + 1]) });
                                //Result = Result + Memnoic.opZV[MN] + Memnoic.adZ[MN] + Convert.ToString(BD[pos + 1]);
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x70:
                            {
                                switch (BD[pos + 1])
                                {
                                    case 0x02:
                                        {
                                            retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opTAK[MN] });
                                            //Result = Result + Memnoic.opTAK[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x06:
                                        {
                                            retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opL[MN], Parameter = Mnemonic.adSTW[MN] });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x07:
                                        {
                                            retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opT[MN], Parameter = Mnemonic.adSTW[MN] });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x08:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                                           {
                                                               Command = Mnemonic.opLOOP[MN],
                                                               JumpWidth = libnodave.getS16from(BD, pos + 2)
                                                           });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x09:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                                           {
                                                               Command = Mnemonic.opSPL[MN],
                                                               JumpWidth = libnodave.getS16from(BD, pos + 2)
                                                           });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x0b:
                                        {
                                            retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opSPA[MN], JumpWidth = libnodave.getS16from(BD,pos+2) });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    default:
                                        retVal.Add(new S7FunctionBlockRow() { Command = "err3" });
                                        ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                        pos += 4;
                                        break;
                                }
                            }
                            break;
                        case 0x71:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opSSD[MN], Parameter = Convert.ToString(BD[pos + 1]) });
                                //Result = Result + Memnoic.opSSD[MN] + Convert.ToString(BD[pos + 1]);
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x74:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opRRD[MN], Parameter = Convert.ToString(BD[pos + 1]) });
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x75:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opUC[MN], Parameter = Mnemonic.adFB[MN] + Convert.ToString(BD[pos + 1]) });
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x79:
                            {
                                string cmd = "", par = "";

                                if (BD[pos + 1] == 0x00)
                                {
                                    cmd = "+I";
                                    retVal.Add(new S7FunctionBlockRow() { Command = cmd });
                                    ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                    pos += 2;
                                }
                                else
                                {
                                    int LowByte = BD[pos + 1] & 0x0F;
                                    int HighByte = BD[pos + 1] & 0xF0;
                                    switch (LowByte)
                                    {
                                        case 0x00:
                                        case 0x08:
                                            cmd += (HighByte < 0x90) ? Mnemonic.opU[MN] : Mnemonic.opS[MN];
                                            break;
                                        case 0x01:
                                        case 0x09:
                                            cmd += (HighByte < 0x90) ? Mnemonic.opUN[MN] : Mnemonic.opR[MN];
                                            break;
                                        case 0x02:
                                        case 0x0A:
                                            cmd += (HighByte < 0x90) ? Mnemonic.opO[MN] : Mnemonic.opZUW[MN];
                                            break;
                                        case 0x03:
                                        case 0x0B:
                                            cmd += (HighByte < 0x90) ? Mnemonic.opON[MN] : "err5"; //Ther is no Value for this???
                                            break;
                                        case 0x04:
                                        case 0x0C:
                                            cmd += (HighByte < 0x90) ? Mnemonic.opX[MN] : Mnemonic.opFP[MN];
                                            break;
                                        case 0x05:
                                        case 0x0D:
                                            cmd += (HighByte < 0x90) ? Mnemonic.opXN[MN] : Mnemonic.opFN[MN];
                                            break;
                                    }

                                    switch (HighByte)
                                    {
                                        case 0x10:
                                            par += Mnemonic.adE[MN];
                                            break;
                                        case 0x20:
                                            par += Mnemonic.adA[MN];
                                            break;
                                        case 0x30:
                                            par += Mnemonic.adM[MN];
                                            break;
                                        case 0x40:
                                            par += Mnemonic.adDBX[MN];
                                            break;
                                        case 0x50:
                                            par += Mnemonic.adDIX[MN];
                                            break;
                                        case 0x60:
                                            par += Mnemonic.adL[MN];
                                            break;

                                    }
                                    if (LowByte < 0x08)
                                        par += "[" + Mnemonic.adAR1[MN] + "," +
                                               Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                    else
                                        par += "[" + Mnemonic.adAR2[MN] + "," +
                                               Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                    retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                    ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                    pos += 4;
                                }

                            }
                            break;
                        case 0x7C:
                            {
                                retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opR[MN], Parameter = Mnemonic.adZ[MN] + Convert.ToString(BD[pos + 1]) });
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0x7E:
                        case 0xBE:
                            {
                                string cmd = "", par = "";

                                if (BD[pos + 1] == 0x00)
                                {
                                    cmd = "err6";
                                    retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                    ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                    pos += 2;
                                }
                                else
                                {
                                    int LowByte = BD[pos + 1] & 0x0F;
                                    int HighByte = BD[pos + 1] & 0xF0;
                                    cmd = Mnemonic.opT[MN];
                                    //if (LowByte>= 0x05 && LowByte<=0x09 || LowByte >)
                                    //cmd = (LowByte <= 0x07) ? Memnoic.opL[MN] : Memnoic.opT[MN];
                                    if (LowByte <= 0x04|| ((LowByte >= 0x09) && LowByte <= 0x0c))
                                        cmd = Mnemonic.opL[MN];

                                    switch (HighByte)
                                    {
                                        case 0x00:
                                            switch (LowByte)
                                            {
                                                case 0x01:
                                                case 0x09:
                                                    par += Mnemonic.adPEB[MN];
                                                    break;
                                                case 0x02:
                                                case 0x0A:
                                                    par += Mnemonic.adPEW[MN];
                                                    break;
                                                case 0x03:
                                                case 0x0B:
                                                    par += Mnemonic.adPED[MN];
                                                    break;
                                                case 0x05:
                                                case 0x0D:
                                                    par += Mnemonic.adPAB[MN];
                                                    break;
                                                case 0x06:
                                                case 0x0E:
                                                    par += Mnemonic.adPAW[MN];
                                                    break;
                                                case 0x07:
                                                case 0x0F:
                                                    par += Mnemonic.adPAD[MN];
                                                    break;
                                            }
                                            break;
                                        case 0x10:
                                            switch (LowByte)
                                            {
                                                case 0x01:
                                                case 0x05:
                                                case 0x09:
                                                case 0x0D:
                                                    par += Mnemonic.adEB[MN];
                                                    break;
                                                case 0x02:
                                                case 0x06:
                                                case 0x0A:
                                                case 0x0E:
                                                    par += Mnemonic.adEW[MN];
                                                    break;
                                                case 0x03:
                                                case 0x07:
                                                case 0x0B:
                                                case 0x0F:
                                                    par += Mnemonic.adED[MN];
                                                    break;
                                            }
                                            break;
                                        case 0x20:
                                            switch (LowByte)
                                            {
                                                case 0x01:
                                                case 0x05:
                                                case 0x09:
                                                case 0x0D:
                                                    par += Mnemonic.adAB[MN];
                                                    break;
                                                case 0x02:
                                                case 0x06:
                                                case 0x0A:
                                                case 0x0E:
                                                    par += Mnemonic.adAW[MN];
                                                    break;
                                                case 0x03:
                                                case 0x07:
                                                case 0x0B:
                                                case 0x0F:
                                                    par += Mnemonic.adAD[MN];
                                                    break;
                                            }
                                            break;
                                        case 0x30:
                                            switch (LowByte)
                                            {
                                                case 0x01:
                                                case 0x05:
                                                case 0x09:
                                                case 0x0D:
                                                    par += Mnemonic.adMB[MN];
                                                    break;
                                                case 0x02:
                                                case 0x06:
                                                case 0x0A:
                                                case 0x0E:
                                                    par += Mnemonic.adMW[MN];
                                                    break;
                                                case 0x03:
                                                case 0x07:
                                                case 0x0B:
                                                case 0x0F:
                                                    par += Mnemonic.adMD[MN];
                                                    break;
                                            }
                                            break;
                                        case 0x40:
                                            switch (LowByte)
                                            {
                                                case 0x01:
                                                case 0x05:
                                                case 0x09:
                                                case 0x0D:
                                                    par += Mnemonic.adDBB[MN];
                                                    break;
                                                case 0x02:
                                                case 0x06:
                                                case 0x0A:
                                                case 0x0E:
                                                    par += Mnemonic.adDBW[MN];
                                                    break;
                                                case 0x03:
                                                case 0x07:
                                                case 0x0B:
                                                case 0x0F:
                                                    par += Mnemonic.adDBD[MN];
                                                    break;
                                            }
                                            break;
                                        case 0x50:
                                            switch (LowByte)
                                            {
                                                case 0x01:
                                                case 0x05:
                                                case 0x09:
                                                case 0x0D:
                                                    par += Mnemonic.adDIB[MN];
                                                    break;
                                                case 0x02:
                                                case 0x06:
                                                case 0x0A:
                                                case 0x0E:
                                                    par += Mnemonic.adDIW[MN];
                                                    break;
                                                case 0x03:
                                                case 0x07:
                                                case 0x0B:
                                                case 0x0F:
                                                    par += Mnemonic.adDID[MN];
                                                    break;
                                            }
                                            break;
                                        case 0x60:
                                            switch (LowByte)
                                            {
                                                case 0x01:
                                                case 0x05:
                                                case 0x09:
                                                case 0x0D:
                                                    par += Mnemonic.adLB[MN];
                                                    break;
                                                case 0x02:
                                                case 0x06:
                                                case 0x0A:
                                                case 0x0E:
                                                    par += Mnemonic.adLW[MN];
                                                    break;
                                                case 0x03:
                                                case 0x07:
                                                case 0x0B:
                                                case 0x0F:
                                                    par += Mnemonic.adLD[MN];
                                                    break;
                                            }
                                            break;
                                    }

                                    if (BD[pos] == 0x7E)
                                        par += Convert.ToString(libnodave.getU16from(BD, pos + 2));
                                    else if (BD[pos] == 0xBE)
                                        if (LowByte < 0x09)
                                            par += "[" + Mnemonic.adAR1[MN] + "," +
                                                         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                        else
                                            par += "[" + Mnemonic.adAR2[MN] + "," +
                                                     Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";

                                    //new
                                    byte[] DBByte = null;
                                    if (retVal[retVal.Count - 1].Command == Mnemonic.opAUF[MN] && par.Substring(0, 2) == "DB")// && CombineDBOpenAndCommand)
                                    {
                                        ((S7FunctionBlockRow)retVal[retVal.Count - 1]).CombineDBAccess = true;
                                        //DBByte = ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7;
                                        //par = ((S7FunctionBlockRow)retVal[retVal.Count - 1]).Parameter + "." + par;
                                        //retVal.RemoveAt(retVal.Count - 1);
                                    }
                                    retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                    ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                    if (DBByte != null)
                                        ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = Helper.CombineByteArray(DBByte, ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7);
                                    pos += 4;

                                    //old
                                    //retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                    //((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                    //pos += 4;
                                }

                            }
                            break;

                        case 0x80:
                        case 0x81:
                        case 0x82:
                        case 0x83:
                        case 0x84:
                        case 0x85:
                        case 0x86:
                        case 0x87:
                            retVal.Add(new S7FunctionBlockRow()
                                           {
                                               Command = Mnemonic.opU[MN],
                                               Parameter = Mnemonic.adM[MN] + Convert.ToString(BD[pos + 1]) + "." +
                                                           Convert.ToString(BD[pos] - 0x80)
                                           });
                            //Result = Result + Memnoic.opU[MN] + Memnoic.adM[MN] + Convert.ToString(BD[pos + 1]) + "." +
                            //         Convert.ToString(BD[pos] - 0x80);
                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                            pos += 2;
                            break;
                        case 0x88:
                        case 0x89:
                        case 0x8A:
                        case 0x8B:
                        case 0x8C:
                        case 0x8D:
                        case 0x8E:
                        case 0x8F:
                            retVal.Add(new S7FunctionBlockRow()
                            {
                                Command = Mnemonic.opO[MN],
                                Parameter = Mnemonic.adM[MN] + Convert.ToString(BD[pos + 1]) + "." +
                                            Convert.ToString(BD[pos] - 0x88)
                            });
                            //Result = Result + Memnoic.opO[MN] + Memnoic.adM[MN] + Convert.ToString(BD[pos + 1]) + "." +
                            //         Convert.ToString(BD[pos] - 0x88);
                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                            pos += 2;
                            break;
                        case 0x90:
                        case 0x91:
                        case 0x92:
                        case 0x93:
                        case 0x94:
                        case 0x95:
                        case 0x96:
                        case 0x97:
                            retVal.Add(new S7FunctionBlockRow()
                            {
                                Command = Mnemonic.opS[MN],
                                Parameter = Mnemonic.adM[MN] + Convert.ToString(BD[pos + 1]) + "." +
                                            Convert.ToString(BD[pos] - 0x90)
                            });
                            //Result = Result + Memnoic.opS[MN] + Memnoic.adM[MN] + Convert.ToString(BD[pos + 1]) + "." +
                            //         Convert.ToString(BD[pos] - 0x90);
                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                            pos += 2;
                            break;
                        case 0x98:
                        case 0x99:
                        case 0x9A:
                        case 0x9B:
                        case 0x9C:
                        case 0x9D:
                        case 0x9E:
                        case 0x9F:
                            retVal.Add(new S7FunctionBlockRow()
                            {
                                Command = Mnemonic.opZUW[MN],
                                Parameter = Mnemonic.adM[MN] + Convert.ToString(BD[pos + 1]) + "." +
                                            Convert.ToString(BD[pos] - 0x98)
                            });
                            //Result = Result + Memnoic.opZUW[MN] + Memnoic.adM[MN] + Convert.ToString(BD[pos + 1]) + "." +
                            //         Convert.ToString(BD[pos] - 0x98);
                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                            pos += 2;
                            break;
                        case 0xA0:
                        case 0xA1:
                        case 0xA2:
                        case 0xA3:
                        case 0xA4:
                        case 0xA5:
                        case 0xA6:
                        case 0xA7:
                            retVal.Add(new S7FunctionBlockRow()
                            {
                                Command = Mnemonic.opUN[MN],
                                Parameter = Mnemonic.adM[MN] + Convert.ToString(BD[pos + 1]) + "." +
                                            Convert.ToString(BD[pos] - 0xA0)
                            });
                            //Result = Result + Memnoic.opUN[MN] + Memnoic.adM[MN] + Convert.ToString(BD[pos + 1]) + "." +
                            //         Convert.ToString(BD[pos] - 0xA0);
                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                            pos += 2;
                            break;
                        case 0xA8:
                        case 0xA9:
                        case 0xAA:
                        case 0xAB:
                        case 0xAC:
                        case 0xAD:
                        case 0xAE:
                        case 0xAF:
                            retVal.Add(new S7FunctionBlockRow()
                            {
                                Command = Mnemonic.opON[MN],
                                Parameter = Mnemonic.adM[MN] + Convert.ToString(BD[pos + 1]) + "." +
                                            Convert.ToString(BD[pos] - 0xA8)
                            });
                            //Result = Result + Memnoic.opON[MN] + Memnoic.adM[MN] + Convert.ToString(BD[pos + 1]) + "." +
                            //         Convert.ToString(BD[pos] - 0xA8);
                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                            pos += 2;
                            break;
                        case 0xB0:
                        case 0xB1:
                        case 0xB2:
                        case 0xB3:
                        case 0xB4:
                        case 0xB5:
                        case 0xB6:
                        case 0xB7:
                            retVal.Add(new S7FunctionBlockRow()
                            {
                                Command = Mnemonic.opR[MN],
                                Parameter = Mnemonic.adM[MN] + Convert.ToString(BD[pos + 1]) + "." +
                                            Convert.ToString(BD[pos] - 0xB0)
                            });
                            //Result = Result + Memnoic.opR[MN] + Memnoic.adM[MN] + Convert.ToString(BD[pos + 1]) + "." +
                            //         Convert.ToString(BD[pos] - 0xB0);
                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                            pos += 2;
                            break;
                        case 0xB8:
                            {
                                retVal.Add(new S7FunctionBlockRow()
                                {
                                    Command = Mnemonic.opU[MN],
                                    Parameter = Mnemonic.adZ[MN] + Convert.ToString(BD[pos + 1])
                                });
                                //Result = Result + Memnoic.opU[MN] + Memnoic.adZ[MN] + Convert.ToString(BD[pos + 1]);
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0xB9:
                            {
                                retVal.Add(new S7FunctionBlockRow()
                                {
                                    Command = Mnemonic.opO[MN],
                                    Parameter = Mnemonic.adZ[MN] + Convert.ToString(BD[pos + 1])
                                });
                                //Result = Result + Memnoic.opO[MN] + Memnoic.adZ[MN] + Convert.ToString(BD[pos + 1]);
                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                pos += 2;
                            }
                            break;
                        case 0xBA:
                        case 0xBB:
                            {
                                int LowByte = BD[pos + 1] & 0x0F;
                                int HighByte = BD[pos + 1] & 0xF0;

                                string cmd = "", par = "";

                                if (BD[pos + 1] == 0x00)
                                {
                                    switch (BD[pos])
                                    {
                                        case 0xBA:
                                            cmd = cmd + Mnemonic.opUO[MN];
                                            break;
                                        case 0xBB:
                                            cmd = cmd + Mnemonic.opOO[MN];
                                            break;
                                    }
                                    retVal.Add(new S7FunctionBlockRow()
                                    {
                                        Command = cmd,
                                        Parameter = par
                                    });
                                    ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                    pos += 2;
                                }
                                else
                                {
                                    cmd += HighByte < 0x80 ? Mnemonic.opL[MN] : Mnemonic.opT[MN];

                                    switch (BD[pos])
                                    {
                                        case 0xBA:
                                            switch (LowByte)
                                            {
                                                case 0x00:
                                                    par += HighByte < 0x80 ? Mnemonic.adPEB[MN] : Mnemonic.adPAB[MN];
                                                    break;
                                                case 0x01:
                                                    par += Mnemonic.adEB[MN];
                                                    break;
                                                case 0x02:
                                                    par += Mnemonic.adAB[MN];
                                                    break;
                                                case 0x03:
                                                    par += Mnemonic.adMB[MN];
                                                    break;
                                                case 0x04:
                                                    par += Mnemonic.adDBB[MN];
                                                    break;
                                                case 0x05:
                                                    par += Mnemonic.adDIB[MN];
                                                    break;
                                                case 0x06:
                                                    par += Mnemonic.adLB[MN];
                                                    break;
                                            }
                                            break;
                                        case 0xBB:
                                            switch (LowByte)
                                            {
                                                case 0x00:
                                                    par += HighByte < 0x80 ? Mnemonic.adPEW[MN] : Mnemonic.adPAW[MN];
                                                    break;
                                                case 0x01:
                                                    par += Mnemonic.adEW[MN];
                                                    break;
                                                case 0x02:
                                                    par += Mnemonic.adAW[MN];
                                                    break;
                                                case 0x03:
                                                    par += Mnemonic.adMW[MN];
                                                    break;
                                                case 0x04:
                                                    par += Mnemonic.adDBW[MN];
                                                    break;
                                                case 0x05:
                                                    par += Mnemonic.adDIW[MN];
                                                    break;
                                                case 0x06:
                                                    par += Mnemonic.adLW[MN];
                                                    break;
                                                case 0x08:
                                                    par += HighByte < 0x80 ? Mnemonic.adPED[MN] : Mnemonic.adPAD[MN];
                                                    break;
                                                case 0x09:
                                                    par += Mnemonic.adED[MN];
                                                    break;
                                                case 0x0A:
                                                    par += Mnemonic.adAD[MN];
                                                    break;
                                                case 0x0B:
                                                    par += Mnemonic.adMD[MN];
                                                    break;
                                                case 0x0C:
                                                    par += Mnemonic.adDBD[MN];
                                                    break;
                                                case 0x0D:
                                                    par += Mnemonic.adDID[MN];
                                                    break;
                                                case 0x0E:
                                                    par += Mnemonic.adLD[MN];
                                                    break;
                                            }
                                            break;
                                    }

                                    switch (HighByte)
                                    {
                                        case 0x00: //Not from old programm, guessed Values!
                                        case 0x80:
                                            par += "[" + Mnemonic.adPED[MN] +
                                                   Convert.ToString(libnodave.getU16from(BD, pos + 2)) +
                                                   "]";
                                            break;
                                        case 0x10://Not from old programm, guessed Values!
                                        case 0x90:
                                            par += "[" + Mnemonic.adED[MN] +
                                                   Convert.ToString(libnodave.getU16from(BD, pos + 2)) +
                                                   "]";
                                            break;
                                        case 0x20://Not from old programm, guessed Values!
                                        case 0xa0:
                                            par += "[" + Mnemonic.adAD[MN] +
                                                   Convert.ToString(libnodave.getU16from(BD, pos + 2)) +
                                                   "]";
                                            break;
                                        case 0x30:
                                        case 0xb0:
                                            par += "[" + Mnemonic.adMD[MN] +
                                                   Convert.ToString(libnodave.getU16from(BD, pos + 2)) +
                                                   "]";
                                            break;
                                        case 0x40:
                                        case 0xc0:
                                            par += "[" + Mnemonic.adDBD[MN] +
                                                   Convert.ToString(libnodave.getU16from(BD, pos + 2)) +
                                                   "]";
                                            break;
                                        case 0x50:
                                        case 0xd0:
                                            par += "[" + Mnemonic.adDID[MN] +
                                                   Convert.ToString(libnodave.getU16from(BD, pos + 2)) +
                                                   "]";
                                            break;
                                        case 0x60:
                                        case 0xe0:
                                            par += "[" + Mnemonic.adLD[MN] +
                                                   Convert.ToString(libnodave.getU16from(BD, pos + 2)) +
                                                   "]";
                                            break;
                                    }
                                    retVal.Add(new S7FunctionBlockRow()
                                    {
                                        Command = cmd,
                                        Parameter = par
                                    });
                                    ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                    pos += 4;
                                }

                            }
                            break;
                        case 0xBF:
                            {
                                string cmd = "", par = "";

                                if (BD[pos + 1] == 0x00)
                                {
                                    cmd = ")";
                                    retVal.Add(new S7FunctionBlockRow()
                                    {
                                        Command = cmd,
                                        Parameter = par
                                    });
                                    ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                    pos += 2;
                                }
                                else
                                {
                                    int LowByte = BD[pos + 1] & 0x0F;
                                    int HighByte = BD[pos + 1] & 0xF0;
                                    switch (LowByte)
                                    {
                                        case 0x00:
                                            cmd += Mnemonic.opU[MN];
                                            break;
                                        case 0x01:
                                            cmd += Mnemonic.opUN[MN];
                                            break;
                                        case 0x02:
                                            cmd += Mnemonic.opO[MN];
                                            break;
                                        case 0x03:
                                            cmd += Mnemonic.opON[MN];
                                            break;
                                        case 0x04:
                                            cmd += Mnemonic.opX[MN];
                                            break;
                                        case 0x05:
                                            cmd += Mnemonic.opXN[MN];
                                            break;
                                        case 0x06:
                                            cmd += Mnemonic.opL[MN];
                                            break;
                                        case 0x08:
                                            cmd += Mnemonic.opFR[MN];
                                            break;
                                        case 0x09:
                                            cmd += Mnemonic.opLC[MN];
                                            break;
                                        case 0x0A:
                                            cmd += HighByte < 0x80 ? Mnemonic.opSA[MN] : Mnemonic.opZR[MN];
                                            break;
                                        case 0x0B:
                                            cmd += HighByte < 0x80 ? Mnemonic.opSV[MN] : Mnemonic.opS[MN];
                                            break;
                                        case 0x0C:
                                            cmd += Mnemonic.opSE[MN];
                                            break;
                                        case 0x0D:
                                            cmd += HighByte < 0x80 ? Mnemonic.opSS[MN] : Mnemonic.opZV[MN];
                                            break;
                                        case 0x0E:
                                            cmd += Mnemonic.opSI[MN];
                                            break;
                                        case 0x0F:
                                            cmd += Mnemonic.opR[MN];
                                            break;
                                    }
                                    if (HighByte < 0x80)
                                        par += Mnemonic.adT[MN];
                                    else
                                        par += Mnemonic.adZ[MN];

                                    switch (HighByte)
                                    {
                                        case 0x00://Guessed Value, not from old PRG
                                        case 0x80:
                                            par += "[" + Mnemonic.adPEW[MN] +
                                                     Convert.ToString(libnodave.getU16from(BD, pos + 2)) + "]";
                                            break;
                                        case 0x10://Guessed Value, not from old PRG
                                        case 0x90:
                                            par += "[" + Mnemonic.adEW[MN] +
                                                     Convert.ToString(libnodave.getU16from(BD, pos + 2)) + "]";
                                            break;
                                        case 0x20://Guessed Value, not from old Prg
                                        case 0xa0:
                                            par += "[" + Mnemonic.adAW[MN] +
                                                     Convert.ToString(libnodave.getU16from(BD, pos + 2)) + "]";
                                            break;
                                        case 0x30:
                                        case 0xb0:
                                            par += "[" + Mnemonic.adMW[MN] +
                                                     Convert.ToString(libnodave.getU16from(BD, pos + 2)) + "]";
                                            break;
                                        case 0x40:
                                        case 0xc0:
                                            par += "[" + Mnemonic.adDBW[MN] +
                                                     Convert.ToString(libnodave.getU16from(BD, pos + 2)) + "]";
                                            break;
                                        case 0x50:
                                        case 0xd0:
                                            par += "[" + Mnemonic.adDIW[MN] +
                                                     Convert.ToString(libnodave.getU16from(BD, pos + 2)) + "]";
                                            break;
                                        case 0x60:
                                        case 0xe0:
                                            par += "[" + Mnemonic.adLW[MN] +
                                                     Convert.ToString(libnodave.getU16from(BD, pos + 2)) + "]";
                                            break;
                                    }
                                    retVal.Add(new S7FunctionBlockRow()
                                    {
                                        Command = cmd,
                                        Parameter = par
                                    });
                                    ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                    pos += 4;
                                }

                            }
                            break;
                        case 0xC0:
                        case 0xC1:
                        case 0xC2:
                        case 0xC3:
                        case 0xC4:
                        case 0xC5:
                        case 0xC6:
                        case 0xC7:
                            if (BD[pos + 1] < 0x80)
                                retVal.Add(new S7FunctionBlockRow()
                                {
                                    Command = Mnemonic.opU[MN],
                                    Parameter = Mnemonic.adE[MN] + Convert.ToString(BD[pos + 1] & 0x7F) + "." +
                                         Convert.ToString(BD[pos] - 0xC0)
                                });
                            //Result = Result + Memnoic.opU[MN] + Memnoic.adE[MN] + Convert.ToString(BD[pos + 1]) + "." +
                            //         Convert.ToString(BD[pos] - 0xC0);
                            else
                                retVal.Add(new S7FunctionBlockRow()
                                {
                                    Command = Mnemonic.opU[MN],
                                    Parameter = Mnemonic.adA[MN] + Convert.ToString(BD[pos + 1] & 0x7F) + "." +
                                         Convert.ToString(BD[pos] - 0xC0)
                                });
                            //Result = Result + Memnoic.opU[MN] + Memnoic.adA[MN] + Convert.ToString(BD[pos + 1] - 0x80) + "." +
                            //         Convert.ToString(BD[pos] - 0xC0);
                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                            pos += 2;

                            break;
                        case 0xC8:
                        case 0xC9:
                        case 0xCA:
                        case 0xCB:
                        case 0xCC:
                        case 0xCD:
                        case 0xCE:
                        case 0xCF:
                            if (BD[pos + 1] < 0x80)
                                retVal.Add(new S7FunctionBlockRow()
                                {
                                    Command = Mnemonic.opO[MN],
                                    Parameter = Mnemonic.adE[MN] + Convert.ToString(BD[pos + 1] & 0x7F) + "." +
                                         Convert.ToString(BD[pos] - 0xC8)
                                });
                            //Result = Result + Memnoic.opO[MN] + Memnoic.adE[MN] + Convert.ToString(BD[pos + 1]) + "." +
                            //         Convert.ToString(BD[pos] - 0xC8);
                            else
                                retVal.Add(new S7FunctionBlockRow()
                                {
                                    Command = Mnemonic.opO[MN],
                                    Parameter = Mnemonic.adA[MN] + Convert.ToString(BD[pos + 1] & 0x7F) + "." +
                                         Convert.ToString(BD[pos] - 0xC8)
                                });
                            //Result = Result + Memnoic.opO[MN] + Memnoic.adA[MN] + Convert.ToString(BD[pos + 1] - 0x80) + "." +
                            //         Convert.ToString(BD[pos] - 0xC8);
                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                            pos += 2;

                            break;
                        case 0xD0:
                        case 0xD1:
                        case 0xD2:
                        case 0xD3:
                        case 0xD4:
                        case 0xD5:
                        case 0xD6:
                        case 0xD7:

                            if (BD[pos + 1] < 0x80)
                                retVal.Add(new S7FunctionBlockRow()
                                {
                                    Command = Mnemonic.opS[MN],
                                    Parameter = Mnemonic.adE[MN] + Convert.ToString(BD[pos + 1] & 0x7F) + "." +
                                         Convert.ToString(BD[pos] - 0xD0)
                                });
                            //Result = Result + Memnoic.opS[MN] + Memnoic.adE[MN] + Convert.ToString(BD[pos + 1]) + "." +
                            //         Convert.ToString(BD[pos] - 0xD0);
                            else
                                retVal.Add(new S7FunctionBlockRow()
                                {
                                    Command = Mnemonic.opS[MN],
                                    Parameter = Mnemonic.adA[MN] + Convert.ToString(BD[pos + 1] & 0x7F) + "." +
                                         Convert.ToString(BD[pos] - 0xD0)
                                });
                            //Result = Result + Memnoic.opS[MN] + Memnoic.adA[MN] + Convert.ToString(BD[pos + 1] - 0x80) + "." +
                            //         Convert.ToString(BD[pos] - 0xD0);
                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                            pos += 2;
                            break;
                        case 0xD8:
                        case 0xD9:
                        case 0xDA:
                        case 0xDB:
                        case 0xDC:
                        case 0xDD:
                        case 0xDE:
                        case 0xDF:
                            if (BD[pos + 1] < 0x80)
                                retVal.Add(new S7FunctionBlockRow()
                                {
                                    Command = Mnemonic.opZUW[MN],
                                    Parameter = Mnemonic.adE[MN] + Convert.ToString(BD[pos + 1] & 0x7F) + "." +
                                         Convert.ToString(BD[pos] - 0xD8)
                                });
                            //Result = Result + Memnoic.opZUW[MN] + Memnoic.adE[MN] + Convert.ToString(BD[pos + 1]) + "." +
                            //         Convert.ToString(BD[pos] - 0xD8);
                            else
                                retVal.Add(new S7FunctionBlockRow()
                                {
                                    Command = Mnemonic.opZUW[MN],
                                    Parameter = Mnemonic.adA[MN] + Convert.ToString(BD[pos + 1] & 0x7F) + "." +
                                         Convert.ToString(BD[pos] - 0xD8)
                                });
                            //Result = Result + Memnoic.opZUW[MN] + Memnoic.adA[MN] + Convert.ToString(BD[pos + 1] - 0x80) + "." +
                            //         Convert.ToString(BD[pos] - 0xD8);
                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                            pos += 2;
                            break;
                        case 0xE0:
                        case 0xE1:
                        case 0xE2:
                        case 0xE3:
                        case 0xE4:
                        case 0xE5:
                        case 0xE6:
                        case 0xE7:
                            if (BD[pos + 1] < 0x80)
                                retVal.Add(new S7FunctionBlockRow()
                                {
                                    Command = Mnemonic.opUN[MN],
                                    Parameter = Mnemonic.adE[MN] + Convert.ToString(BD[pos + 1] & 0x7F) + "." +
                                         Convert.ToString(BD[pos] - 0xE0)
                                });
                            //Result = Result + Memnoic.opUN[MN] + Memnoic.adE[MN] + Convert.ToString(BD[pos + 1]) + "." +
                            //         Convert.ToString(BD[pos] - 0xE0);
                            else
                                retVal.Add(new S7FunctionBlockRow()
                                {
                                    Command = Mnemonic.opU[MN],
                                    Parameter = Mnemonic.adA[MN] + Convert.ToString(BD[pos + 1] & 0x7F) + "." +
                                         Convert.ToString(BD[pos] - 0xE0)
                                });
                            //Result = Result + Memnoic.opUN[MN] + Memnoic.adA[MN] + Convert.ToString(BD[pos + 1] - 0x80) + "." +
                            //         Convert.ToString(BD[pos] - 0xE0);
                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                            pos += 2;
                            break;
                        case 0xE8:
                        case 0xE9:
                        case 0xEA:
                        case 0xEB:
                        case 0xEC:
                        case 0xED:
                        case 0xEE:
                        case 0xEF:
                            if (BD[pos + 1] < 0x80)
                                retVal.Add(new S7FunctionBlockRow()
                                {
                                    Command = Mnemonic.opON[MN],
                                    Parameter = Mnemonic.adE[MN] + Convert.ToString(BD[pos + 1] & 0x7F) + "." +
                                         Convert.ToString(BD[pos] - 0xE8)
                                });
                            //Result = Result + Memnoic.opON[MN] + Memnoic.adE[MN] + Convert.ToString(BD[pos + 1]) + "." +
                            //         Convert.ToString(BD[pos] - 0xE8);
                            else
                                retVal.Add(new S7FunctionBlockRow()
                                {
                                    Command = Mnemonic.opON[MN],
                                    Parameter = Mnemonic.adA[MN] + Convert.ToString(BD[pos + 1] & 0x7F) + "." +
                                         Convert.ToString(BD[pos] - 0xE8)
                                });
                            //Result = Result + Memnoic.opON[MN] + Memnoic.adA[MN] + Convert.ToString(BD[pos + 1] - 0x80) + "." +
                            //         Convert.ToString(BD[pos] - 0xE8);
                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                            pos += 2;
                            break;
                        case 0xF0:
                        case 0xF1:
                        case 0xF2:
                        case 0xF3:
                        case 0xF4:
                        case 0xF5:
                        case 0xF6:
                        case 0xF7:
                            if (BD[pos + 1] < 0x80)
                                retVal.Add(new S7FunctionBlockRow()
                                {
                                    Command = Mnemonic.opR[MN],
                                    Parameter = Mnemonic.adE[MN] + Convert.ToString(BD[pos + 1] & 0x7F) + "." +
                                         Convert.ToString(BD[pos] - 0xF0)
                                });
                            //Result = Result + Memnoic.opR[MN] + Memnoic.adE[MN] + Convert.ToString(BD[pos + 1]) + "." +
                            //         Convert.ToString(BD[pos] - 0xF0);
                            else
                                retVal.Add(new S7FunctionBlockRow()
                                {
                                    Command = Mnemonic.opR[MN],
                                    Parameter = Mnemonic.adA[MN] + Convert.ToString(BD[pos + 1] & 0x7F) + "." +
                                         Convert.ToString(BD[pos] - 0xF0)
                                });
                            //Result = Result + Memnoic.opR[MN] + Memnoic.adA[MN] + Convert.ToString(BD[pos + 1] - 0x80) + "." +
                            //         Convert.ToString(BD[pos] - 0xF0);
                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                            pos += 2;
                            break;
                        case 0xF8:
                            retVal.Add(new S7FunctionBlockRow()
                            {
                                Command = Mnemonic.opU[MN],
                                Parameter = Mnemonic.adT[MN] + Convert.ToString(BD[pos + 1])
                            });
                            //Result = Result + Memnoic.opU[MN] + Memnoic.adT[MN] + Convert.ToString(BD[pos + 1]);
                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                            pos += 2;
                            break;
                        case 0xF9:
                            retVal.Add(new S7FunctionBlockRow()
                            {
                                Command = Mnemonic.opO[MN],
                                Parameter = Mnemonic.adT[MN] + Convert.ToString(BD[pos + 1])
                            });
                            //Result = Result + Memnoic.opO[MN] + Memnoic.adT[MN] + Convert.ToString(BD[pos + 1]);
                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                            pos += 2;
                            break;
                        case 0xFB:
                            {
                                switch (BD[pos + 1])
                                {
                                    case 0x00:
                                        {
                                            retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opO[MN] });
                                            //Result = Result + Memnoic.opO[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x01:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opL[MN],
                                                Parameter = Mnemonic.adB[MN] + "[" + Mnemonic.adAR1[MN] + "," +
                                                    Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opL[MN] + Memnoic.adB[MN] + "[" + Memnoic.adAR1[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x02:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opL[MN],
                                                Parameter = Mnemonic.adW[MN] + "[" + Mnemonic.adAR1[MN] + "," +
                                                    Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opL[MN] + Memnoic.adW[MN] + "[" + Memnoic.adAR1[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x03:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opL[MN],
                                                Parameter = Mnemonic.adD[MN] + "[" + Mnemonic.adAR1[MN] + "," +
                                                    Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opL[MN] + Memnoic.adD[MN] + "[" + Memnoic.adAR1[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x05:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opT[MN],
                                                Parameter = Mnemonic.adB[MN] + "[" + Mnemonic.adAR1[MN] + "," +
                                                    Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opT[MN] + Memnoic.adB[MN] + "[" + Memnoic.adAR1[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x06:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opT[MN],
                                                Parameter = Mnemonic.adW[MN] + "[" + Mnemonic.adAR1[MN] + "," +
                                                    Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opT[MN] + Memnoic.adW[MN] + "[" + Memnoic.adAR1[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x07:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opT[MN],
                                                Parameter = Mnemonic.adD[MN] + "[" + Mnemonic.adAR1[MN] + "," +
                                                    Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opT[MN] + Memnoic.adD[MN] + "[" + Memnoic.adAR1[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x09:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opL[MN],
                                                Parameter = Mnemonic.adB[MN] + "[" + Mnemonic.adAR2[MN] + "," +
                                                    Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opL[MN] + Memnoic.adB[MN] + "[" + Memnoic.adAR2[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x0A:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opL[MN],
                                                Parameter = Mnemonic.adW[MN] + "[" + Mnemonic.adAR2[MN] + "," +
                                                    Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opL[MN] + Memnoic.adW[MN] + "[" + Memnoic.adAR2[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x0b:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opL[MN],
                                                Parameter = Mnemonic.adD[MN] + "[" + Mnemonic.adAR2[MN] + "," +
                                                    Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opL[MN] + Memnoic.adD[MN] + "[" + Memnoic.adAR2[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x0D:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opT[MN],
                                                Parameter = Mnemonic.adB[MN] + "[" + Mnemonic.adAR2[MN] + "," +
                                                    Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opT[MN] + Memnoic.adB[MN] + "[" + Memnoic.adAR2[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x0E:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opT[MN],
                                                Parameter = Mnemonic.adW[MN] + "[" + Mnemonic.adAR2[MN] + "," +
                                                    Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opT[MN] + Memnoic.adW[MN] + "[" + Memnoic.adAR2[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x0F:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opT[MN],
                                                Parameter = Mnemonic.adD[MN] + "[" + Mnemonic.adAR2[MN] + "," +
                                                    Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opT[MN] + Memnoic.adD[MN] + "[" + Memnoic.adAR2[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x10:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opU[MN],
                                                Parameter = "[" + Mnemonic.adAR1[MN] + "," + Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opU[MN] + "[" + Memnoic.adAR1[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x11:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opUN[MN],
                                                Parameter = "[" + Mnemonic.adAR1[MN] + "," + Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opUN[MN] + "[" + Memnoic.adAR1[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x12:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opO[MN],
                                                Parameter = "[" + Mnemonic.adAR1[MN] + "," + Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opO[MN] + "[" + Memnoic.adAR1[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x13:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opON[MN],
                                                Parameter = "[" + Mnemonic.adAR1[MN] + "," + Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opON[MN] + "[" + Memnoic.adAR1[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x14:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opX[MN],
                                                Parameter = "[" + Mnemonic.adAR1[MN] + "," + Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opX[MN] + "[" + Memnoic.adAR1[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x15:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opXN[MN],
                                                Parameter = "[" + Mnemonic.adAR1[MN] + "," + Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opXN[MN] + "[" + Memnoic.adAR1[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x18:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opU[MN],
                                                Parameter = "[" + Mnemonic.adAR2[MN] + "," + Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opU[MN] + "[" + Memnoic.adAR2[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x19:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opUN[MN],
                                                Parameter = "[" + Mnemonic.adAR2[MN] + "," + Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opUN[MN] + "[" + Memnoic.adAR2[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x1A:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opO[MN],
                                                Parameter = "[" + Mnemonic.adAR2[MN] + "," + Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opO[MN] + "[" + Memnoic.adAR2[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x1b:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opON[MN],
                                                Parameter = "[" + Mnemonic.adAR2[MN] + "," + Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opON[MN] + "[" + Memnoic.adAR2[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x1C:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opX[MN],
                                                Parameter = "[" + Mnemonic.adAR2[MN] + "," + Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opX[MN] + "[" + Memnoic.adAR2[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x1D:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opXN[MN],
                                                Parameter = "[" + Mnemonic.adAR2[MN] + "," + Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opXN[MN] + "[" + Memnoic.adAR2[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x20:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opS[MN],
                                                Parameter = "[" + Mnemonic.adAR1[MN] + "," + Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opS[MN] + "[" + Memnoic.adAR1[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x21:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opR[MN],
                                                Parameter = "[" + Mnemonic.adAR1[MN] + "," + Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opR[MN] + "[" + Memnoic.adAR1[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x22:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opZUW[MN],
                                                Parameter = "[" + Mnemonic.adAR1[MN] + "," + Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opZUW[MN] + "[" + Memnoic.adAR1[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x24:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opFP[MN],
                                                Parameter = "[" + Mnemonic.adAR1[MN] + "," + Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opFP[MN] + "[" + Memnoic.adAR1[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x25:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opFN[MN],
                                                Parameter = "[" + Mnemonic.adAR1[MN] + "," + Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opFN[MN] + "[" + Memnoic.adAR1[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x28:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opS[MN],
                                                Parameter = "[" + Mnemonic.adAR2[MN] + "," + Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opS[MN] + "[" + Memnoic.adAR2[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x29:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opR[MN],
                                                Parameter = "[" + Mnemonic.adAR2[MN] + "," + Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opR[MN] + "[" + Memnoic.adAR2[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x2A:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opZUW[MN],
                                                Parameter = "[" + Mnemonic.adAR2[MN] + "," + Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opZUW[MN] + "[" + Memnoic.adAR2[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x2C:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opFP[MN],
                                                Parameter = "[" + Mnemonic.adAR2[MN] + "," + Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opFP[MN] + "[" + Memnoic.adAR2[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x2D:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opFN[MN],
                                                Parameter = "[" + Mnemonic.adAR2[MN] + "," + Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]"
                                            });
                                            //Result = Result + Memnoic.opFN[MN] + "[" + Memnoic.adAR2[MN] + "," +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x38:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opAUF[MN],
                                                Parameter = Mnemonic.adDB[MN] + "[" + Mnemonic.adMW[MN] +
                                                     Convert.ToString(libnodave.getU16from(BD, pos + 2)) + "]"
                                            });
                                            //Result = Result + Memnoic.opAUF[MN] + Memnoic.adDB[MN] + "[" + Memnoic.adMW[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3])) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x39:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opAUF[MN],
                                                Parameter = Mnemonic.adDI[MN] + "[" + Mnemonic.adMW[MN] +
                                                     Convert.ToString(libnodave.getU16from(BD, pos + 2)) + "]"
                                            });
                                            //Result = Result + Memnoic.opAUF[MN] + Memnoic.adDI[MN] + "[" + Memnoic.adMW[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3])) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x3C:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opL[MN],
                                                Parameter = Mnemonic.adDBLG[MN]
                                            });
                                            //Result = Result + Memnoic.opL[MN] + Memnoic.adDBLG[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x3D:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opL[MN],
                                                Parameter = Mnemonic.adDILG[MN]
                                            });
                                            //Result = Result + Memnoic.opL[MN] + Memnoic.adDILG[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x48:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opAUF[MN],
                                                Parameter = Mnemonic.adDB[MN] + "[" + Mnemonic.adDBW[MN] +
                                                     Convert.ToString(libnodave.getU16from(BD, pos + 2)) + "]"
                                            });
                                            //Result = Result + Memnoic.opAUF[MN] + Memnoic.adDB[MN] + "[" + Memnoic.adDBW[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3])) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x49:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opAUF[MN],
                                                Parameter = Mnemonic.adDI[MN] + "[" + Mnemonic.adDBW[MN] +
                                                     Convert.ToString(libnodave.getU16from(BD, pos + 2)) + "]"
                                            });
                                            //Result = Result + Memnoic.opAUF[MN] + Memnoic.adDI[MN] + "[" + Memnoic.adDBW[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3])) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x4C:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opL[MN],
                                                Parameter = Mnemonic.adDBNO[MN]
                                            });
                                            //Result = Result + Memnoic.opL[MN] + Memnoic.adDBNO[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x4D:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opL[MN],
                                                Parameter = Mnemonic.adDINO[MN]
                                            });
                                            //Result = Result + Memnoic.opL[MN] + Memnoic.adDINO[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x58:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opAUF[MN],
                                                Parameter = Mnemonic.adDB[MN] + "[" + Mnemonic.adDIW[MN] +
                                                     Convert.ToString(libnodave.getU16from(BD, pos + 2)) + "]"
                                            });
                                            //Result = Result + Memnoic.opAUF[MN] + Memnoic.adDB[MN] + "[" + Memnoic.adDIW[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3])) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x59:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opAUF[MN],
                                                Parameter = Mnemonic.adDI[MN] + "[" + Mnemonic.adDIW[MN] +
                                                     Convert.ToString(libnodave.getU16from(BD, pos + 2)) + "]"
                                            });
                                            //Result = Result + Memnoic.opAUF[MN] + Memnoic.adDI[MN] + "[" + Memnoic.adDIW[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3])) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x68:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opAUF[MN],
                                                Parameter = Mnemonic.adDB[MN] + "[" + Mnemonic.adLW[MN] +
                                                     Convert.ToString(libnodave.getU16from(BD, pos + 2)) + "]"
                                            });
                                            //Result = Result + Memnoic.opAUF[MN] + Memnoic.adDB[MN] + "[" + Memnoic.adLW[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3])) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x69:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opAUF[MN],
                                                Parameter = Mnemonic.adDI[MN] + "[" + Mnemonic.adLW[MN] +
                                                     Convert.ToString(libnodave.getU16from(BD, pos + 2)) + "]"
                                            });
                                            //Result = Result + Memnoic.opAUF[MN] + Memnoic.adDI[MN] + "[" + Memnoic.adLW[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3])) + "]";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x70:
                                        {
                                            retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opUC[MN], Parameter = Mnemonic.adFC[MN] + Convert.ToString(libnodave.getU16from(BD, pos + 2)) });

                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3], BD[pos + 4], BD[pos + 5], BD[pos + 6], BD[pos + 7] };

                                            //Get Parameter Count
                                            int paranz = (BD[pos + 7] / 2) - 1;
                                            List<string> tmplst = new List<string>();
                                            for (int n = 1; n <= paranz; n++)
                                            {
                                                tmplst.Add(Helper.GetFCPointer(BD[pos + 8], BD[pos + 9], BD[pos + 10], BD[pos + 11]));
                                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = Helper.CombineByteArray(((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7, new byte[] { BD[pos + 8], BD[pos + 9], BD[pos + 10], BD[pos + 11] });
                                                pos += 4;
                                            }

                                            byte[] backup = ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7;
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).ExtParameter = tmplst;
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = backup;

                                            pos += 8;
                                        }
                                        break;
                                    case 0x30:
                                    case 0x40:
                                    case 0x50:
                                    case 0x60:
                                        {
                                            string par = "";
                                            switch (BD[pos + 1] & 0xf0)
                                            {
                                                case 0x30:
                                                    par = Mnemonic.adMW[MN];
                                                    break;
                                                case 0x40:
                                                    par = Mnemonic.adDBW[MN];
                                                    break;
                                                case 0x50:
                                                    par = Mnemonic.adDIW[MN];
                                                    break;
                                                case 0x60:
                                                    par = Mnemonic.adLW[MN];
                                                    break;
                                            }
                                            retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opUC[MN], Parameter = Mnemonic.adFC[MN] + "[" + par + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + "]" });

                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3], BD[pos + 4], BD[pos + 5], BD[pos + 6], BD[pos + 7] };

                                            //Get Parameter Count
                                            int paranz = (BD[pos + 7] / 2) - 1;
                                            List<string> tmplst = new List<string>();
                                            for (int n = 1; n <= paranz; n++)
                                            {
                                                tmplst.Add(Helper.GetFCPointer(BD[pos + 8], BD[pos + 9], BD[pos + 10], BD[pos + 11]));
                                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = Helper.CombineByteArray(((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7, new byte[] { BD[pos + 8], BD[pos + 9], BD[pos + 10], BD[pos + 11] });
                                                pos += 4;
                                            }

                                            byte[] backup = ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7;
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).ExtParameter = tmplst;
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = backup;

                                            pos += 8;
                                        }
                                        break;
                                    case 0x32:
                                    case 0x42:
                                    case 0x52:
                                    case 0x62:
                                        {
                                            string par = "";
                                            switch (BD[pos + 1] & 0xf0)
                                            {
                                                case 0x30:
                                                    par = Mnemonic.adMW[MN];
                                                    break;
                                                case 0x40:
                                                    par = Mnemonic.adDBW[MN];
                                                    break;
                                                case 0x60:
                                                    par = Mnemonic.adLW[MN];
                                                    break;
                                                case 0x50:
                                                    par = Mnemonic.adDIW[MN];
                                                    break;
                                            }
                                            retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opUC[MN], Parameter = Mnemonic.adFB[MN] + "[" + par + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + "]" });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;

                                    case 0x41:
                                    case 0x51:
                                    case 0x61:
                                        {
                                            string par = "";
                                            switch (BD[pos + 1])
                                            {
                                                case 0x61:
                                                    par = Mnemonic.adLW[MN];
                                                    break;
                                                case 0x41:
                                                    par = Mnemonic.adDBW[MN];
                                                    break;
                                                case 0x51:
                                                    par = Mnemonic.adDIW[MN];
                                                    break;
                                            }
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opCC[MN],
                                                Parameter = Mnemonic.adFC[MN] + "[" + par +
                                                     Convert.ToString(libnodave.getU16from(BD, pos + 2)) + "]"
                                            });

                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3], BD[pos + 4], BD[pos + 5], BD[pos + 6], BD[pos + 7] };
                                            pos += 8;
                                        }
                                        break;

                                    case 0x43:
                                    case 0x53:
                                    case 0x63:
                                        {
                                            string par = "";
                                            switch (BD[pos + 1] & 0xf0)
                                            {
                                                case 0x60:
                                                    par = Mnemonic.adLW[MN];
                                                    break;
                                                case 0x40:
                                                    par = Mnemonic.adDBW[MN];
                                                    break;
                                                case 0x50:
                                                    par = Mnemonic.adDIW[MN];
                                                    break;
                                            }
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opCC[MN],
                                                Parameter = Mnemonic.adFB[MN] + "[" + par +
                                                     Convert.ToString(libnodave.getU16from(BD, pos + 2)) + "]"
                                            });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x71:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opCC[MN],
                                                Parameter = Mnemonic.adFC[MN] +
                                                     Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3], BD[pos + 4], BD[pos + 5], BD[pos + 6], BD[pos + 7] };
                                            pos += 8;
                                        }
                                        break;
                                    case 0x72:
                                        {
                                            retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opUC[MN], Parameter = Mnemonic.adFB[MN] + Convert.ToString(libnodave.getU16from(BD, pos + 2)) });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x73:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opCC[MN],
                                                Parameter = Mnemonic.adFB[MN] +
                                                     Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });

                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x74:
                                        {
                                            retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opUC[MN], Parameter = Mnemonic.adSFC[MN] + Convert.ToString(libnodave.getU16from(BD, pos + 2)) });

                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3], BD[pos + 4], BD[pos + 5], BD[pos + 6], BD[pos + 7] };

                                            //Get Parameter Count
                                            int paranz = (BD[pos + 7] / 2) - 1;
                                            List<string> tmplst = new List<string>();
                                            for (int n = 1; n <= paranz; n++)
                                            {
                                                tmplst.Add(Helper.GetFCPointer(BD[pos + 8], BD[pos + 9], BD[pos + 10], BD[pos + 11]));
                                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = Helper.CombineByteArray(((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7, new byte[] { BD[pos + 8], BD[pos + 9], BD[pos + 10], BD[pos + 11] });
                                                pos += 4;
                                            }

                                            byte[] backup = ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7;
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).ExtParameter = tmplst;
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = backup;

                                            pos += 8;
                                        }
                                        break;
                                    case 0x76:
                                        {
                                            retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opUC[MN], Parameter = Mnemonic.adSFB[MN] + Convert.ToString(libnodave.getU16from(BD, pos + 2)) });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x78:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opAUF[MN],
                                                Parameter = Mnemonic.adDB[MN] +
                                                     Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opAUF[MN] + Memnoic.adDB[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x79:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opAUF[MN],
                                                Parameter = Mnemonic.adDI[MN] +
                                                     Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opAUF[MN] + Memnoic.adDI[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x7C:
                                        {
                                            retVal.Add(new S7FunctionBlockRow() { Command = Mnemonic.opTDB[MN] });
                                            //Result = Result + Memnoic.opTDB[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x80:
                                    case 0xA0:
                                    case 0xB0:
                                        {
                                            string cmd = "", par = "";
                                            cmd = Mnemonic.opU[MN];
                                            if (ParaList.Count >= (libnodave.getU16from(BD, pos + 2) / 2) - 1)
                                                par = "#" + ParaList[(libnodave.getU16from(BD, pos + 2) / 2) - 1];
                                            else
                                                par = "unkown parameter (" + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + ")";
                                            retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x81:
                                    case 0xA1:
                                    case 0xB1:
                                        {
                                            string cmd = "", par = "";
                                            cmd = Mnemonic.opUN[MN];
                                            if (ParaList.Count >= (libnodave.getU16from(BD, pos + 2) / 2) - 1)
                                                par = "#" + ParaList[(libnodave.getU16from(BD, pos + 2) / 2) - 1];
                                            else
                                                par = "unkown parameter (" + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + ")";
                                            retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x82:
                                    case 0xA2:
                                    case 0xB2:
                                        {
                                            string cmd = "", par = "";
                                            cmd = Mnemonic.opO[MN];
                                            if (ParaList.Count >= (libnodave.getU16from(BD, pos + 2) / 2) - 1)
                                                par = "#" + ParaList[(libnodave.getU16from(BD, pos + 2) / 2) - 1];
                                            else
                                                par = "unkown parameter (" + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + ")";
                                            retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x83:
                                    case 0xA3:
                                    case 0xB3:
                                        {
                                            string cmd = "", par = "";
                                            cmd = Mnemonic.opON[MN];
                                            if (ParaList.Count >= (libnodave.getU16from(BD, pos + 2) / 2) - 1)
                                                par = "#" + ParaList[(libnodave.getU16from(BD, pos + 2) / 2) - 1];
                                            else
                                                par = "unkown parameter (" + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + ")";
                                            retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x84:
                                    case 0xA4:
                                    case 0xB4:
                                        {
                                            string cmd = "", par = "";
                                            cmd = Mnemonic.opX[MN];
                                            if (ParaList.Count >= (libnodave.getU16from(BD, pos + 2) / 2) - 1)
                                                par = "#" + ParaList[(libnodave.getU16from(BD, pos + 2) / 2) - 1];
                                            else
                                                par = "unkown parameter (" + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + ")";
                                            retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x85:
                                    case 0xA5:
                                    case 0xB5:
                                        {
                                            string cmd = "", par = "";
                                            cmd = Mnemonic.opXN[MN];
                                            if (ParaList.Count >= (libnodave.getU16from(BD, pos + 2) / 2) - 1)
                                                par = "#" + ParaList[(libnodave.getU16from(BD, pos + 2) / 2) - 1];
                                            else
                                                par = "unkown parameter (" + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + ")";
                                            retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x90:
                                    case 0xBB:
                                        {
                                            string cmd = "", par = "";
                                            cmd = Mnemonic.opS[MN];
                                            if (ParaList.Count >= (libnodave.getU16from(BD, pos + 2) / 2) - 1)
                                                par = "#" + ParaList[(libnodave.getU16from(BD, pos + 2) / 2) - 1];
                                            else
                                                par = "unkown parameter (" + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + ")";
                                            retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x91:
                                    case 0xAF:
                                    case 0xBF:
                                        {
                                            string cmd = "", par = "";
                                            cmd = Mnemonic.opR[MN];
                                            if (ParaList.Count >= (libnodave.getU16from(BD, pos + 2) / 2) - 1)
                                                par = "#" + ParaList[(libnodave.getU16from(BD, pos + 2) / 2) - 1];
                                            else
                                                par = "unkown parameter (" + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + ")";
                                            retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x92:
                                        {
                                            string cmd = "", par = "";
                                            cmd = Mnemonic.opZUW[MN];
                                            if (ParaList.Count >= (libnodave.getU16from(BD, pos + 2) / 2) - 1)
                                                par = "#" + ParaList[(libnodave.getU16from(BD, pos + 2) / 2) - 1];
                                            else
                                                par = "unkown parameter (" + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + ")";
                                            retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x94:
                                        {
                                            string cmd = "", par = "";
                                            cmd = Mnemonic.opFP[MN];
                                            if (ParaList.Count >= (libnodave.getU16from(BD, pos + 2) / 2) - 1)
                                                par = "#" + ParaList[(libnodave.getU16from(BD, pos + 2) / 2) - 1];
                                            else
                                                par = "unkown parameter (" + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + ")";
                                            retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x95:
                                        {
                                            string cmd = "", par = "";
                                            cmd = Mnemonic.opFN[MN];
                                            if (ParaList.Count >= (libnodave.getU16from(BD, pos + 2) / 2) - 1)
                                                par = "#" + ParaList[(libnodave.getU16from(BD, pos + 2) / 2) - 1];
                                            else
                                                par = "unkown parameter (" + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + ")";
                                            retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xA6:
                                    case 0xb6:
                                    case 0xc1:
                                    case 0xc2:
                                    case 0xc3:
                                        {
                                            string cmd = "", par = "";
                                            cmd = Mnemonic.opL[MN];
                                            if (ParaList.Count >= (libnodave.getU16from(BD, pos + 2) / 2) - 1)
                                                par = "#" + ParaList[(libnodave.getU16from(BD, pos + 2) / 2) - 1];
                                            else
                                                par = "unkown parameter (" + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + ")";
                                            retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xA8:
                                    case 0xb8:
                                        {
                                            string cmd = "", par = "";
                                            cmd = Mnemonic.opFR[MN];
                                            if (ParaList.Count >= (libnodave.getU16from(BD, pos + 2) / 2) - 1)
                                                par = "#" + ParaList[(libnodave.getU16from(BD, pos + 2) / 2) - 1];
                                            else
                                                par = "unkown parameter (" + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + ")";
                                            retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xA9:
                                        {
                                            string cmd = "", par = "";
                                            cmd = Mnemonic.opLC[MN];
                                            if (ParaList.Count >= (libnodave.getU16from(BD, pos + 2) / 2) - 1)
                                                par = "#" + ParaList[(libnodave.getU16from(BD, pos + 2) / 2) - 1];
                                            else
                                                par = "unkown parameter (" + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + ")";
                                            retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;

                                        }
                                        break;
                                    case 0xAA:
                                        {
                                            string cmd = "", par = "";
                                            cmd = Mnemonic.opSA[MN];
                                            if (ParaList.Count >= (libnodave.getU16from(BD, pos + 2) / 2) - 1)
                                                par = "#" + ParaList[(libnodave.getU16from(BD, pos + 2) / 2) - 1];
                                            else
                                                par = "unkown parameter (" + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + ")";
                                            retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xAB:
                                        {
                                            string cmd = "", par = "";
                                            cmd = Mnemonic.opSV[MN];
                                            if (ParaList.Count >= (libnodave.getU16from(BD, pos + 2) / 2) - 1)
                                                par = "#" + ParaList[(libnodave.getU16from(BD, pos + 2) / 2) - 1];
                                            else
                                                par = "unkown parameter (" + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + ")";
                                            retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xAC:
                                        {
                                            string cmd = "", par = "";
                                            cmd = Mnemonic.opSE[MN];
                                            if (ParaList.Count >= (libnodave.getU16from(BD, pos + 2) / 2) - 1)
                                                par = "#" + ParaList[(libnodave.getU16from(BD, pos + 2) / 2) - 1];
                                            else
                                                par = "unkown parameter (" + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + ")";
                                            retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xAD:
                                        {
                                            string cmd = "", par = "";
                                            cmd = Mnemonic.opSS[MN];
                                            if (ParaList.Count >= (libnodave.getU16from(BD, pos + 2) / 2) - 1)
                                                par = "#" + ParaList[(libnodave.getU16from(BD, pos + 2) / 2) - 1];
                                            else
                                                par = "unkown parameter (" + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + ")";
                                            retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xAE:
                                        {
                                            string cmd = "", par = "";
                                            cmd = Mnemonic.opSI[MN];
                                            if (ParaList.Count >= (libnodave.getU16from(BD, pos + 2) / 2) - 1)
                                                par = "#" + ParaList[(libnodave.getU16from(BD, pos + 2) / 2) - 1];
                                            else
                                                par = "unkown parameter (" + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + ")";
                                            retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xBA:
                                        {
                                            string cmd = "", par = "";
                                            cmd = Mnemonic.opZR[MN];
                                            if (ParaList.Count >= (libnodave.getU16from(BD, pos + 2) / 2) - 1)
                                                par = "#" + ParaList[(libnodave.getU16from(BD, pos + 2) / 2) - 1];
                                            else
                                                par = "unkown parameter (" + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + ")";
                                            retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xBD:
                                        {
                                            string cmd = "", par = "";
                                            cmd = Mnemonic.opZV[MN];
                                            if (ParaList.Count >= (libnodave.getU16from(BD, pos + 2) / 2) - 1)
                                                par = "#" + ParaList[(libnodave.getU16from(BD, pos + 2) / 2) - 1];
                                            else
                                                par = "unkown parameter (" + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + ")";
                                            retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xC5:
                                    case 0xC6:
                                    case 0xC7:
                                    //case 0xCB:
                                        {
                                            string cmd = "", par = "";
                                            cmd = Mnemonic.opT[MN];
                                            if (ParaList.Count >= (libnodave.getU16from(BD, pos + 2) / 2) - 1)
                                                par = "#" + ParaList[(libnodave.getU16from(BD, pos + 2) / 2) - 1];
                                            else
                                                par = "unkown parameter (" + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + ")";
                                            retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xCB:
                                        {
                                            string cmd = "", par = "";
                                            cmd = Mnemonic.opL[MN];
                                            if (ParaList.Count >= (libnodave.getU16from(BD, pos + 2) / 2) - 1)
                                                par = "P##" + ParaList[(libnodave.getU16from(BD, pos + 2) / 2) - 1];
                                            else
                                                par = "unkown parameter (" + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + ")";
                                            retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xD0:
                                    case 0xD2:
                                        {
                                            string cmd = "", par = "";
                                            cmd = Mnemonic.opUC[MN];
                                            if (ParaList.Count >= (libnodave.getU16from(BD, pos + 2) / 2) - 1)
                                                par = "#" + ParaList[(libnodave.getU16from(BD, pos + 2) / 2) - 1];
                                            else
                                                par = "unkown parameter (" + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + ")";
                                            retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });

                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3], BD[pos + 4], BD[pos + 5], BD[pos + 6], BD[pos + 7] };

                                            //Get Parameter Count
                                            int paranz = (BD[pos + 7] / 2) - 1;
                                            List<string> tmplst = new List<string>();
                                            for (int n = 1; n <= paranz; n++)
                                            {
                                                tmplst.Add(Helper.GetFCPointer(BD[pos + 8], BD[pos + 9], BD[pos + 10], BD[pos + 11]));
                                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = Helper.CombineByteArray(((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7, new byte[] { BD[pos + 8], BD[pos + 9], BD[pos + 10], BD[pos + 11] });
                                                pos += 4;
                                            }

                                            byte[] backup = ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7;
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).ExtParameter = tmplst;
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = backup;

                                            pos += 8;
                                        }
                                        break;
                                    case 0xD8:
                                        {
                                            string cmd = "", par = "";
                                            cmd = Mnemonic.opAUF[MN];
                                            if (ParaList.Count >= (libnodave.getU16from(BD, pos + 2) / 2) - 1)
                                                par = "#" + ParaList[(libnodave.getU16from(BD, pos + 2) / 2) - 1];
                                            else
                                                par = "unkown parameter (" + Convert.ToString(libnodave.getU16from(BD, pos + 2)) + ")";
                                            retVal.Add(new S7FunctionBlockRow() { Command = cmd, Parameter = par });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xE0:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opU[MN],
                                                Parameter = Mnemonic.adT[MN] +
                                                    Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opU[MN] + Memnoic.adT[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xE1:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opUN[MN],
                                                Parameter = Mnemonic.adT[MN] +
                                                    Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opUN[MN] + Memnoic.adT[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xE2:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opO[MN],
                                                Parameter = Mnemonic.adT[MN] +
                                                    Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opO[MN] + Memnoic.adT[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xE3:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opON[MN],
                                                Parameter = Mnemonic.adT[MN] +
                                                    Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opON[MN] + Memnoic.adT[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xE4:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opX[MN],
                                                Parameter = Mnemonic.adT[MN] +
                                                    Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opX[MN] + Memnoic.adT[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xE5:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opXN[MN],
                                                Parameter = Mnemonic.adT[MN] +
                                                    Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opXN[MN] + Memnoic.adT[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xE6:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opL[MN],
                                                Parameter = Mnemonic.adT[MN] +
                                                    Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opL[MN] + Memnoic.adT[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xE8:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opFR[MN],
                                                Parameter = Mnemonic.adT[MN] +
                                                    Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opFR[MN] + Memnoic.adT[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xE9:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opLC[MN],
                                                Parameter = Mnemonic.adT[MN] +
                                                    Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opLC[MN] + Memnoic.adT[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xEA:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opSA[MN],
                                                Parameter = Mnemonic.adT[MN] +
                                                    Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opSA[MN] + Memnoic.adT[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xEB:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opSV[MN],
                                                Parameter = Mnemonic.adT[MN] +
                                                    Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opSV[MN] + Memnoic.adT[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xEC:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opSE[MN],
                                                Parameter = Mnemonic.adT[MN] +
                                                    Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opSE[MN] + Memnoic.adT[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xED:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opSS[MN],
                                                Parameter = Mnemonic.adT[MN] +
                                                    Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opSS[MN] + Memnoic.adT[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xEE:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opSI[MN],
                                                Parameter = Mnemonic.adT[MN] +
                                                    Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opSI[MN] + Memnoic.adT[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xEF:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opR[MN],
                                                Parameter = Mnemonic.adT[MN] +
                                                    Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opR[MN] + Memnoic.adT[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xF0:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opU[MN],
                                                Parameter = Mnemonic.adZ[MN] +
                                                    Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opU[MN] + Memnoic.adZ[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xF1:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opUN[MN],
                                                Parameter = Mnemonic.adZ[MN] +
                                                    Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opUN[MN] + Memnoic.adZ[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xF2:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opO[MN],
                                                Parameter = Mnemonic.adZ[MN] +
                                                    Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opO[MN] + Memnoic.adZ[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xF3:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opON[MN],
                                                Parameter = Mnemonic.adZ[MN] +
                                                    Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opON[MN] + Memnoic.adZ[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xF4:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opX[MN],
                                                Parameter = Mnemonic.adZ[MN] +
                                                    Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opX[MN] + Memnoic.adZ[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xF5:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opXN[MN],
                                                Parameter = Mnemonic.adZ[MN] +
                                                    Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opXN[MN] + Memnoic.adZ[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xF8:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opFR[MN],
                                                Parameter = Mnemonic.adZ[MN] +
                                                    Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opFR[MN] + Memnoic.adZ[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xFA:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opZR[MN],
                                                Parameter = Mnemonic.adZ[MN] +
                                                    Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opZR[MN] + Memnoic.adZ[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xFB:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opS[MN],
                                                Parameter = Mnemonic.adZ[MN] +
                                                    Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opS[MN] + Memnoic.adZ[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xfd:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opZV[MN],
                                                Parameter = Mnemonic.adZ[MN] +
                                                    Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opZV[MN] + Memnoic.adZ[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xFF:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opR[MN],
                                                Parameter = Mnemonic.adZ[MN] +
                                                    Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opR[MN] + Memnoic.adZ[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    default:
                                        retVal.Add(new S7FunctionBlockRow() { Command = "errd" });
                                        ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                        pos += 4;
                                        break;
                                }
                            }
                            break;
                        case 0xFC:
                            retVal.Add(new S7FunctionBlockRow()
                            {
                                Command = Mnemonic.opUN[MN],
                                Parameter = Mnemonic.adT[MN] + Convert.ToString(BD[pos + 1])
                            });
                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                            pos += 2;
                            break;
                        case 0xFD:
                            retVal.Add(new S7FunctionBlockRow()
                            {
                                Command = Mnemonic.opON[MN],
                                Parameter = Mnemonic.adT[MN] + Convert.ToString(BD[pos + 1])
                            });
                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                            pos += 2;
                            break;
                        case 0xFE:
                            {
                                switch (BD[pos + 1])
                                {
                                    case 0x01:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opLAR1[MN],
                                                Parameter = Mnemonic.adAR2[MN]
                                            });
                                            //Result = Result + Memnoic.opLAR1[MN] + Memnoic.adAR2[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x02:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opPAR1[MN],
                                                Parameter = Helper.GetShortPointer(BD[pos + 2], BD[pos + 3])
                                            });
                                            //Result = Result + Memnoic.opPAR1[MN] +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]);
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x03:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                                           {
                                                               Command = Mnemonic.opLAR1[MN],
                                                               Parameter = Helper.GetPointer(BD, pos + 2)
                                                           });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3], BD[pos + 4], BD[pos + 5] };
                                            pos += 6;
                                        }
                                        break;
                                    case 0x04:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opLAR1[MN]
                                            });
                                            //Result = Result + Memnoic.opLAR1[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x05:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opTAR1[MN]
                                            });
                                            //Result = Result + Memnoic.opTAR1[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x06:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opPAR1[MN]
                                            });
                                            //Result = Result + Memnoic.opPAR1[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x08:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opTAR[MN]
                                            });
                                            //Result = Result + Memnoic.opTAR[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x09:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opTAR1[MN],
                                                Parameter = Mnemonic.adAR2[MN]
                                            });
                                            //Result = Result + Memnoic.opTAR1[MN] + Memnoic.adAR2[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x0A:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opPAR2[MN],
                                                Parameter = Helper.GetShortPointer(BD[pos + 2], BD[pos + 3])
                                            });
                                            //Result = Result + Memnoic.opPAR2[MN] +
                                            //         Helper.GetShortPointer(BD[pos + 2], BD[pos + 3]);
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x0b:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opLAR2[MN],
                                                Parameter = Helper.GetPointer(BD,pos+2)
                                            });
                                            //Result = Result + Memnoic.opLAR2[MN] +
                                            //         Helper.GetPointer(BD[pos + 2], BD[pos + 3], BD[pos + 4],
                                            //                           BD[pos + 5]);
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3], BD[pos + 4], BD[pos + 5] };
                                            pos += 6;
                                        }
                                        break;
                                    case 0x0C:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opLAR2[MN]
                                            });
                                            //Result = Result + Memnoic.opLAR2[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x0D:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opTAR2[MN]
                                            });
                                            //Result = Result + Memnoic.opTAR2[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x0E:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opPAR2[MN]
                                            });
                                            //Result = Result + Memnoic.opPAR2[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x33:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opLAR1[MN],
                                                Parameter = Mnemonic.adMD[MN] + Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x37:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opTAR1[MN],
                                                Parameter = Mnemonic.adMD[MN] + Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opTAR1[MN] + Memnoic.adMD[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x3b:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opLAR2[MN],
                                                Parameter = Mnemonic.adMD[MN] + Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opLAR2[MN] + Memnoic.adMD[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x3F:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opTAR2[MN],
                                                Parameter = Mnemonic.adMD[MN] + Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opTAR2[MN] + Memnoic.adMD[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x43:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opLAR1[MN],
                                                Parameter = Mnemonic.adDBD[MN] + Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opLAR1[MN] + Memnoic.adDBD[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x47:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opTAR1[MN],
                                                Parameter = Mnemonic.adDBD[MN] + Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opTAR1[MN] + Memnoic.adDBD[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x4b:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opLAR2[MN],
                                                Parameter = Mnemonic.adDBD[MN] + Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opLAR2[MN] + Memnoic.adDBD[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x4F:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opTAR2[MN],
                                                Parameter = Mnemonic.adDBD[MN] + Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opTAR2[MN] + Memnoic.adDBD[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x53:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opLAR1[MN],
                                                Parameter = Mnemonic.adDID[MN] + Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opLAR1[MN] + Memnoic.adDID[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x57:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opTAR1[MN],
                                                Parameter = Mnemonic.adDID[MN] + Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opTAR1[MN] + Memnoic.adDID[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x5b:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opLAR2[MN],
                                                Parameter = Mnemonic.adDID[MN] + Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opLAR2[MN] + Memnoic.adDID[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x5F:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opTAR2[MN],
                                                Parameter = Mnemonic.adDID[MN] + Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opTAR2[MN] + Memnoic.adDID[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x63:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opLAR1[MN],
                                                Parameter = Mnemonic.adLD[MN] + Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opLAR1[MN] + Memnoic.adLD[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x67:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opTAR1[MN],
                                                Parameter = Mnemonic.adLD[MN] + Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opTAR1[MN] + Memnoic.adLD[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x6b:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opLAR2[MN],
                                                Parameter = Mnemonic.adLD[MN] + Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opLAR2[MN] + Memnoic.adLD[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x6F:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opTAR2[MN],
                                                Parameter = Mnemonic.adLD[MN] + Convert.ToString(libnodave.getU16from(BD, pos + 2))
                                            });
                                            //Result = Result + Memnoic.opTAR2[MN] + Memnoic.adLD[MN] +
                                            //         Convert.ToString(Helper.GetWord(BD[pos + 2], BD[pos + 3]));
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xC0:
                                    case 0xD0:
                                    case 0xE0:
                                        retVal.Add(new S7FunctionBlockRow()
                                                    {
                                                        Command = Mnemonic.opSRD[MN],
                                                        Parameter = Convert.ToString(BD[pos + 1] - 0xC0)
                                                    });
                                        //Result = Result + Memnoic.opSRD[MN] + Convert.ToString(BD[pos + 1] - 0xC0);
                                        ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                        pos += 2;
                                        break;
                                    default:
                                        switch (BD[pos + 1] & 0xf0)
                                        {
                                            case 0xC0:
                                            case 0xD0:
                                            case 0xE0:
                                                retVal.Add(new S7FunctionBlockRow()
                                                               {
                                                                   Command = Mnemonic.opSRD[MN],
                                                                   Parameter = Convert.ToString(BD[pos + 1] - 0xC0)
                                                               });
                                                //Result = Result + Memnoic.opSRD[MN] + Convert.ToString(BD[pos + 1] - 0xC0);
                                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] {BD[pos], BD[pos + 1]};
                                                pos += 2;
                                                break;
                                            default:
                                                retVal.Add(new S7FunctionBlockRow() {Command = "err 99"});
                                                ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] {BD[pos], BD[pos + 1]};
                                                pos += 2;
                                                break;
                                        }
                                        break;
                                }
                            }
                            break;
                        case 0xFF:
                            {
                                switch (BD[pos + 1])
                                {
                                    case 0x00:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opU[MN],
                                                Parameter = Mnemonic.adOS[MN]
                                            });
                                            //Result = Result + Memnoic.opU[MN] + Memnoic.adOS[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x01:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opUN[MN],
                                                Parameter = Mnemonic.adOS[MN]
                                            });
                                            //Result = Result + Memnoic.opUN[MN] + Memnoic.adOS[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x02:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opO[MN],
                                                Parameter = Mnemonic.adOS[MN]
                                            });
                                            //Result = Result + Memnoic.opO[MN] + Memnoic.adOS[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x03:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opON[MN],
                                                Parameter = Mnemonic.adOS[MN]
                                            });
                                            //Result = Result + Memnoic.opON[MN] + Memnoic.adOS[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x04:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opX[MN],
                                                Parameter = Mnemonic.adOS[MN]
                                            });
                                            //Result = Result + Memnoic.opX[MN] + Memnoic.adOS[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x05:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opXN[MN],
                                                Parameter = Mnemonic.adOS[MN]
                                            });
                                            //Result = Result + Memnoic.opXN[MN] + Memnoic.adOS[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x08:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                                           {
                                                               Command = Mnemonic.opSPS[MN],
                                                               JumpWidth = libnodave.getS16from(BD, pos + 2)
                                            });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x10:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opU[MN],
                                                Parameter = Mnemonic.adOV[MN]
                                            });
                                            //Result = Result + Memnoic.opU[MN] + Memnoic.adOV[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x11:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opUN[MN],
                                                Parameter = Mnemonic.adOV[MN]
                                            });
                                            //Result = Result + Memnoic.opUN[MN] + Memnoic.adOV[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x12:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opO[MN],
                                                Parameter = Mnemonic.adOV[MN]
                                            });
                                            //Result = Result + Memnoic.opO[MN] + Memnoic.adOV[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x13:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opON[MN],
                                                Parameter = Mnemonic.adOV[MN]
                                            });
                                            //Result = Result + Memnoic.opON[MN] + Memnoic.adOV[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x14:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opX[MN],
                                                Parameter = Mnemonic.adOV[MN]
                                            });
                                            //Result = Result + Memnoic.opX[MN] + Memnoic.adOV[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x15:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opXN[MN],
                                                Parameter = Mnemonic.adOV[MN]
                                            });
                                            //Result = Result + Memnoic.opXN[MN] + Memnoic.adOV[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x18:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opSPO[MN],
                                                JumpWidth = libnodave.getS16from(BD, pos + 2)
                                            });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x20:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opU[MN],
                                                Parameter = ">0"
                                            });
                                            //Result = Result + Memnoic.opU[MN] + ">0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x21:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opUN[MN],
                                                Parameter = ">0"
                                            });
                                            //Result = Result + Memnoic.opUN[MN] + ">0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x22:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opO[MN],
                                                Parameter = ">0"
                                            });
                                            //Result = Result + Memnoic.opO[MN] + ">0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x23:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opON[MN],
                                                Parameter = ">0"
                                            });
                                            //Result = Result + Memnoic.opON[MN] + ">0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x24:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opX[MN],
                                                Parameter = ">0"
                                            });
                                            //Result = Result + Memnoic.opX[MN] + ">0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x25:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opXN[MN],
                                                Parameter = ">0"
                                            });
                                            //Result = Result + Memnoic.opXN[MN] + ">0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x28:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opSPP[MN],
                                                JumpWidth = libnodave.getS16from(BD, pos + 2)
                                            });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x40:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opU[MN],
                                                Parameter = "<0"
                                            });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x41:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opUN[MN],
                                                Parameter = "<0"
                                            });
                                            //Result = Result + Memnoic.opUN[MN] + "<0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x42:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opO[MN],
                                                Parameter = "<0"
                                            });
                                            //Result = Result + Memnoic.opO[MN] + "<0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x43:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opON[MN],
                                                Parameter = "<0"
                                            });
                                            //Result = Result + Memnoic.opON[MN] + "<0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x44:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opX[MN],
                                                Parameter = "<0"
                                            });
                                            //Result = Result + Memnoic.opX[MN] + "<0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x45:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opXN[MN],
                                                Parameter = "<0"
                                            });
                                            //Result = Result + Memnoic.opXN[MN] + "<0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x48:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opSPM[MN],
                                                JumpWidth = libnodave.getS16from(BD, pos + 2)
                                            });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x50:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opU[MN],
                                                Parameter = Mnemonic.adUO[MN]
                                            });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x51:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opUN[MN],
                                                Parameter = Mnemonic.adUO[MN]
                                            });
                                            //Result = Result + Memnoic.opUN[MN] + Memnoic.adUO[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x52:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opO[MN],
                                                Parameter = Mnemonic.adUO[MN]
                                            });
                                            //Result = Result + Memnoic.opO[MN] + Memnoic.adUO[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x53:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opON[MN],
                                                Parameter = Mnemonic.adUO[MN]
                                            });
                                            //Result = Result + Memnoic.opON[MN] + Memnoic.adUO[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x54:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opX[MN],
                                                Parameter = Mnemonic.adUO[MN]
                                            });
                                            //Result = Result + Memnoic.opX[MN] + Memnoic.adUO[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x55:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opXN[MN],
                                                Parameter = Mnemonic.adUO[MN]
                                            });
                                            //Result = Result + Memnoic.opXN[MN] + Memnoic.adUO[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x58:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opSPU[MN],
                                                JumpWidth = libnodave.getS16from(BD, pos + 2)
                                            });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x60:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opU[MN],
                                                Parameter = "<>0"
                                            });
                                            //Result = Result + Memnoic.opU[MN] + "<>0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x61:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opUN[MN],
                                                Parameter = "<>0"
                                            });
                                            //Result = Result + Memnoic.opUN[MN] + "<>0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x62:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opO[MN],
                                                Parameter = "<>0"
                                            });
                                            //Result = Result + Memnoic.opO[MN] + "<>0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x63:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opON[MN],
                                                Parameter = "<>0"
                                            });
                                            //Result = Result + Memnoic.opON[MN] + "<>0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x64:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opX[MN],
                                                Parameter = "<>0"
                                            });
                                            //Result = Result + Memnoic.opX[MN] + "<>0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x65:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opXN[MN],
                                                Parameter = "<>0"
                                            });
                                            //Result = Result + Memnoic.opXN[MN] + "<>0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x68:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opSPN[MN],
                                                JumpWidth = libnodave.getS16from(BD, pos + 2)
                                            });
                                            //Result = Result + Memnoic.opSPN[MN] + "(Springe " +
                                            //         Helper.JumpStr(Helper.GetInt(BD[pos + 2], BD[pos + 3])) + " W)";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x78:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opSPBIN[MN],
                                                JumpWidth = libnodave.getS16from(BD, pos + 2)
                                            });
                                            //Result = Result + Memnoic.opSPBIN[MN] + "(Springe " +
                                            //         Helper.JumpStr(Helper.GetInt(BD[pos + 2], BD[pos + 3])) + " W)";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x80:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opU[MN],
                                                Parameter = "==0"
                                            });
                                            //Result = Result + Memnoic.opU[MN] + "==0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x81:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opUN[MN],
                                                Parameter = "==0"
                                            });
                                            //Result = Result + Memnoic.opUN[MN] + "==0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x82:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opO[MN],
                                                Parameter = "==0"
                                            });
                                            //Result = Result + Memnoic.opO[MN] + "==0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x83:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opON[MN],
                                                Parameter = "==0"
                                            });
                                            //Result = Result + Memnoic.opON[MN] + "==0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x84:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opX[MN],
                                                Parameter = "==0"
                                            });
                                            //Result = Result + Memnoic.opX[MN] + "==0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x85:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opXN[MN],
                                                Parameter = "==0"
                                            });
                                            //Result = Result + Memnoic.opXN[MN] + "==0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0x88:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opSPZ[MN],
                                                JumpWidth = libnodave.getS16from(BD, pos + 2)
                                            });
                                            //Result = Result + Memnoic.opSPZ[MN] + "(Springe " +
                                            //         Helper.JumpStr(Helper.GetInt(BD[pos + 2], BD[pos + 3])) + " W)";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0x98:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opSPBNB[MN],
                                                JumpWidth = libnodave.getS16from(BD, pos + 2)
                                            });
                                            //Result = Result + Memnoic.opSPBNB[MN] + "(Springe " +
                                            //         Helper.JumpStr(Helper.GetInt(BD[pos + 2], BD[pos + 3])) + " W)";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xA0:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opU[MN],
                                                Parameter = ">=0"
                                            });
                                            //Result = Result + Memnoic.opU[MN] + ">=0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0xA1:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opUN[MN],
                                                Parameter = ">=0"
                                            });
                                            //Result = Result + Memnoic.opUN[MN] + ">=0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0xA2:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opO[MN],
                                                Parameter = ">=0"
                                            });
                                            //Result = Result + Memnoic.opO[MN] + ">=0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0xA3:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opON[MN],
                                                Parameter = ">=0"
                                            });
                                            //Result = Result + Memnoic.opON[MN] + ">=0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0xA4:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opX[MN],
                                                Parameter = ">=0"
                                            });
                                            //Result = Result + Memnoic.opX[MN] + ">=0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0xA5:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opXN[MN],
                                                Parameter = ">=0"
                                            });
                                            //Result = Result + Memnoic.opXN[MN] + ">=0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0xA8:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opSPPZ[MN],
                                                JumpWidth = libnodave.getS16from(BD, pos + 2)
                                            });
                                            //Result = Result + Memnoic.opSPPZ[MN] + "(Springe " +
                                            //         Helper.JumpStr(Helper.GetInt(BD[pos + 2], BD[pos + 3])) + " W)";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xB8:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opSPBN[MN],
                                                JumpWidth = libnodave.getS16from(BD, pos + 2)
                                            });
                                            //Result = Result + Memnoic.opSPBN[MN] + "(Springe " +
                                            //         Helper.JumpStr(Helper.GetInt(BD[pos + 2], BD[pos + 3])) + " W)";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xC0:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opU[MN],
                                                Parameter = "<=0"
                                            });
                                            //Result = Result + Memnoic.opU[MN] + "<=0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0xC1:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opUN[MN],
                                                Parameter = "<=0"
                                            });
                                            //Result = Result + Memnoic.opUN[MN] + "<=0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0xC2:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opO[MN],
                                                Parameter = "<=0"
                                            });
                                            //Result = Result + Memnoic.opO[MN] + "<=0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0xC3:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opON[MN],
                                                Parameter = "<=0"
                                            });
                                            //Result = Result + Memnoic.opON[MN] + "<=0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0xC4:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opX[MN],
                                                Parameter = "<=0"
                                            });
                                            //Result = Result + Memnoic.opX[MN] + "<=0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0xC5:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opXN[MN],
                                                Parameter = "<=0"
                                            });
                                            //Result = Result + Memnoic.opXN[MN] + "<=0";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0xC8:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opSPMZ[MN],
                                                JumpWidth = libnodave.getS16from(BD, pos + 2)
                                            });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xD8:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opSPBB[MN],
                                                JumpWidth = libnodave.getS16from(BD, pos + 2)
                                            });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xE0:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opU[MN],
                                                Parameter = Mnemonic.adBIE[MN]
                                            });
                                            //Result = Result + Memnoic.opU[MN] + Memnoic.adBIE[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0xE1:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opUN[MN],
                                                Parameter = Mnemonic.adBIE[MN]
                                            });
                                            //Result = Result + Memnoic.opUN[MN] + Memnoic.adBIE[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0xE2:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opO[MN],
                                                Parameter = Mnemonic.adBIE[MN]
                                            });
                                            //Result = Result + Memnoic.opO[MN] + Memnoic.adBIE[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0xE3:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opON[MN],
                                                Parameter = Mnemonic.adBIE[MN]
                                            });
                                            //Result = Result + Memnoic.opON[MN] + Memnoic.adBIE[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0xE4:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opX[MN],
                                                Parameter = Mnemonic.adBIE[MN]
                                            });
                                            //Result = Result + Memnoic.opX[MN] + Memnoic.adBIE[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0xE5:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opXN[MN],
                                                Parameter = Mnemonic.adBIE[MN]
                                            });
                                            //Result = Result + Memnoic.opXN[MN] + Memnoic.adBIE[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0xE8:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opSPBI[MN],
                                                JumpWidth = libnodave.getS16from(BD, pos + 2)
                                            });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xF8:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opSPB[MN],
                                                JumpWidth = libnodave.getS16from(BD, pos + 2)
                                            });
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                            pos += 4;
                                        }
                                        break;
                                    case 0xF1:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opUNO[MN],
                                            });
                                            //Result = Result + Memnoic.opUNO[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0xF3:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opONO[MN],
                                            });
                                            //Result = Result + Memnoic.opONO[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0xF4:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opXO[MN],
                                            });
                                            //Result = Result + Memnoic.opXO[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0xF5:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opXNO[MN],
                                            });
                                            //Result = Result + Memnoic.opXNO[MN];
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    case 0xFF:
                                        {
                                            retVal.Add(new S7FunctionBlockRow()
                                            {
                                                Command = Mnemonic.opNOP[MN],
                                                Parameter = "1"
                                            });
                                            //Result = Result + Memnoic.opNOP[MN] + "1";
                                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                                            pos += 2;
                                        }
                                        break;
                                    default:
                                        retVal.Add(new S7FunctionBlockRow() { Command = "errf" });
                                        ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1], BD[pos + 2], BD[pos + 3] };
                                        pos += 4;
                                        break;
                                }
                            }
                            break;
                        default:
                            retVal.Add(new S7FunctionBlockRow() { Command = "err7" });
                            ((S7FunctionBlockRow)retVal[retVal.Count - 1]).MC7 = new byte[] { BD[pos], BD[pos + 1] };
                            pos += 2;
                            break;
                    }
                //Result = Result + "\r\n";
            }

            if (Networks != null)
                NetWork.NetworkCheck(ref Networks, ref retVal, ref counter, oldpos, pos, ref NWNr);

            //Go throug retval and add Symbols...
            if (prjBlkFld!=null)
            {
                if (prjBlkFld.SymbolTable!=null)
                {
                    foreach (S7FunctionBlockRow awlRow in retVal)
                    {
                        string para = awlRow.Parameter.Replace(" ", "");

                        awlRow.SymbolTableEntry = prjBlkFld.SymbolTable.GetEntryFromOperand(para);
                    }
                }
            }

            /*
            //Use the Jump-Marks from the Step7 project....
            string[] jumpNames = null;
            int cntJ = 0;
            if (JumpMarks!=null)
            {
                string aa = System.Text.Encoding.GetEncoding("ISO-8859-1").GetString(JumpMarks);
                int anzJ = JumpMarks[4] + JumpMarks[5]*0x100;
                jumpNames = new string[anzJ];

                for (int n = 6; n < JumpMarks.Length; n++)
                {
                    if (JumpMarks[n] != 0 && cntJ < anzJ)
                    {
                        if (jumpNames[cntJ] == null)
                            jumpNames[cntJ] = "";
                        jumpNames[cntJ] = jumpNames[cntJ] + (char) JumpMarks[n];
                    }
                    else
                        cntJ++;
                }
                cntJ = 0;
            }
            */

            //Build the Jumps: Create a List with the Addresses, Look for Jumps, Add Jump Marks
            int JumpCount = 0;
            int akBytePos = 0;
            Dictionary<int, S7FunctionBlockRow> ByteAdressNumerPLCFunctionBlocks = new Dictionary<int, S7FunctionBlockRow>();
            foreach (S7FunctionBlockRow tmp in retVal)
            {
                if (tmp.ByteSize > 0)
                {
                    ByteAdressNumerPLCFunctionBlocks.Add(akBytePos, tmp);
                    akBytePos += tmp.ByteSize;
                }
            }

            akBytePos = 0;
            foreach (S7FunctionBlockRow tmp in retVal)
            {
                if (Helper.IsJump(tmp,MN))
                {
                    int jmpBytePos = 0;

                    if (tmp.Command==Mnemonic.opSPL[MN])
                        jmpBytePos = akBytePos + ((tmp.JumpWidth+1)*4);
                    else
                        jmpBytePos = akBytePos + (tmp.JumpWidth*2);

                    if (ByteAdressNumerPLCFunctionBlocks.ContainsKey(jmpBytePos))
                    {
                        var target = ByteAdressNumerPLCFunctionBlocks[jmpBytePos];
                        if (target.Label == "")
                        {
                            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!
                        byte[] backup = tmp.MC7;
                        tmp.Parameter = target.Label;
                        tmp.MC7 = backup;
                    }
                    else
                    {
                        byte[] backup = tmp.MC7;
                        tmp.Parameter = "Error! JumpWidth :" + tmp.JumpWidth;
                        tmp.MC7 = backup;
                    }

                }
                akBytePos += tmp.ByteSize;
            }
            //End Building of the Jumps.*/

            return retVal;
        }
示例#13
0
        private SymbolTable _GetSymTabForProject(S7ProgrammFolder myBlockFolder, bool showDeleted)
        {
            string tmpId1 = "";

            var retVal = new SymbolTable() { Project = this };

            int tmpId2 = 0;

            //Look in Sym-LinkList for ID
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "YDBs" + _DirSeperator + "YLNKLIST.DBF", _ziphelper, _DirSeperator);
                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool) row["DELETED_FLAG"])
                    {
                        if ((int) row["TOI"] == myBlockFolder.ID)
                        {
                            tmpId2 = (int) row["SOI"];
                            break;
                        }
                    }
                }

                if (tmpId2 == 0 && showDeleted)
                    foreach (DataRow row in dbfTbl.Rows)
                    {
                        if ((int) row["TOI"] == myBlockFolder.ID)
                        {
                            tmpId2 = (int) row["SOI"];
                            retVal.Folder = ProjectFolder + "YDBs" + _DirSeperator + tmpId2.ToString() + _DirSeperator;
                            break;
                        }
                    }
            }

            //Look fro Symlist Name
            {
                var dbfTbl = DBF.ParseDBF.ReadDBF(ProjectFolder + "YDBs" + _DirSeperator + "SYMLISTS.DBF", _ziphelper, _DirSeperator);
                foreach (DataRow row in dbfTbl.Rows)
                {
                    if (!(bool)row["DELETED_FLAG"] || showDeleted)
                    {
                        if ((int)row["_ID"] == tmpId2)
                        {
                            retVal.Name = (string)row["_UName"];
                            if ((bool)row["DELETED_FLAG"]) retVal.Name = "$$_" + retVal.Name;
                            break;
                        }
                    }
                }
            }

            if (string.IsNullOrEmpty(retVal.Name) && !File.Exists(ProjectFolder + "YDBs" + _DirSeperator + tmpId2.ToString() + _DirSeperator + "SYMLIST.DBF"))
                return null;

            retVal.showDeleted = showDeleted;
            if (tmpId2 != 0)
                retVal.Folder = ProjectFolder + "YDBs" + _DirSeperator + tmpId2.ToString() + _DirSeperator;
            //Look in Sym-List
            /*
            if (tmpId2 != 0)
            {
                try
                {
                    var dbfTbl = DBF.ParseDBF.ReadDBF(_projectfolder + "YDBs" + _DirSeperator + tmpId2.ToString() + _DirSeperator + "SYMLIST.DBF", _zipfile);
                    foreach (DataRow row in dbfTbl.Rows)
                    {
                        if (!(bool)row["DELETED_FLAG"] || showDeleted)
                        {
                            SymbolTableEntry sym = new SymbolTableEntry();
                            sym.Symbol = (string)row["_SKZ"];
                            sym.Operand = (string)row["_OPHIST"];
                            sym.OperandIEC = (string)row["_OPIEC"];
                            sym.DataType = (string)row["_DATATYP"];
                            sym.Comment = (string)row["_COMMENT"];
                            if ((bool)row["DELETED_FLAG"]) sym.Comment = "(deleted) " + sym.Comment;
                            retVal.Step7SymbolTableEntrys.Add(sym);
                        }
                    }
                }
                catch (Exception)
                {
                }
            }
            */
            return retVal;
        }