Example #1
0
        private void OnSimulationCommencing(object sender, EventArgs e)
        {
            Items = new List <LabourType>();
            foreach (LabourType labourChildModel in Apsim.Children(this, typeof(LabourType)).Cast <LabourType>().ToList())
            {
                for (int i = 0; i < labourChildModel.Individuals; i++)
                {
                    // get the availability from provided list

                    LabourType labour = new LabourType()
                    {
                        Gender             = labourChildModel.Gender,
                        Individuals        = 1,
                        InitialAge         = labourChildModel.InitialAge,
                        AgeInMonths        = labourChildModel.InitialAge * 12,
                        LabourAvailability = labourChildModel.LabourAvailability,
                        Parent             = this,
                        Name  = labourChildModel.Name + ((labourChildModel.Individuals > 1)?"_" + (i + 1).ToString():""),
                        Hired = labourChildModel.Hired
                    };
                    labour.TransactionOccurred += Resource_TransactionOccurred;
                    Items.Add(labour);
                }
            }
            // clone pricelist so model can modify if needed and not affect initial parameterisation
            if (Apsim.Children(this, typeof(LabourPricing)).Count() > 0)
            {
                PayList = (Apsim.Children(this, typeof(LabourPricing)).FirstOrDefault() as LabourPricing).Clone();
            }
        }
Example #2
0
        private void OnSimulationCommencing(object sender, EventArgs e)
        {
            // locate AE relationship
            adultEquivalentRelationship = this.FindAllChildren <Relationship>().FirstOrDefault(a => a.Name.ToUpper().Contains("AE"));

            Items = new List <LabourType>();
            foreach (LabourType labourChildModel in this.FindAllChildren <LabourType>().Cast <LabourType>().ToList())
            {
                for (int i = 0; i < labourChildModel.Individuals; i++)
                {
                    // get the availability from provided list

                    LabourType labour = new LabourType()
                    {
                        Gender             = labourChildModel.Gender,
                        Individuals        = 1,
                        Parent             = this,
                        InitialAge         = labourChildModel.InitialAge,
                        AgeInMonths        = labourChildModel.InitialAge * 12,
                        LabourAvailability = labourChildModel.LabourAvailability,
                        Name  = labourChildModel.Name + ((labourChildModel.Individuals > 1) ? "_" + (i + 1).ToString() : ""),
                        Hired = labourChildModel.Hired
                    };
                    labour.TransactionOccurred += Resource_TransactionOccurred;
                    Items.Add(labour);
                }
            }
            // clone pricelist so model can modify if needed and not affect initial parameterisation
            if (this.FindAllChildren <LabourPricing>().Count() > 0)
            {
                PayList = Apsim.Clone(this.FindAllChildren <LabourPricing>().FirstOrDefault()) as LabourPricing;
            }
        }
Example #3
0
        /// <summary>
        /// Create a copy of the current instance
        /// </summary>
        /// <returns></returns>
        public LabourPricing Clone()
        {
            LabourPricing clone = new LabourPricing();

            foreach (LabourPriceGroup item in this.Children.OfType <LabourPriceGroup>())
            {
                clone.Children.Add(item.Clone());
            }
            return(clone);
        }