Exemplo n.º 1
0
        public CreatePocoClassSoftWiredTemplate(DbfRow row)
        {
            if (fieldColumns == null)
            { // First/Reinitialized use of this class (WARNING! DbfRow.IColumn[] definition must same in all call or use Reinitialize() smartly.
                string[] names = Enum.GetNames(typeof(FieldNames));
                fieldColumns = new IColumn[names.Length];

                for (int i = 0; i < names.Length; i++)
                {
                    fieldColumns[i] = row.FindColumnByName(names[i], partiallyFilledEnable); // if ! partiallyFilledEnable and not found a field, it throw an exeption
                }
            }

            //

            _recNo_ = row.recNo;

            IColumn column;

            // assign properties with values of fields of DBF table
            // '/*FIELDASSIGNS*/' changed to makes target text, do not delete next line!      /*DROP_LINE*/
            /*FIELDASSIGNS*/
            column = fieldColumns[(int)FieldNames.FIELDNAME]; /*DROP_LINE*/                         // syntax check/template for generated code
            if ((column != null) && !row.IsNull(column)) /*DROP_LINE*/                              // syntax check/template for generated code
            { /*DROP_LINE*/                                                                         // syntax check/template for generated code
                FIELDNAME = row.GetInt32(column); /*DROP_LINE*/                                     // syntax check/template for generated code
            } /*DROP_LINE*/                                                                         // syntax check/template for generated code
        }
Exemplo n.º 2
0
            public void parseBlockFolders(DbfRow row)
            {
                GeneralType = PlcParser.DatabaseType.NormalBlockFolders;

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

                NumFB             = ushort.Parse(row.GetValue("ANZFB").ToString());
                NumFC             = ushort.Parse(row.GetValue("ANZFC").ToString());
                NumOB             = ushort.Parse(row.GetValue("ANZOB").ToString());
                NumDB             = ushort.Parse(row.GetValue("ANZDB").ToString());
                TotNumberOfBlocks = (int)NumFB + (int)NumFC + (int)NumOB + (int)NumDB;

                string time1 = row.GetValue("Lastmod").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("Crdate").ToString();

                byte[] B = encoding.GetBytes(time2);
                parseS7Time(B,
                            out time,
                            out time_ms,
                            out time_dy);
                IntfTime    = time;
                IntfTime_ms = time_ms;
                IntfTime_dy = time_dy;
            }
Exemplo n.º 3
0
            public void parseSystemDataFolders(DbfRow row)
            {
                GeneralType = PlcParser.DatabaseType.SystemDataFolders;

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

                SystemDataMLFB  = row.GetValue("MLFB").ToString();
                bSystemDataMLFB = encoding.GetBytes(SystemDataMLFB);
            }
        public CreatePocoClassHardWiredTemplate(DbfRow row)
        {
            _recNo_ = row.recNo;

            // assign properties with values of fields of DBF table
            // '/*FIELDASSIGNS*/' changed to makes target text, do not delete next line!      /*DROP_LINE*/
            /*FIELDASSIGNS*/
            FIELDNAME = row.GetInt32(row.columns[(int)FieldNames.FIELDNAME]); /*DROP_LINE*/             // syntax check/template for generated code
        }
Exemplo n.º 5
0
            public void parseSystemDataBlock(DbfRow row, string path)
            {
                GeneralType = PlcParser.DatabaseType.SystemDataBlock;

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

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

                string blockType = row.GetValue("TYPE").ToString();

                iBlockType = int.Parse(blockType);
                BlockType  = "SDB";

                string time1 = row.GetValue("TS1").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("TS2").ToString();

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

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

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

                string attr = row.GetValue("ATTRIBUTE").ToString();

                Attribute = byte.Parse(attr);

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

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

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

                parsePGfile(path);
            }
Exemplo n.º 6
0
 static void DisplayTest4DField(DbfRow row)
 {
     Console.WriteLine();
     Console.WriteLine("C10: " + row.GetString("C10"));
     Console.WriteLine("D:   " + row.GetDate("D").ToShortDateString());
     Console.WriteLine("L:   " + row.GetBoolean("L"));
     Console.WriteLine("I:   " + row.GetDecimal("I"));                                 // row.GetInt32("I") + " | " +
     Console.WriteLine("N5:  " + row.GetDecimal("N5"));
     Console.WriteLine("N10: " + row.GetDecimal("N10"));
     Console.WriteLine("B:   " + row.GetString("B"));
 }
Exemplo n.º 7
0
        public CreatePocoClassDynamicTemplate(DbfRow row, bool partiallyFilledEnable)
        {
            _recNo_ = row.recNo;

            IColumn column;

            // assign properties with values of fields of DBF table
            // '/*FIELDASSIGNS*/' changed to makes target text, do not delete next line!      /*DROP_LINE*/
            /*FIELDASSIGNS*/
            column = row.FindColumnByName("FIELDNAME", partiallyFilledEnable); /*DROP_LINE*/        // syntax check/template for generated code
            if ((column != null) && !row.IsNull(column)) /*DROP_LINE*/                              // syntax check/template for generated code
            { /*DROP_LINE*/                                                                         // syntax check/template for generated code
                FIELDNAME = row.GetInt32(column); /*DROP_LINE*/                                     // syntax check/template for generated code
            } /*DROP_LINE*/                                                                         // syntax check/template for generated code
        }
Exemplo n.º 8
0
            }                         // header byte 5

            public Item(DbfRow row, DatabaseType GeneralType, string path = "")
            {
                switch (GeneralType)
                {
                case (PlcParser.DatabaseType.SystemDataBlock):
                    parseSystemDataBlock(row, path);
                    break;

                case (PlcParser.DatabaseType.NormalBlocks):
                    parseNormalBlock(row);
                    break;

                case (PlcParser.DatabaseType.NormalBlockFolders):
                    parseBlockFolders(row);
                    break;

                case (PlcParser.DatabaseType.SystemDataFolders):
                    parseSystemDataFolders(row);
                    break;
                }
            }
Exemplo n.º 9
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);
                }
            }
Exemplo n.º 10
0
 public CreatePocoClassDynamicTemplate(DbfRow row)
     : this(row, partiallyFilledEnable)
 {
 }