public void Init()
		{
			exchangeItem = new ExchangeItem();
			exchangeItem.Quantity = new Quantity("Q");
			ElementSet elementSet = new ElementSet();
			elementSet.ID = "ES";
			exchangeItem.ElementSet = elementSet;
		}
Esempio n. 2
0
        ///<summary>
        /// Check if the current instance equals another instance of this class.
        ///</summary>
        ///<param name="obj">The instance to compare the current instance with.</param>
        ///<returns><code>true</code> if the instances are the same instance or have the same content.</returns>
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }
            ExchangeItem item = (ExchangeItem)obj;

            return(item.Quantity.Equals(Quantity) &&
                   item.ElementSet.Equals(ElementSet));
        }
Esempio n. 3
0
        public override ITimeSpaceValueSet GetEngineValues(ExchangeItem exchangeItem)
        {
            IScalarSet    scalarSet = (IScalarSet)_engineApiAccess.GetValues(exchangeItem.ValueDefinition.Caption, exchangeItem.SpatialDefinition.Caption);
            List <double> values    = new List <double>(scalarSet.Count);

            for (int i = 0; i < scalarSet.Count; i++)
            {
                values.Add(scalarSet.GetScalar(i));
            }
            return(new ValueSet(new List <IList> {
                values
            }));
        }
		public void Equals()
		{
			ExchangeItem exchangeItem = new ExchangeItem();
			exchangeItem.Quantity = new Quantity("Q");
			ElementSet elementSet = new ElementSet();
			elementSet.ID = "ES";
			exchangeItem.ElementSet = elementSet;

			Assert.IsTrue(exchangeItem.Equals(this.exchangeItem));

			exchangeItem.Quantity = new Quantity("Q1");
			Assert.IsFalse(exchangeItem.Equals(this.exchangeItem));
			exchangeItem.Quantity = new Quantity("Q");
			elementSet.ID = "ES2";

			Assert.IsFalse(exchangeItem.Equals(this.exchangeItem));
			Assert.IsFalse(exchangeItem.Equals(null));
			Assert.IsFalse(exchangeItem.Equals("string"));
		}
Esempio n. 5
0
        public override IValueSet GetEngineValues(Oatc.OpenMI.Sdk.Backbone.ExchangeItem exchangeItem)
        {
            //--- give output items ---

            IList values = new List <string>();

            if (exchangeItem is EngineInputItem)
            {
                // Input item, provide current input values
                if (exchangeItem == _InputItem)
                {
                    values.Add(_Inpath);
                }
                else
                {
                    throw new ArgumentException("Unknown Exchange Item Id: \"" + exchangeItem.Id + "\"", "exchangeItem");
                }
            }
            else if (exchangeItem is EngineOutputItem)
            {
                // Output item, provide computed values
                if (exchangeItem == _OutputItem)
                {
                    //if (_Outpath == null)
                    //{
                    //if no values exist, then run perform time step to calculate them
                    ICollection <EngineOutputItem> outputs = new Collection <EngineOutputItem>();
                    outputs.Add(_outputExchangeItems[0]);
                    this.PerformTimestep(outputs);

                    if (_Outpath != null)
                    {
                        values.Add(_Outpath);
                    }
                    else
                    {
                        //if output path is still null, try updating inputs
                        _inputExchangeItems[0].Update();
                        //this.ProcessActiveInputItems();
                        this.PerformTimestep(outputs);
                    }

                    if (_Outpath == null)
                    {
                        values.Add(null);
                    }
                    else
                    {
                        values.Add(_Outpath);
                    }
                    //}
                    //else
                    //{
                    //    values.Add(_Outpath);
                    //}
                }
                else
                {
                    throw new ArgumentException("Unknown Exchange Item Id: \"" + exchangeItem.Id + "\"", "exchangeItem");
                }
            }
            else
            {
                throw new Exception("Should be EngineInputItem or EngineOutputItem");
            }
            //clear output
            this._Outpath = null;
            return(new ValueSet(new List <IList> {
                values
            }));
        }