public void AddValve() { //Arrange TECValve valve = ModelCreation.TestValve(bid.Catalogs, rand); valve.AssignRandomScopeProperties(bid.Catalogs, rand); TECTypical typical = new TECTypical(); bid.Systems.Add(typical); TECEquipment typEquip = new TECEquipment(); typical.Equipment.Add(typEquip); TECSubScope typSS = new TECSubScope(); typEquip.SubScope.Add(typSS); typical.AddInstance(); MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw); //Act typSS.Devices.Add(valve); //Assert AssertMaterialVMMatchesCostBatch(matVM, valve.CostBatch); }
public void RemoveValve() { //Arrange bid.Catalogs.Add(ModelCreation.TestValve(bid.Catalogs, rand)); ChangeWatcher cw = new ChangeWatcher(bid); TECTypical typical = new TECTypical(); bid.Systems.Add(typical); TECEquipment typEquip = new TECEquipment(); typical.Equipment.Add(typEquip); TECSubScope typSS = new TECSubScope(); typEquip.SubScope.Add(typSS); TECValve valve = bid.Catalogs.Valves[0]; valve.AssignRandomScopeProperties(bid.Catalogs, rand); typSS.Devices.Add(valve); typical.AddInstance(); MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw); CostBatch initial = MatVMToCostBatch(matVM); //Act typSS.Devices.Remove(valve); //Assert AssertMaterialVMMatchesCostBatch(matVM, initial - valve.CostBatch); }
public CostBatch RemoveValve(TECValve valve) { bool containsItem = valveDictionary.ContainsKey(valve.Guid); if (containsItem) { CostBatch deltas = new CostBatch(); ValveSummaryItem item = valveDictionary[valve.Guid]; CostBatch delta = item.Decrement(); deltas += delta; ValveCost += delta.GetCost(valve.Type); ValveLabor += delta.GetLabor(valve.Type); if (item.Quantity < 1) { _valveItems.Remove(item); valveDictionary.Remove(valve.Guid); } deltas += RemoveActuator(valve.Actuator); foreach (ICost cost in valve.AssociatedCosts) { deltas += RemoveCost(cost); } return(deltas); } else { logger.Error("Valve not present. Cannot remove valve. Valve: {0}", valve.Name); return(new CostBatch()); } }
public CostBatch AddValve(TECValve valve) { CostBatch deltas = new CostBatch(); bool containsItem = valveDictionary.ContainsKey(valve.Guid); if (containsItem) { ValveSummaryItem item = valveDictionary[valve.Guid]; CostBatch delta = item.Increment(); ValveCost += delta.GetCost(valve.Type); ValveLabor += delta.GetLabor(valve.Type); deltas += delta; } else { ValveSummaryItem item = new ValveSummaryItem(valve); valveDictionary.Add(valve.Guid, item); _valveItems.Add(item); ValveCost += item.TotalCost; ValveLabor += item.TotalLabor; deltas += new CostBatch(item.TotalCost, item.TotalLabor, valve.Type); } deltas += AddActuator(valve.Actuator); foreach (ICost cost in valve.AssociatedCosts) { deltas += AddCost(cost); } return(deltas); }
private bool canReplaceValve(TECValve arg) { if (arg == null || SelectedValve?.Valve == null) { return(false); } return(SelectedValve.SubScope.CanChangeDevice(SelectedValve.Valve, arg)); }
public static TECValve CreateTestValve(TECCatalogs catalogs) { TECValve valve = new TECValve(catalogs.Manufacturers[0], catalogs.Devices[0]); valve.Price = 52.62; valve.AssociatedCosts.Add(catalogs.AssociatedCosts[0]); valve.Tags.Add(catalogs.Tags[0]); return(valve); }
public static TECValve TestValve(TECCatalogs catalogs, Random rand) { TECManufacturer man = catalogs.Manufacturers.RandomElement(rand); TECDevice dev = catalogs.Devices.RandomElement(rand); TECValve valve = new TECValve(man, dev); valve.Description = string.Format("Test Valve"); valve.AssignRandomCostProperties(catalogs, rand); return(valve); }
public void SetLabor() { TECCatalogs catalogs = ModelCreation.TestCatalogs(rand); TECValve valve = catalogs.Valves.RandomElement(rand); double newValue = rand.NextDouble() * 100; valve.Labor = newValue; Assert.AreEqual(newValue, valve.Labor); }
public void CatalogCopyTest() { Random rand = new Random(0); TECCatalogs catalogs = ModelCreation.TestCatalogs(rand); TECValve valve = ModelCreation.TestValve(catalogs, rand); var copy = valve.CatalogCopy(); Assert.AreNotEqual(valve.Guid, copy.Guid); Assert.AreEqual(valve.Name, copy.Name); Assert.AreEqual(valve.Description, copy.Description); Assert.AreEqual(valve.Price, copy.Price); Assert.AreEqual(valve.Manufacturer, copy.Manufacturer); Assert.AreEqual(valve.Actuator, copy.Actuator); }
public ReplaceActuatorVM(TECValve valve, IEnumerable <TECDevice> devices) { this.Valve = valve; SelectedReplacement = null; ViableReplacements = new List <TECDevice>(); foreach (TECDevice dev in devices) { if ((valve.Actuator as IEndDevice).ConnectionMethods.SequenceEqual((dev as IEndDevice).ConnectionMethods) && valve.Actuator != dev) { ViableReplacements.Add(dev); } } ReplaceCommand = new RelayCommand(replaceExecute, replaceCanExecute); }
private void addValveExecute() { TECValve toAdd = new TECValve(ValveManufacturer, ValveActuator); toAdd.Name = ValveName; toAdd.Description = ValveDescription; toAdd.Price = ValveListPrice; toAdd.Labor = ValveLabor; toAdd.Style = ValveStyle; toAdd.Cv = ValveCv; toAdd.Size = ValveSize; Templates.Catalogs.Add(toAdd); ValveName = ""; ValveDescription = ""; ValveListPrice = 0; ValveLabor = 0; ValveCv = 0.0; ValveStyle = ""; ValveSize = 0.0; ValveActuator = null; ValveManufacturer = null; }
private void replaceValveExecute(TECValve obj) { SelectedValve.SubScope.RemoveCatalogItem <IEndDevice>(SelectedValve.Valve, obj); SelectedValve.Valve = obj; }
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); }
public ValveSummaryItem(TECValve valve) { Valve = valve; _quantity = 1; updateTotals(); }
public ValveScopeItem(TECEquipment equipment, TECSubScope subScope, TECValve valve) { this.Equipment = equipment; this.SubScope = subScope; this.Valve = valve; }