Ejemplo n.º 1
0
        public bool AddCalculationsToCurrentElement(
            CalculatorParameters calcParameters, ref XElement currentCalculationsElement, ref XElement currentElement)
        {
            bool bHasCalculations = false;

            if (currentElement.Name.LocalName
                == Input.INPUT_PRICE_TYPES.inputgroup.ToString() &&
                calcParameters.ExtensionDocToCalcURI.URINodeName
                != Constants.LINKEDVIEWS_TYPES.linkedview.ToString())
            {
                bHasCalculations = BIGC1Calculator.SetTotalMachineryStockCalculations(
                    ref currentCalculationsElement, ref currentElement);
            }
            else
            {
                if (currentCalculationsElement != null)
                {
                    GeneralCapital1Input machInput = new GeneralCapital1Input();
                    machInput.SetGeneralCapital1InputProperties(calcParameters,
                                                                currentCalculationsElement, currentElement);
                    //init analyzer props
                    machInput.SetCalculatorProperties(currentCalculationsElement);
                    //run the calculations
                    bHasCalculations = RunGeneralCapitalStockCalculations(machInput,
                                                                          calcParameters);
                    //serialize object back to xml (note that the base calc is not run here)
                    string sAttNameExtension = string.Empty;
                    //update the calculator attributes
                    machInput.SetAndRemoveCalculatorAttributes(sAttNameExtension,
                                                               ref currentCalculationsElement);
                    machInput.SetGeneralCapital1InputAttributes(calcParameters,
                                                                ref currentCalculationsElement, ref 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
                        == Input.INPUT_PRICE_TYPES.input.ToString())
                    {
                        //the count is 1-based, while iNodePosition is 0-based
                        //so the count is the correct next index position
                        int iNodePosition = BIGC1Calculator.GeneralCapitalStock
                                            .GetNodePositionCount(calcParameters.AnalyzerParms.FilePositionIndex,
                                                                  machInput);
                        if (iNodePosition < 0)
                        {
                            iNodePosition = 0;
                        }
                        bHasCalculations = BIGC1Calculator.GeneralCapitalStock
                                           .AddGeneralCapital1StocksToDictionary(
                            calcParameters.AnalyzerParms.FilePositionIndex, iNodePosition,
                            machInput);
                    }
                }
            }
            return(bHasCalculations);
        }
Ejemplo n.º 2
0
 private void TransferCorrespondingDbProperties(
     ref GeneralCapital1Input machInput)
 {
     //calculators use aliases to change db properties
     if (machInput.MarketValue > 0)
     {
         machInput.CAPPrice = machInput.MarketValue;
     }
 }
Ejemplo n.º 3
0
 private void CopyGeneralCapital1InputProperties(
     GeneralCapital1Input calculator)
 {
     this.CopyCalculatorProperties(calculator);
     this.Constants        = calculator.Constants;
     this.Sizes            = calculator.Sizes;
     this.Local            = calculator.Local;
     this.Capital1Constant = calculator.Capital1Constant;
     this.EnergyUseHr      = calculator.EnergyUseHr;
     this.EnergyEffTypical = calculator.EnergyEffTypical;
 }
        public static bool AddMachineryInputToStock(GeneralCapital1Stock machStock, double multiplier,
                                                    GeneralCapital1Input 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.TotalEnergyUseHr               += (machinput.EnergyUseHr);
            machStock.TotalEnergyEffTypical          += (machinput.EnergyEffTypical);
            machStock.TotalRandMPercent              += (machinput.Capital1Constant.RandMPercent);
            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);
            bHasCalculations = true;
            return(bHasCalculations);
        }
 public static void ChangeMachineryInputByInputMultipliers(GeneralCapital1Input 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.RepairCost                = (machInput.RepairCost * multiplier * machInput.OCAmount);
     machInput.LaborCost                 = (machInput.LaborCost * multiplier * machInput.OCAmount);
     machInput.LaborAmount               = (machInput.LaborAmount * multiplier * machInput.OCAmount);
     machInput.CapitalRecoveryCost       = (machInput.CapitalRecoveryCost * multiplier * machInput.AOHAmount);
     machInput.TaxesHousingInsuranceCost = (machInput.TaxesHousingInsuranceCost * multiplier * machInput.AOHAmount);
     //this is ok for machinerystock analysis
     machInput.TotalOC  = machInput.FuelCost + machInput.RepairCost + machInput.LaborCost;
     machInput.TotalAOH = machInput.CapitalRecoveryCost + machInput.TaxesHousingInsuranceCost;
 }
Ejemplo n.º 6
0
 //copy constructors
 public void CopyGeneralCapital1InputProperties(CalculatorParameters calcParameters,
                                                GeneralCapital1Input 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);
     this.Capital1Constant = new Capital1Constant();
     this.Capital1Constant.CopyCapital1ConstantProperties(calculator.Capital1Constant);
     CopyGeneralCapital1InputProperties(calculator);
 }
Ejemplo n.º 7
0
        //add a GeneralCapital1Input to the baseStat.GenCapitalStocks dictionary
        public static bool AddGeneralCapital1StocksToDictionary(
            this GeneralCapital1Stock baseStat,
            int filePosition, int nodePosition, GeneralCapital1Input calculator)
        {
            bool bIsAdded = false;

            if (filePosition < 0 || nodePosition < 0)
            {
                baseStat.ErrorMessage
                    = Errors.MakeStandardErrorMsg("ANALYSES_INDEX_OUTOFBOUNDS");
                return(false);
            }
            if (baseStat.GenCapitalStocks == null)
            {
                baseStat.GenCapitalStocks
                    = new Dictionary <int, List <GeneralCapital1Input> >();
            }
            if (baseStat.GenCapitalStocks.ContainsKey(filePosition))
            {
                if (baseStat.GenCapitalStocks[filePosition] != null)
                {
                    for (int i = 0; i <= nodePosition; i++)
                    {
                        if (baseStat.GenCapitalStocks[filePosition].Count <= i)
                        {
                            baseStat.GenCapitalStocks[filePosition]
                            .Add(new GeneralCapital1Input());
                        }
                    }
                    baseStat.GenCapitalStocks[filePosition][nodePosition]
                             = calculator;
                    bIsAdded = true;
                }
            }
            else
            {
                //add the missing dictionary entry
                List <GeneralCapital1Input> baseStats
                    = new List <GeneralCapital1Input>();
                KeyValuePair <int, List <GeneralCapital1Input> > newStat
                    = new KeyValuePair <int, List <GeneralCapital1Input> >(
                          filePosition, baseStats);
                baseStat.GenCapitalStocks.Add(newStat);
                bIsAdded = AddGeneralCapital1StocksToDictionary(baseStat,
                                                                filePosition, nodePosition, calculator);
            }
            return(bIsAdded);
        }
 public static void AddGeneralCapital1InputTotals(GeneralCapital1Input machInput,
                                                  ref XElement machInputCalcElement)
 {
     //these have already been adjusted by input multipliers (ocamount, times)
     machInput.TotalOC = machInput.FuelCost + machInput.LaborCost
                         + machInput.RepairCost;
     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);
 }
Ejemplo n.º 9
0
        public static int GetNodePositionCount(this GeneralCapital1Stock baseStat,
                                               int filePosition, GeneralCapital1Input calculator)
        {
            int iNodeCount = 0;

            if (baseStat.GenCapitalStocks == null)
            {
                return(iNodeCount);
            }
            if (baseStat.GenCapitalStocks.ContainsKey(filePosition))
            {
                if (baseStat.GenCapitalStocks[filePosition] != null)
                {
                    iNodeCount = baseStat.GenCapitalStocks[filePosition].Count;
                }
            }
            return(iNodeCount);
        }
Ejemplo n.º 10
0
        public bool RunGeneralCapitalStockCalculations(GeneralCapital1Input machInput,
                                                       CalculatorParameters calcParameters)
        {
            bool bHasCalculations = false;

            //see if any db props are being changed by calculator
            TransferCorrespondingDbProperties(ref 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 = SetGeneralCapitalStockCalculations(multiplier,
                                                                      calcParameters, machInput);
            }
            else
            {
                bHasCalculations = true;
            }
            return(bHasCalculations);
        }
Ejemplo n.º 11
0
        public bool SetGeneralCapitalStockCalculations(double multiplier,
                                                       CalculatorParameters calcParameters, GeneralCapital1Input machInput)
        {
            bool bHasCalculations = false;

            if (machInput != null)
            {
                //don't adjust machinery per hour costs by any multiplier
                //pattern is fine but not appropriate here
                //in this extension, calculations are carried out in the
                //budget/investment calculators
                //BIGeneralCapitalStockCalculator biCalculator = new BIGeneralCapitalStockCalculator();
                //biCalculator.ChangeGeneralCapitalInputByMultiplier(machInput, multiplier);
                //bHasCalculations = true;
            }
            else
            {
                calcParameters.ErrorMessage = Errors.MakeStandardErrorMsg("CALCULATORS_WRONG_ONE");
            }
            return(bHasCalculations);
        }
Ejemplo n.º 12
0
 //copies the underlying input and locals props too
 public GeneralCapital1Input(CalculatorParameters calcParameters,
                             GeneralCapital1Input calculator)
 {
     CopyGeneralCapital1InputProperties(calcParameters, calculator);
 }
Ejemplo n.º 13
0
 //copy constructors
 public GeneralCapital1Input(GeneralCapital1Input calculator)
 {
     CopyGeneralCapital1InputProperties(calculator);
 }