public bool AddCalculationsToCurrentElement( CalculatorParameters calcParameters, XElement currentCalculationsElement, XElement currentElement) { bool bHasCalculations = false; if (currentElement.Name.LocalName == Input.INPUT_PRICE_TYPES.inputgroup.ToString() && calcParameters.ExtensionDocToCalcURI.URINodeName != Constants.LINKEDVIEWS_TYPES.linkedview.ToString()) { bHasCalculations = BIM1Calculator.SetTotalMachineryStockCalculations( currentCalculationsElement, currentElement); } else { if (currentCalculationsElement != null) { Machinery1Input machInput = new Machinery1Input(); //deserialize xml to object machInput.SetMachinery1InputProperties(calcParameters, currentCalculationsElement, currentElement); //init analyzer props machInput.SetCalculatorProperties(currentCalculationsElement); //run the calculations bHasCalculations = RunMachineryStockCalculations(machInput, calcParameters); //serialize object back to xml (note that the base calc is not run here) string sAttNameExtension = string.Empty; //set new machinery input totals machInput.SetAndRemoveCalculatorAttributes(sAttNameExtension, currentCalculationsElement); machInput.SetMachinery1InputAttributes(calcParameters, currentCalculationsElement, currentElement); //set calculatorid (primary way to display calculation attributes) CalculatorHelpers.SetCalculatorId( currentCalculationsElement, currentElement); //input groups only aggregate inputs (not input series) if (currentElement.Name.LocalName .Contains(Input.INPUT_PRICE_TYPES.input.ToString())) { //add the machinery to the machstock.machstocks dictionary //the count is 1-based, while iNodePosition is 0-based //so the count is the correct next index position int iNodePosition = BIM1Calculator.MachineryStock .GetNodePositionCount(calcParameters.AnalyzerParms.FilePositionIndex, machInput); if (iNodePosition < 0) { iNodePosition = 0; } bHasCalculations = BIM1Calculator.MachineryStock .AddMachinery1StocksToDictionary( calcParameters.AnalyzerParms.FilePositionIndex, iNodePosition, machInput); } } } return(bHasCalculations); }
private void CopyMachinery1InputProperties(Machinery1Input calculator) { this.MarketValue = calculator.MarketValue; this.ListPriceAdj = calculator.ListPriceAdj; this.SalvageValue = calculator.SalvageValue; this.FuelAmount = calculator.FuelAmount; this.FuelUnit = calculator.FuelUnit; this.FuelPrice = calculator.FuelPrice; this.FuelCost = calculator.FuelCost; this.LubeOilAmount = calculator.LubeOilAmount; this.LubeOilUnit = calculator.LubeOilUnit; this.LubeOilPrice = calculator.LubeOilPrice; this.LubeOilCost = calculator.LubeOilCost; this.RepairCost = calculator.RepairCost; this.LaborAmount = calculator.LaborAmount; this.LaborUnit = calculator.LaborUnit; this.LaborPrice = calculator.LaborPrice; this.LaborCost = calculator.LaborCost; this.ServiceUnits = calculator.ServiceUnits; this.ServiceCapacityUnits = calculator.ServiceCapacityUnits; this.CapitalRecoveryCost = calculator.CapitalRecoveryCost; this.TaxesHousingInsuranceCost = calculator.TaxesHousingInsuranceCost; this.OptionForCapacity = calculator.OptionForCapacity; this.OptionForInflation = calculator.OptionForInflation; this.OptionForTime = calculator.OptionForTime; this.OptionForFuel = calculator.OptionForFuel; this.LaborAmountAdj = calculator.LaborAmountAdj; }
public static bool AddMachineryInputToStock(Machinery1Stock machStock, double multiplier, Machinery1Input machinput, string currentNodeName, bool adjustTotals) { bool bHasCalculations = false; //inheriting classes usually run this class, but adjust their own totals if (adjustTotals) { //multipliers (input.times, out.compositionamount, oc.amount, tp.amount) //don't change per hour machinery costs, only total costs if (currentNodeName.EndsWith(Input.INPUT_PRICE_TYPES.input.ToString())) { //i.e. machinput.cost = machinput.cost * multiplier * input.ocamount //multiplier = input.times * oc.amount * tp.amount ChangeMachineryInputByInputMultipliers(machinput, multiplier); } else { //i.e. machinput.cost = machinput.cost * multiplier (1 in stock analyzers) ChangeMachineryInputByMultiplier(machinput, multiplier); } } machStock.TotalMarketValue += (machinput.MarketValue); machStock.TotalSalvageValue += (machinput.SalvageValue); machStock.TotalFuelAmount += (machinput.FuelAmount); machStock.TotalFuelPrice += AgBudgetingRules.GetFuelPrice(machinput); machStock.TotalFuelCost += (machinput.FuelCost); machStock.TotalLubeOilAmount += (machinput.LubeOilAmount); machStock.TotalLubeOilPrice += (machinput.Constants.PriceOil); machStock.TotalLubeOilCost += (machinput.LubeOilCost); machStock.TotalRepairCost += (machinput.RepairCost); machStock.TotalLaborAmount += (machinput.LaborAmount); machStock.TotalLaborPrice += AgBudgetingRules.GetLaborPrice(machinput); machStock.TotalLaborCost += (machinput.LaborCost); machStock.TotalCapitalRecoveryCost += (machinput.CapitalRecoveryCost); machStock.TotalTaxesHousingInsuranceCost += (machinput.TaxesHousingInsuranceCost); machStock.TotalPriceGas += (machinput.Constants.PriceGas); machStock.TotalPriceDiesel += (machinput.Constants.PriceDiesel); machStock.TotalPriceLP += (machinput.Constants.PriceLP); machStock.TotalPriceElectric += (machinput.Constants.PriceElectric); machStock.TotalPriceNG += (machinput.Constants.PriceNG); machStock.TotalPriceOil += (machinput.Constants.PriceOil); machStock.TotalPriceRegularLabor += (machinput.Constants.PriceRegularLabor); machStock.TotalPriceMachineryLabor += (machinput.Constants.PriceMachineryLabor); machStock.TotalPriceSupervisorLabor += (machinput.Constants.PriceSupervisorLabor); machStock.TotalStartingHrs += (machinput.Constants.StartingHrs); machStock.TotalPlannedUseHrs += (machinput.Constants.PlannedUseHrs); machStock.TotalUsefulLifeHrs += (machinput.Constants.UsefulLifeHrs); machStock.TotalHousingPercent += (machinput.Constants.HousingPercent); machStock.TotalTaxPercent += (machinput.Constants.TaxPercent); machStock.TotalInsurePercent += (machinput.Constants.InsurePercent); machStock.TotalSpeed += (machinput.Constants.FieldSpeedTypical); machStock.TotalWidth += (machinput.Constants.Width); machStock.TotalHorsepower += (machinput.Constants.HP); machStock.TotalHPPTOEquiv += (machinput.Constants.HPPTOEquiv); machStock.TotalFieldEffTypical += (machinput.Constants.FieldEffTypical); bHasCalculations = true; return(bHasCalculations); }
private void TransferCorrespondingDbProperties( Machinery1Input machInput) { //calculators use aliases to change db properties if (machInput.MarketValue > 0) { machInput.CAPPrice = machInput.MarketValue; } }
//copy constructors public void CopyMachinery1InputProperties(CalculatorParameters calcParameters, Machinery1Input calculator) { //set the base input properties this.SetInputProperties(calcParameters, calculator); this.Local = new Local(calcParameters, calculator.Local); //set the constants properties this.Constants = new Machinery1Constant(); this.Constants.SetMachinery1ConstantProperties(calculator.Constants); this.Sizes = new SizeRanges(); this.Sizes.CopySizeRangesProperties(calculator.Sizes); CopyMachinery1InputProperties(calculator); }
//add a Machinery1Input to the baseStat.MachineryStocks dictionary public static bool AddMachinery1StocksToDictionary( this Machinery1Stock baseStat, int filePosition, int nodePosition, Machinery1Input calculator) { bool bIsAdded = false; if (filePosition < 0 || nodePosition < 0) { baseStat.ErrorMessage = Errors.MakeStandardErrorMsg("ANALYSES_INDEX_OUTOFBOUNDS"); return(false); } if (baseStat.MachineryStocks == null) { baseStat.MachineryStocks = new Dictionary <int, List <Machinery1Input> >(); } if (baseStat.MachineryStocks.ContainsKey(filePosition)) { if (baseStat.MachineryStocks[filePosition] != null) { for (int i = 0; i <= nodePosition; i++) { if (baseStat.MachineryStocks[filePosition].Count <= i) { baseStat.MachineryStocks[filePosition] .Add(new Machinery1Input()); } } baseStat.MachineryStocks[filePosition][nodePosition] = calculator; bIsAdded = true; } } else { //add the missing dictionary entry List <Machinery1Input> baseStats = new List <Machinery1Input>(); KeyValuePair <int, List <Machinery1Input> > newStat = new KeyValuePair <int, List <Machinery1Input> >( filePosition, baseStats); baseStat.MachineryStocks.Add(newStat); bIsAdded = AddMachinery1StocksToDictionary(baseStat, filePosition, nodePosition, calculator); } return(bIsAdded); }
public static void AddMachinery1InputTotals(Machinery1Input machInput, ref XElement machInputCalcElement) { //these have already been adjusted by input multipliers (ocamount, times) machInput.TotalOC = machInput.FuelCost + machInput.LaborCost + machInput.RepairCost + machInput.LubeOilCost; machInput.TotalAOH = machInput.CapitalRecoveryCost + machInput.TaxesHousingInsuranceCost; CalculatorHelpers.SetAttributeDoubleF2(machInputCalcElement, CostBenefitCalculator.TOC, machInput.TotalOC); CalculatorHelpers.SetAttributeDoubleF2(machInputCalcElement, CostBenefitCalculator.TAOH, machInput.TotalAOH); //extra multiplier needed for display CalculatorHelpers.SetAttributeDoubleF2(machInputCalcElement, Input.INPUT_TIMES, machInput.Times); }
public static double GetInputFullCostMultiplier(Machinery1Input machInput, CalculatorParameters calcParams) { //to keep all machinery stock analysis consistent, put the totals //in the inputs, then all can be compared consistently //input.times double dbInputMultiplier = IOMachineryStockSubscriber .GetMultiplierForTechInput(machInput); //oc.amount double dbOCMultiplier = OCMachineryStockSubscriber .GetMultiplierForOperation(calcParams.ParentOperationComponent); double dbTPAmount = BIMachineryStockSubscriber.GetMultiplierForTimePeriod( calcParams.ParentTimePeriod); double dbMultiplier = dbInputMultiplier * dbOCMultiplier * dbTPAmount; return(dbMultiplier); }
public static int GetNodePositionCount(this Machinery1Stock baseStat, int filePosition, Machinery1Input calculator) { int iNodeCount = 0; if (baseStat.MachineryStocks == null) { return(iNodeCount); } if (baseStat.MachineryStocks.ContainsKey(filePosition)) { if (baseStat.MachineryStocks[filePosition] != null) { iNodeCount = baseStat.MachineryStocks[filePosition].Count; } } return(iNodeCount); }
public static void ChangeMachineryInputByMultiplier(Machinery1Input machInput, double multiplier) { //cost per hour * hrs/acre * input.times machInput.FuelCost = (machInput.FuelCost * multiplier); machInput.FuelAmount = (machInput.FuelAmount * multiplier); machInput.LubeOilCost = (machInput.LubeOilCost * multiplier); machInput.LubeOilAmount = (machInput.LubeOilAmount * multiplier); machInput.RepairCost = (machInput.RepairCost * multiplier); machInput.LaborCost = (machInput.LaborCost * multiplier); machInput.LaborAmount = (machInput.LaborAmount * multiplier); machInput.CapitalRecoveryCost = (machInput.CapitalRecoveryCost * multiplier); machInput.TaxesHousingInsuranceCost = (machInput.TaxesHousingInsuranceCost); //this is ok for machinerystock analysis (but not for npv) machInput.TotalOC = machInput.FuelCost + machInput.LubeOilCost + machInput.RepairCost + machInput.LaborCost; machInput.TotalAOH = machInput.CapitalRecoveryCost + machInput.TaxesHousingInsuranceCost; }
public static void ChangeMachineryInputByInputMultipliers(Machinery1Input machInput, double multiplier) { //cost per hour * hrs/acre * input.times machInput.FuelCost = (machInput.FuelCost * multiplier * machInput.OCAmount); machInput.FuelAmount = (machInput.FuelAmount * multiplier * machInput.OCAmount); machInput.LubeOilCost = (machInput.LubeOilCost * multiplier * machInput.OCAmount); machInput.LubeOilAmount = (machInput.LubeOilAmount * multiplier * machInput.OCAmount); machInput.RepairCost = (machInput.RepairCost * multiplier * machInput.OCAmount); machInput.LaborCost = (machInput.LaborCost * multiplier * machInput.OCAmount); machInput.LaborAmount = (machInput.LaborAmount * multiplier * machInput.OCAmount); //163 stopped using AOHAmount because it isn't always set set machInput.CapitalRecoveryCost = (machInput.CapitalRecoveryCost * multiplier * machInput.OCAmount); machInput.TaxesHousingInsuranceCost = (machInput.TaxesHousingInsuranceCost * multiplier * machInput.OCAmount); //this is ok for machinerystock analysis machInput.TotalOC = machInput.FuelCost + machInput.LubeOilCost + machInput.RepairCost + machInput.LaborCost; machInput.TotalAOH = machInput.CapitalRecoveryCost + machInput.TaxesHousingInsuranceCost; }
public bool RunMachineryStockCalculations(Machinery1Input machInput, CalculatorParameters calcParameters) { bool bHasCalculations = false; //see if any db props are being changed by calculator TransferCorrespondingDbProperties(machInput); //set the multiplier (the multiplier in most inputs is 1, //this is kept here to keep a uniform pattern when the multiplier //can be changed -see the food nutrition calculator) double multiplier = IOMachineryStockSubscriber .GetMultiplierForInput(machInput); if (multiplier != 1) { bHasCalculations = SetMachineryStockCalculations(multiplier, calcParameters, machInput); } else { bHasCalculations = true; } return(bHasCalculations); }
public bool SetMachineryStockCalculations(double multiplier, CalculatorParameters calcParameters, Machinery1Input machInput) { bool bHasCalculations = true; //don't adjust machinery per hour costs by any multiplier //pattern is fine but not appropriate here //if (machInput != null) //{ // //in this extension, calculations are carried out in the // //budget/investment calculators // BIMachineryStockCalculator.ChangeMachineryInputByMultiplier(machInput, multiplier); // bHasCalculations = true; //} //else //{ // calcParameters.ErrorMessage = Errors.MakeStandardErrorMsg("CALCULATORS_WRONG_ONE"); //} return(bHasCalculations); }
//copies the underlying input and locals props too public Machinery1Input(CalculatorParameters calcParameters, Machinery1Input calculator) { CopyMachinery1InputProperties(calcParameters, calculator); }
//copy constructors public Machinery1Input(Machinery1Input calculator) { CopyMachinery1InputProperties(calculator); }