示例#1
0
        public static void LinkSystem(TECSystem system, Dictionary <Guid, Guid> guidDictionary)
        {
            linkSubScopeConnections(system.Controllers, system.GetAllSubScope(), guidDictionary);
            List <IConnectable> allChildren = new List <IConnectable>();

            allChildren.AddRange(system.Controllers);
            allChildren.AddRange(system.GetAllSubScope());
            linkNetworkConnections(system.Controllers, allChildren, guidDictionary);
            linkPanelsToControllers(system.Panels, system.Controllers, guidDictionary);
            linkProposalItmes(system.ProposalItems, system.Equipment, guidDictionary);
            if (system is TECTypical typical)
            {
                typical.RefreshRegistration();
            }
        }
        public void GetAllSubScopeTest()
        {
            Random    rand   = new Random(0);
            TECBid    bid    = ModelCreation.TestBid(rand);
            TECSystem system = ModelCreation.TestSystem(bid.Catalogs, rand);

            var allSubScope = system.GetAllSubScope();

            foreach (var subScope in system.Equipment.SelectMany(e => e.SubScope))
            {
                Assert.IsTrue(allSubScope.Contains(subScope));
            }
        }
示例#3
0
        public void AddConnection()
        {
            //Arrange
            TECControllerType controllerType = new TECControllerType(bid.Catalogs.Manufacturers[0]);

            bid.Catalogs.Add(controllerType);

            TECTypical typical = new TECTypical();

            bid.Systems.Add(typical);

            TECController controller = new TECProvidedController(controllerType);

            typical.AddController(controller);

            TECEquipment typEquip = new TECEquipment();

            typical.Equipment.Add(typEquip);

            TECSubScope typSS = new TECSubScope();

            typEquip.SubScope.Add(typSS);

            ObservableCollection <TECConnectionType> connectionTypes = new ObservableCollection <TECConnectionType>();

            connectionTypes.Add(bid.Catalogs.ConnectionTypes[0]);
            TECDevice dev = new TECDevice(connectionTypes, new List <TECProtocol>(), bid.Catalogs.Manufacturers[0]);

            bid.Catalogs.Add(dev);
            typSS.Devices.Add(dev);

            MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw);

            //Act
            IControllerConnection connection = controller.Connect(typSS, (typSS as IConnectable).AvailableProtocols.First());

            connection.Length        = 50;
            connection.ConduitLength = 50;
            connection.ConduitType   = bid.Catalogs.ConduitTypes[0];

            TECSystem   instance         = typical.AddInstance();
            TECSubScope instanceSubScope = instance.GetAllSubScope()[0];

            //Assert
            AssertMaterialVMMatchesCostBatch(matVM, connection.CostBatch);
        }
示例#4
0
        public void RemoveConnection()
        {
            //Arrange
            TECController controller = new TECProvidedController(bid.Catalogs.ControllerTypes[0]);

            bid.AddController(controller);

            TECTypical typical = new TECTypical();

            bid.Systems.Add(typical);

            TECEquipment typEquip = new TECEquipment();

            typical.Equipment.Add(typEquip);

            TECSubScope ss = new TECSubScope();

            ss.Devices.Add(bid.Catalogs.Devices[0]);
            typEquip.SubScope.Add(ss);


            TECSystem instance = typical.AddInstance();

            TECSubScope instanceSubScope = instance.GetAllSubScope().First(sub => sub.AvailableProtocols.Any(prot => prot is TECHardwiredProtocol));
            IConnection connection       = controller.Connect(instanceSubScope, (instanceSubScope as IConnectable).AvailableProtocols.First(x => x is TECHardwiredProtocol));

            connection.Length        = 50;
            connection.ConduitLength = 50;
            connection.ConduitType   = bid.Catalogs.ConduitTypes[0];

            MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw);

            CostBatch expected = MatVMToCostBatch(matVM) - connection.CostBatch;

            //Act
            controller.Disconnect(instanceSubScope);

            //Assert
            AssertMaterialVMMatchesCostBatch(matVM, expected);
        }