public void RunToTime(ITime time, int outputLinkIndex) { lock (this) { if (_isBusy == false) { //while(IsLater(time,_engineApiAccess.GetCurrentTime())) while (IsLater(time, outputLinkIndex >= 0 ? ((SmartOutputLink)_smartOutputLinks[outputLinkIndex]).GetLastBufferedTime() : _engineApiAccess.GetCurrentTime())) { _isBusy = true; //Update input links foreach (SmartInputLink smartInputLink in _smartInputLinks) { smartInputLink.UpdateInput(); } _isBusy = false; //Perform Timestep if (_engineApiAccess.PerformTimeStep()) { //Update buffer with engine values, Time is timestamp foreach (SmartOutputLink smartOutputLink in _smartOutputLinks) { smartOutputLink.UpdateBuffer(); } SendEvent(EventType.DataChanged); } } } } }
/// <summary> /// Implementation of the same method in /// OpenMI.Standard.ILInkableComponent /// </summary> /// <param name="time">Time (ITimeSpan or ITimeStamp) for which values are requested</param> /// <param name="LinkID">LinkID associated to the requested values</param> /// <returns>The values</returns> public override IValueSet GetValues(ITime time, string LinkID) { try { CheckTimeArgumentInGetvaluesMethod(time); SendSourceAfterGetValuesCallEvent(time, LinkID); IValueSet engineResult = new ScalarSet(); int outputLinkIndex = -999; for (int i = 0; i < _smartOutputLinks.Count; i++) { if (((SmartOutputLink)_smartOutputLinks[i]).link.ID == LinkID) { outputLinkIndex = i; break; } } if (_isBusy == false) { //while(IsLater(time,_engineApiAccess.GetCurrentTime())) while (IsLater(time, ((SmartOutputLink)_smartOutputLinks[outputLinkIndex]).GetLastBufferedTime())) { _isBusy = true; //Update input links foreach (SmartInputLink smartInputLink in _smartInputLinks) { smartInputLink.UpdateInput(); } _isBusy = false; //Perform Timestep if (_engineApiAccess.PerformTimeStep()) { //Update buffer with engine values, Time is timestamp foreach (SmartOutputLink smartOutputLink in _smartOutputLinks) { smartOutputLink.UpdateBuffer(); } SendEvent(EventType.DataChanged); } } } engineResult = ((SmartOutputLink)_smartOutputLinks[outputLinkIndex]).GetValue(time); SendEvent(EventType.SourceBeforeGetValuesReturn); return(engineResult); } catch (System.Exception e) { string message = "Exception in LinkableComponent. ComponentID: "; message += this.ComponentID; throw new System.Exception(message, e); } }