示例#1
0
        override public bool UpdateRequired(ITimeSet request, ITimeSet current)
        {
            if (Values == null || ValueSet.GetElementCount(Values) * ValueSet.GetTimesCount(Values) != 1)
            {
                return(true);
            }

            ValidTimeSet(request);
            ValidTimeSet(current);

            double dRequest = request.Times[0].StampAsModifiedJulianDay;
            double dCurrent = current.Times[0].StampAsModifiedJulianDay;

            if (Math.Abs(dCurrent - dRequest) <= _timeTolerance)
            {
                return(false); // Equal within tolerance
            }
            // TODO Could check cache and just throw if cache inadequate

            if (dRequest < dCurrent)
            {
                throw new InvalidOperationException("Earlier time request");
            }

            return(true);
        }
示例#2
0
        public void Polygon2PointAdaptedOutputGetValues2Consumers()
        {
            Output adaptee = new Output(xyPolygon.Caption + ".Flow")
            {
                SpatialDefinition = xyPolygon, ValueDefinition = waterLevelQuantity
            };
            ITimeSpaceInput consumerA = new Input(xyPointA.Caption + ".Flow")
            {
                SpatialDefinition = xyPointA, ValueDefinition = waterLevelQuantity
            };

            IIdentifiable           selectedAvailableAdaptedOutputId = adaptedOutputFactory.GetAvailableAdaptedOutputIds(adaptee, consumerA)[1];
            ITimeSpaceAdaptedOutput adaptedOutput = (ITimeSpaceAdaptedOutput)adaptedOutputFactory.CreateAdaptedOutput(selectedAvailableAdaptedOutputId, adaptee, consumerA);

            adaptedOutput.AddConsumer(consumerA);

            IList <IList> values2D = new List <IList>();

            values2D.Add(new List <double> {
                0.444
            });
            adaptee.Values = new ValueSet(values2D);

            ITimeSpaceValueSet adaptedValuesA = adaptedOutput.GetValues(consumerA);

            Assert.AreEqual(1, ValueSet.GetTimesCount(adaptedValuesA), "adaptedValuesA.TimesCount");
            Assert.AreEqual(consumerA.ElementSet().ElementCount, ValueSet.GetElementCount(adaptedValuesA), "adaptedValuesA.ElementCount");
        }
示例#3
0
 override public void ValidValue(ITimeSpaceValueSet valueSet)
 {
     // TODO Standard move ValidValue into IExchangeItem?
     if (valueSet == null)
     {
         throw new ArgumentException("value == null");
     }
     if (ValueSet.GetElementCount(valueSet) != 1)
     {
         throw new ArgumentException("valueSet.ElementCount != 1");
     }
     if (ValueSet.GetTimesCount(valueSet) != 1)
     {
         throw new ArgumentException("valueSet.TimesCount != 1");
     }
     if (!(valueSet.GetValue(0, 0) is double))
     {
         throw new ArgumentException("!(valueSet.GetValue(0,0) is double)");
     }
 }