<?xml version="1.0" encoding="ISO-8859-1"?>
<Xfn2Function xmlns="http://www.mclarenelectronics.com/schemas/OcsXfn"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="C:\Users\robin.cull\Documents\McLaren Electronic Systems\ATLAS 9\Funclib\OcsXFn.xsd">
    <InputParameters>
        <Identifier><!--ATLAS Input parameter full identifier (e.g. vCar:Chassis) --></Identifier>
    </InputParameters>
    <OutputParameters>
        <OutputParameter>
            <Name><!-- Output Function Name (e.g. vCarX2) --></Name>
            <Description><!-- Function description (e.g. <![CDATA[vCar multiplied by 2]]>) --></Description>
            <Units><!-- Function unit string (e.g. kph) --></Units>
            <Format><!-- Function format string (e.g. %.2f) --></Format>
            <DisplayMin><!-- Function display minimum (e.g. 0) --></DisplayMin>
            <DisplayMax><!-- Function display maximum (e.g. 800) --></DisplayMax>
        </OutputParameter>
    </OutputParameters>
	<!-- Defaults are fine here -->
    <FunctionMode>XFN_Instantaneous</FunctionMode>
	<CalculationMode>XFN_EachSample</CalculationMode>
	<InterpolateBetweenSamples>false</InterpolateBetweenSamples>
	<JoinGapsAroundNull>true</JoinGapsAroundNull>
	<CalculateOverWholeSession>false</CalculateOverWholeSession>
	<StoreInSession>false</StoreInSession>
	<!-- End defaults -->
    <Implementation>
        <CSharpFunctionImplementationDefinition>
            <FunctionCode><![CDATA[

// These lines are needed			
using System;
using System.Collections.Generic;
using MESL.SqlRace.Domain.Functions;

// Rename the implementation class
public sealed class <!-- Implementation class name --> : IFunction
{
	// The class must have an Execute method
    public void Execute(IExecutionContext executionContext)
    {
        var functionInput = executionContext.FunctionInput;
        var functionOutput = executionContext.FunctionOutput;

		// Find out how many samples you need to work on in this step
        var timestampsCount = functionInput.Timestamps.Length;

		// Lookup the input and output parameter indexes by name in the parameter collection
        var InputParameterIndex = functionInput.InputParameterIndexes["InputParameter full identifier e.g. vCar:Chassis"];
        var OutputParameterIndex = functionOutput.OutputParameterIndexes["OutputParameter full identifier e.g. vCarX2:FunctionParameters"];

		// Get the input parameter values and an alias to the output parameter values
        var InputParameter = functionInput.Values[InputParameterIndex];
        var OutputParameter = functionOutput.OutputParametersValues[InputParameterIndex];
        
		// Iterate over the samples
        for (var i = 0; i < timestampsCount; i++)
        {
			// Get each parameter value
            var InputParameterValue = InputParameter[i];
			// Perform an operation on it (multiply by 2.0) and assign the calculated value to the output parameter
            OutputParameter[i] = InputParameterValue * 2.0;
        }
    }
}
]]></FunctionCode>
        </CSharpFunctionImplementationDefinition>
    </Implementation>
    <Trigger>
        <ExecuteOnEveryDataRequestDefinition />
    </Trigger>
</Xfn2Function>
