internal static extern IntPtr Instantiate( [MarshalAs(UnmanagedType.LPStr)] string fileName, LogCallback logCallback, StepFinishedCallback stepFinishedCallback, [MarshalAs(UnmanagedType.LPStr)] string instanceName, Fmi2Type fmuType, [MarshalAs(UnmanagedType.LPStr)] string guid, [MarshalAs(UnmanagedType.LPStr)] string resourceLocation, [MarshalAs(UnmanagedType.Bool)] bool visible, [MarshalAs(UnmanagedType.Bool)] bool loggingOn);
/// <summary> /// Instantiates the fmu if it has not been instantiated yet. /// For reinstantiation call Reset or FreeInstance and then Instantiate. /// Throws an exception if the instantiation failed. /// </summary> /// <param name="instanceName"></param> /// <param name="fmuType"></param> /// <param name="guid"></param> /// <param name="resourceLocation"></param> /// <param name="visible"></param> /// <param name="loggingOn"></param> public void Instantiate(string instanceName, Fmi2Type fmuType, string guid, string resourceLocation, bool visible, bool loggingOn) { // Only instantiate if no instance is stored if (wrapper == IntPtr.Zero) { // Load the model instance logCallback = new FmiFunctions.LogCallback(OnLog); stepFinishedCallback = new FmiFunctions.StepFinishedCallback(OnStepFinished); wrapper = FmiFunctions.Instantiate(fileName, logCallback, stepFinishedCallback, instanceName, fmuType, guid, resourceLocation, visible, loggingOn); if (wrapper == IntPtr.Zero) { // Zero is returned when instantiation failed. throw new Exception("Failed to instantiate the fmu instance " + instanceName); } } }