public static double GetInputFullCostMultiplier(FNSR01Calculator foodNutritionInput,
                                                        CalculatorParameters calcParams)
        {
            //to keep all food nutrition stock analysis consistent, put the totals
            //in the inputs, then all can be compared consistently
            //input.times
            double dbInputMultiplier = IOFNStockSubscriber
                                       .GetMultiplierForTechInput(foodNutritionInput);
            //oc.amount
            double dbOCMultiplier = OCFNStockSubscriber
                                    .GetMultiplierForOperation(calcParams.ParentOperationComponent);
            double dbTPAmount = BIFNStockSubscriber.GetMultiplierForTimePeriod(
                calcParams.ParentTimePeriod);
            double dbMultiplier = dbInputMultiplier * dbOCMultiplier * dbTPAmount;

            return(dbMultiplier);
        }
Exemplo n.º 2
0
        public bool RunCalculations()
        {
            bool bHasCalculations = false;

            //these calculators use a mix of calculator and analyzer patterns
            this.FNCalculatorParams.RunCalculatorType
                = CalculatorHelpers.RUN_CALCULATOR_TYPES.iotechnology;
            //urisToAnalyze has the summary calculated results path in position 0.
            //This calculator uses that path to derive the the full calculated
            //results path. The full path document is used to run the calculations
            //(it has the input and output calculated results that are
            //the basis for most resource stock calculations).
            this.FNCalculatorParams.AnalyzerParms.ObservationsPath
                = CalculatorHelpers.GetFullCalculatorResultsPath(
                      this.FNCalculatorParams);
            if (!CalculatorHelpers.URIAbsoluteExists(this.FNCalculatorParams.ExtensionDocToCalcURI,
                                                     this.FNCalculatorParams.AnalyzerParms.ObservationsPath))
            {
                this.FNCalculatorParams.ErrorMessage
                    = Errors.MakeStandardErrorMsg("ANALYZER_BASECALCS_MISSING");
                return(false);
            }
            if (this.FNCalculatorParams.CalculatorType
                == CalculatorHelpers.CALCULATOR_TYPES.input.ToString() ||
                this.FNCalculatorParams.CalculatorType
                == CALCULATOR_TYPES.foodfactUSA1.ToString() ||
                this.FNCalculatorParams.CalculatorType
                == CALCULATOR_TYPES.foodnutSR01.ToString())
            {
                this.FNCalculatorParams.RunCalculatorType
                    = CalculatorHelpers.RUN_CALCULATOR_TYPES.basic;
                if (this.FNCalculatorParams.RelatedCalculatorType
                    == CALCULATOR_TYPES.foodfactUSA1.ToString() ||
                    this.FNCalculatorParams.RelatedCalculatorType
                    == CALCULATOR_TYPES.foodnutSR01.ToString())
                {
                    IOFNStockSubscriber subInput
                        = new IOFNStockSubscriber(this.FNCalculatorParams);
                    bHasCalculations = subInput.RunCalculator();
                    CalculatorHelpers.UpdateCalculatorParams(this.FNCalculatorParams, subInput.GCCalculatorParams);
                    subInput = null;
                }
            }
            else if (this.FNCalculatorParams.CalculatorType
                     == CalculatorHelpers.CALCULATOR_TYPES.operation.ToString() ||
                     this.FNCalculatorParams.CalculatorType
                     == CalculatorHelpers.CALCULATOR_TYPES.component.ToString())
            {
                if (this.FNCalculatorParams.RelatedCalculatorType != string.Empty &&
                    this.FNCalculatorParams.RelatedCalculatorType
                    != Constants.NONE)
                {
                    if (this.FNCalculatorParams.RelatedCalculatorType
                        == CALCULATOR_TYPES.foodfactUSA1.ToString() ||
                        this.FNCalculatorParams.RelatedCalculatorType
                        == CALCULATOR_TYPES.foodnutSR01.ToString())
                    {
                        OCFNStockSubscriber subOperation
                            = new OCFNStockSubscriber(this.FNCalculatorParams);
                        bHasCalculations = subOperation.RunCalculator();
                        CalculatorHelpers.UpdateCalculatorParams(this.FNCalculatorParams, subOperation.GCCalculatorParams);
                        subOperation = null;
                    }
                }
            }
            else if (this.FNCalculatorParams.CalculatorType
                     == CalculatorHelpers.CALCULATOR_TYPES.budget.ToString() ||
                     this.FNCalculatorParams.CalculatorType
                     == CalculatorHelpers.CALCULATOR_TYPES.investment.ToString())
            {
                if (this.FNCalculatorParams.RelatedCalculatorType
                    == CALCULATOR_TYPES.foodfactUSA1.ToString() ||
                    this.FNCalculatorParams.RelatedCalculatorType
                    == CALCULATOR_TYPES.foodnutSR01.ToString())
                {
                    BIFNStockSubscriber subBudget
                        = new BIFNStockSubscriber(this.FNCalculatorParams);
                    bHasCalculations = subBudget.RunCalculator();
                    CalculatorHelpers.UpdateCalculatorParams(this.FNCalculatorParams, subBudget.GCCalculatorParams);
                    subBudget = null;
                }
            }
            //stylesheet set in analyzerhelper
            return(bHasCalculations);
        }