Beispiel #1
0
        /// <summary>
        /// Constructs the Native Pasture model
        /// </summary>
        public IEnumerable <CropActivityManageCrop> GetNativePasture(ActivityFolder forages)
        {
            List <CropActivityManageCrop> pastures = new List <CropActivityManageCrop>();

            // Check if there are native pasture feeds before proceeding
            var feed_type = RumSpecs.GetRowData <int>(28);
            var feeds     = from breed in feed_type
                            where RumIDs.Contains(feed_type.IndexOf(breed))
                            where breed > 1
                            select breed;

            if (feeds.Count() == 0)
            {
                return(null);
            }

            CropActivityManageCrop farm = new CropActivityManageCrop(forages)
            {
                LandItemNameToUse = "Land",
                UseAreaAvailable  = true,
                Name = "NativePastureFarm"
            };

            farm.Add(new CropActivityManageProduct(farm)
            {
                ModelNameFileCrop = "FileForage",
                CropName          = "Native_grass",
                StoreItemName     = "AnimalFoodStore.NativePasture",
                Name = "Cut and carry Native Pasture"
            });

            CropActivityManageCrop common = new CropActivityManageCrop(forages)
            {
                LandItemNameToUse = "Land",
                Name = "Native Pasture Common Land"
            };

            common.Add(new CropActivityManageProduct(common)
            {
                ModelNameFileCrop = "FileForage",
                CropName          = "Native_grass",
                StoreItemName     = "GrazeFoodStore.NativePasture",
                Name = "Grazed Common Land"
            });

            pastures.Add(farm);
            pastures.Add(common);
            return(pastures.AsEnumerable());
        }
Beispiel #2
0
        /// <summary>
        /// Constructs the Manage Forages model
        /// </summary>
        /// <param name="iat">The IAT file to access data from</param>
        public IEnumerable <CropActivityManageCrop> GetManageForages(ActivityFolder forages)
        {
            List <CropActivityManageCrop> manage = new List <CropActivityManageCrop>();

            int col = 0;
            // Check present forages
            var list = ForagesGrown.GetRowData <double>(0);

            foreach (var item in list)
            {
                if (item == 0)
                {
                    continue;
                }

                double area = ForagesGrown.GetData <double>(2, col);
                if (area > 0)
                {
                    int    num  = ForagesGrown.GetData <int>(1, col);
                    int    row  = ForagesGrown.GetData <int>(0, col);
                    string name = ForageSpecs.RowNames[row + 1];

                    CropActivityManageCrop crop = new CropActivityManageCrop(forages)
                    {
                        Name = "Manage " + name,
                        LandItemNameToUse = "Land." + LandSpecs.RowNames[num],
                        AreaRequested     = ForagesGrown.GetData <double>(2, col)
                    };

                    crop.Add(new CropActivityManageProduct(crop)
                    {
                        Name = "Cut and carry " + name,
                        ModelNameFileCrop = "FileForage",
                        CropName          = name,
                        StoreItemName     = "AnimalFoodStore"
                    });

                    manage.Add(crop);
                }
                col++;
            }

            return(manage.AsEnumerable());
        }
Beispiel #3
0
        /// <summary>
        /// Finds all crops in the source IAT which require management
        /// </summary>
        public IEnumerable <CropActivityManageCrop> GetManageCrops(ActivityFolder manage)
        {
            List <CropActivityManageCrop> crops = new List <CropActivityManageCrop>();

            int[] ids = CropsGrown.GetRowData <int>(0).ToArray();

            // Find the name of the crop in the file
            Sheet         sheet  = SearchSheets("crop_inputs");
            WorksheetPart inputs = (WorksheetPart)Book.GetPartById(sheet.Id);

            // Find the name of the crop
            int rows = sheet.Elements <Row>().Count();

            foreach (int id in GrainIDs)
            {
                string name = "Unknown";
                int    row  = 1;

                while (row < rows)
                {
                    if (GetCellValue(inputs, row, 3) == id.ToString())
                    {
                        name = GetCellValue(inputs, row, 4);
                        break;
                    }
                    row++;
                }

                // Find which column holds the data for a given crop ID
                int col = Array.IndexOf(ids, id);

                // Find names
                int    land     = CropsGrown.GetData <int>(1, col);
                string cropname = CropSpecs.RowNames[id + 1];

                // Model the crop management
                CropActivityManageCrop crop = new CropActivityManageCrop(manage)
                {
                    Name = "Manage " + cropname,
                    LandItemNameToUse = LandSpecs.RowNames[land - 1],
                    AreaRequested     = CropsGrown.GetData <double>(2, col)
                };

                // Find the storage pool which the crop uses
                string pool = Pools.Values.ToList().Find(s => s.Contains(cropname));

                // Add the product management model
                crop.Add(new CropActivityManageProduct(crop)
                {
                    Name = "Manage grain",
                    ModelNameFileCrop = "FileCrop",
                    CropName          = name,
                    ProportionKept    = 1.0 - CropsGrown.GetData <double>(5, col) / 100.0,
                    StoreItemName     = "HumanFoodStore." + pool
                });

                // Add the residue management
                crop.Add(new CropActivityManageProduct(crop)
                {
                    Name = "Manage residue",
                    ModelNameFileCrop = "FileCropResidue",
                    CropName          = name,
                    ProportionKept    = CropsGrown.GetData <double>(4, col) / 100.0,
                    StoreItemName     = "AnimalFoodStore." + pool
                });

                crops.Add(crop);
            }
            return(crops);
        }
Beispiel #4
0
 public CropActivityManageProduct(CropActivityManageCrop parent) : base(parent)
 {
 }