4.5 Step 5: Implementing the MyEngineWrapper class

The fifth step is to implement the MyEngineWrapper class (Figure 11).


Figure 11

The MyEngineWrapper class must implement the IEngine interface (Oatc.OpenMI.Sdk.Wrapper.IEngine). The easiest way to get started is to make your development environment auto-generate the stub code for this interface.

The first step is to implement the Initialize method and the Finish method.

The MyEngineWrapper has a private field variable (_myEngine) that holds a reference to the MyEngineDotNetAccess class. The Initialize method will instantiate the MyEngineDotNetAcccess object and assign a reference to this object to the _myEngine variable.

Example code for this is shown below.

using System;
using System.Collections;
using OpenMI.Standard;
using Oatc.OpenMI.Sdk.Backbone;
using Oatc.OpenMI.Sdk.Wrapper;


namespace Oatc.OpenMI.Examples.ModelComponents.SimpleRiver.Wrapper
{
	public class SimpleRiverEngineWrapper : Oatc.OpenMI.Sdk.Wrapper.IEngine
	{
		private SimpleRiverEngineDotNetAccess _simpleRiverEngine;

		public void Initialize(System.Collections.Hashtable properties)
		{
            _simpleRiverEngine = new SimpleRiverEngineDotNetAccess();
            _simpleRiverEngine.Initialize(properties["FilePath"].ToString());
		}

        public void Finish()
        {
            _simpleRiverEngine.Finish();
        }
	}
}
  • No labels