<?php require_once "atp.header.php"; ?>

<section class="content-wrapper" data-heading="position" id="heel">
	<div class="page-title">
		<h1>
			Heel
		</h1>
		<p>
			The ATP Motherboard contains an internal heel/trim sensor.
			This is used for heel wind correction unless an external heel sensor is interfaced and selected below.<br>
			Note: The sign convention used takes <b>positive</b> heel values to mean heel to <b>starboard</b>
			and negative values to mean heel to port. Similarly a positive trim indicates bow-up.
		</p>
	</div>
	
	<div class="box top-wrapper">
		<!--Internal sensor select-->
		<div id="sensor-select-row">
			<div>
				<input type="radio" name="sensor-select" value="true" id="heel-internal-true">
				<label for="heel-internal-true">Use internal heel sensor</label>
			</div>
			<div>
				<input type="radio" name="sensor-select" value="false" id="heel-internal-false">
				<label for="heel-internal-false">Use external heel sensor</label>
			</div>
		</div>
	</div>

	<!--Internal sensor widget-->
	<div id="internal-heel-container" hidden>
		<!--Orientation-->
		<div class="box box-top">
			The ATP1 is mounted with its base:-
			<ul>
				<li>
					<div class="heel-mounting">
						<div>
							<b>Vertical</b> and <b>across the beam</b> of the vessel with the base facing
						</div>
						<div>
							<input type="radio" name="back-plate" data-orientation="vertical" value="forward" id="vertical-forward">
							<label class="label-wide" for="vertical-forward">Forward</label>
							<input type="radio" name="back-plate" data-orientation="vertical" value="aft" id="vertical-aft">
							<label class="label-narrow" for="vertical-aft">Aft</label>
						</div>
					</div>
				</li>
				<li>
					<div class="heel-mounting">
						<div>
							<b>Vertical</b> and <b>along the axis</b> of the vessel with the base facing &emsp;
						</div>
						<div>
							<input type="radio" name="back-plate" data-orientation="vertical" value="starboard" id="vertical-starboard">
							<label class="label-wide" for="vertical-starboard">Starboard</label>
							<input type="radio" name="back-plate" data-orientation="vertical" value="port" id="vertical-port">
							<label class="label-narrow" for="vertical-port">Port</label>
						</div>
					</div>	
				</li>
				<li>
					<div class="heel-mounting">
						<div>
							<b>Horizontal</b> with the base facing
						</div>
						<div>
							<input type="radio" name="back-plate" data-orientation="horizontal" value="down" id="horizontal-down">
							<label class="label-wide" for="horizontal-down">Down</label>
							<input type="radio" name="back-plate" data-orientation="horizontal" value="up" id="horizontal-up">
							<label class="label-narrow" for="horizontal-up">Up</label>
						</div>
					</div>
				</li>
			</ul>

			<div class="heel-mounting">
				The ATP1 cable exit is facing:-
				<div>
					<input type="radio" name="cable-exit" value="down" id="cable-down">
					<label class="label-narrow" for="cable-down" style="width: 3em;">Down</label>
					<input type="radio" name="cable-exit" value="forward" id="cable-forward">
					<label class="label-wide" for="cable-forward">Forward</label>
					<input type="radio" name="cable-exit" value="aft" id="cable-aft">
					<label class="label-narrow" for="cable-aft">Aft</label>
					<input type="radio" name="cable-exit" value="starboard" id="cable-starboard">
					<label class="label-wide" for="cable-starboard">Starboard</label>
					<input type="radio" name="cable-exit" value="port" id="cable-port">
					<label class="label-narrow" for="cable-port">Port</label>
				</div>
			</div>
		</div>

		<!--Sensor Values-->
		<div class="box box-stack">
			<div id="sensor-fields">
				<h2>Raw internal measurements: &emsp;</h2>
				<div class="flex-row">
					<div class="flex-field">
						Rx &nbsp;
						<div class="field-container" data-field="<?php echo fieldEnum::Calc_Accel_X;?>"
							id="rx" data-sender="Main Interface Board" title="X-axis accelerometer value."
							data-instance="<?php echo PROCESSOR_INSTANCE;?>">
								&nbsp;
						</div>
					</div>
					<div class="flex-field">
						Ry &nbsp; 
						<div class="field-container" data-field="<?php echo fieldEnum::Calc_Accel_Y;?>"
							id="ry" data-sender="Main Interface Board" title="Y-axis accelerometer value."
							data-instance="<?php echo PROCESSOR_INSTANCE;?>">
								&nbsp;
						</div>
					</div>
					<div class="flex-field">
						Rz &nbsp;
						<div class="field-container" data-field="<?php echo fieldEnum::Calc_Accel_Z;?>"
							id="rz" data-sender="Main Interface Board" title="Z-axis accelerometer value."
							data-instance="<?php echo PROCESSOR_INSTANCE;?>">
								&nbsp;
						</div>
					</div>
					<div class="flex-field">
						Rg &nbsp;
						<div class="field-container" data-field="<?php echo fieldEnum::Calc_Total_Gravity;?>"
							id="rg" data-sender="Main Interface Board" title="Combined accelerometer value (should be &plusmn;1)."
							data-instance="<?php echo PROCESSOR_INSTANCE;?>">
								&nbsp;
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
		
	<!--External Source-->
	<div id="external-heel-container" hidden>
		<div class="top-wrapper box box-top">
			<!--Source Select-->
			<div class="flex-row">
                <div class="flex-heading">
                    <h2>Input Type:</h2>
                </div>
                <select id="heel-source-select">
                    <option value="NMEA0183">NMEA0183</option>
                    <option value="CanBus">CANbus</option>
                </select>
            </div>

			<!--Instance Select-->
			<div class="flex-row" id="instance-select">
                <div id="heel-nmea-instance" hidden>
                    <div class="flex-row">
                        <div class="flex-heading">
                            <h2>NMEA Port:</h2>
                        </div>
                        <select id="heel-nmea-instance-select"></select>
                    </div>
                </div>

				<div id="heel-canbus-instance" hidden></div>

                <div id="heel-analogue-instance" hidden>
                    <div class="flex-row">
                        <div class="flex-heading">
                            <h2>Analogue Input:</h2>
                        </div>
                        <select id="heel-analogue-instance-select"></select>
                    </div>
                </div>			
			</div>
		</div>
	</div>

    <!--Heel/Trim Values-->
    <div class="box box-bottom">
        <div class="flex-row">
            <div class="flex-third">
                <h2>Raw Heel</h2>
                <div class="flex-field">
                    <div class="field-container" data-field="<?php echo fieldEnum::Heel_Angle_Deg;?>"
                        id="rawHeel" data-sender="Main Interface Board" title="Heel angle before offset."
                        data-instance="<?php echo PROCESSOR_INSTANCE;?>">
                        &nbsp;
                    </div>
                </div>
            </div>
            <div class="flex-third">
                <h2>Heel Offset</h2>
                <div class="input-unit">
                    <input type="number" step="0.01" id="heel-offset">
                    <span>&deg;</span>
                </div>
            </div>
            <div class="flex-third">
                <h2>Corrected Heel</h2>
                <div class="flex-field">
                    <div class="field-container" data-field="<?php echo fieldEnum::Heel_Angle_Deg;?>"
                        id="correctedHeel" data-sender="<?php echo PROCESSOR_ID;?>"
                        data-instance="<?php echo PROCESSOR_INSTANCE;?>" title="Heel angle.">
                        &nbsp;
                    </div>
                </div>
            </div>
        </div>
        <div class="flex-row">
            <div class="flex-third">
                <h2>Raw Trim</h2>
                <div class="flex-field">
                    <div class="field-container" data-field="<?php echo fieldEnum::Trim_Angle;?>"
                        id="rawTrim" data-sender="Main Interface Board" title="Trim angle before offset."
                        data-instance="<?php echo PROCESSOR_INSTANCE;?>">
                            &nbsp;
                    </div>
                </div>
            </div>
            <div class="flex-third">
                <h2>Trim Offset</h2>
                <div class="input-unit">
                    <input type="number" step="0.01" id="trim-offset">
                    <span>&deg;</span>
                </div>
            </div>
            <div class="flex-third">
                <h2>Corrected Trim</h2>
                <div class="flex-field">
                    <div class="field-container" data-field="<?php echo fieldEnum::Trim_Angle;?>"
                        id="correctedTrim" data-sender="<?php echo PROCESSOR_ID;?>"
                        data-instance="<?php echo PROCESSOR_INSTANCE;?>" title="Trim angle.">
                        &nbsp;
                    </div>
                </div>
            </div>
        </div>
    </div>
	
	<!--Buttons-->
	<div class="button-box" id="button-container">
		<div class="box">
			<a id="ok-button" class="button button-gray button-medium">OK</a>
			<a id="cancel-button" class="button button-gray button-medium">Cancel</a>
			<a id="apply-button" class="button button-gray button-medium">Apply</a>
		</div>
	</div>
</section>

<script type="text/javascript" src="js/utils.string.js" defer></script>
<script type="text/javascript" src="js/atp.data-sources.js" defer></script>
<script type="text/javascript" src="js/atp.heel-model.js" defer></script>
<script type="text/javascript" src="js/atp.heel-controller.js" defer></script>
<script type="text/javascript" src="js/atp.heel-view.js" defer></script>
<script>
$(document).ready(function() {
	
	var model = new HeelModel();
	var controller = new HeelController(model);
	var view = new HeelView(controller);
	
});
</script>

<?php require_once "footer.php";?>