Exemplo n.º 1
0
        public void ConvertOldVersionSoftwareDataFileToCurrentModel8001()
        {
            _databaseService = new MSAccessDatabaseAccess(@"E:\2016\6 软件优化升级\4 实际工程数据\工程数据111\连城心怡都城_文件版本5.mdb", _logRecorder, _fileService);
            IOldVersionSoftwareDBService oldVersionService   = new OldVersionSoftware8001DBService(_databaseService);
            IControllerOperation         controllerOperation = null;

            string[]        strFileInfo    = oldVersionService.GetFileVersionAndControllerType();
            ControllerModel controllerInfo = null;

            if (strFileInfo.Length > 0)
            {
                switch (strFileInfo[0])
                {
                case "8001":
                    controllerOperation = new ControllerOperation8001();
                    break;
                }
                if (controllerOperation != null)
                {
                    controllerInfo = controllerOperation.OrganizeControllerInfoFromOldVersionSoftwareDataFile(oldVersionService);
                }
                //strFileInfo[1];
            }
            Assert.That(controllerInfo.Type, Is.EqualTo(ControllerType.NT8001), "控制器类型不正确");
            Assert.That(controllerInfo.DeviceAddressLength, Is.EqualTo(7), "器件长度为7");
            Assert.That(controllerInfo.Loops.Count, Is.EqualTo(10), "回路数量不正确");
            Assert.That(controllerInfo.Loops[0].Code, Is.EqualTo("0001"), "回路名称不正确");
            Assert.That(controllerInfo.Loops[0].DeviceAmount, Is.EqualTo(46), "01回路器件数量不正确");
            Assert.That(controllerInfo.Loops[0].GetDevices <Model.DeviceInfo8001>()[0].Code, Is.EqualTo("0001001"), "器件编码不正确");

            Assert.That(controllerInfo.Loops[2].GetDevices <Model.DeviceInfo8001>()[0].Code, Is.EqualTo("0003001"), "器件编码不正确");
            Assert.That(controllerInfo.Loops[2].GetDevices <Model.DeviceInfo8001>()[0].TypeCode, Is.EqualTo(4), "器件类型不正确");
            Assert.That(controllerInfo.Loops[2].GetDevices <Model.DeviceInfo8001>()[0].Disable, Is.EqualTo(0), "隔离不正确");
            Assert.That(controllerInfo.Loops[2].GetDevices <Model.DeviceInfo8001>()[0].SensitiveLevel, Is.EqualTo(2), "灵敏度不正确");
            Assert.That(controllerInfo.Loops[2].GetDevices <Model.DeviceInfo8001>()[0].Location, Is.EqualTo("A2三层306店"), "地点不正确");
            Assert.That(controllerInfo.Loops[2].GetDevices <Model.DeviceInfo8001>()[0].BuildingNo, Is.EqualTo(1), "楼号不正确");
            //区号可以为0
            Assert.That(controllerInfo.Loops[2].GetDevices <Model.DeviceInfo8001>()[0].ZoneNo, Is.EqualTo(2), "区号不正确");
            Assert.That(controllerInfo.Loops[2].GetDevices <Model.DeviceInfo8001>()[0].FloorNo, Is.EqualTo(3), "层号不正确");
            //房间可以为0
            Assert.That(controllerInfo.Loops[2].GetDevices <Model.DeviceInfo8001>()[0].RoomNo, Is.EqualTo(null), "房间号不正确");

            Assert.That(controllerInfo.Loops[1].Code, Is.EqualTo("0002"), "回路名称不正确");

            Assert.That(controllerInfo.StandardConfig.Count, Is.EqualTo(20), "标准组态数量为20");
            Assert.That(controllerInfo.StandardConfig[13].Code, Is.EqualTo("0014"), "标准组态编号为0014");
            Assert.That(controllerInfo.StandardConfig[13].DeviceNo4, Is.EqualTo("0007102"), "编号4的编号为0007102");
            Assert.That(controllerInfo.StandardConfig[13].LinkageNo2, Is.EqualTo("0020"), "联动组2的编号为0020");


            Assert.That(controllerInfo.MixedConfig.Count, Is.EqualTo(53), "混合组态数量为53");
            Assert.That(controllerInfo.MixedConfig[13].Code, Is.EqualTo("0014"), "混合组态编号为0014");
            Assert.That(controllerInfo.MixedConfig[13].ActionCoefficient, Is.EqualTo("1"), "编号14的动作常数为1");
            Assert.That(controllerInfo.MixedConfig[13].ActionType, Is.EqualTo(LinkageActionType.AND), "编号14的动作类型为与");
            Assert.That(controllerInfo.MixedConfig[13].DeviceTypeCodeA, Is.EqualTo(13), "编号14的类型A为13");
            Assert.That(controllerInfo.MixedConfig[29].TypeC, Is.EqualTo(LinkageType.ZoneLayer), "编号30的类型c为区层");
            Assert.That(controllerInfo.MixedConfig[29].BuildingNoC, Is.EqualTo(6), "编号30的楼号为6");
            Assert.That(controllerInfo.MixedConfig[29].ZoneNoC, Is.EqualTo(5), "编号30的区号为5");
            Assert.That(controllerInfo.MixedConfig[29].LayerNoC, Is.EqualTo(-1), "编号30的层号为-1");
            Assert.That(controllerInfo.MixedConfig[30].TypeC, Is.EqualTo(LinkageType.Address), "编号31的类型c为地址");
            Assert.That(controllerInfo.MixedConfig[30].MachineNoC, Is.EqualTo("00"), "编号31的机号为00");
            Assert.That(controllerInfo.MixedConfig[30].LoopNoC, Is.EqualTo("07"), "编号31的路号为07");
            Assert.That(controllerInfo.MixedConfig[30].DeviceCodeC, Is.EqualTo("075"), "编号31的地编号为075");

            Assert.That(controllerInfo.GeneralConfig.Count, Is.EqualTo(37), "通用组态数量为37");
            Assert.That(controllerInfo.GeneralConfig[13].Code, Is.EqualTo("0014"), "通用组态编号为0014");
            Assert.That(controllerInfo.GeneralConfig[13].ActionCoefficient, Is.EqualTo("1"), "编号14的动作常数为1");
            Assert.That(controllerInfo.GeneralConfig[13].BuildingNoA, Is.EqualTo(6), "编号14的楼号为6");
            Assert.That(controllerInfo.GeneralConfig[13].ZoneNoA, Is.EqualTo(5), "编号14的区号为5");
            Assert.That(controllerInfo.GeneralConfig[13].LayerNoA1, Is.EqualTo(0), "编号14的层号A1为0");
            Assert.That(controllerInfo.GeneralConfig[13].LayerNoA2, Is.EqualTo(0), "编号14的层号A2为0");
            Assert.That(controllerInfo.GeneralConfig[13].DeviceTypeCodeA, Is.EqualTo(13), "编号14的类型A为13");

            Assert.That(controllerInfo.GeneralConfig[13].TypeC, Is.EqualTo(LinkageType.ZoneLayer), "编号14的分类C为区层");
            Assert.That(controllerInfo.GeneralConfig[13].BuildingNoC, Is.EqualTo(6), "编号14的楼号为6");
            Assert.That(controllerInfo.GeneralConfig[13].ZoneNoC, Is.EqualTo(5), "编号14的区号C为5");
            Assert.That(controllerInfo.GeneralConfig[13].LayerNoC, Is.EqualTo(-1), "编号14的层号C为-1");
            Assert.That(controllerInfo.GeneralConfig[13].DeviceTypeCodeC, Is.EqualTo(36), "编号14的层号C为36");

            Assert.That(controllerInfo.GeneralConfig[14].TypeC, Is.EqualTo(LinkageType.Address), "编号15的分类C为地址");
            Assert.That(controllerInfo.GeneralConfig[14].MachineNoC, Is.EqualTo("00"), "编号15的机号为0");
            Assert.That(controllerInfo.GeneralConfig[14].LoopNoC, Is.EqualTo("01"), "编号15的路号为1");
            Assert.That(controllerInfo.GeneralConfig[14].DeviceCodeC, Is.EqualTo("001"), "编号15的层号C为001");
            Assert.That(controllerInfo.GeneralConfig[14].DeviceTypeCodeC, Is.EqualTo(null), "编号14的层号C为null");
        }
Exemplo n.º 2
0
        public HierarchyViewModel()
        {
            IProjectManager              projManager         = ProjectManager.GetInstance;
            IFileService                 _fileService        = new FileService();
            IDatabaseService             _databaseService    = new MSAccessDatabaseAccess(@"C:\Users\Administrator\Desktop\foo\8036.mdb", null, _fileService);
            IOldVersionSoftwareDBService oldVersionService   = new OldVersionSoftware8036DBService(_databaseService);
            IControllerOperation         controllerOperation = null;

            string[]        strFileInfo    = oldVersionService.GetFileVersionAndControllerType();
            ControllerModel controllerInfo = null;

            if (strFileInfo.Length > 0)
            {
                switch (strFileInfo[0])
                {
                case "8036":
                    controllerOperation = new ControllerOperation8036(_databaseService);
                    break;
                }
                if (controllerOperation != null)
                {
                    controllerInfo = controllerOperation.OrganizeControllerInfoFromOldVersionSoftwareDataFile(oldVersionService);
                }
                //strFileInfo[1];
            }


            ProjectModel proj = new ProjectModel()
            {
                ID = 1, Name = "尼特智能"
            };

            proj.Controllers.Add(controllerInfo);



            _databaseService  = new MSAccessDatabaseAccess(@"E:\2016\6 软件优化升级\4 实际工程数据\工程数据111\连城心怡都城_文件版本5.mdb", null, _fileService);
            oldVersionService = new OldVersionSoftware8001DBService(_databaseService);

            strFileInfo    = oldVersionService.GetFileVersionAndControllerType();
            controllerInfo = null;
            if (strFileInfo.Length > 0)
            {
                switch (strFileInfo[0])
                {
                case "8001":
                    controllerOperation = new ControllerOperation8001(null);
                    break;
                }
                if (controllerOperation != null)
                {
                    controllerInfo = controllerOperation.OrganizeControllerInfoFromOldVersionSoftwareDataFile(oldVersionService);
                }
                //strFileInfo[1];
            }

            proj.Controllers.Add(controllerInfo);

            projManager.CreateProject(proj);

            List <ProjectModel> lstProjects = new List <ProjectModel>();

            lstProjects.Add(proj);
            Initialize(lstProjects, null);
        }