package Savage.CommunicationsAndSensors.SeaWeb;

import org.web3d.x3d.jsail.Core.*;
import org.web3d.x3d.jsail.fields.*;
import org.web3d.x3d.jsail.Navigation.*;
import org.web3d.x3d.jsail.Networking.*;
import org.web3d.x3d.jsail.Scripting.*;
import org.web3d.x3d.jsail.Shape.*;
import org.web3d.x3d.jsail.Text.*;

// Javadoc metadata annotations follow, see below for X3DJSAIL Java source code.
/**
 * <p> Takes a communication-message input from a traversing vehicle (such as an AUV or submarine), then sets up the route/relay time delays, directions, animation and visualization of SeaWeb buoy communications among each other, all the way to the SeaWeb RACOM RF-relay buoy at the surface. </p>
 <p> Related links: Catalog page <a href="../../../../CommunicationsAndSensors/SeaWeb/BuoyCommunicationsGridPrototypeIndex.html" target="_blank">BuoyCommunicationsGridPrototype</a>,  source <a href="../../../../CommunicationsAndSensors/SeaWeb/BuoyCommunicationsGridPrototype.java">BuoyCommunicationsGridPrototype.java</a>, <a href="https://www.web3d.org/x3d/content/examples/X3dResources.html" target="_blank">X3D Resources</a>, <a href="https://www.web3d.org/x3d/content/examples/X3dSceneAuthoringHints.html" target="_blank">X3D Scene Authoring Hints</a>, and <a href="https://www.web3d.org/x3d/content/X3dTooltips.html" target="_blank">X3D Tooltips</a>. </p>
	<table style="color:black; border:0px solid; border-spacing:10px 0px;">
        <caption>Scene Meta Information</caption>
		<tr style="background-color:silver; border-color:silver;">
			<td style="text-align:center; padding:10px 0px;"><i>meta tags</i></td>
			<td style="text-align:left;   padding:10px 0px;">&nbsp; Document Metadata </td>
		</tr>

		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> title </i> </td>
			<td> <a href="../../../../CommunicationsAndSensors/SeaWeb/BuoyCommunicationsGridPrototype.x3d">BuoyCommunicationsGridPrototype.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> description </i> </td>
			<td> Takes a communication-message input from a traversing vehicle (such as an AUV or submarine), then sets up the route/relay time delays, directions, animation and visualization of SeaWeb buoy communications among each other, all the way to the SeaWeb RACOM RF-relay buoy at the surface. </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> creator </i> </td>
			<td> Don Brutzman and MV4205 class </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> created </i> </td>
			<td> 8 June 2004 </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> modified </i> </td>
			<td> 2 January 2025 </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> subject </i> </td>
			<td> Buoy, SeaWeb </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> reference </i> </td>
			<td> BuoyCommunicationsGridExampleRoutingTable.xls </td>
		</tr>
		<tr style="color:burntorange">
			<td style="text-align:right; vertical-align: text-top;"> <i> warning </i> </td>
			<td> Under development, need to check timing and routing table </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> identifier </i> </td>
			<td> <a href="https://www.web3d.org/x3d/content/examples/Savage/CommunicationsAndSensors/SeaWeb/BuoyCommunicationsGridPrototype.x3d" target="_blank">https://www.web3d.org/x3d/content/examples/Savage/CommunicationsAndSensors/SeaWeb/BuoyCommunicationsGridPrototype.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> license </i> </td>
			<td> <a href="../../../../CommunicationsAndSensors/SeaWeb/../../license.html">../../license.html</a> </td>
		</tr>
		<tr style="background-color:silver; border-color:silver;">
			<td style="text-align:center;" colspan="2">  &nbsp; </td>
		</tr>
	</table>

	<p>
		This program uses the
		<a href="https://www.web3d.org/specifications/java/X3DJSAIL.html" target="_blank">X3D Java Scene Access Interface Library (X3DJSAIL)</a>.
		It has been produced using the 
		<a href="https://www.web3d.org/x3d/stylesheets/X3dToJava.xslt" target="_blank">X3dToJava.xslt</a>
		stylesheet
	       (<a href="https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/stylesheets/X3dToJava.xslt" target="_blank">version control</a>)
                which is used to create Java source code from an original <code>.x3d</code> model.
	</p>

	* @author Don Brutzman and MV4205 class
 */

public class BuoyCommunicationsGridPrototype
{
	/** Default constructor to create this object. */
	public BuoyCommunicationsGridPrototype ()
	{
	  initialize();
	}

	/** Create and initialize the X3D model for this object. */
	public final void initialize()
	{
            try { // catch-all
  x3dModel = new X3D().setProfile(X3D.PROFILE_IMMERSIVE).setVersion(X3D.VERSION_3_3)
  .setHead(new head()
    .addMeta(new meta().setName(meta.NAME_TITLE      ).setContent("BuoyCommunicationsGridPrototype.x3d"))
    .addMeta(new meta().setName(meta.NAME_DESCRIPTION).setContent("Takes a communication-message input from a traversing vehicle (such as an AUV or submarine), then sets up the route/relay time delays, directions, animation and visualization of SeaWeb buoy communications among each other, all the way to the SeaWeb RACOM RF-relay buoy at the surface."))
    .addMeta(new meta().setName(meta.NAME_CREATOR    ).setContent("Don Brutzman and MV4205 class"))
    .addMeta(new meta().setName(meta.NAME_CREATED    ).setContent("8 June 2004"))
    .addMeta(new meta().setName(meta.NAME_MODIFIED   ).setContent("2 January 2025"))
    .addMeta(new meta().setName(meta.NAME_SUBJECT    ).setContent("Buoy, SeaWeb"))
    .addMeta(new meta().setName(meta.NAME_REFERENCE  ).setContent("BuoyCommunicationsGridExampleRoutingTable.xls"))
    .addMeta(new meta().setName(meta.NAME_WARNING    ).setContent("Under development, need to check timing and routing table"))
    .addMeta(new meta().setName(meta.NAME_IDENTIFIER ).setContent("https://www.web3d.org/x3d/content/examples/Savage/CommunicationsAndSensors/SeaWeb/BuoyCommunicationsGridPrototype.x3d"))
    .addMeta(new meta().setName(meta.NAME_LICENSE    ).setContent("../../license.html")))
  .setScene(new Scene()
    .addComments(" ========== ")
    .addComments(" ExternProtoDeclare statements precede the scene elements utilizing them ")
    .addComments(" ========== ")
    .addChild(new ExternProtoDeclare("BeamCylinder").setName("BeamCylinder").setAppinfo("Produce wireframe or transparent beam cylinders. Typical uses include propeller/thruster water flow or line-of-sight sonar/radar/light beams. Negative range values invert base and apex at same relative location. Default: beam with apex at (0 0 0) and base of radius 1 in x-z plane at (1 0 0).").setUrl(new String[] {"../../CommunicationsAndSensors/Beam/BeamCylinderPrototype.x3d#BeamCylinder","https://www.web3d.org/x3d/content/examples/Savage/CommunicationsAndSensors/Beam/BeamCylinderPrototype.x3d#BeamCylinder","../../CommunicationsAndSensors/Beam/BeamCylinderPrototype.wrl#BeamCylinder","https://www.web3d.org/x3d/content/examples/Savage/CommunicationsAndSensors/Beam/BeamCylinderPrototype.wrl#BeamCylinder"})
      .addField(new field().setName("contact").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("(communications) is transmitted signal in contact with receiver or (sensor) is a target return detected?"))
      .addField(new field().setName("range").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("distance in meters along x axis"))
      .addField(new field().setName("defaultRange").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("distance in meters used until eventIn range sent"))
      .addField(new field().setName("wireframe").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("whether wireframe beam is drawn"))
      .addField(new field().setName("solid").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("whether solid beam is drawn"))
      .addField(new field().setName("beamHeight").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("meters across vertical y axis"))
      .addField(new field().setName("beamWidth").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("meters across horizontal z axis"))
      .addField(new field().setName("contactColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("rendering color when contact=true"))
      .addField(new field().setName("noContactColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("rendering color when contact=false"))
      .addField(new field().setName("transparency").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("1 = fully transparent wireframe only")))
    .addChild(new ExternProtoDeclare("CameraCompass36").setName("CameraCompass36").setAppinfo("Circular set of compass bearings that follow the active viewpoint set at 360/36 = 10 degree intervals. North = +X axis East = +Z axis up = +Y axis.").setUrl(new String[] {"../../../Savage/Tools/HeadsUpDisplays/CameraCompassPrototypes.x3d#CameraCompass36","https://www.web3d.org/x3d/content/examples/Savage/Tools/HeadsUpDisplays/CameraCompassPrototypes.x3d#CameraCompass36","../../../Savage/Tools/HeadsUpDisplays/CameraCompassPrototypes.wrl#CameraCompass36","https://www.web3d.org/x3d/content/examples/Savage/Tools/HeadsUpDisplays/CameraCompassPrototypes.wrl#CameraCompass36"})
      .addField(new field().setName("enabled").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INPUTOUTPUT))
      .addField(new field().setName("positionOffsetFromCamera").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INPUTOUTPUT))
      .addField(new field().setName("markerColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INPUTOUTPUT))
      .addField(new field().setName("labelColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INPUTOUTPUT)))
    .addChild(new ExternProtoDeclare("CrossHair").setName("CrossHair").setAppinfo("The CrossHair prototype provides a heads-up display (HUD) crosshair showing center of screen useful for assessing NavigationInfo lookAt point").setUrl(new String[] {"../../../Savage/Tools/HeadsUpDisplays/CrossHairPrototype.x3d#CrossHair","https://www.web3d.org/x3d/content/examples/Savage/Tools/HeadsUpDisplays/CrossHairPrototype.x3d#CrossHair","../../../Savage/Tools/HeadsUpDisplays/CrossHairPrototype.wrl#CrossHair","https://www.web3d.org/x3d/content/examples/Savage/Tools/HeadsUpDisplays/CrossHairPrototype.wrl#CrossHair"})
      .addField(new field().setName("enabled").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY))
      .addField(new field().setName("set_enabled").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INPUTONLY))
      .addField(new field().setName("markerColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INPUTOUTPUT))
      .addField(new field().setName("scale").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INPUTOUTPUT))
      .addField(new field().setName("positionOffsetFromCamera").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INPUTOUTPUT)))
    .addChild(new ExternProtoDeclare("DvdController").setName("DvdController").setUrl(new String[] {"../../../Savage/Tools/HeadsUpDisplays/DvdControllerPrototype.x3d#DvdController","https://www.web3d.org/x3d/content/examples/Savage/Tools/HeadsUpDisplays/DvdControllerPrototype.x3d#DvdController","../../../Savage/Tools/HeadsUpDisplays/DvdControllerPrototype.wrl#DvdController","https://www.web3d.org/x3d/content/examples/Savage/Tools/HeadsUpDisplays/DvdControllerPrototype.wrl#DvdController"})
      .addField(new field().setName("description").setType(field.TYPE_SFSTRING).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Short description of what is animated by this DvdController."))
      .addField(new field().setName("playEnabled").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Whether or not play mode is enabled including during startup."))
      .addField(new field().setName("displayMode").setType(field.TYPE_SFSTRING).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Initializes how control buttons and slider are displayed. The control buttons include DIS control (i.e. Master Ghost Local) and Playback control (i.e. Reset to Start Fast Rewind Rewind Pause Play Fast Forward Reset to End). Possible values are (case sensitive): ALL DIS_ONLY PLAYBACK_ONLY SLIDER_ONLY DIS_PLAYBACK DIS_SLIDER PLAYBACK_SLIDER and NONE."))
      .addField(new field().setName("setDisplayMode").setType(field.TYPE_SFSTRING).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("Sets how control buttons and slider are displayed. The control buttons include DIS control (i.e. Master Ghost Local) and Playback control (i.e. Reset to Start Fast Rewind Rewind Pause Play Fast Forward Reset to End). Possible values are (case sensitive): ALL DIS_ONLY PLAYBACK_ONLY SLIDER_ONLY DIS_PLAYBACK DIS_SLIDER PLAYBACK_SLIDER and NONE."))
      .addField(new field().setName("buttonColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Default button color."))
      .addField(new field().setName("selectedButtonColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Button color when selected by user."))
      .addField(new field().setName("labelColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Default label color."))
      .addField(new field().setName("selectedLabelColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Label color when selected by user."))
      .addField(new field().setName("locationOffset").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Modified screen location and distance (for size)."))
      .addField(new field().setName("clockEnabled").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY))
      .addField(new field().setName("cycleInterval").setType(field.TYPE_SFTIME).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Time for complete loop cycle in seconds."))
      .addField(new field().setName("set_cycleInterval").setType(field.TYPE_SFTIME).setAccessType(field.ACCESSTYPE_INPUTONLY))
      .addField(new field().setName("cycleInterval_changed").setType(field.TYPE_SFTIME).setAccessType(field.ACCESSTYPE_OUTPUTONLY))
      .addField(new field().setName("speedFactor").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Factor used to determine the speed increase/decrease for Fast Rewind and Fast Forward action."))
      .addField(new field().setName("isActive").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_OUTPUTONLY))
      .addField(new field().setName("startTime_changed").setType(field.TYPE_SFTIME).setAccessType(field.ACCESSTYPE_OUTPUTONLY))
      .addField(new field().setName("stopTime_changed").setType(field.TYPE_SFTIME).setAccessType(field.ACCESSTYPE_OUTPUTONLY))
      .addField(new field().setName("time_changed").setType(field.TYPE_SFTIME).setAccessType(field.ACCESSTYPE_OUTPUTONLY))
      .addField(new field().setName("fraction_changed").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_OUTPUTONLY))
      .addField(new field().setName("secondsElapsed").setType(field.TYPE_SFTIME).setAccessType(field.ACCESSTYPE_OUTPUTONLY))
      .addField(new field().setName("isMaster").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_OUTPUTONLY).setAppinfo("isMaster isRemote and isLocal are booleans represent a 3-way toggle. Only one of them can have a true value at any time."))
      .addField(new field().setName("isRemote").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_OUTPUTONLY).setAppinfo("isMaster isRemote and isLocal are booleans represent a 3-way toggle. Only one of them can have a true value at any time."))
      .addField(new field().setName("isLocal").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_OUTPUTONLY).setAppinfo("isMaster isRemote and isLocal are booleans represent a 3-way toggle. Only one of them can have a true value at any time."))
      .addField(new field().setName("isPaused").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_OUTPUTONLY).setAppinfo("isPaused and isRunning always have opposite values. When isPaused is true isRunning will be false and vice versa."))
      .addField(new field().setName("isRunning").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_OUTPUTONLY).setAppinfo("isPaused and isRunning always have opposite values. When isPaused is true isRunning will be false and vice versa."))
      .addField(new field().setName("traceEnabled").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Enable/disable console output for troubleshooting."))
      .addField(new field().setName("testTimeVal").setType(field.TYPE_SFTIME).setAccessType(field.ACCESSTYPE_INITIALIZEONLY)))
    .addChild(new ExternProtoDeclare("GridXZ").setName("GridXZ").setAppinfo("Line grid authoring tool to enable precise measurement of objects in 3D space - fixed position. Oriented along XZ plane size 20m by 20m.").setUrl(new String[] {"../../../Savage/Tools/Authoring/GridXZPrototype.x3d#GridXZ","https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/GridXZPrototype.x3d#GridXZ","../../../Savage/Tools/Authoring/GridXZPrototype.wrl#GridXZ","https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/GridXZPrototype.wrl#GridXZ"})
      .addField(new field().setName("description").setType(field.TYPE_SFSTRING).setAccessType(field.ACCESSTYPE_INITIALIZEONLY))
      .addField(new field().setName("labelColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INPUTOUTPUT))
      .addField(new field().setName("scale").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("default unscaled size: 10m by 10m"))
      .addField(new field().setName("originLabel").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT))
      .addField(new field().setName("WestLabel").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("-X axis"))
      .addField(new field().setName("NorthWestLabel").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT))
      .addField(new field().setName("NorthLabel").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("-Z axis"))
      .addField(new field().setName("NorthEastLabel").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT))
      .addField(new field().setName("EastLabel").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("+X axis"))
      .addField(new field().setName("SouthEastLabel").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT))
      .addField(new field().setName("SouthLabel").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("+Z axis"))
      .addField(new field().setName("SouthWestLabel").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT))
      .addField(new field().setName("labelsOffset").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("label location offset (in meters) to improve readability")))
    .addChild(new ExternProtoDeclare("SeaWebBuoy").setName("SeaWebBuoy").setUrl(new String[] {"../../CommunicationsAndSensors/SeaWeb/SeaWebBuoyPrototype.x3d#SeaWebBuoy","https://www.web3d.org/x3d/content/examples/Savage/CommunicationsAndSensors/SeaWeb/SeaWebBuoyPrototype.x3d#SeaWebBuoy","../../../Savage/CommunicationsAndSensors/SeaWeb/SeaWebBuoyPrototype.wrl#SeaWebBuoy","https://www.web3d.org/x3d/content/examples/Savage/CommunicationsAndSensors/SeaWeb/SeaWebBuoyPrototype.wrl#SeaWebBuoy"})
      .addField(new field().setName("set_position").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("Position of buoy."))
      .addField(new field().setName("position").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Position of buoy."))
      .addField(new field().setName("set_targetPosition").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("Position of target of transmission."))
      .addField(new field().setName("targetPosition").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Position of target of transmission."))
      .addField(new field().setName("targetIdNumber").setType(field.TYPE_SFINT32).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Id number of target."))
      .addField(new field().setName("set_targetIdNumber").setType(field.TYPE_SFINT32).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("Id number of target."))
      .addField(new field().setName("set_enabled").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("Enable buoy for transmission."))
      .addField(new field().setName("enabled").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Enable buoy for transmission."))
      .addField(new field().setName("set_activated").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("Start transmission."))
      .addField(new field().setName("activated").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Start transmission."))
      .addField(new field().setName("set_transmissionDuration").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("Duration in seconds needed to transmit message (does not include transmissionTimeDelay or propagation delay)."))
      .addField(new field().setName("transmissionDuration").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Duration in seconds needed to transmit message (does not include transmissionTimeDelay or propagation delay)."))
      .addField(new field().setName("transmissionTimeDelay").setType(field.TYPE_SFTIME).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Time delay before transmission begins."))
      .addField(new field().setName("set_transmissionTimeDelay").setType(field.TYPE_SFTIME).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("Time delay before transmission begins."))
      .addField(new field().setName("set_directionalTransmission").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("Select between directional (true) or omni-directional (false) transmission."))
      .addField(new field().setName("directionalTransmission").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Select between directional (true) or omni-directional (false) transmission."))
      .addField(new field().setName("set_buoyType").setType(field.TYPE_SFSTRING).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("Determine which buoy type to use. \"Racom\" for Racom Buoy. \"Telesonar\" for Telesonar Repeater."))
      .addField(new field().setName("buoyType").setType(field.TYPE_SFSTRING).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Determine which buoy type to use. \"Racom\" for Racom Buoy. \"Telesonar\" for Telesonar Repeater."))
      .addField(new field().setName("set_textMessage").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTONLY))
      .addField(new field().setName("textMessage").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INITIALIZEONLY))
      .addField(new field().setName("textMessageColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INPUTOUTPUT))
      .addField(new field().setName("set_description").setType(field.TYPE_SFSTRING).setAccessType(field.ACCESSTYPE_INPUTONLY))
      .addField(new field().setName("description").setType(field.TYPE_SFSTRING).setAccessType(field.ACCESSTYPE_INITIALIZEONLY))
      .addField(new field().setName("traceEnabled").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY))
      .addField(new field().setName("set_soundSpeedInWater").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("Sound speed in water default value 1500 m/s"))
      .addField(new field().setName("soundSpeedInWater").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Sound speed in water default value 1500 m/s")))
    .addChild(new ExternProtoDeclare("ViewPositionOrientation").setName("ViewPositionOrientation").setAppinfo("ViewPositionOrientation prototype provides local position and orientation as user navigates with optional console output").setUrl(new String[] {"../../../Savage/Tools/Authoring/ViewPositionOrientationPrototype.x3d#ViewPositionOrientation","https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/ViewPositionOrientationPrototype.x3d#ViewPositionOrientation","../../../Savage/Tools/Authoring/ViewPositionOrientationPrototype.wrl#ViewPositionOrientation","https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/ViewPositionOrientationPrototype.wrl#ViewPositionOrientation"})
      .addField(new field().setName("enabled").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("Whether or not ViewPositionOrientation sends output to console."))
      .addField(new field().setName("traceEnabled").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Output internal trace messages for debugging this node - developer use only can be ignored."))
      .addField(new field().setName("set_traceEnabled").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("Ability to turn output tracing on/off at runtime."))
      .addField(new field().setName("position_changed").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_OUTPUTONLY).setAppinfo("Output local position."))
      .addField(new field().setName("orientation_changed").setType(field.TYPE_SFROTATION).setAccessType(field.ACCESSTYPE_OUTPUTONLY).setAppinfo("Output local orientation."))
      .addField(new field().setName("outputViewpointString").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_OUTPUTONLY).setAppinfo("MFString value of new Viewpoint for example: <Viewpoint position=\"20 15 20\" orientation=\"-0.516 0.83 0.212 0.9195\"/>")))
    .addChild(new ExternProtoDeclare("WaypointInterpolator").setName("WaypointInterpolator").setAppinfo("Reads waypoints and legSpeeds/legDurations/defaultSpeed to provide a customizable position/orientation interpolator.").setUrl(new String[] {"../../../Savage/Tools/Animation/WaypointInterpolatorPrototype.x3d#WaypointInterpolator","https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/WaypointInterpolatorPrototype.x3d#WaypointInterpolator","../../../Savage/Tools/Animation/WaypointInterpolatorPrototype.wrl#WaypointInterpolator","https://www.web3d.org/x3d/content/examples/Savage/Tools/Animation/WaypointInterpolatorPrototype.wrl#WaypointInterpolator"})
      .addComments(" Priority of use: legSpeeds (m/sec), legDurations (seconds), defaultSpeed (m/sec) ")
      .addField(new field().setName("description").setType(field.TYPE_SFSTRING).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Short description of what is animated by this WaypointInterpolator."))
      .addField(new field().setName("waypoints").setType(field.TYPE_MFVEC3F).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Waypoints being traversed with interpolation of intermediate positions and orientations."))
      .addField(new field().setName("add_waypoint").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("Add another single waypoint to array of waypoints recalculate interpolator values."))
      .addField(new field().setName("set_waypoints").setType(field.TYPE_MFVEC3F).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("Replace all waypoints recalculate interpolator values."))
      .addField(new field().setName("pitchUpDownForVerticalWaypoints").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Whether to pitch child geometry (such as a vehicle) up or down to match vertical slope"))
      .addField(new field().setName("legSpeeds").setType(field.TYPE_MFFLOAT).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Units m/sec. If used array lengths for legSpeeds and legDurations must be one less than number of waypoints."))
      .addField(new field().setName("legDurations").setType(field.TYPE_MFTIME).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Units in seconds. If used array lengths for legSpeeds and legDurations must be one less than number of waypoints."))
      .addField(new field().setName("defaultSpeed").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Units m/sec."))
      .addField(new field().setName("turningRate").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("turningRate (degrees/second) also determines standoff distance prior to waypoint where turn commences. If 0 turns are instantaneous."))
      .addField(new field().setName("totalDuration").setType(field.TYPE_SFTIME).setAccessType(field.ACCESSTYPE_OUTPUTONLY).setAppinfo("Output calculation summing all leg durations, useful for setting TimeSensor cycleInterval. Units in seconds."))
      .addComments(" interpolation fields ")
      .addField(new field().setName("set_fraction").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("exposed PositionInterpolator and OrientationInterpolator setting"))
      .addField(new field().setName("position_changed").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_OUTPUTONLY).setAppinfo("exposed PositionInterpolator setting"))
      .addField(new field().setName("orientation_changed").setType(field.TYPE_SFROTATION).setAccessType(field.ACCESSTYPE_OUTPUTONLY).setAppinfo("exposed OrientationInterpolator setting"))
      .addComments(" display-related fields ")
      .addField(new field().setName("lineColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("default color for non-active line segments"))
      .addField(new field().setName("highlightSegmentColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("active segment highlight color"))
      .addField(new field().setName("transparency").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("1.0 is completely transparent, 0.0 is completely opaque."))
      .addField(new field().setName("labelDisplayMode").setType(field.TYPE_SFSTRING).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("allowed values: none; waypoints (produce labels at each waypoint); or interpolation (produce single moving label at interpolator time course speed location)"))
      .addField(new field().setName("heightLabel").setType(field.TYPE_SFSTRING).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("allowed values: altitude depth (negate Y value) none"))
      .addField(new field().setName("labelOffset").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("heightLabel relative location"))
      .addField(new field().setName("labelFontSize").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("heightLabel text size"))
      .addField(new field().setName("labelColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("heightLabel text color"))
      .addField(new field().setName("traceEnabled").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("enable console output to trace script computations and prototype progress"))
      .addField(new field().setName("outputInitializationComputations").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("Output the number of waypoints totalDistance and totalDuration to console upon initialization"))
      .addField(new field().setName("verticalDropLineColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("default color for vertical drop-line segments"))
      .addField(new field().setName("verticalDropLineTransparency").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("1.0 is completely transparent, 0.0 is completely opaque.")))
    .addComments(" ========== ")
    .addChild(new ProtoDeclare("BuoyCommunicationsGrid").setName("BuoyCommunicationsGrid").setAppinfo("BuoyCommunicationsGrid prototype takes a communication-message input from a traversing vehicle (such as an AUV or submarine) then sets up the route/relay time delays directions animation and visualization of SeaWeb buoy communications among each other all the way to the SeaWeb RACOM RF-relay buoy at the surface.")
      .setProtoInterface(new ProtoInterface()
        .addField(new field().setName("buoyArray").setType(field.TYPE_MFNODE).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("array of SeaWebBuoy nodes index starting at 0")
          .addComments(" Example: <ProtoInstance name='SeaWebBuoy' USE=\"SeaWebBuoy0\"/> <ProtoInstance name='SeaWebBuoy' USE=\"SeaWebBuoy1\"/> <ProtoInstance name='SeaWebBuoy' USE=\"SeaWebBuoy2\"/> "))
        .addField(new field().setName("buoyCommunicationsRoutingTable").setType(field.TYPE_MFINT32).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setValue(new int[] {-1,2,2,2,5,6,6,6,5,6,6,6,5,6,6,6,1,-1,3,3,5,6,7,7,5,6,7,7,5,6,7,7,2,2,-1,4,6,6,7,8,6,6,7,8,6,6,7,8,3,3,3,-1,7,7,7,8,7,7,7,8,7,7,7,8,1,2,2,2,-1,6,6,6,9,10,10,10,9,10,10,10,1,2,3,3,5,-1,7,7,9,10,11,11,9,10,11,11,2,2,3,4,6,6,-1,8,10,10,11,12,10,10,11,12,3,3,3,4,7,7,7,-1,11,11,11,12,11,11,11,12,5,6,6,6,5,6,6,6,-1,10,10,10,13,14,14,14,5,6,7,7,5,6,7,7,9,-1,11,11,13,14,15,15,6,6,7,8,6,6,7,8,10,10,-1,12,14,14,15,16,7,7,7,8,7,7,7,8,11,11,11,-1,15,15,15,16,9,10,10,10,9,10,10,10,9,10,10,10,-1,14,14,14,9,10,11,11,9,10,11,11,9,10,11,11,13,-1,15,15,10,10,11,12,10,10,11,12,10,10,11,12,14,14,-1,16,11,11,11,12,11,11,11,12,11,11,11,12,15,15,15,-1}).setAppinfo("2D array of routing connectivity for buoys consisting either of index of next buoy in line -1 for same buoy or else 0 for no route connection. legal values range [-1..n-1] for n buoys."))
        .addField(new field().setName("set_senderPosition").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("set position of entity sending the message"))
        .addField(new field().setName("senderPosition").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setValue(new SFVec3f(0.0,0.0,0.0)).setAppinfo("position of entity sending the message"))
        .addField(new field().setName("set_receiverPosition").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("set position of entity receiving the message"))
        .addField(new field().setName("receiverPosition").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setValue(new SFVec3f(0.0,0.0,0.0)).setAppinfo("position of entity receiving the message"))
        .addField(new field().setName("set_textMessage").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTONLY))
        .addField(new field().setName("textMessage").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INITIALIZEONLY))
        .addField(new field().setName("sendMessage").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("send it! (note: maybe should rename as 'activate')")))
      .setProtoBody(new ProtoBody()
        .addChild(new Script("BuoyCommunicationsGridScript").setDirectOutput(true).setSourceCode("""
ecmascript:

function alwaysPrint (text)
{
	Browser.println ('[BuoyCommunicationsGrid]' + text);
}
function tracePrint (text)
{
	if (traceEnabled) Browser.println ('[BuoyCommunicationsGrid]' + text);
}
function set_senderPosition (value, timestamp)
{
	senderPosition = value;
}
function set_receiverPosition (value, timestamp)
{
	receiverPosition = value;
}
function set_textMessage (value, timestamp)
{
	textMessage = value;
}
function distance (p1, p2) // inputs:  SFVec3f, output: float
{
	// square root of sum of sum of squares
	dx = (p1.x - p2.x);
	dy = (p1.y - p2.y);
	dz = (p1.z - p2.z);
	d = Math.sqrt (dx*dx + dy*dy + dz*dz);
//	tracePrint ('distance (' + p1 + ',' + p2 + ') =' + d);
	return d;
}
function timeSoundTravels (distance) // input: float meters, output: float seconds
{
	// speed of sound in water = 1500 m/s
	timeInterval = distance / 1500;
	tracePrint ('sound travels' + Math.round(distance) + ' meters in' +
	'timeInterval=' + Math.round(timeInterval*1000)/1000 + ' seconds');
	return timeInterval;
}
function routingTableIndex (senderNodeIndex, destinationNodeIndex)
{
	if ((     senderNodeIndex < 0) || (     senderNodeIndex >= buoyArray.length) ||
	    (destinationNodeIndex < 0) || (destinationNodeIndex >= buoyArray.length))
	   alwaysPrint ('routingTableIndex () error, input index out of bounds:  senderNodeIndex=' + senderNodeIndex +
	', destinationNodeIndex=' + destinationNodeIndex);
	newIndex = buoyArray.length*senderNodeIndex  + destinationNodeIndex;
	return newIndex;
}
function findClosestBuoyIndex (position)
{
	closestBuoyIndex = 0;  // initialize
	closestDistance  = distance (position, buoyArray[0].position);
//	tracePrint ('distance(position, buoyArray[0].position)=' + Math.round(closestDistance));
	if (buoyArray.length == 1) return closestBuoyIndex;

	for (i=1; i < buoyArray.length; i++) // start comparison loop at second buoy
	{
		d = distance (position, buoyArray[i].position);
	//	tracePrint ('distance(position, buoyArray[' + i + '].position)=' + d);
		if (d < closestDistance)
		{
			closestBuoyIndex = i;
			closestDistance  = d;
		//	tracePrint ('  closestBuoyIndex=' + closestBuoyIndex);
		}
	}
	tracePrint ('closest distance(position, buoyArray[' + closestBuoyIndex + '].position)=' + Math.round(closestDistance));
	return closestBuoyIndex;
}
function initialize ()
{
	n = buoyArray.length;
	tracePrint ('initialize() buoyArray.length=' + buoyArray.length);
	tracePrint ('initialize() buoyCommunicationsRoutingTable=' + buoyCommunicationsRoutingTable);
	tracePrint ('initialize() buoyCommunicationsRoutingTable.length=' + buoyCommunicationsRoutingTable.length);

	// check that routing table is a properly sized square array
	if (buoyCommunicationsRoutingTable.length != n*n)
	{
		alwaysPrint ('initialize() invalid buoyCommunicationsRoutingTable.length=' + buoyCommunicationsRoutingTable.length +
			   ', should = (' + n + '*' + n + ') =' + (n*n));
	}
	tracePrint ('initialize() square table check complete');
	// check for routing table loop from node to itself
	for (i=0; i < n; i++)
	{
	//	tracePrint ('initialize() buoyCommunicationsRoutingTable[routingTableIndex(' + i + ',' + i + ')]=' + buoyCommunicationsRoutingTable[routingTableIndex(i,i)] );
		if (buoyCommunicationsRoutingTable[routingTableIndex(i,i)] != -1)
		alwaysPrint ('initialize() invalid buoyCommunicationsRoutingTable[' + i + ']=' +
			             buoyCommunicationsRoutingTable[i] +
		' rather than -1, since node (' + i +
		') cannot route to itself');
	}
	tracePrint ('initialize() self route check complete');
	// check routing table values are legal
	for (i=0; i < n; i++)
	{
		for (j=0; j < n; j++)
		{
			k = buoyCommunicationsRoutingTable[routingTableIndex (i, j)];
		//	tracePrint ('initialize() routingTableIndex (' + i + ',' + j + ') =' + k);
			if ((buoyCommunicationsRoutingTable[k] < -1) ||
			    (buoyCommunicationsRoutingTable[k] >= buoyCommunicationsRoutingTable.length))
				alwaysPrint ('initialize() *** invalid buoyCommunicationsRoutingTable[' + i + ',' + j + ']=' +
				     buoyCommunicationsRoutingTable[k]);
		}
	}
	// TODO:  check for other routing table loops?

	tracePrint ('initialize() complete');
}
function sendMessage (value, timestamp)
{
	if (value != true)
	{
		if (value != false) tracePrint ('sendMessage() exiting, passed value=' + value);
		return;
	}
	// run-time setup happens here!   execution of all buoys occurs upon returning.
	// prepare the scene graph for a message sequence, then start it.

	// first find shortest distances and thus closest buoys to sender and receiver
	senderNodeIndex      = findClosestBuoyIndex(senderPosition);
	destinationNodeIndex = findClosestBuoyIndex(receiverPosition);
	tracePrint ('     senderNodeIndex=' +      senderNodeIndex + ' (' + senderPosition   + ')');
	tracePrint ('destinationNodeIndex=' + destinationNodeIndex + ' (' + receiverPosition + ')');

	// TODO:  sound beam from sender to senderNode or receiver (whichever is closest)

	if (senderNodeIndex == destinationNodeIndex)
	{
		tracePrint ('senderNode and destinationNode are the same, no message sent');
		tracePrint ('=============================================');
		return;
	}
	transmissionDuration  = 1;
	tracePrint ('transmissionDuration=' + transmissionDuration);

	// compute path (sequence of buoy IDs) from closest buoy to SeaWeb buoy
	// compute full buoy-to-buoy routing paths for current sender-receiver combination

	hopCount = 0;
	maxHopCount = buoyArray.length - 1;
	nextNodeIndex = -2;
	nodePath = new MFInt32();
	nodePath[nodePath.length] = senderNodeIndex;
	nodePathString ='sender, buoys' + senderNodeIndex;
	currentNodeIndex = senderNodeIndex;

	d  = distance (senderPosition, buoyArray[senderNodeIndex].position);
	dt = timeSoundTravels (d);
	accumulatedRange = d;
	accumulatedDelay = 2 * (dt + transmissionDuration);
	tracePrint ('distance=' + Math.round(d) + ', accumulatedRange=' + Math.round(accumulatedRange)
		+ ', accumulatedDelay=' + Math.round(accumulatedDelay*1000)/1000);

	while ((nextNodeIndex != -1) && (hopCount <= maxHopCount))
	{
		tracePrint ('=====');
		tableIndex = routingTableIndex (currentNodeIndex, destinationNodeIndex);
		nextNodeIndex = buoyCommunicationsRoutingTable[tableIndex];
		tracePrint ('currentNodeIndex=' + currentNodeIndex + ', nextNodeIndex=' + nextNodeIndex + ', tableIndex=' + tableIndex);

		// check if dead end - incomplete communication path
		if (nextNodeIndex < 0)
		{
			alwaysPrint ('*** hit a dead end! no further routing possible.');
			return nextNodeIndex;
			// consider not animating any buoys, i.e. whether or not partial routing allowed
		}
		hopCount++;
	//	tracePrint ('hopCount=' + hopCount + ', maxHopCount=' + maxHopCount);

		// communicate from currentNodeIndex buoy to nextNodeIndex buoy
		// by sending initialization values to each buoy in path:
		// message, target buoy ID/position, and then compute distance/time to travel
		// to set time delay of each buoy prior to start of each transmission.

		buoyArray[currentNodeIndex].textMessage = textMessage;
		buoyArray[currentNodeIndex].targetIdNumber = nextNodeIndex;
		buoyArray[currentNodeIndex].targetPosition = buoyArray[nextNodeIndex].position;
		d  = distance (	buoyArray[currentNodeIndex].position, buoyArray[nextNodeIndex].position);
		dt = timeSoundTravels (d);
		accumulatedRange += d;
		accumulatedDelay += 2 * (dt + transmissionDuration);
		buoyArray[currentNodeIndex].range  = d;
		buoyArray[currentNodeIndex].transmissionDuration  = transmissionDuration;
		buoyArray[currentNodeIndex].transmissionTimeDelay = accumulatedDelay;
		buoyArray[currentNodeIndex].set_activated = true;

		// set up for next time through loop:
		currentNodeIndex = nextNodeIndex;
		nodePath[nodePath.length] = nextNodeIndex;
		nodePathString +=',' + nextNodeIndex;
		tracePrint ('distance=' + Math.round(d) + ', accumulatedRange=' + Math.round(accumulatedRange)
			+ ', accumulatedDelay=' + Math.round(accumulatedDelay*1000)/1000);

		if (nextNodeIndex == destinationNodeIndex) break;
	}
	tracePrint ('====='); // last node to destination follows
	tracePrint ('destinationNodeIndex=' + destinationNodeIndex + ' to receiver');
	buoyArray[currentNodeIndex].textMessage = textMessage;
	buoyArray[currentNodeIndex].targetIdNumber = -2;
	buoyArray[currentNodeIndex].targetPosition = receiverPosition;
	d  = distance (	buoyArray[destinationNodeIndex].position, receiverPosition);
	dt = timeSoundTravels (d);
	accumulatedRange += d;
	accumulatedDelay += 2 * (dt + transmissionDuration);
	buoyArray[currentNodeIndex].range  = d;
	buoyArray[currentNodeIndex].transmissionDuration  = transmissionDuration;
	buoyArray[destinationNodeIndex].transmissionTimeDelay = accumulatedDelay ;
	buoyArray[destinationNodeIndex].set_activated = true;

	tracePrint ('distance=' + Math.round(d) + ', accumulatedRange=' + Math.round(accumulatedRange)
		+ ', accumulatedDelay=' + Math.round(accumulatedDelay*1000)/1000);

	tracePrint ('=====');
	tracePrint ('path destination found, buoy hopCount=' + hopCount + ', nodePath=' + nodePathString + ', receiver');
	for (i=0; i < nodePath.length; i++)
	{
		j = nodePath[i];
		tracePrint ('node=' + nodePath[i]
			+ ', buoyArray[' + nodePath[i] + '].transmissionTimeDelay=' + Math.round(buoyArray[nodePath[i]].transmissionTimeDelay*1000)/1000);
	}
	tracePrint ('=============================================');

	// TODO: do we need to trigger the RACOM radio at this point?
}
""")
          .addField(new field().setName("buoyArray").setType(field.TYPE_MFNODE).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("array of SeaWebBuoy nodes index starting at 0")
            .addComments(" Example: <ProtoInstance name='SeaWebBuoy' USE=\"SeaWebBuoy0\"/> <ProtoInstance name='SeaWebBuoy' USE=\"SeaWebBuoy1\"/> <ProtoInstance name='SeaWebBuoy' USE=\"SeaWebBuoy2\"/> "))
          .addField(new field().setName("buoyCommunicationsRoutingTable").setType(field.TYPE_MFINT32).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("2D array of routing connectivity for buoys -1 for no connection range [0..n-1] for n buoys."))
          .addField(new field().setName("set_senderPosition").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("set position of entity sending the message"))
          .addField(new field().setName("senderPosition").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("position of entity sending the message"))
          .addField(new field().setName("set_receiverPosition").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("set position of entity receiving the message"))
          .addField(new field().setName("receiverPosition").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("position of entity receiving the message"))
          .addField(new field().setName("set_textMessage").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTONLY))
          .addField(new field().setName("textMessage").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INITIALIZEONLY))
          .addField(new field().setName("sendMessage").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INPUTONLY).setAppinfo("send it!"))
          .addField(new field().setName("traceEnabled").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setValue(true))
          .setIS(new IS()
            .addConnect(new connect().setNodeField("buoyArray").setProtoField("buoyArray"))
            .addConnect(new connect().setNodeField("buoyCommunicationsRoutingTable").setProtoField("buoyCommunicationsRoutingTable"))
            .addConnect(new connect().setNodeField("set_senderPosition").setProtoField("set_senderPosition"))
            .addConnect(new connect().setNodeField("senderPosition").setProtoField("senderPosition"))
            .addConnect(new connect().setNodeField("set_receiverPosition").setProtoField("set_receiverPosition"))
            .addConnect(new connect().setNodeField("receiverPosition").setProtoField("receiverPosition"))
            .addConnect(new connect().setNodeField("set_textMessage").setProtoField("set_textMessage"))
            .addConnect(new connect().setNodeField("textMessage").setProtoField("textMessage"))
            .addConnect(new connect().setNodeField("sendMessage").setProtoField("sendMessage"))))))
    .addComments(" ========== ")
    .addComments(" Viewable geometry for this scene is anchored text that links to an example showing ExternProtoDeclare usage of a BuoyCommunicationsGridPrototype. ")
    .addChild(new WorldInfo().setInfo(new String[] {"A BuoyCommunicationsGrid prototype"}).setTitle("BuoyCommunicationsGridPrototype"))
    .addChild(new Viewpoint().setDescription("BuoyCommunicationsGrid prototype definition").setPosition(0.0,0.0,15.0))
    .addChild(new Anchor().setDescription("BuoyCommunicationsGrid Example").setUrl(new String[] {"BuoyCommunicationsGridExample.x3d","../../../Savage/CommunicationsAndSensors/SeaWeb/BuoyCommunicationsGridExample.x3d","https://www.web3d.org/x3d/content/examples/Savage/CommunicationsAndSensors/SeaWeb/BuoyCommunicationsGridExample.x3d","BuoyCommunicationsGridExample.wrl","../../../Savage/CommunicationsAndSensors/SeaWeb/BuoyCommunicationsGridExample.wrl","https://www.web3d.org/x3d/content/examples/Savage/CommunicationsAndSensors/SeaWeb/BuoyCommunicationsGridExample.wrl"})
      .addChild(new Shape()
        .setAppearance(new Appearance()
          .setMaterial(new Material().setDiffuseColor(0.0,1.0,1.0).setEmissiveColor(0.0,1.0,1.0)))
        .setGeometry(new Text().setString(new String[] {"BuoyCommunicationsGridPrototype","is a Prototype definition file.","","To see an example scene","click this text and view","BuoyCommunicationsGridExample."})
          .setFontStyle(new FontStyle().setJustify(FontStyle.JUSTIFY_MIDDLE_MIDDLE))))));
            }
            catch (Exception ex)
            {       
                System.err.println ("*** Further hints on X3DJSAIL errors and exceptions at");
                System.err.println ("*** https://www.web3d.org/specifications/java/X3DJSAIL.html");
                throw (ex);
            }
	}
	// end of initialize() method

	/** The initialized model object, created within initialize() method. */
	private X3D x3dModel;

	/** 
	 * Provide a 
	 * <a href="https://dzone.com/articles/java-copy-shallow-vs-deep-in-which-you-will-swim" target="_blank">shallow copy</a>
	 * of the X3D model.
	 * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Core/X3D.html">X3D</a>
	 * @return BuoyCommunicationsGridPrototype model
	 */
	public X3D getX3dModel()
	{	  
		return x3dModel;
	}
	   
    /** 
     * Default main() method provided for test purposes, uses CommandLine to set global ConfigurationProperties for this object.
     * @param args array of input parameters, provided as arguments
     * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Core/X3D.html#handleArguments-java.lang.String:A-">X3D.handleArguments(args)</a>
     * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Core/X3D.html#validationReport--">X3D.validationReport()</a>
     * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/CommandLine.html">CommandLine</a>
     * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/CommandLine.html#USAGE">CommandLine.USAGE</a>
     * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/ConfigurationProperties.html">ConfigurationProperties</a>
     */
    public static void main(String args[])
    {
        System.out.println("Build this X3D model, showing validation diagnostics...");
        X3D thisExampleX3dModel = new BuoyCommunicationsGridPrototype().getX3dModel();
//      System.out.println("X3D model construction complete.");
	
        // next handle command line arguments
        boolean hasArguments = (args != null) && (args.length > 0);
        boolean validate = true; // default
        boolean argumentsLoadNewModel = false;
        String  fileName = new String();

        if (args != null)
        {
                for (String arg : args)
                {
                        if (arg.toLowerCase().startsWith("-v") || arg.toLowerCase().contains("validate"))
                        {
                                validate = true; // making sure
                        }
                        if (arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_X3D) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_CLASSICVRML) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_X3DB) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_VRML97) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_EXI) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_GZIP) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_ZIP) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_HTML) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_XHTML))
                        {
                                argumentsLoadNewModel = true;
                                fileName = arg;
                        }
                }
        }
        if      (argumentsLoadNewModel)
                System.out.println("WARNING: \"Savage.CommunicationsAndSensors.SeaWeb.BuoyCommunicationsGridPrototype\" model invocation is attempting to load file \"" + fileName + "\" instead of simply validating itself... file loading ignored.");
        else if (hasArguments) // if no arguments provided, this method produces usage warning
                thisExampleX3dModel.handleArguments(args);
	
        if (validate)
        {
            //  System.out.println("--- TODO fix duplicated outputs ---"); // omit when duplicated outputs problem is solved/refactored
		String validationResults = thisExampleX3dModel.validationReport();
            //  System.out.println("-----------------------------------"); // omit when duplicated outputs problem is solved/refactored
                System.out.print("Savage.CommunicationsAndSensors.SeaWeb.BuoyCommunicationsGridPrototype self-validation test confirmation: ");
                if (!validationResults.equals("success"))
                    System.out.println();
                System.out.println(validationResults.trim());

                // experimental: test X3DJSAIL output files
                // CommunicationsAndSensors/SeaWeb/BuoyCommunicationsGridPrototype_JavaExport.* file validation is checked when building X3D Example Archives
                String filenameX3D  = "CommunicationsAndSensors/SeaWeb/BuoyCommunicationsGridPrototype_JavaExport.x3d"; 
                String filenameX3DV = "CommunicationsAndSensors/SeaWeb/BuoyCommunicationsGridPrototype_JavaExport.x3dv"; 
                String filenameJSON = "CommunicationsAndSensors/SeaWeb/BuoyCommunicationsGridPrototype_JavaExport.json";
                thisExampleX3dModel.toFileX3D        (filenameX3D);
                thisExampleX3dModel.toFileClassicVRML(filenameX3DV);
// TODO         thisExampleX3dModel.toFileJSON       (filenameJSON);
        }
    }
}
