public void ConnectTest2()
        {
            TECConnectionType connectionType   = new TECConnectionType();
            TECDevice         compatibleDevice = new TECDevice(new List <TECConnectionType> {
                connectionType
            }, new List <TECProtocol>(), new TECManufacturer());
            TECSubScope subScope = new TECSubScope();

            subScope.Devices.Add(compatibleDevice);
            TECPoint point = new TECPoint();

            point.Type = IOType.AI;
            subScope.Points.Add(point);

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

            type.IO.Add(new TECIO(IOType.AI));

            TECProvidedController controller = new TECProvidedController(type);

            TECHardwiredConnection connection = controller.Connect(subScope, subScope.HardwiredProtocol()) as TECHardwiredConnection;

            Assert.IsTrue(connection.Child == subScope);
            Assert.IsTrue(controller.ChildrenConnections.Contains(connection));
            Assert.IsTrue((subScope as IConnectable).GetParentConnection() == connection);
            Assert.IsTrue(connection.Protocol is TECHardwiredProtocol);
        }
        private void addConnectionTypeExecute()
        {
            var connectionType = new TECConnectionType();

            connectionType.Name  = ConnectionTypeName;
            connectionType.Cost  = ConnectionTypeCost;
            connectionType.Labor = ConnectionTypeLabor;

            if (HasPlenum)
            {
                //Setting marginal plenum cost and labor
                connectionType.PlenumCost  = (ConnectionTypePlenumCost - ConnectionTypeCost);
                connectionType.PlenumLabor = (ConnectionTypePlenumLabor - ConnectionTypeLabor);
            }
            else
            {
                connectionType.PlenumCost  = 0;
                connectionType.PlenumLabor = 0;
            }

            this.Templates.Catalogs.Add(connectionType);

            this.ConnectionTypeName        = "";
            this.ConnectionTypeCost        = 0;
            this.ConnectionTypeLabor       = 0;
            this.ConnectionTypePlenumCost  = 0;
            this.ConnectionTypePlenumLabor = 0;
        }
        public void AddDeviceToConnectedHardwired()
        {
            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.AddDevice(device);

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

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

            subScope.AddDevice(otherDevice);

            Assert.IsFalse(subScope.Devices.Contains(otherDevice));

            TECConnectionType otherConnectionType = new TECConnectionType();
            TECDevice         nextDevice          = new TECDevice(new List <TECConnectionType> {
                otherConnectionType
            }, new List <TECProtocol>(), new TECManufacturer());
            bool deviceAdded = subScope.AddDevice(nextDevice);

            Assert.IsFalse(deviceAdded);
            Assert.IsFalse(subScope.Devices.Contains(nextDevice));
        }
        public void DiconnectTest1()
        {
            TECConnectionType connectionType   = new TECConnectionType();
            TECDevice         compatibleDevice = new TECDevice(new List <TECConnectionType> {
                connectionType
            }, new List <TECProtocol>(), new TECManufacturer());
            TECSubScope subScope = new TECSubScope();

            subScope.Devices.Add(compatibleDevice);
            TECPoint point = new TECPoint();

            point.Type = IOType.AI;
            subScope.Points.Add(point);

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

            type.IO.Add(new TECIO(IOType.AI));

            TECProvidedController controller = new TECProvidedController(type);

            TECHardwiredConnection connection = controller.Connect(subScope, subScope.AvailableProtocols.First(x => x is TECHardwiredProtocol)) as TECHardwiredConnection;

            controller.Disconnect(subScope);

            Assert.IsFalse(controller.ChildrenConnections.Contains(connection));
            Assert.IsNull((subScope as IConnectable).GetParentConnection());
        }
        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);
        }
        public void AvailableProtocols1()
        {
            TECConnectionType type1 = new TECConnectionType();
            TECConnectionType type2 = new TECConnectionType();

            TECProtocol prot1 = new TECProtocol(new List <TECConnectionType>());
            TECProtocol prot2 = new TECProtocol(new List <TECConnectionType>());
            TECProtocol prot3 = new TECProtocol(new List <TECConnectionType>());

            TECDevice dev1 = new TECDevice(new List <TECConnectionType>(),
                                           new List <TECProtocol> {
                prot1, prot2
            }, new TECManufacturer());
            TECDevice dev2 = new TECDevice(new List <TECConnectionType> {
                type2
            },
                                           new List <TECProtocol> {
                prot1, prot3
            }, new TECManufacturer());

            TECSubScope ss        = new TECSubScope();
            bool        dev1Added = ss.AddDevice(dev1);
            bool        dev2Added = ss.AddDevice(dev2);

            Assert.IsTrue(dev1Added);
            Assert.IsTrue(dev2Added);

            Assert.IsFalse(ss.AvailableProtocols.Any(prot => { return(prot is TECHardwiredProtocol); }));
            Assert.IsTrue(ss.AvailableProtocols.Contains(prot1));
            Assert.IsFalse(ss.AvailableProtocols.Contains(prot2));
            Assert.IsFalse(ss.AvailableProtocols.Contains(prot3));
            Assert.AreEqual(1, ss.AvailableProtocols.Count);
        }
Exemplo n.º 7
0
        public void ConnectTest3()
        {
            TECConnectionType connectionType   = new TECConnectionType();
            TECDevice         compatibleDevice = new TECDevice(new List <TECConnectionType> {
                connectionType
            }, new List <TECProtocol>(), new TECManufacturer());
            TECSubScope subScope = new TECSubScope();

            subScope.Devices.Add(compatibleDevice);
            TECPoint point = new TECPoint();

            point.Type = IOType.AI;
            subScope.Points.Add(point);

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

            module.IO.Add(new TECIO(IOType.AO));
            type.IOModules.Add(module);

            TECProvidedController  controller = new TECProvidedController(type);
            TECHardwiredConnection connection = controller.Connect(subScope, subScope.HardwiredProtocol()) as TECHardwiredConnection;

            Assert.IsNull(connection);
        }
        public void CompatibleProtocolsTest2()
        {
            TECConnectionType connectionType   = new TECConnectionType();
            TECDevice         compatibleDevice = new TECDevice(new List <TECConnectionType> {
                connectionType
            }, new List <TECProtocol>(), new TECManufacturer());
            TECSubScope subScope = new TECSubScope();

            subScope.Devices.Add(compatibleDevice);
            TECPoint point = new TECPoint();

            point.Type = IOType.AI;
            subScope.Points.Add(point);

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

            type.IO.Add(new TECIO(IOType.AI));

            TECProvidedController controller = new TECProvidedController(type);

            var compatible = controller.CompatibleProtocols(subScope);

            Assert.AreEqual(1, compatible.Count);
            Assert.IsTrue(compatible.Any(x => x is TECHardwiredProtocol));
        }
Exemplo n.º 9
0
        public static TECConnectionType TestConnectionType(TECCatalogs catalogs, Random rand)
        {
            TECConnectionType type = new TECConnectionType();

            type.Description = string.Format("Test Connection Type");
            type.AssignRandomElectricalMaterialProperties(catalogs, rand);
            type.PlenumCost  = (rand.NextDouble() * 100);
            type.PlenumLabor = (rand.NextDouble() * 100);
            return(type);
        }
        public void GetHashCodeTest()
        {
            TECConnectionType type1 = new TECConnectionType();
            TECConnectionType type2 = new TECConnectionType();

            TECHardwiredProtocol first = new TECHardwiredProtocol(new List <TECConnectionType>()
            {
                type1, type2
            });
            TECHardwiredProtocol second = new TECHardwiredProtocol(new List <TECConnectionType>()
            {
                type1, type2
            });

            Assert.AreEqual(first.GetHashCode(), second.GetHashCode());
        }
        public void EqualsTest()
        {
            TECConnectionType type1 = new TECConnectionType();
            TECConnectionType type2 = new TECConnectionType();

            TECHardwiredProtocol first = new TECHardwiredProtocol(new List <TECConnectionType>()
            {
                type1, type2
            });
            TECHardwiredProtocol second = new TECHardwiredProtocol(new List <TECConnectionType>()
            {
                type1, type2
            });

            Assert.AreEqual(first, second);
        }
Exemplo n.º 12
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);
        }
        public void Undo_Template_Device_ConnectionType()
        {
            //Arrange
            var Template           = ModelCreation.TestTemplates(rand);
            var device             = Template.Catalogs.Devices[0];
            int expected           = device.HardwiredConnectionTypes.Count;
            TECConnectionType edit = Template.Catalogs.ConnectionTypes[0];

            //Act
            ChangeWatcher watcher = new ChangeWatcher(Template); DoStacker testStack = new DoStacker(watcher);

            device.HardwiredConnectionTypes.Add(edit);
            //Assert.AreEqual(1, testStack.UndoCount(), "Not added to undo stack");
            testStack.Undo();

            //assert
            int actual = device.HardwiredConnectionTypes.Count;

            Assert.AreEqual(expected, actual, "Not Undone");
        }
        public void GetCostsTest()
        {
            TECConnectionType type  = new TECConnectionType();
            TECAssociatedCost aCost = new TECAssociatedCost(CostType.TEC);

            aCost.Cost = 3;
            TECAssociatedCost rCost = new TECAssociatedCost(CostType.TEC);

            rCost.Cost = 5;
            type.Cost  = 2;
            type.Labor = 1;

            type.AssociatedCosts.Add(aCost);
            type.RatedCosts.Add(rCost);

            var costs        = type.GetCosts(2);
            var tecExpected  = 2 * (5) + 3;
            var elecExpected = 2 * (2);

            Assert.AreEqual(tecExpected, costs.GetCost(CostType.TEC));
            Assert.AreEqual(elecExpected, costs.GetCost(CostType.Electrical));
            var tecLaborExpected  = 0;
            var elecLabroExpected = 2 * (1);

            Assert.AreEqual(tecLaborExpected, costs.GetLabor(CostType.TEC));
            Assert.AreEqual(elecLabroExpected, costs.GetLabor(CostType.Electrical));

            type.PlenumCost  = 1;
            type.PlenumLabor = 1;
            costs            = type.GetCosts(2, true);
            tecExpected      = 2 * (5) + 3;
            elecExpected     = 2 * (2 + 1);
            Assert.AreEqual(tecExpected, costs.GetCost(CostType.TEC));
            Assert.AreEqual(elecExpected, costs.GetCost(CostType.Electrical));
            tecLaborExpected  = 0;
            elecLabroExpected = 2 * (1 + 1);
            Assert.AreEqual(tecLaborExpected, costs.GetLabor(CostType.TEC));
            Assert.AreEqual(elecLabroExpected, costs.GetLabor(CostType.Electrical));
        }
        public void RemoveDeviceFromConnectedHardwired()
        {
            TECControllerType type = new TECControllerType(new TECManufacturer());

            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);

            TECHardwiredConnection connection = controller.Connect(subScope, subScope.HardwiredProtocol()) as TECHardwiredConnection;

            subScope.RemoveDevice(device);

            Assert.IsNull((subScope as IConnectable).GetParentConnection());
            Assert.IsFalse(controller.ChildrenConnections.Contains(connection));
        }
        public void CanConnectTest7()
        {
            TECConnectionType connectionType   = new TECConnectionType();
            TECDevice         compatibleDevice = new TECDevice(new List <TECConnectionType> {
                connectionType
            }, new List <TECProtocol>(), new TECManufacturer());
            TECSubScope subScope = new TECSubScope();

            subScope.Devices.Add(compatibleDevice);
            TECPoint point = new TECPoint();

            point.Type = IOType.AI;
            subScope.Points.Add(point);

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

            type.IO.Add(new TECIO(IOType.AO));

            TECProvidedController controller = new TECProvidedController(type);

            Assert.IsFalse(controller.CanConnect(subScope, subScope.AvailableProtocols.First(x => x is TECHardwiredProtocol)));
        }
        public void CanConnectTest2()
        {
            TECConnectionType connectionType   = new TECConnectionType();
            TECDevice         compatibleDevice = new TECDevice(new List <TECConnectionType> {
                connectionType
            }, new List <TECProtocol>(), new TECManufacturer());
            TECSubScope subScope = new TECSubScope();

            subScope.Devices.Add(compatibleDevice);
            TECPoint point = new TECPoint();

            point.Type = IOType.AI;
            subScope.Points.Add(point);

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

            type.IO.Add(new TECIO(IOType.AI));

            TECProvidedController controller = new TECProvidedController(type);

            Assert.IsTrue(controller.CanConnect(subScope));
        }
 public WireSummaryItem(TECConnectionType type, double length, bool isPlenum) : base(type, length)
 {
     this.IsPlenum = isPlenum;
     updateTotals();
 }
Exemplo n.º 19
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));
        }
Exemplo n.º 20
0
        public void ConnectToControllerTest2()
        {
            TECConnectionType connectionType = new TECConnectionType();
            TECDevice         protDevice     = new TECDevice(new List <TECConnectionType> {
                connectionType
            }, 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 otherAiPoint = new TECPoint();

            otherAiPoint.Type = IOType.AI;
            item5.AddPoint(otherAiPoint);
            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.IsTrue(connections.Any(x => connectionContainsItem(x, thing)));
            }
        }
        public void RemoveAllChildConnectionsTest()
        {
            TECConnectionType connectionType = new TECConnectionType();

            TECProtocol firstProtocol  = new TECProtocol(new List <TECConnectionType>());
            TECProtocol secondProtocol = new TECProtocol(new List <TECConnectionType>());
            TECProtocol thirdProtocol  = new TECProtocol(new List <TECConnectionType>());
            TECProtocol fourthProtocol = new TECProtocol(new List <TECConnectionType>());

            TECDevice compatibleDevice = new TECDevice(new List <TECConnectionType> {
                connectionType
            }, new List <TECProtocol>()
            {
                secondProtocol, firstProtocol, fourthProtocol
            }, new TECManufacturer());
            TECSubScope subScope = new TECSubScope();

            subScope.Devices.Add(compatibleDevice);

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

            type.IO.Add(new TECIO(firstProtocol));
            type.IO.Add(new TECIO(secondProtocol));
            type.IO.Add(new TECIO(thirdProtocol));

            TECProvidedController controller = new TECProvidedController(type);

            TECNetworkConnection connection = controller.Connect(subScope, firstProtocol) as TECNetworkConnection;

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

            hardSubScope.Devices.Add(compatibleDevice);
            TECPoint point = new TECPoint();

            point.Type = IOType.AI;
            hardSubScope.Points.Add(point);

            type.IO.Add(new TECIO(IOType.AI));

            TECHardwiredConnection hardConnection = controller.Connect(hardSubScope, hardSubScope.AvailableProtocols.First(x => x is TECHardwiredProtocol)) as TECHardwiredConnection;


            TECController parentController = new TECProvidedController(type);

            parentController.Connect(controller, secondProtocol);

            Assert.IsNotNull(controller.ParentConnection);

            controller.RemoveAllChildConnections();

            Assert.IsFalse(connection.Children.Contains(subScope));
            Assert.IsFalse(controller.ChildrenConnections.Contains(connection));
            Assert.IsNull((subScope as IConnectable).GetParentConnection());

            Assert.IsFalse(controller.ChildrenConnections.Contains(hardConnection));
            Assert.IsNull((hardSubScope as IConnectable).GetParentConnection());

            Assert.IsNotNull(controller.ParentConnection);
        }
Exemplo n.º 22
0
 private void deleteProtocolConnectionTypeExecute(TECConnectionType obj)
 {
     (Selected as TECProtocol).ConnectionTypes.Remove(obj);
 }
Exemplo n.º 23
0
 private bool canDeleteProtocolConnectionType(TECConnectionType arg)
 {
     return(Selected is TECProtocol);
 }
Exemplo n.º 24
0
        public static TECCatalogs CreateTestCatalogs()
        {
            TECCatalogs outCatalogs = new TECCatalogs();

            //Associated Costs
            TECAssociatedCost elecCost = new TECAssociatedCost(CostType.Electrical);

            elecCost.Name  = "Elec Cost";
            elecCost.Cost  = 156.61;
            elecCost.Labor = 456.64;
            elecCost.Type  = CostType.Electrical;
            outCatalogs.AssociatedCosts.Add(elecCost);

            TECAssociatedCost tecCost = new TECAssociatedCost(CostType.TEC);

            tecCost.Name  = "TEC Cost";
            tecCost.Cost  = 46.43;
            tecCost.Labor = 61.45;
            tecCost.Type  = CostType.TEC;
            outCatalogs.AssociatedCosts.Add(tecCost);

            //Tags
            var tag1 = new TECTag();

            tag1.Label = "Tag 1";
            var tag2 = new TECTag();

            tag2.Label = "Test Tag";

            outCatalogs.Tags.Add(tag1);
            outCatalogs.Tags.Add(tag2);

            //Conduit Types
            var conduitType1 = new TECElectricalMaterial();

            conduitType1.Name  = "Test Conduit 1";
            conduitType1.Cost  = 64.49;
            conduitType1.Labor = 463.87;
            AssignSecondaryProperties(conduitType1, outCatalogs);
            conduitType1.RatedCosts.Add(tecCost);
            conduitType1.RatedCosts.Add(elecCost);

            outCatalogs.ConduitTypes.Add(conduitType1);

            var conduitType2 = new TECElectricalMaterial();

            conduitType2.Name  = "Test Conduit 2";
            conduitType2.Cost  = 13.45;
            conduitType2.Labor = 9873.40;
            AssignSecondaryProperties(conduitType2, outCatalogs);
            conduitType2.RatedCosts.Add(tecCost);
            conduitType2.RatedCosts.Add(elecCost);

            outCatalogs.ConduitTypes.Add(conduitType2);

            //ConnectionTypes
            var connectionType1 = new TECConnectionType();

            connectionType1.Name  = "FourC18";
            connectionType1.Cost  = 64.63;
            connectionType1.Labor = 98.16;
            AssignSecondaryProperties(connectionType1, outCatalogs);
            connectionType1.RatedCosts.Add(tecCost);
            connectionType1.RatedCosts.Add(elecCost);

            var connectionType2 = new TECConnectionType();

            connectionType2.Name  = "ThreeC18";
            connectionType2.Cost  = 73.16;
            connectionType2.Labor = 35.49;
            AssignSecondaryProperties(connectionType1, outCatalogs);
            connectionType1.RatedCosts.Add(tecCost);
            connectionType1.RatedCosts.Add(elecCost);

            outCatalogs.ConnectionTypes.Add(connectionType1);
            outCatalogs.ConnectionTypes.Add(connectionType2);

            //Manufacturers
            var manufacturer1 = new TECManufacturer();

            manufacturer1.Label      = "Test";
            manufacturer1.Multiplier = .51;

            outCatalogs.Manufacturers.Add(manufacturer1);

            //Devices
            ObservableCollection <TECConnectionType> contypes4 = new ObservableCollection <TECConnectionType>();

            contypes4.Add(connectionType1);
            TECDevice device1 = new TECDevice(Guid.NewGuid(), contypes4, new List <TECProtocol>(), manufacturer1);

            device1.Name        = "Device 1";
            device1.Description = "Description 1";
            device1.Price       = 64.96;
            device1.Tags.Add(tag1);
            AssignSecondaryProperties(device1, outCatalogs);

            outCatalogs.Devices.Add(device1);

            //IO Modules
            TECIOModule testIOModule = new TECIOModule(manufacturer1);

            testIOModule.Name         = "Test IO Module";
            testIOModule.Price        = 13.46;
            testIOModule.Manufacturer = manufacturer1;
            outCatalogs.IOModules.Add(testIOModule);

            //Controller Types
            TECControllerType controllerType = new TECControllerType(manufacturer1);

            controllerType.Name  = "Test Controller Type";
            controllerType.Price = 196.73;
            controllerType.Labor = 61.34;
            AssignSecondaryProperties(controllerType, outCatalogs);

            TECIO io = new TECIO(IOType.AI);

            io.Quantity = 100;
            controllerType.IO.Add(io);

            io          = new TECIO(IOType.UI);
            io.Quantity = 100;
            controllerType.IO.Add(io);

            io          = new TECIO(IOType.UO);
            io.Quantity = 100;
            controllerType.IO.Add(io);

            outCatalogs.ControllerTypes.Add(controllerType);

            //Panel Types
            TECPanelType panelType = new TECPanelType(manufacturer1);

            panelType.Price = 16.64;
            panelType.Labor = 91.46;
            panelType.Name  = "Test Panel Type";
            AssignSecondaryProperties(panelType, outCatalogs);

            outCatalogs.PanelTypes.Add(panelType);

            TECPanelType otherPanelType = new TECPanelType(manufacturer1);

            otherPanelType.Price = 46.61;
            otherPanelType.Labor = 64.19;
            otherPanelType.Name  = "Other Test Panel Type";
            AssignSecondaryProperties(otherPanelType, outCatalogs);

            outCatalogs.PanelTypes.Add(otherPanelType);

            //Valves
            TECDevice actuator = new TECDevice(new ObservableCollection <TECConnectionType>()
            {
                connectionType1
            },
                                               new List <TECProtocol>(),
                                               manufacturer1);

            actuator.Name = "actuator";
            outCatalogs.Devices.Add(actuator);
            TECValve valve = new TECValve(manufacturer1, actuator);

            outCatalogs.Valves.Add(valve);

            //Protocols
            TECProtocol protocol = new TECProtocol(new List <TECConnectionType> {
                connectionType1
            });

            protocol.Label = "BACnet IP";
            outCatalogs.Protocols.Add(protocol);

            controllerType.IO.Add(new TECIO(protocol));

            TECDevice netDevice = new TECDevice(Guid.NewGuid(), new List <TECConnectionType>(), new List <TECProtocol> {
                protocol
            }, manufacturer1);

            outCatalogs.Devices.Add(netDevice);

            return(outCatalogs);
        }
Exemplo n.º 25
0
        public static TECTemplates CreateTestTemplates()
        {
            TECTemplates templates = new TECTemplates();

            //Labor
            //templates.Labor = CreateTestLabor();
            templates.Parameters.Add(CreateTestParameters(Guid.NewGuid()));
            templates.Catalogs = CreateTestCatalogs();

            //Tags
            TECTag testTag = new TECTag();

            testTag.Label = "Test Tag";
            TECTag sysTag = new TECTag();

            sysTag.Label = "System Tag";
            TECTag equipTag = new TECTag();

            equipTag.Label = "Equipment Tag";
            TECTag ssTag = new TECTag();

            ssTag.Label = "SubScope Tag";
            TECTag devTag = new TECTag();

            devTag.Label = "Device Tag";

            templates.Catalogs.Tags.Add(testTag);
            templates.Catalogs.Tags.Add(sysTag);
            templates.Catalogs.Tags.Add(equipTag);
            templates.Catalogs.Tags.Add(ssTag);
            templates.Catalogs.Tags.Add(devTag);

            //Manufacturers
            TECManufacturer testMan = new TECManufacturer();

            testMan.Label      = "Test Manufacturer";
            testMan.Multiplier = 0.654;
            TECManufacturer testDevMan = new TECManufacturer();

            testDevMan.Label      = "Child Manufacturer (Test Device)";
            testDevMan.Multiplier = 0.446;
            TECManufacturer childDevMan = new TECManufacturer();

            childDevMan.Label      = "Child Manufacturer (Child Device)";
            childDevMan.Multiplier = 0.916;

            templates.Catalogs.Manufacturers.Add(testMan);
            templates.Catalogs.Manufacturers.Add(testDevMan);
            templates.Catalogs.Manufacturers.Add(childDevMan);

            //Connection Types
            TECConnectionType testDevConnType = new TECConnectionType();

            testDevConnType.Name = "FourC18";

            TECConnectionType childDevConnType = new TECConnectionType();

            childDevConnType.Name = "ThreeC18";

            templates.Catalogs.ConnectionTypes.Add(testDevConnType);
            templates.Catalogs.ConnectionTypes.Add(childDevConnType);

            //Conduit Types
            TECElectricalMaterial testConduitType = new TECElectricalMaterial();

            testConduitType.Name  = "EMT";
            testConduitType.Cost  = 12;
            testConduitType.Labor = 2;

            templates.Catalogs.ConduitTypes.Add(testConduitType);

            TECElectricalMaterial otherConduitType = new TECElectricalMaterial();

            otherConduitType.Name  = "RGS";
            otherConduitType.Cost  = 18;
            otherConduitType.Labor = 4;

            templates.Catalogs.ConduitTypes.Add(otherConduitType);

            //Associated Costs
            TECAssociatedCost testAssociatedCost = new TECAssociatedCost(CostType.Electrical);

            testAssociatedCost.Name = "Flex";
            testAssociatedCost.Cost = 42;

            templates.Catalogs.AssociatedCosts.Add(testAssociatedCost);

            var testCost2 = new TECAssociatedCost(CostType.TEC);

            testCost2.Name = "Other Cost";
            templates.Catalogs.AssociatedCosts.Add(testCost2);

            //IO Modules
            TECIOModule testIOModule = new TECIOModule(testMan);

            testIOModule.Name         = "Test IO Module";
            testIOModule.Price        = 42;
            testIOModule.Manufacturer = testMan;
            templates.Catalogs.IOModules.Add(testIOModule);

            //Devices
            ObservableCollection <TECConnectionType> contypes2 = new ObservableCollection <TECConnectionType>();

            contypes2.Add(testDevConnType);
            TECDevice testDev = new TECDevice(Guid.NewGuid(), contypes2, new List <TECProtocol>(), testDevMan);

            testDev.Name        = "Test Device";
            testDev.Description = "Device Description";
            testDev.Price       = 20.3;

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

            contypes3.Add(childDevConnType);
            TECDevice childDev = new TECDevice(Guid.NewGuid(), contypes3, new List <TECProtocol>(), childDevMan);

            childDev.Name        = "Child Device";
            childDev.Description = "Child Device Description";
            childDev.Price       = 54.1;

            testDev.Tags.Add(devTag);
            childDev.Tags.Add(devTag);

            templates.Catalogs.Devices.Add(testDev);
            templates.Catalogs.Devices.Add(childDev);

            //System
            TECSystem system = new TECSystem(false);

            system.Name        = "Test System";
            system.Description = "System Description";

            TECEquipment sysEquip = new TECEquipment(false);

            sysEquip.Name        = "System Equipment";
            sysEquip.Description = "Child Equipment";
            TECSubScope sysSS = new TECSubScope(false);

            sysSS.Name        = "System SubScope";
            sysSS.Description = "Child SubScope";
            sysSS.AssociatedCosts.Add(testAssociatedCost);
            TECPoint sysPoint = new TECPoint(false);

            sysPoint.Type  = IOType.AI;
            sysPoint.Label = "System Point";

            sysSS.Points.Add(sysPoint);
            sysSS.Devices.Add(childDev);
            sysSS.Tags.Add(ssTag);

            sysEquip.SubScope.Add(sysSS);
            sysEquip.Tags.Add(equipTag);

            system.Equipment.Add(sysEquip);
            system.Tags.Add(sysTag);

            templates.SystemTemplates.Add(system);

            //Equipment
            TECEquipment equipment = new TECEquipment(false);

            equipment.Name        = "Test Equipment";
            equipment.Description = "Equipment Description";
            TECSubScope equipSS = new TECSubScope(false);

            equipSS.Name        = "Equipment SubScope";
            equipSS.Description = "Child SubScope";
            TECPoint equipPoint = new TECPoint(false);

            equipPoint.Type  = IOType.AI;
            equipPoint.Label = "Equipment Point";

            equipSS.Points.Add(equipPoint);
            equipSS.Devices.Add(childDev);
            equipSS.Tags.Add(ssTag);

            equipment.SubScope.Add(equipSS);
            equipment.Tags.Add(equipTag);

            templates.EquipmentTemplates.Add(equipment);

            //SubScope
            TECSubScope subScope = new TECSubScope(false);

            subScope.Name        = "Test SubScope";
            subScope.Description = "SubScope Description";
            TECPoint ssPoint = new TECPoint(false);

            ssPoint.Type  = IOType.DO;
            ssPoint.Label = "SubScope Point";

            subScope.Points.Add(ssPoint);
            subScope.Devices.Add(childDev);
            subScope.Tags.Add(ssTag);
            subScope.AssociatedCosts.Add(testAssociatedCost);

            templates.SubScopeTemplates.Add(subScope);

            //Controller
            var expectedControllerType = new TECControllerType(testMan);

            expectedControllerType.Price = 42.6;
            TECIO ioToAdd = new TECIO(IOType.AI);

            ioToAdd.Quantity = 5;
            TECIO otherIO = new TECIO(IOType.UI);

            otherIO.Quantity = 3;
            expectedControllerType.IO.Add(ioToAdd);
            expectedControllerType.IO.Add(otherIO);
            templates.Catalogs.ControllerTypes.Add(expectedControllerType);

            TECController expectedController = new TECProvidedController(expectedControllerType, false);

            expectedController.Name        = "Test Controller";
            expectedController.Description = "Test description";

            TECController controlledController = new TECProvidedController(expectedControllerType, false);

            controlledController.Name = "Controlled Controller";

            templates.ControllerTemplates.Add(expectedController);

            //Misc Cost
            TECMisc cost = new TECMisc(CostType.TEC, false);

            cost.Name     = "Test Cost";
            cost.Cost     = 79.79;
            cost.Quantity = 67;

            templates.MiscCostTemplates.Add(cost);

            //Misc wiring
            TECMisc wiring = new TECMisc(CostType.Electrical, false);

            wiring.Name     = "Test Wiring";
            wiring.Cost     = 69.69;
            wiring.Quantity = 69;

            templates.MiscCostTemplates.Add(wiring);

            //Panel Types
            TECPanelType panelType = new TECPanelType(testMan);

            panelType.Price = 123.4;
            panelType.Name  = "Test Panel Type";

            templates.Catalogs.PanelTypes.Add(panelType);

            //Panels
            TECPanel panel = new TECPanel(panelType, false);

            panel.Name = "Test Panel";
            panel.AssociatedCosts.Add(testAssociatedCost);
            panel.AssociatedCosts.Add(testAssociatedCost);

            TECPanel controlledPanel = new TECPanel(panelType, false);

            controlledPanel.Name = "Controlled Panel";

            templates.PanelTemplates.Add(panel);

            //Synchronizer
            TemplateSynchronizer <TECEquipment> equipSynchronizer = templates.EquipmentSynchronizer;
            TemplateSynchronizer <TECSubScope>  ssSynchronizer    = templates.SubScopeSynchronizer;

            TECSystem syncSys = new TECSystem(false);

            syncSys.Name = "Sync System";
            templates.SystemTemplates.Add(syncSys);

            TECEquipment syncEquip = new TECEquipment(false);

            syncEquip.Name = "Sync Equip";
            templates.EquipmentTemplates.Add(syncEquip);
            syncSys.Equipment.Add(equipSynchronizer.NewItem(syncEquip));

            TECSubScope syncSubScope = new TECSubScope(false);

            syncSubScope.Name = "Sync SS";
            templates.SubScopeTemplates.Add(syncSubScope);
            syncEquip.SubScope.Add(ssSynchronizer.NewItem(syncSubScope));

            return(templates);
        }
Exemplo n.º 26
0
        public void ConnectTest6()
        {
            TECProtocol firstProtocol  = new TECProtocol(new List <TECConnectionType>());
            TECProtocol secondProtocol = new TECProtocol(new List <TECConnectionType>());
            TECProtocol thirdProtocol  = new TECProtocol(new List <TECConnectionType>());
            TECProtocol fourthProtocol = new TECProtocol(new List <TECConnectionType>());

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

            TECSubScope hSubScope1 = new TECSubScope();

            hSubScope1.Devices.Add(hardDevice);
            hSubScope1.Points.Add(new TECPoint {
                Type = IOType.AI
            });

            TECSubScope hSubScope2 = new TECSubScope();

            hSubScope2.Devices.Add(hardDevice);
            hSubScope2.Points.Add(new TECPoint {
                Type = IOType.AI
            });

            TECSubScope hSubScope3 = new TECSubScope();

            hSubScope3.Devices.Add(hardDevice);
            hSubScope3.Points.Add(new TECPoint {
                Type = IOType.AI
            });

            TECSubScope hSubScope4 = new TECSubScope();

            hSubScope4.Devices.Add(hardDevice);
            hSubScope4.Points.Add(new TECPoint {
                Type = IOType.AI
            });

            TECSubScope hSubScope5 = new TECSubScope();

            hSubScope5.Devices.Add(hardDevice);
            hSubScope5.Points.Add(new TECPoint {
                Type = IOType.AI
            });


            TECDevice compatibleDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>()
            {
                secondProtocol, firstProtocol, fourthProtocol
            }, new TECManufacturer());
            TECSubScope subScope1 = new TECSubScope();

            subScope1.Devices.Add(compatibleDevice);
            TECSubScope subScope2 = new TECSubScope();

            subScope2.Devices.Add(compatibleDevice);
            TECSubScope subScope3 = new TECSubScope();

            subScope3.Devices.Add(compatibleDevice);
            TECSubScope subScope4 = new TECSubScope();

            subScope4.Devices.Add(compatibleDevice);

            List <IConnectable> connectables = new List <IConnectable>
            {
                subScope1,
                subScope2,
                subScope3,
                subScope4,
                hSubScope1,
                hSubScope2,
                hSubScope3,
                hSubScope4,
                hSubScope5
            };


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

            module.IO.Add(new TECIO(firstProtocol));

            TECIOModule hModule = new TECIOModule(new TECManufacturer());

            hModule.IO.Add(new TECIO(IOType.AI)
            {
                Quantity = 2
            });

            type.IOModules.Add(module);
            type.IOModules.Add(hModule);
            type.IOModules.Add(hModule);
            type.IOModules.Add(hModule);

            TECProvidedController controller = new TECProvidedController(type);

            foreach (var subScope in connectables)
            {
                IProtocol             protocol   = subScope.HardwiredProtocol() as IProtocol ?? firstProtocol;
                IControllerConnection connection = controller.Connect(subScope, protocol);

                bool containsChild = connection is TECNetworkConnection netConnect?
                                     netConnect.Children.Contains(subScope) : (connection as TECHardwiredConnection).Child == subScope;

                Assert.IsTrue(containsChild);
                Assert.IsTrue(controller.ChildrenConnections.Contains(connection));
                Assert.IsTrue((subScope as IConnectable).GetParentConnection() == connection);
                Assert.AreEqual(connection.Protocol, protocol);
            }
        }