Summary
It will be useful to have Value as a property in the IExchangeItem which can be set, get. Currently the only way to get value is to call GetValues(ITime time, string linkID) from ILinkableComponent.
...
Code Block |
---|
interface ILinkableComponent
{
IList<IExchangeItem> InputItems { get; }
IList<IExchangeItem> OutputItems { get; }
void Update();
}
interface ITimeRunnableComponent : ILinkableComponent
{
void Run(DateTime startTime, DateTime endTime);
DateTime TimeHorizonStart { get; } // component will provide possible min start and max end times
DateTime TimeHorizonEnd { get; }
DateTime CurrentTime { get; } // will change after each run
}
class TimeRunnableComponentTests
{
void RunTimeRunnableComponent()
{
ITimeRunnableComponent c1 = ...;
DateTime t0 = c1.TimeHorizonStart;
TimeSpan duration = new TimeSpan(0, 0, 10); // hours, minutes, seconds
DateTime t1 = t0.Add(duration);
c1.Run(t0, t1);
// check current component time
DateTime currentComponentTime = c1.CurrentTime;
Assert.AreEqual(t1, currentComponentTime);
}
void RunTimeRunnableComponentInGenericWay()
{
// StartTime, EndTime may be wrapped by input exchange items
// which may be even linked to another component, e.g. controls in ComponentRunDialog.
ILinkableComponent c1 = ...;
// assume that 1st and 2nd output exchange items of component equal to time horizon start and end.
DateTime t0 = (DateTime)c1.OutputItems[0].Value;
TimeSpan duration = new TimeSpan(0, 0, 10); // hours, minutes, seconds
DateTime t1 = t0.Add(duration);
// assuming that 1st and 2nd input exchange items of component used as run star and run end times
c1.InputItems[0].Value = t0;
c1.InputItems[1].Value = t1;
c1.Update();
// assume that 3rt output exchange item of component is "current time"
Assert.AreEqual(c1.OutputItems[2].Name, "current time");
// check current component time
DateTime currentComponentTime = (DateTime)c1.OutputItems[2].Value;
Assert.AreEqual(t1, currentTime);
}
}
|
unmigrated-inline-wiki-markup{ |