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

<section class="content-wrapper" data-heading="display" id="fastnet">
	<!--Heading-->
	<div class="page-title">
		<h1>Fastnet</h1>
		<p>
			Configuration for all data input from or output to fastnet.
		</p>

		<div>
			<p>
				Some older B&amp;G FFDs report problems with custom field names in the menu.
				Check this box to disable sending menu items, each device will use its own defaults.
			</p>
			<input type="checkbox" id="fastnet-menus">
		</div>
	</div>
	
	<!--Fastnet Input-->
	<div class="box box-top">
		<fieldset>		
			<legend><h2>Input from Fastnet</h2></legend>
			<div class="io-grid">
				<div class="tooltip-wrapper">
					<h2>Node</h2>
					<div class="tooltip">
						<p>If set to zero, all nodes will be checked.</p>
					</div>
				</div>
				<h2>Channel</h2>
				<h2>Data Value</h2>
				<h2>Enable Input</h2>
				<!--Position-->
				<h2>Position</h2>
				<input type="number" id="position-input-node">
				<input type="number" value="256" id="position-input-channel" disabled>
				<div class="flex-field">
					<div class="field-container" data-field="<?php echo fieldEnum::GPS_Latitude;?>"
						data-sender="Fastnet" id="position-latitude" data-instance="0">
					</div>
					<div class="field-container" data-field="<?php echo fieldEnum::GPS_Longitude;?>"
						data-sender="Fastnet" id="position-longitude" data-instance="0">
					</div>
				</div>
				<input type="checkbox" id="position-input-enable">
				<!--Heading-->
				<h2>Heading</h2>
				<input type="number" id="heading-input-node">
				<input type="number" id="heading-input-channel">
				<div class="flex-field">
					<div class="field-container" data-field="<?php echo fieldEnum::Heading_True;?>"
						data-sender="Fastnet" id="heading-true" data-instance="0">
					</div>
					<div class="field-container" data-field="<?php echo fieldEnum::Heading_Magnetic;?>"
						data-sender="Fastnet" id="heading-mag" data-instance="0">
					</div>
				</div>
				<input type="checkbox" id="heading-input-enable">
				<!--Boat Speed-->
				<h2>Boat Speed</h2>
				<input type="number" id="speed-input-node">
				<input type="number" id="speed-input-channel" value="65" disabled>
				<div class="flex-field">
					<div class="field-container" data-field="<?php echo fieldEnum::Boat_Speed_Kts;?>"
						data-sender="fastnet" id="bspd" data-instance="0">
					</div>
				</div>
				<input type="checkbox" id="speed-input-enable">
				<!--Rudder-->
				<h2>Rudder</h2>
				<input type="number" id="rudder-input-node">
				<input type="number" id="rudder-input-channel">
				<div class="flex-field">
					<div class="field-container" data-field="<?php echo fieldEnum::Rudder_Ang_Stbd_Deg;?>"
						data-sender="Fastnet" id="rudder-data" data-instance="0">
					</div>
				</div>
				<input type="checkbox" id="rudder-input-enable">
			</div>
		</fieldset>
	</div>

	<!--Fastnet Output-->
	<div class="box box-stack">
		<fieldset>		
			<legend><h2>Output to Fastnet</h2></legend>
			<div class="io-grid output-grid">
				<div class="tooltip-wrapper">
					<h2>Node</h2>
					<div class="tooltip">
						<p>
							If set to zero, will output on system default node 5.
						</p>
					</div>
				</div>
				<div class="tooltip-wrapper">
					<h2>Fastnet Name</h2>
					<div class="tooltip">
						<p>
							Legacy B&G displays only accept uppercase channel names.
						</p>
					</div>
				</div>
				<h2>Decimal<br> Places</h2>
				<h2>Enable<br> Output</h2>
				<!--Position-->
				<h2>Position</h2>
				<input type="number" id="position-output-node">
				<input type="text" maxlength="10" id="position-output-name">
				<div id="decimal-placeholder"></div>
				<input type="checkbox" id="position-output-enable">
				<!--Heading-->
				<div class="tooltip-wrapper">
					<h2>Heading</h2>
					<div class="tooltip">
						<p>Enabling heading output will also send raw heading at 10Hz for B&amp;G ACP autopilots</p>
					</div>
				</div>
				<input type="number" id="heading-output-node">
				<input type="text" maxlength="10" id="heading-output-name">
				<div class="decimal-placeholder"></div>
				<input type="checkbox" id="heading-output-enable">
				<!--Heel/Trim-->
				<h2>Heel/Trim</h2>
				<div></div>
				<div></div>
				<div></div>
				<input type="checkbox" id="heel-output-enable" checked>
				<!--Rudder-->
				<h2>Rudder</h2>
				<input type="number" id="rudder-output-node">
				<input type="text" maxlength="10" id="rudder-output-name">
				<div class="tooltip-wrapper" id="rudder-tooltip">
					<select id="rudder-output-dp">
						<option value="0">0</option>
						<option value="1">1</option>
					</select>
					<div class="tooltip" tooltip-position="left">
						<p>
							Due to constraints of the Fastnet protocol, 1 decimal place rudder output
							will revert to 0 decimal places for rudder angles greater than 25.5.<br>
							On some B&G displays the 1 decimal place format is displayed with 'l' or 'r'
							as direction indicators rather than '='.
						</p>
					</div>
				</div>
				<input type="checkbox" id="rudder-output-enable">
				<!--CoG-->
				<h2>CoG</h2>
				<input type="number" id="cog-output-node">
				<input type="text" maxlength="10" id="cog-output-name">
				<select id="cog-output-dp">
					<option value="0">0</option>
					<option value="1">1</option>
				</select>
				<input type="checkbox" id="cog-output-enable">
			</div>
			<!--Analogues-->
			<div class="dropdown-container">
				<h2>Analogues</h2>
				<a id="analogue-toggle" class="button button-gray button-small">
					<i class="arrow arrow-down"></i>
				</a>
			</div>
			<div class="dropdown" id="analogue-output"></div>
			<!--Depth-->
			<div class="dropdown-container">
				<div class="tooltip-wrapper">
					<h2>Depth Transducers</h2>
					<div class="tooltip">
						<p>
							If a single depth source is connected then its channel should be set to
							'Primary' which uses the predefined fastnet channels for depth. If an aft
							depth source is connected it should similarly be set to 'Aft' below. For any further
							sources, assign an unused channel and set connected displays to use
							this channel.
						</p>
					</div>
				</div>
				<a id="depth-toggle" class="button button-gray button-small">
					<i class="arrow arrow-down"></i>
				</a>
			</div>
			<div class="dropdown" id="depth-output"></div>
			<!--Loadcells-->
			<div class="dropdown-container">
				<h2>Loadcells</h2>
				<a id="loadcell-toggle" class="button button-gray button-small">
					<i class="arrow arrow-down"></i>
				</a>
			</div>
			<div class="dropdown" id="loadcell-output"></div>
		</fieldset>
	</div>
	
	<div class="box box-bottom" id="bearing-container">
		<fieldset>
			<legend>
				<div class="tooltip-wrapper">
					<h2>Default Bearing Mode</h2>
					<div class="tooltip">
						<p>Sets the bearing mode on connected displays.</p>
					</div>
				</div>
			</legend>
			<div>
				<div>
					<h2>True</h2>
					<input type="radio" name="bearing-mode" value="True"></input>
				</div>
				<div>
					<h2>Magnetic</h2>
					<input type="radio" name="bearing-mode" value="Magnetic"></input>
				</div>
			</div>
		</fieldset>
	</div>

	<div class="box top-wrapper" id="fastnet-resistance-container" hidden>
		<div class="flex-row">
			<h2>Fastnet Resistance</h2>
			<div class="flex-field">
				<div class="field-container" id="fastnet-resistance-field" data-sender="Main Interface Board"
					data-instance="Internal" data-field="<?php echo fieldEnum::Fastnet_Resistance;?>">
					&nbsp;
				</div>
				<a class="button button-gray button-medium" id="fastnet-resistance">Test</a>
			</div>
		</div>
	</div>
	
	<!--Buttons-->
	<div class="button-box" id="button-container">
		<div class="box box-bottom">
			<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/atp.fastnet.js?v=<?php echo VERSION_NUMBER;?>" defer></script>
<script>
$(document).ready(function() {
	let model = new FastnetModel();
	let controller = new FastnetController(model);
	let view = new FastnetView(controller);
});
</script>

<?php require_once "footer.php"?>
