示例#1
0
        public void Finish()
        {
            if (!(SimpleRiverEngineDllAccess.Finish()))
            {
                CreateAndThrowException();
            }

            while (Kernel32Wrapper.FreeLibrary(_fortranDllHandle))
            {
            }

            _fortranDllHandle = (IntPtr)0;
        }
示例#2
0
        public void Initialize(string filePath, string simFileName)
        {
            string enginedll  = @"Oatc.OpenMI.Examples.ModelComponents.SimpleRiver.Engine.dll";
            string enginePath = enginedll;

            Trace.TraceInformation("Looking for engineDll: {0}", enginePath);

            if (!File.Exists(enginePath))
            {
                // ADH: Why did this work before?

                string folder = Directory.GetParent(
                    Assembly.GetAssembly(GetType()).Location).FullName;

                enginePath = Path.Combine(folder, enginedll);

                Trace.TraceInformation("Looking for engineDll: {0}", enginePath);

                if (!File.Exists(enginePath))
                {
                    throw new SimpleRiverException("Cannot find dll " + enginedll);
                }
            }

            _fortranDllHandle = Kernel32Wrapper.LoadLibrary(enginePath);

            if (_fortranDllHandle.ToInt32() == 0)
            {
                throw new SimpleRiverException("Failed fortran dll load " + enginedll);
            }

            string curDir = System.IO.Directory.GetCurrentDirectory();

            if (!(SimpleRiverEngineDllAccess.SetSimFileName(simFileName, ((uint)simFileName.Length))))
            {
                CreateAndThrowException();
            }
            if (!(SimpleRiverEngineDllAccess.Initialize(filePath, ((uint)filePath.Length))))
            {
                CreateAndThrowException();
            }
        }