public void Status()
 {
     Assert.AreEqual(LinkableComponentStatus.Initialized, riverModelLC.Status);
     riverModelLC.Update();
     Assert.AreEqual(LinkableComponentStatus.Updated, riverModelLC.Status);
 }
Beispiel #2
0
        public override IValueSet GetValues(IExchangeItem querySpecifier)
        {
            if (querySpecifier.TimeSet == null || querySpecifier.TimeSet.Times == null ||
                querySpecifier.TimeSet.Times.Count == 0)
            {
                throw new Exception("Invalid query specifier \"" + querySpecifier.Id +
                                    "\" for in GetValues() call to time decorater " + Id);
            }
            if (ParentOutput.TimeSet == null || ParentOutput.TimeSet.Times == null)
            {
                throw new Exception("Invalid time specifier in decorated output item \"" + ParentOutput.Id +
                                    "\" for in GetValues() call to time decorater " + Id);
            }

            // Determinee query time and currently available time
            double queryTimeAsMJD =
                querySpecifier.TimeSet.Times[querySpecifier.TimeSet.Times.Count - 1].StampAsModifiedJulianDay +
                querySpecifier.TimeSet.Times[querySpecifier.TimeSet.Times.Count - 1].DurationInDays;
            double        availableTimeAsMJD       = Double.NegativeInfinity;
            IList <ITime> decoratedOutputItemTimes = ParentOutput.TimeSet.Times;

            if (decoratedOutputItemTimes.Count > 0)
            {
                availableTimeAsMJD =
                    decoratedOutputItemTimes[decoratedOutputItemTimes.Count - 1].StampAsModifiedJulianDay +
                    decoratedOutputItemTimes[decoratedOutputItemTimes.Count - 1].DurationInDays;
            }

            // Update as far as needed.
            ILinkableComponent linkableComponent = ParentOutput.Component;

            while ((linkableComponent.Status == LinkableComponentStatus.Valid ||
                    linkableComponent.Status == LinkableComponentStatus.Updated) &&
                   availableTimeAsMJD < queryTimeAsMJD)
            {
                linkableComponent.Update();
                // Determine newly available time
                decoratedOutputItemTimes = ParentOutput.TimeSet.Times;
                availableTimeAsMJD       =
                    decoratedOutputItemTimes[decoratedOutputItemTimes.Count - 1].StampAsModifiedJulianDay +
                    decoratedOutputItemTimes[decoratedOutputItemTimes.Count - 1].DurationInDays;
            }

            // Return the values for the required time(s)
            IList <IList <double> > resultValues = new List <IList <double> >();

            if (querySpecifier.TimeSet != null && querySpecifier.TimeSet.Times != null)
            {
                for (int t = 0; t < querySpecifier.TimeSet.Times.Count; t++)
                {
                    resultValues.Add(new List <double>());
                    ITime         queryTime         = querySpecifier.TimeSet.Times[t];
                    List <double> valuesForTimeStep = _buffer.GetValues(queryTime);
                    foreach (double d in valuesForTimeStep)
                    {
                        resultValues[t].Add(d);
                    }
                }
            }
            return(new ValueSet <double>(resultValues));
        }