示例#1
0
        /// <summary>
        /// Method to collect manure from uncollected manure stores
        /// Manure is collected from freshest to oldest
        /// </summary>
        /// <param name="storeName">Name of store to add manure to</param>
        /// <param name="resourceLimiter">Reduction due to limited resources</param>
        /// <param name="activity">Name of activity performing collection</param>
        public void Collect(string storeName, double resourceLimiter, CLEMModel activity)
        {
            ManureStoreUncollected store = UncollectedStores.Where(a => a.Name.ToLower() == storeName.ToLower()).FirstOrDefault();

            if (store != null)
            {
                double limiter        = Math.Max(Math.Min(resourceLimiter, 1.0), 0);
                double amountPossible = store.Pools.Sum(a => a.Amount) * limiter;
                double amountMoved    = 0;

                while (store.Pools.Count > 0 && amountMoved < amountPossible)
                {
                    // take needed
                    double take = Math.Min(amountPossible - amountMoved, store.Pools[0].Amount);
                    amountMoved           += take;
                    store.Pools[0].Amount -= take;
                    // if 0 delete
                    store.Pools.RemoveAll(a => a.Amount == 0);
                }
                this.Add(amountMoved, activity, this.NameWithParent, ((storeName == "")?"General":storeName));
            }
        }
示例#2
0
        /// <summary>
        /// Method to add uncollected manure to stores
        /// </summary>
        /// <param name="storeName">Name of store to add manure to</param>
        /// <param name="amount">Amount (dry weight) of manure to add</param>
        public void AddUncollectedManure(string storeName, double amount)
        {
            ManureStoreUncollected store = UncollectedStores.Where(a => a.Name.ToLower() == storeName.ToLower()).FirstOrDefault();

            if (store == null)
            {
                store = new ManureStoreUncollected()
                {
                    Name = storeName
                };
                UncollectedStores.Add(store);
            }
            ManurePool pool = store.Pools.Where(a => a.Age == 0).FirstOrDefault();

            if (pool == null)
            {
                pool = new ManurePool()
                {
                    Age = 0, ProportionMoisture = ProportionMoistureFresh
                };
                store.Pools.Add(pool);
            }
            pool.Amount += amount;
        }