public void AddPointToConnectedNetwork()
        {
            TECControllerType type     = new TECControllerType(new TECManufacturer());
            TECProtocol       protocol = new TECProtocol(new List <TECConnectionType>());

            type.IO.Add(new TECIO(IOType.AI));
            type.IO.Add(new TECIO(protocol));
            TECProvidedController controller = new TECProvidedController(type);

            TECDevice device = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol> {
                protocol
            }, new TECManufacturer());

            TECSubScope subScope = new TECSubScope();

            subScope.Devices.Add(device);

            controller.Connect(subScope, protocol);

            TECPoint point = new TECPoint();

            point.Type = IOType.AI;
            subScope.AddPoint(point);

            Assert.IsTrue(subScope.Points.Contains(point));
            Assert.IsTrue(controller.AvailableIO.IONumber(IOType.AI) == 1);

            TECPoint otherPoint = new TECPoint();

            otherPoint.Type = IOType.AI;

            subScope.AddPoint(otherPoint);
            Assert.IsTrue(subScope.Points.Contains(otherPoint));
            Assert.IsTrue(controller.AvailableIO.IONumber(IOType.AI) == 1);
        }
        private void addExecute()
        {
            for (int x = 0; x < Quantity; x++)
            {
                TECSubScope subScope = null;
                if (underlyingTemplate != null)
                {
                    subScope = AsReference ? templates.SubScopeSynchronizer.NewItem(underlyingTemplate) : new TECSubScope(underlyingTemplate);
                    subScope.CopyPropertiesFromScope(ToAdd);
                    foreach (IEndDevice device in ToAdd.Devices.Where(item => !originalDevices.Contains(item)))
                    {
                        subScope.AddDevice(device);
                    }
                    foreach (TECPoint point in ToAdd.Points.Where(item => !originalPoints.Contains(item)))
                    {
                        subScope.AddPoint(point);
                    }
                }
                else
                {
                    subScope = new TECSubScope(ToAdd);
                }

                add(subScope);
                if (ConnectVM != null && ConnectVM.Connect)
                {
                    ConnectVM.ExecuteConnection(subScope);
                }
                Added?.Invoke(subScope);
            }
        }
        public void RemovePointFromConnectedHardwired()
        {
            TECControllerType type = new TECControllerType(new TECManufacturer());

            type.IO.Add(new TECIO(IOType.AI));
            TECProvidedController controller = new TECProvidedController(type);

            TECConnectionType connectionType = new TECConnectionType();
            TECDevice         device         = new TECDevice(new List <TECConnectionType> {
                connectionType
            }, new List <TECProtocol>(), new TECManufacturer());

            TECSubScope subScope = new TECSubScope();

            subScope.Devices.Add(device);

            TECPoint point = new TECPoint();

            point.Type = IOType.AI;
            subScope.AddPoint(point);

            controller.Connect(subScope, subScope.HardwiredProtocol());

            subScope.RemovePoint(point);

            Assert.IsFalse(subScope.Points.Contains(point));
            Assert.IsTrue(controller.AvailableIO.IONumber(IOType.AI) == 1);
        }
예제 #4
0
        public void CanChangeTypeTest1()
        {
            TECControllerType cType    = new TECControllerType(new TECManufacturer());
            TECProtocol       protocol = new TECProtocol(new List <TECConnectionType>());

            cType.IO.Add(new TECIO(protocol));
            cType.IO.Add(new TECIO(IOType.AI));

            TECControllerType otherCType = new TECControllerType(new TECManufacturer());

            TECProvidedController controller = new TECProvidedController(cType);

            TECSubScope ss1 = new TECSubScope();
            TECSubScope ss2 = new TECSubScope();

            TECDevice proDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>()
            {
                protocol
            }, new TECManufacturer());
            TECDevice hardDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>(), new TECManufacturer());

            ss1.Devices.Add(proDevice);
            ss2.Devices.Add(hardDevice);
            TECPoint point = new TECPoint();

            point.Type = IOType.AI;
            ss2.AddPoint(point);

            controller.Connect(ss1, protocol);
            controller.Connect(ss2, ss2.HardwiredProtocol());

            Assert.IsFalse(controller.CanChangeType(otherCType));
        }
        public void AddPointTest()
        {
            TECSubScope subScope = new TECSubScope();
            TECPoint    point    = new TECPoint();

            subScope.AddPoint(point);

            Assert.IsTrue(subScope.Points.Contains(point));
        }
        public void RemovePointTest()
        {
            TECSubScope subScope = new TECSubScope();
            TECPoint    point    = new TECPoint();

            subScope.AddPoint(point);

            subScope.RemovePoint(point);

            Assert.IsFalse(subScope.Points.Contains(point));
        }
예제 #7
0
        public void SubScopeTemplateChanged()
        {
            //Arrange
            TECTemplates templates = new TECTemplates();

            TECSubScope templateSS = new TECSubScope();

            templateSS.Name = "Template SubScope";
            templates.Templates.SubScopeTemplates.Add(templateSS);

            TemplateSynchronizer <TECSubScope> ssSynchronizer = templates.SubScopeSynchronizer;
            TECSubScope refSS = ssSynchronizer.NewItem(templateSS);

            TECEquipment equip = new TECEquipment();

            templates.Templates.EquipmentTemplates.Add(equip);
            equip.SubScope.Add(refSS);

            TECDevice dev = new TECDevice(new List <TECConnectionType>(),
                                          new List <TECProtocol>(),
                                          new TECManufacturer());

            templates.Catalogs.Add(dev);

            TECPoint point = new TECPoint();

            point.Label    = "Test Point";
            point.Type     = IOType.AI;
            point.Quantity = 5;

            TECAssociatedCost cost = new TECAssociatedCost(CostType.TEC);

            templates.Catalogs.Add(cost);

            TECTag tag = new TECTag();

            templates.Catalogs.Add(tag);

            //Act
            templateSS.Description = "Test Description";
            templateSS.Devices.Add(dev);
            templateSS.AddPoint(point);
            templateSS.AssociatedCosts.Add(cost);
            templateSS.Tags.Add(tag);

            //Assert
            //Assert.AreEqual(templateSS.Description, refSS.Description, "Description didn't sync properly between SubScope.");
            Assert.AreEqual(templateSS.Devices[0], refSS.Devices[0], "Devices didn't sync properly between SubScope.");
            Assert.AreEqual(templateSS.Points[0].Label, refSS.Points[0].Label, "Points didn't sync properly between SubScope.");
            Assert.AreEqual(templateSS.Points[0].Type, refSS.Points[0].Type, "Points didn't sync properly between SubScope.");
            Assert.AreEqual(templateSS.Points[0].Quantity, refSS.Points[0].Quantity, "Points didn't sync properly between SubScope.");
            Assert.AreEqual(templateSS.AssociatedCosts[0], refSS.AssociatedCosts[0], "Associated costs didn't sync properly between SubScope.");
            Assert.AreEqual(templateSS.Tags[0], refSS.Tags[0], "Tags didn't sync properly between SubScope.");
        }
예제 #8
0
        private void testNetworkExecute()
        {
            TECControllerType type = new TECControllerType(bid.Catalogs.Manufacturers[0]);

            type.Name = "Controller Type";
            type.IO.Add(new TECIO(IOType.AI));

            bid.Catalogs.Add(type);

            TECProvidedController controller = new TECProvidedController(type);

            controller.Name        = "Test Server";
            controller.Description = "For testing.";
            controller.IsServer    = true;

            bid.AddController(controller);

            TECProvidedController child = new TECProvidedController(type);

            child.Name = "Child";

            bid.AddController(child);

            TECProvidedController emptyController = new TECProvidedController(type);

            emptyController.Name = "EmptyController";

            bid.AddController(emptyController);

            TECNetworkConnection connection = controller.AddNetworkConnection(bid.Catalogs.Protocols[0]);

            connection.AddChild(child);

            TECTypical   typical = new TECTypical();
            TECEquipment equip   = new TECEquipment();
            TECSubScope  ss      = new TECSubScope();

            ss.Name = "Test Subscope";
            ss.AddDevice(bid.Catalogs.Devices[0]);
            TECPoint point = new TECPoint();

            point.Type     = IOType.AI;
            point.Quantity = 1;
            ss.AddPoint(point);
            equip.SubScope.Add(ss);
            typical.Equipment.Add(equip);

            bid.Systems.Add(typical);
            typical.AddInstance();
        }
예제 #9
0
        public void ChangeTypeTest()
        {
            TECControllerType cType    = new TECControllerType(new TECManufacturer());
            TECProtocol       protocol = new TECProtocol(new List <TECConnectionType>());

            cType.IO.Add(new TECIO(protocol));
            cType.IO.Add(new TECIO(IOType.AI));

            TECControllerType otherCType = new TECControllerType(new TECManufacturer());

            otherCType.IO.Add(new TECIO(protocol));
            otherCType.IO.Add(new TECIO(IOType.AI));

            TECProvidedController controller = new TECProvidedController(cType);

            TECSubScope ss1 = new TECSubScope();
            TECSubScope ss2 = new TECSubScope();

            TECConnectionType connectionType = new TECConnectionType();
            TECDevice         proDevice      = new TECDevice(new List <TECConnectionType> {
                connectionType
            }, new List <TECProtocol>()
            {
                protocol
            }, new TECManufacturer());
            TECDevice hardDevice = new TECDevice(new List <TECConnectionType> {
                connectionType
            }, new List <TECProtocol>(), new TECManufacturer());

            ss1.Devices.Add(proDevice);
            ss2.Devices.Add(hardDevice);
            TECPoint point = new TECPoint();

            point.Type = IOType.AI;
            ss2.AddPoint(point);

            controller.Connect(ss1, protocol);
            controller.Connect(ss2, ss2.HardwiredProtocol());

            controller.ChangeType(otherCType);

            Assert.AreEqual(2, controller.ChildrenConnections.Count);
            Assert.AreEqual(controller, (ss1 as IConnectable).GetParentConnection().ParentController);
            Assert.AreEqual(controller, (ss2 as IConnectable).GetParentConnection().ParentController);
        }
예제 #10
0
        private void addExecute()
        {
            var newPoint = new TECPoint(ToAdd);

            parent.AddPoint(newPoint);
            if (parent.Connection != null && parent.Connection is TECHardwiredConnection hardwiredConnection)
            {
                var parentController = parent.Connection.ParentController;
                var length           = hardwiredConnection.Length;
                var conduitLength    = hardwiredConnection.ConduitLength;
                var conduit          = hardwiredConnection.ConduitType;
                var isPlenum         = hardwiredConnection.IsPlenum;
                var protocol         = hardwiredConnection.Protocol;

                parentController.Disconnect(parent);
                var newConnection = parentController.Connect(parent, protocol);
                newConnection.Length        = length;
                newConnection.ConduitLength = conduitLength;
                newConnection.ConduitType   = conduit;
                newConnection.IsPlenum      = isPlenum;
            }

            Added?.Invoke(newPoint);
        }
예제 #11
0
        private void addTypicalExecute()
        {
            TECTypical typical = new TECTypical();

            typical.Name = "test";
            TECEquipment equipment = new TECEquipment();

            equipment.Name = "test equipment";
            TECSubScope ss = new TECSubScope();

            ss.Name = "Test Subscope";
            ss.AddDevice(bid.Catalogs.Devices[0]);
            TECPoint point = new TECPoint();

            point.Type     = IOType.AI;
            point.Quantity = 1;
            ss.AddPoint(point);
            equipment.SubScope.Add(ss);
            typical.Equipment.Add(equipment);

            TECSubScope connected = new TECSubScope();

            connected.Name = "Connected";
            connected.AddDevice(bid.Catalogs.Devices[0]);
            TECPoint point2 = new TECPoint();

            point2.Type     = IOType.AI;
            point2.Quantity = 1;
            connected.AddPoint(point2);
            equipment.SubScope.Add(connected);

            TECSubScope toConnect = new TECSubScope();

            toConnect.Name = "To Connect";
            toConnect.AddDevice(bid.Catalogs.Devices[0]);
            TECPoint point3 = new TECPoint();

            point3.Type     = IOType.AI;
            point3.Quantity = 1;
            toConnect.AddPoint(point3);
            equipment.SubScope.Add(toConnect);

            TECControllerType controllerType = new TECControllerType(new TECManufacturer());

            controllerType.IOModules.Add(bid.Catalogs.IOModules[0]);
            TECIO io = new TECIO(IOType.AI);

            io.Quantity = 10;
            controllerType.IO.Add(io);
            bid.Catalogs.IOModules[0].IO.Add(io);
            controllerType.Name = "Test Type";

            TECProvidedController controller = new TECProvidedController(controllerType);

            controller.IOModules.Add(bid.Catalogs.IOModules[0]);
            controller.Name = "Test Controller";
            typical.AddController(controller);
            TECProvidedController otherController = new TECProvidedController(controllerType);

            otherController.Name = "Other Controller";
            typical.AddController(otherController);
            IControllerConnection connection = controller.Connect(connected, (connected as IConnectable).AvailableProtocols.First());

            connection.Length        = 10;
            connection.ConduitLength = 20;
            connection.ConduitType   = bid.Catalogs.ConduitTypes[1];

            TECPanelType panelType = new TECPanelType(new TECManufacturer());

            panelType.Name = "test type";

            TECPanel panel = new TECPanel(panelType);

            panel.Name = "Test Panel";
            typical.Panels.Add(panel);

            TECMisc misc = new TECMisc(CostType.TEC);

            misc.Name = "test Misc";
            typical.MiscCosts.Add(misc);

            bid.Systems.Add(typical);
            typical.AddInstance();
        }
예제 #12
0
        public void ConnectToControllerTest3()
        {
            TECDevice protDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>(), new TECManufacturer());

            List <IConnectable> connectables = new List <IConnectable>();

            TECSubScope item1 = new TECSubScope();

            item1.Devices.Add(protDevice);
            TECPoint aiPoint = new TECPoint();

            aiPoint.Type = IOType.AI;
            item1.AddPoint(aiPoint);
            connectables.Add(item1);
            TECSubScope item2 = new TECSubScope();

            item2.Devices.Add(protDevice);
            TECPoint diPoint = new TECPoint();

            diPoint.Type = IOType.DI;
            item2.AddPoint(diPoint);
            connectables.Add(item2);
            TECSubScope item3 = new TECSubScope();

            item3.Devices.Add(protDevice);
            TECPoint doPoint = new TECPoint();

            doPoint.Type = IOType.DO;
            item3.AddPoint(doPoint);
            connectables.Add(item3);
            TECSubScope item4 = new TECSubScope();

            item4.Devices.Add(protDevice);
            TECPoint aoPoint = new TECPoint();

            aoPoint.Type = IOType.AO;
            item4.AddPoint(aoPoint);
            connectables.Add(item4);
            TECSubScope item5 = new TECSubScope();

            item5.Devices.Add(protDevice);
            TECPoint otherAoPoint = new TECPoint();

            otherAoPoint.Type = IOType.AO;
            item5.AddPoint(otherAoPoint);
            connectables.Add(item5);


            TECControllerType type = new TECControllerType(new TECManufacturer());

            type.IO.Add(new TECIO(IOType.UI));
            type.IO.Add(new TECIO(IOType.UI));
            type.IO.Add(new TECIO(IOType.UO));
            type.IO.Add(new TECIO(IOType.UO));
            type.IO.Add(new TECIO(IOType.UI));

            TECProvidedController controller = new TECProvidedController(type);

            List <IControllerConnection> connections = ConnectionHelper.ConnectToController(connectables, controller, new ConnectionProperties());

            foreach (var thing in connectables)
            {
                Assert.IsFalse(connections.Any(x => connectionContainsItem(x, thing)));
            }
        }
예제 #13
0
        public void CanConnectToControllerTest3()
        {
            TECConnectionType connectionType = new TECConnectionType();
            TECDevice         device         = new TECDevice(new List <TECConnectionType> {
                connectionType
            }, new List <TECProtocol>(), new TECManufacturer());

            List <IConnectable> connectables = new List <IConnectable>();

            TECSubScope item1 = new TECSubScope();

            item1.Devices.Add(device);
            TECPoint aiPoint = new TECPoint();

            aiPoint.Type = IOType.AI;
            item1.AddPoint(aiPoint);
            connectables.Add(item1);
            TECSubScope item2 = new TECSubScope();

            item2.Devices.Add(device);
            TECPoint diPoint = new TECPoint();

            diPoint.Type = IOType.DI;
            item2.AddPoint(diPoint);
            connectables.Add(item2);
            TECSubScope item3 = new TECSubScope();

            item3.Devices.Add(device);
            TECPoint doPoint = new TECPoint();

            doPoint.Type = IOType.DO;
            item3.AddPoint(doPoint);
            connectables.Add(item3);
            TECSubScope item4 = new TECSubScope();

            item4.Devices.Add(device);
            TECPoint aoPoint = new TECPoint();

            aoPoint.Type = IOType.AO;
            item4.AddPoint(aoPoint);
            connectables.Add(item4);
            TECSubScope item5 = new TECSubScope();

            item5.Devices.Add(device);
            TECPoint otherAoPoint = new TECPoint();

            otherAoPoint.Type = IOType.AO;
            item5.AddPoint(otherAoPoint);
            connectables.Add(item5);


            TECControllerType type = new TECControllerType(new TECManufacturer());

            type.IO.Add(new TECIO(IOType.UI));
            type.IO.Add(new TECIO(IOType.UI));
            type.IO.Add(new TECIO(IOType.UO));
            type.IO.Add(new TECIO(IOType.UO));
            type.IO.Add(new TECIO(IOType.UI));

            TECProvidedController controller = new TECProvidedController(type);

            Assert.IsFalse(ConnectionHelper.CanConnectToController(connectables, controller));
        }
예제 #14
0
        public static void AddBidConnections(TECBid bid, IEnumerable <TECTypical> typicals, TECCatalogs catalogs, Random rand)
        {
            var typ    = typicals.Where(x => x.Instances.Count > 0).RandomElement(rand);
            var system = typ.Instances.RandomElement(rand);

            var hardwiredDevice = catalogs.Devices.Where(x => x.HardwiredConnectionTypes.Count > 0).RandomElement(rand) ??
                                  new TECDevice(catalogs.ConnectionTypes.RandomElements(rand, false), new List <TECProtocol>(), catalogs.Manufacturers.RandomElement(rand));

            if (!catalogs.Devices.Contains(hardwiredDevice))
            {
                catalogs.Add(hardwiredDevice);
            }
            var networkDevice = catalogs.Devices.Where(x => x.PossibleProtocols.Count > 0 && x != hardwiredDevice).RandomElement(rand) ??
                                new TECDevice(new List <TECConnectionType>(), new List <TECProtocol> {
                catalogs.Protocols.RandomElement(rand)
            }, catalogs.Manufacturers.RandomElement(rand));

            var hardwiredSubScope = new TECSubScope();

            hardwiredSubScope.Devices.Add(hardwiredDevice);
            hardwiredSubScope.AddPoint(TestPoint(rand));

            var hardwiredProtocol = hardwiredSubScope.AvailableProtocols.Where(x => x is TECHardwiredProtocol).RandomElement(rand) as TECHardwiredProtocol;

            var networkSubScope = new TECSubScope();

            networkSubScope.Devices.Add(networkDevice);
            networkSubScope.AddPoint(TestPoint(rand));

            var networkProtocol = networkSubScope.AvailableProtocols.Where(x => x is TECProtocol).RandomElement(rand) as TECProtocol;

            typ.Equipment.RandomElement(rand).SubScope.Add(hardwiredSubScope);
            typ.Equipment.RandomElement(rand).SubScope.Add(networkSubScope);

            networkSubScope   = system.GetAllSubScope().First(x => typ.GetInstancesFromTypical(networkSubScope).Contains(x));
            hardwiredSubScope = system.GetAllSubScope().First(x => typ.GetInstancesFromTypical(hardwiredSubScope).Contains(x));

            var hardwiredControllerType = catalogs.ControllerTypes.Where(x => new TECProvidedController(x).AvailableIO.Contains((hardwiredSubScope as IConnectable).HardwiredIO)).RandomElement(rand) ??
                                          new TECControllerType(catalogs.Manufacturers.RandomElement(rand));

            if (!catalogs.ControllerTypes.Contains(hardwiredControllerType))
            {
                catalogs.Add(hardwiredControllerType);
                hardwiredControllerType.IO.AddRange((hardwiredSubScope as IConnectable).HardwiredIO.ToList());
            }
            var hardwiredController = bid.Controllers.Where(x => x is TECProvidedController y && y.Type == hardwiredControllerType).RandomElement(rand) ??
                                      new TECProvidedController(hardwiredControllerType);

            if (!bid.Controllers.Contains(hardwiredController))
            {
                bid.AddController(hardwiredController);
            }

            var networkControllerType = catalogs.ControllerTypes.Where(x => new TECProvidedController(x).AvailableProtocols.Any(y => y == networkProtocol)).RandomElement(rand) ??
                                        new TECControllerType(catalogs.Manufacturers.RandomElement(rand));

            if (!catalogs.ControllerTypes.Contains(networkControllerType))
            {
                catalogs.Add(networkControllerType);
                networkControllerType.IO.Add(new TECIO(networkProtocol));
            }
            var networkController = bid.Controllers.Where(x => x is TECProvidedController y && y.Type == networkControllerType && y.AvailableProtocols.Contains(networkProtocol)).RandomElement(rand) ??
                                    new TECProvidedController(networkControllerType);

            if (!bid.Controllers.Contains(networkController))
            {
                bid.AddController(networkController);
            }

            var hardwiredConnection = hardwiredController.Connect(hardwiredSubScope, hardwiredProtocol);
            var networkConnection   = networkController.Connect(networkSubScope, networkProtocol);

            hardwiredConnection.AssignRandomConnectionProperties(catalogs, rand);
            networkConnection.AssignRandomConnectionProperties(catalogs, rand);
        }
예제 #15
0
        public static void AddSystemConnections(TECSystem system, TECCatalogs catalogs, Random rand)
        {
            var hardwiredDevice = catalogs.Devices.Where(x => x.HardwiredConnectionTypes.Count > 0).RandomElement(rand) ??
                                  new TECDevice(catalogs.ConnectionTypes.RandomElements(rand, false), new List <TECProtocol>(), catalogs.Manufacturers.RandomElement(rand));

            if (!catalogs.Devices.Contains(hardwiredDevice))
            {
                catalogs.Add(hardwiredDevice);
            }
            var networkDevice = catalogs.Devices.Where(x => x.PossibleProtocols.Count > 0 && x != hardwiredDevice).RandomElement(rand) ??
                                new TECDevice(new List <TECConnectionType>(), new List <TECProtocol> {
                catalogs.Protocols.RandomElement(rand)
            }, catalogs.Manufacturers.RandomElement(rand));

            var hardwiredSubScope = new TECSubScope();

            hardwiredSubScope.Devices.Add(hardwiredDevice);
            hardwiredSubScope.AddPoint(TestPoint(rand));

            var hardwiredProtocol = hardwiredSubScope.AvailableProtocols.Where(x => x is TECHardwiredProtocol).RandomElement(rand) as TECHardwiredProtocol;

            var networkSubScope = new TECSubScope();

            networkSubScope.Devices.Add(networkDevice);
            networkSubScope.AddPoint(TestPoint(rand));

            var networkProtocol = networkSubScope.AvailableProtocols.Where(x => x is TECProtocol).RandomElement(rand) as TECProtocol;

            system.Equipment.RandomElement(rand).SubScope.Add(hardwiredSubScope);
            system.Equipment.RandomElement(rand).SubScope.Add(networkSubScope);

            var hardwiredControllerType = catalogs.ControllerTypes.Where(x => new TECProvidedController(x).CanConnect(hardwiredSubScope, hardwiredProtocol)).RandomElement(rand) ??
                                          new TECControllerType(catalogs.Manufacturers.RandomElement(rand));

            if (!catalogs.ControllerTypes.Contains(hardwiredControllerType))
            {
                catalogs.Add(hardwiredControllerType);
                hardwiredControllerType.IO.AddRange((hardwiredSubScope as IConnectable).HardwiredIO.ToList());
            }
            var hardwiredController = system.Controllers.Where(x => x is TECProvidedController y && y.Type == hardwiredControllerType && y.CanConnect(hardwiredSubScope, hardwiredProtocol)).RandomElement(rand) ??
                                      new TECProvidedController(hardwiredControllerType);

            if (!system.Controllers.Contains(hardwiredController))
            {
                system.AddController(hardwiredController);
            }

            var networkControllerType = catalogs.ControllerTypes.Where(x => new TECProvidedController(x).AvailableProtocols.Any(y => y == networkProtocol)).RandomElement(rand) ??
                                        new TECControllerType(catalogs.Manufacturers.RandomElement(rand));

            if (!catalogs.ControllerTypes.Contains(networkControllerType))
            {
                catalogs.Add(networkControllerType);
                networkControllerType.IO.Add(new TECIO(networkProtocol));
            }
            var networkController = system.Controllers.Where(x => x is TECProvidedController y && y.Type == networkControllerType && y.CanConnect(networkSubScope, networkProtocol)).RandomElement(rand) ??
                                    new TECProvidedController(networkControllerType);

            if (!system.Controllers.Contains(networkController))
            {
                system.AddController(networkController);
            }

            var hardwiredConnection = hardwiredController.Connect(hardwiredSubScope, hardwiredProtocol);
            var networkConnection   = networkController.Connect(networkSubScope, networkProtocol);

            hardwiredConnection.AssignRandomConnectionProperties(catalogs, rand);
            networkConnection.AssignRandomConnectionProperties(catalogs, rand);
        }
예제 #16
0
        public void EquipmentReferenceChanged()
        {
            //Arrange
            TECTemplates templates = new TECTemplates();

            TECEquipment templateEquip = new TECEquipment();

            templateEquip.Name = "Template Equip";
            templates.Templates.EquipmentTemplates.Add(templateEquip);

            TemplateSynchronizer <TECEquipment> equipSynchronizer = templates.EquipmentSynchronizer;
            TECEquipment refEquip = equipSynchronizer.NewItem(templateEquip);

            TECSystem sys = new TECSystem();

            templates.Templates.SystemTemplates.Add(sys);
            sys.Equipment.Add(refEquip);

            TECDevice dev = new TECDevice(new List <TECConnectionType>(),
                                          new List <TECProtocol>(),
                                          new TECManufacturer());

            templates.Catalogs.Add(dev);

            TECPoint point = new TECPoint();

            point.Label    = "Test Point";
            point.Type     = IOType.AI;
            point.Quantity = 5;

            TECAssociatedCost cost = new TECAssociatedCost(CostType.TEC);

            templates.Catalogs.Add(cost);

            TECTag tag = new TECTag();

            templates.Catalogs.Add(tag);

            TECSubScope ss = new TECSubScope();

            ss.Description = "Test Description";
            ss.Devices.Add(dev);
            ss.AddPoint(point);
            ss.AssociatedCosts.Add(cost);
            ss.Tags.Add(tag);

            templates.Templates.SubScopeTemplates.Add(ss);

            //Act
            refEquip.Description = "Test Description";
            refEquip.SubScope.Add(ss);
            refEquip.AssociatedCosts.Add(cost);
            refEquip.Tags.Add(tag);

            //Assert
            //Assert.AreEqual(refEquip.Description, templateEquip.Description, "Description didn't sync properly between Equipment.");

            Assert.IsNotNull(templateEquip.SubScope[0], "SubScope didn't sync properly between Equipment.");

            TECSubScope templateSubScope = templateEquip.SubScope[0];
            TECSubScope refSubScope      = refEquip.SubScope[0];

            //Assert.AreEqual(refSubScope.Description, templateSubScope.Description, "Description didn't sync properly between SubScope in Equipment.");
            Assert.AreEqual(refSubScope.Devices[0], templateSubScope.Devices[0], "Devices didn't sync properly between SubScope in Equipment.");
            Assert.AreEqual(refSubScope.Points[0].Label, templateSubScope.Points[0].Label, "Points didn't sync properly between SubScope in Equipment.");
            Assert.AreEqual(refSubScope.Points[0].Type, templateSubScope.Points[0].Type, "Points didn't sync properly between SubScope in Equipment.");
            Assert.AreEqual(refSubScope.Points[0].Quantity, templateSubScope.Points[0].Quantity, "Points didn't sync properly between SubScope in Equipment.");
            Assert.AreEqual(refSubScope.AssociatedCosts[0], templateSubScope.AssociatedCosts[0], "AssociatedCosts didn't sync properly between SubScope in Equipment.");
            Assert.AreEqual(refSubScope.Tags[0], templateSubScope.Tags[0], "Tags didn't sync properly between SubScope.");

            Assert.AreEqual(refEquip.AssociatedCosts[0], templateEquip.AssociatedCosts[0], "AssociatedCosts didn't sync properly between Equipment.");
            Assert.AreEqual(refEquip.Tags[0], templateEquip.Tags[0], "Tags didn't sync properly in Equipment.");
        }