public IBaseAdaptedOutput CreateAdaptedOutput(IIdentifiable adaptedOutputId, IBaseOutput adaptee, IBaseInput target)
 {
   ITimeSpaceAdaptedOutput adaptedOutput = adaptedOutputId as ITimeSpaceAdaptedOutput;
   if (adaptedOutput == null)
     throw new ArgumentException("Adapted output id does no come from this factory","adaptedOutputId");
   return (adaptedOutput);
 }
Example #2
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 IIdentifiable[] GetAvailableAdaptedOutputIds(IBaseOutput adaptee, IBaseInput target)
    {
      ITimeSpaceOutput tadaptee = adaptee as ITimeSpaceOutput;
      
      // Not a time-space exchange item, no available adaptors
      if (tadaptee == null)
        return (new IIdentifiable[0]);
      
      // For each of the spatial extension classes, return its wrapper class

      // MultiPoint must come before ILineString (because ILineString is currently also an IMultiPoint)
      if (tadaptee.SpatialDefinition is IMultiPoint)
        return new IIdentifiable[] { new SpatialExtensionElementSetAdaptor(tadaptee, new MultiPointWrapper(tadaptee.SpatialDefinition as IMultiPoint), "MultiPointWrapper") };
      
      if (tadaptee.SpatialDefinition is ILineString)
        return new IIdentifiable[] { new SpatialExtensionElementSetAdaptor(tadaptee, new LineStringWrapper(tadaptee.SpatialDefinition as ILineString), "LineStringWrapper") };
      
      if (tadaptee.SpatialDefinition is ISpatial2DGrid)
        return new IIdentifiable[] { new SpatialExtensionElementSetAdaptor(tadaptee, new Spatial2DGridWrapper(tadaptee.SpatialDefinition as ISpatial2DGrid), "Spatial2DGridWrapper") };
      
      if (tadaptee.SpatialDefinition is ISpatialMesh)
        return new IIdentifiable[] { new SpatialExtensionElementSetAdaptor(tadaptee, new SpatialMeshWrapper(tadaptee.SpatialDefinition as ISpatialMesh), "SpatialMeshWrapper") };

      // Spatial definition is not known, return an empty set.
      return (new IIdentifiable[0]);

    }
        /// <summary>
        /// Create an adapted output, assuming that the adaptee and target are matching (check must
        /// be done beforehand.
        /// </summary>
        /// <param name="adaptee">Adaptee to connect to multi input</param>
        /// <param name="target">Target of created multi input adaptor</param>
        /// <returns>Multi input adaptor, connected to adaptee</returns>
        public ITimeSpaceAdaptedOutput CreateAdaptedOutput(IBaseOutput adaptee, IBaseInput target)
        {
            MultiInputAdaptor multiInputAdaptor;

            if (!ExistingMultiInputAdaptors.TryGetValue(target, out multiInputAdaptor))
            {
                // Set up a multi input adaptor having the same properties as the target
                multiInputAdaptor = new MultiInputAdaptor("MultiInputAdaptor:" + target.Id)
                {
                    SpatialDefinition = ((ITimeSpaceInput)target).SpatialDefinition,
                    ValueDefinition   = target.ValueDefinition,
                };
                ExistingMultiInputAdaptors.Add(target, multiInputAdaptor);
            }

            // Identity adaptor, create and register with multiInput
            //adaptedOutput = multiInputAdaptor.CreateChildAdaptor(adaptee);

            // The trick here is to always return and use the same multi input adaptor.
            // for all adaptees.
            multiInputAdaptor.Adaptees.Add((ITimeSpaceOutput)adaptee);

            // Connect adaptee and adaptor - the factory must do this.
            if (!adaptee.AdaptedOutputs.Contains(multiInputAdaptor))
            {
                adaptee.AddAdaptedOutput(multiInputAdaptor);
            }
            return(multiInputAdaptor);
        }
        public virtual void AddConsumer(IBaseInput consumer)
        {
            ITimeSpaceInput timeSpaceConsumer = consumer as ITimeSpaceInput;

            if (timeSpaceConsumer == null)
            {
                throw new ArgumentException("Must be a ITimeSpaceInput - may need to add adaptor");
            }

            // Create list of consumers
            if (_consumers == null)
            {
                _consumers = new List <ITimeSpaceInput>();
            }

            // consumer should not be already added
            if (_consumers.Contains(timeSpaceConsumer))
            {
                //throw new Exception("consumer \"" + consumer.Caption +
                //    "\" has already been added to \"" + Caption);
            }
            else
            {
                _consumers.Add(timeSpaceConsumer);
                if (consumer.Provider != this)
                {
                    consumer.Provider = this;
                }
            }
        }
Example #6
0
 public void RemoveConsumer(IBaseInput consumer)
 {
     if (!_consumers.Contains(consumer))
     {
         throw new Exception("Consumer was never registered");
     }
 }
Example #7
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());
        }
Example #8
0
 /// <summary>
 /// Check if a consumer can be added to an output or adapted output. If both the output and the
 /// new consumer are time space items, the element sets and the time set types are checked.
 /// </summary>
 /// <param name="outputItem">The output item</param>
 /// <param name="newConsumer">The new consumer</param>
 /// <returns>True if the consumer can be added indeed</returns>
 public static bool ConsumersCompatible(IBaseOutput outputItem, IBaseInput newConsumer)
 {
     if (outputItem is ITimeSpaceOutput && newConsumer is ITimeSpaceInput)
     {
         return(ConsumersCompatibleForTimeAndElementSet((ITimeSpaceOutput)outputItem, (ITimeSpaceInput)newConsumer));
     }
     return(true);
 }
 public IIdentifiable[] GetAvailableAdaptedOutputIds(IBaseOutput parentItem, IBaseInput target)
 {
   // The time methods in this factory only works on an ITimeSpaceOutput
   ITimeSpaceOutput tsoutput = parentItem as ITimeSpaceOutput;
   if (tsoutput == null)
     return (new IIdentifiable[0]);
   return new IIdentifiable[] { new TimeInterpolator(tsoutput), new TimeExtrapolator(tsoutput) };
 }
Example #10
0
 public void AddConsumer(IBaseInput consumer)
 {
     if (_consumers.Contains(consumer))
     {
         throw new Exception("Consumer has already been registered");
     }
     _consumers.Add(consumer);
 }
Example #11
0
 /// <summary>
 /// Check if a consumer can be added to an output or adapted output. If both the output and the
 /// new consumer are time space items, the element sets and the time set types are checked.
 /// </summary>
 /// <param name="provider">The output item</param>
 /// <param name="consumer">The new consumer</param>
 /// <returns>True if the consumer can be added indeed</returns>
 public static bool ProviderConsumerConnectable(IBaseOutput provider, IBaseInput consumer)
 {
     if (provider is ITimeSpaceOutput && consumer is ITimeSpaceInput)
     {
         return(ProviderConsumerConnectableForTimeAndElementSet((ITimeSpaceOutput)provider, (ITimeSpaceInput)consumer));
     }
     return(true);
 }
Example #12
0
 public override void RemoveConsumer(IBaseInput consumer)
 {
     base.RemoveConsumer(consumer);
     if (_consumers.Count == 0 && _adaptedOutputs.Count == 0)
     {
         _linkableEngine.ActiveOutputItems.Remove(this);
     }
 }
Example #13
0
        public void AddConsumer(IBaseInput consumer)
        {
            _consumers.Add((ITimeSpaceInput)consumer);

            if (consumer.Provider != this)
            {
                consumer.Provider = this;
            }
        }
Example #14
0
        public void RemoveConsumer(IBaseInput consumer)
        {
            _consumers.Remove((ITimeSpaceInput)consumer);

            if (consumer.Provider == this)
            {
                consumer.Provider = null;
            }
        }
Example #15
0
 /// <summary>
 /// Check if a new consumer is compatible with existing consumers. Throw an exception if not.
 /// </summary>
 /// <param name="outputItem">The output item</param>
 /// <param name="newConsumer">The new consumer</param>
 public static void CheckConsumersCompatible(IBaseOutput outputItem, IBaseInput newConsumer)
 {
     if (!ConsumersCompatible(outputItem, newConsumer))
     {
         throw new Exception("consumer \"" + newConsumer.Caption +
                             "\" can not be added to \"" + outputItem.Caption +
                             "\", because it is incompatible with existing consumers");
     }
 }
Example #16
0
 /// <summary>
 /// Check if a consumer can be added to an output or adapted output. Throw an exception if not.
 /// </summary>
 /// <param name="provider">The output item</param>
 /// <param name="consumer">The new consumer</param>
 public static void CheckProviderConsumerConnectable(IBaseOutput provider, IBaseInput consumer)
 {
     if (!ProviderConsumerConnectable(provider, consumer))
     {
         throw new Exception("consumer \"" + consumer.Caption +
                             "\" and provider \"" + provider.Caption +
                             "\" are not connectable, put an adapted output in between");
     }
 }
Example #17
0
 public override void AddConsumer(IBaseInput consumer)
 {
     if (consumer == null)
     {
         throw new ArgumentNullException("consumer", "Can not be null");
     }
     base.AddConsumer(consumer);
     // Add it to list of active output items
     _linkableEngine.ActiveOutputItems.Add(this);
 }
        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) });
        }
Example #19
0
 private void Awake()
 {
     _health       = GetComponent <IHealth>();
     _move         = GetComponent <IMove>();
     _jump         = GetComponent <IJump>();
     _climb        = GetComponent <IClimb>();
     _inputControl = GetComponent <IBaseInput>();
     _animator     = GetComponent <Animator>();
     _collider2D   = GetComponent <BoxCollider2D>();
     _rigidbody2D  = GetComponent <Rigidbody2D>();
 }
        public IBaseAdaptedOutput CreateAdaptedOutput(IIdentifiable adaptedOutputId, IBaseOutput adaptee, IBaseInput target)
        {
            IBaseAdaptedOutput adaptedOutput = new ElementMapperAdaptedOutput(adaptedOutputId, (ITimeSpaceOutput)adaptee, target.ElementSet());

            // Connect adaptor and adaptee
            if (!adaptee.AdaptedOutputs.Contains(adaptedOutput))
            {
                adaptee.AddAdaptedOutput(adaptedOutput);
            }

            return adaptedOutput;
        }
Example #21
0
        public IIdentifiable[] GetAvailableAdaptedOutputIds(IBaseOutput adaptee, IBaseInput targetItem)
        {
            List <IIdentifiable> available = new List <IIdentifiable>();

            if (adaptee.ValueDefinition.ValueType == typeof(double) ||
                adaptee.ValueDefinition.ValueType == typeof(double[]))
            {
                available.Add(Linear.Identifier);
            }

            return(available.ToArray());
        }
        public virtual void RemoveConsumer(IBaseInput consumer)
        {
            ITimeSpaceInput timeSpaceConsumer = consumer as ITimeSpaceInput;

            if (timeSpaceConsumer == null || _consumers == null || !_consumers.Contains(timeSpaceConsumer))
            {
                throw new Exception("consumer \"" + consumer.Caption +
                                    "\" can not be removed from \"" + Caption +
                                    "\", because it was not added");
            }
            _consumers.Remove(timeSpaceConsumer);
            consumer.Provider = null;
        }
 public IBaseAdaptedOutput CreateAdaptedOutput(IIdentifiable adaptedOutputIdentifier, IBaseOutput adaptee, IBaseInput target)
 {
   IBaseAdaptedOutput adaptor = adaptedOutputIdentifier as IBaseAdaptedOutput;
   if (adaptor == null)
   {
     throw new ArgumentException("Unknown adaptedOutput type - it does not originate from this factory");
   }
   // Connect the adaptor and the adaptee
   if (!adaptee.AdaptedOutputs.Contains(adaptor))
   {
     adaptee.AddAdaptedOutput(adaptor);
   }
   return adaptor;
 }
Example #24
0
        public virtual void AddConsumer(IBaseInput consumer)
        {
            ITimeSpaceInput timeSpaceConsumer = consumer as ITimeSpaceInput;

            if (timeSpaceConsumer == null)
            {
                throw new ArgumentException("Must be a ITimeSpaceInput - may need to add adaptor");
            }

            // Create list of consumers
            if (_consumers == null)
            {
                _consumers = new List <ITimeSpaceInput>();
            }

            // consumer should not be already added
            if (_consumers.Contains(timeSpaceConsumer))
            {
                throw new Exception("consumer \"" + consumer.Caption +
                                    "\" has already been added to \"" + Caption);
            }

            // Check if this consumer can be added
            if (!ExchangeItemHelper.ConsumerCanBeAdded(_consumers, timeSpaceConsumer))
            {
                throw new Exception("consumer \"" + consumer.Caption +
                                    "\" can not be added to \"" + Caption +
                                    "\", because it is incompatible with existing consumers");
            }

            _consumers.Add(timeSpaceConsumer);


            if (consumer.Provider != this)
            {
                consumer.Provider = this;
            }
            //// TODO (JG): EXPERIMENTAL CODE
            //if (consumer is IBaseMultiInput)
            //{
            //    ((IBaseMultiInput)consumer).AddProvider(this);
            //}
            //else
            //{
            //    if (consumer.Provider != this)
            //    {
            //        consumer.Provider = this;
            //    }
            //}
        }
        public IIdentifiable[] GetAvailableAdaptedOutputIds(IBaseOutput adaptee, IBaseInput target)
        {
          ITimeSpaceOutput tsadaptee = adaptee as ITimeSpaceOutput;
          ITimeSpaceInput tstarget = target as ITimeSpaceInput;

          // This inly works with time space items, and target can not be null
          if (tsadaptee == null || tstarget == null)
            return new IIdentifiable[0];

          // This only works with element sets
          if (!(tsadaptee.SpatialDefinition is IElementSet && tstarget.SpatialDefinition is IElementSet))
            return new IIdentifiable[0];

          return ElementMapper.GetAvailableMethods(tsadaptee.ElementSet().ElementType, tstarget.ElementSet().ElementType);
        }
Example #26
0
        public virtual void AddConsumer(IBaseInput consumer)
        {
            ITimeSpaceInput timeSpaceConsumer = consumer as ITimeSpaceInput;
            if (timeSpaceConsumer == null)
                throw new ArgumentException("Must be a ITimeSpaceInput - may need to add adaptor");

            // Create list of consumers
            if (_consumers == null)
            {
                _consumers = new List<ITimeSpaceInput>();
            }

            // consumer should not be already added
            if (_consumers.Contains(timeSpaceConsumer))
            {
                throw new Exception("consumer \"" + consumer.Caption +
                    "\" has already been added to \"" + Caption);
            }

            // Check if this consumer can be added
            if (!ExchangeItemHelper.ConsumerCanBeAdded(_consumers, timeSpaceConsumer))
            {
                throw new Exception("consumer \"" + consumer.Caption +
                    "\" can not be added to \"" + Caption +
                    "\", because it is incompatible with existing consumers");
            }

            _consumers.Add(timeSpaceConsumer);


            if (consumer.Provider != this)
            {
                consumer.Provider = this;
            }
            //// TODO (JG): EXPERIMENTAL CODE
            //if (consumer is IBaseMultiInput)
            //{
            //    ((IBaseMultiInput)consumer).AddProvider(this);
            //}
            //else
            //{
            //    if (consumer.Provider != this)
            //    {
            //        consumer.Provider = this;
            //    }
            //}
        }
Example #27
0
        public IIdentifiable[] GetAvailableAdaptedOutputIds(IBaseOutput adaptee, IBaseInput target)
        {
            ITimeSpaceOutput tsadaptee = adaptee as ITimeSpaceOutput;
            ITimeSpaceInput  tstarget  = target as ITimeSpaceInput;

            // This inly works with time space items, and target can not be null
            if (tsadaptee == null || tstarget == null)
            {
                return(new IIdentifiable[0]);
            }

            // This only works with element sets
            if (!(tsadaptee.SpatialDefinition is IElementSet && tstarget.SpatialDefinition is IElementSet))
            {
                return(new IIdentifiable[0]);
            }

            return(ElementMapper.GetAvailableMethods(tsadaptee.ElementSet().ElementType, tstarget.ElementSet().ElementType));
        }
Example #28
0
        public virtual void AddConsumer(IBaseInput consumer)
        {
            ITimeSpaceInput timeSpaceConsumer = consumer as ITimeSpaceInput;

            if (timeSpaceConsumer == null)
            {
                throw new ArgumentException("Must be a ITimeSpaceInput - may need to add adaptor");
            }

            // Create list of consumers
            if (_consumers == null)
            {
                _consumers = new List <ITimeSpaceInput>();
            }

            // consumer should not be already added
            if (_consumers.Contains(timeSpaceConsumer))
            {
                throw new Exception("consumer \"" + consumer.Caption +
                                    "\" has already been added to \"" + Caption);
            }

            _consumers.Add(timeSpaceConsumer);


            if (consumer.Provider != this)
            {
                consumer.Provider = this;
            }
            //// TODO (JG): EXPERIMENTAL CODE
            //if (consumer is IBaseMultiInput)
            //{
            //    ((IBaseMultiInput)consumer).AddProvider(this);
            //}
            //else
            //{
            //    if (consumer.Provider != this)
            //    {
            //        consumer.Provider = this;
            //    }
            //}
        }
        public IIdentifiable[] GetAvailableAdaptedOutputIds(IBaseOutput adaptee, IBaseInput target)
        {
            // Target must be this component!
            if (target == null || target.Component != _component)
            {
                return(new IIdentifiable[0]);
            }

            // Check for filter
            if (Filter != null && !Filter(adaptee, target))
            {
                return(new IIdentifiable[0]);
            }

            List <IIdentifiable> res = new List <IIdentifiable>();

            res.Add(_identityAdaptor);

            return(res.ToArray());
        }
Example #30
0
        public IIdentifiable[] GetAvailableAdaptedOutputIds(IBaseOutput adaptee, IBaseInput target)
        {
            ITimeSpaceOutput tadaptee = adaptee as ITimeSpaceOutput;

            // Not a time-space exchange item, no available adaptors
            if (tadaptee == null)
            {
                return(new IIdentifiable[0]);
            }

            // For each of the spatial extension classes, return its wrapper class

            // MultiPoint must come before ILineString (because ILineString is currently also an IMultiPoint)
            if (tadaptee.SpatialDefinition is IMultiPoint)
            {
                return new IIdentifiable[] { new SpatialExtensionElementSetAdaptor(tadaptee, new MultiPointWrapper(tadaptee.SpatialDefinition as IMultiPoint), "MultiPointWrapper") }
            }
            ;

            if (tadaptee.SpatialDefinition is ILineString)
            {
                return new IIdentifiable[] { new SpatialExtensionElementSetAdaptor(tadaptee, new LineStringWrapper(tadaptee.SpatialDefinition as ILineString), "LineStringWrapper") }
            }
            ;

            if (tadaptee.SpatialDefinition is ISpatial2DGrid)
            {
                return new IIdentifiable[] { new SpatialExtensionElementSetAdaptor(tadaptee, new Spatial2DGridWrapper(tadaptee.SpatialDefinition as ISpatial2DGrid), "Spatial2DGridWrapper") }
            }
            ;

            if (tadaptee.SpatialDefinition is ISpatialMesh)
            {
                return new IIdentifiable[] { new SpatialExtensionElementSetAdaptor(tadaptee, new SpatialMeshWrapper(tadaptee.SpatialDefinition as ISpatialMesh), "SpatialMeshWrapper") }
            }
            ;

            // Spatial definition is not known, return an empty set.
            return(new IIdentifiable[0]);
        }
        public IIdentifiable[] GetAvailableAdaptedOutputIds(IBaseOutput adaptee, IBaseInput target)
        {
            if (target.Component != _component)
            {
                return(new IIdentifiable[0]);
            }

            List <IIdentifiable> res = new List <IIdentifiable>();

            // TODO: Implement some criteria here
            //if (adaptee and target spatialDefintion equals)
            //{

            res.Add(_identityAdaptor);
            //}
            //else
            //{
            res.AddRange(_spatialAdaptorFactory.GetAvailableAdaptedOutputIds(adaptee, target));
            //}


            return(res.ToArray());
        }
Example #32
0
        public IIdentifiable[] GetAvailableAdaptedOutputIds(IBaseOutput adaptee, IBaseInput target)
        {
            // The time methods in this factory only works on an ITimeSpaceOutput
            ITimeSpaceOutput tsAdaptee = adaptee as ITimeSpaceOutput;

            if (tsAdaptee == null)
            {
                return(new IIdentifiable[0]);
            }

            IIdentifiable[] ids = new IBaseAdaptedOutput[]
            {
                new TimeInterpolator(tsAdaptee),
                new TimeExtrapolator(tsAdaptee),
                new LinearOperationAdaptedOutput(tsAdaptee)
            };

            for (int i = 0; i < ids.Length; i++)
            {
                IBaseAdaptedOutput searchItem = ids[i] as IBaseAdaptedOutput;

                IBaseAdaptedOutput temp = (from n in outputsCreatedSoFar
                                           where searchItem.Id == n.Id && n.Adaptee == searchItem.Adaptee
                                           select n).FirstOrDefault();

                if (temp == null)
                {
                    outputsCreatedSoFar.Add(searchItem);
                }
                else
                {
                    ids[i] = temp;
                }
            }

            return(ids);
        }
 public virtual void RemoveConsumer(IBaseInput consumer)
 {
     Consumers.Remove(consumer);
 }
 public virtual void AddConsumer(IBaseInput consumer)
 {
     Consumers.Add(consumer);
 }
Example #35
0
        public IBaseAdaptedOutput CreateAdaptedOutput(IIdentifiable adaptedOutputIdentifier, IBaseOutput adaptee, IBaseInput target)
        {
            IBaseAdaptedOutput adaptor = adaptedOutputIdentifier as IBaseAdaptedOutput;

            if (adaptor == null)
            {
                throw new ArgumentException("Unknown adaptedOutput type - it does not originate from this factory");
            }
            // Connect the adaptor and the adaptee
            if (!adaptee.AdaptedOutputs.Contains(adaptor))
            {
                adaptee.AddAdaptedOutput(adaptor);
            }
            return(adaptor);
        }
Example #36
0
 public virtual void RemoveConsumer(IBaseInput consumer)
 {
     ITimeSpaceInput timeSpaceConsumer = consumer as ITimeSpaceInput;
     if (timeSpaceConsumer == null || _consumers == null || !_consumers.Contains(timeSpaceConsumer))
     {
         throw new Exception("consumer \"" + consumer.Caption +
             "\" can not be removed from \"" + Caption +
             "\", because it was not added");
     }
     _consumers.Remove(timeSpaceConsumer);
     consumer.Provider = null;
 }
    public IBaseAdaptedOutput CreateAdaptedOutput(IIdentifiable adaptedOutputId, IBaseOutput adaptee, IBaseInput target)
    {
      // TODO: Some usefull criteria here
      if (true)
      {
        // If a MultiInputAdaptor already exists for the target, get that one, otherwise create a new.
        MultiInputAdaptor multiInputAdaptor;
        if (!ExistingMultiInputAdaptors.TryGetValue(target, out multiInputAdaptor))
        {
          multiInputAdaptor = new MultiInputAdaptor("SomeId")
                                  {
                                    SpatialDefinition = ((ITimeSpaceInput)target).SpatialDefinition
                                  };
          multiInputAdaptor.AddConsumer(target);
          ExistingMultiInputAdaptors.Add(target, multiInputAdaptor);
        }

        if (adaptedOutputId == _identityAdaptor)
        {
          // Identity adaptor
          IBaseAdaptedOutput adaptedOutput = multiInputAdaptor.CreateChildAdaptor(adaptee);
          return (adaptedOutput);
        }
        else
        {
          // ElementMapping adaptor
          IBaseAdaptedOutput adaptedOutput = _spatialAdaptorFactory.CreateAdaptedOutput(adaptedOutputId, adaptee, target);
          if (adaptedOutput != null)
          {
            multiInputAdaptor.Adaptees.Add((ITimeSpaceOutputAdder) adaptedOutput);
            return (adaptedOutput);
          }
        }
      }

      return (null);

    }
        public IBaseAdaptedOutput CreateAdaptedOutput(IIdentifiable adaptedOutputId, IBaseOutput adaptee, IBaseInput target)
        {
            MultiInputAdaptor multiInputAdaptor = null;

            if (adaptedOutputId == _identityAdaptor)
            {
                // If a MultiInputAdaptor already exists for the target, get that one, otherwise create a new.
                return(CreateAdaptedOutput(adaptee, target));
            }

            if (multiInputAdaptor == null)
            {
                throw new ArgumentException("Adapted output id could not be found", "adaptedOutputId");
            }

            return(multiInputAdaptor);
        }
        public InputSurrogate(IBaseInput input)
        {
            _inputOriginal = input;

            if (input == null)
            {
                SetDescribes(new Describes("Unspecified Input"));
                ValueDefinition = new ValueDefinition();
                Component = null;
            }
            else
            {
                SetDescribes(input);

                ValueDefinition = input.ValueDefinition;
                Component = input.Component;
            }
        }
 public void RemoveConsumer(IBaseInput consumer)
 {
   throw new NotSupportedException();
 }
        public IBaseAdaptedOutput CreateAdaptedOutput(IIdentifiable adaptedOutputIdentifier, IBaseOutput parentOutput, IBaseInput target)
        {
            IBaseAdaptedOutput adaptedOutput = null;

            if (adaptedOutputIdentifier.Id.Equals(TimeInterpolatorId))
            {
                adaptedOutput = new MeasurementsInterpolator((ITimeSpaceOutput)parentOutput);
            }
            else if (adaptedOutputIdentifier.Id.Equals(TimeExtrapolatorId))
            {
                adaptedOutput = new TimeExtrapolator((ITimeSpaceOutput)parentOutput);
            }
            if (adaptedOutput == null)
            {
                throw new Exception("AdaptedOutput id: " + adaptedOutputIdentifier.Id);
            }

            // connect adaptor and adaptee
            if (!parentOutput.AdaptedOutputs.Contains(adaptedOutput))
            {
                parentOutput.AddAdaptedOutput(adaptedOutput);
            }
            return(adaptedOutput);
        }
    public IIdentifiable[] GetAvailableAdaptedOutputIds(IBaseOutput adaptee, IBaseInput target)
    {
      if (target.Component != _component)
        return (new IIdentifiable[0]);

      List<IIdentifiable> res = new List<IIdentifiable>();

      // TODO: Implement some criteria here
      //if (adaptee and target spatialDefintion equals)
      //{

      res.Add(_identityAdaptor);
      //}
      //else
      //{
      res.AddRange(_spatialAdaptorFactory.GetAvailableAdaptedOutputIds(adaptee, target));
      //}


      return (res.ToArray());
    }