public Block GetBlock(ProjectBlockInfo blkInfo)
        {
            S7ProjectSourceInfo srcInfo = (S7ProjectSourceInfo)blkInfo;

            S7SourceBlock retVal = new S7SourceBlock();

            retVal.Text = GetSource(srcInfo);

            retVal.Name         = srcInfo.Name;
            retVal.ParentFolder = srcInfo.ParentFolder;
            retVal.Filename     = srcInfo.Filename;

            return(retVal);
        }
Esempio n. 2
0
        public Block GetBlock(ProjectBlockInfo blkInfo)
        {
            S7ProjectSourceInfo srcInfo = (S7ProjectSourceInfo)blkInfo;

            S7SourceBlock retVal = new S7SourceBlock();

            retVal.Name          = srcInfo.Name;
            retVal.BlockNumber   = blkInfo.id;
            retVal.ParentFolder  = srcInfo.ParentFolder;
            retVal.Filename      = srcInfo.Filename;
            retVal.BlockType     = srcInfo.BlockType;
            retVal.BlockLanguage = PLCLanguage.SRC;


            // Read header
            if (((Step7ProjectV5)Project)._ziphelper.FileExists(Folder + "S7CONTAI.DBF"))
            {
                var       dbfTbl  = DBF.ParseDBF.ReadDBF(Folder + "S7CONTAI.DBF", ((Step7ProjectV5)Project)._ziphelper, ((Step7ProjectV5)Project)._DirSeperator);
                DataRow[] bstRows = dbfTbl.Select("ID = " + blkInfo.id);

                // Should get only one record
                if (bstRows.Length == 1)
                {
                    DataRow bstRow = bstRows[0];
                    retVal.Author      = (string)bstRow["CREATOR"];
                    retVal.Description = (string)bstRow["COMMENT"];
                    // TODO: Parse CRDATE1/2 fields in the DBF
                    int ver = ((int)bstRow["VERSION"]);
                    retVal.Version = (ver / 15).ToString() + "." + (ver % 15).ToString();
                }
            }


            // Read source file
            if (((Step7ProjectV5)Project)._ziphelper.FileExists(srcInfo.Filename))
            {
                // Get a file timestamp for now
                retVal.LastCodeChange = ((Step7ProjectV5)Project)._ziphelper.FileModDateTime(srcInfo.Filename);
                Stream strm = ((Step7ProjectV5)Project)._ziphelper.GetReadStream(srcInfo.Filename);

                retVal.Text = new System.IO.StreamReader(strm, Encoding.UTF7).ReadToEnd();
                //ReadToEnd();
            }

            // Block size
            retVal.CodeSize = retVal.Text.Length;

            return(retVal);
        }
Esempio n. 3
0
        public Block GetBlock(ProjectBlockInfo blkInfo)
        {
            S7ProjectSourceInfo srcInfo = (S7ProjectSourceInfo)blkInfo;

            S7SourceBlock retVal = new S7SourceBlock();

            if (((Step7ProjectV5)Project)._ziphelper.FileExists(srcInfo.Filename))
            {
                Stream strm = ((Step7ProjectV5)Project)._ziphelper.GetReadStream(srcInfo.Filename);

                retVal.Text = new System.IO.StreamReader(strm, Encoding.UTF7).ReadToEnd();
                //ReadToEnd();
            }

            retVal.Name         = srcInfo.Name;
            retVal.ParentFolder = srcInfo.ParentFolder;
            retVal.Filename     = srcInfo.Filename;

            return(retVal);
        }