Exemple #1
0
        // ==============================================================================================
        protected override void ResetLimit(double NewLimit)
        {
            // check of NewLimit is larger or smaller
            //
            // edits 01.07.21 das - for Desal. IF not using piped desal no new limit is created
            if (NewLimit > FValue)
            {
                // OK, need to adjust each flux so original new allocated values stays the same as old
                // Set Allocation will adjust the Allocated value of flux based on method of allocation being used
                // get the oldvalues
                List <double> OldValues = new List <double>();
                foreach (CRF_Flux Flux in ToFluxs) //FFluxList)
                {
                    OldValues.Add(Flux.Allocated());
                }
                // set the new limit
                FValue = NewLimit;

                // loop through the fluxes and set values
                int index = 0;
                foreach (CRF_Flux Flux in ToFluxs) //FFluxList)
                {
                    // Check if a flux transfer is allowed, base CRF Resource should say no unless their is a need
                    // if not, then reset value to old value
                    if (!CRF_Utility.AllowFluxChange(this, Flux.Target))
                    {
                        Flux.SetAllocation(OldValues[index]);
                        index++;
                    }
                }
            }
            else
            {
                if (NewLimit == FValue)
                {
                }
                else
                {
                    // set the new limit
                    FValue = NewLimit;
                    List <double> OldValues = new List <double>();
                    List <double> NewValues = new List <double>();
                    foreach (CRF_Flux Flux in ToFluxs) //FFluxList)
                    {
                        if (Flux.Source.Label == "COL")
                        {
                            OldValues.Add(Flux.Allocated());
                            //if(OldValues)
                            Flux.SetAllocation(FValue);
                            NewValues.Add(Flux.Allocated());
                        }
                        ;
                        // NewValues.Add(Flux.Allocated());
                    }

                    // loop through the fluxes and set values
                    int index = 0;
                    foreach (CRF_Flux Flux in ToFluxs) //FFluxList)
                    {
                        // Check if a flux transfer is allowed, base CRF Resource should say no unless their is a need
                        // if not, then reset value to old value
                        if (!CRF_Utility.AllowFluxChange(this, Flux.Target))
                        {
                            //Flux.SetAllocation(OldValues[index]);
                            Flux.SetAllocation(NewValues[index]);
                            index++;
                        }
                    }
                }
                //bool stop = true;
            }

            // ok just do it if less everyone lives with consequences, if ratio not reset, they get alot more
            FValue = NewLimit;


            //
        }