<?xml version="1.0" encoding="UTF-8"?>
<!--
	PrintType	Description
	++++++++	+++++++++
	Brief		Basic parameters only; no analog out, thresholds or events
	Summary	Basic parameters and analog out
	Full			Basic parameters, analog out, thresholds and events
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:Locale="urn:Locale-namespace">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
	<xsl:include href="DefaultPrint-r102.xsl"/>
	<xsl:include href="Locale.xsl"/>
	<xsl:param name="printtype">Full</xsl:param>
	<xsl:variable name="NativePressureUnits">psi</xsl:variable>
	<xsl:variable name="TheSchema" select="document('AltusA10FL-Method-r100.xsd')"/>
	<xsl:variable name="LanguageSubfolder" select="Locale:LanguageSubfolder()"/>
	<xsl:variable name="ResourceFile" select="concat($LanguageSubfolder,'\\AltusA10FL-Resource-r100.xml')"/>
	<xsl:variable name="TheResources" select="document(string($ResourceFile))"/>
	
	<!-- Emit ChannelA...D only in 2D mode, and only when enabled -->
	<xsl:template match="ChannelA | ChannelB | ChannelC | ChannelD">
		<xsl:if test="//DetectorMode = 'DetectorMode_1' and ./Enable = 'true'" >
			<xsl:call-template name="Emit-FieldList">
				<xsl:with-param name="InputVar" select="name()"/>
				<xsl:with-param name="InputType">String</xsl:with-param>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>
	
	<!-- Don't emit the 'Enable' element of ChannelA...D -->
	<xsl:template match="ChannelA/Enable | ChannelB/Enable | ChannelC/Enable | ChannelD/Enable">
	</xsl:template>
	
	<xsl:template match="Threshold1/Enable | Threshold2/Enable">
	</xsl:template>

	<!-- Don't emit event table if brief or summary report is requested -->
	<xsl:template match="EventTable">
		<xsl:if test="$printtype = 'Full'">
			<xsl:call-template name="Emit"/>
		</xsl:if>
	</xsl:template>

	<!-- Customize text for boolean On/Off at end of FieldList -->
	<xsl:template match="Lamp">
		<xsl:variable name="ParameterName" select="name()"/>
		<xsl:variable name="ParameterTypeNode" select="$TheSchema//xsd:element[@name=$ParameterName]/@type"/>
		<xsl:variable name="ParameterType" select="string($ParameterTypeNode)"/>
		<xsl:call-template name="Emit-Field-Value-Prompt">
			<xsl:with-param name="InputVar" select="name()"/>
			<xsl:with-param name="InputType">String</xsl:with-param>
			<xsl:with-param name="InputPrecision">0</xsl:with-param>
			<xsl:with-param name="InputValue">
				<xsl:choose>
					<xsl:when test=".='true'">
						<xsl:value-of select="$TheResources//Enum[@id='BooleanOn_1B']/@value"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="$TheResources//Enum[@id='BooleanOff_0B']/@value"/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:with-param>
			<xsl:with-param name="InputPrompt" select="$TheResources//Type[@name=$ParameterType]/@prompt"/>
			<xsl:with-param name="InputUnits">None</xsl:with-param>
		</xsl:call-template>

		<xsl:text disable-output-escaping="yes">
			&lt;/FieldList&gt;
		</xsl:text>
	</xsl:template>

	<!-- Customize text for boolean Yes/No before end of FieldList -->
	<xsl:template match="ChartMarkEnable | AutoZeroInjectStart | AutoZeroEventOrKey">
		<xsl:variable name="ParameterName" select="name()"/>
		<xsl:variable name="ParameterTypeNode" select="$TheSchema//xsd:element[@name=$ParameterName]/@type"/>
		<xsl:variable name="ParameterType" select="string($ParameterTypeNode)"/>
		<xsl:call-template name="Emit-Field-Value-Prompt">
			<xsl:with-param name="InputVar" select="name()"/>
			<xsl:with-param name="InputType">String</xsl:with-param>
			<xsl:with-param name="InputPrecision">0</xsl:with-param>
			<xsl:with-param name="InputValue">
				<xsl:choose>
					<xsl:when test=".='true'">
						<xsl:value-of select="$TheResources//Enum[@id='BooleanYes_1A']/@value"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="$TheResources//Enum[@id='BooleanNo_0A']/@value"/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:with-param>
			<xsl:with-param name="InputPrompt" select="$TheResources//Type[@name=$ParameterType]/@prompt"/>
			<xsl:with-param name="InputUnits">None</xsl:with-param>
		</xsl:call-template>
	</xsl:template>

	<!-- Customize text for boolean Yes/No at end of FieldList -->
	<xsl:template match="RunEvents">
		<xsl:variable name="ParameterName" select="name()"/>
		<xsl:variable name="ParameterTypeNode" select="$TheSchema//xsd:element[@name=$ParameterName]/@type"/>
		<xsl:variable name="ParameterType" select="string($ParameterTypeNode)"/>
		<xsl:call-template name="Emit-Field-Value-Prompt">
			<xsl:with-param name="InputVar" select="name()"/>
			<xsl:with-param name="InputType">String</xsl:with-param>
			<xsl:with-param name="InputPrecision">0</xsl:with-param>
			<xsl:with-param name="InputValue">
				<xsl:choose>
					<xsl:when test=".='true'">
						<xsl:value-of select="$TheResources//Enum[@id='BooleanYes_1A']/@value"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="$TheResources//Enum[@id='BooleanNo_0A']/@value"/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:with-param>
			<xsl:with-param name="InputPrompt" select="$TheResources//Type[@name=$ParameterType]/@prompt"/>
			<xsl:with-param name="InputUnits">None</xsl:with-param>
		</xsl:call-template>

		<xsl:text disable-output-escaping="yes">
			&lt;/FieldList&gt;
		</xsl:text>
	</xsl:template>

	<!-- Emit Scan only in 3D mode -->
	<xsl:template match="Scan">
		<xsl:if test="//DetectorMode = 'DetectorMode_2'" >
			<xsl:call-template name="Emit-FieldList">
				<xsl:with-param name="InputVar" select="name()"/>
				<xsl:with-param name="InputType">String</xsl:with-param>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>

	<!-- Exclude analog out from Brief -->
	<xsl:template match="Analog1 | Analog2">
		<xsl:if test="$printtype != 'Brief'">
			<xsl:call-template name="Emit-FieldList">
				<xsl:with-param name="InputVar" select="name()"/>
				<xsl:with-param name="InputType">String</xsl:with-param>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>
	
	<!-- Rename threshold groups -->
	<xsl:template match="Threshold1 | Threshold2">
		<xsl:if test="$printtype = 'Full'">
			<xsl:variable name="EnableThreshold">
				<xsl:choose>
					<xsl:when test="name() = 'Threshold1' and //Threshold1/Enable = 'true'">1</xsl:when>
					<xsl:when test="name() = 'Threshold2' and //Threshold2/Enable = 'true'">1</xsl:when>
					<xsl:otherwise>0</xsl:otherwise>
				</xsl:choose>
			</xsl:variable>
			<xsl:if test="$EnableThreshold = 1">
				<xsl:choose>
					<xsl:when test="//DetectorMode = 'DetectorMode_2'" >
						<xsl:call-template name="Emit-FieldList">
							<xsl:with-param name="InputVar">
								<xsl:choose>
									<xsl:when test="name() = 'Threshold1'">
										<xsl:value-of select="$TheResources//Enum[@id='Analog1ThresholdString']/@value"/>
									</xsl:when>
									<xsl:when test="name() = 'Threshold2'">
										<xsl:value-of select="$TheResources//Enum[@id='Analog2ThresholdString']/@value"/>
									</xsl:when>
									<xsl:otherwise>None</xsl:otherwise>
								</xsl:choose>
							</xsl:with-param>
							<xsl:with-param name="InputType">
								<xsl:choose>
									<xsl:when test="name() = 'Threshold1'">tThreshold1</xsl:when>
									<xsl:when test="name() = 'Threshold2'">tThreshold2</xsl:when>
								</xsl:choose>
							</xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="//DetectorMode = 'DetectorMode_1'" >
						<xsl:call-template name="Emit-FieldList">
							<xsl:with-param name="InputVar">
								<xsl:choose>
									<xsl:when test="name() = 'Threshold1'">
										<xsl:value-of select="$TheResources//Enum[@id='ChannelAThresholdString']/@value"/>
									</xsl:when>
									<xsl:when test="name() = 'Threshold2'">
										<xsl:value-of select="$TheResources//Enum[@id='ChannelBThresholdString']/@value"/>
									</xsl:when>
									<xsl:otherwise>None</xsl:otherwise>
								</xsl:choose>
							</xsl:with-param>
							<xsl:with-param name="InputType">
								<xsl:choose>
									<xsl:when test="name() = 'Threshold1'">tThreshold1</xsl:when>
									<xsl:when test="name() = 'Threshold2'">tThreshold2</xsl:when>
								</xsl:choose>
							</xsl:with-param>
						</xsl:call-template>
					</xsl:when>
				</xsl:choose>
			</xsl:if>
		</xsl:if>
	</xsl:template>

	<!-- Adjust the prompts for the fixed wavelength of Scan, depending upon mode -->
	<xsl:template match="FixedWavelength">
		<xsl:variable name="ParameterName" select="name()"/>
		<xsl:variable name="ParameterTypeNode" select="$TheSchema//xsd:element[@name=$ParameterName]/@type"/>
		<xsl:variable name="ParameterType" select="string($ParameterTypeNode)"/>
			<xsl:call-template name="Emit-Field-Value-Prompt">
				<xsl:with-param name="InputVar" select="name()"/>
				<xsl:with-param name="InputType">Int</xsl:with-param>
				<xsl:with-param name="InputPrecision">None</xsl:with-param>
				<xsl:with-param name="InputValue" select="."/>
				<xsl:with-param name="InputPrompt">
					<xsl:choose>
						<xsl:when test="//ScanType = 'ScanType_1'">
							<xsl:value-of select="$TheResources//Enum[@id='ExcitationWavelengthString']/@value"/>
						</xsl:when>
						<xsl:when test="//ScanType = 'ScanType_0'">
							<xsl:value-of select="$TheResources//Enum[@id='EmissionWavelengthString']/@value"/>
						</xsl:when>
						<xsl:otherwise>None</xsl:otherwise>
					</xsl:choose>
				</xsl:with-param>
				<xsl:with-param name="InputUnits" select="$TheResources//Type[@name=$ParameterType]/@units"/>
			</xsl:call-template>

	</xsl:template>

	<!-- Adjust the prompts for the varying wavelength of Scan, depending upon mode -->
	<xsl:template match="Wavelength1 |  Wavelength2">
		<xsl:variable name="ParameterName" select="name()"/>
		<xsl:variable name="ParameterTypeNode" select="$TheSchema//xsd:element[@name=$ParameterName]/@type"/>
		<xsl:variable name="ParameterType" select="string($ParameterTypeNode)"/>
			<xsl:call-template name="Emit-Field-Value-Prompt">
				<xsl:with-param name="InputVar" select="name()"/>
				<xsl:with-param name="InputType">Int</xsl:with-param>
				<xsl:with-param name="InputPrecision">None</xsl:with-param>
				<xsl:with-param name="InputValue" select="."/>
				<xsl:with-param name="InputPrompt">
					<xsl:choose>
						<xsl:when test="//ScanType = 'ScanType_1' and name() = 'Wavelength1'">
							<xsl:value-of select="$TheResources//Enum[@id='EmissionWavelengthStartString']/@value"/>
						</xsl:when>
						<xsl:when test="//ScanType = 'ScanType_1' and name() = 'Wavelength2'">
							<xsl:value-of select="$TheResources//Enum[@id='EmissionWavelengthEndString']/@value"/>
						</xsl:when>
						<xsl:when test="//ScanType = 'ScanType_0' and name() = 'Wavelength1'">
							<xsl:value-of select="$TheResources//Enum[@id='ExcitationWavelengthStartString']/@value"/>
						</xsl:when>
						<xsl:when test="//ScanType = 'ScanType_0' and name() = 'Wavelength2'">
							<xsl:value-of select="$TheResources//Enum[@id='ExcitationWavelengthEndString']/@value"/>
						</xsl:when>
						<xsl:otherwise>None</xsl:otherwise>
					</xsl:choose>
				</xsl:with-param>
				<xsl:with-param name="InputUnits" select="$TheResources//Type[@name=$ParameterType]/@units"/>
			</xsl:call-template>

	</xsl:template>

	<!-- Change the prompt text for AutoZeroOnWavelength if in Scan mode -->
	<xsl:template match="AutoZeroWavelength">
		<xsl:variable name="ParameterName" select="name()"/>
		<xsl:variable name="ParameterTypeNode" select="$TheSchema//xsd:element[@name=$ParameterName]/@type"/>
		<xsl:variable name="ParameterType" select="string($ParameterTypeNode)"/>
		<xsl:choose>
			<xsl:when test="//DetectorMode = 'DetectorMode_2'" >
				<xsl:call-template name="Emit-Field-Value-Prompt">
					<xsl:with-param name="InputVar" select="name()"/>
					<xsl:with-param name="InputType">String</xsl:with-param>
					<xsl:with-param name="InputPrecision">None</xsl:with-param>
					<xsl:with-param name="InputValue" select="."/>
					<xsl:with-param name="InputPrompt" select="$TheResources//Type[@name=$ParameterType]/@prompt"/>
					<xsl:with-param name="InputUnits">None</xsl:with-param>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="Emit" />
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<!-- Change the prompt text for DataOffset based on DataUnits -->
	<xsl:template match="DataOffset">
		<xsl:variable name="ParameterName" select="name()"/>
		<xsl:variable name="ParameterTypeNode" select="$TheSchema//xsd:element[@name=$ParameterName]/@type"/>
		<xsl:variable name="ParameterType" select="string($ParameterTypeNode)"/>
		<xsl:call-template name="Emit-Field-Value-Prompt">
			<xsl:with-param name="InputVar" select="name()"/>
			<xsl:with-param name="InputType">Float</xsl:with-param>
			<xsl:with-param name="InputPrecision">1</xsl:with-param>
			<xsl:with-param name="InputValue" select="."/>
			<xsl:with-param name="InputPrompt" select="$TheResources//Type[@name=$ParameterType]/@prompt"/>
			<xsl:with-param name="InputUnits">
				<xsl:choose>
					<xsl:when test="//DataUnits = 'DataUnits_1'" >
						<xsl:value-of select="$TheResources//Enum[@id='EuString']/@value"/>
					</xsl:when>
					<xsl:when test="//DataUnits = 'DataUnits_2'" >
						<xsl:value-of select="$TheResources//Enum[@id='SampleEnergyUnitsString']/@value"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="$TheResources//Enum[@id='EuOrSampleEnergyUnitsString']/@value"/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:with-param>
		</xsl:call-template>

	</xsl:template>

	<!-- In Scan mode, convert the output wavelength index to the wavelength in nm. In 2D mode, omit output wavelength from printout -->
	<xsl:template match="OutputWavelength">
		<xsl:variable name="ParameterName" select="name()"/>
		<xsl:variable name="ParameterTypeNode" select="$TheSchema//xsd:element[@name=$ParameterName]/@type"/>
		<xsl:variable name="ParameterType" select="string($ParameterTypeNode)"/>
		<xsl:if test="//DetectorMode = 'DetectorMode_2'" >
			<xsl:variable name="StepSize" select="(number(//Scan/Wavelength2) - number(//Scan/Wavelength1)) div 20" />
			<xsl:variable name="Index" select="number(.)"/>
			<xsl:variable name="Wavelength" select="number(//Scan/Wavelength1) + ( $Index * $StepSize )" />

			<xsl:call-template name="Emit-Field-Value-Prompt">
				<xsl:with-param name="InputVar" select="name()"/>
				<xsl:with-param name="InputType">Float</xsl:with-param>
				<xsl:with-param name="InputPrecision">1</xsl:with-param>
				<xsl:with-param name="InputValue" select="format-number($Wavelength,'0.0')"/>
				<xsl:with-param name="InputPrompt" select="$TheResources//Type[@name=$ParameterType]/@prompt"/>
				<xsl:with-param name="InputUnits" select="$TheResources//Type[@name=$ParameterType]/@units"/>
			</xsl:call-template>

		</xsl:if>
	</xsl:template>
	
	<xsl:template match="AltusA10FLMethod">
		<xsl:element name="AltusA10FLMethod">
			<xsl:apply-templates/>
		</xsl:element>
	</xsl:template>
	
</xsl:stylesheet>
