public override void Initialize() { Hashtable hashtable = new Hashtable(); for (int i = 0; i < Arguments.Count; i++) { hashtable.Add(Arguments[i].Id, Arguments[i].Value); } SetEngineApiAccess(); if (_engineApiAccess == null) { throw new Exception("Failed to assign the engine"); } _engineApiAccess.Initialize(hashtable); for (int i = 0; i < _engineApiAccess.GetInputExchangeItemCount(); i++) { // TODO: How important is the IQuantity quantity = _engineApiAccess.GetInputExchangeItem(i).Quantity; IElementSet elementSet = _engineApiAccess.GetInputExchangeItem(i).ElementSet; String inputItemID = elementSet.Caption + "." + quantity.Caption; InputItem inputItem = new InputItem(_engineApiAccess, inputItemID); inputItem.ValueDefinition = quantity; inputItem.SpatialDefinition = elementSet; Inputs.Add(inputItem); } for (int i = 0; i < _engineApiAccess.GetOutputExchangeItemCount(); i++) { IQuantity quantity = _engineApiAccess.GetOutputExchangeItem(i).Quantity; IElementSet elementSet = _engineApiAccess.GetOutputExchangeItem(i).ElementSet; String outputItemID = elementSet.Caption + "." + quantity.Caption; OutputItem outputItem = new OutputItem(_engineApiAccess, outputItemID); outputItem.ValueDefinition = quantity; outputItem.SpatialDefinition = elementSet; Outputs.Add(outputItem); } foreach (InputItem inputItem in Inputs) { TimeSet timeset = new TimeSet(); timeset.Times.Add(TimeHelper.ConvertTime(_engineApiAccess.GetCurrentTime())); inputItem.TimeSet = timeset; // TODO inputItem.TimeSet = TimeSet for input item; } foreach (OutputItem outputItem in Outputs) { TimeSet timeset = new TimeSet(); timeset.Times.Add(TimeHelper.ConvertTime(_engineApiAccess.GetCurrentTime())); outputItem.TimeSet = timeset; } _initializeWasInvoked = true; Status = LinkableComponentStatus.Initialized; }
public override ITime GetInputTime(bool asStamp) { if (!asStamp) { throw new NotSupportedException(); } ITime time; Oatc.UpwardsComp.Standard.ITime time1_4 = _engineApiAccess.GetCurrentTime(); // A 1.4 component may return a time interval where the start time is the current time if (time1_4 is Oatc.UpwardsComp.Standard.ITimeSpan) { time = TimeHelper.ConvertTime(((Oatc.UpwardsComp.Standard.ITimeSpan)time1_4).End); } else { time = TimeHelper.ConvertTime(time1_4); } return(time); }
public override void Initialize() { Status = LinkableComponentStatus.Initializing; Hashtable hashtable = new Hashtable(); for (int i = 0; i < Arguments.Count; i++) { hashtable.Add(Arguments[i].Caption, Arguments[i].Value); } if (_engineApiAccess == null) { throw new Exception("Failed to assign the engine"); } _engineApiAccess.Initialize(hashtable); //foreach (InputItem inputItem in inputItems) //{ // TimeSet timeset = new TimeSet(); // timeset.Times.Add(TimeHelper.ConvertTime(_engineApiAccess.GetCurrentTime())); // inputItem.TimeSet = timeset; // // TODO inputItem.TimeSet = TimeSet for input item; //} //foreach (OutputItem outputItem in outputItems) //{ // TimeSet timeset = new TimeSet(); // timeset.Times.Add(TimeHelper.ConvertTime(_engineApiAccess.GetCurrentTime())); // outputItem.TimeSet = timeset; //} Id = _engineApiAccess.GetModelID(); Description = _engineApiAccess.GetModelDescription(); for (int i = 0; i < _engineApiAccess.GetOutputExchangeItemCount(); i++) { OutputExchangeItem output = _engineApiAccess.GetOutputExchangeItem(i); IQuantity quantity = output.Quantity; IElementSet elementSet = output.ElementSet(); String outputItemId = string.IsNullOrEmpty(output.Id) ? elementSet.Caption + ":" + quantity.Caption : output.Id; EngineOutputItem outputItem = new EngineEOutputItem(outputItemId, quantity, elementSet, this); outputItem.TimeSet.SetSingleTime(TimeHelper.ConvertTime(_engineApiAccess.GetTimeHorizon().Start)); outputItem.TimeSet.SetTimeHorizon(TimeHelper.ConvertTime(_engineApiAccess.GetTimeHorizon())); EngineOutputItems.Add(outputItem); } for (int i = 0; i < _engineApiAccess.GetInputExchangeItemCount(); i++) { InputExchangeItem input = _engineApiAccess.GetInputExchangeItem(i); IQuantity quantity = input.Quantity; IElementSet elementSet = input.ElementSet(); String inputItemId = string.IsNullOrEmpty(input.Id) ? elementSet.Caption + ":" + quantity.Caption : input.Id; EngineInputItem inputItem = new EngineEInputItem(inputItemId, quantity, elementSet, this); inputItem.TimeSet.SetSingleTime(TimeHelper.ConvertTime(_engineApiAccess.GetTimeHorizon().Start)); inputItem.TimeSet.SetTimeHorizon(TimeHelper.ConvertTime(_engineApiAccess.GetTimeHorizon())); EngineInputItems.Add(inputItem); } Status = LinkableComponentStatus.Initialized; _initializeWasInvoked = true; }