Beispiel #1
0
        public void GetValuesFromTimeSeries()
        {
            ITimeSpaceComponent timeSeries = new TimeSeriesComponent();

            // initialize model
            timeSeries.Initialize();

            ITimeSpaceOutput output = (ITimeSpaceOutput)timeSeries.Outputs[0];

            // specify query times
            Time   startTime = new Time(new DateTime(2005, 1, 1, 0, 0, 0));
            double firstTriggerGetValuesTime  = startTime.StampAsModifiedJulianDay;
            double secondTriggerGetValuesTime = firstTriggerGetValuesTime + 12.1;
            double thirdTriggerGetValuesTime  = firstTriggerGetValuesTime + 16.7;

            // get values for specified query times - initial time, will return initial value
            queryItem1.TimeSet.SetSingleTimeStamp(firstTriggerGetValuesTime);
            ITimeSpaceValueSet values = output.GetValues(queryItem1);

            Assert.AreEqual(1, values.GetValue(0, 0), "value for first query time");

            // 12.1 days from 01-01
            queryItem1.TimeSet.SetSingleTimeStamp(secondTriggerGetValuesTime);
            values = output.GetValues(queryItem1);
            Assert.AreEqual(13, values.GetValue(0, 0), "value for second query time");

            // 16.7 days from 01-01
            queryItem1.TimeSet.SetSingleTimeStamp(thirdTriggerGetValuesTime);
            values = output.GetValues(queryItem1);
            Assert.AreEqual(17, values.GetValue(0, 0), "value for third query time");
        }
 internal MeasurementsInterpolator(ITimeSpaceOutput parentOutput)
     : base(parentOutput.Caption + "-" + MeasurementsInterpolatorName)
 {
     _valueDefinition   = parentOutput.ValueDefinition;
     _spatialDefinition = parentOutput.ElementSet();
     _adaptee           = parentOutput;
 }
        public void GetValuesOnTimeExtrapolator()
        {
            // create the component
            // connect query and output item
            // take care that component becomes valid and produces initial output for connected items
            ITimeSpaceComponent cf             = RainRrCfComponents.CreateChannelFlowInstance("CF-2");
            ITimeSpaceOutput    selectedOutput = RainRrCfCompositions.FindOutputItem(cf, "node-2.waterlevel");

            cf.Validate();

            ITimeSpaceAdaptedOutput timeExtrapolator =
                (ITimeSpaceAdaptedOutput)RainRrCfCompositions.ConnectItemsUsingAdaptedOutput(cf,
                                                                                             selectedOutput, _waterlevQueryItem,
                                                                                             RainRrCfCompositions.timeExtrapolatorId);

            // set query time for getting values
            _dischargeQueryItem.TimeSet.SetSingleTimeStamp(new DateTime(2009, 3, 28, 12, 0, 0));
            ITimeSpaceValueSet values = timeExtrapolator.GetValues(_dischargeQueryItem);

            Assert.IsNotNull(values, "values != null");
            Assert.AreEqual(4001.5, (double)values.Values2D[0][0], "value[0] from GetValues 1");

            _dischargeQueryItem.TimeSet.SetSingleTimeStamp(new DateTime(2009, 3, 29, 0, 0, 0));
            values = timeExtrapolator.GetValues(_dischargeQueryItem);
            Assert.IsNotNull(values, "values != null");
            Assert.AreEqual(4002.0, (double)values.Values2D[0][0], "value[0] from GetValues 1");

            _dischargeQueryItem.TimeSet.SetSingleTimeStamp(new DateTime(2009, 3, 30, 0, 0, 0));
            timeExtrapolator.GetValues(_dischargeQueryItem);
            Assert.AreEqual(4002.0, (double)values.Values2D[0][0], "value[0] from GetValues 1");
        }
Beispiel #4
0
        public static IIdentifiable[] GetAvailableMethods(IBaseOutput adaptee, IBaseInput target)
        {
            ITimeSpaceOutput tsadaptee = adaptee as ITimeSpaceOutput;

            // Only works with timespace output as adaptee, and element set as spatial definition
            if (tsadaptee == null || !(tsadaptee.SpatialDefinition is IElementSet))
            {
                return(new IIdentifiable[0]);
            }

            IList <IIdentifiable> methods = new List <IIdentifiable>();

            GetAvailableOperationMethods(ref methods, tsadaptee.ElementSet().ElementType);

            // Check if the target is there and is a timespace input
            ITimeSpaceInput tstarget = target as ITimeSpaceInput;

            if (target == null || tstarget == null || !(tstarget.SpatialDefinition is IElementSet))
            {
                return(((List <IIdentifiable>)methods).ToArray());
            }

            GetAvailableMappingMethods(ref methods, tsadaptee.ElementSet().ElementType, tstarget.ElementSet().ElementType);

            return(((List <IIdentifiable>)methods).ToArray());
        }
 public SpatialExtensionElementSetAdaptor(ITimeSpaceOutput adaptee, IElementSet elementSet, string id)
   : base(adaptee, id)
 {
   _elementSet = elementSet;
   _caption = elementSet.Caption;
   _description = elementSet.Description;
 }
Beispiel #6
0
 public ExchangeItem(IBaseExchangeItem openMIItem, bool useBufferedValues)
 {
     if (openMIItem is ITimeSpaceOutput)
     {
         _openMIItem = _openMIOutputItem = (ITimeSpaceOutput)openMIItem;
     }
     else if (openMIItem is ITimeSpaceInput)
     {
         _openMIItem = _openMIInputItem = (ITimeSpaceInput)openMIItem;
     }
     else
     {
         throw new Exception("Unknown exchange item type: " + openMIItem.GetType());
     }
     if (_openMIItem.TimeSet != null && _openMIItem.TimeSet.HasDurations)
     {
         throw new Exception("\"" + Id + ": OpenDA Time Spans not covered by OpenDA Exchange items");
     }
     _useBufferedValues = useBufferedValues;
     if (_useBufferedValues)
     {
         _bufferedValues = new List <List <double> > {
             new List <double>()
         };
         _bufferedTimes = new List <double>();
     }
 }
 public SpatialExtensionElementSetAdaptor(ITimeSpaceOutput adaptee, IElementSet elementSet, string id)
     : base(adaptee, id)
 {
     _elementSet  = elementSet;
     _caption     = elementSet.Caption;
     _description = elementSet.Description;
 }
Beispiel #8
0
 public void AddOut(IBaseExchangeItem openMIo)
 {
     if (openMIo is ITimeSpaceOutput)
     {
         _openMIItem = _openMIOutputItem = (ITimeSpaceOutput)openMIo;
     }
 }
Beispiel #9
0
        public void TestDummyModelFactoryGetInstances()
        {
            IOpenDaModelProvider linkableComponentFactory = new SimpleLinkableComponentFactory();

            linkableComponentFactory.Initialize(".", "factory-arg1-value");

            ITimeSpaceComponent modelInstance = linkableComponentFactory.CreateInstance();

            modelInstance.Arguments[0].Value = "instance-arg1-value";
            modelInstance.Initialize();
            modelInstance.Validate();
            modelInstance.Prepare();

            IList <IBaseInput> inputs = modelInstance.Inputs;

            Assert.IsTrue(inputs.Count > 0, "At least one input");
            IBaseInput input = inputs[0];

            Assert.IsTrue(input != null, "Inputs[0] is IBaseInput");

            IList <IBaseOutput> outputs = modelInstance.Outputs;

            Assert.IsTrue(outputs.Count > 0, "At least one output");
            ITimeSpaceOutput output = outputs[0] as ITimeSpaceOutput;

            Assert.IsTrue(output != null, "Outputs[0] is ITimeSpaceOutput");

            while (modelInstance.Status == LinkableComponentStatus.Updated)
            {
                modelInstance.Update();
            }
            Assert.AreEqual(LinkableComponentStatus.Done, modelInstance.Status, "Status == Done");

            modelInstance.Finish();
        }
        public ElementLineLengthOperationAdaptor(string id, ITimeSpaceOutput adaptee)
            : base(adaptee, id)
        {
            _tsadaptee = adaptee;
            Arguments.Add(_lengthExponentArgument);
            // Check the adaptee data
            IElementSet elementSet = adaptee.SpatialDefinition as IElementSet;

            if (elementSet == null)
            {
                throw new ArgumentException("Adaptee must have an IElementSet as SpatialDefinition", "adaptee");
            }
            if (elementSet.ElementType != ElementType.PolyLine)
            {
                throw new ArgumentException("Adaptee must have a SpatialDefinition having polyline as elements", "adaptee");
            }
            if (adaptee.ValueDefinition.ValueType != typeof(double))
            {
                throw new ArgumentException("Adaptee valuetype must be typeof(double)", "adaptee");
            }
            if (!(adaptee.ValueDefinition is IQuantity))
            {
                throw new ArgumentException("Adaptee valueDefinition must be an IQuantity", "adaptee");
            }
        }
 protected AbstractTimeSpaceAdaptor(ITimeSpaceOutput adaptee, string id)
 {
     _adaptee       = adaptee;
     _id            = id;
     AdaptedOutputs = new List <IBaseAdaptedOutput>();
     Consumers      = new List <IBaseInput>();
 }
Beispiel #12
0
        public void GetValuesExtrapolateTest()
        {
            string dataFileRoot = @"..\..\..\..\..\Examples\AsciiFileReader\Data\";

            AsciiFileDataComponent ascii = new AsciiFileDataComponent();

            IArgument[] arguments = new IArgument[2];
            arguments[0] = Argument.Create("File1", dataFileRoot + "FlowDataId.txt", false, "Name of first file to load");
            arguments[1] = Argument.Create("File2", dataFileRoot + "WaterlevelDataPoints.txt", false, "Name of second file to load");
            ascii.ApplyArguments(arguments);
            ascii.Initialize();

            Assert.AreEqual(2, ascii.Outputs.Count);

            ITimeSpaceOutput flowOutput  = (ITimeSpaceOutput)ascii.Outputs[0];
            ITimeSpaceOutput levelOutput = (ITimeSpaceOutput)ascii.Outputs[1];

            Time   startTime       = new Time(new DateTime(2005, 1, 1, 0, 0, 0));
            double startTimeMjd    = startTime.StampAsModifiedJulianDay;
            double afterEndTimeMjd = startTimeMjd + 4;


            double[] expectedFlows  = new double[] { 11, 15.6, 21.3 };
            double[] expectedLevels = new double[] { 1, 5.6, 8.3 };


            // TODO: Make it extrapolate instead!
            _queryItem1.TimeSet.SetSingleTimeStamp(afterEndTimeMjd);
            ITimeSpaceValueSet flows  = flowOutput.GetValues(_queryItem1);
            ITimeSpaceValueSet levels = levelOutput.GetValues(_queryItem1);

            Assert.AreEqual(expectedFlows, flows.Values2D[0]);
            Assert.AreEqual(expectedLevels, levels.Values2D[0]);
        }
 public Output(ITimeSpaceOutput iOutput)
     : base(iOutput)
 {
     foreach (ITimeSpaceInput item in iOutput.Consumers)
     {
         _consumers.Add(item.Caption);
     }
 }
        private static void ConnectItems(ITimeSpaceComponent sourceComponentInstance, string outputItemId,
                                         ITimeSpaceComponent targetComponentInstance, string inputItemId)
        {
            ITimeSpaceOutput output = FindOutputItem(sourceComponentInstance, outputItemId);
            ITimeSpaceInput  input  = FindInputItem(targetComponentInstance, inputItemId);

            output.AddConsumer(input);
        }
Beispiel #15
0
 protected DecoratorBase(IIdentifiable identifiable, string caption, string description, ITimeSpaceOutput decorated, ITimeSpaceInput target)
 {
     _identifiable = identifiable;
     _description  = description;
     _caption      = caption;
     _decorated    = decorated;
     _target       = target;
 }
Beispiel #16
0
    public void CreateInitializeTest()
    {
      ITimeSpaceComponent gwModel = new GWModelLC();
      IBaseLinkableComponent lc = gwModel;
      Assert.IsTrue(gwModel.Status == LinkableComponentStatus.Created);

      List<IArgument> gwArguments = CreateTestArguments();

      gwModel.Arguments.ApplyArguments(gwArguments);
      gwModel.Initialize();
      Assert.IsTrue(gwModel.Status == LinkableComponentStatus.Initialized);
      Assert.AreEqual("GWModelLC", gwModel.Id);

      Assert.AreEqual(3, gwModel.Inputs.Count);
      Assert.AreEqual(3, gwModel.Outputs.Count);

      {
        // Check the ground water level output
        ITimeSpaceOutput gwLevel = lc.Outputs[2] as ITimeSpaceOutput;
        Assert.IsNotNull(gwLevel);
        Assert.AreEqual("Grid.gwLevel", gwLevel.Id);

        // Check quantity
        IQuantity quantity = gwLevel.ValueDefinition as IQuantity;
        Assert.IsNotNull(quantity);
        Assert.AreEqual("Ground water level", quantity.Caption);
        Assert.AreEqual("gw level", quantity.Unit.Caption);
        Assert.AreEqual(1, quantity.Unit.Dimension.GetPower(DimensionBase.Length));
        Assert.AreEqual(0, quantity.Unit.Dimension.GetPower(DimensionBase.Time));
        Assert.AreEqual(1, quantity.Unit.ConversionFactorToSI);

        // Check element set
        IElementSet gridSet = gwLevel.ElementSet();
        CheckRegularGridElmtSet(gridSet);

      }

      {
        // Check the ground water inflow input
        ITimeSpaceInput gwInput = lc.Inputs[2] as ITimeSpaceInput;
        Assert.IsNotNull(gwInput);
        Assert.AreEqual("Grid.Inflow", gwInput.Id);

        // Check quantity
        IQuantity quantity = gwInput.ValueDefinition as IQuantity;
        Assert.IsNotNull(quantity);
        Assert.AreEqual("Inflow", quantity.Caption);
        Assert.AreEqual("Discharge", quantity.Unit.Caption);
        Assert.AreEqual(3, quantity.Unit.Dimension.GetPower(DimensionBase.Length));
        Assert.AreEqual(-1, quantity.Unit.Dimension.GetPower(DimensionBase.Time));
        Assert.AreEqual(0.001, quantity.Unit.ConversionFactorToSI);

        // Check element set
        IElementSet gridSet = gwInput.ElementSet();
        CheckRegularGridElmtSet(gridSet);
      }

    }
Beispiel #17
0
 public DecoratorWave(IIdentifiable identifiable, ITimeSpaceOutput decorated, ITimeSpaceInput target)
     : base(identifiable, "Wave: A*sin(F*t + P)",
            "Wave transformation y = Amplitude * sin(frequancy * time + phase)",
            decorated, target)
 {
     _arguments.Add(Argument.Create("Amplitude", "0.0", false, "A in A*sin(F*t + P)"));
     _arguments.Add(Argument.Create("Phase", "0.0", false, "P in y = A*sin(F*t + P)"));
     _arguments.Add(Argument.Create("Frequency", "0.0", false, "F in y = A*sin(F*t + P)"));
 }
Beispiel #18
0
        public IIdentifiable[] GetAvailableAdaptedOutputIds(IBaseOutput decoratedItem, IBaseInput targetItem)
        {
            ITimeSpaceOutput tsoutput = decoratedItem as ITimeSpaceOutput;

            if (tsoutput == null)
            {
                return(new IIdentifiable[0]);
            }
            return(new List <IIdentifiable>(_ids.Keys).ToArray());
        }
Beispiel #19
0
        public void GetValues1A()
        {
            LinkableEngine      riverModelLE = CreateRiverModel();
            ITimeSpaceComponent riverModelLC = riverModelLE;

            // initialize model
            List <IArgument> riverArguments = CreateRiverModelArguments(riverModelLC);

            riverArguments.Add(Argument.Create("ModelID", "RiverModel", true, "argument"));
            riverArguments.Add(Argument.Create("TimeStepLength", 3600));
            riverModelLC.Arguments.ApplyArguments(riverArguments);
            riverModelLC.Initialize();

            // Link output and trigger with a time buffer
            ITimeSpaceOutput      output = (ITimeSpaceOutput)riverModelLC.Outputs[2];
            IAdaptedOutputFactory adaptedOutputFactory = riverModelLC.AdaptedOutputFactories[0];

            IIdentifiable[]         adaptedOutputIds = adaptedOutputFactory.GetAvailableAdaptedOutputIds(output, _queryItem1);
            ITimeSpaceAdaptedOutput adaptedOutput    = (ITimeSpaceAdaptedOutput)
                                                       adaptedOutputFactory.CreateAdaptedOutput(adaptedOutputIds[0], output, _queryItem1);

            adaptedOutput.AddConsumer(_queryItem1);

            riverModelLC.Validate();
            Assert.IsTrue(riverModelLC.Status == LinkableComponentStatus.Valid);
            riverModelLC.Prepare();
            Assert.IsTrue(riverModelLC.Status == LinkableComponentStatus.Updated);

            // specify query times
            double firstTriggerGetValuesTime  = riverModelLE.CurrentTime.StampAsModifiedJulianDay;
            double secondTriggerGetValuesTime = firstTriggerGetValuesTime + 2;
            double thirdTriggerGetValuesTime  = firstTriggerGetValuesTime + 4.3;

            // check initial values
            Assert.AreEqual(1, output.Values.Values2D[0].Count, "#values for " + output.Id);
            Assert.AreEqual(7.0, (double)output.Values.GetValue(0, 0), "Value[0] as property");

            // get values for specified query times
            _queryItem1.TimeSet.SetSingleTimeStamp(firstTriggerGetValuesTime);
            ITimeSpaceValueSet values = adaptedOutput.GetValues(_queryItem1);

            Assert.AreEqual(7.0, values.GetValue(0, 0), "value for first query time");

            // only runoff inflow, 10 L/s
            _queryItem1.TimeSet.SetSingleTimeStamp(secondTriggerGetValuesTime);
            values = adaptedOutput.GetValues(_queryItem1);
            Assert.AreEqual(35.0 / 4.0, values.GetValue(0, 0), "value for second query time");

            // still only runoff inflow, 10 L/s
            _queryItem1.TimeSet.SetSingleTimeStamp(thirdTriggerGetValuesTime);
            values = adaptedOutput.GetValues(_queryItem1);
            Assert.AreEqual(35.0 / 4.0, values.GetValue(0, 0), "value for third query time");

            riverModelLC.Finish();
        }
        public static void ConnectItemsUsingAdaptedOutput(ITimeSpaceComponent sourceComponentInstance,
                                                          string outputItemId,
                                                          ITimeSpaceComponent targetComponentInstance,
                                                          string inputItemId,
                                                          string derivedOutputName)
        {
            ITimeSpaceOutput output = FindOutputItem(sourceComponentInstance, outputItemId);
            ITimeSpaceInput  input  = FindInputItem(targetComponentInstance, inputItemId);

            ConnectItemsUsingAdaptedOutput(sourceComponentInstance, output, input, derivedOutputName);
        }
        private static void ConnectItemsWithTimeInterpolator(ITimeSpaceComponent sourceComponentInstance,
                                                             string outputItemId,
                                                             ITimeSpaceComponent targetComponentInstance, string inputItemId)
        {
            ITimeSpaceOutput      output = FindOutputItem(sourceComponentInstance, outputItemId);
            ITimeSpaceInput       input  = FindInputItem(targetComponentInstance, inputItemId);
            IAdaptedOutputFactory derivedOutputFactory = sourceComponentInstance.AdaptedOutputFactories[0];

            IIdentifiable[]    derivedOutputIdentifiers = derivedOutputFactory.GetAvailableAdaptedOutputIds(output, input);
            IBaseAdaptedOutput timeInterpolator         = derivedOutputFactory.CreateAdaptedOutput(derivedOutputIdentifiers[0], output, input);
        }
Beispiel #22
0
        public void RemoveProvider(IBaseOutput provider)
        {
            // TODO: Check if provider is valid (must be ITimeSpaceOutput)
            ITimeSpaceOutput timeSpaceprovider = (ITimeSpaceOutput)provider;

            _providers.Remove(timeSpaceprovider);
            if (_providers.Count == 0)
            {
                _linkableEngine.ActiveInputItems.Remove(this);
            }
        }
Beispiel #23
0
        private double GetModelValue(string exchangeItemId, int modelVariableIndex)
        {
            char[]   delimiterChars   = { ',' };
            string[] words            = exchangeItemId.Split(delimiterChars);
            string   openMIVariableID = words[0].Trim();


            ITimeSpaceOutput output = FindOutputItem(openMIVariableID);

            return(output.Values.Values2D[0].Cast <double>().ToArray()[modelVariableIndex]);
        }
        public IIdentifiable[] GetAvailableAdaptedOutputIds(IBaseOutput adaptee, IBaseInput target)
        {
            // The time methods in this factory only works on an ITimeSpaceOutput
            ITimeSpaceOutput tsoutput = adaptee as ITimeSpaceOutput;

            if (tsoutput == null)
            {
                return(new IIdentifiable[0]);
            }
            return(new IIdentifiable[] { new AdaptedOutputIdentifier(TimeInterpolatorId), new AdaptedOutputIdentifier(TimeExtrapolatorId) });
        }
Beispiel #25
0
 public AddapterBase(IIdentifiable identifier, IDescribable described, ITimeSpaceOutput adapted, ITimeSpaceInput target)
 {
     _identifier = identifier;
     _described  = described;
     _target     = target;
     _adapted    = adapted;
     if (!_adapted.AdaptedOutputs.Contains(this))
     {
         _adapted.AddAdaptedOutput(this);
     }
 }
        public OrphanedInputSpaceTime(ITimeSpaceOutput output)
        {
            var describes = new Describes("Temporal Target", "= Temporal Target");
            SetIdentity(new Identity("FluidEarth2.Sdk.OrphanedInputSpaceTime", describes));

            Component = null;

            ValueDefinition = output.ValueDefinition;
            SpatialDefinition = output.SpatialDefinition;

            TimeSet = new TimeSet();
        }
Beispiel #27
0
 private IIdentifiable[] GetAvailableAdaptedOutputIdsAndDescriptions(ITimeSpaceOutput adaptee, ITimeSpaceInput consumer,
                                                                     ICollection <IDescribable>
                                                                     adaptedOutputDescriptions)
 {
     IIdentifiable[] availableAdaptedOutputIds = adaptedOutputFactory.GetAvailableAdaptedOutputIds(adaptee,
                                                                                                   consumer);
     foreach (IIdentifiable adaptedOutputId in availableAdaptedOutputIds)
     {
         adaptedOutputDescriptions.Add(adaptedOutputId);
     }
     return(availableAdaptedOutputIds);
 }
Beispiel #28
0
        public static bool Update(ITimeSpaceOutput output, IBaseExchangeItem basequerySpecifier)
        {
            ITimeSpaceExchangeItem querySpecifier = basequerySpecifier as ITimeSpaceExchangeItem;

            if (querySpecifier == null)
            {
                throw new ArgumentException("querySpecifier must be an ITimeSpaceExchangeItem - add an adaptor");
            }

            // Time set of query must be defined and have at least 1 time
            if (querySpecifier.TimeSet == null ||
                querySpecifier.TimeSet.Times == null ||
                querySpecifier.TimeSet.Times.Count == 0)
            {
                throw new Exception("Given the TimeSet of output item \"" + output.Id +
                                    "\", it can not produce one set of values for \"" + querySpecifier.Id + "\"");
            }

            // Output time set must be defined
            if (output.TimeSet == null || output.TimeSet.Times == null)
            {
                throw new Exception("Invalid time specifier in output item \"" + output.Id +
                                    "\" for in updating according to a time specification" + querySpecifier.Id);
            }

            // Compute until this time is available
            double queryTimeMjd = querySpecifier.TimeSet.Times[0].End().StampAsModifiedJulianDay;

            // The current available time from the output item
            double availableTimeMjd = Double.NegativeInfinity;

            if (output.TimeSet.Times.Count > 0)
            {
                availableTimeMjd = output.TimeSet.Times[output.TimeSet.Times.Count - 1].End().StampAsModifiedJulianDay;
            }

            // Update component until querytime is available
            // If component is "busy" (LinkableComponentStatus.Updating), the
            // component will not be updated.
            IBaseLinkableComponent component = output.Component;

            while ((component.Status == LinkableComponentStatus.Valid ||
                    component.Status == LinkableComponentStatus.Updated) &&
                   availableTimeMjd + Time.EpsilonForTimeCompare < queryTimeMjd)
            {
                component.Update();
                availableTimeMjd = output.TimeSet.Times[output.TimeSet.Times.Count - 1].End().StampAsModifiedJulianDay;
            }

            // Return true if component was updated up until queryTimeMjd
            return(availableTimeMjd + Time.EpsilonForTimeCompare >= queryTimeMjd);
        }
Beispiel #29
0
        public void AddProvider(IBaseOutput provider)
        {
            // TODO: Check if provider is valid (must be ITimeSpaceOutput)
            ITimeSpaceOutput timeSpaceprovider = (ITimeSpaceOutput)provider;

            if (!_providers.Contains(timeSpaceprovider))
            {
                _providers.Add(timeSpaceprovider);
                if (_providers.Count == 1)
                {
                    _linkableEngine.ActiveInputItems.Add(this);
                }
            }
        }
Beispiel #30
0
 public LinearOperationAdaptedOutput(ITimeSpaceOutput adaptee)
     : base(adaptee.Id + " => LinearOperation", adaptee)
 {
     Caption     = adaptee.Id + " => y = A*x + B";
     Description = "Performs a linear operation on the form: y = Ax + B";
     Arguments.Add(new ArgumentDouble("A", 1.0)
     {
         Description = "A in y = A*x + B"
     });
     Arguments.Add(new ArgumentDouble("B", 0.0)
     {
         Description = "B in y = A*x + B"
     });
 }
Beispiel #31
0
        private double[] GetModelValuesDifferentVariables(List <string> exchangeItemId, IList <int> modelVariableIndices)
        {
            double[] modelValues = new double[modelVariableIndices.Count];
            for (int i = 0; i < modelVariableIndices.Count; i++)
            {
                char[]   delimiterChars   = { ',' };
                string[] words            = exchangeItemId[i].Split(delimiterChars);
                string   openMIVariableID = words[0].Trim();


                ITimeSpaceOutput output = FindOutputItem(openMIVariableID);
                var modVars             = output.Values.Values2D[0].Cast <double>().ToArray();
                modelValues[i] = modVars[modelVariableIndices[i]];
            }
            return(modelValues);
        }
Beispiel #32
0
        private void GetExchangeItemsFromOpenMIComponent()
        {
            // ZZZ
            // Match the Input and Output Exchange Items
            foreach (IBaseInput baseInput in _openMIComponent.Inputs)
            {
                foreach (IBaseOutput baseOutput in _openMIComponent.Outputs)
                {
                    if (baseInput.Id.CompareTo(baseOutput.Id) == 0)
                    {
                        ITimeSpaceInput  timeSpaceInput  = baseInput as ITimeSpaceInput;
                        ITimeSpaceOutput timeSpaceOutput = baseOutput as ITimeSpaceOutput;

                        var IO = new ExchangeItem(timeSpaceOutput);
                        IO.AddIn(timeSpaceInput);

                        if (IO != null && !_inout.ContainsKey(timeSpaceOutput.Id))
                        {
                            _inout.Add(timeSpaceOutput.Id, IO);
                        }
                    }
                }
            }

            foreach (IBaseInput baseIn in _openMIComponent.Inputs)
            {
                ITimeSpaceInput timeSpaceIn = baseIn as ITimeSpaceInput;

                if (timeSpaceIn != null && !_inout.ContainsKey(baseIn.Id))
                {
                    _inputs.Add(timeSpaceIn.Id, new ExchangeItem(timeSpaceIn));
                }
            }
            foreach (IBaseOutput baseOut in _openMIComponent.Outputs)
            {
                ITimeSpaceOutput timeSpaceOut = baseOut as ITimeSpaceOutput;
                if (timeSpaceOut != null && !_inout.ContainsKey(baseOut.Id))
                {
                    //ZZZ
                    var I = new ExchangeItem(timeSpaceOut);
                    if (I != null)
                    {
                        _outputs.Add(timeSpaceOut.Id, I);
                    }
                }
            }
        }
 public TimeExtrapolator(ITimeSpaceOutput adaptee)
     : base(timeExtrapolatorId, adaptee)
   {
   }
 public TimeInterpolator(ITimeSpaceOutput adaptee)
   : base(timeInterpolatorId, adaptee)
 {
 }
 protected TimeBufferer(string id, ITimeSpaceOutput decoratedOutput)
   : base(id, decoratedOutput)
 {
   CreateBufferAndTimeSet();
 }
 public ChildIdentityAdaptor(MultiInputAdaptor parent, ITimeSpaceOutput adaptee)
 {
   _parent = parent;
   _adaptee = adaptee;
 }
 protected AbstractAdaptedOutput(string id, ITimeSpaceOutput decoratedOutput)
     : base(id)
 {
     _adaptee = decoratedOutput;
 }