Example #1
0
        /// <summary>
        /// Checks the display FW Version
        /// </summary>
        //  Revision History
        //  MM/DD/YY Who Version ID Number Description
        //  -------- --- ------- -- ------ -------------------------------------------
        //  09/17/09 RCG 2.30.00           Created
        //  09/23/14 jrf 4.00.63 WR 534158 Modified way test details are set.
        private void CheckDisplayFWVersion()
        {
            // Only check this value if it's HW 2.0 or later and earlier than HW 3.0
            if (VersionChecker.CompareTo(m_AmiDevice.HWRevision, CENTRON_AMI.HW_VERSION_2_0) >= 0 &&
                VersionChecker.CompareTo(m_AmiDevice.HWRevision, CENTRON_AMI.HW_VERSION_3_0) < 0)
            {
                XMLOpenWayActiveFiles ActiveFiles = new XMLOpenWayActiveFiles();
                FirmwareSet           MeterFWSet  = ActiveFiles.GetFirmwareSet(FirmwareSet.DetermineMeterType(m_AmiDevice.DeviceClass,
                                                                                                              m_AmiDevice.HWRevision, m_AmiDevice.MeterKey_TransparentDeviceSupported));

                string MeterValue    = m_AmiDevice.DisplayModVer + "." + m_AmiDevice.DisplayModBuild;
                string ExpectedValue = "";
                string Result        = "";
                string Details       = "";
                string Reason        = "";

                if (MeterFWSet != null && File.Exists(FW_PATH + MeterFWSet.DisplayFWFile))
                {
                    CENTRON_AMI_FW_File FWFile = new CENTRON_AMI_FW_File(FW_PATH + MeterFWSet.DisplayFWFile);
                    ExpectedValue = FWFile.CompleteVersion;
                }
                else
                {
                    Reason = TestResources.ReasonNoFirmwareFile;
                }

                // Get the result string. We skip if the expected value is empty string. Pass if the values are equal
                Result = GetResultString(String.IsNullOrEmpty(ExpectedValue), MeterValue.Equals(ExpectedValue));

                Details = GetFWVersionDetails(MeterValue, ExpectedValue);

                AddTestDetail(TestResources.DisplayFirmwareVersion, Result, Details, Reason);
            }
        }
Example #2
0
        /// <summary>
        /// Checks the Register FW version
        /// </summary>
        //  Revision History
        //  MM/DD/YY Who Version ID Number Description
        //  -------- --- ------- -- ------ -------------------------------------------
        //  09/17/09 RCG 2.30.00           Created
        //  09/23/14 jrf 4.00.63 WR 534158 Modified way test details are set.
        private void CheckRegisterFWVersion()
        {
            XMLOpenWayActiveFiles ActiveFiles = new XMLOpenWayActiveFiles();
            FirmwareSet           MeterFWSet  = ActiveFiles.GetFirmwareSet(FirmwareSet.DetermineMeterType(m_AmiDevice.DeviceClass,
                                                                                                          m_AmiDevice.HWRevision, m_AmiDevice.MeterKey_TransparentDeviceSupported));

            string MeterValue = m_AmiDevice.FWRevision.ToString("F3", CultureInfo.CurrentCulture)
                                + "." + m_AmiDevice.FirmwareBuild.ToString("d3", CultureInfo.CurrentCulture);
            string ExpectedValue = "";
            string Result        = "";
            string Details       = "";
            string Reason        = "";

            if (MeterFWSet != null && File.Exists(FW_PATH + MeterFWSet.RegisterFWFile))
            {
                CENTRON_AMI_FW_File FWFile = new CENTRON_AMI_FW_File(FW_PATH + MeterFWSet.RegisterFWFile);
                ExpectedValue = FWFile.CompleteVersion;
            }
            else
            {
                Reason = TestResources.ReasonNoFirmwareFile;
            }

            // Get the result string. We skip if the expected value is empty string. Pass if the values are equal
            Result = GetResultString(String.IsNullOrEmpty(ExpectedValue), MeterValue.Equals(ExpectedValue));

            Details = GetFWVersionDetails(MeterValue, ExpectedValue);

            AddTestDetail(TestResources.RegisterFirmwareVersion, Result, Details, Reason);
        }
Example #3
0
        /// <summary>
        /// Gets the firmware set for the specified meter type
        /// </summary>
        /// <param name="type">The meter type to get the firmware set for.</param>
        /// <returns>The firmware set.</returns>
        //  Revision History
        //  MM/DD/YY Who Version Issue# Description
        //  -------- --- ------- ------ -------------------------------------------
        //  09/20/10 SCW  1.00.00       Created
        //
        public FirmwareSet GetFirmwareSet(FirmwareSet.MeterType type)
        {
            FirmwareSet SelectedSet = null;

            foreach (FirmwareSet CurrentSet in ActiveFirmwareSets)
            {
                if (CurrentSet.FirmwareSetType == type)
                {
                    SelectedSet = CurrentSet;
                    break;
                }
            }

            return(SelectedSet);
        }
Example #4
0
        /// <summary>
        /// Gets the list of active firmware sets
        /// </summary>
        /// <returns>The list of firmware sets.</returns>
        //  Revision History
        //  MM/DD/YY Who Version Issue# Description
        //  -------- --- ------- ------ -------------------------------------------
        //  09/22/09 RCG 2.30.00        Created

        private List <FirmwareSet> GetActiveFirmwareSets()
        {
            List <FirmwareSet> FirmwareSets = new List <FirmwareSet>();

            foreach (string strHWNode in XML_HW_LIST)
            {
                m_XMLSettings.SelectHWNode(strHWNode, true);

                foreach (XmlNode CurrentChild in m_XMLSettings.CurrentNode.ChildNodes)
                {
                    FirmwareSet NewSet = new FirmwareSet(CurrentChild);

                    if (NewSet != null && NewSet.FirmwareSetType != FirmwareSet.MeterType.Unknown)
                    {
                        FirmwareSets.Add(NewSet);
                    }
                }
            }

            return(FirmwareSets);
        }
Example #5
0
        protected override void Seed(RepositoryDbContext dbContext)
        {
            var domain = new Domain
            {
                Id             = Guid.Parse("DB07AB5E-A23F-4238-94CE-D52411199C18"),
                DomainName     = "Root",
                DomianType     = DomainType.RootDomain,
                CreateDateTime = DateTime.Now,
                DomainStatus   = DomainStatus.Enabled,
                IsEnabled      = true
            };

            var user = new WdUser
            {
                Id             = Guid.Parse("77F05B52-AE62-4225-9F09-153C5634031F"),
                UserName       = "******",
                LoginName      = "Root",
                Password       = "******",
                Email          = "*****@*****.**",
                Telephone      = "18679361687",
                Status         = UserStatus.Enabled,
                CreateDateTime = DateTime.Now,
                DomainId       = domain.Id,
                Roles          = new List <WdRole>(),
                IsEnabled      = true
            };

            var commUser = new WdUser()
            {
                Id             = Guid.Parse("c8c95a88-5d5d-4e80-a2d6-3ff32d472bde"),
                UserName       = "******",
                LoginName      = "CommnicationServer",
                Password       = "******",
                Email          = "*****@*****.**",
                Telephone      = "18679361687",
                Status         = UserStatus.Enabled,
                CreateDateTime = DateTime.Now,
                DomainId       = domain.Id,
                Roles          = new List <WdRole>(),
                IsEnabled      = true
            };

            var role = new WdRole
            {
                Id             = Guid.Parse("650BFB4C-7277-484A-812E-6052F6DB71C7"),
                RoleName       = "Root",
                Users          = new List <WdUser>(),
                CreateDateTime = DateTime.Now,
                Status         = RoleStatus.Enabled,
                CreateUserId   = user.Id,
                DomainId       = domain.Id,
                IsEnabled      = true
            };

            var adminRole = new WdRole()
            {
                Id             = Guid.Parse("fce321ca-8761-44c4-8204-546dfa6134e1"),
                RoleName       = "Admin",
                Users          = new List <WdUser>(),
                CreateDateTime = DateTime.Now,
                Status         = RoleStatus.Enabled,
                CreateUserId   = user.Id,
                DomainId       = domain.Id,
                IsEnabled      = true
            };

            var serverRole = new WdRole()
            {
                Id             = Guid.Parse("a45ae4cd-d0ad-4cea-b666-6787a42b2b4d"),
                RoleName       = "Server",
                Users          = new List <WdUser>(),
                CreateDateTime = DateTime.Now,
                Status         = RoleStatus.Enabled,
                CreateUserId   = user.Id,
                DomainId       = domain.Id,
                IsEnabled      = true
            };

            user.CreateUserId             = user.Id;
            user.LastUpdateUserId         = user.Id;
            user.LastUpdateDateTime       = DateTime.Now;
            user.LastLoginDateTime        = DateTime.Now;
            commUser.CreateUserId         = user.Id;
            commUser.LastUpdateUserId     = user.Id;
            commUser.LastUpdateDateTime   = DateTime.Now;
            commUser.LastLoginDateTime    = DateTime.Now;
            domain.CreateUserId           = user.Id;
            domain.LastUpdateUserId       = user.Id;
            domain.LastUpdateDateTime     = DateTime.Now;
            role.CreateUserId             = user.Id;
            role.LastUpdateUserId         = user.Id;
            role.LastUpdateDateTime       = DateTime.Now;
            adminRole.CreateUserId        = user.Id;
            adminRole.LastUpdateUserId    = user.Id;
            adminRole.LastUpdateDateTime  = DateTime.Now;
            serverRole.CreateUserId       = user.Id;
            serverRole.LastUpdateUserId   = user.Id;
            serverRole.LastUpdateDateTime = DateTime.Now;
            user.Roles.Add(role);
            role.Users.Add(user);
            commUser.Roles.Add(serverRole);
            serverRole.Users.Add(commUser);

            dbContext.Users.Add(user);
            dbContext.Users.Add(commUser);
            dbContext.Roles.Add(role);
            dbContext.Roles.Add(adminRole);
            dbContext.Roles.Add(serverRole);
            dbContext.SysDomains.Add(domain);

            var field = new SysDictionary
            {
                Id                 = Guid.Parse("7402cdb5-1e1e-4633-a7e9-7d6d15634fc0"),
                ItemName           = "Field",
                ItemKey            = "7E0384B37CFJ",
                ItemValue          = "GpsCommunication",
                ItemLevel          = 1,
                CreateUserId       = user.Id,
                CreateDateTime     = DateTime.Now,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id,
                IsEnabled          = true
            };

            var subfield = new SysDictionary
            {
                Id = Guid.Parse("24ae6ee7-a024-4052-a1de-3cc0d542d908"),
                ParentDictionaryId = field.Id,
                ItemName           = "Subield",
                ItemKey            = "7E0384B37CFL",
                ItemValue          = "GeneralFunction",
                ItemLevel          = 1,
                CreateUserId       = user.Id,
                CreateDateTime     = DateTime.Now,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id,
                IsEnabled          = true
            };

            dbContext.SysDictionaries.Add(field);
            dbContext.SysDictionaries.Add(subfield);

            var deviceType = new DeviceType
            {
                Id                 = Guid.Parse("31b9ae77-6f5b-4c70-b180-d80ecb7df12b"),
                Field              = field,
                SubField           = subfield,
                Version            = "2016-03-17",
                ReleaseDateTime    = DateTime.Now,
                DeviceTypeCode     = "WD_YC_Classic",
                CreateUserId       = user.Id,
                CreateDateTime     = DateTime.Now,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id,
                IsEnabled          = true
            };

            var firma = new Firmware
            {
                Id                 = Guid.Parse("648892a9-bf37-4490-a947-e1c0a529bba1"),
                FirmwareName       = "firma",
                CreateUserId       = user.Id,
                CreateDateTime     = DateTime.Now,
                LastUpdateUserId   = user.Id,
                LastUpdateDateTime = DateTime.Now,
                Protocols          = new List <Protocol>()
            };

            dbContext.Firmwares.Add(firma);

            var firmSet = new FirmwareSet
            {
                Id = Guid.Parse("6c36fddf-d3d9-416b-84df-cd849006eef1"),
                FirmwareSetName    = "扬尘第三版",
                CreateUserId       = user.Id,
                CreateDateTime     = DateTime.Now,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id,
                IsEnabled          = true
            };

            firmSet.Firmwares.Add(firma);
            dbContext.FirmwareSets.Add(firmSet);

            dbContext.DeviceTypes.Add(deviceType);

            var nep = new Protocol
            {
                Id                 = Guid.Parse("f59022bc-6f8c-4ced-954f-3a6d7dd29335"),
                FieldId            = field.Id,
                SubFieldId         = subfield.Id,
                CustomerInfo       = "1",
                ProtocolName       = "Nep",
                ProtocolModule     = "Nep",
                Version            = "HT212",
                ReleaseDateTime    = DateTime.Now,
                CreateUserId       = user.Id,
                CreateDateTime     = DateTime.Now,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id,
                IsEnabled          = true,
                CheckType          = ProtocolCheckType.CrcModBus,
                Head               = new byte[] { 0x23, 0x23 },
                Tail               = new byte[] { 0x0D, 0x0A }
            };

            firma.Protocols.Add(nep);

            var head = new ProtocolStructure
            {
                Id                  = Guid.Parse("2bb54221-f036-48ff-babc-22358bdf50e2"),
                ProtocolId          = nep.Id,
                StructureName       = "Head",
                StructureIndex      = 0,
                StructureDataLength = 2,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.AsciiString,
                DefaultBytes        = new byte[] { 0x23, 0x23 }
            };

            var contentLength = new ProtocolStructure
            {
                Id                  = Guid.Parse("277211ee-4ee9-4ef3-ab95-c43fce4c395b"),
                ProtocolId          = nep.Id,
                StructureName       = "ContentLength",
                StructureIndex      = 1,
                StructureDataLength = 4,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.AsciiString,
                DefaultBytes        = new byte[0]
            };

            var requestNumber = new ProtocolStructure
            {
                Id                  = Guid.Parse("e64862bb-1427-45e6-9dda-ec7925963573"),
                ProtocolId          = nep.Id,
                StructureName       = "RequestNumber",
                StructureIndex      = 2,
                StructureDataLength = 21,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.AsciiString,
                DefaultBytes        = new byte[0]
            };

            var cmdtype = new ProtocolStructure
            {
                Id                  = Guid.Parse("dcdb914f-62ec-42dc-bece-04124cfd61fa"),
                ProtocolId          = nep.Id,
                StructureName       = "CmdType",
                StructureIndex      = 3,
                StructureDataLength = 6,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.AsciiString,
                DefaultBytes        = new byte[0]
            };

            var cmdbyte = new ProtocolStructure
            {
                Id                  = Guid.Parse("fa009ac1-8a08-4243-a143-eb7cb8942660"),
                ProtocolId          = nep.Id,
                StructureName       = "CmdByte",
                StructureIndex      = 4,
                StructureDataLength = 8,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.AsciiString,
                DefaultBytes        = new byte[0]
            };

            var password = new ProtocolStructure()
            {
                Id                  = Guid.Parse("eddaa794-088a-4cc0-8c8e-b09635ba249a"),
                ProtocolId          = nep.Id,
                StructureName       = "Password",
                StructureIndex      = 5,
                StructureDataLength = 10,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.AsciiString,
                DefaultBytes        = new byte[] { 0x50, 0x57, 0x3D, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x3B }
            };

            var nodeid = new ProtocolStructure()
            {
                Id                  = Guid.Parse("ff20af2c-8f93-4755-889f-e8943c023e7d"),
                ProtocolId          = nep.Id,
                StructureName       = "NodeId",
                StructureIndex      = 6,
                StructureDataLength = 18,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.AsciiString,
                DefaultBytes        = new byte[0]
            };

            var data = new ProtocolStructure()
            {
                Id                  = Guid.Parse("4cde87be-468c-46cf-a1f9-0172f21761ca"),
                ProtocolId          = nep.Id,
                StructureName       = "Data",
                StructureIndex      = 7,
                StructureDataLength = 0,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.Data,
                DefaultBytes        = new byte[0]
            };

            var crcModBus = new ProtocolStructure()
            {
                Id                  = Guid.Parse("1bd5725a-0408-4c4a-b7ad-f2c92dd830e2"),
                ProtocolId          = nep.Id,
                StructureName       = "CrcModBus",
                StructureIndex      = 8,
                StructureDataLength = 4,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.CrcModBus,
                DefaultBytes        = new byte[] { 0x00, 0x00, 0x00, 0x00 }
            };

            var tail = new ProtocolStructure()
            {
                Id                  = Guid.Parse("6aea3080-bb97-4e50-8140-7c31728b1637"),
                ProtocolId          = nep.Id,
                StructureName       = "Tail",
                StructureIndex      = 9,
                StructureDataLength = 2,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.AsciiString,
                DefaultBytes        = new byte[] { 0x0D, 0x0A }
            };

            dbContext.ProtocolStructures.Add(head);
            dbContext.ProtocolStructures.Add(cmdtype);
            dbContext.ProtocolStructures.Add(cmdbyte);
            dbContext.ProtocolStructures.Add(password);
            dbContext.ProtocolStructures.Add(nodeid);
            dbContext.ProtocolStructures.Add(contentLength);
            dbContext.ProtocolStructures.Add(requestNumber);
            dbContext.ProtocolStructures.Add(data);
            dbContext.ProtocolStructures.Add(crcModBus);
            dbContext.ProtocolStructures.Add(tail);

            var commandReplyA = new SysConfig()
            {
                Id                 = Guid.Parse("b06c49c1-f9f7-4e69-92df-04fa55f95045"),
                SysConfigName      = ProtocolDeliveryParam.StoreData,
                SysConfigType      = SysConfigType.ProtocolDeliveryParam,
                SysConfigValue     = ProtocolDeliveryParam.StoreData,
                CreateUserId       = user.Id,
                CreateDateTime     = DateTime.Now,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id
            };

            dbContext.SysConfigs.Add(commandReplyA);

            var command = new ProtocolCommand
            {
                Id = Guid.Parse("d2ccf8b0-ed68-48ef-b185-f94b504944ca"),
                CommandTypeCode            = new byte[] { 0x32, 0x32 },
                CommandCode                = new byte[] { 0x32, 0x30, 0x31, 0x31 },
                ReceiveBytesLength         = 0,
                CommandCategory            = CommandCategory.TimingAutoReport,
                DataOrderType              = DataOrderType.Random,
                ProtocolId                 = nep.Id,
                CommandDeliverParamConfigs = new List <SysConfig> {
                    commandReplyA
                },
                CreateUserId       = user.Id,
                CreateDateTime     = DateTime.Now,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id
            };

            var commandA = new ProtocolCommand
            {
                Id = Guid.Parse("ec4260ba-b36d-40ab-b357-15345590f516"),
                CommandTypeCode            = new byte[] { 0x32, 0x32 },
                CommandCode                = new byte[] { 0x32, 0x30, 0x31, 0x31 },
                ReceiveBytesLength         = 0,
                CommandCategory            = CommandCategory.TimingAutoReport,
                DataOrderType              = DataOrderType.Random,
                ProtocolId                 = nep.Id,
                CommandDeliverParamConfigs = new List <SysConfig> {
                    commandReplyA
                },
                CreateUserId       = user.Id,
                CreateDateTime     = DateTime.Now,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id
            };

            var commandB = new ProtocolCommand
            {
                Id = Guid.Parse("9fbc1163-abf1-4f49-9bb6-64bec7946670"),
                CommandTypeCode            = new byte[] { 0x32, 0x32 },
                CommandCode                = new byte[] { 0x32, 0x30, 0x31, 0x31 },
                ReceiveBytesLength         = 0,
                CommandCategory            = CommandCategory.TimingAutoReport,
                DataOrderType              = DataOrderType.Random,
                ProtocolId                 = nep.Id,
                CommandDeliverParamConfigs = new List <SysConfig> {
                    commandReplyA
                },
                CreateUserId       = user.Id,
                CreateDateTime     = DateTime.Now,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id
            };

            var tsp = new CommandData
            {
                Id                 = Guid.NewGuid(),
                DataIndex          = 0,
                DataLength         = 0,
                DataName           = "a34001-Avg",
                DataDisplayName    = "粉尘",
                DataConvertType    = "DoubleString",
                DataValueType      = DataValueType.Double,
                DataFlag           = 0x00,
                ValidFlagIndex     = 0,
                CreateDateTime     = DateTime.Now,
                CreateUserId       = user.Id,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id
            };

            var pm25 = new CommandData
            {
                Id                 = Guid.NewGuid(),
                DataIndex          = 0,
                DataLength         = 0,
                DataName           = "a34004-Avg",
                DataDisplayName    = "PM2.5",
                DataConvertType    = "DoubleString",
                DataValueType      = DataValueType.Double,
                DataFlag           = 0x00,
                ValidFlagIndex     = 0,
                CreateDateTime     = DateTime.Now,
                CreateUserId       = user.Id,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id
            };

            var pm100 = new CommandData
            {
                Id                 = Guid.NewGuid(),
                DataIndex          = 0,
                DataLength         = 0,
                DataName           = "a34005-Avg",
                DataDisplayName    = "PM10",
                DataConvertType    = "DoubleString",
                DataValueType      = DataValueType.Double,
                DataFlag           = 0x00,
                ValidFlagIndex     = 0,
                CreateDateTime     = DateTime.Now,
                CreateUserId       = user.Id,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id
            };

            var noise = new CommandData
            {
                Id                 = Guid.NewGuid(),
                DataIndex          = 0,
                DataLength         = 0,
                DataName           = "a50001-Avg",
                DataDisplayName    = "噪音",
                DataConvertType    = "DoubleString",
                DataValueType      = DataValueType.Double,
                DataFlag           = 0x00,
                ValidFlagIndex     = 0,
                CreateDateTime     = DateTime.Now,
                CreateUserId       = user.Id,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id
            };

            var temp = new CommandData
            {
                Id                 = Guid.NewGuid(),
                DataIndex          = 0,
                DataLength         = 0,
                DataName           = "a01001-Avg",
                DataDisplayName    = "温度",
                DataConvertType    = "DoubleString",
                DataValueType      = DataValueType.Double,
                DataFlag           = 0x00,
                ValidFlagIndex     = 0,
                CreateDateTime     = DateTime.Now,
                CreateUserId       = user.Id,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id
            };

            var huma = new CommandData
            {
                Id                 = Guid.NewGuid(),
                DataIndex          = 0,
                DataLength         = 0,
                DataName           = "a01002-Avg",
                DataDisplayName    = "湿度",
                DataConvertType    = "DoubleString",
                DataValueType      = DataValueType.Double,
                DataFlag           = 0x00,
                ValidFlagIndex     = 0,
                CreateDateTime     = DateTime.Now,
                CreateUserId       = user.Id,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id
            };

            var windspeed = new CommandData
            {
                Id                 = Guid.NewGuid(),
                DataIndex          = 0,
                DataLength         = 0,
                DataName           = "a01007-Avg",
                DataDisplayName    = "风速",
                DataConvertType    = "DoubleString",
                DataValueType      = DataValueType.Double,
                DataFlag           = 0x00,
                ValidFlagIndex     = 0,
                CreateDateTime     = DateTime.Now,
                CreateUserId       = user.Id,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id
            };

            var winddir = new CommandData
            {
                Id                 = Guid.NewGuid(),
                DataIndex          = 0,
                DataLength         = 0,
                DataName           = "a01008-Avg",
                DataDisplayName    = "风向",
                DataConvertType    = "DoubleString",
                DataValueType      = DataValueType.Double,
                DataFlag           = 0x00,
                ValidFlagIndex     = 0,
                CreateDateTime     = DateTime.Now,
                CreateUserId       = user.Id,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id
            };

            command.CommandDatas = new List <CommandData> {
                tsp, pm25, pm100, noise, temp, huma, windspeed, winddir
            };
            commandA.CommandDatas = new List <CommandData> {
                tsp, pm25, pm100, noise, temp, huma, windspeed, winddir
            };
            commandB.CommandDatas = new List <CommandData> {
                tsp, pm25, pm100, noise, temp, huma, windspeed, winddir
            };
            dbContext.ProtocolCommands.Add(command);
            dbContext.ProtocolCommands.Add(commandA);
            dbContext.ProtocolCommands.Add(commandB);

            var dev = new Device()
            {
                Id               = Guid.NewGuid(),
                DeviceTypeId     = deviceType.Id,
                DeviceCode       = "扬尘硬件第三版测试一号",
                DevicePassword   = string.Empty,
                DeviceModuleGuid = Guid.NewGuid(),
                DeviceNodeId     = "KSHBZBWCOM0001",
                FirmwareSetId    = firmSet.Id,
                StartTime        = DateTime.Now,
                PreEndTime       = DateTime.Now,
                EndTime          = DateTime.Now,
                Status           = DeviceStatus.Enabled,
                DomainId         = domain.Id,
                CreateUserId     = user.Id,
                CreateDateTime   = DateTime.Now,
                IsEnabled        = true
            };

            dbContext.Devices.Add(dev);
        }
Example #6
0
        /// <summary>
        /// Checks the RFLAN FW Version
        /// </summary>
        //  Revision History
        //  MM/DD/YY Who Version ID Number Description
        //  -------- --- ------- -- ------ -------------------------------------------
        //  09/17/09 RCG 2.30.00           Created
        //  09/23/14 jrf 4.00.63 WR 534158 Modified way test details are set.
        //  11/03/14 jrf 4.00.84 WR 542970 Making sure correct type of comm module firmware version is checked.
        private void CheckRFLANFWVersion()
        {
            XMLOpenWayActiveFiles ActiveFiles = new XMLOpenWayActiveFiles();
            FirmwareSet           MeterFWSet  = ActiveFiles.GetFirmwareSet(FirmwareSet.DetermineMeterType(m_AmiDevice.DeviceClass,
                                                                                                          m_AmiDevice.HWRevision, m_AmiDevice.MeterKey_TransparentDeviceSupported));

            string MeterValue    = m_AmiDevice.CommModVer + "." + m_AmiDevice.CommModBuild;
            string ExpectedValue = "";
            string Result        = "";
            string Details       = "";
            string Reason        = "";
            string FileName      = "";

            if (MeterFWSet != null)
            {
                //Determine which comm module firmware type we are looking for.
                switch (m_AmiDevice.CommModuleDeviceClass)
                {
                case CommModuleBase.ITR2_DEVICE_CLASS:
                {
                    string strCommModuleID = null;

                    try
                    {
                        if (null != m_AmiDevice.CommModule)
                        {
                            strCommModuleID = m_AmiDevice.CommModule.CommModuleIdentification;
                        }
                    }
                    catch (PSEMException)
                    {
                        // This read may fail on some meters whose Comm Module is down
                    }

                    if (String.CompareOrdinal(strCommModuleID, CG_MESH_MODULE) == 0)
                    {
                        FileName = MeterFWSet.CiscoCommFWFile;
                    }
                    else if (m_AmiDevice is IBridge &&
                             ((IBridge)m_AmiDevice).CurrentRegisterCommOpMode == OpenWayMFGTable2428.ChoiceConnectCommOpMode.ChoiceConnectOperationalMode)
                    {
                        MeterValue = ((IBridge)m_AmiDevice).ChoiceConnectFWVerRev + "." + ((IBridge)m_AmiDevice).ChoiceConnectFWBuild;

                        FileName = MeterFWSet.ChoiceConnectFWFile;
                    }
                    else
                    {
                        FileName = MeterFWSet.LANFWFile;
                    }
                    break;
                }

                case CommModuleBase.ITRL_DEVICE_CLASS:
                {
                    FileName = MeterFWSet.LANFWFile;
                    break;
                }

                case CommModuleBase.ITRP_DEVICE_CLASS:
                {
                    FileName = MeterFWSet.PLANFWFile;
                    break;
                }

                case CENTRON_AMI.ITRH_DEVICE_CLASS:
                case CENTRON_AMI.ITRU_DEVICE_CLASS:
                case CENTRON_AMI.ITRV_DEVICE_CLASS:
                {
                    FileName = MeterFWSet.ICSFWFile;
                    break;
                }

                case CENTRON_AMI.ITRS_DEVICE_CLASS:
                {
                    FileName = MeterFWSet.CiscoCommFWFile;
                    break;
                }

                default:
                {
                    FileName = MeterFWSet.LANFWFile;
                    break;
                }
                }

                if (File.Exists(FW_PATH + FileName))
                {
                    CENTRON_AMI_FW_File FWFile = new CENTRON_AMI_FW_File(FW_PATH + FileName);
                    ExpectedValue = FWFile.CompleteVersion;
                }
                else
                {
                    Reason = TestResources.ReasonNoFirmwareFile;
                }
            }

            // Get the result string. We skip if the expected value is empty string. Pass if the values are equal
            Result = GetResultString(String.IsNullOrEmpty(ExpectedValue), MeterValue.Equals(ExpectedValue));

            Details = GetFWVersionDetails(MeterValue, ExpectedValue);

            AddTestDetail(TestResources.RFLANFirmwareVersion, Result, Details, Reason);
        }
        protected override void Seed(RepositoryDbContext dbContext)
        {
            var domain = new Domain
            {
                Id             = Guid.Parse("DB07AB5E-A23F-4238-94CE-D52411199C18"),
                DomainName     = "Root",
                DomianType     = DomainType.RootDomain,
                CreateDateTime = DateTime.Now,
                DomainStatus   = DomainStatus.Enabled,
                IsEnabled      = true
            };

            var user = new WdUser
            {
                Id             = Guid.Parse("77F05B52-AE62-4225-9F09-153C5634031F"),
                UserName       = "******",
                LoginName      = "Root",
                Password       = "******",
                Email          = "*****@*****.**",
                Telephone      = "18679361687",
                Status         = UserStatus.Enabled,
                CreateDateTime = DateTime.Now,
                DomainId       = domain.Id,
                Roles          = new List <WdRole>(),
                IsEnabled      = true
            };

            var commUser = new WdUser()
            {
                Id             = Guid.Parse("c8c95a88-5d5d-4e80-a2d6-3ff32d472bde"),
                UserName       = "******",
                LoginName      = "CommnicationServer",
                Password       = "******",
                Email          = "*****@*****.**",
                Telephone      = "18679361687",
                Status         = UserStatus.Enabled,
                CreateDateTime = DateTime.Now,
                DomainId       = domain.Id,
                Roles          = new List <WdRole>(),
                IsEnabled      = true
            };

            var role = new WdRole
            {
                Id             = Guid.Parse("650BFB4C-7277-484A-812E-6052F6DB71C7"),
                RoleName       = "Root",
                Users          = new List <WdUser>(),
                CreateDateTime = DateTime.Now,
                Status         = RoleStatus.Enabled,
                CreateUserId   = user.Id,
                DomainId       = domain.Id,
                IsEnabled      = true
            };

            var adminRole = new WdRole()
            {
                Id             = Guid.Parse("fce321ca-8761-44c4-8204-546dfa6134e1"),
                RoleName       = "Admin",
                Users          = new List <WdUser>(),
                CreateDateTime = DateTime.Now,
                Status         = RoleStatus.Enabled,
                CreateUserId   = user.Id,
                DomainId       = domain.Id,
                IsEnabled      = true
            };

            var serverRole = new WdRole()
            {
                Id             = Guid.Parse("a45ae4cd-d0ad-4cea-b666-6787a42b2b4d"),
                RoleName       = "Server",
                Users          = new List <WdUser>(),
                CreateDateTime = DateTime.Now,
                Status         = RoleStatus.Enabled,
                CreateUserId   = user.Id,
                DomainId       = domain.Id,
                IsEnabled      = true
            };

            user.CreateUserId             = user.Id;
            user.LastUpdateUserId         = user.Id;
            user.LastUpdateDateTime       = DateTime.Now;
            user.LastLoginDateTime        = DateTime.Now;
            commUser.CreateUserId         = user.Id;
            commUser.LastUpdateUserId     = user.Id;
            commUser.LastUpdateDateTime   = DateTime.Now;
            commUser.LastLoginDateTime    = DateTime.Now;
            domain.CreateUserId           = user.Id;
            domain.LastUpdateUserId       = user.Id;
            domain.LastUpdateDateTime     = DateTime.Now;
            role.CreateUserId             = user.Id;
            role.LastUpdateUserId         = user.Id;
            role.LastUpdateDateTime       = DateTime.Now;
            adminRole.CreateUserId        = user.Id;
            adminRole.LastUpdateUserId    = user.Id;
            adminRole.LastUpdateDateTime  = DateTime.Now;
            serverRole.CreateUserId       = user.Id;
            serverRole.LastUpdateUserId   = user.Id;
            serverRole.LastUpdateDateTime = DateTime.Now;
            user.Roles.Add(role);
            role.Users.Add(user);
            commUser.Roles.Add(serverRole);
            serverRole.Users.Add(commUser);

            dbContext.Users.Add(user);
            dbContext.Users.Add(commUser);
            dbContext.Roles.Add(role);
            dbContext.Roles.Add(adminRole);
            dbContext.Roles.Add(serverRole);
            dbContext.SysDomains.Add(domain);

            var field = new SysDictionary
            {
                Id                 = Guid.Parse("7402cdb5-1e1e-4633-a7e9-7d6d15634fc0"),
                ItemName           = "Field",
                ItemKey            = "7E0384B37CFJ",
                ItemValue          = "GpsCommunication",
                ItemLevel          = 1,
                CreateUserId       = user.Id,
                CreateDateTime     = DateTime.Now,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id,
                IsEnabled          = true
            };

            var subfield = new SysDictionary
            {
                Id = Guid.Parse("24ae6ee7-a024-4052-a1de-3cc0d542d908"),
                ParentDictionaryId = field.Id,
                ItemName           = "Subield",
                ItemKey            = "7E0384B37CFL",
                ItemValue          = "GeneralFunction",
                ItemLevel          = 1,
                CreateUserId       = user.Id,
                CreateDateTime     = DateTime.Now,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id,
                IsEnabled          = true
            };

            dbContext.SysDictionaries.Add(field);
            dbContext.SysDictionaries.Add(subfield);

            var deviceType = new DeviceType
            {
                Id                 = Guid.Parse("31b9ae77-6f5b-4c70-b180-d80ecb7df12b"),
                Field              = field,
                SubField           = subfield,
                Version            = "2016-03-17",
                ReleaseDateTime    = DateTime.Now,
                DeviceTypeCode     = "WD_YC_Classic",
                CreateUserId       = user.Id,
                CreateDateTime     = DateTime.Now,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id,
                IsEnabled          = true
            };

            var firma = new Firmware
            {
                Id                 = Guid.Parse("648892a9-bf37-4490-a947-e1c0a529bba1"),
                FirmwareName       = "firma",
                CreateUserId       = user.Id,
                CreateDateTime     = DateTime.Now,
                LastUpdateUserId   = user.Id,
                LastUpdateDateTime = DateTime.Now,
                Protocols          = new List <Protocol>()
            };

            dbContext.Firmwares.Add(firma);

            var firmSet = new FirmwareSet
            {
                Id = Guid.Parse("6c36fddf-d3d9-416b-84df-cd849006eef1"),
                FirmwareSetName    = "扬尘第三版",
                CreateUserId       = user.Id,
                CreateDateTime     = DateTime.Now,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id,
                IsEnabled          = true
            };

            firmSet.Firmwares.Add(firma);
            dbContext.FirmwareSets.Add(firmSet);

            dbContext.DeviceTypes.Add(deviceType);

            var classic = new Protocol
            {
                Id                 = Guid.Parse("f59022bc-6f8c-4ced-954f-3a6d7dd29335"),
                FieldId            = field.Id,
                SubFieldId         = subfield.Id,
                CustomerInfo       = "1",
                ProtocolName       = "Classic",
                ProtocolModule     = "Classic",
                Version            = "Dust Protocol Brief V0017",
                ReleaseDateTime    = DateTime.Now,
                CreateUserId       = user.Id,
                CreateDateTime     = DateTime.Now,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id,
                IsEnabled          = true,
                CheckType          = ProtocolCheckType.Crc16,
                Head               = new byte[] { 0xAA },
                Tail               = new byte[] { 0xDD }
            };

            firma.Protocols.Add(classic);

            var head = new ProtocolStructure
            {
                Id                  = Guid.Parse("2bb54221-f036-48ff-babc-22358bdf50e2"),
                ProtocolId          = classic.Id,
                StructureName       = "Head",
                StructureIndex      = 0,
                StructureDataLength = 1,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.SingleByte,
                DefaultBytes        = new byte[] { 0xAA }
            };

            var cmdtype = new ProtocolStructure
            {
                Id                  = Guid.Parse("dcdb914f-62ec-42dc-bece-04124cfd61fa"),
                ProtocolId          = classic.Id,
                StructureName       = "CmdType",
                StructureIndex      = 1,
                StructureDataLength = 1,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.SingleByte,
                DefaultBytes        = new byte[0]
            };

            var cmdbyte = new ProtocolStructure
            {
                Id                  = Guid.Parse("fa009ac1-8a08-4243-a143-eb7cb8942660"),
                ProtocolId          = classic.Id,
                StructureName       = "CmdByte",
                StructureIndex      = 2,
                StructureDataLength = 1,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.SingleByte,
                DefaultBytes        = new byte[0]
            };

            var password = new ProtocolStructure()
            {
                Id                  = Guid.Parse("eddaa794-088a-4cc0-8c8e-b09635ba249a"),
                ProtocolId          = classic.Id,
                StructureName       = "Password",
                StructureIndex      = 3,
                StructureDataLength = 8,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.NumPassword,
                DefaultBytes        = new byte[] { 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38 }
            };

            var nodeid = new ProtocolStructure()
            {
                Id                  = Guid.Parse("ff20af2c-8f93-4755-889f-e8943c023e7d"),
                ProtocolId          = classic.Id,
                StructureName       = "NodeId",
                StructureIndex      = 4,
                StructureDataLength = 4,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.NodeId,
                DefaultBytes        = new byte[0]
            };

            var descrip = new ProtocolStructure()
            {
                Id                  = Guid.Parse("92006a07-3726-4cdc-99a4-7b3fdf7ef03d"),
                ProtocolId          = classic.Id,
                StructureName       = "Description",
                StructureIndex      = 5,
                StructureDataLength = 12,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.Description,
                DefaultBytes        = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
            };

            var sourceaddr = new ProtocolStructure()
            {
                Id                  = Guid.Parse("9ccdffd7-7d22-43d1-9185-a58541ce87f8"),
                ProtocolId          = classic.Id,
                StructureName       = "SourceAddr",
                StructureIndex      = 6,
                StructureDataLength = 1,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.SourceAddr,
                DefaultBytes        = new byte[] { 0x01 }
            };

            var destination = new ProtocolStructure()
            {
                Id                  = Guid.Parse("20ddc634-6ce6-47cc-82e1-c3df8f68abaa"),
                ProtocolId          = classic.Id,
                StructureName       = "DestinationAddr",
                StructureIndex      = 7,
                StructureDataLength = 1,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.Destination,
                DefaultBytes        = new byte[] { 0x01 }
            };

            var datalength = new ProtocolStructure()
            {
                Id                  = Guid.Parse("ad465018-24d3-400d-b7d5-712abf54ceeb"),
                ProtocolId          = classic.Id,
                StructureName       = "PayloadLength",
                StructureIndex      = 8,
                StructureDataLength = 2,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.DataLength,
                DefaultBytes        = new byte[] { 0x00, 0x00 }
            };

            var data = new ProtocolStructure()
            {
                Id                  = Guid.Parse("4cde87be-468c-46cf-a1f9-0172f21761ca"),
                ProtocolId          = classic.Id,
                StructureName       = "Data",
                StructureIndex      = 9,
                StructureDataLength = 0,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.Data,
                DefaultBytes        = new byte[0]
            };

            var crc = new ProtocolStructure()
            {
                Id                  = Guid.Parse("1bd5725a-0408-4c4a-b7ad-f2c92dd830e2"),
                ProtocolId          = classic.Id,
                StructureName       = "CRCValue",
                StructureIndex      = 10,
                StructureDataLength = 2,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.CRC,
                DefaultBytes        = new byte[] { 0x00, 0x00 }
            };

            var tail = new ProtocolStructure()
            {
                Id                  = Guid.Parse("6aea3080-bb97-4e50-8140-7c31728b1637"),
                ProtocolId          = classic.Id,
                StructureName       = "Tail",
                StructureIndex      = 11,
                StructureDataLength = 1,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.SingleByte,
                DefaultBytes        = new byte[] { 0xDD }
            };

            dbContext.ProtocolStructures.Add(head);
            dbContext.ProtocolStructures.Add(cmdtype);
            dbContext.ProtocolStructures.Add(cmdbyte);
            dbContext.ProtocolStructures.Add(password);
            dbContext.ProtocolStructures.Add(nodeid);
            dbContext.ProtocolStructures.Add(descrip);
            dbContext.ProtocolStructures.Add(sourceaddr);
            dbContext.ProtocolStructures.Add(destination);
            dbContext.ProtocolStructures.Add(datalength);
            dbContext.ProtocolStructures.Add(data);
            dbContext.ProtocolStructures.Add(crc);
            dbContext.ProtocolStructures.Add(tail);

            var commandReply = new SysConfig()
            {
                Id                 = Guid.Parse("6ca98eba-47df-45c3-9bfb-1b56865b0a11"),
                SysConfigName      = ProtocolDeliveryParam.ReplyOriginal,
                SysConfigType      = SysConfigType.ProtocolDeliveryParam,
                SysConfigValue     = ProtocolDeliveryParam.ReplyOriginal,
                CreateUserId       = user.Id,
                CreateDateTime     = DateTime.Now,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id
            };


            var commandReplyA = new SysConfig()
            {
                Id                 = Guid.Parse("b06c49c1-f9f7-4e69-92df-04fa55f95045"),
                SysConfigName      = ProtocolDeliveryParam.StoreData,
                SysConfigType      = SysConfigType.ProtocolDeliveryParam,
                SysConfigValue     = ProtocolDeliveryParam.StoreData,
                CreateUserId       = user.Id,
                CreateDateTime     = DateTime.Now,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id
            };

            var messageSource = new SysConfig
            {
                Id                 = Guid.Parse("34EDC4EC-F046-418E-A9DC-9EA3EA284F84"),
                SysConfigName      = "CommandMessageQueueName",
                SysConfigType      = SysConfigType.ProtocolAdminTools,
                SysConfigValue     = @"FormatName:Direct=TCP:121.40.49.97\private$\protocolcommand",
                CreateUserId       = user.Id,
                CreateDateTime     = DateTime.Now,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id
            };

            dbContext.SysConfigs.Add(commandReply);
            dbContext.SysConfigs.Add(commandReplyA);
            dbContext.SysConfigs.Add(messageSource);

            var commandDataA = new CommandData()
            {
                Id                 = Guid.Parse("46225dc9-ffe2-43af-bba4-7b45bbb55af2"),
                DataIndex          = 0,
                DataLength         = 2,
                DataName           = ProtocolDataName.DataValidFlag,
                DataConvertType    = ProtocolDataType.TwoBytesToUShort,
                CreateDateTime     = DateTime.Now,
                CreateUserId       = user.Id,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id
            };

            var commandDataB = new CommandData()
            {
                Id                 = Guid.Parse("489287c6-e179-4864-bd02-7f8962d5e81c"),
                DataIndex          = 1,
                DataLength         = 4,
                DataName           = "PM2.5",
                DataConvertType    = ProtocolDataType.FourBytesToUInt32,
                ValidFlagIndex     = 1,
                CreateDateTime     = DateTime.Now,
                CreateUserId       = user.Id,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id
            };

            var commandDataC = new CommandData()
            {
                Id                 = Guid.Parse("b69c75a5-c813-42a6-a3a6-5eeef561c068"),
                DataIndex          = 2,
                DataLength         = 4,
                DataName           = "PM10",
                DataConvertType    = ProtocolDataType.FourBytesToUInt32,
                ValidFlagIndex     = 1,
                CreateDateTime     = DateTime.Now,
                CreateUserId       = user.Id,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id
            };

            var commandDataD = new CommandData()
            {
                Id                 = Guid.Parse("36b4d5eb-b141-4cfd-9df5-d4508103fbbf"),
                DataIndex          = 3,
                DataLength         = 4,
                DataName           = "CPM",
                DataConvertType    = ProtocolDataType.FourBytesToUInt32,
                ValidFlagIndex     = 2,
                CreateDateTime     = DateTime.Now,
                CreateUserId       = user.Id,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id
            };

            var commandDataE = new CommandData()
            {
                Id                 = Guid.Parse("57874a4a-9a91-42dd-86de-e8940ad92c10"),
                DataIndex          = 4,
                DataLength         = 2,
                DataName           = "噪音值",
                DataConvertType    = ProtocolDataType.TwoBytesToDoubleSeparate,
                ValidFlagIndex     = 3,
                CreateDateTime     = DateTime.Now,
                CreateUserId       = user.Id,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id
            };

            var commandDataF = new CommandData()
            {
                Id                 = Guid.Parse("7e175d64-be72-48ed-baf2-549f80c27319"),
                DataIndex          = 5,
                DataLength         = 3,
                DataName           = "风向",
                DataConvertType    = ProtocolDataType.ThreeBytesToUShort,
                ValidFlagIndex     = 4,
                CreateDateTime     = DateTime.Now,
                CreateUserId       = user.Id,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id
            };

            var commandDataG = new CommandData()
            {
                Id                 = Guid.Parse("0c9124b1-168d-4510-bd8b-1acd183895a3"),
                DataIndex          = 6,
                DataLength         = 3,
                DataName           = "风速",
                DataConvertType    = ProtocolDataType.ThreeBytesToUShort,
                ValidFlagIndex     = 5,
                CreateDateTime     = DateTime.Now,
                CreateUserId       = user.Id,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id
            };

            var commandDataH = new CommandData()
            {
                Id                 = Guid.Parse("dc8815aa-0203-4c82-a09a-73521bcf208b"),
                DataIndex          = 7,
                DataLength         = 2,
                DataName           = "温度",
                DataConvertType    = ProtocolDataType.TwoBytesToDoubleSeparate,
                ValidFlagIndex     = 6,
                CreateDateTime     = DateTime.Now,
                CreateUserId       = user.Id,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id
            };

            var commandDataI = new CommandData()
            {
                Id                 = Guid.Parse("1ff2c99a-e0af-4419-80f6-53e69574d2c4"),
                DataIndex          = 8,
                DataLength         = 2,
                DataName           = "湿度",
                DataConvertType    = ProtocolDataType.TwoBytesToDoubleSeparate,
                ValidFlagIndex     = 6,
                CreateDateTime     = DateTime.Now,
                CreateUserId       = user.Id,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id
            };

            var commandDataJ = new CommandData()
            {
                Id                 = Guid.Parse("d24a7c0b-05f1-4a3f-b82c-6a5615ccdfc5"),
                DataIndex          = 9,
                DataLength         = 4,
                DataName           = "挥发性有机物",
                DataConvertType    = ProtocolDataType.FourBytesToUInt32,
                ValidFlagIndex     = 7,
                CreateDateTime     = DateTime.Now,
                CreateUserId       = user.Id,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id
            };

            var command = new ProtocolCommand
            {
                Id = Guid.Parse("d2ccf8b0-ed68-48ef-b185-f94b504944ca"),
                CommandTypeCode            = new byte[] { 0xF9 },
                CommandCode                = new byte[] { 0x1F },
                ReceiveBytesLength         = 0,
                CommandCategory            = CommandCategory.HeartBeat,
                ProtocolId                 = classic.Id,
                CommandDeliverParamConfigs = new List <SysConfig> {
                    commandReply
                },
                CreateUserId       = user.Id,
                CreateDateTime     = DateTime.Now,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id
            };

            var commandA = new ProtocolCommand
            {
                Id = Guid.Parse("29b2f9c1-a79b-4598-bc33-2b4c20488159"),
                CommandTypeCode            = new byte[] { 0xFD },
                CommandCode                = new byte[] { 0x27 },
                ReceiveBytesLength         = 30,
                CommandCategory            = CommandCategory.TimingAutoReport,
                ProtocolId                 = classic.Id,
                CommandDeliverParamConfigs = new List <SysConfig> {
                    commandReplyA
                },
                CreateUserId       = user.Id,
                CreateDateTime     = DateTime.Now,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id,
                CommandDatas       = new List <CommandData>()
            };

            var commandB = new ProtocolCommand
            {
                Id = Guid.Parse("52FD2857-1607-4AD6-86C9-AC6B2B75BBB6"),
                CommandTypeCode            = new byte[] { 0xFC },
                CommandCode                = new byte[] { 0x1F },
                ReceiveBytesLength         = 0,
                CommandCategory            = CommandCategory.DeviceControl,
                ProtocolId                 = classic.Id,
                CommandDeliverParamConfigs = new List <SysConfig>(),
                CreateUserId               = user.Id,
                CreateDateTime             = DateTime.Now,
                LastUpdateDateTime         = DateTime.Now,
                LastUpdateUserId           = user.Id,
                CommandDatas               = new List <CommandData>()
            };

            commandA.CommandDatas.Add(commandDataA);
            commandA.CommandDatas.Add(commandDataB);
            commandA.CommandDatas.Add(commandDataC);
            commandA.CommandDatas.Add(commandDataD);
            commandA.CommandDatas.Add(commandDataE);
            commandA.CommandDatas.Add(commandDataF);
            commandA.CommandDatas.Add(commandDataG);
            commandA.CommandDatas.Add(commandDataH);
            commandA.CommandDatas.Add(commandDataI);
            commandA.CommandDatas.Add(commandDataJ);

            dbContext.ProtocolCommands.Add(command);
            dbContext.ProtocolCommands.Add(commandA);
            dbContext.ProtocolCommands.Add(commandB);

            var lampblack = new Protocol
            {
                Id                 = Guid.Parse("ea38e48c-1df2-4bfb-8917-7f736795bdc3"),
                FieldId            = field.Id,
                SubFieldId         = subfield.Id,
                CustomerInfo       = "1",
                ProtocolName       = "Lampblack",
                ProtocolModule     = "Lampblack",
                Version            = "Lampblack_Protocol_V0001",
                ReleaseDateTime    = DateTime.Now,
                CreateUserId       = user.Id,
                CreateDateTime     = DateTime.Now,
                LastUpdateDateTime = DateTime.Now,
                LastUpdateUserId   = user.Id,
                IsEnabled          = true,
                CheckType          = ProtocolCheckType.Lrc,
                Head               = new byte[] { 0x3A },
                Tail               = new byte[] { 0x0D, 0x0A }
            };

            dbContext.Protocols.Add(lampblack);

            var lbHead = new ProtocolStructure()
            {
                Id                  = Guid.Parse("a47ffc76-30ed-4d94-84d7-74540c51d9c4"),
                ProtocolId          = lampblack.Id,
                StructureName       = "Head",
                StructureIndex      = 0,
                StructureDataLength = 1,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.SingleByte,
                DefaultBytes        = new byte[] { 0x3A }
            };

            var lbFunctionCode = new ProtocolStructure()
            {
                Id                  = Guid.Parse("b9c7a5ef-d6ec-43e8-bdec-edcddbc8d4bb"),
                ProtocolId          = lampblack.Id,
                StructureName       = "FunctionCode",
                StructureIndex      = 1,
                StructureDataLength = 2,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.FunctionCode,
                DefaultBytes        = new byte[0]
            };

            var lbDeviceNodeId = new ProtocolStructure()
            {
                Id                  = Guid.Parse("a98f5e06-5093-4ab9-9762-5dacc4bdaf73"),
                ProtocolId          = lampblack.Id,
                StructureName       = "DeviceNodeId",
                StructureIndex      = 2,
                StructureDataLength = 7,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.NodeId,
                DefaultBytes        = new byte[0]
            };

            var lbData = new ProtocolStructure()
            {
                Id                  = Guid.Parse("c3ec8746-7c23-43bd-9cf8-a0db19c29655"),
                ProtocolId          = lampblack.Id,
                StructureName       = "Data",
                StructureIndex      = 3,
                StructureDataLength = 0,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.Data,
                DefaultBytes        = new byte[0]
            };

            var lbAscTime = new ProtocolStructure()
            {
                Id                  = Guid.Parse("d9c5172a-233b-4ea8-b064-297bc9c8fb75"),
                ProtocolId          = lampblack.Id,
                StructureName       = "ASCTime",
                StructureIndex      = 4,
                StructureDataLength = 14,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.ASCTime,
                DefaultBytes        = new byte[0]
            };

            var lbLrc = new ProtocolStructure()
            {
                Id                  = Guid.Parse("3e8b6176-19b0-4b0b-8635-a9a995799da4"),
                ProtocolId          = lampblack.Id,
                StructureName       = "LRCValue",
                StructureIndex      = 5,
                StructureDataLength = 3,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.LRC,
                DefaultBytes        = new byte[0]
            };

            var lbTail = new ProtocolStructure()
            {
                Id                  = Guid.Parse("56d4150a-7a22-4c74-8a22-9bc6b3bb70f7"),
                ProtocolId          = lampblack.Id,
                StructureName       = "Tail",
                StructureIndex      = 6,
                StructureDataLength = 2,
                CreateUserId        = user.Id,
                CreateDateTime      = DateTime.Now,
                LastUpdateDateTime  = DateTime.Now,
                LastUpdateUserId    = user.Id,
                IsEnabled           = true,
                DataType            = ProtocolDataType.Bytes,
                DefaultBytes        = new byte[] { 0x0D, 0x0A }
            };

            dbContext.ProtocolStructures.Add(lbHead);
            dbContext.ProtocolStructures.Add(lbFunctionCode);
            dbContext.ProtocolStructures.Add(lbDeviceNodeId);
            dbContext.ProtocolStructures.Add(lbData);
            dbContext.ProtocolStructures.Add(lbAscTime);
            dbContext.ProtocolStructures.Add(lbLrc);
            dbContext.ProtocolStructures.Add(lbTail);

            //var devices = new List<Device>();
            //for (var i = 0; i < 1000; i++)
            //{
            //    var dev = new Device()
            //    {
            //        Id = Guid.NewGuid(),
            //        DeviceTypeId = deviceType.Id,
            //        DeviceCode = "扬尘硬件第三版测试一号",
            //        DevicePassword = string.Empty,
            //        DeviceModuleGuid = Guid.NewGuid(),
            //        DeviceNodeId = (i + 1000).ToString("X8"),
            //        FirmwareSetId = firmSet.Id,
            //        StartTime = DateTime.Now,
            //        PreEndTime = DateTime.Now,
            //        EndTime = DateTime.Now,
            //        Status = DeviceStatus.Enabled,
            //        DomainId = domain.Id,
            //        CreateUserId = user.Id,
            //        CreateDateTime = DateTime.Now,
            //        IsEnabled = true
            //    };

            //    dbContext.Devices.Add(dev);
            //}
        }