Beispiel #1
0
        public static void CheckValueSizes(ITimeSpaceExchangeItem exchangeItem, ITimeSpaceValueSet valueSet)
        {
            int timesCount = 1;

            if (exchangeItem.TimeSet != null)
            {
                if (exchangeItem.TimeSet.Times != null)
                {
                    timesCount = exchangeItem.TimeSet.Times.Count;
                }
                else
                {
                    timesCount = 0;
                }
            }

            if (ValueSet.GetTimesCount(valueSet) != timesCount)
            {
                throw new Exception("ExchangeItem \"" + exchangeItem.Caption +
                                    "\": Wrong #times in valueSet (" + ValueSet.GetTimesCount(valueSet) + "), expected #times (" + timesCount + ")");
            }

            int elementCount = 1;

            if (exchangeItem.ElementSet() != null)
            {
                elementCount = exchangeItem.ElementSet().ElementCount;
            }
            if (ValueSet.GetElementCount(valueSet) != elementCount)
            {
                throw new Exception("ExchangeItem \"" + exchangeItem.Caption +
                                    "\": Wrong #times in valueSet (" + ValueSet.GetElementCount(valueSet) + "), expected #times (" + elementCount + ")");
            }
        }
 public ExchangeItem(ITimeSpaceExchangeItem item)
     : base(item)
 {
     _id = item.Id;
     if (item.ValueDefinition != null)
     {
         if (item.ValueDefinition is IQuality)
         {
             _valueDefinition = new Quality((IQuality)item.ValueDefinition);
         }
         else
         {
             _valueDefinition = new Quantity((IQuantity)item.ValueDefinition);
         }
     }
     if (item.ElementSet() != null)
     {
         _elementSet = new ElementSet(item.ElementSet());
     }
     if (item.TimeSet != null)
     {
         _timeSet = new TimeSet(item.TimeSet);
     }
     if (item.Component != null)
     {
         _component = new Component(item.Component);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Get the <see cref="IElementSet"/> from the <paramref name="baseitem"/>,
        /// assuming it is a <see cref="ITimeSpaceExchangeItem"/> with an <see cref="IElementSet"/>
        /// as its <see cref="ITimeSpaceExchangeItem.SpatialDefinition"/>. If not, exceptions
        /// are thrown.
        /// </summary>
        public static IElementSet ElementSet(this IBaseExchangeItem baseitem)
        {
            ITimeSpaceExchangeItem item = baseitem as ITimeSpaceExchangeItem;

            if (item == null)
            {
                throw new Exception("base item is not an ITimeSpaceExchangeItem");
            }
            return(item.ElementSet());
        }
Beispiel #4
0
        public static bool OutputAndInputElementSetsFit(ITimeSpaceExchangeItem sourceItem, ITimeSpaceExchangeItem targetItem)
        {
            if (sourceItem == null)
            {
                throw new ArgumentNullException("sourceItem");
            }

            if (targetItem == null)
            {
                throw new ArgumentNullException("targetItem");
            }

            bool        elementSetFits   = true;
            IElementSet sourceElementSet = sourceItem.ElementSet();
            IElementSet targetElementSet = targetItem.ElementSet();

            if (sourceElementSet == null)
            {
                if (targetElementSet != null)
                {
                    // NOTE: Source has no elementset specification, source has.
                    // Source fits target if target requires only one element.
                    elementSetFits = targetElementSet.ElementCount == 1;
                }
            }
            else
            {
                if (targetElementSet == null)
                {
                    // NOTE: Target has no elementset specification, source has.
                    // Source fits target if source has values for only one element available.
                    elementSetFits = sourceElementSet.ElementCount == 1;
                }
                else
                {
                    // Both source and target have an element set specification
                    // If the source is a regular exchange item, the #elements will fit
                    // (has been checked configuration time)

                    // If it is a spatial extension, we need to check if valeus on the newly required
                    // element set can be delivered
                    if (sourceItem is ITimeSpaceAdaptedOutput)
                    {
                        // TODO: Check how we can find out that it is a spatial adaptedOutput.
                        // TODO: If it is, how do we check whether the values on the target element set can be delivered
                    }
                }
            }
            return(elementSetFits);
        }
Beispiel #5
0
      public override ITimeSpaceValueSet GetValues(IBaseExchangeItem querySpecifier)
      {
        ITimeSpaceExchangeItem item = (ITimeSpaceExchangeItem)querySpecifier;

        TimeSet.SetSingleTime(item.TimeSet.Times[0]);

        int count = item.ElementSet().ElementCount;

        double[] vals = new double[count];
        for (int i = 0; i < count; i++)
        {
          vals[i] = ConstOutput;
        }

        ValueSetArray<double> valueset = new ValueSetArray<double>(vals);

        return valueset;

      }
        public static void CheckValueSizes(ITimeSpaceExchangeItem exchangeItem, ITimeSpaceValueSet valueSet)
        {
            int timesCount = 1;
            if (exchangeItem.TimeSet != null)
            {
                if (exchangeItem.TimeSet.Times != null)
                {
                    timesCount = exchangeItem.TimeSet.Times.Count;
                }
                else
                {
                    timesCount = 0;
                }
            }

            if (ValueSet.GetTimesCount(valueSet) != timesCount)
            {
                throw new Exception("ExchangeItem \"" + exchangeItem.Caption +
                    "\": Wrong #times in valueSet (" + ValueSet.GetTimesCount(valueSet) + "), expected #times (" + timesCount + ")");
            }

            int elementCount = 1;
            if (exchangeItem.ElementSet() != null)
            {
                elementCount = exchangeItem.ElementSet().ElementCount;
            }
            if (ValueSet.GetElementCount(valueSet) != elementCount)
            {
                throw new Exception("ExchangeItem \"" + exchangeItem.Caption +
                    "\": Wrong #times in valueSet (" + ValueSet.GetElementCount(valueSet) + "), expected #times (" + elementCount + ")");
            }

        }
        public static bool OutputAndInputElementSetsFit(ITimeSpaceExchangeItem sourceItem, ITimeSpaceExchangeItem targetItem)
        {
            if (sourceItem == null)
            {
                throw new ArgumentNullException("sourceItem");
            }

            if (targetItem == null)
            {
                throw new ArgumentNullException("targetItem");
            }

            bool elementSetFits = true;
            IElementSet sourceElementSet = sourceItem.ElementSet();
            IElementSet targetElementSet = targetItem.ElementSet();
            if (sourceElementSet == null)
            {
                if (targetElementSet != null)
                {
                    // NOTE: Source has no elementset specification, source has.
                    // Source fits target if target requires only one element.
                    elementSetFits = targetElementSet.ElementCount == 1;
                }
            }
            else
            {
                if (targetElementSet == null)
                {
                    // NOTE: Target has no elementset specification, source has.
                    // Source fits target if source has values for only one element available.
                    elementSetFits = sourceElementSet.ElementCount == 1;
                }
                else
                {
                    // Both source and target have an element set specification
                    // If the source is a regular exchange item, the #elements will fit
                    // (has been checked configuration time)

                    // If it is a spatial extension, we need to check if valeus on the newly required
                    // element set can be delivered
                    if (sourceItem is ITimeSpaceAdaptedOutput)
                    {
                        // TODO: Check how we can find out that it is a spatial adaptedOutput.
                        // TODO: If it is, how do we check whether the values on the target element set can be delivered
                    }
                }
            }
            return elementSetFits;
        }