예제 #1
0
        /// <summary>
        /// Constructor for a plain report variable.
        /// </summary>
        /// <param name="variableName">The name of the APSIM variable to retrieve</param>
        /// <param name="columnName">The column name to write to the output</param>
        /// <param name="frequenciesFromReport">Reporting frequencies</param>
        /// <param name="parentModel">The parent model</param>
        private ReportColumn(string variableName, string columnName, string[] frequenciesFromReport, IModel parentModel)
        {
            Values            = new List <object>();
            this.variableName = variableName;
            this.Name         = columnName;
            this.parentModel  = parentModel;
            this.reportingFrequencies.AddRange(frequenciesFromReport);
            this.clock = Apsim.Find(parentModel, typeof(Clock)) as Clock;

            try
            {
                IVariable var = Apsim.GetVariableObject(parentModel, variableName);
                if (var != null)
                {
                    Units = var.UnitsLabel;
                }
            }
            // Exceptions may arise when we are setting up at the start of simulation, since some of the other model
            // components might not be fully initialized. If that's the case, we just fail silently and don't
            // worry about determining units of measurement.
            catch (Exception) { }

            foreach (string frequency in this.reportingFrequencies)
            {
                Apsim.Subscribe(parentModel, frequency, this.OnReportFrequency);
            }
        }
예제 #2
0
        /// <summary>
        /// Constructor for a plain report variable.
        /// </summary>
        /// <param name="variableName">The name of the APSIM variable to retrieve</param>
        /// <param name="columnName">The column name to write to the output</param>
        /// <param name="frequenciesFromReport">Reporting frequencies</param>
        /// <param name="parentModel">The parent model</param>
        private ReportColumn(string variableName, string columnName, string[] frequenciesFromReport, IModel parentModel)
        {
            this.variableName = variableName;
            this.heading      = columnName;
            this.parentModel  = parentModel;
            this.reportingFrequencies.AddRange(frequenciesFromReport);
            this.clock = Apsim.Find(parentModel, typeof(Clock)) as Clock;

            foreach (string frequency in this.reportingFrequencies)
            {
                Apsim.Subscribe(parentModel, frequency, this.OnReportFrequency);
            }
        }
예제 #3
0
        /// <summary>
        /// Constructor for an aggregated column.
        /// </summary>
        /// <param name="aggregationFunction">The aggregation function</param>
        /// <param name="variableName">The name of the APSIM variable to retrieve</param>
        /// <param name="columnName">The column name to write to the output</param>
        /// <param name="from">The beginning of the capture window</param>
        /// <param name="to">The end of the capture window</param>
        /// <param name="frequenciesFromReport">Reporting frequencies</param>
        /// <param name="parentModel">The parent model</param>
        /// <returns>The newly created ReportColumn</returns>
        private ReportColumn(string aggregationFunction, string variableName, string columnName, string from, string to, string[] frequenciesFromReport, IModel parentModel)
        {
            Values = new List <object>();

            this.aggregationFunction = aggregationFunction;
            this.variableName        = variableName;
            this.Name            = columnName;
            this.parentModel     = parentModel;
            this.inCaptureWindow = false;
            this.reportingFrequencies.AddRange(frequenciesFromReport);
            this.clock = Apsim.Find(parentModel, typeof(Clock)) as Clock;

            try
            {
                IVariable var = Apsim.GetVariableObject(parentModel, variableName);
                if (var != null)
                {
                    Units = var.UnitsLabel;
                }
            }
            catch (Exception) { }

            Apsim.Subscribe(parentModel, "[Clock].StartOfDay", this.OnStartOfDay);
            Apsim.Subscribe(parentModel, "[Clock].DoReportCalculations", this.OnEndOfDay);

            if (DateTime.TryParse(from, out this.fromDate))
            {
                this.fromHasNoYear = !from.Contains(this.fromDate.Year.ToString());
            }
            else
            {
                Apsim.Subscribe(parentModel, from, this.OnBeginCapture);
            }

            if (DateTime.TryParse(to, out this.toDate))
            {
                this.toHasNoYear = !to.Contains(this.toDate.Year.ToString());
            }
            else
            {
                Apsim.Subscribe(parentModel, to, this.OnEndCapture);
            }

            foreach (string frequency in this.reportingFrequencies)
            {
                Apsim.Subscribe(parentModel, frequency, this.OnReportFrequency);
            }
        }
예제 #4
0
        /// <summary>
        /// Constructor for an aggregated column.
        /// </summary>
        /// <param name="aggregationFunction">The aggregation function</param>
        /// <param name="variableName">The name of the APSIM variable to retrieve</param>
        /// <param name="columnName">The column name to write to the output</param>
        /// <param name="from">The beginning of the capture window</param>
        /// <param name="to">The end of the capture window</param>
        /// <param name="frequenciesFromReport">Reporting frequencies</param>
        /// <param name="parentModel">The parent model</param>
        /// <returns>The newly created ReportColumn</returns>
        private ReportColumn(string aggregationFunction, string variableName, string columnName, string from, string to, string[] frequenciesFromReport, IModel parentModel)
        {
            this.aggregationFunction = aggregationFunction;
            this.variableName        = variableName;
            this.heading             = columnName;
            this.parentModel         = parentModel;
            this.inCaptureWindow     = false;
            this.reportingFrequencies.AddRange(frequenciesFromReport);
            this.clock = Apsim.Find(parentModel, typeof(Clock)) as Clock;

            Apsim.Subscribe(parentModel, "[Clock].StartOfDay", this.OnStartOfDay);
            Apsim.Subscribe(parentModel, "[Clock].DoReportCalculations", this.OnEndOfDay);

            if (DateTime.TryParse(from, out this.fromDate))
            {
                this.fromHasNoYear = !from.Contains(this.fromDate.Year.ToString());
            }
            else
            {
                Apsim.Subscribe(parentModel, from, this.OnBeginCapture);
            }

            if (DateTime.TryParse(to, out this.toDate))
            {
                this.toHasNoYear = !to.Contains(this.toDate.Year.ToString());
            }
            else
            {
                Apsim.Subscribe(parentModel, to, this.OnEndCapture);
            }

            foreach (string frequency in this.reportingFrequencies)
            {
                Apsim.Subscribe(parentModel, frequency, this.OnReportFrequency);
            }
        }