5.4 Implementing the GetValues method

The source code for the IEngine GetValues implementation is shown below.

//From Class: Oatc.OpenMI.Examples.ModelComponents.SimpleRiver.Wrapper.SimpleRiverEngineWrapper : Oatc.OpenMI.Sdk.Wrapper.IEngine
public IValueSet GetValues(string QuantityID, string ElementSetID)
		{
			double[] returnValues;
			Char[] separator = new char[]{':'};

			if (QuantityID == "Flow")
			{
				int index = Convert.ToInt32((ElementSetID.Split(separator))[1]);
				returnValues = new double[1];
				returnValues[0] = _simpleRiverEngine.GetFlow(index);
			}
			else
			{
				throw new Exception("Illegal QuantityID in GetValues method in SimpleRiverEngine");
			}

			Oatc.OpenMI.Sdk.Backbone.ScalarSet values = new Oatc.OpenMI.Sdk.Backbone.ScalarSet(returnValues);
			return values;
		}

The branch number is extracted from the ElementSetID and used as an index in the GetValues call to the SimpleRiverDotNetAccess class.

The calling sequence for the GetValues method is shown in Figure 16.


Fig. 16. Calling sequence for the GetValues method

  • No labels