Пример #1
0
 //copy constructor
 public OperationComponent(CalculatorParameters calcParameters,
                           OperationComponent operationorcomponent)
 {
     //several extensions store some calculator props in base element (observations, targettype)
     //no harm done in setting them but never set their attributes
     this.CopyCalculatorProperties(operationorcomponent);
     this.CopySharedObjectProperties(operationorcomponent);
     this.Amount          = operationorcomponent.Amount;
     this.Unit            = operationorcomponent.Unit;
     this.Weight          = operationorcomponent.Weight;
     this.EffectiveLife   = operationorcomponent.EffectiveLife;
     this.SalvageValue    = operationorcomponent.SalvageValue;
     this.IncentiveAmount = operationorcomponent.IncentiveAmount;
     this.IncentiveRate   = operationorcomponent.IncentiveRate;
     this.TimePeriodId    = operationorcomponent.TimePeriodId;
     this.Type            = operationorcomponent.Type;
     this.ErrorMessage    = operationorcomponent.ErrorMessage;
     this.AnnuityType     = operationorcomponent.AnnuityType;
     this.AnnuityCount    = operationorcomponent.AnnuityCount;
     //better to set in base
     this.CopyTotalCostsProperties(operationorcomponent);
     //calculators are always app-specific and must be copied subsequently
     this.Calculators = new List <Calculator1>();
     if (operationorcomponent.Local == null)
     {
         operationorcomponent.Local = new Local();
     }
     this.Local = new Local(calcParameters, operationorcomponent.Local);
     if (operationorcomponent.XmlDocElement != null)
     {
         this.XmlDocElement = new XElement(operationorcomponent.XmlDocElement);
     }
 }
Пример #2
0
        private void AddNewOCToCollection(OperationComponent opComp, List <OperationComponent> ocs)
        {
            OperationComponent oc = new OperationComponent(this.GCCalculatorParams, opComp);

            oc.Calculators = new List <Calculator1>();
            if (opComp.Calculators != null)
            {
                ME2AnalyzerHelper.CopyStockCalculator(this.GCCalculatorParams, opComp.Calculators, oc.Calculators);
            }
            oc.Inputs = new List <Extensions.Input>();
            if (opComp.Inputs != null)
            {
                foreach (Input input in opComp.Inputs)
                {
                    Input i = new Input(input);
                    i.Calculators = new List <Calculator1>();
                    if (input.Calculators != null)
                    {
                        ME2AnalyzerHelper.CopyStockCalculator(this.GCCalculatorParams, input.Calculators, i.Calculators);
                    }
                    oc.Inputs.Add(i);
                }
            }
            ocs.Add(oc);
        }
Пример #3
0
 private static void SerializeChildrenInputs(OperationComponent opComp,
     CalculatorParameters calcParameters, XElement currentCalculator,
     ref XElement opCompEl, IDictionary<string, string> updates)
 {
     //serialize and add children inputs to operationEl
     if (opComp.Inputs != null)
     {
         foreach (Input input in opComp.Inputs)
         {
             XElement inputEl = null;
             if (calcParameters.SubApplicationType == Constants.SUBAPPLICATION_TYPES.budgets)
             {
                 inputEl
                 = new XElement(BudgetInvestment.BUDGET_TYPES.budgetinput.ToString());
             }
             else if (calcParameters.SubApplicationType == Constants.SUBAPPLICATION_TYPES.investments)
             {
                 inputEl
                 = new XElement(BudgetInvestment.INVESTMENT_TYPES.investmentinput.ToString());
             }
             input.SetSharedObjectAttributes(string.Empty, ref inputEl);
             input.SetNewInputAttributes(calcParameters, ref inputEl);
             input.SetTotalCostsAttributes(string.Empty, ref inputEl);
             opCompEl.Add(inputEl);
         }
     }
 }
Пример #4
0
        public bool SetOpOrCompMachineryStockCalculations(ref XElement currentCalculationsElement,
                                                          ref XElement currentElement)
        {
            bool bHasCalculations = false;

            //set the parent tp for holding collection of opcomps
            if (this.TimePeriod == null)
            {
                this.TimePeriod = new TimePeriod();
            }
            if (this.OpComp == null)
            {
                this.OpComp = new OperationComponent();
            }
            //note that the machinput calculator can not change Operation properties
            //but needs several properties from the Operation (i.e. Id, Amount)
            this.OpComp.SetOperationComponentProperties(this.GCCalculatorParams,
                                                        currentCalculationsElement, currentElement);
            //init machStock props
            this.MachineryStock.SetCalculatorProperties(currentCalculationsElement);
            //oc.amount was multiplied in the inputs
            double dbMultiplier = 1;

            //the machStock.machstocks dictionary can now be summed to derive totals
            bHasCalculations = SetTotalMachineryStockCalculations(dbMultiplier, currentElement.Name.LocalName);
            //serialize calculator object back to xml
            //(calculator doesn't change opOrComp, so don't serialize it)
            string sAttNameExtension = string.Empty;

            //set new machinery stock totals
            this.MachineryStock.SetAndRemoveCalculatorAttributes(sAttNameExtension,
                                                                 ref currentCalculationsElement);
            this.MachineryStock.SetTotalMachinery1StockAttributes(sAttNameExtension,
                                                                  ref currentCalculationsElement);
            this.MachineryStock.SetTotalMachinery1ConstantAttributes(sAttNameExtension,
                                                                     ref currentCalculationsElement);
            //set the totaloc and totalaoh
            AddMachineryStockTotals(this.MachineryStock, ref currentCalculationsElement);
            //set calculatorid (primary way to display calculation attributes)
            CalculatorHelpers.SetCalculatorId(
                currentCalculationsElement, currentElement);
            //reset machstock totals to zero (for next opOrComp)
            this.MachineryStock.InitTotalMachinery1StockProperties();
            this.MachineryStock.InitTotalMachinery1ConstantProperties();
            //reset machStock.machstocks fileposition index
            //next opOrComp's machstock will be inserted in next index
            this.GCCalculatorParams.AnalyzerParms.FilePositionIndex += 1;
            //add to collection
            if (this.TimePeriod.OperationComponents == null)
            {
                this.TimePeriod.OperationComponents = new List <OperationComponent>();
            }
            this.TimePeriod.OperationComponents.Add(this.OpComp);
            //reset for next collection
            this.OpComp = null;
            return(bHasCalculations);
        }
Пример #5
0
        public static double GetMultiplierForOperation(OperationComponent opComp)
        {
            //ops, comps, budgets and investments use the times multiplier
            double multiplier = 1;

            if (opComp != null)
            {
                multiplier = opComp.Amount;
                if (multiplier == 0)
                {
                    multiplier = 1;
                }
            }
            return(multiplier);
        }
        public static double GetMultiplierForOperation(OperationComponent opComp)
        {
            //this subscriber does not use these multipliers
            double multiplier = 1;

            if (opComp != null)
            {
                multiplier = opComp.Amount;
                if (multiplier == 0)
                {
                    multiplier = 1;
                }
            }
            return(multiplier);
        }
Пример #7
0
        public bool SetInputMachineryStockCalculations(ref XElement currentCalculationsElement,
                                                       ref XElement currentElement)
        {
            bool bHasCalculations = false;

            //set the parent opcomp for holding collection of machinputs
            if (this.OpComp == null)
            {
                this.OpComp = new OperationComponent();
            }
            if (currentCalculationsElement != null)
            {
                //note that the machinput calculator can not change Input properties
                //when running from opOrComps or budgets
                //but needs several properties from the Input (i.e. Id, Times)
                this.Mach1Input = new Machinery1Input();
                //deserialize xml to object
                this.Mach1Input.SetMachinery1InputProperties(this.GCCalculatorParams,
                                                             currentCalculationsElement, currentElement);
                //init analyzer props
                this.MachineryStock.SetCalculatorProperties(currentCalculationsElement);
                //all stocks analyzers put full costs in inputs (easier to manipulate collections)
                double dbMultiplier = GetInputFullCostMultiplier(this.Mach1Input, this.GCCalculatorParams);
                //change fuel cost, repair cost, by input.times * input.ocamount or input.aohamount
                ChangeMachineryInputByInputMultipliers(this.Mach1Input, dbMultiplier);
                //serialize calculator object back to xml
                //(calculator doesn't change opOrComp, so don't serialize it)
                string sAttNameExtension = string.Empty;
                //set new machinery input totals
                this.Mach1Input.SetAndRemoveCalculatorAttributes(sAttNameExtension,
                                                                 ref currentCalculationsElement);
                this.Mach1Input.SetMachinery1InputAttributes(this.GCCalculatorParams,
                                                             ref currentCalculationsElement, ref currentElement);
                //set the totaloc and totalaoh
                AddMachinery1InputTotals(this.Mach1Input, ref currentCalculationsElement);
                //163: this.Mach1Input is sometimes used to build feasible input combos and needs input name when serialized
                if (this.Mach1Input.Name == string.Empty)
                {
                    string sInputName = CalculatorHelpers.GetAttribute(currentElement, Calculator1.cName);
                    this.Mach1Input.Name = sInputName;
                }
                //set calculatorid (primary way to display calculation attributes)
                CalculatorHelpers.SetCalculatorId(
                    currentCalculationsElement, currentElement);
                //add the machinput 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 = this.MachineryStock.GetNodePositionCount(
                    this.GCCalculatorParams.AnalyzerParms.FilePositionIndex, this.Mach1Input);
                if (iNodePosition < 0)
                {
                    iNodePosition = 0;
                }
                bHasCalculations = this.MachineryStock
                                   .AddMachinery1StocksToDictionary(
                    this.GCCalculatorParams.AnalyzerParms.FilePositionIndex, iNodePosition,
                    this.Mach1Input);
                //add to collection
                if (this.OpComp.Inputs == null)
                {
                    this.OpComp.Inputs = new List <Input>();
                }
                //note that machinput can be retrieved by converting the input to the
                //Machinery1Input type (machinput = (Machinery1Input) input)
                if (this.Mach1Input != null)
                {
                    this.OpComp.Inputs.Add(this.Mach1Input);
                }
                bHasCalculations = true;
            }
            return(bHasCalculations);
        }