Beispiel #1
0
 // -----------------------------------------------------------------------
 /// <summary>
 /// Write a message to the summary stream.
 /// </summary>
 /// <param name="msg"></param>
 // -----------------------------------------------------------------------
 public void write(String msg)
 {
     if (!haveWrittenToStdOutToday)
     {
         if (tick.startday != 0)
         {
             TTimeValue gDate = new TTimeValue(tick.startday, (uint)tick.startsec, tick.startsecpart);
             Console.WriteLine("(Day of year=" + gDate.dayOfYear() + ")" + ", ");
         }
         Console.WriteLine(getName() + ": ");
         haveWrittenToStdOutToday = true;
     }
     Console.WriteLine("     " + msg);
 }
Beispiel #2
0
 /// <summary>
 /// Set the internal Value from the DDMLValue that was set in the unpack()
 /// </summary>
 private void setVariableValue()
 {
     if (tType == typeof(Boolean))
     {
         Value = (T)(Convert.ChangeType(DDMLValue.asBool(), typeof(T)));
     }
     else if (tType == typeof(Int32))
     {
         Value = (T)(Convert.ChangeType(DDMLValue.asInt(), typeof(T)));
     }
     else if (tType == typeof(Single))
     {
         Value = (T)(Convert.ChangeType(DDMLValue.asSingle(), typeof(T)));
     }
     else if (tType == typeof(double))
     {
         Value = (T)(Convert.ChangeType(DDMLValue.asDouble(), typeof(T)));
     }
     else if (tType == typeof(String))
     {
         Value = (T)(Convert.ChangeType(DDMLValue.asStr(), typeof(T)));
     }
     else if (tType == typeof(Boolean[]))
     {
         Value = (T)(Convert.ChangeType(DDMLValue.asBooleanArray(), typeof(T)));
     }
     else if (tType == typeof(Int32[]))
     {
         Value = (T)(Convert.ChangeType(DDMLValue.asIntArray(), typeof(T)));
     }
     else if (tType == typeof(Single[]))
     {
         Value = (T)(Convert.ChangeType(DDMLValue.asSingleArray(), typeof(T)));
     }
     else if (tType == typeof(double[]))
     {
         Value = (T)(Convert.ChangeType(DDMLValue.asDoubleArray(), typeof(T)));
     }
     else if (tType == typeof(String[]))
     {
         Value = (T)(Convert.ChangeType(DDMLValue.asStringArray(), typeof(T)));
     }
     else if (tType == typeof(DateTime))
     {
         double   JulianDate = DDMLValue.asDouble();             //stored as a double
         DateTime jDate      = TTimeValue.JDToDateTime(JulianDate);
         Value = (T)(Convert.ChangeType(jDate, typeof(T)));
     }
 }
        //============================================================================
        /// <summary>
        ///
        /// </summary>
        //============================================================================
        public TGenericReporter()
        {
            FOutputs      = new List <TMainOutputSpecifier>();
            FRequestNames = new List <string>();
            FRequests     = new List <TDDMLValue>();
            FColumns      = new List <TOutputScalar>();

            FCurrOutputTime = new TTimeValue();                                 //Start of current reporting interval
            FNextOutputTime = new TTimeValue();                                 //Start of next reporting interval

            FReportInterval = 1;
            FIntervalUnit   = TTimeValue.DAY;
            FWriting        = false;
            FFirstTime      = true;
            FTitle          = new String(' ', 0);
            ApsimFMT        = false;
        }
 //==============================================================================
 /// <summary>
 ///
 /// </summary>
 /// <param name="currTime"></param>
 //==============================================================================
 public void writeVariables(TTimeValue currTime)
 {
     if (FCurrOutputTime.getDay() == 0)   //First time
     {
         FCurrOutputTime.Set(currTime);
         FNextOutputTime.Set(FCurrOutputTime);
         FNextOutputTime.advTime(ReportInterval, IntervalUnit);
     }
     else
     {
         if (FNextOutputTime <= currTime)   //Store outputs from previous period
         {
             writeValues();
             FCurrOutputTime.Set(currTime);
             FNextOutputTime.Set(FCurrOutputTime);
             FNextOutputTime.advTime(ReportInterval, IntervalUnit);
         }
     }
     aggregateValues();
 }