Beispiel #1
0
            public void parseNormalBlock(DbfRow row)
            {
                GeneralType = PlcParser.DatabaseType.NormalBlocks;

                DatabaseId = row.GetValue("OBJECTID").ToString();

                BlockNumber  = row.GetValue("BLKNUMBER").ToString();
                bBlockNumber = ushort.Parse(BlockNumber);

                string lanStrig = row.GetValue("BLKLANG").ToString();

                bBlockLanguage = byte.Parse(lanStrig);
                try
                {
                    BlockLanguage = BlockLanguages[int.Parse(lanStrig)];
                }
                catch { }

                string blockTypeNr = row.GetValue("SUBBLKTYP").ToString();

                bBlockType = byte.Parse(blockTypeNr);
                BlockType  = BlockTypes.TryGetValue(bBlockType, out string BlkType) ? BlkType : blockTypeNr;

                string time1 = row.GetValue("TIMESTAMP1").ToString();

                byte[] A = encoding.GetBytes(time1);
                parseS7Time(A,
                            out DateTime time,
                            out byte[] time_ms,
                            out byte[] time_dy);
                CodeTime    = time;
                CodeTime_ms = time_ms;
                CodeTime_dy = time_dy;

                string time2 = row.GetValue("TIMESTAMP2").ToString();

                byte[] B = encoding.GetBytes(time2);
                parseS7Time(B,
                            out DateTime time_2,
                            out time_ms,
                            out time_dy);
                IntfTime    = time_2;
                IntfTime_ms = time_ms;
                IntfTime_dy = time_dy;

                Checksum = ushort.Parse(row.GetValue("CHECKSUM").ToString());

                if (bBlockType != 6 && bBlockType != 5)
                {
                    Mc5Len     = ushort.Parse(row.GetValue("MC5LEN").ToString());
                    SsbLen     = ushort.Parse(row.GetValue("SSBLEN").ToString());
                    AddLen     = ushort.Parse(row.GetValue("ADDLEN").ToString());
                    LocDataLen = ushort.Parse(row.GetValue("LOCDATALEN").ToString());
                }
                else
                {
                    uintMc5Len     = uint.Parse(row.GetValue("MC5LEN").ToString());
                    uintSsbLen     = uint.Parse(row.GetValue("SSBLEN").ToString());
                    uintAddLen     = uint.Parse(row.GetValue("ADDLEN").ToString());
                    uintLocDataLen = uint.Parse(row.GetValue("LOCDATALEN").ToString());
                }

                string blkLength = row.GetValue("BLKTOTLEN").ToString();

                BlockTotLen = uint.Parse(blkLength);
                LoadMemLen  = uint.Parse((BlockTotLen - 6).ToString());

                /// Attribute
                /// Non-retain: 00X0 0000: 1:Non retain=yes, 0=Non retain=no
                string attr = row.GetValue("ATTRIBUTE").ToString();

                Attribute = byte.Parse(attr);

                AgReserved = encoding.GetBytes(row.GetValue("AGRESERVED").ToString());

                Password = byte.Parse(row.GetValue("PASSWORD").ToString());

                Author  = row.GetValue("USERNAME").ToString();
                bAuthor = encoding.GetBytes(Author);

                Family  = row.GetValue("BLOCKFNAME").ToString();
                bFamily = encoding.GetBytes(Family);

                Name  = row.GetValue("BLOCKNAME").ToString();
                bName = encoding.GetBytes(Name);

                Version = byte.Parse(row.GetValue("VERSION").ToString());

                try
                {
                    MC5CODE  = row.GetValue("MC5CODE").ToString();
                    bMC5CODE = encoding.GetBytes(MC5CODE);

                    SSBPART  = row.GetValue("SSBPART").ToString();
                    bSSBPART = encoding.GetBytes(SSBPART);

                    ADDINFO  = row.GetValue("ADDINFO").ToString();
                    bADDINFO = encoding.GetBytes(ADDINFO);
                }
                catch (Exception Ex)
                {
                    Console.WriteLine(Ex);
                }
            }