Пример #1
0
		public void IsBefore()
		{
			TimeStamp t_4 = new TimeStamp(4);
			TimeStamp t_7 = new TimeStamp(7);
			Assert.AreEqual(true, Support.IsBefore(t_4,t_7));
			Assert.AreEqual(false, Support.IsBefore(t_7,t_4));
			Assert.AreEqual(false, Support.IsBefore(t_4,t_4));

			Oatc.OpenMI.Sdk.Backbone.TimeSpan t_3_5 = new Oatc.OpenMI.Sdk.Backbone.TimeSpan(new TimeStamp(3),new TimeStamp(5));
			Oatc.OpenMI.Sdk.Backbone.TimeSpan t_4_6 = new Oatc.OpenMI.Sdk.Backbone.TimeSpan(new TimeStamp(4),new TimeStamp(6));
			Oatc.OpenMI.Sdk.Backbone.TimeSpan t_5_7 = new Oatc.OpenMI.Sdk.Backbone.TimeSpan(new TimeStamp(5),new TimeStamp(7));
			Oatc.OpenMI.Sdk.Backbone.TimeSpan t_6_8 = new Oatc.OpenMI.Sdk.Backbone.TimeSpan(new TimeStamp(6),new TimeStamp(8));

			Assert.AreEqual(true,  Support.IsBefore(t_3_5,t_6_8));
			Assert.AreEqual(false, Support.IsBefore(t_6_8, t_3_5));
			Assert.AreEqual(false, Support.IsBefore(t_3_5,t_4_6));
			Assert.AreEqual(false, Support.IsBefore(t_3_5,t_5_7));
			Assert.AreEqual(false, Support.IsBefore(t_3_5,t_3_5));

			Assert.AreEqual(true,  Support.IsBefore(t_4, t_5_7));
			Assert.AreEqual(false, Support.IsBefore(t_4, t_3_5));
			Assert.AreEqual(false, Support.IsBefore(t_7, t_3_5));
			Assert.AreEqual(false, Support.IsBefore(t_4, t_4_6));
			Assert.AreEqual(false, Support.IsBefore(t_7, t_5_7));

			Assert.AreEqual(true,  Support.IsBefore(t_3_5,t_7));
			Assert.AreEqual(false, Support.IsBefore(t_3_5, t_4));
			Assert.AreEqual(false, Support.IsBefore(t_6_8, t_4));
			Assert.AreEqual(false, Support.IsBefore(t_5_7, t_7));

		}
Пример #2
0
        public void IsBefore()
        {
            TimeStamp t_4 = new TimeStamp(4);
            TimeStamp t_7 = new TimeStamp(7);

            Assert.AreEqual(true, Support.IsBefore(t_4, t_7));
            Assert.AreEqual(false, Support.IsBefore(t_7, t_4));
            Assert.AreEqual(false, Support.IsBefore(t_4, t_4));

            Oatc.OpenMI.Sdk.Backbone.TimeSpan t_3_5 = new Oatc.OpenMI.Sdk.Backbone.TimeSpan(new TimeStamp(3), new TimeStamp(5));
            Oatc.OpenMI.Sdk.Backbone.TimeSpan t_4_6 = new Oatc.OpenMI.Sdk.Backbone.TimeSpan(new TimeStamp(4), new TimeStamp(6));
            Oatc.OpenMI.Sdk.Backbone.TimeSpan t_5_7 = new Oatc.OpenMI.Sdk.Backbone.TimeSpan(new TimeStamp(5), new TimeStamp(7));
            Oatc.OpenMI.Sdk.Backbone.TimeSpan t_6_8 = new Oatc.OpenMI.Sdk.Backbone.TimeSpan(new TimeStamp(6), new TimeStamp(8));

            Assert.AreEqual(true, Support.IsBefore(t_3_5, t_6_8));
            Assert.AreEqual(false, Support.IsBefore(t_6_8, t_3_5));
            Assert.AreEqual(false, Support.IsBefore(t_3_5, t_4_6));
            Assert.AreEqual(false, Support.IsBefore(t_3_5, t_5_7));
            Assert.AreEqual(false, Support.IsBefore(t_3_5, t_3_5));

            Assert.AreEqual(true, Support.IsBefore(t_4, t_5_7));
            Assert.AreEqual(false, Support.IsBefore(t_4, t_3_5));
            Assert.AreEqual(false, Support.IsBefore(t_7, t_3_5));
            Assert.AreEqual(false, Support.IsBefore(t_4, t_4_6));
            Assert.AreEqual(false, Support.IsBefore(t_7, t_5_7));

            Assert.AreEqual(true, Support.IsBefore(t_3_5, t_7));
            Assert.AreEqual(false, Support.IsBefore(t_3_5, t_4));
            Assert.AreEqual(false, Support.IsBefore(t_6_8, t_4));
            Assert.AreEqual(false, Support.IsBefore(t_5_7, t_7));
        }
Пример #3
0
		public ITimeSpan GetTimeHorizon()
		{
			TimeStamp startTime = new TimeStamp(Oatc.OpenMI.Sdk.DevelopmentSupport.CalendarConverter.Gregorian2ModifiedJulian(_simulationStart));
			TimeStamp endTime   = new TimeStamp(Oatc.OpenMI.Sdk.DevelopmentSupport.CalendarConverter.Gregorian2ModifiedJulian(_simulationEnd));
			Oatc.OpenMI.Sdk.Backbone.TimeSpan timeHorizon = new Oatc.OpenMI.Sdk.Backbone.TimeSpan(startTime,endTime);
			return timeHorizon;
		}
Пример #4
0
        public ITime GetCurrentTime()
        {
            double t = Oatc.OpenMI.Sdk.DevelopmentSupport.CalendarConverter.Gregorian2ModifiedJulian(_simulationStart);

            t += _currentTimeStepNumber * _timeStepLength / (24.0 * 3600.0);
            Oatc.OpenMI.Sdk.Backbone.TimeSpan currentTime = new Oatc.OpenMI.Sdk.Backbone.TimeSpan(new TimeStamp(t - _timeStepLength / (24.0 * 3600.0)), new TimeStamp(t));
            return(currentTime);
        }
Пример #5
0
        public ITimeSpan GetTimeHorizon()
        {
            TimeStamp startTime = new TimeStamp(Oatc.OpenMI.Sdk.DevelopmentSupport.CalendarConverter.Gregorian2ModifiedJulian(_simulationStart));
            TimeStamp endTime   = new TimeStamp(Oatc.OpenMI.Sdk.DevelopmentSupport.CalendarConverter.Gregorian2ModifiedJulian(_simulationEnd));

            Oatc.OpenMI.Sdk.Backbone.TimeSpan timeHorizon = new Oatc.OpenMI.Sdk.Backbone.TimeSpan(startTime, endTime);
            return(timeHorizon);
        }
        /// <summary>
        /// Creates a new instance of <see cref="Trigger">Trigger</see> class.
        /// </summary>
        public Trigger()
        {
            _link = null;
            _inputExchangeItem = new TriggerExchangeItem();

            Oatc.OpenMI.Sdk.Backbone.TimeStamp
                start = new TimeStamp( CalendarConverter.Gregorian2ModifiedJulian(new DateTime(1800,1,1)) ),
                end = new TimeStamp( CalendarConverter.Gregorian2ModifiedJulian(new DateTime(2200,1,1)) );
            _timeHorizon = new Oatc.OpenMI.Sdk.Backbone.TimeSpan(start, end);

            _earliestInputTime = end;
        }
Пример #7
0
        /// <summary>
        /// Creates a new instance of <see cref="Trigger">Trigger</see> class.
        /// </summary>
        public Trigger()
        {
            _link = null;
            _inputExchangeItem = new TriggerExchangeItem();

            Oatc.OpenMI.Sdk.Backbone.TimeStamp
                start = new TimeStamp(CalendarConverter.Gregorian2ModifiedJulian(new DateTime(1800, 1, 1))),
                end   = new TimeStamp(CalendarConverter.Gregorian2ModifiedJulian(new DateTime(2200, 1, 1)));
            _timeHorizon = new Oatc.OpenMI.Sdk.Backbone.TimeSpan(start, end);

            _earliestInputTime = end;
        }
		public void ITimeToString()
		{
			System.DateTime t1 = new DateTime(2004,7,12,10,25,34);
			System.DateTime t2 = new DateTime(2004,8,15,13,15,14);
			TimeStamp timeStamp1 = new TimeStamp(Oatc.OpenMI.Sdk.DevelopmentSupport.CalendarConverter.Gregorian2ModifiedJulian(t1));
			TimeStamp timeStamp2 = new TimeStamp(Oatc.OpenMI.Sdk.DevelopmentSupport.CalendarConverter.Gregorian2ModifiedJulian(t2));
			Oatc.OpenMI.Sdk.Backbone.TimeSpan timeSpan = new Oatc.OpenMI.Sdk.Backbone.TimeSpan(timeStamp1,timeStamp2);

			Assert.AreEqual(t1.ToString(),LinkableRunEngine.ITimeToString(timeStamp1));
			string str = "[" + t1.ToString()+", "+t2.ToString()+"]";
			Assert.AreEqual(str, LinkableRunEngine.ITimeToString(timeSpan));

		}
		public void TimeToTimeStamp()
		{
			Oatc.OpenMI.Sdk.Backbone.TimeSpan timeSpan = new Oatc.OpenMI.Sdk.Backbone.TimeSpan(new TimeStamp(10.0),new TimeStamp(20.0));
			Oatc.OpenMI.Sdk.Backbone.TimeStamp timeStamp = new TimeStamp(15.0);

			Assert.AreEqual(20.0, LinkableRunEngine.TimeToTimeStamp(timeSpan).ModifiedJulianDay);
			Assert.AreEqual(15.0, LinkableRunEngine.TimeToTimeStamp(timeStamp).ModifiedJulianDay);
		}
Пример #10
0
		public void Constructor ()
		{
			TimeSpan timeSpan2 = new TimeSpan(timeSpan);
			Assert.AreEqual(timeSpan,timeSpan2);
		}
Пример #11
0
		public void Init()
		{	
			timeSpan = new TimeSpan(new TimeStamp(1.0),new TimeStamp(2.0));
		}
        public void Initialize(System.Collections.Hashtable properties)
        {
            //check if the input arg are and Input or Output Exchange Item
            if (properties.ContainsKey("InputExchangeItem"))
            {
                //get the input quantity and element set ids
                string value = properties["InputExchangeItem"].ToString();
                //save them
                if (_inputExchangeItems.ContainsKey(value.Split(',')[0]))
                {
                    _inputExchangeItems[value.Split(',')[0]].Add(value.Split(',')[1]);
                }
                else
                {
                    _inputExchangeItems.Add(value.Split(',')[0], new List <string>()
                    {
                        value.Split(',')[1]
                    });
                }

                ////get the output quantity and element set ids
                //value = properties["OutputExchangeItem"].ToString();
                ////save them
                //_outputExchangeItems.Add["OutputExchangeItem

                //get the time horizon info
                Oatc.OpenMI.Sdk.Backbone.TimeSpan timehorizon = (Oatc.OpenMI.Sdk.Backbone.TimeSpan)properties["TimeHorizon"];
                //adjust the start and end times
                if (timehorizon.Start.ModifiedJulianDay > start)
                {
                    start = timehorizon.Start.ModifiedJulianDay;
                }
                if (timehorizon.End.ModifiedJulianDay < end)
                {
                    end = timehorizon.End.ModifiedJulianDay;
                }


                Link l = (Link)properties["Link"];
                //get the link info
                _links.Add(l.ID, l);

                ////get the link info
                //_links.Add(value.Split(',')[0] + ":" + value.Split(',')[1], (Link)properties["Link"]);
            }
            else
            {
                //get the quantity and element set ids
                string value = properties["OutputExchangeItem"].ToString();

                if (value.Contains(':')) //output defined in omi or config file
                {
                    string elementSet = value.Split(':')[0];
                    string quantity   = value.Split(':')[1];
                    //save them
                    if (_outputExchangeItems.ContainsKey(quantity))
                    {
                        _outputExchangeItems[quantity].Add(elementSet);
                    }
                    else
                    {
                        _outputExchangeItems.Add(quantity, new List <string>()
                        {
                            elementSet
                        });
                    }
                }
                else //ouput defined by links
                {
                    //save them
                    if (_outputExchangeItems.ContainsKey(value.Split(',')[0]))
                    {
                        _outputExchangeItems[value.Split(',')[0]].Add(value.Split(',')[1]);
                    }
                    else
                    {
                        _outputExchangeItems.Add(value.Split(',')[0], new List <string>()
                        {
                            value.Split(',')[1]
                        });
                    }

                    Link l = (Link)properties["Link"];
                    //get the link info
                    _links.Add(l.ID, l);
                }
            }
        }
        public override void AddLink(ILink link)
        {
            base.AddLink(link);

            //save the link
            //

            //get the id of the target element set
            string id = link.TargetElementSet.ID;

            //get the corresponding input and output exchange item index
            int inIndex = 0; int outIndex = 0;

            for (int i = 0; i <= _inputExchangeItems.Count - 1; i++)
            {
                if (_inputExchangeItems[i].ElementSet.ID == id)
                {
                    inIndex = i; break;
                }
            }
            for (int i = 0; i <= _outputExchangeItems.Count - 1; i++)
            {
                if (_outputExchangeItems[i].ElementSet.ID == id)
                {
                    outIndex = i; break;
                }
            }

            //update input and output exchange item elementsets and quantities
            //Unit u = new Unit();

            //u.Description = link.SourceQuantity.Unit.Description;
            //u.ID = link.SourceQuantity.Unit.ID;

            Quantity q = new Quantity();

            q = (Quantity)link.SourceQuantity;
            //q.Description = link.SourceQuantity.Description;
            //q.ID = link.SourceQuantity.ID;
            //q.ValueType = link.SourceQuantity.ValueType;
            //q.Unit = link.SourceQuantity.Unit;

            ElementSet eset = new ElementSet();

            //eset.Description = link.SourceElementSet.Description;
            //eset.ID = link.SourceElementSet.ID;
            //eset.ElementType = link.SourceElementSet.ElementType;
            eset = (ElementSet)link.SourceElementSet;

            //HACK:  Right now this assumes there is only one outputexchangeitem!
            //HACK:  Also assumes that the output elementset will contain the same elements as the element set of the first link
            //check to see if the output exchange item has been defined yet
            if (_outputExchangeItems[0].ElementSet.GetElementID(0) == "Empty")
            {
                OutputExchangeItem Output = (OutputExchangeItem)_outputExchangeItems[0];
                //Quantity OutputQ = (Quantity)Output.Quantity;
                ElementSet OutputE = (ElementSet)Output.ElementSet;
                OutputE.ElementType = eset.ElementType;

                //int min = 100000;
                //int index = 0;
                //for (int o = 0; o <= _inputExchangeItems.Count - 1; o++)
                //    if (_inputExchangeItems[o].ElementSet != OutputE)
                //        if (_inputExchangeItems[o].ElementSet.ElementCount < min)
                //        {
                //            min = _inputExchangeItems[o].ElementSet.ElementCount;
                //            index = o;
                //        }


                Element e = OutputE.GetElement(0);
                e.ID = eset.GetElementID(0);
                Vertex v = new Vertex();
                e.Vertices[0].x = eset.GetXCoordinate(0, 0);
                e.Vertices[0].y = eset.GetYCoordinate(0, 0);
                //e.AddVertex(v);

                for (int o = 1; o <= eset.Elements.Length - 1; o++)
                {
                    e   = new Element(eset.GetElementID(o));
                    v   = new Vertex();
                    v.x = eset.GetXCoordinate(o, 0);
                    v.y = eset.GetYCoordinate(o, 0);
                    e.AddVertex(v);
                    OutputE.AddElement(e);
                }

                Output.ElementSet = OutputE;
                //_outputExchangeItems.Add(output);
            }

            //generate an output exchange item based on the input its getting
            OutputExchangeItem output = new OutputExchangeItem();

            output.Quantity   = q;
            output.ElementSet = eset;
            if (!_outputExchangeItems.Contains(output))
            {
                eset.Description  = "Time Matched: " + output.Quantity.ID;
                output.ElementSet = eset;
                _outputExchangeItems.Add(output);
            }

            //create a link to reflect the info we're getting from the source component
            Link l = new Link();

            l.ID = link.ID;
            l.SourceComponent  = link.SourceComponent;
            l.SourceElementSet = link.SourceElementSet;
            l.SourceQuantity   = link.SourceQuantity;
            l.TargetComponent  = link.TargetComponent;
            l.TargetElementSet = eset;
            l.TargetQuantity   = q;

            //get the earliest time (this will determine a start time based on source component, unless one is provided in the omi)
            if (this.start == -999)
            {
                if (_currentTime < l.SourceComponent.TimeHorizon.Start.ModifiedJulianDay)
                {
                    _currentTime = l.SourceComponent.TimeHorizon.Start.ModifiedJulianDay;
                }
            }

            //add updated link instead of the placeholder one
            _links.Add(link.ID, l);

            //Subscribe to events


            System.Collections.Hashtable hashtable = new Hashtable();
            if (link.SourceComponent != this)
            {
                ////get the exchange item info
                //string value = link.SourceQuantity.ID + "," + link.SourceElementSet.ID;
                //hashtable.Add("OutputExchangeItem", value);

                string value = link.TargetQuantity.ID + "," + link.TargetElementSet.ID;
                hashtable.Add("InputExchangeItem", value);

                //add the time horizon info
                hashtable.Add("TimeHorizon", link.SourceComponent.TimeHorizon);

                //add the link info
                hashtable.Add("Link", link);

                //pass this info to the IRunEngine, via Intitialize
                _engineApiAccess.Initialize(hashtable);

                //set the time horizon for the LinkableRunEngine
                Oatc.OpenMI.Sdk.Backbone.TimeSpan timehorizon = (Oatc.OpenMI.Sdk.Backbone.TimeSpan)link.SourceComponent.TimeHorizon;
                if (timehorizon.Start.ModifiedJulianDay > start)
                {
                    start = timehorizon.Start.ModifiedJulianDay;
                }
                if (timehorizon.End.ModifiedJulianDay < end)
                {
                    end = timehorizon.End.ModifiedJulianDay;
                }
            }
            else
            {
                //get the exchange item info
                string value = link.SourceQuantity.ID + "," + link.SourceElementSet.ID;
                hashtable.Add("OutputExchangeItem", value);

                //add the link info
                hashtable.Add("Link", link);

                //pass this info to the IRunEngine, via Intitialize
                _engineApiAccess.Initialize(hashtable);

                //lc = link.TargetComponent;
            }
        }
Пример #14
0
		public void ClearAfter()
		{
			SmartBuffer smartBuffer = new SmartBuffer();
			smartBuffer.DoExtendedDataVerification = true;

			// --Populate the SmartBuffer --
			smartBuffer.AddValues(new TimeStamp(10), new ScalarSet(new double[2] {11, 21}));
			smartBuffer.AddValues(new TimeStamp(13), new ScalarSet(new double[2] {12 ,22}));
			smartBuffer.AddValues(new TimeStamp(16), new ScalarSet(new double[2] {13 ,23}));
			smartBuffer.AddValues(new TimeStamp(20), new ScalarSet(new double[2] {14 ,24}));
			smartBuffer.AddValues(new TimeStamp(27), new ScalarSet(new double[2] {15 ,25}));
			smartBuffer.AddValues(new TimeStamp(30), new ScalarSet(new double[2] {16, 26}));
			smartBuffer.AddValues(new TimeStamp(48), new ScalarSet(new double[2] {17, 27}));

            Oatc.OpenMI.Sdk.Backbone.TimeStamp time = new Oatc.OpenMI.Sdk.Backbone.TimeStamp();

			time.ModifiedJulianDay = 50; // this time is after the last time in buffer
			smartBuffer.ClearAfter(time);
			Assert.AreEqual(7,smartBuffer.TimesCount);  //nothing removed
			Assert.AreEqual(11,((IScalarSet) smartBuffer.GetValuesAt(0)).GetScalar(0));
			Assert.AreEqual(27,((IScalarSet) smartBuffer.GetValuesAt(6)).GetScalar(1));

			time.ModifiedJulianDay = 30;
			smartBuffer.ClearAfter(time);
			Assert.AreEqual(5,smartBuffer.TimesCount);
			Assert.AreEqual(11,((IScalarSet) smartBuffer.GetValuesAt(0)).GetScalar(0));
			Assert.AreEqual(25,((IScalarSet) smartBuffer.GetValuesAt(4)).GetScalar(1));

			time.ModifiedJulianDay = 16.5;
			smartBuffer.ClearAfter(time);
			Assert.AreEqual(3,smartBuffer.TimesCount);
			Assert.AreEqual(11,((IScalarSet) smartBuffer.GetValuesAt(0)).GetScalar(0));
			Assert.AreEqual(23,((IScalarSet) smartBuffer.GetValuesAt(2)).GetScalar(1));

			time.ModifiedJulianDay = 9;
			smartBuffer.ClearAfter(time);
			Assert.AreEqual(0,smartBuffer.TimesCount);

			time.ModifiedJulianDay = 9;
			smartBuffer.ClearAfter(time);
			Assert.AreEqual(0,smartBuffer.TimesCount);

			smartBuffer.AddValues(new TimeStamp(10), new ScalarSet(new double[2] {11, 21}));
			smartBuffer.AddValues(new TimeStamp(13), new ScalarSet(new double[2] {12 ,22}));
			smartBuffer.AddValues(new TimeStamp(16), new ScalarSet(new double[2] {13 ,23}));
			smartBuffer.AddValues(new TimeStamp(20), new ScalarSet(new double[2] {14 ,24}));
			smartBuffer.AddValues(new TimeStamp(27), new ScalarSet(new double[2] {15 ,25}));
			smartBuffer.AddValues(new TimeStamp(30), new ScalarSet(new double[2] {16, 26}));
			smartBuffer.AddValues(new TimeStamp(48), new ScalarSet(new double[2] {17, 27}));

			Oatc.OpenMI.Sdk.Backbone.TimeStamp start   = new Oatc.OpenMI.Sdk.Backbone.TimeStamp(50);
			Oatc.OpenMI.Sdk.Backbone.TimeStamp end     = new Oatc.OpenMI.Sdk.Backbone.TimeStamp(55);
			Oatc.OpenMI.Sdk.Backbone.TimeSpan timeSpan = new Oatc.OpenMI.Sdk.Backbone.TimeSpan(start,end);

			start.ModifiedJulianDay = 50; // this time is after the last time in buffer
			smartBuffer.ClearAfter(timeSpan);
			Assert.AreEqual(7,smartBuffer.TimesCount);  //nothing removed
			Assert.AreEqual(11,((IScalarSet) smartBuffer.GetValuesAt(0)).GetScalar(0));
			Assert.AreEqual(27,((IScalarSet) smartBuffer.GetValuesAt(6)).GetScalar(1));

			start.ModifiedJulianDay = 30;
			smartBuffer.ClearAfter(timeSpan);
			Assert.AreEqual(5,smartBuffer.TimesCount);
			Assert.AreEqual(11,((IScalarSet) smartBuffer.GetValuesAt(0)).GetScalar(0));
			Assert.AreEqual(25,((IScalarSet) smartBuffer.GetValuesAt(4)).GetScalar(1));

			start.ModifiedJulianDay = 16.5;
			smartBuffer.ClearAfter(timeSpan);
			Assert.AreEqual(3,smartBuffer.TimesCount);
			Assert.AreEqual(11,((IScalarSet) smartBuffer.GetValuesAt(0)).GetScalar(0));
			Assert.AreEqual(23,((IScalarSet) smartBuffer.GetValuesAt(2)).GetScalar(1));

			start.ModifiedJulianDay = 9;
			smartBuffer.ClearAfter(timeSpan);
			Assert.AreEqual(0,smartBuffer.TimesCount);

			start.ModifiedJulianDay = 9;
			smartBuffer.ClearAfter(timeSpan);
			Assert.AreEqual(0,smartBuffer.TimesCount);

			smartBuffer.AddValues(new Oatc.OpenMI.Sdk.Backbone.TimeSpan(new TimeStamp(10),new TimeStamp(13)), new ScalarSet(new double[2] {11, 21}));
			smartBuffer.AddValues(new Oatc.OpenMI.Sdk.Backbone.TimeSpan(new TimeStamp(13),new TimeStamp(16)), new ScalarSet(new double[2] {12, 22}));
			smartBuffer.AddValues(new Oatc.OpenMI.Sdk.Backbone.TimeSpan(new TimeStamp(16),new TimeStamp(20)), new ScalarSet(new double[2] {13, 23}));
			smartBuffer.AddValues(new Oatc.OpenMI.Sdk.Backbone.TimeSpan(new TimeStamp(20),new TimeStamp(27)), new ScalarSet(new double[2] {14, 24}));
			smartBuffer.AddValues(new Oatc.OpenMI.Sdk.Backbone.TimeSpan(new TimeStamp(27),new TimeStamp(30)), new ScalarSet(new double[2] {15, 25}));
			smartBuffer.AddValues(new Oatc.OpenMI.Sdk.Backbone.TimeSpan(new TimeStamp(30),new TimeStamp(48)), new ScalarSet(new double[2] {16, 26}));
			smartBuffer.AddValues(new Oatc.OpenMI.Sdk.Backbone.TimeSpan(new TimeStamp(48),new TimeStamp(55)), new ScalarSet(new double[2] {17, 27}));

			
			time.ModifiedJulianDay = 50; // this time is after the last time in buffer
			smartBuffer.ClearAfter(time);
			Assert.AreEqual(7,smartBuffer.TimesCount);  //nothing removed
			Assert.AreEqual(11,((IScalarSet) smartBuffer.GetValuesAt(0)).GetScalar(0));
			Assert.AreEqual(27,((IScalarSet) smartBuffer.GetValuesAt(6)).GetScalar(1));

			time.ModifiedJulianDay = 30;
			smartBuffer.ClearAfter(time);
			Assert.AreEqual(5,smartBuffer.TimesCount);
			Assert.AreEqual(11,((IScalarSet) smartBuffer.GetValuesAt(0)).GetScalar(0));
			Assert.AreEqual(25,((IScalarSet) smartBuffer.GetValuesAt(4)).GetScalar(1));

			time.ModifiedJulianDay = 16.5;
			smartBuffer.ClearAfter(time);
			Assert.AreEqual(3,smartBuffer.TimesCount);
			Assert.AreEqual(11,((IScalarSet) smartBuffer.GetValuesAt(0)).GetScalar(0));
			Assert.AreEqual(23,((IScalarSet) smartBuffer.GetValuesAt(2)).GetScalar(1));

			time.ModifiedJulianDay = 9;
			smartBuffer.ClearAfter(time);
			Assert.AreEqual(0,smartBuffer.TimesCount);

			time.ModifiedJulianDay = 9;
			smartBuffer.ClearAfter(time);
			Assert.AreEqual(0,smartBuffer.TimesCount);

			smartBuffer.AddValues(new Oatc.OpenMI.Sdk.Backbone.TimeSpan(new TimeStamp(10),new TimeStamp(13)), new ScalarSet(new double[2] {11, 21}));
			smartBuffer.AddValues(new Oatc.OpenMI.Sdk.Backbone.TimeSpan(new TimeStamp(13),new TimeStamp(16)), new ScalarSet(new double[2] {12, 22}));
			smartBuffer.AddValues(new Oatc.OpenMI.Sdk.Backbone.TimeSpan(new TimeStamp(16),new TimeStamp(20)), new ScalarSet(new double[2] {13, 23}));
			smartBuffer.AddValues(new Oatc.OpenMI.Sdk.Backbone.TimeSpan(new TimeStamp(20),new TimeStamp(27)), new ScalarSet(new double[2] {14, 24}));
			smartBuffer.AddValues(new Oatc.OpenMI.Sdk.Backbone.TimeSpan(new TimeStamp(27),new TimeStamp(30)), new ScalarSet(new double[2] {15, 25}));
			smartBuffer.AddValues(new Oatc.OpenMI.Sdk.Backbone.TimeSpan(new TimeStamp(30),new TimeStamp(48)), new ScalarSet(new double[2] {16, 26}));
			smartBuffer.AddValues(new Oatc.OpenMI.Sdk.Backbone.TimeSpan(new TimeStamp(48),new TimeStamp(55)), new ScalarSet(new double[2] {17, 27}));

			start.ModifiedJulianDay = 50; // this time is after the last time in buffer
			smartBuffer.ClearAfter(timeSpan);
			Assert.AreEqual(7,smartBuffer.TimesCount);  //nothing removed
			Assert.AreEqual(11,((IScalarSet) smartBuffer.GetValuesAt(0)).GetScalar(0));
			Assert.AreEqual(27,((IScalarSet) smartBuffer.GetValuesAt(6)).GetScalar(1));

			start.ModifiedJulianDay = 30;
			smartBuffer.ClearAfter(timeSpan);
			Assert.AreEqual(5,smartBuffer.TimesCount);
			Assert.AreEqual(11,((IScalarSet) smartBuffer.GetValuesAt(0)).GetScalar(0));
			Assert.AreEqual(25,((IScalarSet) smartBuffer.GetValuesAt(4)).GetScalar(1));

			start.ModifiedJulianDay = 16.5;
			smartBuffer.ClearAfter(timeSpan);
			Assert.AreEqual(3,smartBuffer.TimesCount);
			Assert.AreEqual(11,((IScalarSet) smartBuffer.GetValuesAt(0)).GetScalar(0));
			Assert.AreEqual(23,((IScalarSet) smartBuffer.GetValuesAt(2)).GetScalar(1));

			start.ModifiedJulianDay = 9;
			smartBuffer.ClearAfter(timeSpan);
			Assert.AreEqual(0,smartBuffer.TimesCount);

			start.ModifiedJulianDay = 9;
			smartBuffer.ClearAfter(timeSpan);
			Assert.AreEqual(0,smartBuffer.TimesCount);
		}
Пример #15
0
		public ITime GetCurrentTime()
		{
			double t = Oatc.OpenMI.Sdk.DevelopmentSupport.CalendarConverter.Gregorian2ModifiedJulian(_simulationStart);
			t += _currentTimeStepNumber * _timeStepLength / (24.0*3600.0);
			Oatc.OpenMI.Sdk.Backbone.TimeSpan currentTime = new Oatc.OpenMI.Sdk.Backbone.TimeSpan(new TimeStamp(t - _timeStepLength / (24.0*3600.0)),new TimeStamp(t));
			return currentTime;
		}