コード例 #1
0
        /// <summary>
        ///     Hàm đọc danh sách các gói dữ liệu.
        /// </summary>
        /// <param name="dvNode">XmlNode</param>
        /// <returns>Danh sách gói dữ liệu</returns>
        public List <DataBlock> GetDataBlocks(XmlNode dvNode)
        {
            List <DataBlock> dbList = new List <DataBlock>();

            try
            {
                foreach (XmlNode dbNote in dvNode)
                {
                    DataBlock db = new DataBlock
                    {
                        ChannelId     = int.Parse(dbNote.Attributes[CHANNEL_ID].Value),
                        DeviceId      = int.Parse(dbNote.Attributes[DEVICE_ID].Value),
                        DataBlockId   = int.Parse(dbNote.Attributes[DATABLOCK_ID].Value),
                        DataBlockName = dbNote.Attributes[DATABLOCK_NAME].Value,
                        TypeOfRead    = $"{dbNote.Attributes[TypeOfRead].Value}",
                        StartAddress  = ushort.Parse(dbNote.Attributes[START_ADDRESS].Value),
                        MemoryType    = $"{dbNote.Attributes[MemoryType].Value}",
                        Length        = ushort.Parse(dbNote.Attributes[LENGTH].Value),
                        DataType      = (DataTypes)System.Enum.Parse(typeof(DataTypes), string.Format("{0}", dbNote.Attributes[DATA_TYPE].Value)),
                        IsArray       = bool.Parse(dbNote.Attributes[Is_Array].Value),
                        Description   = dbNote.Attributes[ChannelService.DESCRIPTION].Value,
                        Tags          = objTagManager.GetTags(dbNote)
                    };
                    dbList.Add(db);
                }
            }
            catch (Exception ex)
            {
                EventscadaException?.Invoke(GetType().Name, ex.Message);
            }

            return(dbList);
        }
コード例 #2
0
        /// <summary>
        ///     Hàm đọc danh sách các gói dữ liệu.
        /// </summary>
        /// <param name="dvNode">XmlNode</param>
        /// <returns>Danh sách gói dữ liệu</returns>
        public List <DataBlock> GetDataBlocks(XmlNode dvNode)
        {
            var dbList = new List <DataBlock>();

            try
            {
                foreach (XmlNode dbNote in dvNode)
                {
                    var db = new DataBlock();
                    db.ChannelId     = int.Parse(dbNote.Attributes[CHANNEL_ID].Value);
                    db.DeviceId      = int.Parse(dbNote.Attributes[DEVICE_ID].Value);
                    db.DataBlockId   = int.Parse(dbNote.Attributes[DATABLOCK_ID].Value);
                    db.DataBlockName = dbNote.Attributes[DATABLOCK_NAME].Value;
                    db.TypeOfRead    = $"{dbNote.Attributes[TypeOfRead].Value}";
                    db.StartAddress  = ushort.Parse(dbNote.Attributes[START_ADDRESS].Value);
                    db.MemoryType    = $"{dbNote.Attributes[MemoryType].Value}";
                    db.Length        = ushort.Parse(dbNote.Attributes[LENGTH].Value);
                    db.DataType      = dbNote.Attributes[DATA_TYPE].Value;
                    db.Description   = dbNote.Attributes[ChannelService.DESCRIPTION].Value;
                    db.Tags          = objTagManager.GetTags(dbNote);
                    dbList.Add(db);
                }
            }
            catch (Exception ex)
            {
                EventscadaException?.Invoke(this.GetType().Name, ex.Message);
            }

            return(dbList);
        }