4.6 Step 6: Implementing the MyModelLinkablComponent

The sixth step is to implement the MyModeLinkableComponent class (Figure 12).


Figure 12

The MyModelLinkableComponent is the OpenMI-compliant linkable component that is going to be accessed by other models. Implementation of this class is very simple, since it will inherit lots of functionality from the Oatc.OpenMI.Sdk.Wrapper.LinkableEngine class. The example code shown below is the complete implementation for the Simple River model.

using System;

namespace Oatc.OpenMI.Examples.ModelComponents.SimpleRiver.Wrapper
{
	public class SimpleRiverOpenMIComponent : Oatc.OpenMI.Sdk.Wrapper.LinkableEngine
	{
		public SimpleRiverOpenMIComponent()
		{
			_engineApiAccess = new SimpleRiverEngineWrapper();
		}

		protected override void SetEngineApiAccess()
		{
			_engineApiAccess = new SimpleRiverEngineWrapper();
		}
	}
}

This class inherits from the LinkableEngine class. The class creates the EngineWrapper and assigns it to the protected field variable _engineApiAccess.

  • No labels