public void Load_Templates_ConnectionType()
        {
            //Arrange
            Guid   expectedGuid  = new Guid("f38867c8-3846-461f-a6fa-c941aeb723c7");
            string expectedName  = "Test Connection Type";
            double expectedCost  = 12.48;
            double expectedLabor = 84.21;

            TECElectricalMaterial actualConnectionType = null;

            foreach (TECElectricalMaterial connectionType in actualTemplates.Catalogs.ConnectionTypes)
            {
                if (connectionType.Guid == expectedGuid)
                {
                    actualConnectionType = connectionType;
                    break;
                }
            }

            //Assert
            Assert.AreEqual(expectedName, actualConnectionType.Name);
            Assert.AreEqual(expectedCost, actualConnectionType.Cost);
            Assert.AreEqual(expectedLabor, actualConnectionType.Labor);

            testForCosts(actualConnectionType);
            testForRatedCosts(actualConnectionType);
        }
        public void Load_Templates_ConduitType()
        {
            //Arrange
            Guid   expectedGuid  = new Guid("8d442906-efa2-49a0-ad21-f6b27852c9ef");
            string expectedName  = "Test Conduit Type";
            double expectedCost  = 45.67;
            double expectedLabor = 76.54;

            TECElectricalMaterial actualConduitType = null;

            foreach (TECElectricalMaterial conduitType in actualTemplates.Catalogs.ConduitTypes)
            {
                if (conduitType.Guid == expectedGuid)
                {
                    actualConduitType = conduitType;
                    break;
                }
            }

            //Assert
            Assert.AreEqual(expectedName, actualConduitType.Name);
            Assert.AreEqual(expectedCost, actualConduitType.Cost);
            Assert.AreEqual(expectedLabor, actualConduitType.Labor);

            testForCosts(actualConduitType);
            testForRatedCosts(actualConduitType);
        }
        public void GetCostsTest()
        {
            TECElectricalMaterial type  = new TECElectricalMaterial();
            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));
        }
        public CostBatch AddLength(TECElectricalMaterial material, double length)
        {
            if (length < 0)
            {
                logger.Error("Length needs to be greater than 0 when adding to length summary. " +
                             "Failed to add length. Obj: {0}", material.Name);
                return(new CostBatch());
            }

            CostBatch deltas       = new CostBatch();
            bool      containsItem = lengthDictionary.ContainsKey(material.Guid);

            if (containsItem)
            {
                LengthSummaryItem item  = lengthDictionary[material.Guid];
                CostBatch         delta = item.AddLength(length);
                LengthCostTotal  += delta.GetCost(CostType.Electrical);
                LengthLaborTotal += delta.GetLabor(CostType.Electrical);
                deltas           += delta;
            }
            else
            {
                LengthSummaryItem item = new LengthSummaryItem(material, length);
                lengthDictionary.Add(material.Guid, item);
                _lengthSummaryItems.Add(item);
                LengthCostTotal  += item.TotalCost;
                LengthLaborTotal += item.TotalLabor;
                deltas           += new CostBatch(item.TotalCost, item.TotalLabor, CostType.Electrical);
            }
            foreach (ICost cost in material.RatedCosts)
            {
                deltas += addRatedCost(cost, length);
            }
            return(deltas);
        }
        private static List <LengthSummaryItem> consolidateConduit(IEnumerable <IControllerConnection> connections)
        {
            Dictionary <TECElectricalMaterial, LengthSummaryItem> dictionary = new Dictionary <TECElectricalMaterial, LengthSummaryItem>();
            List <LengthSummaryItem> items = new List <LengthSummaryItem>();

            foreach (IControllerConnection connection in connections)
            {
                TECElectricalMaterial type = connection.ConduitType;
                if (type != null)
                {
                    if (dictionary.ContainsKey(type))
                    {
                        dictionary[type].AddLength(connection.ConduitLength);
                    }
                    else
                    {
                        LengthSummaryItem item = new LengthSummaryItem(type, connection.ConduitLength);
                        dictionary.Add(type, item);
                        items.Add(item);
                    }
                }
            }

            return(items);
        }
예제 #6
0
        public static TECElectricalMaterial TestElectricalMaterial(TECCatalogs catalogs, Random rand, string type)
        {
            TECElectricalMaterial mat = new TECElectricalMaterial();

            mat.Description = string.Format("Test {0}", type);
            mat.AssignRandomElectricalMaterialProperties(catalogs, rand);
            return(mat);
        }
        public CostBatch RemoveRun(TECElectricalMaterial material, double length)
        {
            CostBatch deltas = RemoveLength(material, length);

            foreach (ICost cost in material.AssociatedCosts)
            {
                deltas += removeAssocCost(cost);
            }
            return(deltas);
        }
        public void DragDropCopyTest()
        {
            TECBid bid = new TECBid();
            TECElectricalMaterial dev = new TECElectricalMaterial();

            bid.Catalogs.Add(dev);
            var copy = dev.DropData();

            Assert.AreEqual(dev, copy);
        }
        public NetworkConnectionVM(TECNetworkConnection connection, IEnumerable <TECElectricalMaterial> conduitTypes)
        {
            noneConduit      = new TECElectricalMaterial();
            noneConduit.Name = "None";

            Connection = connection;
            Connection.PropertyChanged += handleConnectionChanged;
            ConduitTypes = conduitTypes != null ? new List <TECElectricalMaterial>(conduitTypes) : new List <TECElectricalMaterial>();
            ConduitTypes.Insert(0, noneConduit);
        }
 public SubScopeConnectionItem(TECSubScope subScope, TECElectricalMaterial noneConduit, TECSystem parentSystem, TECEquipment parentEquip, bool needsUpdate = false)
 {
     SubScope      = subScope;
     SystemName    = parentSystem.Name;
     EquipmentName = parentEquip.Name;
     NeedsUpdate   = needsUpdate;
     if (subScope.IsTypical)
     {
         subScope.Connection.PropertyChanged += Connection_PropertyChanged;
     }
     this.noneConduit = noneConduit;
 }
        public void CatalogCopyTest()
        {
            Random                rand     = new Random(0);
            TECCatalogs           catalogs = ModelCreation.TestCatalogs(rand);
            TECElectricalMaterial mat      = ModelCreation.TestElectricalMaterial(catalogs, rand, "conduit");
            var copy = mat.CatalogCopy();

            Assert.AreNotEqual(mat.Guid, copy.Guid);
            Assert.AreEqual(mat.Name, copy.Name);
            Assert.AreEqual(mat.Description, copy.Description);
            Assert.AreEqual(mat.Cost, copy.Cost);
        }
예제 #12
0
 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     if (value == null)
     {
         var conduitType = new TECElectricalMaterial();
         conduitType.Name = "None";
         return(conduitType);
     }
     else
     {
         return(value);
     }
 }
        public static void ClassInitialize(TestContext TestContext)
        {
            rand = new Random(0);
            //Arrange
            expectedTemplates = ModelCreation.TestTemplates(rand);
            ModelCreation.AddSyncronizerItems(expectedTemplates);
            expectedSystem         = expectedTemplates.Templates.SystemTemplates.First();
            expectedEquipment      = expectedTemplates.Templates.EquipmentTemplates.First();
            expectedSubScope       = expectedTemplates.Templates.SubScopeTemplates.First();
            expectedDevice         = expectedTemplates.Catalogs.Devices.First();
            expectedManufacturer   = expectedTemplates.Catalogs.Manufacturers.First();
            expectedTag            = expectedTemplates.Catalogs.Tags[0];
            expectedController     = (TECProvidedController)expectedTemplates.Templates.ControllerTemplates.First(sys => sys is TECProvidedController);
            expectedAssociatedCost = expectedTemplates.Catalogs.AssociatedCosts[0];
            expectedConnectionType = expectedTemplates.Catalogs.ConnectionTypes[0];
            expectedConduitType    = expectedTemplates.Catalogs.ConduitTypes[0];

            path = Path.GetTempFileName();

            //Act
            DatabaseManager <TECTemplates> manager = new DatabaseManager <TECTemplates>(path);
            bool success = manager.New(expectedTemplates);

            Assert.IsTrue(success, "New method in DatabaseManager returned false.");
            actualTemplates = manager.Load();

            if (actualTemplates.Templates.SystemTemplates.Count == 0)
            {
                string failDirectory = Path.GetTempPath() + "Estimating Tools\\";
                Directory.CreateDirectory(failDirectory);
                string failPath = failDirectory + "SaveNewTemplatesTestFailed.tdb";
                if (File.Exists(failPath))
                {
                    File.Delete(failPath);
                }
                File.Copy(path, failPath);
                Assert.Fail(string.Format("No systems loaded into templates. File saved at: {0}", failPath));
            }

            actualSystem         = actualTemplates.Templates.SystemTemplates.First(x => x.Guid == expectedSystem.Guid);
            actualEquipment      = actualTemplates.Templates.EquipmentTemplates.First(x => x.Guid == expectedEquipment.Guid);
            actualSubScope       = actualTemplates.Templates.SubScopeTemplates.First(x => x.Guid == expectedSubScope.Guid);
            actualDevice         = actualTemplates.Catalogs.Devices.First(x => x.Guid == expectedDevice.Guid);
            actualManufacturer   = actualTemplates.Catalogs.Manufacturers.First(x => x.Guid == expectedManufacturer.Guid);
            actualTag            = actualTemplates.Catalogs.Tags.First(x => x.Guid == expectedTag.Guid);
            actualController     = actualTemplates.Templates.ControllerTemplates.First(x => x.Guid == expectedController.Guid) as TECProvidedController;
            actualAssociatedCost = actualTemplates.Catalogs.AssociatedCosts.First(x => x.Guid == expectedAssociatedCost.Guid);
            actualConnectionType = actualTemplates.Catalogs.ConnectionTypes.First(x => x.Guid == expectedConnectionType.Guid);
            actualConduitType    = actualTemplates.Catalogs.ConduitTypes.First(x => x.Guid == expectedConduitType.Guid);
        }
예제 #14
0
        private void addConduitTypeExecute()
        {
            TECElectricalMaterial conduitType = new TECElectricalMaterial();

            conduitType.Name  = ConduitTypeName;
            conduitType.Cost  = ConduitTypeCost;
            conduitType.Labor = ConduitTypeLabor;

            this.Templates.Catalogs.Add(conduitType);

            this.ConduitTypeName  = "";
            this.ConduitTypeCost  = 0;
            this.ConduitTypeLabor = 0;
        }
        public static void AssignRandomElectricalMaterialProperties(this TECElectricalMaterial mat, TECCatalogs catalogs, Random rand)
        {
            mat.AssignRandomCostProperties(catalogs, rand);
            TECAssociatedCost randTECCost  = catalogs.RandomCost(rand, CostType.TEC);
            TECAssociatedCost randElecCost = catalogs.RandomCost(rand, CostType.Electrical);

            if (randTECCost != null)
            {
                mat.RatedCosts.Add(randTECCost);
            }
            if (randElecCost != null)
            {
                mat.RatedCosts.Add(randElecCost);
            }
        }
        private void testForRatedCosts(TECElectricalMaterial component)
        {
            bool foundCost = false;

            foreach (ICost cost in component.RatedCosts)
            {
                if (cost.Guid == TEST_RATED_COST_GUID)
                {
                    foundCost = true;
                    break;
                }
            }

            Assert.IsTrue(foundCost, "Rated Cost not loaded properly into scope.");
        }
        public CostBatch RemoveLength(TECElectricalMaterial material, double length)
        {
            if (length < 0)
            {
                logger.Error("Length needs to be greater than 0 when removing from length summary. " +
                             "Failed to remove length. Obj: {0}", material.Name);
                return(new CostBatch());
            }

            bool containsItem = lengthDictionary.ContainsKey(material.Guid);

            if (containsItem)
            {
                CostBatch         deltas = new CostBatch();
                LengthSummaryItem item   = lengthDictionary[material.Guid];
                CostBatch         delta  = item.RemoveLength(length);
                LengthCostTotal  += delta.GetCost(CostType.Electrical);
                LengthLaborTotal += delta.GetLabor(CostType.Electrical);
                deltas           += delta;

                if (item.Length <= 0)
                {
                    _lengthSummaryItems.Remove(item);
                    lengthDictionary.Remove(material.Guid);
                }
                foreach (ICost cost in material.RatedCosts)
                {
                    deltas += removeRatedCost(cost, length);
                }
                return(deltas);
            }
            else
            {
                logger.Error("Electrical Material not found. Cannot remove length. Material: {0}",
                             material.Name);
                return(new CostBatch());
            }
        }
예제 #18
0
        public InterlocksVM(IRelatable root, ChangeWatcher watcher,
                            TECCatalogs catalogs, Func <ITECObject, bool> filterPredicate = null)
        {
            if (filterPredicate == null)
            {
                filterPredicate = item => true;
            }
            this.filterPredicate = filterPredicate;

            this.root = root;
            new DirectRelationshipChangedFilter(watcher).DirectRelationshipChanged += parentScopeChanged;


            noneConduit                  = new TECElectricalMaterial();
            noneConduit.Name             = "None";
            this.rootInterlockablesGroup = new ScopeGroup("root");
            this.AddInterlockCommand     = new RelayCommand(addInterlockExecute, canAddInterlock);
            this.DeleteInterlockCommand  = new RelayCommand <TECInterlockConnection>(deleteInterlockExecute, canDeleteInterlock);
            this.ConduitTypes            = new List <TECElectricalMaterial>(catalogs.ConduitTypes);
            this.ConduitTypes.Add(noneConduit);
            this.ConduitType = noneConduit;

            repopulateGroups(null, root, addInterlockable);
        }
예제 #19
0
 private bool canDeleteConnectionType(TECElectricalMaterial arg)
 {
     return(arg is TECConnectionType);
 }
예제 #20
0
 //Cosntructor
 public LengthSummaryItem(TECElectricalMaterial material, double length) : base(Guid.NewGuid())
 {
     _material = material;
     _length   = length;
     updateTotals();
 }
예제 #21
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);
        }
예제 #22
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);
        }
예제 #23
0
 private void deleteConnectiontypeExecute(TECElectricalMaterial obj)
 {
     ToAdd.ConnectionTypes.Remove(obj as TECConnectionType);
 }