public void Load_Templates_TypicalPanel()
        {
            //Arrange
            Guid   expectedGuid        = new Guid("e7695d68-d79f-44a2-92f5-b303436186af");
            string expectedName        = "Typical Panel";
            string expectedDescription = "Typical Panel Description";
            //int expectedQuantity = 1;

            Guid expectedTypeGuid = new Guid("04e3204c-b35f-4e1a-8a01-db07f7eb055e");

            TECPanel actualPanel = null;

            foreach (TECSystem system in actualTemplates.Templates.SystemTemplates)
            {
                foreach (TECPanel panel in system.Panels)
                {
                    if (panel.Guid == expectedGuid)
                    {
                        actualPanel = panel;
                        break;
                    }
                }
                if (actualPanel != null)
                {
                    break;
                }
            }

            //Assert
            Assert.AreEqual(expectedName, actualPanel.Name);
            Assert.AreEqual(expectedDescription, actualPanel.Description);
            Assert.AreEqual(expectedTypeGuid, actualPanel.Type.Guid);
            testForCosts(actualPanel);
        }
        public void Load_Templates_Panel()
        {
            //Arrange
            Guid   expectedGuid        = new Guid("a8cdd31c-e690-4eaa-81ea-602c72904391");
            string expectedName        = "Bid Panel";
            string expectedDescription = "Bid Panel Description";

            Guid expectedTypeGuid = new Guid("04e3204c-b35f-4e1a-8a01-db07f7eb055e");

            TECPanel actualPanel = null;

            foreach (TECPanel panel in actualTemplates.Templates.PanelTemplates)
            {
                if (panel.Guid == expectedGuid)
                {
                    actualPanel = panel;
                    break;
                }
            }

            //Assert
            Assert.AreEqual(expectedName, actualPanel.Name);
            Assert.AreEqual(expectedDescription, actualPanel.Description);
            Assert.AreEqual(expectedTypeGuid, actualPanel.Type.Guid);
            testForCosts(actualPanel);
        }
        public void Undo_Template_Panel()
        {
            //Arrange
            var Template = ModelCreation.TestTemplates(rand);
            ObservableCollection <TECPanel> expected = new ObservableCollection <TECPanel>();

            foreach (TECPanel item in Template.Templates.PanelTemplates)
            {
                expected.Add(item);
            }
            TECPanel edit = new TECPanel(Template.Catalogs.PanelTypes[0]);

            //Act
            ChangeWatcher watcher = new ChangeWatcher(Template); DoStacker testStack = new DoStacker(watcher);
            int           beforeCount = testStack.UndoCount();

            Template.Templates.PanelTemplates.Add(edit);
            Assert.AreEqual((beforeCount + 1), testStack.UndoCount(), "Not added to undo stack");
            testStack.Undo();

            //assert
            var actual = Template.Templates.PanelTemplates;

            Assert.AreEqual(expected.Count, actual.Count, "Not Undone");
        }
 public AddPanelVM(Action <TECPanel> addMethod, IEnumerable <TECPanelType> panelTypes, TECScopeManager scopeManager) : base(scopeManager)
 {
     Quantity   = 1;
     add        = addMethod;
     PanelTypes = new List <TECPanelType>(panelTypes);
     toAdd      = new TECPanel(PanelTypes[0]);
     AddCommand = new RelayCommand(addExecute, addCanExecute);
 }
Beispiel #5
0
        public static TECPanel TestPanel(TECCatalogs catalogs, Random rand)
        {
            TECPanel panel = new TECPanel(catalogs.PanelTypes.RandomElement(rand));

            panel.Description = "Test Panel";
            panel.AssignRandomScopeProperties(catalogs, rand);
            return(panel);
        }
        public static TECPanel CreateTestPanel(bool isTypical, TECCatalogs catalogs)
        {
            var panelType = catalogs.PanelTypes[0];

            var panel = new TECPanel(panelType, isTypical);

            panel.Tags.Add(catalogs.Tags[0]);
            return(panel);
        }
        public void SaveNew_Templates_Panel()
        {
            //Arrange
            TECPanel expectedPanel = expectedTemplates.Templates.PanelTemplates.First();
            TECPanel actualPanel   = actualTemplates.Templates.PanelTemplates.First(item => item.Guid == expectedPanel.Guid);

            Assert.AreEqual(expectedPanel.Name, actualPanel.Name);
            Assert.AreEqual(expectedPanel.Type.Guid, actualPanel.Type.Guid);
        }
Beispiel #8
0
        private CostBatch removePanel(TECPanel panel)
        {
            CostBatch deltas = new CostBatch();

            deltas += (PanelSummaryVM.RemoveHardware(panel.Type));
            foreach (ICost cost in panel.AssociatedCosts)
            {
                deltas += (PanelSummaryVM.RemoveCost(cost));
            }
            return(deltas);
        }
Beispiel #9
0
 private void handlePanelSelection(TECPanel originalPanel, TECPanel selectedPanel)
 {
     if (originalPanel != null)
     {
         originalPanel.Controllers.Remove(Controller);
     }
     if (selectedPanel != null)
     {
         selectedPanel.Controllers.Add(Controller);
     }
 }
Beispiel #10
0
 private static void linkPanelToPanelType(TECPanel panel, IEnumerable <TECPanelType> panelTypes)
 {
     foreach (TECPanelType type in panelTypes)
     {
         if (panel.Type.Guid == type.Guid)
         {
             panel.Type = type;
             return;
         }
     }
 }
Beispiel #11
0
        public void ControllerInPanel_AddPanel()
        {
            TECPanel      panel      = new TECPanel(new TECPanelType(new TECManufacturer()));
            TECController controller = new TECProvidedController(new TECControllerType(new TECManufacturer()));

            ControllerInPanel controllerInPanel = new ControllerInPanel(controller, null);

            controllerInPanel.Panel = panel;

            Assert.AreEqual(panel.Controllers.Count, 1, "Controller not added to panel");
        }
        public void DragDropCopyTest()
        {
            Random   rand  = new Random(0);
            TECBid   bid   = ModelCreation.TestBid(rand);
            TECPanel panel = ModelCreation.TestPanel(bid.Catalogs, rand);

            TECPanel copy = panel.DropData() as TECPanel;

            Assert.AreEqual(panel.Name, copy.Name);
            Assert.IsTrue(panel.CostBatch.CostsEqual(copy.CostBatch));
        }
Beispiel #13
0
        public void ControllerInPanel_RemovePanel()
        {
            TECPanel      panel      = new TECPanel(new TECPanelType(new TECManufacturer()));
            TECController controller = new TECProvidedController(new TECControllerType(new TECManufacturer()));

            ControllerInPanel controllerInPanel = new ControllerInPanel(controller, panel);

            controllerInPanel.Panel = null;

            Assert.AreEqual(panel.Controllers.Count, 0, "Controller not removed to panel");
        }
        public void Bid_AddPanel()
        {
            TECPanelType panelType = new TECPanelType(manufacturer);

            panelType.Price = 100;
            TECPanel panel = new TECPanel(panelType);

            bid.Panels.Add(panel);

            Assert.AreEqual(100, costs.GetCost(CostType.TEC));
            Assert.AreEqual(0, costs.GetCost(CostType.Electrical));
        }
 public AddPanelVM(TECSystem parentSystem, IEnumerable <TECPanelType> panelTypes, TECScopeManager scopeManager) : base(scopeManager)
 {
     Quantity = 1;
     parent   = parentSystem;
     add      = panel =>
     {
         parent.Panels.Add(panel);
     };
     PanelTypes = new List <TECPanelType>(panelTypes);
     toAdd      = new TECPanel(PanelTypes[0]);
     AddCommand = new RelayCommand(addExecute, addCanExecute);
 }
Beispiel #16
0
        private void populatePanelSelections()
        {
            PanelSelections = new ObservableCollection <TECPanel>();
            var nonePanel = new TECPanel(new TECPanelType(new TECManufacturer()));

            nonePanel.Name = "None";
            NonePanel      = nonePanel;
            PanelSelections.Add(NonePanel);
            foreach (TECPanel panel in PanelsSource)
            {
                PanelSelections.Add(panel);
            }
        }
Beispiel #17
0
        public void AddPanel()
        {
            //Arrange
            TECPanel panel = ModelCreation.TestPanel(bid.Catalogs, rand);

            panel.AssignRandomScopeProperties(bid.Catalogs, rand);

            MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw);

            //Act
            bid.Panels.Add(panel);

            //Assert
            AssertMaterialVMMatchesCostBatch(matVM, panel.CostBatch);
        }
Beispiel #18
0
 private void populateControllerCollection()
 {
     ControllerCollection = new ObservableCollection <ControllerInPanel>();
     controllersIndex     = new Dictionary <TECController, ControllerInPanel>();
     foreach (TECController controller in sourceControllers)
     {
         TECPanel panelToAdd = PanelsSource.FirstOrDefault(panel =>
                                                           { return(panel.Controllers.Contains(controller)); });
         var controllerInPanelToAdd = new ControllerInPanel(controller, panelToAdd);
         if (controller is TECFBOController fbo)
         {
             controllerInPanelToAdd = new FBOControllerInPanel(fbo, panelToAdd);
         }
         ControllerCollection.Add(controllerInPanelToAdd);
         controllersIndex[controller] = controllerInPanelToAdd;
     }
 }
Beispiel #19
0
        public void SaveAs_Bid_Panel()
        {
            //Arrange
            TECPanel expectedPanel = expectedBid.Panels[0];
            TECPanel actualPanel   = null;

            foreach (TECPanel panel in actualBid.Panels)
            {
                if (panel.Guid == expectedPanel.Guid)
                {
                    actualPanel = panel;
                    break;
                }
            }

            Assert.AreEqual(expectedPanel.Name, actualPanel.Name);
            Assert.AreEqual(expectedPanel.Type.Guid, actualPanel.Type.Guid);
            Assert.IsTrue(compareCosts(expectedPanel.CostBatch, actualPanel.CostBatch));
        }
        public void Undo_Template_Panel_Name()
        {
            //Arrange
            var      Template     = ModelCreation.TestTemplates(rand);
            TECPanel expected     = Template.Templates.PanelTemplates[0];
            string   expectedName = expected.Name;

            string edit = "edit";

            //Act
            ChangeWatcher watcher = new ChangeWatcher(Template); DoStacker testStack = new DoStacker(watcher);
            int           beforeCount = testStack.UndoCount();

            Template.Templates.PanelTemplates[0].Name = edit;
            Assert.AreEqual((beforeCount + 1), testStack.UndoCount(), "Not added to undo stack");
            testStack.Undo();

            //assert
            TECPanel actual = Template.Templates.PanelTemplates[0];

            Assert.AreEqual(expectedName, actual.Name, "Not Undone");
        }
        public static TECBid CreateTestBid()
        {
            TECBid bid = new TECBid();

            //Bid Info
            bid.Name        = "Bid Name";
            bid.BidNumber   = "1701-117";
            bid.DueDate     = DateTime.Now;
            bid.Salesperson = "Mrs. Test";
            bid.Estimator   = "Mr. Test";

            //Bid Objects
            bid.ExtraLabor = CreateTestExtraLabor(bid.Guid);
            bid.Parameters = CreateTestParameters(bid.Guid);
            bid.Catalogs   = CreateTestCatalogs();

            //Internal Notes
            TECInternalNote internalNote = new TECInternalNote();

            internalNote.Label = "Test internal";
            internalNote.Body  = "Test body";
            bid.InternalNotes.Add(internalNote);

            //Locations
            var cellar = new TECLocation();

            cellar.Name  = "Cellar";
            cellar.Label = "C";

            var location1 = new TECLocation();

            location1.Name  = "1st Floor";
            location1.Label = "1";

            var location2 = new TECLocation();

            location2.Name  = "2nd Floor";
            location2.Label = "2";

            var location3 = new TECLocation();

            location3.Name  = "3rd Floor";
            location3.Label = "3";

            bid.Locations.Add(cellar);
            bid.Locations.Add(location1);
            bid.Locations.Add(location2);
            bid.Locations.Add(location3);


            //Scope Branches
            var branch1 = new TECScopeBranch(false);

            branch1.Label = "Branch 1";
            var branch2 = new TECScopeBranch(false);

            branch2.Label = "Branch 2";
            var branch3 = new TECScopeBranch(false);

            branch3.Label = "Branch 3";

            bid.ScopeTree.Add(branch1);
            branch1.Branches.Add(branch2);
            branch2.Branches.Add(branch3);

            //Notes
            var note1 = new TECLabeled();

            note1.Label = "Note 1";

            bid.Notes.Add(note1);

            //Exclusions
            var exclusion1 = new TECLabeled();

            exclusion1.Label = "Exclusion 1";

            bid.Exclusions.Add(exclusion1);

            //Controller
            TECController expectedController = new TECProvidedController(Guid.NewGuid(), bid.Catalogs.ControllerTypes[0], false);

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

            bid.AddController(expectedController);

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

            cost.Name     = "Test Cost";
            cost.Cost     = 69.69;
            cost.Quantity = 69;

            bid.MiscCosts.Add(cost);

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

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

            bid.MiscCosts.Add(wiring);

            //Panels
            TECPanel panel = new TECPanel(bid.Catalogs.PanelTypes[0], false);

            panel.Name = "Test Panel";
            panel.Controllers.Add(expectedController);
            panel.AssociatedCosts.Add(bid.Catalogs.AssociatedCosts[0]);
            panel.AssociatedCosts.Add(bid.Catalogs.AssociatedCosts[0]);

            bid.Panels.Add(panel);

            //Systems
            var system1 = CreateTestTypical(bid.Catalogs);

            system1.Name        = "System 1";
            system1.Description = "Locations all the way";
            system1.Location    = cellar;

            var system2 = CreateTestTypical(bid.Catalogs);

            system2.Name        = "System 2";
            system2.Description = "Description 2";

            var system3 = CreateTestTypical(bid.Catalogs);

            system3.Name        = "System 3";
            system3.Description = "";

            bid.Systems.Add(system1);
            bid.Systems.Add(system2);
            bid.Systems.Add(system3);

            system1.AddInstance(bid);
            system2.AddInstance(bid);
            system3.AddInstance(bid);

            system1.AddInstance(bid);
            system2.AddInstance(bid);
            system3.AddInstance(bid);

            //Equipment
            var equipment1 = new TECEquipment(true);

            equipment1.Name        = "Equipment 1";
            equipment1.Description = "Description 1";

            var equipment2 = new TECEquipment(true);

            equipment2.Name        = "Equipment 2";
            equipment2.Description = "Description 2";

            system1.Equipment.Add(equipment1);
            system3.Equipment.Add(equipment2);

            //SubScope
            var subScope1 = new TECSubScope(true);

            subScope1.Name        = "SubScope 1";
            subScope1.Description = "Description 1";
            subScope1.AssociatedCosts.Add(bid.Catalogs.AssociatedCosts[0]);
            subScope1.AssociatedCosts.Add(bid.Catalogs.AssociatedCosts[0]);
            subScope1.AssociatedCosts.Add(bid.Catalogs.AssociatedCosts[0]);

            var subScope2 = new TECSubScope(true);

            subScope2.Name        = "Empty SubScope";
            subScope2.Description = "Description 2";
            subScope2.AssociatedCosts.Add(bid.Catalogs.AssociatedCosts[0]);

            equipment1.SubScope.Add(subScope1);
            equipment2.SubScope.Add(subScope2);

            //Points
            var point1 = new TECPoint(true);

            point1.Label    = "Point 1";
            point1.Type     = IOType.AI;
            point1.Quantity = 2;

            subScope1.Points.Add(point1);

            var point2 = new TECPoint(true);

            point2.Label    = "Point 2";
            point2.Type     = IOType.AI;
            point2.Quantity = 2;

            subScope2.Points.Add(point2);

            //Devices
            subScope1.Devices.Add(bid.Catalogs.Devices[0]);

            //Connections
            TECSubScope           instanceSubScope = system1.GetInstancesFromTypical(subScope1)[0];
            IControllerConnection testConnection   = expectedController.Connect(instanceSubScope, (instanceSubScope as IConnectable).AvailableProtocols.First());

            testConnection.ConduitType = bid.Catalogs.ConduitTypes[0];
            testConnection.Length      = 42;

            AssignAllSecondaryProperties(bid);

            TECTypical noLocation = new TECTypical();

            noLocation.Name = "No Location";
            noLocation.Equipment.Add(new TECEquipment(true));
            noLocation.Equipment[0].SubScope.Add(new TECSubScope(true));
            bid.Systems.Add(noLocation);

            return(bid);
        }
Beispiel #22
0
        internal static void GenerateReport(string path, TECBid bid, bool openOnComplete = true)
        {
            XLWorkbook   workbook  = new XLWorkbook();
            IXLWorksheet worksheet = workbook.Worksheets.Add("Summary");

            worksheet.Cell(1, 2).Value = "Quantity";
            worksheet.Cell(1, 2).Style.Border.BottomBorder = XLBorderStyleValues.Thick;
            worksheet.Cell(1, 3).Value = "Price";
            worksheet.Cell(1, 3).Style.Border.BottomBorder = XLBorderStyleValues.Thick;
            worksheet.Cell(1, 4).Value = "Unit Price";
            worksheet.Cell(1, 4).Style.Border.BottomBorder = XLBorderStyleValues.Thick;

            worksheet.Cell(2, 1).Value = "Systems";
            worksheet.Cell(2, 1).Style.Border.BottomBorder = XLBorderStyleValues.Thin;

            int x = 3;

            for (int i = 0; i < bid.Systems.Count; i++, x++)
            {
                TECTypical   typical        = bid.Systems[i];
                TECEstimator systemEstimate = new TECEstimator(typical, bid.Parameters, bid.ExtraLabor, bid.Duration, new ChangeWatcher(typical));
                worksheet.Cell(x, 1).Value = typical.Name;
                worksheet.Cell(x, 2).Value = typical.Instances.Count;
                worksheet.Cell(x, 3).Value = systemEstimate.TotalPrice;
                worksheet.Cell(x, 3).Style.NumberFormat.Format = "$ #,##0.00";
                worksheet.Cell(x, 4).Value = typical.Instances.Count > 0 ? systemEstimate.TotalPrice / typical.Instances.Count : 0;
                worksheet.Cell(x, 4).Style.NumberFormat.Format = "$ #,##0.00";
            }
            x++;

            worksheet.Cell(x, 1).Value = "BMS Network";
            worksheet.Cell(x, 1).Style.Border.BottomBorder = XLBorderStyleValues.Thin;
            x++;

            for (int i = 0; i < bid.Controllers.Count; i++, x++)
            {
                TECController controller     = bid.Controllers[i];
                TECEstimator  systemEstimate = new TECEstimator(controller, bid.Parameters, bid.ExtraLabor, bid.Duration, new ChangeWatcher(controller));
                worksheet.Cell(x, 1).Value = controller.Name;
                worksheet.Cell(x, 2).Value = "1";
                worksheet.Cell(x, 3).Value = systemEstimate.TotalPrice;
                worksheet.Cell(x, 3).Style.NumberFormat.Format = "$ #,##0.00";
            }
            for (int i = 0; i < bid.Panels.Count; i++, x++)
            {
                TECPanel     typical        = bid.Panels[i];
                TECEstimator systemEstimate = new TECEstimator(typical, bid.Parameters, bid.ExtraLabor, bid.Duration, new ChangeWatcher(typical));
                worksheet.Cell(x, 1).Value = typical.Name;
                worksheet.Cell(x, 2).Value = "1";
                worksheet.Cell(x, 3).Value = systemEstimate.TotalPrice;
                worksheet.Cell(x, 3).Style.NumberFormat.Format = "$ #,##0.00";
            }
            x++;

            worksheet.Cell(x, 1).Value = "Miscellaneous";
            worksheet.Cell(x, 1).Style.Border.BottomBorder = XLBorderStyleValues.Thin;
            x++;

            for (int i = 0; i < bid.MiscCosts.Count; i++, x++)
            {
                TECMisc      typical        = bid.MiscCosts[i];
                TECEstimator systemEstimate = new TECEstimator(typical, bid.Parameters, bid.ExtraLabor, bid.Duration, new ChangeWatcher(typical));
                worksheet.Cell(x, 1).Value = typical.Name;
                worksheet.Cell(x, 2).Value = typical.Quantity;
                worksheet.Cell(x, 3).Value = systemEstimate.TotalPrice;
                worksheet.Cell(x, 3).Style.NumberFormat.Format = "$ #,##0.00";
            }
            TECEstimator extraLaborEstimate = new TECEstimator(bid.ExtraLabor, bid.Parameters, bid.ExtraLabor, bid.Duration, new ChangeWatcher(bid.ExtraLabor));

            worksheet.Cell(x, 1).Value = "Other Labor";
            worksheet.Cell(x, 2).Value = "1";
            worksheet.Cell(x, 3).Value = extraLaborEstimate.TotalPrice;
            worksheet.Cell(x, 3).Style.NumberFormat.Format = "$ #,##0.00";
            x += 2;

            worksheet.Cell(x, 2).Value = "Total: ";
            worksheet.Cell(x, 2).Style.Border.BottomBorder = XLBorderStyleValues.Thick;

            worksheet.Cell(x, 3).FormulaA1 = "=SUM(C3:C" + (x - 1) + ")";
            worksheet.Cell(x, 3).Style.NumberFormat.Format = "$ #,##0.00";

            worksheet.Columns().AdjustToContents();
            workbook.SaveAs(path);


            if (openOnComplete)
            {
                System.Diagnostics.Process.Start(path);
            }
        }
Beispiel #23
0
 public void UpdatePanel(TECPanel panel)
 {
     _panel = panel;
     raisePropertyChanged("Panel");
 }
Beispiel #24
0
 private static void linkPanelToCatalogs(TECPanel panel, TECCatalogs catalogs)
 {
     linkPanelToPanelType(panel, catalogs.PanelTypes);
     linkScopeChildrenToCatalogs(panel, catalogs);
 }
Beispiel #25
0
 public ControllerInPanel(TECController controller, TECPanel panel) : base(Guid.NewGuid())
 {
     _controller = controller;
     _panel      = panel;
 }
 public FBOControllerInPanel(TECFBOController controller, TECPanel panel) : base(controller, panel)
 {
     _controller        = controller;
     AddPointCommand    = new RelayCommand(addPointExecute, canAddPoint);
     DeletePointCommand = new RelayCommand <TECPoint>(deletePointExecute, canDeletePoint);
 }
 internal void SetTemplate(TECPanel panel)
 {
     ToAdd = new TECPanel(panel);
 }
        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);
        }
Beispiel #29
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();
        }
Beispiel #30
0
 private void deletePanelExecute(TECPanel panel)
 {
     deletePanelMethod(panel);
 }