public void PrePrepare( LinkableComponentOpenMIV1Wrapper component2, IExternalType component1ExternalType, double startTime, double updateLinkTimeIncrement, List<IBaseInput> activeInputs, List<IBaseOutput> activeOutputs) { Type tComponentV1; Component1 = component1ExternalType.CreateInstance(out tComponentV1) as OpenMI.Standard.ILinkableComponent; if (Component1 == null) throw new Exception("Cannot instantiate " + component1ExternalType.ToString()); Component1.Initialize(component2.Arguments1.ToArray()); _currentTime = startTime; _updateLinkTimeIncrement = updateLinkTimeIncrement; // Create internal links between components 1 and 2 // T2 --> T1 // S1 --> S2 Utilities.Standard1.TimeSpan timeHorizon1 = new Utilities.Standard1.TimeSpan(component2.TimeExtent.TimeHorizon); OpenMI.Standard.IInputExchangeItem input; OpenMI.Standard.IOutputExchangeItem output; OpenMI.Standard.ILink internalLink; ITimeSpaceExchangeItem itemTimeSpace; string idQuantity, idElementSet; activeInputs.ForEach(i => { idQuantity = i.ValueDefinition.Caption; itemTimeSpace = i as ITimeSpaceExchangeItem; idElementSet = itemTimeSpace == null ? i.Caption // what else? : itemTimeSpace.SpatialDefinition.Caption; internalLink = null; for (int n = 0; n < _component1.InputExchangeItemCount; ++n) { input = _component1.GetInputExchangeItem(n); if (input.Quantity.ID != idQuantity || input.ElementSet.ID != idElementSet) continue; var isVector = input.Quantity.ValueType == OpenMI.Standard.ValueType.Vector; // Get providers convertot to use directly Contract.Requires(i.Provider is IHasValueSetConvertor, "i.Provider is IHasValueSetConvertor"); var convertorProvider = ((IHasValueSetConvertor)i.Provider).ValueSetConverter as IValueSetConverterTime; Contract.Requires(convertorProvider != null, "i.Provider.ValueSetConverter is IValueSetConverterTime"); internalLink = new Utilities.Standard1.InternalLink( _component1, input, timeHorizon1, convertorProvider, isVector); _linksIn.Add(internalLink); _component1.AddLink(internalLink); break; } if (internalLink == null) throw new Exception(string.Format( "OpenMI.Standard.IOutputExchangeItem not found with Qualtity,ElementSet ids if \"{0}\",\"{1}\"", idQuantity, idElementSet)); }); activeOutputs.ForEach(o => { idQuantity = o.ValueDefinition.Caption; itemTimeSpace = o as ITimeSpaceExchangeItem; idElementSet = itemTimeSpace == null ? o.Caption // what else? : itemTimeSpace.SpatialDefinition.Caption; internalLink = null; for (int n = 0; n < _component1.OutputExchangeItemCount; ++n) { output = _component1.GetOutputExchangeItem(n); if (output.Quantity.ID != idQuantity || output.ElementSet.ID != idElementSet) continue; internalLink = new Utilities.Standard1.InternalLink(_component1, output, timeHorizon1); _linksOut.Add(internalLink); _component1.AddLink(internalLink); if (((IHasValueSetConvertor)o).ValueSetConverter is ValueSetConverterTimeEngineDoubleStandard1) { var convertor = (ValueSetConverterTimeEngineDoubleStandard1)((IHasValueSetConvertor)o).ValueSetConverter; //convertor.SetRuntime(this, internalLink); } else if (((IHasValueSetConvertor)o).ValueSetConverter is ValueSetConverterTimeEngineDoubleVector3dStandard1) { var convertor = (ValueSetConverterTimeEngineDoubleVector3dStandard1)((IHasValueSetConvertor)o).ValueSetConverter; //convertor.SetRuntime(this, internalLink); } else throw new Exception("o.ValueSetConverter as ValueSetConverterTimeEngineDouble?"); break; } if (internalLink == null) throw new Exception(string.Format( "OpenMI.Standard.IInputExchangeItem not found with Qualtity,ElementSet ids if \"{0}\",\"{1}\"", idQuantity, idElementSet)); }); if (_linksOut.Count < 1) throw new Exception("At least one output link must be specified"); }